Skip to content

Commit 9004b95

Browse files
committed
Replace broken settings dropdown with a settings window
1 parent 3816fda commit 9004b95

File tree

7 files changed

+146
-373
lines changed

7 files changed

+146
-373
lines changed

Python/gui/checkbox_button_menu.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

Python/gui/checkbox_button_menu_refactor_idea.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

Python/gui/gui.py

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from Python import convert
88
from Python import warnings
99

10-
from Python.gui import gui_layout
11-
from Python.gui import checkbox_button_menu
10+
from Python.gui import gui_windows
1211

1312

1413
def init_window_theme():
@@ -21,53 +20,43 @@ def init_window_theme():
2120
sg.theme_button_color((sg.theme_text_color(), "#2a3948"))
2221

2322

24-
def init_window():
23+
def init_settings():
2524
sg.user_settings_filename(filename="settings.json", path=".")
2625

2726
if not os.path.isfile(sg.user_settings_filename()):
2827
sg.Popup("This is a tool that allows you to convert legacy (old) mods to the latest version of CCCP. You can get more information from the GitHub repo or the Discord server by clicking the corresponding icons.", title="Welcome screen", custom_text=" OK ")
2928

30-
# set_default_settings(window)
31-
3229
cfg.sg = sg
3330

3431
warnings.load_conversion_and_warning_rules() # TODO: Why is this called in this GUI function?
3532

36-
window = sg.Window(
37-
f"Legacy Mod Converter {cfg.CONVERTER_VERSION} for CCCP {cfg.GAME_VERSION}",
38-
gui_layout.get_layout(),
39-
icon=utils.path("Media/legacy-mod-converter.ico"),
40-
font=("Helvetica", 16),
41-
finalize=True
42-
)
43-
44-
set_default_settings(window)
45-
46-
cfg.progress_bar = window["PROGRESS_BAR"]
33+
set_default_settings()
4734

48-
# window.finalize()
4935

50-
return window
36+
def set_default_settings():
37+
play_finish_sound_setting = sg.user_settings_get_entry("play_finish_sound")
38+
sg.user_settings_set_entry("play_finish_sound", True if play_finish_sound_setting == None else play_finish_sound_setting)
5139

5240

53-
def set_default_settings(window):
54-
if sg.user_settings_get_entry("play_finish_sound") == None:
55-
checkbox_button_menu.handle_button_press(window, "SETTINGS", "Play finish sound", cfg.USER_SETTINGS_BUTTON_MAPPINGS)
41+
def run_window():
42+
main_window = gui_windows.get_main_window()
43+
settings_window = None
5644

45+
cfg.progress_bar = main_window["PROGRESS_BAR"]
5746

58-
def run_window(window):
5947
valid_cccp_path = True if sg.user_settings_get_entry("cccp_folder") else False
6048

6149
while True:
62-
event, values = window.read()
50+
window, event, values = sg.read_all_windows()
6351

6452
if event == "Exit" or event == sg.WIN_CLOSED:
6553
window.close()
66-
break
54+
if window == main_window:
55+
break
56+
if window == settings_window:
57+
settings_window = None
6758

68-
# print(event, values)
69-
70-
if event == "CCCP_FOLDER":
59+
elif event == "CCCP_FOLDER":
7160
cccp_folder = values[event]
7261
if Path(cccp_folder).exists():
7362
valid_cccp_path = True
@@ -81,9 +70,12 @@ def run_window(window):
8170
valid_cccp_path = False
8271
window[event](background_color = cfg.NO_PATH_SET_COLOR)
8372

84-
elif event == "SETTINGS":
85-
selected_button_name = values[event]
86-
checkbox_button_menu.handle_button_press(window, event, selected_button_name, cfg.USER_SETTINGS_BUTTON_MAPPINGS)
73+
elif event == "LAUNCH_SETTINGS_WINDOW" and settings_window == None:
74+
settings_window = gui_windows.get_settings_window()
75+
76+
elif event in ("SKIP_CONVERSION", "OUTPUT_ZIPS", "PLAY_FINISH_SOUND"):
77+
value = values[event]
78+
sg.user_settings_set_entry(event.lower(), value)
8779

8880
elif event == "CONVERT":
8981
if valid_cccp_path:

0 commit comments

Comments
 (0)