OSDN Git Service

rename database_ids & some variables in order to understand easily
[amulettoolsmh4/main.git] / amulettool.py
index 565d39d..3f8d6a5 100644 (file)
@@ -16,7 +16,7 @@ import view
 import model
 
 SETTING_FILE = u"settings"
-SETTING_THRESHOLD = u"threshold"
+SETTING_THRESHOLD1 = u"threshold1"
 SETTING_SKILLS = u"skills"
 
 def _get_base_dir():
@@ -151,28 +151,28 @@ class AmuletToolController(wx.App):
 
     def _set_skill_list_from_amulet(self, amulet_id):
         u""" お守り種類の選択が変わった時の動作 """
-        skill_selected = []
         for i, (combo, skill_dict) in enumerate(zip(
                 [self.frame_view.combo_box_amulet_search_skill1, 
                     self.frame_view.combo_box_amulet_search_skill2], 
                 [self._amulet_id2skill1_id_dict, self._amulet_id2skill2_id_dict]
                 )):
+            skill_ids = skill_dict[amulet_id]
             combo.Clear()
             if i == 1:
                 combo.Append(view.VAL_NO_SKILL)
-            skill_ids = skill_dict[amulet_id]
+            else:
+                skill1_selected = skill_ids[0]
             for skill_id in skill_ids:
                 combo.Append(self._skill_id2name_dict[skill_id])
-            skill_selected.append(skill_ids[i])
             combo.SetSelection(0)   # combo1 = skill1, combo2 = No Skill
-        self._set_spin_range(amulet_id, skill_selected[0], skill_selected[1])
+        self._set_spin_range(amulet_id, skill1_selected, None)
 
     def _set_spin_views(self):
         u""" Spin Ctrlの最大最小をセット"""
         min1, max1, min2, max2 = self.db_accessor.get_skill_minmax()
         self.frame_view.spin_ctrl_amulet_search_slot_num.SetRange(view.SLOT_MIN, view.SLOT_MAX)
-        self.frame_view.spin_ctrl_highlight.SetRange(view.THRESHOLD2_MIN, view.THRESHOLD2_MAX)
-        self.frame_view.spin_ctrl_highlight.SetValue(self._highlight_threshold)
+        self.frame_view.spin_ctrl_highlight.SetRange(view.THRESHOLD1_MIN, view.THRESHOLD1_MAX)
+        self.frame_view.spin_ctrl_highlight.SetValue(self._highlight_threshold1)
 
     def _set_check_list_views(self):
         u""" CheckListBoxの値のセット """
@@ -210,6 +210,7 @@ class AmuletToolController(wx.App):
         seed_sets = self.db_accessor.select_seeds(amu_id2skill_id_list_dict)
         self.frame_view.text_ctrl_seed_result.SetValue(u"""Seedの候補は{0}個です。""".format(len(seed_sets)))
 
+        self.frame_view.list_box_seed.Clear()
         if len(seed_sets) > 0:
             for seed in seed_sets:
                 self.frame_view.list_box_seed.Append(u"{0}".format(seed))
@@ -238,7 +239,7 @@ class AmuletToolController(wx.App):
         seed = self.frame_view.text_ctrl_seed_select.GetValue()
         if seed.isdigit():
             seed = int(seed)
-            skill_dict, threshold2_dict = self.db_accessor.select_skills_from_seeds([seed])
+            skill_dict, threshold1_dict = self.db_accessor.select_skills_from_seeds([seed])
 
             try:
                 text_ctrl_dict = self.frame_view.text_ctrl_seed_skill_dict
@@ -247,8 +248,8 @@ class AmuletToolController(wx.App):
                     amu_id = self._amulet_name2id_dict[amu_name]
                     for txt_ctr, skill_id in zip(text_ctrl_dict[amu_key], skill_dict[amu_id][seed]):
                         txt_ctr.SetValue(self._skill_id2name_dict[skill_id])
-                for txt_ctr, threshold2 in zip(text_ctrl_dict[view.KEY_THRESHOLD2], threshold2_dict[seed]):
-                    txt_ctr.SetValue(u"{0}".format(threshold2))
+                for txt_ctr, threshold1 in zip(text_ctrl_dict[view.KEY_THRESHOLD1], threshold1_dict[seed]):
+                    txt_ctr.SetValue(u"{0}".format(threshold1))
                 self._update_highlight()
 
             except KeyError, e:
@@ -264,7 +265,7 @@ class AmuletToolController(wx.App):
             amu_id = self._amulet_name2id_dict[amu_name]
             for txt_ctr in text_ctrl_dict[amu_key]:
                 txt_ctr.Clear()
-        for txt_ctr in text_ctrl_dict[view.KEY_THRESHOLD2]:
+        for txt_ctr in text_ctrl_dict[view.KEY_THRESHOLD1]:
             txt_ctr.Clear()
         self.frame_view.list_box_seed_skill_amulet_prospect.Clear() 
 
@@ -300,7 +301,6 @@ class AmuletToolController(wx.App):
             raise IndexError(u"amulet id is unknown")
         self._set_spin_range(amu_id, skill1_id, skill2_id)
 
-
     def OnClickAmuletSearch(self, evt):
         u""" search seeds from amulet condition """
         skill1_name = self.frame_view.combo_box_amulet_search_skill1.GetStringSelection()
@@ -372,7 +372,7 @@ class AmuletToolController(wx.App):
 
     def OnClickSettingOK(self, evt):
         u""" get settings of setting tab """
-        self._highlight_threshold = self.frame_view.spin_ctrl_highlight.GetValue()
+        self._highlight_threshold1 = self.frame_view.spin_ctrl_highlight.GetValue()
         self._highlight_skills = set([self._skill_name2id_dict[x] for x in 
                 self.frame_view.check_list_box_highlight_skill.GetCheckedStrings()
                 if x in self._skill_name2id_dict])
@@ -380,8 +380,8 @@ class AmuletToolController(wx.App):
 
     def OnClickSettingClear(self, evt):
         u""" reset settings of setting tab """
-        self._highlight_threshold = view.HIGHLIGHT_THRESHOLD
-        self.frame_view.spin_ctrl_highlight.SetValue(view.HIGHLIGHT_THRESHOLD)
+        self._highlight_threshold1 = view.HIGHLIGHT_THRESHOLD1
+        self.frame_view.spin_ctrl_highlight.SetValue(view.HIGHLIGHT_THRESHOLD1)
         self._highlight_skills = set()
         for idx in self.frame_view.check_list_box_highlight_skill.GetChecked():
             self.frame_view.check_list_box_highlight_skill.Check(idx, False)
@@ -398,9 +398,9 @@ class AmuletToolController(wx.App):
                     text_ctrl.SetBackgroundColour("Yellow")
                 else:
                     text_ctrl.SetBackgroundColour(wx.NullColor)
-        for text_ctrl in text_dict[view.KEY_THRESHOLD2]:
+        for text_ctrl in text_dict[view.KEY_THRESHOLD1]:
             val = text_ctrl.GetValue()
-            if val.isdigit() and int(val) >= self._highlight_threshold:
+            if val.isdigit() and int(val) >= self._highlight_threshold1:
                 text_ctrl.SetBackgroundColour("Yellow")
             else:
                 text_ctrl.SetBackgroundColour(wx.NullColor)
@@ -446,7 +446,7 @@ class AmuletToolController(wx.App):
 
     def _write_settings(self):
         with open(SETTING_FILE, mode="w") as f:
-            data = {SETTING_THRESHOLD:self._highlight_threshold
+            data = {SETTING_THRESHOLD1:self._highlight_threshold1
                     SETTING_SKILLS:self._highlight_skills}
             pickle.dump(data, f)
 
@@ -455,13 +455,13 @@ class AmuletToolController(wx.App):
             with open(SETTING_FILE, mode="r") as f:
                 try:
                     data = pickle.load(f)
-                    self._highlight_threshold = data[SETTING_THRESHOLD
+                    self._highlight_threshold1 = data[SETTING_THRESHOLD1
                     self._highlight_skills = data[SETTING_SKILLS]
                 except EOFError, e:
-                    self._highlight_threshold = view.HIGHLIGHT_THRESHOLD
+                    self._highlight_threshold1 = view.HIGHLIGHT_THRESHOLD1
                     self._highlight_skills = set()
         else:
-            self._highlight_threshold = view.HIGHLIGHT_THRESHOLD
+            self._highlight_threshold1 = view.HIGHLIGHT_THRESHOLD1
             self._highlight_skills = set()
 
 if __name__ == "__main__":