Major refactor to include tactical combat feed
This commit is contained in:
@@ -8,7 +8,7 @@ require("GameManager/TutorialTextView")
|
||||
---@field MaxLines integer Maximum number of lines to display at once.
|
||||
---@field _KeyOrder string[] Insertion-ordered list of active entry keys (oldest first).
|
||||
---@field _NextId integer Counter used to generate unique entry keys.
|
||||
TutorialTextFeed = setmetatable({}, {__index = TutorialTextView})
|
||||
TutorialTextFeed = setmetatable({}, { __index = TutorialTextView })
|
||||
TutorialTextFeed.__index = TutorialTextFeed
|
||||
|
||||
---Creates a new Tutorial Text Feed.
|
||||
@@ -16,9 +16,9 @@ TutorialTextFeed.__index = TutorialTextFeed
|
||||
---@param maxLines integer Maximum number of lines to display at once.
|
||||
---@return TutorialTextFeed
|
||||
function TutorialTextFeed:New(name, maxLines)
|
||||
local self = TutorialTextView.New(TutorialTextView, name)
|
||||
setmetatable(self, TutorialTextFeed)
|
||||
local self = setmetatable(TutorialTextView:New(name), TutorialTextFeed)
|
||||
|
||||
---@cast self TutorialTextFeed
|
||||
self.MaxLines = maxLines
|
||||
self._KeyOrder = {}
|
||||
self._NextId = 0
|
||||
@@ -33,7 +33,8 @@ end
|
||||
---@param duration number|nil Duration in seconds, defaults to -1 (infinite).
|
||||
---@param color ColorStruct|nil The text color, defaults to white.
|
||||
function TutorialTextFeed:Append(text, duration, color)
|
||||
if #self._KeyOrder >= self.MaxLines then
|
||||
---@diagnostic disable-next-line
|
||||
if table.getn(self._KeyOrder) >= self.MaxLines then
|
||||
local oldestKey = table.remove(self._KeyOrder, 1)
|
||||
self.Entries[oldestKey] = nil
|
||||
if self.IsActive then
|
||||
@@ -68,5 +69,6 @@ end
|
||||
|
||||
function TutorialTextFeed:Debug()
|
||||
return string.format("TutorialTextFeed '%s' (%d/%d lines)",
|
||||
self.Name, #self._KeyOrder, self.MaxLines)
|
||||
---@diagnostic disable-next-line
|
||||
self.Name, table.getn(self._KeyOrder), self.MaxLines)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user