OSDN Git Service

implemet almost gui events
authorkei9 <kei9@users.sourceforge.jp>
Fri, 6 Dec 2013 12:30:56 +0000 (21:30 +0900)
committerkei9 <kei9@users.sourceforge.jp>
Fri, 6 Dec 2013 12:30:56 +0000 (21:30 +0900)
.gitignore
amulettool.py
model/db_accessor.py
model/db_supports.py
view/constnumbers.py
view/mainframe.xrc
view/mainframeview.py

index 302010d..543e624 100644 (file)
@@ -2,3 +2,4 @@
 *.swp
 *.sqlite3
 *.bak
 *.swp
 *.sqlite3
 *.bak
+settings
index d145fa3..f1143ad 100644 (file)
@@ -6,23 +6,34 @@
 import threading
 import time
 import os.path
 import threading
 import time
 import os.path
+import pickle
+import sqlite3
 
 import wx
 
 import view
 import model
 
 
 import wx
 
 import view
 import model
 
+SETTING_FILE = u"settings"
+SETTING_THRESHOLD = u"threshold"
+SETTING_SKILLS = u"skills"
 
 class AmuletToolController(wx.App):
     u""" アプリケーションの制御クラス """
     def OnInit(self):
 
 class AmuletToolController(wx.App):
     u""" アプリケーションの制御クラス """
     def OnInit(self):
+        self._read_settings()
         self.frame_view = view.MainFrameView("view")
         self.frame_view = view.MainFrameView("view")
-        
+
         self._init_events()
 
         self.frame_view.Show()
 
         self._init_events()
 
         self.frame_view.Show()
 
+        self.frame_view.DisableNoteBook()
+
         self._init_database()
         self._init_database()
+        self._set_views()
+
+        self.frame_view.EnableNoteBook()
         return True
 
     def _init_events(self):
         return True
 
     def _init_events(self):
@@ -32,6 +43,28 @@ class AmuletToolController(wx.App):
         # menu event
         frame.Bind(wx.EVT_MENU, self.OnClose, id=self.frame_view.ID_MENU_ITEM_EXIT)
         frame.Bind(wx.EVT_MENU, self.OnAboutBox, id=self.frame_view.ID_MENU_ITEM_ABOUT)
         # menu event
         frame.Bind(wx.EVT_MENU, self.OnClose, id=self.frame_view.ID_MENU_ITEM_EXIT)
         frame.Bind(wx.EVT_MENU, self.OnAboutBox, id=self.frame_view.ID_MENU_ITEM_ABOUT)
+        frame.Bind(wx.EVT_CLOSE, self.CloseHandler)
+
+        # button event
+        frame.Bind(wx.EVT_BUTTON, self.OnClickSeedSearch, id=self.frame_view.ID_BUTTON_SEED_SEARCH)
+        frame.Bind(wx.EVT_BUTTON, self.OnClickSeedClear, id=self.frame_view.ID_BUTTON_SEED_CLEAR)
+        frame.Bind(wx.EVT_BUTTON, self.OnClickSkillSearchFromSeed, id=self.frame_view.ID_BUTTON_SKILL_FROM_SEED_SEARCH)
+        frame.Bind(wx.EVT_BUTTON, self.OnClickSkillSearch, id=self.frame_view.ID_BUTTON_SKILL_SEARCH)
+        frame.Bind(wx.EVT_BUTTON, self.OnClickSkillClear, id=self.frame_view.ID_BUTTON_SKILL_CLEAR)
+        frame.Bind(wx.EVT_BUTTON, self.OnClickAmuletSearch, id=self.frame_view.ID_BUTTON_AMULET_SEARCH_SEARCH)
+        frame.Bind(wx.EVT_BUTTON, self.OnClickAmuletClear, id=self.frame_view.ID_BUTTON_AMULET_SEARCH_CLEAR)
+        frame.Bind(wx.EVT_BUTTON, self.OnClickSkillSearchFromAmulet, id=self.frame_view.ID_BUTTON_AMULET_SEARCH_SKILL)
+        frame.Bind(wx.EVT_BUTTON, self.OnClickSettingOK, id=self.frame_view.ID_BUTTON_SETTING_OK)
+        frame.Bind(wx.EVT_BUTTON, self.OnClickSettingClear, id=self.frame_view.ID_BUTTON_SETTING_CLEAR)
+
+        # radio button event
+        frame.Bind(wx.EVT_RADIOBUTTON, self.OnClickAmuletRadio, id=self.frame_view.ID_RADIO_BUTTON_AMULET1)
+        frame.Bind(wx.EVT_RADIOBUTTON, self.OnClickAmuletRadio, id=self.frame_view.ID_RADIO_BUTTON_AMULET2)
+        frame.Bind(wx.EVT_RADIOBUTTON, self.OnClickAmuletRadio, id=self.frame_view.ID_RADIO_BUTTON_AMULET3)
+
+        # combo box event
+        frame.Bind(wx.EVT_COMBOBOX, self.OnClickAmuletCombo, id=self.frame_view.ID_COMBO_BOX_AMULET_SEARCH_SKILL1)
+        frame.Bind(wx.EVT_COMBOBOX, self.OnClickAmuletCombo, id=self.frame_view.ID_COMBO_BOX_AMULET_SEARCH_SKILL2)
 
     def _init_database(self):
         u""" DBの初期設定 """
 
     def _init_database(self):
         u""" DBの初期設定 """
@@ -39,31 +72,346 @@ class AmuletToolController(wx.App):
         if not os.path.exists(model.DB_FILE_NAME):
             u""" DBが存在しない時は再生成する """
             frame = self.frame_view.frame
         if not os.path.exists(model.DB_FILE_NAME):
             u""" DBが存在しない時は再生成する """
             frame = self.frame_view.frame
-            generator = model.DataBaseGenerator(model.DB_FILE_NAME)
-            #generator = model.DataBaseGenerator()
-
-            dlg_view = view.GaugeDialogView("view")
-            def _loop():
-                while t1.is_alive():
-                    dlg_view.gauge.Pulse()
-                    time.sleep(0.2)
-                dlg_view.finish_generation()
-
-            t1 = threading.Thread(target=generator.generate_db)
-            t2 = threading.Thread(target=_loop)
-            t1.start()
-            t2.start()
-
-            dlg_view.ShowModal()
-            t1.join()
-            t2.join()
-            dlg_view.Destroy()
+            try:
+                generator = model.DataBaseGenerator(model.DB_FILE_NAME)
+                #generator = model.DataBaseGenerator()
+
+                dlg_view = view.GaugeDialogView("view")
+                def _loop():
+                    while t1.is_alive():
+                        dlg_view.gauge.Pulse()
+                        time.sleep(0.2)
+                    dlg_view.finish_generation()
+
+                t1 = threading.Thread(target=generator.generate_db)
+                t2 = threading.Thread(target=_loop)
+                t1.start()
+                t2.start()
+
+                dlg_view.ShowModal()
+                t1.join()
+                t2.join()
+                dlg_view.Destroy()
+            except sqlite3.Error as e:
+                self._show_error_dialog(u"データベース生成中にエラーが発生しました")
 
         # access to db
 
         # access to db
-        db_accessor = model.DataBaseAccessor(model.DB_FILE_NAME)
+        try:
+            self.db_accessor = model.DataBaseAccessor(model.DB_FILE_NAME)
+        except sqlite3.Error as e:
+            self._show_error_dialog(u"データベースが壊れています")
+
+        # get dictionaries
+        (self._skill_id2name_dict, 
+            self._skill_name2id_dict,
+            self._amulet_id2name_dict, 
+            self._amulet_name2id_dict,
+            self._amulet_id2skill1_id_dict,
+            self._amulet_id2skill2_id_dict) = self.db_accessor.get_dicts()
+
+
+    def _set_views(self):
+        u""" GUIにDBの各種値をセットする """
+        self._set_combo_views()
+        self._set_spin_views()
+        self._set_check_list_views()
+
+    def _set_combo_views(self):
+        u""" ComboBoxの値をセットする """
+        combo_dict = self.frame_view.combo_box_skill_dict
+
+        u" 各種お守りの第2スキル選択 "
+        for amu_key, amu_name in zip([view.KEY_AMULET1, view.KEY_AMULET2, view.KEY_AMULET3], 
+                [view.NAME_AMULET1, view.NAME_AMULET2, view.NAME_AMULET3]):
+            amu_id = self._amulet_name2id_dict[amu_name]
+            skill_ids = self._amulet_id2skill2_id_dict[amu_id]
+            skill_names = [self._skill_id2name_dict[x] for x in skill_ids]
+            for combo in combo_dict[amu_key]:
+                combo.Clear()
+                combo.Append(u"なし")
+                for name in skill_names:
+                    combo.Append(name)
+                combo.SetSelection(0)
+
+        # amulet search
+        amu_id = self._amulet_name2id_dict[view.NAME_AMULET1]
+        self._set_skill_list_from_amulet(amu_id)
+        self.frame_view.amulet2radio_button_dict[view.NAME_AMULET1].SetValue(True)
+
+    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]
+                )):
+            combo.Clear()
+            skill_ids = skill_dict[amulet_id]
+            for skill_id in skill_ids:
+                combo.Append(self._skill_id2name_dict[skill_id])
+            skill_selected.append(skill_ids[i])
+            combo.SetSelection(i)
+        self._set_spin_range(amulet_id, skill_selected[0], skill_selected[1])
+
+    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)
+
+    def _set_check_list_views(self):
+        u""" CheckListBoxの値のセット """
+        checklist = self.frame_view.check_list_box_highlight_skill
+        checklist.SetItems(self._skill_name2id_dict.keys())
+        checklist.SetCheckedStrings([self._skill_id2name_dict[x] for x in self._highlight_skills])
+
+    def _set_spin_range(self, amulet_id, skill1_id, skill2_id):
+        u""" スキルに応じてSpinCtrlの最大最小をセットする """
+        minmax_dict = self.db_accessor.select_minmax_from_skill_ids(amulet_id, [skill1_id, skill2_id])
+        min1, max1 = minmax_dict[skill1_id][0], minmax_dict[skill1_id][1]
+        min2, max2 = minmax_dict[skill2_id][2], minmax_dict[skill2_id][3]
+        self.frame_view.spin_ctrl_amulet_search_skill1_val.SetRange(min1, max1)
+        self.frame_view.spin_ctrl_amulet_search_skill2_val.SetRange(min2, max2)
+
+    def OnClickSeedSearch(self, evt):
+        u""" search seeds from selected skills """
+        amu_id2skill_id_list_dict = {}
+        for amu_key, amu_name in zip([view.KEY_AMULET1, view.KEY_AMULET2, view.KEY_AMULET3], 
+                [view.NAME_AMULET1, view.NAME_AMULET2, view.NAME_AMULET3]):
+            amu_id = self._amulet_name2id_dict[amu_name]
+            ls = []
+            for combo in self.frame_view.combo_box_skill_dict[amu_key]:
+                name = combo.GetStringSelection()
+                if name not in self._skill_name2id_dict:
+                    ls.append(None)
+                else:
+                    ls.append(self._skill_name2id_dict[name])
+            amu_id2skill_id_list_dict[amu_id] = ls
+        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)))
 
 
+        if len(seed_sets) > 0:
+            for seed in seed_sets:
+                self.frame_view.list_box_seed.Append(u"{0}".format(seed))
+            self.frame_view.list_box_seed.SetSelection(0)
+            self.frame_view.button_skill_from_seed_search.Enable()
 
 
+    def OnClickSeedClear(self, evt):
+        u""" reset seed search settings of combo box"""
+        combo_dict = self.frame_view.combo_box_skill_dict
+        for amu_key in [view.KEY_AMULET1, view.KEY_AMULET2, view.KEY_AMULET3]:
+            for combo in combo_dict[amu_key]:
+                combo.SetSelection(0)
+        self.frame_view.button_skill_from_seed_search.Disable()
+        self.frame_view.list_box_seed.Clear()
 
 
+    def OnClickSkillSearchFromSeed(self, evt):
+        u""" change page to skill search from seed"""
+        seed = self.frame_view.list_box_seed.GetStringSelection()
+        if seed.isdigit():
+            self.frame_view.text_ctrl_seed_select.SetValue(seed)
+            self.frame_view.note_book.SetSelection(view.SKILL_SEARCH_PAGE)
+            self.OnClickSkillSearch(evt)
+
+    def OnClickSkillSearch(self, evt):
+        u""" skill search from seed"""
+        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])
+
+            try:
+                text_ctrl_dict = self.frame_view.text_ctrl_seed_skill_dict
+                for amu_key, amu_name in zip([view.KEY_AMULET1, view.KEY_AMULET2, view.KEY_AMULET3], 
+                    [view.NAME_AMULET1, view.NAME_AMULET2, view.NAME_AMULET3]):
+                    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))
+                self._update_highlight()
+
+            except KeyError, e:
+                self._show_message_dialog(message=u"指定されたSeed値は存在しません")
+        else:
+            self._show_message_dialog(message=u"Seed値には数字を入力してください")
+
+    def OnClickSkillClear(self, evt):
+        u""" clear skills from seed """
+        text_ctrl_dict = self.frame_view.text_ctrl_seed_skill_dict
+        for amu_key, amu_name in zip([view.KEY_AMULET1, view.KEY_AMULET2, view.KEY_AMULET3], 
+            [view.NAME_AMULET1, view.NAME_AMULET2, view.NAME_AMULET3]):
+            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]:
+            txt_ctr.Clear()
+        self.frame_view.list_box_seed_skill_amulet_prospect.Clear() 
+
+    def OnClickAmuletRadio(self, evt):
+        u""" switch skill lists by amulet id """
+        btn_id = evt.GetId()
+        if btn_id == self.frame_view.ID_RADIO_BUTTON_AMULET1:
+            amu_id = self._amulet_name2id_dict[view.NAME_AMULET1]
+        elif btn_id == self.frame_view.ID_RADIO_BUTTON_AMULET2:
+            amu_id = self._amulet_name2id_dict[view.NAME_AMULET2]
+        elif btn_id == self.frame_view.ID_RADIO_BUTTON_AMULET3:
+            amu_id = self._amulet_name2id_dict[view.NAME_AMULET3]
+        else:
+            return
+        self._set_skill_list_from_amulet(amu_id)
+
+    def OnClickAmuletCombo(self, evt):
+        u""" switch skill minmax by amulet id and skill_id"""
+        skill1_name = self.frame_view.combo_box_amulet_search_skill1.GetStringSelection()
+        skill2_name = self.frame_view.combo_box_amulet_search_skill2.GetStringSelection()
+        skill1_id = self._skill_name2id_dict[skill1_name]
+        skill2_id = self._skill_name2id_dict[skill2_name]
+        if self.frame_view.amulet2radio_button_dict[view.NAME_AMULET1].GetValue():
+            amu_id = self._amulet_name2id_dict[view.NAME_AMULET1]
+        elif self.frame_view.amulet2radio_button_dict[view.NAME_AMULET2].GetValue():
+            amu_id = self._amulet_name2id_dict[view.NAME_AMULET2]
+        elif self.frame_view.amulet2radio_button_dict[view.NAME_AMULET3].GetValue():
+            amu_id = self._amulet_name2id_dict[view.NAME_AMULET3]
+        else:
+            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()
+        skill2_name = self.frame_view.combo_box_amulet_search_skill2.GetStringSelection()
+        skill1_val = self.frame_view.spin_ctrl_amulet_search_skill1_val.GetValue()
+        skill2_val = self.frame_view.spin_ctrl_amulet_search_skill2_val.GetValue()
+        slot_val = self.frame_view.spin_ctrl_amulet_search_slot_num.GetValue()
+        if self.frame_view.amulet2radio_button_dict[view.NAME_AMULET1].GetValue():
+            amu_id = self._amulet_name2id_dict[view.NAME_AMULET1]
+        elif self.frame_view.amulet2radio_button_dict[view.NAME_AMULET2].GetValue():
+            amu_id = self._amulet_name2id_dict[view.NAME_AMULET2]
+        elif self.frame_view.amulet2radio_button_dict[view.NAME_AMULET3].GetValue():
+            amu_id = self._amulet_name2id_dict[view.NAME_AMULET3]
+        else:
+            raise IndexError(u"amulet id is unknown")
+
+        list_box = self.frame_view.list_box_amulet_search_seeds
+        if skill1_name == skill2_name:
+            self._show_message_dialog(message=u"異なるスキルを選択してください")
+        elif skill1_val == 0 or skill2_val == 0:
+            self._show_message_dialog(message=u"スキルの値には0以外を指定してください")
+        else:
+            skill1_id = self._skill_name2id_dict[skill1_name]
+            skill2_id = self._skill_name2id_dict[skill2_name]
+            suff_dict = {}
+            tup = self.db_accessor.get_sufficient_value(
+                amu_id, skill1_id, skill2_id, skill1_val, skill2_val)
+            if tup is not None:
+                suff_val = tup[0]
+                seeds_set = self.db_accessor.select_seeds_from_sufficient_val(amu_id, suff_val, slot_val, skill2_id)
+                if len(seeds_set) > 0:
+                    self.frame_view.text_ctrl_amulet_search_result.SetValue(
+                        u"{0}個のSeedで出現するお守りです".format(len(seeds_set)))
+                    list_box.Clear()
+                    for seed in seeds_set:
+                        list_box.Append(u"{0}".format(seed))
+                    list_box.SetSelection(0)
+                    self.frame_view.button_amulet_search_skill.Enable()
+                else:
+                    self.frame_view.text_ctrl_amulet_search_result.SetValue(
+                        u"指定されたお守りは見つかりませんでした")
+                    self.frame_view.button_amulet_search_skill.Disable()
+                    list_box.Clear()
+            else:
+                self.frame_view.text_ctrl_amulet_search_result.SetValue(
+                    u"指定されたお守りは見つかりませんでした")
+                self.frame_view.button_amulet_search_skill.Disable()
+                list_box.Clear()
+
+    def OnClickAmuletClear(self, evt):
+        u""" clear amulet conditions """
+        amu_id = self._amulet_name2id_dict[view.NAME_AMULET1]
+        self._set_skill_list_from_amulet(amu_id)
+        self.frame_view.amulet2radio_button_dict[view.NAME_AMULET1].SetValue(True)
+        self.frame_view.button_amulet_search_skill.Disable()
+        self.frame_view.text_ctrl_amulet_search_result.SetValue(u"")
+        self.frame_view.list_box_amulet_search_seeds.Clear()
+
+    def OnClickSkillSearchFromAmulet(self, evt):
+        u""" change page to skill search from amulet"""
+        seed = self.frame_view.list_box_amulet_search_seeds.GetStringSelection()
+        if seed.isdigit():
+            self.frame_view.text_ctrl_seed_select.SetValue(seed)
+            self.frame_view.note_book.SetSelection(view.SKILL_SEARCH_PAGE)
+            self.OnClickSkillSearch(evt)
+
+    def OnClickSettingOK(self, evt):
+        u""" get settings of setting tab """
+        self._highlight_threshold = 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])
+        self._update_highlight()
+
+    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_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)
+        self._update_highlight()
+
+    def _update_highlight(self):
+        u""" update highlight cells """
+        text_dict = self.frame_view.text_ctrl_seed_skill_dict
+        for key in [view.KEY_AMULET1, view.KEY_AMULET2, view.KEY_AMULET3]:
+            for text_ctrl in text_dict[key]:
+                val = text_ctrl.GetValue()
+                if (val in self._skill_name2id_dict and
+                        self._skill_name2id_dict[val] in self._highlight_skills):
+                    text_ctrl.SetBackgroundColour("Yellow")
+                else:
+                    text_ctrl.SetBackgroundColour(wx.NullColor)
+        for text_ctrl in text_dict[view.KEY_THRESHOLD2]:
+            val = text_ctrl.GetValue()
+            if val.isdigit() and int(val) >= self._highlight_threshold:
+                text_ctrl.SetBackgroundColour("Yellow")
+            else:
+                text_ctrl.SetBackgroundColour(wx.NullColor)
+
+
+    def _show_error_dialog(self, message=u"予期せぬエラーが発生しました", caption=u"エラー"):
+        u""" エラーダイアログを表示し、
+        OKボタンが押されたらアプリケーションを終了する
+        """
+        dlg = wx.MessageDialog(self.frame_view.frame, 
+            message,
+            caption, wx.OK | wx.ICON_ERROR)
+        dlg.ShowModal()
+        dlg.Destroy()
+        wx.Exit()
+    
+    def _show_message_dialog(self, message, caption=u"メッセージ"):
+        u""" メッセージダイアログを表示する
+        """
+        dlg = wx.MessageDialog(self.frame_view.frame, 
+            message,
+            caption, wx.OK | wx.ICON_INFORMATION)
+        dlg.ShowModal()
+        dlg.Destroy()
+
+    def CloseHandler(self, evt):
+        dlg = wx.MessageDialog(parent = self.frame_view.frame,
+                message = u"終了します。よろしいですか?", 
+                caption = u"終了確認", 
+                style = wx.YES_NO)
+        result = dlg.ShowModal()
+        dlg.Destroy()
+        if result == wx.ID_YES:
+            self._write_settings()
+            wx.Exit()
 
     def OnClose(self, evt):
         self.frame_view.Close()
 
     def OnClose(self, evt):
         self.frame_view.Close()
@@ -72,6 +420,27 @@ class AmuletToolController(wx.App):
         info = self.frame_view.GetAboutInfo()
         wx.AboutBox(info)
 
         info = self.frame_view.GetAboutInfo()
         wx.AboutBox(info)
 
+    def _write_settings(self):
+        with open(SETTING_FILE, mode="w") as f:
+            data = {SETTING_THRESHOLD:self._highlight_threshold, 
+                    SETTING_SKILLS:self._highlight_skills}
+            pickle.dump(data, f)
+
+    def _read_settings(self):
+        if os.path.exists(SETTING_FILE):
+            with open(SETTING_FILE, mode="r") as f:
+                try:
+                    data = pickle.load(f)
+                    self._highlight_threshold = data[SETTING_THRESHOLD] 
+                    self._highlight_skills = data[SETTING_SKILLS]
+                except EOFError, e:
+                    self._highlight_threshold = view.HIGHLIGHT_THRESHOLD
+                    self._highlight_skills = set()
+        else:
+            self._highlight_threshold = view.HIGHLIGHT_THRESHOLD
+            self._highlight_skills = set()
+
 if __name__ == "__main__":
     app = AmuletToolController(False)
     app.MainLoop()
 if __name__ == "__main__":
     app = AmuletToolController(False)
     app.MainLoop()
+
index a44ffb9..42000b1 100644 (file)
@@ -4,6 +4,7 @@
 # 2013/12/04 written by kei9 
 
 import sqlite3
 # 2013/12/04 written by kei9 
 
 import sqlite3
+import sys
 
 import db_supports
 from amuletskillsholder import AmuletSkillsHolder
 
 import db_supports
 from amuletskillsholder import AmuletSkillsHolder
@@ -19,7 +20,10 @@ class DataBaseAccessor(object):
         self._cursor = self._connect.cursor()
 
         self._skill_id2name_dict, self._skill_name2id_dict = self._get_skill_dict()
         self._cursor = self._connect.cursor()
 
         self._skill_id2name_dict, self._skill_name2id_dict = self._get_skill_dict()
-        self._amulet_id2name_dict, self._amulet_name2id_dict, self._amulet_id2minmax_dict, self._amulet_id2second_dict, self._amulet_id2suff_dict = self._get_amulet_dict()
+        (self._amulet_id2name_dict, self._amulet_name2id_dict, 
+            self._amulet_id2minmax_table_dict, self._amulet_id2second_table_dict,
+            self._amulet_id2suff_table_dict,
+            self._amulet_id2skill1_id_dict, self._amulet_id2skill2_id_dict) = self._get_amulet_dict()
 
     def _print_dicts(self):
         u""" for debug """
 
     def _print_dicts(self):
         u""" for debug """
@@ -27,9 +31,11 @@ class DataBaseAccessor(object):
         print self._skill_name2id_dict
         print self._amulet_id2name_dict
         print self._amulet_name2id_dict
         print self._skill_name2id_dict
         print self._amulet_id2name_dict
         print self._amulet_name2id_dict
-        print self._amulet_id2minmax_dict
-        print self._amulet_id2second_dict
-        print self._amulet_id2suff_dict
+        print self._amulet_id2minmax_table_dict
+        print self._amulet_id2second_table_dict
+        print self._amulet_id2suff_table_dict
+        print self._amulet_id2skill1_id_dict
+        print self._amulet_id2skill2_id_dict
 
     def get_dicts(self, clone_enable=False):
         u""" get all dicts 
 
     def get_dicts(self, clone_enable=False):
         u""" get all dicts 
@@ -38,25 +44,22 @@ class DataBaseAccessor(object):
 
             returns (skill_id2name_dict, skill_name2id_dict, 
                 amulet_id2name_dict, amulet_name2id_dict,
 
             returns (skill_id2name_dict, skill_name2id_dict, 
                 amulet_id2name_dict, amulet_name2id_dict,
-                amulet_id2minmax_dict, amulet_id2second_dict,
-                amulet_id2stuff_dict)
+                amulet_id2skill_ids)
         """
         if clone_enable:
             return (dict(self._skill_id2name_dict), 
                     dict(self._skill_name2id_dict),
                     dict(self._amulet_id2name_dict), 
                     dict(self._amulet_name2id_dict),
         """
         if clone_enable:
             return (dict(self._skill_id2name_dict), 
                     dict(self._skill_name2id_dict),
                     dict(self._amulet_id2name_dict), 
                     dict(self._amulet_name2id_dict),
-                    dict(self._amulet_id2minmax_dict),
-                    dict(self._amulet_id2second_dict),
-                    dict(self._amulet_id2stuff_dict))
+                    dict(self._amulet_id2skill1_id_dict),
+                    dict(self._amulet_id2skill2_id_dict))
         else:
             return (self._skill_id2name_dict, 
                     self._skill_name2id_dict,
                     self._amulet_id2name_dict, 
                     self._amulet_name2id_dict,
         else:
             return (self._skill_id2name_dict, 
                     self._skill_name2id_dict,
                     self._amulet_id2name_dict, 
                     self._amulet_name2id_dict,
-                    self._amulet_id2minmax_dict, 
-                    self._amulet_id2second_dict,
-                    self._amulet_id2suff_dict)
+                    self._amulet_id2skill1_id_dict,
+                    self._amulet_id2skill2_id_dict)
 
 
     def _get_skill_dict(self):
 
 
     def _get_skill_dict(self):
@@ -73,11 +76,14 @@ class DataBaseAccessor(object):
         return skill_id2name_dict, skill_name2id_dict
 
     def _get_amulet_dict(self):
         return skill_id2name_dict, skill_name2id_dict
 
     def _get_amulet_dict(self):
-        u""" create id2name, name2id, id2minmax, id2second, id2suff dict of amulet 
-            return (dict_id2name, dict_name2id, id2minmax, id2second, id2suff)
+        u""" create id2name, name2id, id2minmax_table, id2second_table, id2suff_table,
+            id2skill1_ids, id2skill2_id dict of amulet 
+        return (dict_id2name, dict_name2id, 
+            id2minmax_table, id2second_table, id2suff_table, id2skill1_ids, id2skill2_ids)
         """
         amulet_id2name_dict, amulet_name2id_dict = {}, {}
         """
         amulet_id2name_dict, amulet_name2id_dict = {}, {}
-        id2minmax, id2second, id2suff = {}, {}, {}
+        id2minmax_table, id2second_table, id2suff_table = {}, {}, {}
+        id2skill1_ids, id2skill2_ids = {}, {}
         self._cursor.execute(db_supports.AMULET_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, name = val[0], val[1]
         self._cursor.execute(db_supports.AMULET_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, name = val[0], val[1]
@@ -88,21 +94,37 @@ class DataBaseAccessor(object):
         self._cursor.execute(db_supports.MIN_MAX_MASTER_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
         self._cursor.execute(db_supports.MIN_MAX_MASTER_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
-            id2minmax[amulet_id] = table
+            id2minmax_table[amulet_id] = table
  
         # id 2 second table name
         self._cursor.execute(db_supports.SECOND_MASTER_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
  
         # id 2 second table name
         self._cursor.execute(db_supports.SECOND_MASTER_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
-            id2second[amulet_id] = table
+            id2second_table[amulet_id] = table
 
         # id 2 sufficient table name
 
         # id 2 sufficient table name
-        self._cursor.execute(db_supports.MIN_MAX_MASTER_TABLE_SELECT_ALL_SQL)
+        self._cursor.execute(db_supports.SUFFICIENT_MASTER_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
-            id2suff[amulet_id] = table
+            id2suff_table[amulet_id] = table
+
+        # id 2 non zero skill1 ids
+        # id 2 non zero skill2 ids
+        for amu_id in amulet_id2name_dict.keys():
+            table = id2minmax_table[amu_id]
+            sql = db_supports.MIN_MAX_TABLE_SELECT_NON_ZERO_SKILL1_ID_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            ls = [x[0] for x in self._cursor.fetchall()]
+            id2skill1_ids[amu_id] = tuple(ls)
+
+            sql = db_supports.MIN_MAX_TABLE_SELECT_NON_ZERO_SKILL2_ID_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            ls = [x[0] for x in self._cursor.fetchall()]
+            id2skill2_ids[amu_id] = tuple(ls)
 
 
-        return amulet_id2name_dict, amulet_name2id_dict, id2minmax, id2second, id2suff
+        return (amulet_id2name_dict, amulet_name2id_dict, 
+                id2minmax_table, id2second_table, id2suff_table,
+                id2skill1_ids, id2skill2_ids)
 
     def select_seeds(self, amu_id2skill_id_list_dict):
         u""" from dict of amulet_id to skill_id_list,
 
     def select_seeds(self, amu_id2skill_id_list_dict):
         u""" from dict of amulet_id to skill_id_list,
@@ -110,8 +132,8 @@ class DataBaseAccessor(object):
         """
         seed_set = None
         for key, val in amu_id2skill_id_list_dict.items():
         """
         seed_set = None
         for key, val in amu_id2skill_id_list_dict.items():
-            if key in self._amulet_id2second_dict:
-                second_skill_table = self._amulet_id2second_dict[key]
+            if key in self._amulet_id2second_table_dict:
+                second_skill_table = self._amulet_id2second_table_dict[key]
                 amulet_skill = AmuletSkillsHolder(val)
 
                 if amulet_skill.is_empty():
                 amulet_skill = AmuletSkillsHolder(val)
 
                 if amulet_skill.is_empty():
@@ -130,11 +152,37 @@ class DataBaseAccessor(object):
         else:
             return seed_set
 
         else:
             return seed_set
 
+    def select_seeds_from_sufficient_val(self, amu_id, sufficient_val, slot_num, skill2_id):
+        u""" get seeds set from slot number, skill2_id, amulet id, sufficient value
+        """
+        if amu_id in self._amulet_id2name_dict.keys():
+            table = self._amulet_id2suff_table_dict[amu_id]
+            sql = db_supports.SUFFICIENT_TABLE_SELECT_THRESHOLDS_SQL.format(
+                    table_name=table, sufficient_val=sufficient_val)
+            self._cursor.execute(sql)
+            try:
+                threshold2 = self._cursor.fetchone()[slot_num-1]
+            except TypeError, e:
+                threshold2 = None
+
+            if threshold2 is not None:
+                table = self._amulet_id2second_table_dict[amu_id]
+                sql = db_supports.SECOND_SLOT_TABLE_SELECT_SEEDS_FROM_THRESHOLD_AND_SKILL2_SQL.format(
+                        threshold=threshold2,
+                        skill_table=table,
+                        skill_id=skill2_id)
+                self._cursor.execute(sql)
+                return set([x[0] for x in self._cursor.fetchall()])
+            else:
+                return set()
+        else:
+            return set()
+
     def select_minmax_from_skill_ids(self, amulet_id, skill_ids):
         u""" お守りのidとスキルidのリストから、スキルIDと取りうるスキルの最大最小値の辞書を得る
             return dict{skill_id:(min1, max1, min2, max2)}
         """
     def select_minmax_from_skill_ids(self, amulet_id, skill_ids):
         u""" お守りのidとスキルidのリストから、スキルIDと取りうるスキルの最大最小値の辞書を得る
             return dict{skill_id:(min1, max1, min2, max2)}
         """
-        minmax_table = self._amulet_id2minmax_dict[amulet_id]
+        minmax_table = self._amulet_id2minmax_table_dict[amulet_id]
         amulet_skill = AmuletSkillsHolder(skill_ids)
         result_dict = {}
         if amulet_skill.is_empty() is False:
         amulet_skill = AmuletSkillsHolder(skill_ids)
         result_dict = {}
         if amulet_skill.is_empty() is False:
@@ -142,14 +190,14 @@ class DataBaseAccessor(object):
             self._cursor.execute(sql)
 
             for row in self._cursor.fetchall():
             self._cursor.execute(sql)
 
             for row in self._cursor.fetchall():
-                result_dict[row[0]] = tuple(row[1])
+                result_dict[row[0]] = tuple(row[1:])
         return result_dict
 
     def select_threshold_from_sufficient(self, amulet_id, sufficient_vals):
         u""" お守りのidと充足値のリストから、充足値とスロットごとの判定値の辞書を得る
             return dict({sufficient_val:(slot1_th, slot2_th, slot3_th)})
         """
         return result_dict
 
     def select_threshold_from_sufficient(self, amulet_id, sufficient_vals):
         u""" お守りのidと充足値のリストから、充足値とスロットごとの判定値の辞書を得る
             return dict({sufficient_val:(slot1_th, slot2_th, slot3_th)})
         """
-        suff_table = self._amulet_id2suff_dict[amulet_id]
+        suff_table = self._amulet_id2suff_table_dict[amulet_id]
         amulet_skill = SufficientsHolder(sufficient_vals)
         result_dict = {}
         if amulet_skill.is_empty() is False:
         amulet_skill = SufficientsHolder(sufficient_vals)
         result_dict = {}
         if amulet_skill.is_empty() is False:
@@ -162,14 +210,14 @@ class DataBaseAccessor(object):
 
     def select_skills_from_seeds(self, seed_set):
         u""" get amulet id to (random_seed to skill ids dict) dict,
 
     def select_skills_from_seeds(self, seed_set):
         u""" get amulet id to (random_seed to skill ids dict) dict,
-        and rendom_seed to slot value dict
+        and random_seed to slot value dict
         return: skill_dict, slot_dict
         """
         skill_dict, slot_dict = {}, {}
 
         # skill dict
         seeds = RandomSeedsHolder(seed_set)
         return: skill_dict, slot_dict
         """
         skill_dict, slot_dict = {}, {}
 
         # skill dict
         seeds = RandomSeedsHolder(seed_set)
-        for amu_id, table in self._amulet_id2second_dict.items():
+        for amu_id, table in self._amulet_id2second_table_dict.items():
             sql = db_supports.SECOND_TABLE_SELECT_ALL_SQL.format(
                     table_name=table) + seeds.get_where_sql()
             self._cursor.execute(sql)
             sql = db_supports.SECOND_TABLE_SELECT_ALL_SQL.format(
                     table_name=table) + seeds.get_where_sql()
             self._cursor.execute(sql)
@@ -186,6 +234,91 @@ class DataBaseAccessor(object):
 
         return skill_dict, slot_dict
 
 
         return skill_dict, slot_dict
 
+    def get_sufficient_value(self, amu_id, skill1_id, skill2_id, skill1_val, skill2_val):
+        u""" 充足値を計算する。
+        指定したスキルが見つからない場合はNoneを返す 
+        return (sufficient_val, max1, max2)
+        """
+        
+        if amu_id in self._amulet_id2minmax_table_dict:
+            table = self._amulet_id2minmax_table_dict[amu_id]
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MAX1_OF_SKILL_SQL.format(
+                    table_name=table,skill_id=skill1_id)
+            self._cursor.execute(sql)
+            max1 = self._cursor.fetchone()[0]
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MAX2_OF_SKILL_SQL.format(
+                    table_name=table,skill_id=skill2_id)
+            self._cursor.execute(sql)
+            max2 = self._cursor.fetchone()[0]
+
+            if max1 is None or max2 is None:
+                return None
+
+            #print skill1_val, "/", max1 , skill2_val, "/", max2
+            try:
+                skill1_val = max1 if skill1_val > max1 else skill1_val
+                skill2_val = max2 if skill2_val > max2 else skill2_val
+                val1 = (10 * skill1_val) // max1 if skill1_val >= 0 else 0
+                val2 = (10 * skill2_val) // max2 if skill2_val >= 0 else 0
+            except TypeError, e:
+                return None
+            except ZeroDivisionError, e:
+                return None
+            else:
+                return  (val1 + val2, max1, max2)
+
+        else:
+            return None
+
+    def get_skill_minmax(self):
+        u""" 全てのお守りのスキルにおいて、その最大値と最小値を返す 
+            return (min1, max1, min2, max2)
+        """
+        min1_ls, max1_ls, min2_ls, max2_ls = [],[],[],[]
+        # get min max of each amulet
+        for amu_id, table in self._amulet_id2minmax_table_dict.items():
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MIN1_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            min1_ls.append(self._cursor.fetchone()[0])
+
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MAX1_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            max1_ls.append(self._cursor.fetchone()[0])
+
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MIN2_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            min2_ls.append(self._cursor.fetchone()[0])
+
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MAX2_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            max2_ls.append(self._cursor.fetchone()[0])
+
+        return (min(min1_ls), max(max1_ls), min(min2_ls), max(max2_ls))
+
+    def get_skill_ids(self, amulet_id):
+        u""" 全てのお守りのスキルにおいて、その最大値と最小値を返す 
+            return (min1, max1, min2, max2)
+        """
+        min1_ls, max1_ls, min2_ls, max2_ls = [],[],[],[]
+        # get min max of each amulet
+        for amu_id, table in self._amulet_id2minmax_table_dict.items():
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MIN1_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            min1_ls.append(self._cursor.fetchone()[0])
+
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MAX1_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            max1_ls.append(self._cursor.fetchone()[0])
+
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MIN2_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            min2_ls.append(self._cursor.fetchone()[0])
+
+            sql = db_supports.MIN_MAX_TABLE_SELECT_MAX2_SQL.format(table_name=table)
+            self._cursor.execute(sql)
+            max2_ls.append(self._cursor.fetchone()[0])
+
+        return (min(min1_ls), max(max1_ls), min(min2_ls), max(max2_ls))
 
     def close(self):
         u""" close database accessor """
 
     def close(self):
         u""" close database accessor """
index e86167e..0651fc3 100644 (file)
@@ -110,7 +110,30 @@ MIN_MAX_TABLE_SELECT_ALL_SQL = u"""select {skill_id}, {min1}, {max1}, {min2}, {m
         max1=MIN_MAX_COL_MAX1,
         min2=MIN_MAX_COL_MIN2,
         max2=MIN_MAX_COL_MAX2)
         max1=MIN_MAX_COL_MAX1,
         min2=MIN_MAX_COL_MIN2,
         max2=MIN_MAX_COL_MAX2)
-
+MIN_MAX_TABLE_SELECT_NON_ZERO_SKILL1_ID_SQL = u"""select {skill_id} from {{table_name}} 
+    where {min1} != 0 and {max1} != 0""".format(
+        skill_id=MIN_MAX_COL_SKILL_ID,
+        min1=MIN_MAX_COL_MIN1,
+        max1=MIN_MAX_COL_MAX1)
+MIN_MAX_TABLE_SELECT_NON_ZERO_SKILL2_ID_SQL = u"""select {skill_id} from {{table_name}} 
+    where {min2} != 0 and {max2} != 0""".format(
+        skill_id=MIN_MAX_COL_SKILL_ID,
+        min2=MIN_MAX_COL_MIN2,
+        max2=MIN_MAX_COL_MAX2)
+MIN_MAX_TABLE_SELECT_MIN1_SQL = u"""select min({col}) from {{table_name}} """.format(
+        col=MIN_MAX_COL_MIN1)
+MIN_MAX_TABLE_SELECT_MAX1_SQL = u"""select max({col}) from {{table_name}} """.format(
+        col=MIN_MAX_COL_MAX1)
+MIN_MAX_TABLE_SELECT_MIN2_SQL = u"""select min({col}) from {{table_name}} """.format(
+        col=MIN_MAX_COL_MIN2)
+MIN_MAX_TABLE_SELECT_MAX2_SQL = u"""select max({col}) from {{table_name}} """.format(
+        col=MIN_MAX_COL_MAX2)
+MIN_MAX_TABLE_SELECT_MAX1_OF_SKILL_SQL = u"""select max({col}) from {{table_name}} 
+    where skill_id={{skill_id}}""".format(
+        col=MIN_MAX_COL_MAX1)
+MIN_MAX_TABLE_SELECT_MAX2_OF_SKILL_SQL = u"""select max({col}) from {{table_name}} 
+    where skill_id={{skill_id}}""".format(
+        col=MIN_MAX_COL_MAX2)
 
 # for Second skill
 SECOND_MASTER_TABLE_NAME = u"skill_second_master"
 
 # for Second skill
 SECOND_MASTER_TABLE_NAME = u"skill_second_master"
@@ -230,6 +253,33 @@ SECOND_SLOT_TABLE_SELECT_ALL_SQL = u"""select {seed}, {slot1}, {slot2},
         slot5=SECOND_COL_SLOT5,
         slot6=SECOND_COL_SLOT6,
         slot7=SECOND_COL_SLOT7)
         slot5=SECOND_COL_SLOT5,
         slot6=SECOND_COL_SLOT6,
         slot7=SECOND_COL_SLOT7)
+SECOND_SLOT_TABLE_SELECT_SEEDS_FROM_THRESHOLD_AND_SKILL2_SQL = u"""
+    select {slot_table}.{seed} from {slot_table} 
+    inner join {{skill_table}} on {slot_table}.{seed} = {{skill_table}}.{seed}
+    where ({{skill_table}}.{skill_id1} == {{skill_id}} and {slot_table}.{slot1} >= {{threshold}}) or 
+    ({{skill_table}}.{skill_id2} == {{skill_id}} and {slot_table}.{slot2} >= {{threshold}}) or 
+    ({{skill_table}}.{skill_id3} == {{skill_id}} and {slot_table}.{slot3} >= {{threshold}}) or 
+    ({{skill_table}}.{skill_id4} == {{skill_id}} and {slot_table}.{slot4} >= {{threshold}}) or 
+    ({{skill_table}}.{skill_id5} == {{skill_id}} and {slot_table}.{slot5} >= {{threshold}}) or 
+    ({{skill_table}}.{skill_id6} == {{skill_id}} and {slot_table}.{slot6} >= {{threshold}}) or 
+    ({{skill_table}}.{skill_id7} == {{skill_id}} and {slot_table}.{slot7} >= {{threshold}})
+    """.format(
+        slot_table=SECOND_SLOT_TABLE_NAME,
+        seed=SECOND_COL_RANDOM_SEED,
+        skill_id1=SECOND_COL_SKILL_ID1,
+        skill_id2=SECOND_COL_SKILL_ID2,
+        skill_id3=SECOND_COL_SKILL_ID3,
+        skill_id4=SECOND_COL_SKILL_ID4,
+        skill_id5=SECOND_COL_SKILL_ID5,
+        skill_id6=SECOND_COL_SKILL_ID6,
+        skill_id7=SECOND_COL_SKILL_ID7,
+        slot1=SECOND_COL_SLOT1,
+        slot2=SECOND_COL_SLOT2,
+        slot3=SECOND_COL_SLOT3,
+        slot4=SECOND_COL_SLOT4,
+        slot5=SECOND_COL_SLOT5,
+        slot6=SECOND_COL_SLOT6,
+        slot7=SECOND_COL_SLOT7)
 
 # for sufficient value for slots
 SUFFICIENT_MASTER_TABLE_NAME = u"sufficient_master"
 
 # for sufficient value for slots
 SUFFICIENT_MASTER_TABLE_NAME = u"sufficient_master"
@@ -275,3 +325,10 @@ SUFFICIENT_TABLE_SELECT_ALL_SQL = u"""select {sufficient_val}, {slot1_val}, {slo
         slot1_val=SUFFICIENT_COL_SLOT1_THRESHOLD,
         slot2_val=SUFFICIENT_COL_SLOT2_THRESHOLD,
         slot3_val=SUFFICIENT_COL_SLOT3_THRESHOLD)
         slot1_val=SUFFICIENT_COL_SLOT1_THRESHOLD,
         slot2_val=SUFFICIENT_COL_SLOT2_THRESHOLD,
         slot3_val=SUFFICIENT_COL_SLOT3_THRESHOLD)
+SUFFICIENT_TABLE_SELECT_THRESHOLDS_SQL = u"""select {slot1_val}, {slot2_val}, {slot3_val} from {{table_name}}
+    where {sufficient_val}={{sufficient_val}}""".format(
+        sufficient_val=SUFFICIENT_COL_SUFFICIENT_VALUE,
+        slot1_val=SUFFICIENT_COL_SLOT1_THRESHOLD,
+        slot2_val=SUFFICIENT_COL_SLOT2_THRESHOLD,
+        slot3_val=SUFFICIENT_COL_SLOT3_THRESHOLD)
+
index 5fa117d..cdd612e 100644 (file)
@@ -4,14 +4,27 @@
 # 2013/12/05 written by kei9
 
 # for dict
 # 2013/12/05 written by kei9
 
 # for dict
-KEY_AMULET1 = "amulet1"
-KEY_AMULET2 = "amulet1"
-KEY_AMULET3 = "amulet1"
-KEY_THRESHOLD2 = "threshold2"
+NAME_AMULET1 = u"光るお守り"
+NAME_AMULET2 = u"古びたお守り"
+NAME_AMULET3 = u"歪んだお守り"
+KEY_AMULET1 = u"amulet1"
+KEY_AMULET2 = u"amulet2"
+KEY_AMULET3 = u"amulet3"
+KEY_THRESHOLD2 = u"threshold2"
+
+SKILL_SEARCH_PAGE = 1
+
+# skill vals
+SLOT_MIN = 1
+SLOT_MAX = 3
+
+HIGHLIGHT_THRESHOLD = 90
+THRESHOLD2_MIN = 0
+THRESHOLD2_MAX = 100
 
 # xrc file
 
 # xrc file
-XRC_GAUGE_DIALOG = "gaugedialog.xrc"
-XRC_MAIN_FRAME = "mainframe.xrc"
+XRC_GAUGE_DIALOG = u"gaugedialog.xrc"
+XRC_MAIN_FRAME = u"mainframe.xrc"
 
 # for about
 NAME = u"Amulet Tools MH4"
 
 # for about
 NAME = u"Amulet Tools MH4"
index b3bdb85..8d77b53 100644 (file)
@@ -15,7 +15,7 @@
         <label>Help</label>
       </object>
     </object>
         <label>Help</label>
       </object>
     </object>
-    <object class="wxNotebook" name="NoteBookSeed">
+    <object class="wxNotebook" name="NoteBookMain">
       <object class="notebookpage">
         <object class="wxPanel" name="NoteBookPanelSeed">
           <object class="wxBoxSizer">
       <object class="notebookpage">
         <object class="wxPanel" name="NoteBookPanelSeed">
           <object class="wxBoxSizer">
@@ -43,7 +43,9 @@
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet1_1"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet1_1">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
@@ -55,7 +57,9 @@
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet1_2"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet1_2">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
@@ -67,7 +71,9 @@
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet1_3"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet1_3">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
@@ -79,7 +85,9 @@
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet1_4"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet1_4">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
@@ -91,7 +99,9 @@
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet1_5"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet1_5">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet1_6"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet1_6">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet1_7"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet1_7">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet2_1"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet2_1">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet2_2"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet2_2">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet2_3"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet2_3">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet2_4"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet2_4">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet2_5"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet2_5">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet2_6"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet2_6">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet2_7"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet2_7">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet3_1"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet3_1">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet3_2"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet3_2">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet3_3"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet3_3">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet3_4"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet3_4">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet3_5"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet3_5">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet3_6"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet3_6">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
                               <border>3</border>
                             </object>
                             <object class="sizeritem">
-                              <object class="wxComboBox" name="ComboBoxAmulet3_7"/>
+                              <object class="wxComboBox" name="ComboBoxAmulet3_7">
+                                <style>wxCB_READONLY</style>
+                              </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
                               <option>1</option>
                               <flag>wxEXPAND</flag>
                             </object>
           </object>
         </object>
         <label>Seed値の特定</label>
           </object>
         </object>
         <label>Seed値の特定</label>
-        <selected>1</selected>
       </object>
       <object class="notebookpage">
         <object class="wxPanel" name="NoteBookPanelSkill">
       </object>
       <object class="notebookpage">
         <object class="wxPanel" name="NoteBookPanelSkill">
                 </object>
                 <object class="sizeritem">
                   <object class="wxStaticBoxSizer">
                 </object>
                 <object class="sizeritem">
                   <object class="wxStaticBoxSizer">
-                    <label>お守り候補</label>
-                    <orient>wxVERTICAL</orient>
                     <object class="sizeritem">
                       <object class="wxListBox" name="ListBoxSeedSkillAmuletProspect"/>
                       <option>1</option>
                       <flag>wxEXPAND</flag>
                     </object>
                     <object class="sizeritem">
                       <object class="wxListBox" name="ListBoxSeedSkillAmuletProspect"/>
                       <option>1</option>
                       <flag>wxEXPAND</flag>
                     </object>
+                    <label>お守り候補(未実装)</label>
+                    <orient>wxVERTICAL</orient>
                   </object>
                   <option>1</option>
                   <flag>wxBOTTOM|wxRIGHT|wxEXPAND</flag>
                   </object>
                   <option>1</option>
                   <flag>wxBOTTOM|wxRIGHT|wxEXPAND</flag>
             <object class="sizeritem">
               <object class="wxStaticBoxSizer">
                 <object class="sizeritem">
             <object class="sizeritem">
               <object class="wxStaticBoxSizer">
                 <object class="sizeritem">
+                  <object class="wxStaticBoxSizer">
+                    <object class="sizeritem">
+                      <object class="wxRadioButton" name="RadioButtonAmulet1">
+                        <label>光るお守り</label>
+                        <value>1</value>
+                      </object>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxRadioButton" name="RadioButtonAmulet2">
+                        <label>古びたお守り</label>
+                      </object>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxRadioButton" name="RadioButtonAmulet3">
+                        <label>歪んだお守り</label>
+                      </object>
+                    </object>
+                    <label>種類</label>
+                    <orient>wxHORIZONTAL</orient>
+                  </object>
+                  <flag>wxALL|wxEXPAND</flag>
+                  <border>5</border>
+                </object>
+                <object class="sizeritem">
                   <object class="wxFlexGridSizer">
                     <object class="sizeritem">
                       <object class="wxStaticText" name="LabelAmuletSearchSkill1">
                   <object class="wxFlexGridSizer">
                     <object class="sizeritem">
                       <object class="wxStaticText" name="LabelAmuletSearchSkill1">
                       </object>
                     </object>
                     <object class="sizeritem">
                       </object>
                     </object>
                     <object class="sizeritem">
-                      <object class="wxComboBox" name="ComboBoxAmuletSearchSkill1"/>
+                      <object class="wxComboBox" name="ComboBoxAmuletSearchSkill1">
+                        <style>wxCB_READONLY</style>
+                      </object>
                     </object>
                     <object class="sizeritem">
                       <object class="wxSpinCtrl" name="SpinCtrlAmuletSearchSkill1Value"/>
                     </object>
                     <object class="sizeritem">
                       <object class="wxSpinCtrl" name="SpinCtrlAmuletSearchSkill1Value"/>
                       </object>
                     </object>
                     <object class="sizeritem">
                       </object>
                     </object>
                     <object class="sizeritem">
-                      <object class="wxComboBox" name="ComboBoxAmuletSearchSkill2"/>
+                      <object class="wxComboBox" name="ComboBoxAmuletSearchSkill2">
+                        <style>wxCB_READONLY</style>
+                      </object>
                     </object>
                     <object class="sizeritem">
                       <object class="wxSpinCtrl" name="SpinCtrlAmuletSearchSkill2Value"/>
                     </object>
                     <object class="sizeritem">
                       <object class="wxSpinCtrl" name="SpinCtrlAmuletSearchSkill2Value"/>
                     <hgap>3</hgap>
                   </object>
                   <option>0</option>
                     <hgap>3</hgap>
                   </object>
                   <option>0</option>
-                  <flag>wxEXPAND</flag>
+                  <flag>wxALL|wxEXPAND</flag>
+                  <border>5</border>
                 </object>
                 <object class="sizeritem">
                   <object class="wxBoxSizer">
                 </object>
                 <object class="sizeritem">
                   <object class="wxBoxSizer">
                     </object>
                     <orient>wxHORIZONTAL</orient>
                   </object>
                     </object>
                     <orient>wxHORIZONTAL</orient>
                   </object>
-                  <flag>wxEXPAND</flag>
+                  <flag>wxALL|wxEXPAND</flag>
+                  <border>5</border>
                 </object>
                 <label>お守り指定</label>
                 <orient>wxVERTICAL</orient>
                 </object>
                 <label>お守り指定</label>
                 <orient>wxVERTICAL</orient>
                     <style>wxTE_MULTILINE|wxTE_READONLY</style>
                   </object>
                   <option>1</option>
                     <style>wxTE_MULTILINE|wxTE_READONLY</style>
                   </object>
                   <option>1</option>
-                  <flag>wxEXPAND</flag>
+                  <flag>wxALL|wxEXPAND</flag>
+                  <border>5</border>
                 </object>
                 <object class="sizeritem">
                   <object class="wxListBox" name="ListBoxAmuletSearchSeeds"/>
                   <option>2</option>
                 </object>
                 <object class="sizeritem">
                   <object class="wxListBox" name="ListBoxAmuletSearchSeeds"/>
                   <option>2</option>
-                  <flag>wxEXPAND</flag>
+                  <flag>wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND</flag>
+                  <border>5</border>
                 </object>
                 <label>Seed候補</label>
                 <orient>wxVERTICAL</orient>
                 </object>
                 <label>Seed候補</label>
                 <orient>wxVERTICAL</orient>
+                <object class="sizeritem">
+                  <object class="wxBoxSizer">
+                    <object class="sizeritem">
+                      <object class="wxPanel"/>
+                      <option>1</option>
+                      <flag>wxEXPAND</flag>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxButton" name="ButtonAmuletSearchSkill">
+                        <label>対応スキル検索</label>
+                        <enabled>0</enabled>
+                      </object>
+                    </object>
+                    <orient>wxHORIZONTAL</orient>
+                  </object>
+                  <flag>wxALL|wxEXPAND</flag>
+                  <border>5</border>
+                </object>
               </object>
               <option>1</option>
               <flag>wxTOP|wxBOTTOM|wxRIGHT|wxEXPAND</flag>
               </object>
               <option>1</option>
               <flag>wxTOP|wxBOTTOM|wxRIGHT|wxEXPAND</flag>
         <label>第2スキル固定手順</label>
       </object>
       <object class="notebookpage">
         <label>第2スキル固定手順</label>
       </object>
       <object class="notebookpage">
-        <object class="wxPanel" name="NoteBookPanelSettings"/>
+        <object class="wxPanel" name="NoteBookPanelSettings">
+          <object class="wxBoxSizer">
+            <orient>wxVERTICAL</orient>
+            <object class="sizeritem">
+              <object class="wxBoxSizer">
+                <object class="sizeritem">
+                  <object class="wxStaticBoxSizer">
+                    <label>ハイライトするスキル</label>
+                    <orient>wxVERTICAL</orient>
+                    <object class="sizeritem">
+                      <object class="wxPanel" name="CheckListBoxPos"/>
+                      <option>1</option>
+                      <flag>wxEXPAND</flag>
+                    </object>
+                  </object>
+                  <option>1</option>
+                  <flag>wxALL|wxEXPAND</flag>
+                  <border>5</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxStaticBoxSizer">
+                    <object class="sizeritem">
+                      <object class="wxSpinCtrl" name="SpinCtrlHighlightThreshold">
+                        <min>0</min>
+                        <max>100</max>
+                      </object>
+                      <flag>wxEXPAND</flag>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxStaticText">
+                        <label>以上</label>
+                      </object>
+                      <flag>wxLEFT</flag>
+                      <border>3</border>
+                    </object>
+                    <label>ハイライトする判定値</label>
+                    <orient>wxHORIZONTAL</orient>
+                  </object>
+                  <option>0</option>
+                  <flag>wxTOP|wxBOTTOM|wxRIGHT</flag>
+                  <border>5</border>
+                </object>
+                <orient>wxHORIZONTAL</orient>
+              </object>
+              <option>1</option>
+              <flag>wxTOP|wxLEFT|wxRIGHT|wxEXPAND</flag>
+              <border>10</border>
+            </object>
+            <object class="sizeritem">
+              <object class="wxBoxSizer">
+                <object class="sizeritem">
+                  <object class="wxPanel"/>
+                  <option>1</option>
+                  <flag>wxEXPAND</flag>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxButton" name="ButtonSettingOK">
+                    <label>決定</label>
+                  </object>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxButton" name="ButtonSettingClear">
+                    <label>クリア</label>
+                  </object>
+                </object>
+                <orient>wxHORIZONTAL</orient>
+              </object>
+              <flag>wxALL|wxEXPAND</flag>
+              <border>5</border>
+            </object>
+          </object>
+        </object>
         <label>設定</label>
       </object>
     </object>
         <label>設定</label>
       </object>
     </object>
index f119d77..43eee6e 100644 (file)
@@ -6,6 +6,7 @@ import os.path
 
 import wx
 from wx import xrc
 
 import wx
 from wx import xrc
+import wx.lib.intctrl
 
 import constnumbers
 
 
 import constnumbers
 
@@ -22,14 +23,46 @@ class MainFrameView():
         # load controls
         self.frame = self.res.LoadFrame(None, "MainFrame")
 
         # load controls
         self.frame = self.res.LoadFrame(None, "MainFrame")
 
+        self.note_book = xrc.XRCCTRL(self.frame, "NoteBookMain")
+
         # buttons
         self.button_seed_seaerch = xrc.XRCCTRL(self.frame, "ButtonSeedSearch")
         self.button_seed_clear = xrc.XRCCTRL(self.frame, "ButtonSeedClear")
         self.button_skill_from_seed_search = xrc.XRCCTRL(self.frame, "ButtonSkillFromSeedSearch")
         # buttons
         self.button_seed_seaerch = xrc.XRCCTRL(self.frame, "ButtonSeedSearch")
         self.button_seed_clear = xrc.XRCCTRL(self.frame, "ButtonSeedClear")
         self.button_skill_from_seed_search = xrc.XRCCTRL(self.frame, "ButtonSkillFromSeedSearch")
-        self.button_skill_search = xrc.XRCCTRL(self.frame, "ButtonSkillSearch")
-        self.button_skill_clear = xrc.XRCCTRL(self.frame, "ButtonSkillClear")
+        self.button_skill_search = xrc.XRCCTRL(self.frame, "ButtonSeedSkillSearch")
+        self.button_skill_clear = xrc.XRCCTRL(self.frame, "ButtonSeedSkillClear")
         self.button_amulet_search_seaerch = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSearch")
         self.button_amulet_search_clear = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchClear")
         self.button_amulet_search_seaerch = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSearch")
         self.button_amulet_search_clear = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchClear")
+        self.button_amulet_search_skill = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSkill")
+        self.button_setting_ok = xrc.XRCCTRL(self.frame, "ButtonSettingOK")
+        self.button_setting_clear = xrc.XRCCTRL(self.frame, "ButtonSettingClear")
+
+        self.ID_BUTTON_SEED_SEARCH = xrc.XRCID("ButtonSeedSearch")
+        self.ID_BUTTON_SEED_CLEAR = xrc.XRCID("ButtonSeedClear")
+        self.ID_BUTTON_SKILL_FROM_SEED_SEARCH = xrc.XRCID("ButtonSkillFromSeedSearch")
+        self.ID_BUTTON_SKILL_SEARCH = xrc.XRCID("ButtonSeedSkillSearch")
+        self.ID_BUTTON_SKILL_CLEAR = xrc.XRCID("ButtonSeedSkillClear")
+        self.ID_BUTTON_AMULET_SEARCH_SEARCH = xrc.XRCID("ButtonAmuletSearchSearch")
+        self.ID_BUTTON_AMULET_SEARCH_CLEAR = xrc.XRCID("ButtonAmuletSearchClear")
+        self.ID_BUTTON_AMULET_SEARCH_SKILL = xrc.XRCID("ButtonAmuletSearchSkill")
+        self.ID_BUTTON_SETTING_OK = xrc.XRCID("ButtonSettingOK")
+        self.ID_BUTTON_SETTING_CLEAR = xrc.XRCID("ButtonSettingClear")
+
+        # radio button
+        self.radio_button_amulet1 = xrc.XRCCTRL(self.frame, "RadioButtonAmulet1")
+        self.radio_button_amulet2 = xrc.XRCCTRL(self.frame, "RadioButtonAmulet2")
+        self.radio_button_amulet3 = xrc.XRCCTRL(self.frame, "RadioButtonAmulet3")
+        self.ID_RADIO_BUTTON_AMULET1 = xrc.XRCID("RadioButtonAmulet1")
+        self.ID_RADIO_BUTTON_AMULET2 = xrc.XRCID("RadioButtonAmulet2")
+        self.ID_RADIO_BUTTON_AMULET3 = xrc.XRCID("RadioButtonAmulet3")
+        self.amulet2radio_button_dict = {}
+        self.amulet2radio_button_dict[constnumbers.NAME_AMULET1] = self.radio_button_amulet1
+        self.amulet2radio_button_dict[constnumbers.NAME_AMULET2] = self.radio_button_amulet2
+        self.amulet2radio_button_dict[constnumbers.NAME_AMULET3] = self.radio_button_amulet3
+        self.amulet2radio_id_dict = {}
+        self.amulet2radio_id_dict[constnumbers.NAME_AMULET1] = self.ID_RADIO_BUTTON_AMULET1
+        self.amulet2radio_id_dict[constnumbers.NAME_AMULET2] = self.ID_RADIO_BUTTON_AMULET2
+        self.amulet2radio_id_dict[constnumbers.NAME_AMULET3] = self.ID_RADIO_BUTTON_AMULET3
 
         # menu
         self.ID_MENU_ITEM_EXIT = xrc.XRCID("wxID_EXIT") # same as wx.ID_EXIT
 
         # menu
         self.ID_MENU_ITEM_EXIT = xrc.XRCID("wxID_EXIT") # same as wx.ID_EXIT
@@ -42,13 +75,35 @@ class MainFrameView():
         self._load_combo_boxes()
 
         # load list box
         self._load_combo_boxes()
 
         # load list box
+        self.list_box_seed = xrc.XRCCTRL(self.frame, "ListBoxSeed")
         self.list_box_amulet_search_seeds = xrc.XRCCTRL(self.frame, "ListBoxAmuletSearchSeeds")
         self.list_box_seed_skill_amulet_prospect = xrc.XRCCTRL(self.frame, "ListBoxSeedSkillAmuletProspect")
         self.list_box_amulet_search_seeds = xrc.XRCCTRL(self.frame, "ListBoxAmuletSearchSeeds")
         self.list_box_seed_skill_amulet_prospect = xrc.XRCCTRL(self.frame, "ListBoxSeedSkillAmuletProspect")
+        self.ID_LIST_BOX_SEED = xrc.XRCID("ListBoxSeed")
+        self.ID_LIST_BOX_AMULET_SEARCH_SEEDS = xrc.XRCID("ListBoxAmuletSearchSeeds")
+        self.ID_LIST_BOX_SEED_SKILL_AMULET_PROSPECT = xrc.XRCID("ListBoxSeedSkillAmuletProspect")
 
         # load spin ctrl
         self.spin_ctrl_amulet_search_skill1_val = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSkill1Value")
         self.spin_ctrl_amulet_search_skill2_val = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSkill2Value")
         self.spin_ctrl_amulet_search_slot_num = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSlotNumber")
 
         # load spin ctrl
         self.spin_ctrl_amulet_search_skill1_val = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSkill1Value")
         self.spin_ctrl_amulet_search_skill2_val = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSkill2Value")
         self.spin_ctrl_amulet_search_slot_num = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSlotNumber")
+        self.ID_SPIN_CTRL_AMULET_SKILL1_VAL = xrc.XRCID("SpinCtrlAmuletSearchSkill1Value")
+        self.ID_SPIN_CTRL_AMULET_SKILL2_VAL = xrc.XRCID("SpinCtrlAmuletSearchSkill2Value")
+        self.spin_ctrl_highlight = xrc.XRCCTRL(self.frame, "SpinCtrlHighlightThreshold")
+
+        # load custom ctrl
+        panel = xrc.XRCCTRL(self.frame, "CheckListBoxPos")
+        #panel = xrc.XRCCTRL(self.frame, "NoteBookPanelSettings")
+        self.ID_CHECK_LIST_BOX_HIGHLIGHT_SKILL = wx.NewId()
+        #self.check_list_box_highlight_skill = wx.CheckListBox(self.frame, self.ID_CHECK_LIST_BOX_HIGHLIGHT_SKILL)
+        self.check_list_box_highlight_skill = wx.CheckListBox(panel, id=self.ID_CHECK_LIST_BOX_HIGHLIGHT_SKILL,
+                name="CheckListBoxHighlightSkills")
+        #self.res.AttachUnknownControl("CheckListBoxHighlightSkills", self.check_list_box_highlight_skill, panel) # list isn't shown. why?
+
+        vbox = wx.BoxSizer(wx.VERTICAL)
+        vbox.Add(self.check_list_box_highlight_skill, 1, wx.EXPAND)
+        panel.SetSizer(vbox)
+
+        #panel.Fit()
 
         # set explanation text
         self.text_ctrl_seed_explain.SetValue(constnumbers.SEED_DECISION_EXPLANATION)
 
         # set explanation text
         self.text_ctrl_seed_explain.SetValue(constnumbers.SEED_DECISION_EXPLANATION)
@@ -59,30 +114,32 @@ class MainFrameView():
         self.combo_box_skill_dict = {}
         self.combo_box_skill_dict[constnumbers.KEY_AMULET1] = [
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_1"),
         self.combo_box_skill_dict = {}
         self.combo_box_skill_dict[constnumbers.KEY_AMULET1] = [
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_1"),
+                xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_2"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_3"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_4"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_3"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_4"),
-                xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_4"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_5"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_6"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_7")]
         self.combo_box_skill_dict[constnumbers.KEY_AMULET2] = [
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_1"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_5"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_6"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet1_7")]
         self.combo_box_skill_dict[constnumbers.KEY_AMULET2] = [
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_1"),
+                xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_2"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_3"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_4"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_3"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_4"),
-                xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_4"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_5"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_6"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_7")]
         self.combo_box_skill_dict[constnumbers.KEY_AMULET3] = [
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_1"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_5"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_6"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet2_7")]
         self.combo_box_skill_dict[constnumbers.KEY_AMULET3] = [
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_1"),
+                xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_2"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_3"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_4"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_3"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_4"),
-                xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_4"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_5"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_6"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_7")]
         self.combo_box_amulet_search_skill1 = xrc.XRCCTRL(self.frame, "ComboBoxAmuletSearchSkill1")
         self.combo_box_amulet_search_skill2 = xrc.XRCCTRL(self.frame, "ComboBoxAmuletSearchSkill2")
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_5"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_6"),
                 xrc.XRCCTRL(self.frame, "ComboBoxAmulet3_7")]
         self.combo_box_amulet_search_skill1 = xrc.XRCCTRL(self.frame, "ComboBoxAmuletSearchSkill1")
         self.combo_box_amulet_search_skill2 = xrc.XRCCTRL(self.frame, "ComboBoxAmuletSearchSkill2")
+        self.ID_COMBO_BOX_AMULET_SEARCH_SKILL1 = xrc.XRCID("ComboBoxAmuletSearchSkill1")
+        self.ID_COMBO_BOX_AMULET_SEARCH_SKILL2 = xrc.XRCID("ComboBoxAmuletSearchSkill2")
 
     def _load_text_ctrls(self):
         # load text ctrls
 
     def _load_text_ctrls(self):
         # load text ctrls
@@ -131,6 +188,12 @@ class MainFrameView():
     def Close(self):
         self.frame.Close(True)
 
     def Close(self):
         self.frame.Close(True)
 
+    def DisableNoteBook(self):
+        self.note_book.Disable()
+
+    def EnableNoteBook(self):
+        self.note_book.Enable()
+        
     def OnAboutBox(self, evt):
         u""" Show About Box """
         info = wx.AboutDialogInfo()
     def OnAboutBox(self, evt):
         u""" Show About Box """
         info = wx.AboutDialogInfo()