1
1
import os , sys
2
- import os . path , pathlib , webbrowser
2
+ import pathlib , webbrowser
3
3
import PySimpleGUI as sg
4
4
5
5
from Python import shared_globals as cfg
6
6
from Python import convert
7
7
8
8
9
9
sg .user_settings_filename (filename = "settings.json" , path = "." )
10
+ no_path_set_color = "#b35858"
10
11
11
12
12
13
# TODO: Move to shared_globals.py
@@ -30,8 +31,6 @@ def init_window():
30
31
if not os .path .isfile (sg .user_settings_filename ()):
31
32
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 " )
32
33
33
- no_path_set_color = "#b35858"
34
-
35
34
paths_column = [
36
35
[sg .Frame (layout = [
37
36
[
@@ -88,6 +87,8 @@ def init_window():
88
87
89
88
90
89
def run_window (window ):
90
+ valid_input_path = True if sg .user_settings_get_entry ("input_folder" ) else False
91
+
91
92
while True :
92
93
event , values = window .read ()
93
94
@@ -98,19 +99,24 @@ def run_window(window):
98
99
# print(event, values)
99
100
100
101
if event == "-INPUT FOLDER-" :
101
- input_folder_or_file = values [event ]
102
- if input_folder_or_file != "" :
103
- sg . user_settings_set_entry ( "input_folder" , input_folder_or_file )
102
+ input_folder = values [event ]
103
+ if os . path . exists ( input_folder ) :
104
+ valid_input_path = True
104
105
window [event ](background_color = sg .theme_input_background_color ())
106
+ sg .user_settings_set_entry ("input_folder" , input_folder )
107
+ else :
108
+ valid_input_path = False
109
+ window [event ](background_color = no_path_set_color )
105
110
106
111
elif event == "-OUTPUT ZIPS-" :
107
112
sg .user_settings_set_entry ("output_zips" , values [event ])
108
113
elif event == "-PLAY FINISH SOUND-" :
109
114
sg .user_settings_set_entry ("play_finish_sound" , values [event ])
110
115
111
116
elif event == "-CONVERT-" :
112
- if sg . user_settings_get_entry ( "input_folder" ) not in ( None , "" ) :
117
+ if valid_input_path :
113
118
convert .convert ()
119
+
114
120
115
121
elif event == "-GITHUB-" :
116
122
webbrowser .open ("https://github.com/cortex-command-community/Cortex-Command-Legacy-Mod-Converter" )
0 commit comments