6
6
from Python import convert
7
7
8
8
9
- warning_rules = {} # A global that's initialized in load_conversion_and_warning_rules()
10
-
11
-
12
9
MANUAL_REPLACEMENT_TITLE_SEPARATOR = "=" * 50
13
- mods_warnings = None # A global list set in init_mods_warnings()
14
-
15
- def init_mods_warnings ():
16
- global mods_warnings
17
- mods_warnings = [
18
- "\n " .join (
19
- (MANUAL_REPLACEMENT_TITLE_SEPARATOR , "LINES REQUIRING MANUAL REPLACEMENT" , MANUAL_REPLACEMENT_TITLE_SEPARATOR )
20
- )
21
- ]
22
10
11
+ mods_warnings = []
23
12
24
13
FRESH_CONVERSION_RULES_REMINDER = "You can get a fresh Conversion Rules folder by redownloading the Legacy Mod Converter from its GitHub repository with the below button."
25
14
26
15
16
+ warning_rules = {}
27
17
def load_conversion_and_warning_rules ():
28
18
try :
29
19
for folder_path , subfolders , subfiles in os .walk ("Conversion Rules" ):
@@ -51,51 +41,29 @@ def check_github_button_clicked_and_exit(clicked_github_button):
51
41
sys .exit ()
52
42
53
43
54
- mod_warnings = None # A global list set in clear_mod_warnings()
55
- def clear_mod_warnings ():
56
- global mod_warnings
57
- mod_warnings = []
58
-
59
-
60
44
def append_mod_replacement_warnings (line , file_path , line_number ):
61
45
for old_str , new_str in warning_rules .items ():
62
46
if old_str in line :
63
- append_mod_replacement_warning (file_path , line_number , old_str , new_str )
64
-
65
-
66
- def append_mod_replacement_warning (file_path , line_number , old_str , new_str ):
67
- append_mod_warning (file_path , line_number , f"Replace '{ old_str } ' with" , f"'{ new_str } '" )
47
+ append_mod_warning (file_path , line_number , f"\" { old_str } \" " , new_str )
68
48
69
49
70
50
def append_mod_warning (file_path , line_number , error , error_subject ):
71
- global mod_warnings
51
+ global mods_warnings
72
52
warning = f"\n Line { line_number } at { file_path } \n \t { error } : { error_subject } "
73
- mod_warnings .append (warning )
74
-
75
-
76
- def prepend_mod_title (mod_name ):
77
- title = "\n " + "\n " .join (
78
- (cfg .WARNINGS_MOD_NAME_SEPARATOR , f"\t { mod_name } " , cfg .WARNINGS_MOD_NAME_SEPARATOR )
79
- )
80
- mod_warnings .insert (0 , title )
81
-
82
-
83
- def push_mod_warnings ():
84
- global mod_warnings
85
- mods_warnings .extend (mod_warnings )
53
+ mods_warnings .append (warning )
86
54
87
55
88
56
def show_popup_if_necessary ():
89
- if len (mods_warnings ) > 1 : # mods_warnings is initialized with a first line, so mods_warnings starts with a len of 1.
57
+ if len (mods_warnings ) > 0 :
90
58
warnings_popup ()
91
59
92
60
93
61
def warnings_popup ():
94
- message = "\n " .join (mods_warnings )
62
+ message = f" { MANUAL_REPLACEMENT_TITLE_SEPARATOR } \n LINES REQUIRING MANUAL REPLACEMENT \n { MANUAL_REPLACEMENT_TITLE_SEPARATOR } \n " + "\n " .join (mods_warnings )
95
63
96
64
w = max (
97
65
30 ,
98
- len (get_longest_line_length (message )) + 1 # TODO: Add a comment here on why + 1 is necessary .
66
+ len (get_longest_line (message )) # Can't divide by two or anything because the line wrapping will cause the height of the window to be wrong, making user have to scroll .
99
67
)
100
68
h = min (
101
69
50 ,
@@ -111,5 +79,5 @@ def warnings_popup():
111
79
)
112
80
113
81
114
- def get_longest_line_length (message ):
82
+ def get_longest_line (message ):
115
83
return max (message .split ("\n " ), key = len )
0 commit comments