Skip to content

Commit 695e31d

Browse files
author
arch
committed
improve ofs extension
1 parent d298012 commit 695e31d

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

contrib/Installer/assets/main.lua

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

2-
processHandle = nil
2+
processHandleMTFG = nil
33
processHandleConfigDir = nil
4+
processHandleLogFile = nil
5+
logfileExist = false
6+
updateCounter = 0
47
scriptIdx = 0
58
status = "MTFG not running"
69

@@ -26,15 +29,15 @@ function start_funscript_generator()
2629
print("nextAction: ", next_action and tostring(script.actions[next_action].at) or "nil")
2730

2831
if next_action then
29-
processHandle = ofs.CreateProcess(
32+
processHandleMTFG = ofs.CreateProcess(
3033
cmd, "--generator",
3134
"-s", tostring(currentTimeMs),
3235
"-e", tostring(script.actions[next_action].at),
3336
"-i", video,
3437
"-o", tmpFile
3538
)
3639
else
37-
processHandle = ofs.CreateProcess(
40+
processHandleMTFG = ofs.CreateProcess(
3841
cmd, "--generator",
3942
"-s", tostring(currentTimeMs),
4043
"-i", video,
@@ -78,24 +81,40 @@ end
7881

7982

8083
function update(delta)
81-
if processHandle and not ofs.IsProcessAlive(processHandle) then
84+
updateCounter = updateCounter + 1
85+
if processHandleMTFG and not ofs.IsProcessAlive(processHandleMTFG) then
8286
print('funscript generator completed import result')
83-
processHandle = nil
87+
processHandleMTFG = nil
8488
import_funscript_generator_result()
8589
end
90+
if math.fmod(updateCounter, 1000) then
91+
local f = io.open("C:/Temp/funscript_editor.log")
92+
if f then
93+
logfileExist = true
94+
else
95+
logfileExist = false
96+
end
97+
end
8698
end
8799

88100

89101
function gui()
90102
ofs.Text(status)
91-
if not processHandle then
103+
if not processHandleMTFG then
92104
ofs.SameLine()
93105
if ofs.Button("Start MTFG") then
94106
start_funscript_generator()
95107
end
96108
end
97109
ofs.SameLine()
98-
if ofs.Button("Open Config Directory") then
110+
if ofs.Button("Open Config") then
99111
processHandleConfigDir = ofs.CreateProcess("explorer.exe", ofs.ExtensionDir().."\\funscript-editor\\funscript_editor\\config")
100112
end
113+
114+
if logfileExist then
115+
ofs.SameLine()
116+
if ofs.Button("Open Log") then
117+
processHandleLogFile = ofs.CreateProcess("notepad.exe", "C:/Temp/funscript_editor.log")
118+
end
119+
end
101120
end

0 commit comments

Comments
 (0)