@@ -93,7 +93,7 @@ def extract_file(archive, src_path, dst_path):
93
93
#===============================================================================
94
94
95
95
@dataclass
96
- class Mod :
96
+ class Option :
97
97
id : str = ""
98
98
name : str = ""
99
99
category : str = ""
@@ -129,9 +129,9 @@ def __init__(self):
129
129
self ._game_dir_editor = PathEdit ("Game Directory" , QFileDialog .Directory , str (find_game_dir ()))
130
130
self ._output_dir_editor = PathEdit ("Output Directory" , QFileDialog .Directory , str (find_mods_dir ()))
131
131
132
- self ._mod_tree = ModTreeWidget ()
133
- self ._mod_tree . modSelected .connect (self ._on_mod_tree_mod_selected )
134
- self ._mod_tree .load ()
132
+ self ._option_tree = OptionTreeWidget ()
133
+ self ._option_tree . optionSelected .connect (self ._on_option_tree_option_selected )
134
+ self ._option_tree .load ()
135
135
136
136
self ._description_box = QTextEdit ()
137
137
self ._description_box .set_maximum_size (self ._description_box .maximum_width (), 120 )
@@ -145,7 +145,7 @@ def __init__(self):
145
145
self ._layout .set_contents_margins (10 , 10 , 10 , 10 )
146
146
self ._layout .add_widget (self ._game_dir_editor )
147
147
self ._layout .add_widget (self ._output_dir_editor )
148
- self ._layout .add_widget (self ._mod_tree )
148
+ self ._layout .add_widget (self ._option_tree )
149
149
self ._layout .add_widget (self ._description_box )
150
150
self ._layout .add_widget (self ._build_button )
151
151
@@ -170,7 +170,7 @@ def __init__(self):
170
170
status_bar .add_permanent_widget (self ._version_label )
171
171
172
172
def close_event (self , event ):
173
- self ._mod_tree .save ()
173
+ self ._option_tree .save ()
174
174
event .accept ()
175
175
176
176
def _validate_game_kpf (self ):
@@ -192,7 +192,7 @@ def _build_mod(self):
192
192
data_dir = frozen_path ("Data" ),
193
193
build_dir = frozen_path ("Build" ),
194
194
output_path = self ._output_dir_editor .path () / MOD_KPF_NAME ,
195
- build_params = self ._mod_tree .build_params ()
195
+ build_params = self ._option_tree .build_params ()
196
196
)
197
197
self ._builder .statusUpdated .connect (self ._on_build_status_updated )
198
198
self ._builder .finished .connect (self ._on_build_finished )
@@ -206,8 +206,8 @@ def _show_message_box(self, title, icon, text):
206
206
msg_box .set_window_title (title )
207
207
msg_box .exec ()
208
208
209
- def _on_mod_tree_mod_selected (self , mod ):
210
- self ._description_box .set_text (mod .long_description )
209
+ def _on_option_tree_option_selected (self , option ):
210
+ self ._description_box .set_text (option .long_description )
211
211
212
212
def _on_build_button_clicked (self ):
213
213
if not (self ._game_dir_editor .path () / GAME_KPF_NAME ).is_file ():
@@ -297,8 +297,8 @@ def _on_open_button_clicked(self):
297
297
298
298
#===============================================================================
299
299
300
- class ModTreeWidget (QTreeWidget ):
301
- modSelected = Signal (Mod )
300
+ class OptionTreeWidget (QTreeWidget ):
301
+ optionSelected = Signal (Option )
302
302
303
303
def __init__ (self , parent = None ):
304
304
super ().__init__ (parent )
@@ -308,21 +308,21 @@ def __init__(self, parent = None):
308
308
def load (self ):
309
309
config = self ._load_config ()
310
310
311
- with open (frozen_path ("Resources/Mods .json" ), "r" ) as json_file :
311
+ with open (frozen_path ("Resources/Options .json" ), "r" ) as json_file :
312
312
categories = defaultdict (list )
313
313
314
- for mod_data in json .load (json_file ):
315
- description = mod_data .pop ("description" , "" )
314
+ for option_data in json .load (json_file ):
315
+ description = option_data .pop ("description" , "" )
316
316
317
317
if isinstance (description , list ):
318
- mod_data ["short_description" ] = description [0 ].removesuffix ("<br>" )
319
- mod_data ["long_description" ] = "" .join (description )
318
+ option_data ["short_description" ] = description [0 ].removesuffix ("<br>" )
319
+ option_data ["long_description" ] = "" .join (description )
320
320
else :
321
- mod_data ["short_description" ] = description
322
- mod_data ["long_description" ] = description
321
+ option_data ["short_description" ] = description
322
+ option_data ["long_description" ] = description
323
323
324
- mod = Mod (** mod_data )
325
- categories [mod .category ].append (mod )
324
+ option = Option (** option_data )
325
+ categories [option .category ].append (option )
326
326
327
327
category_font = QFont ()
328
328
category_font .set_bold (True )
@@ -337,18 +337,18 @@ def load(self):
337
337
# NOTE: Should be called after appending to a tree
338
338
category_item .set_expanded (True )
339
339
340
- for mod in category :
341
- mod_item = QTreeWidgetItem ([mod .name ])
342
- mod_item .set_check_state (0 , Qt .Checked if config .get (mod .id , True ) else Qt .Unchecked )
343
- mod_item .set_data (0 , Qt .UserRole , mod )
344
- mod_item .set_tool_tip (0 , mod .short_description )
345
- category_item .add_child (mod_item )
340
+ for option in category :
341
+ option_item = QTreeWidgetItem ([option .name ])
342
+ option_item .set_check_state (0 , Qt .Checked if config .get (option .id , True ) else Qt .Unchecked )
343
+ option_item .set_data (0 , Qt .UserRole , option )
344
+ option_item .set_tool_tip (0 , option .short_description )
345
+ category_item .add_child (option_item )
346
346
347
347
def save (self ):
348
348
self ._save_config ()
349
349
350
350
def build_params (self ):
351
- return [BuildParam (enabled , mod .definition , mod .script ) for enabled , mod in self ._mods ()]
351
+ return [BuildParam (enabled , option .definition , option .script ) for enabled , option in self ._options ()]
352
352
353
353
def _load_config (self ):
354
354
if not Path ("Settings.ini" ).exists ():
@@ -358,36 +358,36 @@ def _load_config(self):
358
358
config = ConfigParser ()
359
359
config .read_file (config_file )
360
360
361
- if not config .has_section ("mods " ):
361
+ if not config .has_section ("options " ):
362
362
return dict ()
363
363
364
- return {key : config .getboolean ("mods " , key ) for key in config .options ("mods " )}
364
+ return {key : config .getboolean ("options " , key ) for key in config .options ("options " )}
365
365
366
366
def _save_config (self ):
367
367
with open ("Settings.ini" , "w" ) as config_file :
368
368
config = ConfigParser ()
369
- config .add_section ("mods " )
369
+ config .add_section ("options " )
370
370
371
- for enabled , mod in self ._mods ():
372
- config .set ("mods " , mod .id , str (enabled ).lower ())
371
+ for enabled , option in self ._options ():
372
+ config .set ("options " , option .id , str (enabled ).lower ())
373
373
374
374
config .write (config_file )
375
375
376
- def _mods (self ):
376
+ def _options (self ):
377
377
items = (self .top_level_item (i ) for i in range (self .top_level_item_count ()))
378
378
children = lambda item : (item .child (i ) for i in range (item .child_count ()))
379
379
380
380
return (
381
- (mod_item .check_state (0 ) == Qt .Checked , mod_item .data (0 , Qt .UserRole ))
381
+ (option_item .check_state (0 ) == Qt .Checked , option_item .data (0 , Qt .UserRole ))
382
382
for category_item in items
383
- for mod_item in children (category_item )
383
+ for option_item in children (category_item )
384
384
)
385
385
386
386
def _on_item_changed (self , item ):
387
387
user_data = item .data (0 , Qt .UserRole )
388
388
389
389
if user_data != "CATEGORY" :
390
- self .modSelected .emit (user_data )
390
+ self .optionSelected .emit (user_data )
391
391
392
392
#===============================================================================
393
393
0 commit comments