Skip to content

Commit f754946

Browse files
author
arch
committed
add data reprocessing to ofs extension #22
1 parent 46b6253 commit f754946

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

contrib/Installer/assets/main.lua

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ end
4545
platform = get_platform()
4646

4747
function binding.start_funscript_generator()
48+
exec_mtfg(false)
49+
end
50+
51+
function exec_mtfg(no_tracking)
4852
if processHandleMTFG then
4953
print('MTFG already running')
5054
return
@@ -112,6 +116,10 @@ function binding.start_funscript_generator()
112116
table.insert(args, tostring(math.floor(next_action.at*1000.0)))
113117
end
114118

119+
if no_tracking then
120+
table.insert(args, "--no-tracking")
121+
end
122+
115123
print("cmd: ", cmd)
116124
print("args: ", table.unpack(args))
117125

@@ -121,6 +129,26 @@ function binding.start_funscript_generator()
121129
end
122130

123131

132+
function delete_range(script, start_of_range, end_of_range)
133+
local fps = player.FPS()
134+
local frame_time = 1.0/fps
135+
for idx, action in ipairs(script.actions) do
136+
if action.at >= (start_of_range - frame_time) and action.at <= (end_of_range + frame_time) then
137+
script:markForRemoval(idx)
138+
end
139+
end
140+
print("delete range", start_of_range, end_of_range)
141+
script:removeMarked()
142+
end
143+
144+
145+
function tableLength(T)
146+
local count = 0
147+
for _ in pairs(T) do count = count + 1 end
148+
return count
149+
end
150+
151+
124152
function import_funscript_generator_json_result()
125153
status = "MTFG not running"
126154
local tmpFile = ofs.ExtensionDir() .. "/" .. tmpFileName
@@ -147,6 +175,7 @@ function import_funscript_generator_json_result()
147175
if name and name == scriptNames[v.idx] then
148176
if actions[k] then
149177
script = ofs.Script(i)
178+
delete_range(script, actions[k][1]["at"] / 1000.0, actions[k][#(actions[k])]["at"] / 1000.0)
150179
for _, action in pairs(actions[k]) do
151180
local closest_action, _ = script:closestAction(action["at"])
152181
local new_action = Action.new(action["at"]/1000.0, action["pos"], true)
@@ -164,9 +193,10 @@ function import_funscript_generator_json_result()
164193
end
165194
else
166195
script = ofs.Script(scriptIdx)
167-
168196
for metric, actions_metric in pairs(actions) do
169197
print('add ', metric, ' to ', ofs.ScriptName(scriptIdx))
198+
print(type(actions_metric))
199+
delete_range(script, actions_metric[1]["at"] / 1000.0, actions_metric[#actions_metric]["at"] / 1000.0)
170200
for _, action in pairs(actions_metric) do
171201
local closest_action, _ = script:closestAction(action["at"]/1000.0)
172202
local new_action = Action.new(action["at"]/1000.0, action["pos"], true)
@@ -388,9 +418,12 @@ function gui()
388418

389419
ofs.SameLine()
390420
if not processHandleMTFG then
391-
392421
if ofs.Button("Start MTFG") then
393-
binding.start_funscript_generator()
422+
exec_mtfg(false)
423+
end
424+
ofs.SameLine()
425+
if ofs.Button("Reprocess Data") then
426+
exec_mtfg(true)
394427
end
395428
else
396429
if ofs.Button("Kill MTFG") then

funscript_editor/ui/funscript_generator_window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def continue_with_tracking_result(self):
114114

115115
current_video_filename = os.path.basename(self.video_file)
116116
if cache_content["videoFile"] != current_video_filename:
117-
self.__show_message(f"tracking result for {current_video_filename} not found")
117+
self.__show_message(f"Tracking result for {current_video_filename} not found")
118118
sys.exit()
119119

120120
if cache_content["fps"] != self.video_info.fps:

0 commit comments

Comments
 (0)