Skip to content

Commit 7e89237

Browse files
committed
add title box and clean up console output
1 parent 37a91a5 commit 7e89237

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

gm8x_fix.lua

+30-7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ local function patch_exe(file, patches)
4040
end
4141
end
4242

43+
local titleBox = table.concat({
44+
"+-----------------------------------------+",
45+
"| gm8x_fix_lua v0.2 -- Feb 6th 2023 |",
46+
"| https://github.com/Apis035/gm8x_fix_lua |",
47+
"+-----------------------------------------+",
48+
"",
49+
}, "\n")
50+
4351
local help = table.concat({
4452
"Usage: " .. arg[0] .. " file [options]",
4553
" or drag the game file into the patcher.",
@@ -63,7 +71,11 @@ local disabledPatch = {}
6371
for i=1, #arg do
6472
local arg = arg[i]
6573

66-
if arg == "-h" then print(help) exit(1)
74+
if arg == "-h" then
75+
print(titleBox)
76+
print(help)
77+
exit(1)
78+
6779
elseif arg == "-s" then isSilent = true
6880
elseif arg == "-nb" then makeBackup = false
6981
elseif arg == "-nj" then disabledPatch[PatchType.JOY] = true
@@ -77,20 +89,21 @@ for i=1, #arg do
7789
else inputFile = arg end
7890
end
7991

80-
-- Disable print and prompt if silent mode is on
81-
if isSilent then
82-
print = function(...) end
83-
prompt = function(...) return true end
92+
-- Show title if not in silent mode
93+
if not isSilent or inputFile == nil then
94+
print(titleBox)
8495
end
8596

8697
-- Check if user disabled all patches
8798
local isAllPatchesDisabled = true
99+
88100
for i=1, #PatchType do
89101
if disabledPatch[i] ~= true then
90102
isAllPatchesDisabled = false
91103
break
92104
end
93105
end
106+
94107
if isAllPatchesDisabled then
95108
print "All patches is disabled, no operation will be performed."
96109
exit(1)
@@ -99,13 +112,20 @@ end
99112
-- No file specified
100113
if inputFile == nil then
101114
print "Input file is not specified."
115+
print ""
102116
print(help)
103117
exit(1)
104118
end
105119

120+
-- Disable print and prompt if silent mode is on
121+
if isSilent then
122+
print = function(...) end
123+
prompt = function(...) return true end
124+
end
125+
106126
--| Reading input file |--------------------------------------------------------
107127

108-
print("Inspecting file %s...", inputFile)
128+
print("Inspecting file %s...\n", inputFile)
109129

110130
local file, err = io.open(inputFile, "r+b")
111131

@@ -163,6 +183,7 @@ if hasAppliedPatch then
163183
end
164184
end
165185
end
186+
print ""
166187

167188
-- List applicable patches
168189
if canApplyPatch then
@@ -178,12 +199,13 @@ else
178199
file:close()
179200
exit(1)
180201
end
202+
print ""
181203

182204
--| Applying patches |----------------------------------------------------------
183205

184206
-- Backup file
185207
if makeBackup then
186-
print "Backup will be made before applying patches."
208+
print "Backup will be made before applying patches.\n"
187209

188210
local backupName = inputFile .. '.bak'
189211
local backupFile = io.open(backupName, "rb")
@@ -203,6 +225,7 @@ if makeBackup then
203225
os.execute("copy " .. inputFile .. " " .. backupName)
204226
end
205227
end
228+
print ""
206229

207230
-- Begin applying patch
208231
local joystickPatched = false

0 commit comments

Comments
 (0)