7
7
from Python import convert
8
8
from Python import warnings
9
9
10
- from Python .gui import gui_layout
11
- from Python .gui import checkbox_button_menu
10
+ from Python .gui import gui_windows
12
11
13
12
14
13
def init_window_theme ():
@@ -21,53 +20,43 @@ def init_window_theme():
21
20
sg .theme_button_color ((sg .theme_text_color (), "#2a3948" ))
22
21
23
22
24
- def init_window ():
23
+ def init_settings ():
25
24
sg .user_settings_filename (filename = "settings.json" , path = "." )
26
25
27
26
if not os .path .isfile (sg .user_settings_filename ()):
28
27
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 " )
29
28
30
- # set_default_settings(window)
31
-
32
29
cfg .sg = sg
33
30
34
31
warnings .load_conversion_and_warning_rules () # TODO: Why is this called in this GUI function?
35
32
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 ()
47
34
48
- # window.finalize()
49
35
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 )
51
39
52
40
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
56
44
45
+ cfg .progress_bar = main_window ["PROGRESS_BAR" ]
57
46
58
- def run_window (window ):
59
47
valid_cccp_path = True if sg .user_settings_get_entry ("cccp_folder" ) else False
60
48
61
49
while True :
62
- event , values = window . read ()
50
+ window , event , values = sg . read_all_windows ()
63
51
64
52
if event == "Exit" or event == sg .WIN_CLOSED :
65
53
window .close ()
66
- break
54
+ if window == main_window :
55
+ break
56
+ if window == settings_window :
57
+ settings_window = None
67
58
68
- # print(event, values)
69
-
70
- if event == "CCCP_FOLDER" :
59
+ elif event == "CCCP_FOLDER" :
71
60
cccp_folder = values [event ]
72
61
if Path (cccp_folder ).exists ():
73
62
valid_cccp_path = True
@@ -81,9 +70,12 @@ def run_window(window):
81
70
valid_cccp_path = False
82
71
window [event ](background_color = cfg .NO_PATH_SET_COLOR )
83
72
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 )
87
79
88
80
elif event == "CONVERT" :
89
81
if valid_cccp_path :
0 commit comments