Skip to content

Commit 0b6acd5

Browse files
committed
Ascii art & Kanji handling
added ascii art to give feedback to the user and give a better idea of what went wrong
1 parent f564691 commit 0b6acd5

2 files changed

Lines changed: 132 additions & 9 deletions

File tree

FT_Builder.py

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,42 @@ def print_ascii_art():
2424
print(ascii_art)
2525
print(credits)
2626

27+
def print_ascii_Ready():
28+
ascii_art = r"""
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
_ _ __ _ _ ____ ____ __ __ ____ ____
48+
( \/ )/ \ / )( \( _ \ ( __)( )( ) ( __)/ ___)
49+
) /( O )) \/ ( ) / ) _) )( / (_/\ ) _) \___ \
50+
(__/ \__/ \____/(__\_) (__) (__)\____/(____)(____/
51+
__ ____ ____ ____ ____ __ ____ _ _ _
52+
/ _\ ( _ \( __) ( _ \( __) / _\ ( \( \/ ) / \
53+
/ \ ) / ) _) ) / ) _) / \ ) D ( ) / \_/
54+
\_/\_/(__\_)(____) (__\_)(____)\_/\_/(____/(__/ (_)
55+
"""
56+
check = r"""
57+
Evrything should be all up and ready in the folder
58+
59+
"""
60+
print(ascii_art)
61+
print(check)
62+
2763

2864
def get_file_path(prompt):
2965
root = tk.Tk()
@@ -86,7 +122,7 @@ def get_assets_relative_path(file_path):
86122

87123
#fonction that will take care of modifying the right lines of code in the patcher
88124
def modify_python_patcher_script(original_model_path, original_meta_file_path, diff_file_name, meta_diff_file_name, output_name, NameCustomScript):
89-
with open('PythonPatcher.py', 'r') as file:
125+
with open('PythonPatcher.py', 'r', encoding='utf-8') as file: # Open the file in UTF-8 encoding
90126
script_content = file.read()
91127

92128
script_content = script_content.replace(
@@ -110,28 +146,35 @@ def modify_python_patcher_script(original_model_path, original_meta_file_path, d
110146
f'output_name = "{output_name}"'
111147
)
112148

113-
with open("! "+NameCustomScript+"Patcher.py", 'w') as file:
114-
file.write(script_content)
149+
with open("! "+NameCustomScript+"Patcher.py", 'wb') as file: # Open the file in binary write mode
150+
encoded_content = script_content.encode('utf-8') # Encode the content as bytes
151+
file.write(encoded_content)
115152

116153
print("Modified script and saved it as '! " + NameCustomScript + "Patcher.py'")
117154

118155

119156

120157

121158

159+
122160
def main():
161+
os.environ['PYTHONIOENCODING'] = 'utf-8'
123162

124163
print_ascii_art()
125164

126-
# Get the required info to proceed
127165

166+
# Get the required info to proceed
128167

168+
print("Please select the original FBX file")
129169
OriginalFBX = get_file_path("Please select the original FBX file")
130170
while not os.path.isfile(OriginalFBX):
171+
print("Please select a valid original FBX file")
131172
OriginalFBX = get_file_path("Please select a valid original FBX file")
132173

174+
print("Please select the Face tracked FBX file")
133175
FaceTrackedFBX = get_file_path("Please select the Face tracked FBX file")
134176
while not os.path.isfile(FaceTrackedFBX):
177+
print("Please select a valid Face tracked FBX file")
135178
FaceTrackedFBX = get_file_path("Please select a valid Face tracked FBX file")
136179

137180

@@ -150,7 +193,7 @@ def main():
150193

151194

152195

153-
196+
print("Please select the directory with your descriptions and readme files (leave empty to skip) (window may not be focused, check your alt+tab to find the window)")
154197
DescriptionDir = get_directory_path("Please select the directory with your descriptions and readme files (leave empty to skip)")
155198

156199
if DescriptionDir!="":
@@ -273,5 +316,8 @@ def main():
273316
)
274317

275318

319+
print_ascii_Ready()
320+
321+
276322
if __name__ == "__main__":
277323
main()

PythonPatcher.py

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,76 @@ def print_ascii_art():
1414
(__) \_/\_/ \___)(____) (__) (__\_)\_/\_/ \___)(__\_)(__)\_)__) \___/ (__) \_/\_/(__) \___)\_)(_/(____)(__\_)
1515
"""
1616
credits = r"""
17-
Made By Hash - v1.0
17+
Made By Hash - v1.2
1818
1919
2020
"""
2121
print(ascii_art)
2222
print(credits)
2323

24+
def print_ascii_success():
25+
ascii_art = r"""
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
____ _ _ ___ ____ ____ ____ _
45+
/ ___)/ )( \ / __)( __)/ ___)/ ___) / \
46+
\___ \) \/ (( (__ ) _) \___ \\___ \ \_/
47+
(____/\____/ \___)(____)(____/(____/ (_)
48+
"""
49+
desc = r"""
50+
Please import the prefab in your scene
51+
52+
53+
54+
55+
"""
56+
print(ascii_art)
57+
print(desc)
58+
59+
def print_ascii_error():
60+
ascii_art = r"""
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
____ ____ ____ __ ____
80+
( __)( _ \( _ \ / \( _ \
81+
) _) ) / ) /( O )) /
82+
(____)(__\_)(__\_) \__/(__\_)
83+
"""
84+
85+
print(ascii_art)
86+
2487
def resource_path(relative_path):
2588
""" Get absolute path to resource, works for dev and for PyInstaller """
2689
try:
@@ -57,15 +120,21 @@ def patch_model(original_model_path, original_meta_file_path, diff_file_path, me
57120
diff_file = resource_path(diff_file_path)
58121
meta_diff_file = resource_path(meta_diff_file_path)
59122

123+
ErrorFlag = False
124+
60125
if not os.path.exists(original_model):
61126
error_msg = f"Please make sure you have the original .fbx at:\n{original_model}"
127+
print_ascii_error()
62128
print(error_msg)
63129
input("Press Enter to continue...")
130+
ErrorFlag = True
64131
return
65132

66133
if not os.path.exists(diff_file):
134+
print_ascii_error()
67135
print("Missing diff file")
68136
input("Press Enter to continue...")
137+
ErrorFlag = True
69138
return
70139

71140
backup_dir = os.path.abspath(os.path.join(__file__, '..', '..', 'fbx'))
@@ -82,20 +151,27 @@ def patch_model(original_model_path, original_meta_file_path, diff_file_path, me
82151
patched_meta_file = os.path.join(backup_dir, f'{output_name}.meta')
83152

84153
if subprocess.run([patcher_exe, '-f', patched_model, diff_file, patched_model]).returncode != 0:
154+
print_ascii_error()
85155
print("Error occurred during patching process for model.")
86156
input("Press Enter to continue...")
157+
ErrorFlag = True
87158
return
88159

89160
if subprocess.run([patcher_exe, '-f', patched_meta_file, meta_diff_file, patched_meta_file]).returncode != 0:
161+
print_ascii_error()
90162
print("Error occurred during patching process for meta file.")
91163
input("Press Enter to continue...")
164+
ErrorFlag = True
92165
return
166+
return ErrorFlag
93167

94168

95169
def main():
96170
print_ascii_art()
97171

98-
patch_model(
172+
ErrorFlag = False
173+
174+
ErrorFlag = patch_model(
99175
original_model_path="../../../ Location of your FBX relative to Assets", # Change this to the relative directory to your FBX
100176
original_meta_file_path="../../../ Location of your FBX.meta relative to Assets", # Change this to the relative directory to your FBX's import settings
101177
diff_file_path="data/DiffFiles/NameOfYourDiffFile.hdiff", # Change the name to the name of the Hdiff file you generated
@@ -105,8 +181,9 @@ def main():
105181

106182
delete_files_in_directory(os.path.join(os.path.expanduser("~"), "AppData", "LocalLow", "VRChat", "VRChat", "OSC"))
107183

108-
print("Patch complete! Please read the documentation and instructions.")
109-
input("Press Enter to exit...")
184+
if ErrorFlag==False:
185+
print_ascii_success()
186+
input("Press Enter to continue...")
110187

111188
if __name__ == "__main__":
112189
main()

0 commit comments

Comments
 (0)