mirror of
https://github.com/kepler155c/opus
synced 2025-01-11 16:20:26 +00:00
script bug, improve recorder
This commit is contained in:
parent
ddeaddae3d
commit
3fdd7336f1
@ -8,7 +8,7 @@ local GROUPS_PATH = '/apps/groups'
|
|||||||
local SCRIPTS_PATH = '/apps/scripts'
|
local SCRIPTS_PATH = '/apps/scripts'
|
||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Script')
|
multishell.setTitle(multishell.getCurrent(), 'Script')
|
||||||
UI:configure('Script', ...)
|
UI:configure('script', ...)
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
showGroups = false,
|
showGroups = false,
|
||||||
@ -17,7 +17,7 @@ local config = {
|
|||||||
}]],
|
}]],
|
||||||
}
|
}
|
||||||
|
|
||||||
Config.load('Script', config)
|
Config.load('script', config)
|
||||||
|
|
||||||
local width = math.floor(UI.term.width / 2) - 1
|
local width = math.floor(UI.term.width / 2) - 1
|
||||||
if UI.term.width % 2 ~= 0 then
|
if UI.term.width % 2 ~= 0 then
|
||||||
@ -453,7 +453,7 @@ function mainPage:eventHandler(event)
|
|||||||
-- self.statusBar.toggleButton.text = text
|
-- self.statusBar.toggleButton.text = text
|
||||||
self:draw()
|
self:draw()
|
||||||
|
|
||||||
Config.update('Script', config)
|
Config.update('script', config)
|
||||||
|
|
||||||
elseif event.type == 'grid_focus_row' then
|
elseif event.type == 'grid_focus_row' then
|
||||||
local computer = self.computers:getSelected()
|
local computer = self.computers:getSelected()
|
||||||
|
@ -14,12 +14,17 @@ local version = "Version 1.1.6"
|
|||||||
-- Original code by Bomb Bloke
|
-- Original code by Bomb Bloke
|
||||||
-- Modified to integrate with opus os
|
-- Modified to integrate with opus os
|
||||||
|
|
||||||
local calls, recTerm, oldTerm, arg, showInput, skipLast, lastDelay, curInput, callCount, callListCount = {{["delay"] = 0}}, {}, Util.shallowCopy(multishell.term), {...}, false, false, 2, "", 1, 2
|
local recTerm, oldTerm, arg, showInput, skipLast, lastDelay, curInput = {}, Util.shallowCopy(multishell.term), {...}, false, false, 2, ""
|
||||||
local curBlink, oldBlink, curCalls, tTerm, buffer, colourNum, xPos, yPos, oldXPos, oldYPos, tCol, bCol, xSize, ySize = false, false, calls[1], {}, {}, {}, 1, 1, 1, 1, colours.white, colours.black, oldTerm.getSize()
|
local curBlink, oldBlink, tTerm, buffer, colourNum, xPos, yPos, oldXPos, oldYPos, tCol, bCol, xSize, ySize = false, false, {}, {}, {}, 1, 1, 1, 1, colours.white, colours.black, oldTerm.getSize()
|
||||||
local greys, buttons = {["0"] = true, ["7"] = true, ["8"] = true, ["f"] = true}, {"l", "r", "m"}
|
local greys, buttons = {["0"] = true, ["7"] = true, ["8"] = true, ["f"] = true}, {"l", "r", "m"}
|
||||||
local charW, charH, chars, resp
|
local charW, charH, chars, resp
|
||||||
local filename
|
local filename
|
||||||
|
|
||||||
|
local calls = { }
|
||||||
|
local curCalls = { delay = 0 }
|
||||||
|
local callListCount = 0
|
||||||
|
local callCount = 0
|
||||||
|
|
||||||
local function showSyntax()
|
local function showSyntax()
|
||||||
print('Gif Recorder by Bomb Bloke\n')
|
print('Gif Recorder by Bomb Bloke\n')
|
||||||
print('Syntax: recGif [-i] [-s] [-ld:<delay>] filename')
|
print('Syntax: recGif [-i] [-s] [-ld:<delay>] filename')
|
||||||
@ -123,13 +128,14 @@ recTerm = multishell.term
|
|||||||
|
|
||||||
for key, func in pairs(oldTerm) do
|
for key, func in pairs(oldTerm) do
|
||||||
recTerm[key] = function(...)
|
recTerm[key] = function(...)
|
||||||
local result = {pcall(func, ...)}
|
local result = { func(...) }
|
||||||
|
|
||||||
if result[1] then
|
if callCount == 0 then
|
||||||
curCalls[callCount] = {key, ...}
|
os.queueEvent('capture_frame')
|
||||||
callCount = callCount + 1
|
end
|
||||||
return unpack(result, 2)
|
callCount = callCount + 1
|
||||||
else error(result[2], 2) end
|
curCalls[callCount] = { key, ... }
|
||||||
|
return unpack(result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -149,36 +155,27 @@ for _,tab in pairs(tabs) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
local curTime = os.clock() - 1
|
||||||
local curTime = os.clock() - 1
|
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local event = { os.pullEventRaw() }
|
local event = { os.pullEventRaw() }
|
||||||
|
|
||||||
if event[1] == 'recorder_stop' or event[1] == 'terminate' then
|
if event[1] == 'recorder_stop' or event[1] == 'terminate' then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if event[1] == 'capture_frame' then
|
||||||
local newTime = os.clock()
|
local newTime = os.clock()
|
||||||
|
|
||||||
if newTime ~= curTime then
|
if callListCount > 0 then
|
||||||
local delay = curCalls.delay + (newTime - curTime)
|
calls[callListCount].delay = (newTime - curTime)
|
||||||
curTime = newTime
|
|
||||||
|
|
||||||
if callCount > 1 then
|
|
||||||
curCalls.delay = curCalls.delay + delay
|
|
||||||
curCalls, callCount = {["delay"] = 0}, 1
|
|
||||||
calls[callListCount] = curCalls
|
|
||||||
callListCount = callListCount + 1
|
|
||||||
elseif callListCount > 2 then
|
|
||||||
calls[callListCount - 2].delay = calls[callListCount - 2].delay + delay
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if showInput and (event[1] == "key" or event[1] == "mouse_click") then
|
curTime = newTime
|
||||||
curCalls[callCount] = {unpack(event)}
|
callListCount = callListCount + 1
|
||||||
callCount = callCount + 1
|
calls[callListCount] = curCalls
|
||||||
end
|
|
||||||
|
curCalls, callCount = { delay = 0 }, 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -196,8 +193,6 @@ if skipLast and #calls > 1 then calls[#calls] = nil end
|
|||||||
|
|
||||||
calls[#calls].delay = lastDelay
|
calls[#calls].delay = lastDelay
|
||||||
|
|
||||||
-- Recording done, bug user as to whether to encode it:
|
|
||||||
|
|
||||||
print(string.format("Encoding %d frames...", #calls))
|
print(string.format("Encoding %d frames...", #calls))
|
||||||
--Util.writeTable('tmp/raw.txt', calls)
|
--Util.writeTable('tmp/raw.txt', calls)
|
||||||
|
|
||||||
@ -463,7 +458,14 @@ for i = 1, #calls do
|
|||||||
|
|
||||||
oldBlink, oldXPos, oldYPos = curBlink, xPos, yPos
|
oldBlink, oldXPos, oldYPos = curBlink, xPos, yPos
|
||||||
|
|
||||||
local thisFrame = {["xstart"] = (xMin - 1) * charW, ["ystart"] = (yMin - 1) * charH, ["xend"] = (xMax - xMin + 1) * charW, ["yend"] = (yMax - yMin + 1) * charH, ["delay"] = curCalls.delay, ["disposal"] = 1}
|
local thisFrame = {
|
||||||
|
["xstart"] = (xMin - 1) * charW,
|
||||||
|
["ystart"] = (yMin - 1) * charH,
|
||||||
|
["xend"] = (xMax - xMin + 1) * charW,
|
||||||
|
["yend"] = (yMax - yMin + 1) * charH,
|
||||||
|
["delay"] = curCalls.delay,
|
||||||
|
["disposal"] = 1
|
||||||
|
}
|
||||||
|
|
||||||
for y = 1, (yMax - yMin + 1) * charH do
|
for y = 1, (yMax - yMin + 1) * charH do
|
||||||
local row = {}
|
local row = {}
|
||||||
@ -515,7 +517,11 @@ for i = 1, #calls do
|
|||||||
snooze()
|
snooze()
|
||||||
end
|
end
|
||||||
|
|
||||||
if changed then image[#image + 1] = thisFrame else image[#image].delay = image[#image].delay + curCalls.delay end
|
if changed then
|
||||||
|
image[#image + 1] = thisFrame
|
||||||
|
else
|
||||||
|
image[#image].delay = image[#image].delay + curCalls.delay
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
buffer = nil
|
buffer = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user