From 2ff5f0a846a7d2958bb179794a45751a89e73b53 Mon Sep 17 00:00:00 2001 From: kei9 Date: Wed, 18 Dec 2013 16:28:47 +0900 Subject: [PATCH] revise amulet search to consider of seed1 value, but too slow to search --- amulettool.py | 64 +++-- model/db_accessor.py | 80 +++++- model/db_supports.py | 34 ++- model/skillplaceholder.py | 47 ++++ view/constnumbers.py | 12 +- view/mainframe.fbp | 628 ++++++++++++++++++++++++++++++++++++++++++--- view/mainframe.xrc | 95 +++++-- view/notebookamuletview.py | 136 ++++++++-- 8 files changed, 992 insertions(+), 104 deletions(-) create mode 100644 model/skillplaceholder.py diff --git a/amulettool.py b/amulettool.py index a8b64b9..295c75d 100644 --- a/amulettool.py +++ b/amulettool.py @@ -187,7 +187,6 @@ class AmuletToolController(wx.App): def _update_notebook_amulet_seed2s(self): u"""お守り検索タブのSeed2リストを更新する""" - set_items = [] threshold_type = self.notebook_amulet_view.get_selected_threshold_type() if threshold_type == view.THRESHOLD_TYPE_ALL: include_th1, include_th2, include_ini = True, True, True @@ -198,26 +197,32 @@ class AmuletToolController(wx.App): elif threshold_type == view.THRESHOLD_TYPE_INISHIE: include_th1, include_th2, include_ini = False, False, True + set_items_dict = {} seed2_set = self.threshold1_seed2_set | self.threshold2_seed2_set | self.threshold_inishie_set - for seed in seed2_set: + for seed2 in seed2_set: type_set, include = [], False - if seed in self.threshold1_seed2_set: + if seed2 in self.threshold1_seed2_set: type_set.append(u"判定値1") if include_th1: include = True - if seed in self.threshold2_seed2_set: + if seed2 in self.threshold2_seed2_set: type_set.append(u"判定値2") if include_th2: include = True - if seed in self.threshold_inishie_set: # seed in inishie_set + if seed2 in self.threshold_inishie_set: # seed in inishie_set type_set.append(u"いにしえ") if include_ini: include = True if include: - set_items.append(u"{0:06d}: (".format(seed) + u",".join(type_set) + u")") - self.notebook_amulet_view.set_listbox_items(set_items) - if len(set_items) > 0: - self.notebook_amulet_view.set_selection_listbox(0) + if seed2 in self.seed2_tenun_num_dict: + tenun555_num, tenun888_num = self.seed2_tenun_num_dict[seed2] + else: + tenun555_num, tenun888_num = 0, 0 + set_items_dict[seed2] = (u",".join(type_set), tenun555_num, tenun888_num) + + self.notebook_amulet_view.set_grid_seed2s_items(set_items_dict) + if len(set_items_dict) > 0: + self.notebook_amulet_view.set_grid_seed2s_selected_idx(0) self.notebook_amulet_view.set_skill_button_enable(True) else: self.notebook_amulet_view.set_skill_button_enable(False) @@ -237,6 +242,8 @@ class AmuletToolController(wx.App): self._update_notebook_amulet(amu_id) self.threshold1_seed2_set, self.threshold2_seed2_set, self.threshold_inishie_set = set(), set(), set() + self.seed2_tenun_num_dict = {} + self._amulet_values = None def _init_notebook_setting(self): u""" 設定タブの初期設定 """ @@ -393,7 +400,7 @@ class AmuletToolController(wx.App): self._update_notebook_amulet(amu_id) self.notebook_amulet_view.set_result_text_ctrl_value(u"") self.notebook_amulet_view.set_skill_button_enable(False) - self.notebook_amulet_view.clear_listbox_items() + self.notebook_amulet_view.clear_grid() def OnClickAmuletRadioThresholdType(self, evt): u""" switch seed lists by threshold_type """ @@ -429,40 +436,63 @@ class AmuletToolController(wx.App): (threshold, self.threshold1_seed2_set, self.threshold2_seed2_set, self.threshold_inishie_set) = self.db_accessor.select_seed2s_from_sufficient_val( amu_id, suff_val, slot_val, skill2_id) - seed2_set = self.threshold1_seed2_set | self.threshold2_seed2_set | self.threshold_inishie_set + seed2_set = self.threshold1_seed2_set | self.threshold2_seed2_set + + # filter seed2s by skill1_id + filtered_seed2_dict = {} # seeds -> (num555, num888) + for seed2 in seed2_set: + places = self.db_accessor.select_skill2_place(amu_id, seed2, skill2_id) + num_555, num_888 = self.db_accessor.count_seed1s_from_skill_place(skill1_id, places, amu_id) + if num_555 > 0 or num_888 > 0: + filtered_seed2_dict[seed2] = (num_555, num_888) + seed2_set = set(filtered_seed2_dict.keys()) + self.seed2_tenun_num_dict = filtered_seed2_dict + self.threshold1_seed2_set = seed2_set & self.threshold1_seed2_set + self.threshold2_seed2_set = seed2_set & self.threshold2_seed2_set + u""" self.threshold_inishie_set についてはSeed1との対応が不明なのでそのまま使用する""" + + self._amulet_values = (skill1_id, skill2_id, skill1_val, skill2_val) self._update_notebook_amulet_seed2s() if len(seed2_set) > 0: self.notebook_amulet_view.set_result_text_ctrl_value( u"""指定されたお守りの充足値:\t{0} 必要な判定値:\t{1}\n判定値1:\t{2}個のSeed2で出現\n判定値2:\t{3}個のSeed2で出現\nいにしえ:\t{4}個のSeed2で出現 -全体:\t{5}個のSeed2で出現""".format( +判定値1,2:\t{5}個のSeed2で出現""".format( suff_val, threshold, len(self.threshold1_seed2_set), len(self.threshold2_seed2_set), len(self.threshold_inishie_set), len(seed2_set))) else: + self.threshold1_seed2_set, self.threshold2_seed2_set, self.threshold_inishie_set = set(), set(), set() self.notebook_amulet_view.set_result_text_ctrl_value( u"""指定されたお守りの充足値:\t{0}\n必要な判定値:\t{1} 指定されたお守りは見つかりませんでした""".format(suff_val, threshold)) self.notebook_amulet_view.set_skill_button_enable(False) - self.notebook_amulet_view.clear_listbox_items() + self.notebook_amulet_view.clear_grid() + self._amulet_values = None + self.seed2_tenun_num_dict = {} else: self.threshold1_seed2_set, self.threshold2_seed2_set, self.threshold_inishie_set = set(), set(), set() self.notebook_amulet_view.set_result_text_ctrl_value( u"エラー。充足値が計算できません") self.notebook_amulet_view.set_skill_button_enable(False) - self.notebook_amulet_view.clear_listbox_items() + self.notebook_amulet_view.clear_grid() + self._amulet_values = None + self.seed2_tenun_num_dict = {} def OnClickAmuletClear(self, evt): u""" clear amulet conditions """ + self.threshold1_seed2_set, self.threshold2_seed2_set, self.threshold_inishie_set = set(), set(), set() + self._amulet_values = None + self.seed2_tenun_num_dict = {} self.notebook_amulet_view.set_radio_value(True, view.NAME_AMULET1) amu_id = self._amulet_name2id_dict[view.NAME_AMULET1] self._update_notebook_amulet(amu_id) self.notebook_amulet_view.set_skill_button_enable(False) self.notebook_amulet_view.set_result_text_ctrl_value(u"") - self.notebook_amulet_view.clear_listbox_items() + self.notebook_amulet_view.clear_grid() def OnClickSkillSearchFromAmulet(self, evt): u""" change page to skill search from amulet""" - seed = self.notebook_amulet_view.get_string_selection_listbox().split(u":")[0] - if seed.isdigit(): + seed = self.notebook_amulet_view.get_grid_selected_seed2() + if seed is not None: self.notebook_skill2_view.set_seed2_value(seed) self.frame_view.note_book.SetSelection(view.SKILL_SEARCH_PAGE) self.OnClickSkillSearch(evt) diff --git a/model/db_accessor.py b/model/db_accessor.py index 1af496d..8770a78 100644 --- a/model/db_accessor.py +++ b/model/db_accessor.py @@ -11,6 +11,7 @@ from amuletskillsholder import AmuletSkillsHolder from amuletidskillidholder import AmuletIdSkillIdHolder from seedsholder import SeedsHolder from sufficientsholder import SufficientsHolder +from skillplaceholder import SkillPlaceHolder class DataBaseAccessor(object): u""" this is access class to database """ @@ -62,7 +63,6 @@ class DataBaseAccessor(object): self._amulet_id2skill1_id_dict, self._amulet_id2skill2_id_dict) - def _get_skill_dict(self): u""" create id2name, name2id dict of skill return (dict_id2name, dict_name2id) @@ -153,6 +153,84 @@ class DataBaseAccessor(object): else: return seed_set + def select_skill2_place(self, amulet_id, seed2, skill2_id): + u""" Seed2、第2スキルid、お守りidから、指定されたSeed2において + Skill2_idが何枠目に属しているか判定し、判定された枠のタプルを返す + return (skill2's indexes)""" + second_skill_table = self._amulet_id2skill2_table_dict[amulet_id] + sql = db_supports.SEED2_SKILL2_TABLE_SELECT_ALL_FROM_SEED2_SQL.format(table_name=second_skill_table,seed2=seed2) + self._cursor.execute(sql) + row = self._cursor.fetchone() # seed2, skill_id1, ..., skill_id7 + if row is not None and len(row) > 1: + return tuple([i for i, x in enumerate(row, 0) if x == skill2_id]) + else: + return tuple() + + def count_seed1s_from_skill_place(self, skill1_id, skill_places, amulet_id): + u""" お守りIdと、第1スキルの種類と出現枠を指定し、 + それを満たすSeed1の個数を天運555と天運888に分けて返す""" + if skill_places is not None and len(skill_places) > 0: + # tenun 555 + if 6 in skill_places: + places555 = list(skill_places).remove(6) + places555 = [] if places555 is None else place555 + else: + places555 = list(skill_places) + place_holder = SkillPlaceHolder(places555, skill1_id) + if len(places555) > 0: + sql555 = (db_supports.SEED1_TENUN555_TABLE_COUNT_SEED1_SQL + + place_holder.get_skill1_where_or_sql(amulet_id)) + else: + sql555 = None + # tenun888 + place_holder = SkillPlaceHolder(skill_places, skill1_id) + sql888 = (db_supports.SEED1_TENUN888_TABLE_COUNT_SEED1_SQL + + place_holder.get_skill1_where_or_sql(amulet_id)) + else: + return 0, 0 + + if sql555 is not None: + self._cursor.execute(sql555) + seeds_555 = self._cursor.fetchone()[0] + else: + seeds_555 = 0 + + self._cursor.execute(sql888) + seeds_888 = self._cursor.fetchone()[0] + + return seeds_555, seeds_888 + + def select_seed1s_from_skill_place(self, skill1_id, skill_places, amulet_id): + u""" お守りIdと、第1スキルの種類と出現枠を指定し、 + それを満たすSeed1のセットを天運555と天運888に分けて返す""" + if skill_places is not None and len(skill_places) > 0: + # tenun 555 + if 6 in skill_places: + places555 = list(skill_places).remove(6) + places555 = [] if places555 is None else place555 + else: + places555 = list(skill_places) + place_holder = SkillPlaceHolder(places555, skill1_id) + if len(places555) > 0: + sql555 = (db_supports.SEED1_TENUN555_TABLE_SELECT_SEED1_SQL + + place_holder.get_skill1_where_or_sql(amulet_id)) + else: + sql555 = None + # tenun888 + place_holder = SkillPlaceHolder(skill_places, skill1_id) + sql888 = (db_supports.SEED1_TENUN888_TABLE_SELECT_SEED1_SQL + + place_holder.get_skill1_where_or_sql(amulet_id)) + else: + return set(), set() + seeds_555, seeds_888 = set(), set() + if sql555 is not None: + self._cursor.execute(sql555) + seeds_555 = set([x[0] for x in self._cursor.fetchall()]) + self._cursor.execute(sql888) + seeds_888 = set([x[0] for x in self._cursor.fetchall()]) + + return seeds_555, seeds_888 + def select_seed1s_tenun(self, amu_id_skill1_id_list, key_tenun): u""" select seed1 from list of amulet_id and skill1_id, key_tenun must be KEY_TENUN555 or KEY_TENUN888 diff --git a/model/db_supports.py b/model/db_supports.py index da18ae6..b8bf68f 100644 --- a/model/db_supports.py +++ b/model/db_supports.py @@ -248,7 +248,16 @@ SEED2_SKILL2_TABLE_SELECT_ALL_SQL = u"""select {seed}, {skill_id1}, {skill_id2}, skill_id5=SEED2_SKILL2_COL_SKILL2_ID5, skill_id6=SEED2_SKILL2_COL_SKILL2_ID6, skill_id7=SEED2_SKILL2_COL_SKILL2_ID7) - +SEED2_SKILL2_TABLE_SELECT_ALL_FROM_SEED2_SQL = u"""select {skill_id1}, {skill_id2}, + {skill_id3}, {skill_id4}, {skill_id5}, {skill_id6}, {skill_id7} from {{table_name}} where {seed}={{seed2}}""".format( + seed=SEED2_SKILL2_COL_SEED2, + skill_id1=SEED2_SKILL2_COL_SKILL2_ID1, + skill_id2=SEED2_SKILL2_COL_SKILL2_ID2, + skill_id3=SEED2_SKILL2_COL_SKILL2_ID3, + skill_id4=SEED2_SKILL2_COL_SKILL2_ID4, + skill_id5=SEED2_SKILL2_COL_SKILL2_ID5, + skill_id6=SEED2_SKILL2_COL_SKILL2_ID6, + skill_id7=SEED2_SKILL2_COL_SKILL2_ID7) # for seed2 to threshold1 u""" SEED2から判定値1へのテーブル """ SEED2_THRESHOLD1_TABLE_NAME = u"seed2_threshold1" @@ -662,6 +671,18 @@ SEED1_TENUN555_TABLE_SELECT_ALL_FROM_SEED1_SQL = u"""select id, {table_no}, {res skill1_id4=SEED1_TENUN_COL_SKILL1_4, skill1_id5=SEED1_TENUN_COL_SKILL1_5, skill1_id6=SEED1_TENUN_COL_SKILL1_6) +# extract skill1 by place +SEED1_TENUN555_TABLE_SELECT_SEED1_SQL = u"""select + {seed1} from {table_name} """.format( + seed1=SEED1_TENUN_COL_SEED1, + table_name=SEED1_TENUN555_TABLE) +# count seed1 number with skill1 and place +SEED1_TENUN555_TABLE_COUNT_SEED1_SQL = u"""select + count({seed1}) from {table_name} """.format( + seed1=SEED1_TENUN_COL_SEED1, + table_name=SEED1_TENUN555_TABLE) + +# tenun888 SEED1_TENUN888_TABLE_CREATE_SQL = u"""create table if not exists {table_name} (id integer primary key, {table_no} integer, {seed} integer unique, {result_num} integer, {amulet_id1} integer, {amulet_id2} integer, {amulet_id3} integer, @@ -766,3 +787,14 @@ SEED1_TENUN888_TABLE_SELECT_ALL_FROM_SEED1_SQL = u"""select id, {table_no}, {res skill1_id5=SEED1_TENUN_COL_SKILL1_5, skill1_id6=SEED1_TENUN_COL_SKILL1_6, skill1_id7=SEED1_TENUN_COL_SKILL1_7) + +# extract skill1 by place +SEED1_TENUN888_TABLE_SELECT_SEED1_SQL = u"""select + {seed1} from {table_name} """.format( + seed1=SEED1_TENUN_COL_SEED1, + table_name=SEED1_TENUN888_TABLE) +# count seed1 number with skill1 and place +SEED1_TENUN888_TABLE_COUNT_SEED1_SQL = u"""select + count({seed1}) from {table_name} """.format( + seed1=SEED1_TENUN_COL_SEED1, + table_name=SEED1_TENUN888_TABLE) diff --git a/model/skillplaceholder.py b/model/skillplaceholder.py new file mode 100644 index 0000000..dac5ff1 --- /dev/null +++ b/model/skillplaceholder.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +# お守りのスキルの出現枠の位置とスキル +# 2013/12/18 written by kei9 + +import db_supports + +class SkillPlaceHolder(object): + u""" スキルの出現場所とスキルidを保持するクラス """ + def __init__(self, place_ids, skill_id): + u""" place_ids: (0-6 's list) """ + self._place_ids = place_ids + self._skill_id = skill_id + + def get_skill1_where_or_sql(self, amulet_id, remove_where=False): + u""" 第1スキルのSQLのWhere文に変換する(OR結合) """ + valid_eqls = [] + for x in self._place_ids: + amu_col = db_supports.SEED1_TENUN_COL_AMULET_LIST[x] + skill_col = db_supports.SEED1_TENUN_COL_SKILL1_LIST[x] + valid_eqls.append(u"({amu_col}={amu_id} and {skill_col}={skill_id})".format( + amu_col=amu_col, + amu_id=amulet_id, + skill_col=skill_col, + skill_id=self._skill_id)) + + if len(valid_eqls) > 0: + if remove_where: + return u" or ".join(valid_eqls) + else: + return u" where " + u" or ".join(valid_eqls) + else: + return "" + + def get_skill2_where_or_sql(self, remove_where=False): + u""" 第2スキルのSQLのWhere文に変換する(OR結合) """ + valid_eqls = [] + for x in self._place_ids: + col = db_supports.SEED2_SKILL2_COL_SKILL2_LIST[x] + valid_eqls.append(u"{col}={skill_id}".format(col=col,skill_id=self._skill_id)) + if len(valid_eqls) > 0: + if remove_where: + return u" or ".join(valid_eqls) + else: + return u" where " + u" or ".join(valid_eqls) + else: + return "" diff --git a/view/constnumbers.py b/view/constnumbers.py index c6fd422..926d128 100644 --- a/view/constnumbers.py +++ b/view/constnumbers.py @@ -26,6 +26,7 @@ AMULET_NAME_TO_SHORT_NAME_DICT = {NAME_AMULET0:SHORT_NAME_AMULET0, NAME_AMULET1:SHORT_NAME_AMULET1, NAME_AMULET2:SHORT_NAME_AMULET2, NAME_AMULET3:SHORT_NAME_AMULET3} AMULET_SHORT_NAME_TO_NAME_DICT = {SHORT_NAME_AMULET0:NAME_AMULET0, SHORT_NAME_AMULET1:NAME_AMULET1, SHORT_NAME_AMULET2:NAME_AMULET2, SHORT_NAME_AMULET3:NAME_AMULET3} +VAL_NO_SKILL = u"なし" # skill2 grid DICT_SKILL2_GRID_COL = {KEY_AMULET1:0, KEY_AMULET2:1, KEY_AMULET3:2, KEY_THRESHOLD1:3, KEY_THRESHOLD2:4} @@ -42,8 +43,17 @@ LABEL_FORMAT_SEED1_GRID_COL_AFTER2 = u"{0}枠目" NUM_SEED1_GRID_COL = 9 NUM_SEED1_GRID_ROW = 50 -VAL_NO_SKILL = u"なし" +# amulet seed2s grid +LABEL_FORMAT_AMULET_SEED2S_GRID_COL1 = u"錬金の種類" +LABEL_FORMAT_AMULET_SEED2S_GRID_COL2 = u"SEED1の個数(天運555)" +LABEL_FORMAT_AMULET_SEED2S_GRID_COL3 = u"SEED1の個数(天運888)" +NUM_AMULET_SEED2S_GRID_COL = 3 + +LABEL_FORMAT_AMULET_SEED1S_GRID_COL1 = u"天運555" +LABEL_FORMAT_AMULET_SEED1S_GRID_COL2 = u"天運888" +NUM_AMULET_SEED1S_GRID_COL = 2 +# page index SKILL_SEARCH_PAGE = 1 # skill vals diff --git a/view/mainframe.fbp b/view/mainframe.fbp index 70191fd..e2f76df 100644 --- a/view/mainframe.fbp +++ b/view/mainframe.fbp @@ -264,7 +264,7 @@ Seed2の特定 - 1 + 0 1 1 @@ -6320,7 +6320,7 @@ Seed1の特定 - 0 + 1 1 1 @@ -9366,7 +9366,7 @@ 0 1 - wxRA_SPECIFY_ROWS + wxRA_SPECIFY_COLS 0 @@ -9403,14 +9403,14 @@ - + 5 wxALL|wxEXPAND 0 - + 3 - wxBOTH - + wxHORIZONTAL + 1,2 3 @@ -9421,7 +9421,7 @@ 3 0 - + wxALIGN_CENTER|wxEXPAND 0 1 @@ -9504,8 +9504,8 @@ 0 - - 0 + wxEXPAND + 1 1 1 @@ -9552,7 +9552,7 @@ Resizable -1 1 - + -1,-1 wxCB_READONLY 0 @@ -9644,7 +9644,7 @@ Resizable 1 - + 50,-1 wxSP_ARROW_KEYS 0 @@ -9682,7 +9682,7 @@ 0 - + wxALIGN_CENTER|wxEXPAND 0 1 @@ -9765,8 +9765,8 @@ 0 - - 0 + wxEXPAND + 1 1 1 @@ -9905,7 +9905,7 @@ Resizable 1 - + 50,-1 wxSP_ARROW_KEYS 0 @@ -9943,7 +9943,7 @@ 0 - + wxEXPAND 0 1 @@ -10024,10 +10024,20 @@ + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + 0 - - 0 + wxEXPAND + 1 1 1 @@ -10075,7 +10085,7 @@ Resizable 1 - + 50,-1 wxSP_ARROW_KEYS 0 @@ -10147,7 +10157,7 @@ 0 wxID_ANY 表示する判定値の種類 - 2 + 1 0 @@ -10166,7 +10176,7 @@ 0 1 - wxRA_SPECIFY_ROWS + wxRA_SPECIFY_COLS 0 @@ -10472,13 +10482,13 @@ - + 10 wxTOP|wxBOTTOM|wxRIGHT|wxEXPAND 1 - + wxID_ANY - Seed2の候補 + Seedの候補 sbSizer11 wxVERTICAL @@ -10575,11 +10585,94 @@ - + + 5 + wxLEFT|wxRIGHT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Seed2候補 + + 0 + + + 0 + + 1 + m_staticText411 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND + wxEXPAND | wxALL 2 - + 1 1 1 @@ -10593,7 +10686,6 @@ 1 0 - 1 1 @@ -10606,7 +10698,7 @@ 1 0 - + 0 wxID_ANY 0 @@ -10615,7 +10707,237 @@ 0 1 - ListBoxAmuletSearchSeeds + m_panel14 + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer21 + wxVERTICAL + none + + 0 + wxALL|wxEXPAND + 2 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTRE + 30 + + wxALIGN_CENTRE + 5 + + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 1 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + + 1 + GridAmuletSeed2s + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTRE + 80 + + wxALIGN_CENTRE + + 5 + 1 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxLEFT|wxRIGHT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Seed1候補 + + 0 + + + 0 + + 1 + m_staticText421 1 @@ -10629,13 +10951,10 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - + -1 @@ -10646,8 +10965,6 @@ - - @@ -10663,11 +10980,240 @@ - + + 5 + wxEXPAND | wxALL + 2 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panel141 + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer211 + wxVERTICAL + none + + 0 + wxALL|wxEXPAND + 2 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTRE + 30 + + wxALIGN_CENTRE + 5 + + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 1 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + + 1 + GridAmuletSeed1s + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTRE + 80 + + wxALIGN_CENTRE + + 5 + 1 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALL|wxEXPAND 0 - + bSizer10 wxHORIZONTAL @@ -10785,7 +11331,7 @@ 0 wxID_ANY - 対応スキル検索 + Seed2対応スキル表示 0 @@ -10793,7 +11339,7 @@ 0 1 - ButtonAmuletSearchSkill + ButtonAmuletSearchSkill2 1 diff --git a/view/mainframe.xrc b/view/mainframe.xrc index cd14646..c90e141 100644 --- a/view/mainframe.xrc +++ b/view/mainframe.xrc @@ -25,7 +25,7 @@ - 1 + 0 @@ -813,7 +813,7 @@ - 0 + 1 @@ -1217,7 +1217,7 @@ wxALL|wxEXPAND 5 - + 0 @@ -1237,11 +1237,11 @@ 3 3 3 - + 1,2 - + wxALIGN_CENTER|wxEXPAND 0 @@ -1249,8 +1249,8 @@ - - + + wxEXPAND 0 @@ -1264,6 +1264,7 @@ 0 + 50,-1 0 0 @@ -1271,7 +1272,7 @@ - + wxALIGN_CENTER|wxEXPAND 0 @@ -1279,8 +1280,8 @@ - - + + wxEXPAND 0 @@ -1294,6 +1295,7 @@ 0 + 50,-1 0 0 @@ -1301,19 +1303,26 @@ - + wxEXPAND 0 0 + + + wxEXPAND + 5 + 0,0 + - - + + wxEXPAND 0 + 50,-1 0 0 @@ -1326,7 +1335,7 @@ wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT 5 - + 0 @@ -1335,7 +1344,7 @@ 判定値2のみ いにしえの錬金 - 2 + 1 @@ -1380,7 +1389,7 @@ 10 wxVERTICAL - + wxALL|wxEXPAND @@ -1392,11 +1401,55 @@ + + wxLEFT|wxRIGHT|wxTOP + 5 + + + -1 + + + - wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND + wxEXPAND | wxALL 5 - - + + + + wxVERTICAL + + + wxALL|wxEXPAND + 0 + + + + + + + + wxLEFT|wxRIGHT|wxTOP + 5 + + + -1 + + + + + wxEXPAND | wxALL + 5 + + + + wxVERTICAL + + + wxALL|wxEXPAND + 0 + + + @@ -1417,9 +1470,9 @@ 0 - + 0 - + 0 diff --git a/view/notebookamuletview.py b/view/notebookamuletview.py index 8a587a7..3f79f19 100644 --- a/view/notebookamuletview.py +++ b/view/notebookamuletview.py @@ -13,6 +13,7 @@ class NoteBookAmuletView(): def __init__(self, frame): self.frame = frame self._init_view() + self._init_event() def _init_view(self): # initialize view @@ -20,18 +21,33 @@ class NoteBookAmuletView(): # button self.button_search = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSearch") self.button_clear = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchClear") - self.button_skill = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSkill") + self.button_skill = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSkill2") self.ID_BUTTON_SEARCH = xrc.XRCID("ButtonAmuletSearchSearch") self.ID_BUTTON_CLEAR = xrc.XRCID("ButtonAmuletSearchClear") - self.ID_BUTTON_SKILL = xrc.XRCID("ButtonAmuletSearchSkill") + self.ID_BUTTON_SKILL = xrc.XRCID("ButtonAmuletSearchSkill2") # radio button self.radiobox_amulet = xrc.XRCCTRL(self.frame, "RadioBoxAmulet") self.radiobox_threshold_type = xrc.XRCCTRL(self.frame, "RadioBoxThresholdType") - # seed list - self.list_box_seeds = xrc.XRCCTRL(self.frame, "ListBoxAmuletSearchSeeds") - self.ID_LIST_BOX_SEEDS = xrc.XRCID("ListBoxAmuletSearchSeeds") + # seed2s list + self.grid_seed2s = xrc.XRCCTRL(self.frame, "GridAmuletSeed2s") + self.grid_seed2s.CreateGrid(1, constnumbers.NUM_AMULET_SEED2S_GRID_COL) + self.grid_seed2s.SetColLabelValue(0, constnumbers.LABEL_FORMAT_AMULET_SEED2S_GRID_COL1) + self.grid_seed2s.SetColLabelValue(1, constnumbers.LABEL_FORMAT_AMULET_SEED2S_GRID_COL2) + self.grid_seed2s.SetColLabelValue(2, constnumbers.LABEL_FORMAT_AMULET_SEED2S_GRID_COL3) + self.grid_seed2s.DisableDragGridSize() + self.grid_seed2s.EnableEditing(False) + self.grid_seed2s.SetSelectionMode(wx.grid.Grid.wxGridSelectRows) + + # seed1s list + self.grid_seed1s = xrc.XRCCTRL(self.frame, "GridAmuletSeed1s") + self.grid_seed1s.CreateGrid(1, constnumbers.NUM_AMULET_SEED1S_GRID_COL) + self.grid_seed1s.SetColLabelValue(0, constnumbers.LABEL_FORMAT_AMULET_SEED1S_GRID_COL1) + self.grid_seed1s.SetColLabelValue(1, constnumbers.LABEL_FORMAT_AMULET_SEED1S_GRID_COL2) + self.grid_seed1s.DisableDragGridSize() + self.grid_seed1s.EnableEditing(False) + self.grid_seed1s.SetRowLabelSize(1) # spin ctrl self.spin_ctrl_skill1_val = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSkill1Value") @@ -52,6 +68,27 @@ class NoteBookAmuletView(): # set min & max of slot self.set_slot_minmax(constnumbers.SLOT_MIN, constnumbers.SLOT_MAX) + def _init_event(self): + # initialize event + self.grid_seed1s.Bind(wx.EVT_SIZE, self.OnSeed1GridSizeChanged) + self.grid_seed2s.Bind(wx.EVT_SIZE, self.OnSeed2GridSizeChanged) + + def OnSeed1GridSizeChanged(self, event): + u""" Seed1Gridサイズの変更時 """ + width, height = self.grid_seed1s.GetParent().GetSize() + each_width = (width) / (constnumbers.NUM_AMULET_SEED1S_GRID_COL) # consider margin size + self.grid_seed1s.SetRowLabelValue(0, u"") + for col in range(constnumbers.NUM_AMULET_SEED1S_GRID_COL): + self.grid_seed1s.SetColSize(col, each_width) + + def OnSeed2GridSizeChanged(self, event): + u""" Seed2Gridサイズの変更時 """ + width, height = self.grid_seed2s.GetParent().GetSize() + each_width = (width - 60) / (constnumbers.NUM_AMULET_SEED2S_GRID_COL) # consider margin size + self.grid_seed2s.SetRowLabelSize(45) + for col in range(constnumbers.NUM_AMULET_SEED2S_GRID_COL): + self.grid_seed2s.SetColSize(col, each_width) + def bind_radiobox_amulet(self, event_func, evt=wx.EVT_RADIOBOX): u""" お守り種類のラジオボタンが押された時のイベントをセットする """ self.radiobox_amulet.Bind(evt, event_func) @@ -202,22 +239,77 @@ class NoteBookAmuletView(): u""" 結果表示用のTextCtrlに値をセットする """ self.text_ctrl_result.SetValue(value) - def set_listbox_items(self, items): - u""" Seed一覧のListBoxに値をセットする。 + def set_grid_seed2s_items(self, items_dict): + u""" Seed2一覧のGridに値をセットする。 + 引数はSeed2 -> (str_renkin_type, tenun555_num, tenun888)の辞書とする。 Noneが与えられた時はClearする""" - if items is not None: - self.list_box_seeds.SetItems(items) - else: - self.list_box_seeds.Clear() - - def get_string_selection_listbox(self): - u""" Seed一覧のListBoxの選択された値を得る。""" - return self.list_box_seeds.GetStringSelection() - def set_selection_listbox(self, idx): - u""" Seed一覧のListBoxの選択されたインデックスをセットする。""" - self.list_box_seeds.SetSelection(idx) - - def clear_listbox_items(self): - u""" Seed一覧のListBoxから値をClearする""" - self.list_box_seeds.Clear() + if items_dict is not None: + row_num = len(items_dict) + diff = row_num - self.grid_seed2s.GetNumberRows() + if diff > 0: + self.grid_seed2s.AppendRows(diff, False) + elif diff < 0: + self.grid_seed2s.DeleteRows(0, -diff, False) + + for row, seed2 in enumerate(sorted(items_dict.keys())): + self.grid_seed2s.SetRowLabelValue(row, u"{0}".format(seed2)) + renkin_type, tenun555_num, tenun888_num = items_dict[seed2] + self.grid_seed2s.SetCellValue(row, 0, renkin_type) + self.grid_seed2s.SetCellValue(row, 1, u"{0}".format(tenun555_num)) + self.grid_seed2s.SetCellValue(row, 2, u"{0}".format(tenun888_num)) + else: + self.clear_grid_seed2s() + + def set_grid_seed1s_items(self, tenun555_seed1s, tenun888_seed1s): + u""" Seed1一覧のGridに天運555と天運888のSeed1の値をセットする。""" + self.clear_grid_seed1s() + max_len = max([len(tenun555_seed1s, tenun888_seed2s)]) + diff = max_len - self.grid_seed2s.GetNumberRows() + if diff > 0: + self.grid_seed1s.AppendRows(diff, False) + elif diff < 0: + self.grid_seed1s.DeleteRows(0, -diff, False) + + for row in range(max_len): + self.grid_seed1s.SetRowLabelValue(row, u"") + for row, seed1 in enumerate(sorted(tenun555_seed1s)): + self.grid_seed1s.SetCellValue(row, 0, seed1) + for row, seed1 in enumerate(sorted(tenun888_seed1s)): + self.grid_seed1s.SetCellValue(row, 1, seed1) + + def get_grid_selected_seed2(self): + u""" Seed2一覧のGridの選択されたSeed2の値を得る。""" + rows = [x for x in self.grid_seed2s.GetSelectedRows()] + print rows + if len(rows) > 0: + return int(self.grid_seed2s.GetRowLabelValue(rows[0])) + else: + return None + + def set_grid_seed2s_selected_idx(self, idx): + u""" Seed2一覧のGridの選択された行を選択状態にする。""" + if idx >= 0 and idx < self.grid_seed2s.GetNumberRows(): + self.grid_seed2s.MakeCellVisible(idx, 0) + self.grid_seed2s.SelectRow(idx) + + def clear_grid_seed2s(self): + u""" Seed2一覧のGridから値をClearする""" + for row in range(self.grid_seed2s.GetNumberRows()): + self.grid_seed2s.SetRowLabelValue(row, u"") + for col in range(self.grid_seed2s.GetNumberCols()): + self.grid_seed2s.SetCellValue(row, col, u"") + self.grid_seed2s.ClearSelection() + + def clear_grid_seed1s(self): + u""" Seed1一覧のGridから値をClearする""" + for row in range(self.grid_seed1s.GetNumberRows()): + self.grid_seed1s.SetRowLabelValue(row, u"") + for col in range(self.grid_seed1s.GetNumberCols()): + self.grid_seed1s.SetCellValue(row, col, u"") + self.grid_seed1s.ClearSelection() + + def clear_grid(self): + u"""Gridの値をクリアする""" + self.clear_grid_seed1s() + self.clear_grid_seed2s() -- 2.11.0