Skip to content

Commit bf76a76

Browse files
committed
The user can now only use existing input paths.
1 parent d8733ce commit bf76a76

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Python/gui.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import os, sys
2-
import os.path, pathlib, webbrowser
2+
import pathlib, webbrowser
33
import PySimpleGUI as sg
44

55
from Python import shared_globals as cfg
66
from Python import convert
77

88

99
sg.user_settings_filename(filename="settings.json", path=".")
10+
no_path_set_color = "#b35858"
1011

1112

1213
# TODO: Move to shared_globals.py
@@ -30,8 +31,6 @@ def init_window():
3031
if not os.path.isfile(sg.user_settings_filename()):
3132
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 ")
3233

33-
no_path_set_color = "#b35858"
34-
3534
paths_column = [
3635
[sg.Frame(layout=[
3736
[
@@ -88,6 +87,8 @@ def init_window():
8887

8988

9089
def run_window(window):
90+
valid_input_path = True if sg.user_settings_get_entry("input_folder") else False
91+
9192
while True:
9293
event, values = window.read()
9394

@@ -98,19 +99,24 @@ def run_window(window):
9899
# print(event, values)
99100

100101
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
104105
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)
105110

106111
elif event == "-OUTPUT ZIPS-":
107112
sg.user_settings_set_entry("output_zips", values[event])
108113
elif event == "-PLAY FINISH SOUND-":
109114
sg.user_settings_set_entry("play_finish_sound", values[event])
110115

111116
elif event == "-CONVERT-":
112-
if sg.user_settings_get_entry("input_folder") not in (None, ""):
117+
if valid_input_path:
113118
convert.convert()
119+
114120

115121
elif event == "-GITHUB-":
116122
webbrowser.open("https://github.com/cortex-command-community/Cortex-Command-Legacy-Mod-Converter")

0 commit comments

Comments
 (0)