Skip to content

Commit

Permalink
bug fix : early set create method
Browse files Browse the repository at this point in the history
  • Loading branch information
pur1fying committed Feb 8, 2025
1 parent ede8481 commit 274856c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
18 changes: 7 additions & 11 deletions gui/components/expand/createPriority.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def __change_create_phase(self, text):
self.initiated = True

class Layout(QWidget):

def __init__(self, parent=None, config=None, phase=1):
super().__init__(parent=parent)
self.viewLayout = QVBoxLayout(self)
Expand All @@ -217,8 +218,7 @@ def __init__(self, parent=None, config=None, phase=1):
2: self.tr('二级制造配置'),
3: self.tr('三级制造配置')
}

__dict_for_method = [
__dict_for_create_method = [
{
'default': self.tr('默认')
},
Expand All @@ -237,22 +237,18 @@ def __init__(self, parent=None, config=None, phase=1):
'advanced_superior': self.tr('金色+紫色材料'),
}
]
__dict_for_method = __dict_for_method[phase - 1]
__rev_dict_for_method = {v: k for k, v in __dict_for_method.items()}
__dict_for_create_method = __dict_for_create_method[phase - 1]
__rev_dict_for_method = {v: k for k, v in __dict_for_create_method.items()}

layout_for_line_one = QHBoxLayout()

layout_for_create_method = QHBoxLayout()
label_for_create_method = QLabel(self.tr('材料选择'), self)
input_for_create_method = ComboBox(self)
for key in __dict_for_method:
input_for_create_method.addItems([__dict_for_method[key]])
for key in __dict_for_create_method:
input_for_create_method.addItems([__dict_for_create_method[key]])
self.create_method = self.config.get(f'create_phase_{phase}_select_item_rule')
if self.create_method not in __dict_for_method:
self.create_method = list(__dict_for_method.keys())[0]
self.config.set(f'create_phase_{phase}_select_item_rule', self.create_method)
self.config.save()
input_for_create_method.setCurrentText(__dict_for_method[self.create_method])
input_for_create_method.setCurrentText(__dict_for_create_method[self.create_method])
input_for_create_method.currentTextChanged.connect(
lambda text: self.config.set('create_method', __rev_dict_for_method[text]))
layout_for_create_method.addWidget(label_for_create_method, 1, Qt.AlignLeft)
Expand Down
10 changes: 10 additions & 0 deletions gui/fragments/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def _config_update(self):
self._common_shop_config_update()
self._tactical_challenge_shop_config_update()
self._create_config_update()
self.config.save()

def _common_shop_config_update(self):
default_goods = self.config.static_config['common_shop_price_list'][self.config.server_mode]
Expand All @@ -111,6 +112,11 @@ def _tactical_challenge_shop_config_update(self):
self.config.set('TacticalChallengeShopList', len(default_goods) * [0])

def _create_config_update(self):
valid_methods = [
['default'],
['primary', 'normal', 'primary_normal', 'advanced', 'superior','advanced_superior','primary_normal_advanced_superior'],
['advanced', 'superior', 'advanced_superior']
]
for phase in range(1, 4):
cfg_key_name = 'createPriority_phase' + str(phase)
current_priority = self.config.get(cfg_key_name)
Expand All @@ -123,6 +129,10 @@ def _create_config_update(self):
if default_priority[j] not in res:
res.append(default_priority[j])
self.config.set(cfg_key_name, res)
create_method = self.config.get(f'create_phase_{phase}_select_item_rule')
if create_method not in valid_methods[phase - 1]:
create_method = valid_methods[phase - 1][0]
self.config.set(f'create_phase_{phase}_select_item_rule', create_method)

def _lazy_load(self):
"""
Expand Down

0 comments on commit 274856c

Please sign in to comment.