Fix stale config options
This commit is contained in:
parent
731018650a
commit
37f12c95a1
5 changed files with 70 additions and 14 deletions
|
|
@ -107,20 +107,27 @@ class ConfigIntegration:
|
|||
with open(module_path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Find configuration lines
|
||||
config_patterns = [
|
||||
r'^(FIRSTLINESPEAKERS|INLINE401SPEAKERS|FACENAME101|NAMES|BRFLAG|FIXTEXTWRAP|IGNORETLTEXT)\s*=\s*(True|False)',
|
||||
r'^(CODE\d+)\s*=\s*(True|False)'
|
||||
]
|
||||
# Find configuration lines used by the RPG Maker config UI.
|
||||
bool_pattern = (
|
||||
r'^(FIRSTLINESPEAKERS|INLINE401SPEAKERS|FACENAME101|NAMES|'
|
||||
r'BRFLAG|FIXTEXTWRAP|IGNORETLTEXT|TLSYSTEMVARIABLES|'
|
||||
r'TLSYSTEMSWITCHES|JOIN408|SPEAKERS408|CODE\d+)\s*=\s*(True|False)'
|
||||
)
|
||||
int_pattern = r'^(CODE122_VAR_MIN|CODE122_VAR_MAX)\s*=\s*(\d+)'
|
||||
|
||||
for line in content.split('\n'):
|
||||
line = line.strip()
|
||||
for pattern in config_patterns:
|
||||
match = re.match(pattern, line)
|
||||
if match:
|
||||
key = match.group(1)
|
||||
value = match.group(2) == 'True'
|
||||
config[key] = value
|
||||
match = re.match(bool_pattern, line)
|
||||
if match:
|
||||
key = match.group(1)
|
||||
value = match.group(2) == 'True'
|
||||
config[key] = value
|
||||
continue
|
||||
|
||||
match = re.match(int_pattern, line)
|
||||
if match:
|
||||
key = match.group(1)
|
||||
config[key] = int(match.group(2))
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error reading configuration from {module_path}: {e}")
|
||||
|
|
|
|||
|
|
@ -269,11 +269,22 @@ class ConfigTab(QWidget):
|
|||
def switch_page(self, index):
|
||||
"""Switch to the specified page and update button states."""
|
||||
self.content_stack.setCurrentIndex(index)
|
||||
self._refresh_engine_config_page(index)
|
||||
|
||||
# Update button checked states
|
||||
for i, btn in enumerate(self.nav_buttons):
|
||||
btn.setChecked(i == index)
|
||||
|
||||
def _refresh_engine_config_page(self, index):
|
||||
"""Refresh engine config pages from their module files when shown."""
|
||||
engine_pages = {
|
||||
1: getattr(self, "mvmz_tab", None),
|
||||
2: getattr(self, "ace_tab", None),
|
||||
}
|
||||
page = engine_pages.get(index)
|
||||
if page is not None and hasattr(page, "refresh_from_module"):
|
||||
page.refresh_from_module()
|
||||
|
||||
def create_general_settings_tab(self):
|
||||
"""Create combined general settings tab with API, Translation, Performance, and UI settings."""
|
||||
widget = QWidget()
|
||||
|
|
@ -672,12 +683,13 @@ class ConfigTab(QWidget):
|
|||
super().mousePressEvent(event)
|
||||
|
||||
def showEvent(self, event):
|
||||
"""Reload values from .env every time this tab becomes visible."""
|
||||
"""Reload values from disk every time this tab becomes visible."""
|
||||
super().showEvent(event)
|
||||
if self.env_file_path.exists():
|
||||
self.disconnect_auto_save()
|
||||
self.load_from_env()
|
||||
self.connect_auto_save()
|
||||
self._refresh_engine_config_page(self.content_stack.currentIndex())
|
||||
|
||||
def load_from_env(self):
|
||||
"""Load configuration from .env file, reading directly from disk."""
|
||||
|
|
|
|||
|
|
@ -824,9 +824,36 @@ class RPGMakerTab(QWidget):
|
|||
module_path = Path("modules") / module_filename
|
||||
config = self.config_integration.read_current_config(module_path)
|
||||
if config:
|
||||
self.set_config(config)
|
||||
self.disconnect_auto_apply()
|
||||
try:
|
||||
self.set_config(config)
|
||||
finally:
|
||||
self.connect_auto_apply()
|
||||
QMessageBox.information(self, "Success", f"Configuration loaded from {module_filename}")
|
||||
else:
|
||||
QMessageBox.warning(self, "Warning", f"No configuration found in {module_filename}")
|
||||
except Exception as e:
|
||||
QMessageBox.critical(self, "Error", f"Failed to load from module:\n{str(e)}")
|
||||
|
||||
def refresh_from_module(self) -> bool:
|
||||
"""Reload current module config into the UI without applying or showing dialogs."""
|
||||
if not self.config_integration:
|
||||
return False
|
||||
|
||||
try:
|
||||
module_filename = "rpgmakermvmz.py" if self.engine != "ACE" else "rpgmakerace.py"
|
||||
module_path = Path("modules") / module_filename
|
||||
config = self.config_integration.read_current_config(module_path)
|
||||
if not config:
|
||||
return False
|
||||
|
||||
self.disconnect_auto_apply()
|
||||
self.set_config(config)
|
||||
self.connect_auto_apply()
|
||||
return True
|
||||
except Exception:
|
||||
try:
|
||||
self.connect_auto_apply()
|
||||
except Exception:
|
||||
pass
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -604,6 +604,7 @@ class WorkflowTab(QWidget):
|
|||
page_layout.addWidget(nav)
|
||||
self._step_tabs.addTab(page, tab_label)
|
||||
|
||||
self._step_tabs.currentChanged.connect(self._on_step_tab_changed)
|
||||
splitter.addWidget(self._step_tabs)
|
||||
|
||||
# ---- Right: log area ----
|
||||
|
|
@ -659,6 +660,11 @@ class WorkflowTab(QWidget):
|
|||
self._detected_on_show = True
|
||||
QTimer.singleShot(100, self._detect_folder)
|
||||
|
||||
def _on_step_tab_changed(self, index: int):
|
||||
"""Refresh config-backed controls when their workflow page is shown."""
|
||||
if index == 5:
|
||||
self._populate_p2_checkboxes()
|
||||
|
||||
def _apply_theme(self):
|
||||
"""Apply a unified dark-theme stylesheet to all standard controls."""
|
||||
self.setStyleSheet("""
|
||||
|
|
@ -2833,6 +2839,10 @@ class WorkflowTab(QWidget):
|
|||
ci = ConfigIntegration()
|
||||
# Code toggle checkboxes
|
||||
cur = ci.read_current_config()
|
||||
if "CODE122_VAR_MIN" in cur:
|
||||
self._p2_var_min.setText(str(cur["CODE122_VAR_MIN"]))
|
||||
if "CODE122_VAR_MAX" in cur:
|
||||
self._p2_var_max.setText(str(cur["CODE122_VAR_MAX"]))
|
||||
for code_key, cb in getattr(self, "_p2_code_checks", {}).items():
|
||||
if code_key in cur:
|
||||
cb.setChecked(cur[code_key])
|
||||
|
|
|
|||
|
|
@ -3210,7 +3210,7 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
regex = r"Menu\sName\s*:\s*(.*)>"
|
||||
elif "text_indicator" in jaString:
|
||||
regex = r"text_indicator\s?:\s?(.+)"
|
||||
elif re.match(r"^NW名前指定\s+", jaString):
|
||||
elif "NW名前指定" in jaString:
|
||||
regex = r"NW名前指定\s+(.+)"
|
||||
else:
|
||||
i += 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue