Skip to content

Commit

Permalink
move time machine to options
Browse files Browse the repository at this point in the history
Signed-off-by: Allen Faure <[email protected]>
  • Loading branch information
emptyrivers committed Mar 8, 2024
1 parent 865ce09 commit 69afb1b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 5 deletions.
1 change: 0 additions & 1 deletion WeakAuras/WeakAuras.toc
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ SubRegionTypes\Model.lua

# Misc
Legendaries.lua
TimeMachine.lua
2 changes: 0 additions & 2 deletions WeakAuras/WeakAuras_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,3 @@ SubRegionTypes\Border.lua
SubRegionTypes\Glow.lua
SubRegionTypes\Tick.lua
SubRegionTypes\Model.lua

TimeMachine.lua
2 changes: 0 additions & 2 deletions WeakAuras/WeakAuras_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,3 @@ SubRegionTypes\Border.lua
SubRegionTypes\Glow.lua
SubRegionTypes\Tick.lua
SubRegionTypes\Model.lua

TimeMachine.lua
14 changes: 14 additions & 0 deletions WeakAuras/TimeMachine.lua → WeakAurasOptions/TimeMachine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ end

---@param record actionRecord
function TimeMachine:Append(record)
print('Appending...')
local action = self.actions[record.actionType]
Private.DebugPrint("Forward action", record.actionType, "for", record.uid, "at", keyPathToString(record.path), "with", record.payload)
if not action then
Expand All @@ -175,6 +176,7 @@ end

---@param records actionRecord[]
function TimeMachine:AppendMany(records)
print('Appending many...')
local commit = false
if not self.transaction then
self:StartTransaction()
Expand All @@ -189,6 +191,7 @@ function TimeMachine:AppendMany(records)
end

function TimeMachine:Reject()
print('rejecting...')
self.next = {
forward = {},
backward = {}
Expand All @@ -198,6 +201,7 @@ end

---@param instant? boolean
function TimeMachine:Commit(instant)
print('committing...')
if not self.transaction and not instant then return end
while self.index < #self.changes do
table.remove(self.changes)
Expand All @@ -214,6 +218,7 @@ end
---@param records actionRecord[]
---@param skipEffects? boolean
function TimeMachine:Apply(records, skipEffects)
print('applying...')
local effects = {}
for _, record in ipairs(records) do
local action = self.actions[record.actionType]
Expand All @@ -230,6 +235,7 @@ function TimeMachine:Apply(records, skipEffects)
end
end
if not skipEffects then
print('doing effects...')
for uid, effect in pairs(effects) do
local data = Private.GetDataByUID(uid)
for _, func in pairs(effect) do
Expand All @@ -241,20 +247,23 @@ function TimeMachine:Apply(records, skipEffects)
end

function TimeMachine:StepForward()
print('stepping forward...')
if self.index < #self.changes then
self.index = self.index + 1
self:Apply(self.changes[self.index].forward)
end
end

function TimeMachine:StepBackward()
print('stepping backward...')
if self.index > 0 then
self:Apply(self.changes[self.index].backward)
self.index = self.index - 1
end
end

function TimeMachine:TravelTo(index)
print('traveling to', index, 'from', self.index, '...')
if index < 0 or index > #self.changes then
error("Invalid index: " .. index)
end
Expand All @@ -264,3 +273,8 @@ function TimeMachine:TravelTo(index)
end
self.index = index
end

if DevTool then
DevTool:AddData(TimeMachine, "TimeMachine")
end

2 changes: 2 additions & 0 deletions WeakAurasOptions/WeakAurasOptions.toc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

locales.xml

TimeMachine.lua

ForAllIndentsAndPurposes.lua

RegionOptions\AuraBar.lua
Expand Down
2 changes: 2 additions & 0 deletions WeakAurasOptions/WeakAurasOptions_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

locales.xml

TimeMachine.lua

ForAllIndentsAndPurposes.lua

RegionOptions\AuraBar.lua
Expand Down
2 changes: 2 additions & 0 deletions WeakAurasOptions/WeakAurasOptions_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

locales.xml

TimeMachine.lua

ForAllIndentsAndPurposes.lua

RegionOptions\AuraBar.lua
Expand Down

0 comments on commit 69afb1b

Please sign in to comment.