Skip to content

Commit 929fa2b

Browse files
committed
Add a stylua toggle setting called "Beautify Lua"
1 parent 86dba01 commit 929fa2b

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

Python/convert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def convert():
4040

4141
converter_walk(input_folder_path, output_folder_path)
4242

43-
stylua.run(input_folder_path, output_folder_path)
43+
if sg.user_settings_get_entry("beautify_lua"):
44+
stylua.run(input_folder_path, output_folder_path)
4445

4546
ini_cst = ini_cst_builder.get_ini_cst(input_folder_path, output_folder_path, input_folder_path)
4647
ini_rules.apply_rules_on_ini_cst(ini_cst)

Python/gui/gui.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ def init_settings():
3030

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

33-
set_default_settings()
33+
default_settings_to_true([
34+
"play_finish_sound",
35+
"beautify_lua"
36+
])
3437

3538

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)
39+
def default_settings_to_true(settings_to_default_to_true):
40+
for setting_to_default_to_true in settings_to_default_to_true:
41+
play_finish_sound_setting = sg.user_settings_get_entry(setting_to_default_to_true)
42+
sg.user_settings_set_entry(setting_to_default_to_true, True if play_finish_sound_setting == None else play_finish_sound_setting)
3943

4044

4145
def run_window():
@@ -76,7 +80,7 @@ def run_window():
7680
settings_window = gui_windows.get_settings_window()
7781
main_window.Disable()
7882

79-
elif event in ("SKIP_CONVERSION", "OUTPUT_ZIPS", "PLAY_FINISH_SOUND"):
83+
elif event in ("SKIP_CONVERSION", "OUTPUT_ZIPS", "PLAY_FINISH_SOUND", "BEAUTIFY_LUA"):
8084
value = values[event]
8185
sg.user_settings_set_entry(event.lower(), value)
8286

Python/gui/gui_windows.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ def get_settings_window_layout():
116116
key="PLAY_FINISH_SOUND",
117117
default=sg.user_settings_get_entry("play_finish_sound"),
118118
enable_events=True,
119+
)],
120+
[sg.Checkbox(
121+
"Beautify Lua",
122+
tooltip=" Fixes the indentation and much more of Lua files ",
123+
key="BEAUTIFY_LUA",
124+
default=sg.user_settings_get_entry("beautify_lua"),
125+
enable_events=True,
119126
)]
120127
]
121128
]

0 commit comments

Comments
 (0)