bugfix + changes
- added getMinScroll and getMaxScroll for frames - fixed a small bug with dynamicvalues - textfield got a :clear() function - improved the focus system - fixed a bug with dynamic values getting into a infinite loop
This commit is contained in:
@@ -36,6 +36,9 @@ return function(name, parent, pTerm, basalt)
|
|||||||
local mirrorSide = ""
|
local mirrorSide = ""
|
||||||
local importantScroll = false
|
local importantScroll = false
|
||||||
|
|
||||||
|
local focusedOBjectCache
|
||||||
|
local focusedObject
|
||||||
|
|
||||||
base:setZIndex(10)
|
base:setZIndex(10)
|
||||||
|
|
||||||
local basaltDraw = BasaltDraw(termObject)
|
local basaltDraw = BasaltDraw(termObject)
|
||||||
@@ -151,6 +154,11 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function newDynamicValue(_, obj, str)
|
local function newDynamicValue(_, obj, str)
|
||||||
|
for k,v in pairs(dynamicValues)do
|
||||||
|
if(v[2]==str)and(v[4]==obj)then
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
dynValueId = dynValueId + 1
|
dynValueId = dynValueId + 1
|
||||||
dynamicValues[dynValueId] = {0, str, {}, obj, dynValueId}
|
dynamicValues[dynValueId] = {0, str, {}, obj, dynValueId}
|
||||||
return dynamicValues[dynValueId]
|
return dynamicValues[dynValueId]
|
||||||
@@ -244,14 +252,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
setFocusedObject = function(self, obj)
|
setFocusedObject = function(self, obj)
|
||||||
if (basalt.getFocusedObject() ~= nil) then
|
focusedOBjectCache = obj
|
||||||
basalt.getFocusedObject():loseFocusHandler()
|
|
||||||
basalt.setFocusedObject(nil)
|
|
||||||
end
|
|
||||||
if(obj~=nil)then
|
|
||||||
basalt.setFocusedObject(obj)
|
|
||||||
obj:getFocusHandler()
|
|
||||||
end
|
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -306,24 +307,21 @@ return function(name, parent, pTerm, basalt)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getOffset = function(self)
|
getOffsetInternal = function(self)
|
||||||
return xOffset, yOffset
|
return xOffset, yOffset
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getOffsetInternal = function(self) -- internal
|
getOffset = function(self) -- internal
|
||||||
return xOffset < 0 and math.abs(xOffset) or -xOffset, yOffset < 0 and math.abs(yOffset) or -yOffset
|
return xOffset < 0 and math.abs(xOffset) or -xOffset, yOffset < 0 and math.abs(yOffset) or -yOffset
|
||||||
end;
|
end;
|
||||||
|
|
||||||
removeFocusedObject = function(self)
|
removeFocusedObject = function(self)
|
||||||
if (basalt.getFocusedObject() ~= nil) then
|
focusedOBjectCache = nil
|
||||||
basalt.getFocusedObject():loseFocusHandler()
|
|
||||||
end
|
|
||||||
basalt.setFocusedObject(nil)
|
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getFocusedObject = function(self)
|
getFocusedObject = function(self)
|
||||||
return basalt.getFocusedObject()
|
return focusedObject
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setCursor = function(self, _blink, _xCursor, _yCursor, color)
|
setCursor = function(self, _blink, _xCursor, _yCursor, color)
|
||||||
@@ -371,6 +369,14 @@ return function(name, parent, pTerm, basalt)
|
|||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
getMaxScroll = function(self)
|
||||||
|
return maxScroll
|
||||||
|
end,
|
||||||
|
|
||||||
|
getMinScroll = function(self)
|
||||||
|
return minScroll
|
||||||
|
end,
|
||||||
|
|
||||||
show = function(self)
|
show = function(self)
|
||||||
base.show(self)
|
base.show(self)
|
||||||
if(self.parent==nil)then
|
if(self.parent==nil)then
|
||||||
@@ -534,6 +540,10 @@ return function(name, parent, pTerm, basalt)
|
|||||||
|
|
||||||
loseFocusHandler = function(self)
|
loseFocusHandler = function(self)
|
||||||
base.loseFocusHandler(self)
|
base.loseFocusHandler(self)
|
||||||
|
if(focusedOBjectCache~=nil)then
|
||||||
|
focusedOBjectCache:loseFocusHandler()
|
||||||
|
focusedOBjectCache = nil
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getFocusHandler = function(self)
|
getFocusHandler = function(self)
|
||||||
@@ -545,7 +555,6 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
keyHandler = function(self, event, key)
|
keyHandler = function(self, event, key)
|
||||||
local focusedObject = basalt.getFocusedObject()
|
|
||||||
if (focusedObject ~= nil) then
|
if (focusedObject ~= nil) then
|
||||||
if(focusedObject~=self)then
|
if(focusedObject~=self)then
|
||||||
if (focusedObject.keyHandler ~= nil) then
|
if (focusedObject.keyHandler ~= nil) then
|
||||||
@@ -617,7 +626,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
|
|
||||||
mouseHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (self.drag) then
|
if (self.drag) then
|
||||||
local xO, yO = self.parent:getOffset()
|
local xO, yO = self.parent:getOffsetInternal()
|
||||||
xO = xO < 0 and math.abs(xO) or -xO
|
xO = xO < 0 and math.abs(xO) or -xO
|
||||||
yO = yO < 0 and math.abs(yO) or -yO
|
yO = yO < 0 and math.abs(yO) or -yO
|
||||||
if (event == "mouse_drag") then
|
if (event == "mouse_drag") then
|
||||||
@@ -634,15 +643,14 @@ return function(name, parent, pTerm, basalt)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
local yOff = false
|
local yOff = false
|
||||||
if(objY-1 == y)and(self:getBorder("top"))then
|
if(fy-1 == y)and(self:getBorder("top"))then
|
||||||
y = y+1
|
y = y+1
|
||||||
yOff = true
|
yOff = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if (base.mouseHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
|
||||||
fx = fx + xOffset;fy = fy + yOffset;
|
fx = fx + xOffset;fy = fy + yOffset;
|
||||||
if(isScrollable)and(importantScroll)then
|
if(isScrollable)and(importantScroll)then
|
||||||
if(event=="mouse_scroll")then
|
if(event=="mouse_scroll")then
|
||||||
@@ -662,8 +670,8 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:removeFocusedObject()
|
||||||
if (self.isMoveable) then
|
if (self.isMoveable) then
|
||||||
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
|
||||||
if (x >= fx) and (x <= fx + self:getWidth() - 1) and (y == fy) and (event == "mouse_click") then
|
if (x >= fx) and (x <= fx + self:getWidth() - 1) and (y == fy) and (event == "mouse_click") then
|
||||||
self.drag = true
|
self.drag = true
|
||||||
dragXOffset = fx - x
|
dragXOffset = fx - x
|
||||||
@@ -677,10 +685,6 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (basalt.getFocusedObject() ~= nil) then
|
|
||||||
basalt.getFocusedObject():loseFocusHandler()
|
|
||||||
basalt.setFocusedObject(nil)
|
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -768,6 +772,17 @@ return function(name, parent, pTerm, basalt)
|
|||||||
if(isMonitor)and not(monitorAttached)then return false end;
|
if(isMonitor)and not(monitorAttached)then return false end;
|
||||||
if (self:getVisualChanged()) then
|
if (self:getVisualChanged()) then
|
||||||
if (base.draw(self)) then
|
if (base.draw(self)) then
|
||||||
|
|
||||||
|
if(focusedObject~=focusedOBjectCache)then
|
||||||
|
if(focusedOBjectCache~=nil)then
|
||||||
|
focusedOBjectCache:getFocusHandler()
|
||||||
|
end
|
||||||
|
if(focusedObject~=nil)then
|
||||||
|
focusedObject:loseFocusHandler()
|
||||||
|
end
|
||||||
|
focusedObject = focusedOBjectCache
|
||||||
|
end
|
||||||
|
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
local anchx, anchy = self:getAnchorPosition()
|
local anchx, anchy = self:getAnchorPosition()
|
||||||
local w,h = self:getSize()
|
local w,h = self:getSize()
|
||||||
@@ -851,7 +866,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
addFrame = function(self, name)
|
addFrame = function(self, name)
|
||||||
local obj = basalt.newFrame(name, self, nil, basalt)
|
local obj = basalt.newFrame(name or uuid(), self, nil, basalt)
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,11 +232,11 @@ return function(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
getX = function(self)
|
getX = function(self)
|
||||||
return type(self.x) == "number" and self.x or self.x[1]
|
return type(self.x) == "number" and self.x or math.floor(self.x[1]+0.5)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getY = function(self)
|
getY = function(self)
|
||||||
return type(self.y) == "number" and self.y or self.y[1]
|
return type(self.y) == "number" and self.y or math.floor(self.y[1]+0.5)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getPosition = function(self)
|
getPosition = function(self)
|
||||||
@@ -275,11 +275,11 @@ return function(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
getHeight = function(self)
|
getHeight = function(self)
|
||||||
return type(self.height) == "number" and self.height or self.height[1]
|
return type(self.height) == "number" and self.height or math.floor(self.height[1]+0.5)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getWidth = function(self)
|
getWidth = function(self)
|
||||||
return type(self.width) == "number" and self.width or self.width[1]
|
return type(self.width) == "number" and self.width or math.floor(self.width[1]+0.5)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getSize = function(self)
|
getSize = function(self)
|
||||||
@@ -464,7 +464,7 @@ return function(name)
|
|||||||
y = math.floor(ph/2) + y - 1
|
y = math.floor(ph/2) + y - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local xO, yO = self.parent:getOffset()
|
local xO, yO = self.parent:getOffsetInternal()
|
||||||
if not(ignOffset or ignOff) then
|
if not(ignOffset or ignOff) then
|
||||||
return x+xO, y+yO
|
return x+xO, y+yO
|
||||||
end
|
end
|
||||||
@@ -663,7 +663,7 @@ return function(name)
|
|||||||
if(isDragging)and(event=="mouse_drag")then
|
if(isDragging)and(event=="mouse_drag")then
|
||||||
local xO, yO, parentX, parentY = 0, 0, 1, 1
|
local xO, yO, parentX, parentY = 0, 0, 1, 1
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
xO, yO = self.parent:getOffset()
|
xO, yO = self.parent:getOffsetInternal()
|
||||||
xO = xO < 0 and math.abs(xO) or -xO
|
xO = xO < 0 and math.abs(xO) or -xO
|
||||||
yO = yO < 0 and math.abs(yO) or -yO
|
yO = yO < 0 and math.abs(yO) or -yO
|
||||||
parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition())
|
parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition())
|
||||||
@@ -680,8 +680,10 @@ return function(name)
|
|||||||
dragXOffset, dragYOffset = objX - x, objY - y
|
dragXOffset, dragYOffset = objX - x, objY - y
|
||||||
end
|
end
|
||||||
if(event~="mouse_drag")then
|
if(event~="mouse_drag")then
|
||||||
if (self.parent ~= nil) then
|
if(event~="mouse_up")then
|
||||||
self.parent:setFocusedObject(self)
|
if (self.parent ~= nil) then
|
||||||
|
self.parent:setFocusedObject(self)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local val = eventSystem:sendEvent(event, self, event, button, x, y)
|
local val = eventSystem:sendEvent(event, self, event, button, x, y)
|
||||||
if(val~=nil)then return val end
|
if(val~=nil)then return val end
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
local splitString = function(str, sep)
|
||||||
|
if sep == nil then
|
||||||
|
sep = "%s"
|
||||||
|
end
|
||||||
|
local t={}
|
||||||
|
for v in string.gmatch(str, "([^"..sep.."]+)") do
|
||||||
|
table.insert(t, v)
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getTextHorizontalAlign = function(text, width, textAlign, replaceChar)
|
getTextHorizontalAlign = function(text, width, textAlign, replaceChar)
|
||||||
text = string.sub(text, 1, width)
|
text = string.sub(text, 1, width)
|
||||||
@@ -37,15 +48,26 @@ rpairs = function(t)
|
|||||||
end, t, #t + 1
|
end, t, #t + 1
|
||||||
end,
|
end,
|
||||||
|
|
||||||
splitString = function(str, sep)
|
splitString = splitString,
|
||||||
if sep == nil then
|
|
||||||
sep = "%s"
|
createText = function(str, width)
|
||||||
|
local uniqueLines = splitString(str, "\n")
|
||||||
|
local lines = {}
|
||||||
|
for k,v in pairs(uniqueLines)do
|
||||||
|
local line = ""
|
||||||
|
local words = splitString(v, " ")
|
||||||
|
for a,b in pairs(words)do
|
||||||
|
if(#line+#b <= width)then
|
||||||
|
line = line=="" and b or line.." "..b
|
||||||
|
if(a==#words)then table.insert(lines, line) end
|
||||||
|
else
|
||||||
|
table.insert(lines, line)
|
||||||
|
line = b:sub(1,width)
|
||||||
|
if(a==#words)then table.insert(lines, line) end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local t={}
|
return lines
|
||||||
for v in string.gmatch(str, "([^"..sep.."]+)") do
|
|
||||||
table.insert(t, v)
|
|
||||||
end
|
|
||||||
return t
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getValueFromXML = function(name, tab)
|
getValueFromXML = function(name, tab)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
local basaltEvent = require("basaltEvent")()
|
local basaltEvent = require("basaltEvent")()
|
||||||
local Frame = require("Frame")
|
local Frame = require("Frame")
|
||||||
local theme = require("theme")
|
local theme = require("theme")
|
||||||
local uuid = require("utils").uuid
|
local utils = require("utils")
|
||||||
|
local uuid = utils.uuid
|
||||||
|
local createText = utils.createText
|
||||||
|
|
||||||
local baseTerm = term.current()
|
local baseTerm = term.current()
|
||||||
local version = 4
|
local version = 4
|
||||||
@@ -85,6 +87,41 @@ local bInstance = {
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local basaltError = function(errMsg)
|
||||||
|
baseTerm.clear()
|
||||||
|
baseTerm.setBackgroundColor(colors.black)
|
||||||
|
baseTerm.setTextColor(colors.red)
|
||||||
|
local w,h = baseTerm.getSize()
|
||||||
|
|
||||||
|
local splitString = function(str, sep)
|
||||||
|
if sep == nil then
|
||||||
|
sep = "%s"
|
||||||
|
end
|
||||||
|
local t={}
|
||||||
|
for v in string.gmatch(str, "([^"..sep.."]+)") do
|
||||||
|
table.insert(t, v)
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
local words = splitString(errMsg, " ")
|
||||||
|
local line = "Basalt error: "
|
||||||
|
local yPos = 1
|
||||||
|
for n=1,#words do
|
||||||
|
baseTerm.setCursorPos(1,yPos)
|
||||||
|
if(#line+#words[n]<w)then
|
||||||
|
line = line.." "..words[n]
|
||||||
|
else
|
||||||
|
baseTerm.write(line)
|
||||||
|
line = words[n]
|
||||||
|
yPos = yPos + 1
|
||||||
|
end
|
||||||
|
if(n==#words)then
|
||||||
|
baseTerm.write(line)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
baseTerm.setCursorPos(1,yPos+1)
|
||||||
|
end
|
||||||
|
|
||||||
local function handleShedules(event, p1, p2, p3, p4)
|
local function handleShedules(event, p1, p2, p3, p4)
|
||||||
if(#shedules>0)then
|
if(#shedules>0)then
|
||||||
local finished = {}
|
local finished = {}
|
||||||
@@ -93,7 +130,7 @@ local function handleShedules(event, p1, p2, p3, p4)
|
|||||||
if (coroutine.status(shedules[n]) == "suspended")then
|
if (coroutine.status(shedules[n]) == "suspended")then
|
||||||
local ok, result = coroutine.resume(shedules[n], event, p1, p2, p3, p4)
|
local ok, result = coroutine.resume(shedules[n], event, p1, p2, p3, p4)
|
||||||
if not(ok)then
|
if not(ok)then
|
||||||
table.insert(finished, n)
|
basaltError(result)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
table.insert(finished, n)
|
table.insert(finished, n)
|
||||||
@@ -164,41 +201,6 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
|||||||
drawFrames()
|
drawFrames()
|
||||||
end
|
end
|
||||||
|
|
||||||
local basaltError = function(errMsg)
|
|
||||||
baseTerm.clear()
|
|
||||||
baseTerm.setBackgroundColor(colors.black)
|
|
||||||
baseTerm.setTextColor(colors.red)
|
|
||||||
local w,h = baseTerm.getSize()
|
|
||||||
|
|
||||||
local splitString = function(str, sep)
|
|
||||||
if sep == nil then
|
|
||||||
sep = "%s"
|
|
||||||
end
|
|
||||||
local t={}
|
|
||||||
for v in string.gmatch(str, "([^"..sep.."]+)") do
|
|
||||||
table.insert(t, v)
|
|
||||||
end
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
local words = splitString(errMsg, " ")
|
|
||||||
local line = "Basalt error: "
|
|
||||||
local yPos = 1
|
|
||||||
for n=1,#words do
|
|
||||||
baseTerm.setCursorPos(1,yPos)
|
|
||||||
if(#line+#words[n]<w)then
|
|
||||||
line = line.." "..words[n]
|
|
||||||
else
|
|
||||||
baseTerm.write(line)
|
|
||||||
line = words[n]
|
|
||||||
yPos = yPos + 1
|
|
||||||
end
|
|
||||||
if(n==#words)then
|
|
||||||
baseTerm.write(line)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
baseTerm.setCursorPos(1,yPos+1)
|
|
||||||
end
|
|
||||||
|
|
||||||
local basalt = {}
|
local basalt = {}
|
||||||
basalt = {
|
basalt = {
|
||||||
setTheme = setTheme,
|
setTheme = setTheme,
|
||||||
@@ -277,6 +279,8 @@ basalt = {
|
|||||||
local ok, result = coroutine.resume(co, ...)
|
local ok, result = coroutine.resume(co, ...)
|
||||||
if(ok)then
|
if(ok)then
|
||||||
table.insert(shedules, co)
|
table.insert(shedules, co)
|
||||||
|
else
|
||||||
|
basaltError(result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -316,7 +320,9 @@ basalt = {
|
|||||||
str = str .. tostring(value) .. (#args ~= key and ", " or "")
|
str = str .. tostring(value) .. (#args ~= key and ", " or "")
|
||||||
end
|
end
|
||||||
basalt.debugLabel:setText("[Debug] " .. str)
|
basalt.debugLabel:setText("[Debug] " .. str)
|
||||||
basalt.debugList:addItem(str)
|
for k,v in pairs(createText(str, basalt.debugList:getWidth()))do
|
||||||
|
basalt.debugList:addItem(v)
|
||||||
|
end
|
||||||
if (basalt.debugList:getItemCount() > 50) then
|
if (basalt.debugList:getItemCount() > 50) then
|
||||||
basalt.debugList:removeItem(1)
|
basalt.debugList:removeItem(1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ return function(name)
|
|||||||
|
|
||||||
local animations = {}
|
local animations = {}
|
||||||
local animationTime = 0
|
local animationTime = 0
|
||||||
|
local animationActive = false
|
||||||
local index = 1
|
local index = 1
|
||||||
local infinitePlay = false
|
local infinitePlay = false
|
||||||
|
|
||||||
@@ -279,7 +280,7 @@ return function(name)
|
|||||||
|
|
||||||
offset = function(self, x, y, duration, timer, obj)
|
offset = function(self, x, y, duration, timer, obj)
|
||||||
_OBJ = obj or _OBJ
|
_OBJ = obj or _OBJ
|
||||||
predefinedLerp(x,y,duration,timer or 0,_OBJ.getOffsetInternal,_OBJ.setOffset)
|
predefinedLerp(x,y,duration,timer or 0,_OBJ.getOffset,_OBJ.setOffset)
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -384,6 +385,7 @@ return function(name)
|
|||||||
|
|
||||||
play = function(self, infinite)
|
play = function(self, infinite)
|
||||||
self:cancel()
|
self:cancel()
|
||||||
|
animationActive = true
|
||||||
infinitePlay = infinite and true or false
|
infinitePlay = infinite and true or false
|
||||||
index = 1
|
index = 1
|
||||||
animationTime = 0
|
animationTime = 0
|
||||||
@@ -404,6 +406,7 @@ return function(name)
|
|||||||
os.cancelTimer(timerObj)
|
os.cancelTimer(timerObj)
|
||||||
infinitePlay = false
|
infinitePlay = false
|
||||||
end
|
end
|
||||||
|
animationActive = false
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -412,11 +415,13 @@ return function(name)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
eventHandler = function(self, event, tObj)
|
eventHandler = function(self, event, tObj)
|
||||||
if (event == "timer") and (tObj == timerObj) then
|
if(animationActive)then
|
||||||
if (animations[index] ~= nil) then
|
if (event == "timer") and (tObj == timerObj) then
|
||||||
onPlay(self)
|
if (animations[index] ~= nil) then
|
||||||
else
|
onPlay(self)
|
||||||
self:animationDoneHandler()
|
else
|
||||||
|
self:animationDoneHandler()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local Object = require("Object")
|
local Object = require("Object")
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
local xmlValue = utils.getValueFromXML
|
local xmlValue = utils.getValueFromXML
|
||||||
|
local createText = utils.createText
|
||||||
local tHex = require("tHex")
|
local tHex = require("tHex")
|
||||||
local bigFont = require("bigfont")
|
local bigFont = require("bigfont")
|
||||||
|
|
||||||
@@ -95,17 +96,7 @@ return function(name)
|
|||||||
if(self.fgColor~=false)then self.parent:drawForegroundBox(obx, oby, w, h, self.fgColor) end
|
if(self.fgColor~=false)then self.parent:drawForegroundBox(obx, oby, w, h, self.fgColor) end
|
||||||
if(fontsize==0)then
|
if(fontsize==0)then
|
||||||
if not(autoSize)then
|
if not(autoSize)then
|
||||||
local splittedText = utils.splitString(self:getValue(), " ")
|
local text = createText(self:getValue(), self:getWidth())
|
||||||
local text = {}
|
|
||||||
local line = ""
|
|
||||||
for _,v in pairs(splittedText)do
|
|
||||||
if(line:len()+v:len()<=w)then
|
|
||||||
line = line=="" and v or line.." "..v
|
|
||||||
else
|
|
||||||
table.insert(text, line)
|
|
||||||
line = v:sub(1,w)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for k,v in pairs(text)do
|
for k,v in pairs(text)do
|
||||||
self.parent:setText(obx, oby+k-1, v)
|
self.parent:setText(obx, oby+k-1, v)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -104,12 +104,17 @@ return function(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
setActiveSymbol = function(self, sym)
|
||||||
|
symbol = sym:sub(1,1)
|
||||||
|
return self
|
||||||
|
end,
|
||||||
|
|
||||||
setSelectedItem = function(self, bgCol, fgCol, boxBG, boxFG, active)
|
setSelectedItem = function(self, bgCol, fgCol, boxBG, boxFG, active)
|
||||||
itemSelectedBG = bgCol or itemSelectedBG
|
itemSelectedBG = bgCol or itemSelectedBG
|
||||||
itemSelectedFG = fgCol or itemSelectedFG
|
itemSelectedFG = fgCol or itemSelectedFG
|
||||||
boxSelectedBG = boxBG or boxSelectedBG
|
boxSelectedBG = boxBG or boxSelectedBG
|
||||||
boxSelectedFG = boxFG or boxSelectedFG
|
boxSelectedFG = boxFG or boxSelectedFG
|
||||||
selectionColorActive = active
|
selectionColorActive = active~=nil and active or true
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -123,7 +128,7 @@ return function(name)
|
|||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setFocusedObject(self)
|
self.parent:setFocusedObject(self)
|
||||||
end
|
end
|
||||||
--eventSystem:sendEvent(event, self, event, button, x, y)
|
self:getEventSystem():sendEvent(event, self, event, button, x, y)
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -147,6 +147,14 @@ return function(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
clear = function(self)
|
||||||
|
lines = {""}
|
||||||
|
bgLines = {""}
|
||||||
|
fgLines = {""}
|
||||||
|
hIndex, wIndex, textX, textY = 1, 1, 1, 1
|
||||||
|
return self
|
||||||
|
end,
|
||||||
|
|
||||||
addLine = function(self, text, index)
|
addLine = function(self, text, index)
|
||||||
if(text~=nil)then
|
if(text~=nil)then
|
||||||
if(#lines==1)and(lines[1]=="")then
|
if(#lines==1)and(lines[1]=="")then
|
||||||
|
|||||||
Reference in New Issue
Block a user