mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
Remove support for LOVE 0.8.0
This commit is contained in:
parent
50718f04c3
commit
60ad73f8b7
@ -1,5 +1,5 @@
|
|||||||
================================================
|
================================================
|
||||||
Version 0.9.8 - Alpha (Release date TBD)
|
Version 0.9.8 - Alpha (April 3 - 2014)
|
||||||
================================================
|
================================================
|
||||||
[ADDED] support for method chaining
|
[ADDED] support for method chaining
|
||||||
[ADDED] a new tooltip method: GetPadding()
|
[ADDED] a new tooltip method: GetPadding()
|
||||||
@ -11,6 +11,8 @@ Version 0.9.8 - Alpha (Release date TBD)
|
|||||||
|
|
||||||
[CHANGED] the text object will now detect newlines that are not separated by spaces
|
[CHANGED] the text object will now detect newlines that are not separated by spaces
|
||||||
|
|
||||||
|
[REMOVED] support for LOVE 0.8.0
|
||||||
|
|
||||||
================================================
|
================================================
|
||||||
Version 0.9.7.2 - Alpha (January 29 - 2014)
|
Version 0.9.7.2 - Alpha (January 29 - 2014)
|
||||||
================================================
|
================================================
|
||||||
|
158
init.lua
158
init.lua
@ -45,12 +45,6 @@ loveframes.collisions = {}
|
|||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function loveframes.load()
|
function loveframes.load()
|
||||||
|
|
||||||
local loveversion = love._version
|
|
||||||
|
|
||||||
if loveversion ~= "0.8.0" and loveversion ~= "0.9.0" then
|
|
||||||
error("Love Frames is not compatible with your version of LOVE.")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- install directory of the library
|
-- install directory of the library
|
||||||
local dir = loveframes.config["DIRECTORY"] or path
|
local dir = loveframes.config["DIRECTORY"] or path
|
||||||
|
|
||||||
@ -95,6 +89,9 @@ function loveframes.load()
|
|||||||
local base = loveframes.objects["base"]
|
local base = loveframes.objects["base"]
|
||||||
loveframes.base = base:new()
|
loveframes.base = base:new()
|
||||||
|
|
||||||
|
-- enable key repeat
|
||||||
|
love.keyboard.setKeyRepeat(true)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -105,7 +102,6 @@ function loveframes.update(dt)
|
|||||||
|
|
||||||
local base = loveframes.base
|
local base = loveframes.base
|
||||||
local input_cursor_set = loveframes.input_cursor_set
|
local input_cursor_set = loveframes.input_cursor_set
|
||||||
local version = love._version
|
|
||||||
|
|
||||||
loveframes.collisioncount = 0
|
loveframes.collisioncount = 0
|
||||||
loveframes.objectcount = 0
|
loveframes.objectcount = 0
|
||||||
@ -124,86 +120,84 @@ function loveframes.update(dt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if version == "0.9.0" then
|
local hoverobject = loveframes.hoverobject
|
||||||
local hoverobject = loveframes.hoverobject
|
local arrow = love.mouse.getSystemCursor("arrow")
|
||||||
local arrow = love.mouse.getSystemCursor("arrow")
|
local curcursor = love.mouse.getCursor()
|
||||||
local curcursor = love.mouse.getCursor()
|
if hoverobject then
|
||||||
if hoverobject then
|
local ibeam = love.mouse.getSystemCursor("ibeam")
|
||||||
local ibeam = love.mouse.getSystemCursor("ibeam")
|
local mx, my = love.mouse.getPosition()
|
||||||
local mx, my = love.mouse.getPosition()
|
if hoverobject.type == "textinput" and not loveframes.resizeobject then
|
||||||
if hoverobject.type == "textinput" and not loveframes.resizeobject then
|
if curcursor ~= ibeam then
|
||||||
if curcursor ~= ibeam then
|
love.mouse.setCursor(ibeam)
|
||||||
love.mouse.setCursor(ibeam)
|
end
|
||||||
end
|
elseif hoverobject.type == "frame" then
|
||||||
elseif hoverobject.type == "frame" then
|
if not hoverobject.dragging and hoverobject.canresize then
|
||||||
if not hoverobject.dragging and hoverobject.canresize then
|
if loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y, my, 5, 1, 5, 1) then
|
||||||
if loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y, my, 5, 1, 5, 1) then
|
local sizenwse = love.mouse.getSystemCursor("sizenwse")
|
||||||
local sizenwse = love.mouse.getSystemCursor("sizenwse")
|
if curcursor ~= sizenwse then
|
||||||
if curcursor ~= sizenwse then
|
love.mouse.setCursor(sizenwse)
|
||||||
love.mouse.setCursor(sizenwse)
|
end
|
||||||
end
|
elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 5, mx, hoverobject.y + hoverobject.height - 5, my, 5, 1, 5, 1) then
|
||||||
elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 5, mx, hoverobject.y + hoverobject.height - 5, my, 5, 1, 5, 1) then
|
local sizenwse = love.mouse.getSystemCursor("sizenwse")
|
||||||
local sizenwse = love.mouse.getSystemCursor("sizenwse")
|
if curcursor ~= sizenwse then
|
||||||
if curcursor ~= sizenwse then
|
love.mouse.setCursor(sizenwse)
|
||||||
love.mouse.setCursor(sizenwse)
|
end
|
||||||
end
|
elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 5, mx, hoverobject.y, my, 5, 1, 5, 1) then
|
||||||
elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 5, mx, hoverobject.y, my, 5, 1, 5, 1) then
|
local sizenesw = love.mouse.getSystemCursor("sizenesw")
|
||||||
local sizenesw = love.mouse.getSystemCursor("sizenesw")
|
if curcursor ~= sizenesw then
|
||||||
if curcursor ~= sizenesw then
|
love.mouse.setCursor(sizenesw)
|
||||||
love.mouse.setCursor(sizenesw)
|
end
|
||||||
end
|
elseif loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y + hoverobject.height - 5, my, 5, 1, 5, 1) then
|
||||||
elseif loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y + hoverobject.height - 5, my, 5, 1, 5, 1) then
|
local sizenesw = love.mouse.getSystemCursor("sizenesw")
|
||||||
local sizenesw = love.mouse.getSystemCursor("sizenesw")
|
if curcursor ~= sizenesw then
|
||||||
if curcursor ~= sizenesw then
|
love.mouse.setCursor(sizenesw)
|
||||||
love.mouse.setCursor(sizenesw)
|
end
|
||||||
end
|
elseif loveframes.util.BoundingBox(hoverobject.x + 5, mx, hoverobject.y, my, hoverobject.width - 10, 1, 2, 1) then
|
||||||
elseif loveframes.util.BoundingBox(hoverobject.x + 5, mx, hoverobject.y, my, hoverobject.width - 10, 1, 2, 1) then
|
local sizens = love.mouse.getSystemCursor("sizens")
|
||||||
local sizens = love.mouse.getSystemCursor("sizens")
|
if curcursor ~= sizens then
|
||||||
if curcursor ~= sizens then
|
love.mouse.setCursor(sizens)
|
||||||
love.mouse.setCursor(sizens)
|
end
|
||||||
end
|
elseif loveframes.util.BoundingBox(hoverobject.x + 5, mx, hoverobject.y + hoverobject.height - 2, my, hoverobject.width - 10, 1, 2, 1) then
|
||||||
elseif loveframes.util.BoundingBox(hoverobject.x + 5, mx, hoverobject.y + hoverobject.height - 2, my, hoverobject.width - 10, 1, 2, 1) then
|
local sizens = love.mouse.getSystemCursor("sizens")
|
||||||
local sizens = love.mouse.getSystemCursor("sizens")
|
if curcursor ~= sizens then
|
||||||
if curcursor ~= sizens then
|
love.mouse.setCursor(sizens)
|
||||||
love.mouse.setCursor(sizens)
|
end
|
||||||
end
|
elseif loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y + 5, my, 2, 1, hoverobject.height - 10, 1) then
|
||||||
elseif loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y + 5, my, 2, 1, hoverobject.height - 10, 1) then
|
local sizewe = love.mouse.getSystemCursor("sizewe")
|
||||||
local sizewe = love.mouse.getSystemCursor("sizewe")
|
if curcursor ~= sizewe then
|
||||||
if curcursor ~= sizewe then
|
love.mouse.setCursor(sizewe)
|
||||||
love.mouse.setCursor(sizewe)
|
end
|
||||||
end
|
elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 2, mx, hoverobject.y + 5, my, 2, 1, hoverobject.height - 10, 1) then
|
||||||
elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 2, mx, hoverobject.y + 5, my, 2, 1, hoverobject.height - 10, 1) then
|
local sizewe = love.mouse.getSystemCursor("sizewe")
|
||||||
local sizewe = love.mouse.getSystemCursor("sizewe")
|
if curcursor ~= sizewe then
|
||||||
if curcursor ~= sizewe then
|
love.mouse.setCursor(sizewe)
|
||||||
love.mouse.setCursor(sizewe)
|
end
|
||||||
end
|
else
|
||||||
else
|
if not loveframes.resizeobject then
|
||||||
if not loveframes.resizeobject then
|
local arrow = love.mouse.getSystemCursor("arrow")
|
||||||
local arrow = love.mouse.getSystemCursor("arrow")
|
if curcursor ~= arrow then
|
||||||
if curcursor ~= arrow then
|
love.mouse.setCursor(arrow)
|
||||||
love.mouse.setCursor(arrow)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif hoverobject.type == "text" and hoverobject.linkcol and not loveframes.resizeobject then
|
|
||||||
local hand = love.mouse.getSystemCursor("hand")
|
|
||||||
if curcursor ~= hand then
|
|
||||||
love.mouse.setCursor(hand)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if curcursor ~= arrow then
|
elseif hoverobject.type == "text" and hoverobject.linkcol and not loveframes.resizeobject then
|
||||||
if hoverobject.type ~= "textinput" and hoverobject.type ~= "frame" and not hoverobject.linkcol and not loveframes.resizeobject then
|
local hand = love.mouse.getSystemCursor("hand")
|
||||||
love.mouse.setCursor(arrow)
|
if curcursor ~= hand then
|
||||||
elseif hoverobject.type ~= "textinput" and curcursor == ibeam then
|
love.mouse.setCursor(hand)
|
||||||
love.mouse.setCursor(arrow)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
if curcursor ~= arrow and not loveframes.resizeobject then
|
if curcursor ~= arrow then
|
||||||
|
if hoverobject.type ~= "textinput" and hoverobject.type ~= "frame" and not hoverobject.linkcol and not loveframes.resizeobject then
|
||||||
|
love.mouse.setCursor(arrow)
|
||||||
|
elseif hoverobject.type ~= "textinput" and curcursor == ibeam then
|
||||||
love.mouse.setCursor(arrow)
|
love.mouse.setCursor(arrow)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if curcursor ~= arrow and not loveframes.resizeobject then
|
||||||
|
love.mouse.setCursor(arrow)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
loveframes.collisions = {}
|
loveframes.collisions = {}
|
||||||
@ -281,13 +275,13 @@ function loveframes.mousereleased(x, y, button)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: keypressed(key)
|
- func: keypressed(key, isrepeat)
|
||||||
- desc: called when the player presses a key
|
- desc: called when the player presses a key
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function loveframes.keypressed(key, unicode)
|
function loveframes.keypressed(key, isrepeat)
|
||||||
|
|
||||||
local base = loveframes.base
|
local base = loveframes.base
|
||||||
base:keypressed(key, unicode)
|
base:keypressed(key, isrepeat)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -136,17 +136,10 @@ end
|
|||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function loveframes.util.GetDirectoryContents(dir, t)
|
function loveframes.util.GetDirectoryContents(dir, t)
|
||||||
|
|
||||||
local version = love._version
|
|
||||||
local dir = dir
|
local dir = dir
|
||||||
local t = t or {}
|
local t = t or {}
|
||||||
local dirs = {}
|
local dirs = {}
|
||||||
local files
|
local files = love.filesystem.getDirectoryItems(dir)
|
||||||
|
|
||||||
if version == "0.9.0" then
|
|
||||||
files = love.filesystem.getDirectoryItems(dir)
|
|
||||||
else
|
|
||||||
files = love.filesystem.enumerate(dir)
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in ipairs(files) do
|
for k, v in ipairs(files) do
|
||||||
local isdir = love.filesystem.isDirectory(dir.. "/" ..v)
|
local isdir = love.filesystem.isDirectory(dir.. "/" ..v)
|
||||||
|
@ -151,10 +151,10 @@ function newobject:mousereleased(x, y, button)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: keypressed(key)
|
- func: keypressed(key, isrepeat)
|
||||||
- desc: called when the player presses a key
|
- desc: called when the player presses a key
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:keypressed(key, unicode)
|
function newobject:keypressed(key, isrepeat)
|
||||||
|
|
||||||
local state = loveframes.state
|
local state = loveframes.state
|
||||||
local selfstate = self.state
|
local selfstate = self.state
|
||||||
|
@ -105,7 +105,6 @@ function newobject:draw()
|
|||||||
local width = self.width
|
local width = self.width
|
||||||
local height = self.height
|
local height = self.height
|
||||||
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
||||||
local loveversion = love._version
|
|
||||||
local skins = loveframes.skins.available
|
local skins = loveframes.skins.available
|
||||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||||
@ -127,12 +126,7 @@ function newobject:draw()
|
|||||||
drawfunc(self)
|
drawfunc(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if loveversion == "0.8.0" then
|
love.graphics.setStencil(stencilfunc)
|
||||||
local stencil = love.graphics.newStencil(stencilfunc)
|
|
||||||
love.graphics.setStencil(stencil)
|
|
||||||
else
|
|
||||||
love.graphics.setStencil(stencilfunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height)
|
local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height)
|
||||||
|
@ -87,7 +87,6 @@ function newobject:draw()
|
|||||||
local width = self.width
|
local width = self.width
|
||||||
local height = self.height
|
local height = self.height
|
||||||
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
||||||
local loveversion = love._version
|
|
||||||
local skins = loveframes.skins.available
|
local skins = loveframes.skins.available
|
||||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||||
@ -105,12 +104,7 @@ function newobject:draw()
|
|||||||
-- set the object's draw order
|
-- set the object's draw order
|
||||||
self:SetDrawOrder()
|
self:SetDrawOrder()
|
||||||
|
|
||||||
if loveversion == "0.8.0" then
|
love.graphics.setStencil(stencilfunc)
|
||||||
local stencil = love.graphics.newStencil(stencilfunc)
|
|
||||||
love.graphics.setStencil(stencil)
|
|
||||||
else
|
|
||||||
love.graphics.setStencil(stencilfunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
if draw then
|
if draw then
|
||||||
draw(self)
|
draw(self)
|
||||||
|
@ -144,7 +144,6 @@ function newobject:draw()
|
|||||||
local width = self.width
|
local width = self.width
|
||||||
local height = self.height
|
local height = self.height
|
||||||
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
||||||
local loveversion = love._version
|
|
||||||
local skins = loveframes.skins.available
|
local skins = loveframes.skins.available
|
||||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||||
@ -170,12 +169,7 @@ function newobject:draw()
|
|||||||
v:draw()
|
v:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
if loveversion == "0.8.0" then
|
love.graphics.setStencil(stencilfunc)
|
||||||
local stencil = love.graphics.newStencil(stencilfunc)
|
|
||||||
love.graphics.setStencil(stencil)
|
|
||||||
else
|
|
||||||
love.graphics.setStencil(stencilfunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height)
|
local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height)
|
||||||
|
@ -147,10 +147,10 @@ function newobject:mousereleased(x, y, button)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: keypressed(key)
|
- func: keypressed(key, isrepeat)
|
||||||
- desc: called when the player presses a key
|
- desc: called when the player presses a key
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:keypressed(key, unicode)
|
function newobject:keypressed(key, isrepeat)
|
||||||
|
|
||||||
local text = self.text
|
local text = self.text
|
||||||
local selectedobject = loveframes.selectedobject
|
local selectedobject = loveframes.selectedobject
|
||||||
|
@ -133,7 +133,6 @@ function newobject:draw()
|
|||||||
local width = self.width
|
local width = self.width
|
||||||
local height = self.height
|
local height = self.height
|
||||||
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
||||||
local loveversion = love._version
|
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local children = self.children
|
local children = self.children
|
||||||
local skins = loveframes.skins.available
|
local skins = loveframes.skins.available
|
||||||
@ -155,12 +154,7 @@ function newobject:draw()
|
|||||||
drawfunc(self)
|
drawfunc(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if loveversion == "0.8.0" then
|
love.graphics.setStencil(stencilfunc)
|
||||||
local stencil = love.graphics.newStencil(stencilfunc)
|
|
||||||
love.graphics.setStencil(stencil)
|
|
||||||
else
|
|
||||||
love.graphics.setStencil(stencilfunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
local col = loveframes.util.BoundingBox(x, v.x, y, v.y, width, v.width, height, v.height)
|
local col = loveframes.util.BoundingBox(x, v.x, y, v.y, width, v.width, height, v.height)
|
||||||
|
@ -74,13 +74,8 @@ function newobject:initialize()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
increasebutton.Update = function(object)
|
increasebutton.Update = function(object)
|
||||||
local loveversion = love._version
|
|
||||||
local time = 0
|
local time = 0
|
||||||
if loveversion == "0.8.0" then
|
time = love.timer.getTime()
|
||||||
time = love.timer.getMicroTime()
|
|
||||||
else
|
|
||||||
time = love.timer.getTime()
|
|
||||||
end
|
|
||||||
local delay = self.delay
|
local delay = self.delay
|
||||||
local down = object.down
|
local down = object.down
|
||||||
local canmodify = self.canmodify
|
local canmodify = self.canmodify
|
||||||
@ -114,13 +109,8 @@ function newobject:initialize()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
decreasesbutton.Update = function(object)
|
decreasesbutton.Update = function(object)
|
||||||
local loveversion = love._version
|
|
||||||
local time = 0
|
local time = 0
|
||||||
if loveversion == "0.8.0" then
|
time = love.timer.getTime()
|
||||||
time = love.timer.getMicroTime()
|
|
||||||
else
|
|
||||||
time = love.timer.getTime()
|
|
||||||
end
|
|
||||||
local delay = self.delay
|
local delay = self.delay
|
||||||
local down = object.down
|
local down = object.down
|
||||||
local canmodify = self.canmodify
|
local canmodify = self.canmodify
|
||||||
|
@ -140,7 +140,6 @@ function newobject:draw()
|
|||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local tabheight = self:GetHeightOfButtons()
|
local tabheight = self:GetHeightOfButtons()
|
||||||
local stencilfunc = function() love.graphics.rectangle("fill", x + self.buttonareax, y, self.buttonareawidth, height) end
|
local stencilfunc = function() love.graphics.rectangle("fill", x + self.buttonareax, y, self.buttonareawidth, height) end
|
||||||
local loveversion = love._version
|
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local skins = loveframes.skins.available
|
local skins = loveframes.skins.available
|
||||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||||
@ -161,12 +160,7 @@ function newobject:draw()
|
|||||||
drawfunc(self)
|
drawfunc(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if loveversion == "0.8.0" then
|
love.graphics.setStencil(stencilfunc)
|
||||||
local stencil = love.graphics.newStencil(stencilfunc)
|
|
||||||
love.graphics.setStencil(stencil)
|
|
||||||
else
|
|
||||||
love.graphics.setStencil(stencilfunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in ipairs(internals) do
|
for k, v in ipairs(internals) do
|
||||||
local col = loveframes.util.BoundingBox(x + self.buttonareax, v.x, self.y, v.y, self.buttonareawidth, v.width, tabheight, v.height)
|
local col = loveframes.util.BoundingBox(x + self.buttonareax, v.x, self.y, v.y, self.buttonareawidth, v.width, tabheight, v.height)
|
||||||
|
@ -92,7 +92,6 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
local hover = self.hover
|
local hover = self.hover
|
||||||
local linksenabled = self.linksenabled
|
local linksenabled = self.linksenabled
|
||||||
local version = love._version
|
|
||||||
local linkcol = false
|
local linkcol = false
|
||||||
|
|
||||||
if hover and linksenabled and not loveframes.resizeobject then
|
if hover and linksenabled and not loveframes.resizeobject then
|
||||||
|
@ -98,7 +98,6 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
local time = love.timer.getTime()
|
local time = love.timer.getTime()
|
||||||
local keydown = self.keydown
|
local keydown = self.keydown
|
||||||
local unicode = self.unicode
|
|
||||||
local parent = self.parent
|
local parent = self.parent
|
||||||
local base = loveframes.base
|
local base = loveframes.base
|
||||||
local update = self.Update
|
local update = self.Update
|
||||||
@ -116,7 +115,6 @@ function newobject:update(dt)
|
|||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local repeatrate = self.repeatrate
|
local repeatrate = self.repeatrate
|
||||||
local hover = self.hover
|
local hover = self.hover
|
||||||
local version = love._version
|
|
||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
@ -133,18 +131,6 @@ function newobject:update(dt)
|
|||||||
self.alltextselected = false
|
self.alltextselected = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- keydown check
|
|
||||||
if keydown ~= "none" then
|
|
||||||
if time > delay then
|
|
||||||
if (loveframes.util.IsCtrlDown()) and keydown == "v" then
|
|
||||||
self:Paste()
|
|
||||||
else
|
|
||||||
self:RunKey(keydown, unicode, true)
|
|
||||||
end
|
|
||||||
self.delay = time + repeatrate
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:PositionText()
|
self:PositionText()
|
||||||
self:UpdateIndicator()
|
self:UpdateIndicator()
|
||||||
|
|
||||||
@ -294,7 +280,6 @@ function newobject:draw()
|
|||||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||||
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
|
||||||
local loveversion = love._version
|
|
||||||
local selfskin = self.skin
|
local selfskin = self.skin
|
||||||
local skin = skins[selfskin] or skins[skinindex]
|
local skin = skins[selfskin] or skins[skinindex]
|
||||||
local drawfunc = skin.DrawTextInput or skins[defaultskin].DrawTextInput
|
local drawfunc = skin.DrawTextInput or skins[defaultskin].DrawTextInput
|
||||||
@ -312,12 +297,7 @@ function newobject:draw()
|
|||||||
stencilfunc = function() love.graphics.rectangle("fill", x, y, width - 16, height - 16) end
|
stencilfunc = function() love.graphics.rectangle("fill", x, y, width - 16, height - 16) end
|
||||||
end
|
end
|
||||||
|
|
||||||
if loveversion == "0.8.0" then
|
love.graphics.setStencil(stencilfunc)
|
||||||
local stencil = love.graphics.newStencil(stencilfunc)
|
|
||||||
love.graphics.setStencil(stencil)
|
|
||||||
else
|
|
||||||
love.graphics.setStencil(stencilfunc)
|
|
||||||
end
|
|
||||||
|
|
||||||
if draw then
|
if draw then
|
||||||
draw(self)
|
draw(self)
|
||||||
@ -454,10 +434,10 @@ function newobject:mousereleased(x, y, button)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: keypressed(key)
|
- func: keypressed(key, isrepeat)
|
||||||
- desc: called when the player presses a key
|
- desc: called when the player presses a key
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:keypressed(key, unicode)
|
function newobject:keypressed(key, isrepeat)
|
||||||
|
|
||||||
local state = loveframes.state
|
local state = loveframes.state
|
||||||
local selfstate = self.state
|
local selfstate = self.state
|
||||||
@ -477,7 +457,6 @@ function newobject:keypressed(key, unicode)
|
|||||||
local repeatdelay = self.repeatdelay
|
local repeatdelay = self.repeatdelay
|
||||||
local alltextselected = self.alltextselected
|
local alltextselected = self.alltextselected
|
||||||
local editable = self.editable
|
local editable = self.editable
|
||||||
local version = love._version
|
|
||||||
|
|
||||||
self.delay = time + repeatdelay
|
self.delay = time + repeatdelay
|
||||||
self.keydown = key
|
self.keydown = key
|
||||||
@ -485,14 +464,14 @@ function newobject:keypressed(key, unicode)
|
|||||||
if (loveframes.util.IsCtrlDown()) and focus then
|
if (loveframes.util.IsCtrlDown()) and focus then
|
||||||
if key == "a" then
|
if key == "a" then
|
||||||
self.alltextselected = true
|
self.alltextselected = true
|
||||||
elseif key == "c" and alltextselected and version == "0.9.0" then
|
elseif key == "c" and alltextselected then
|
||||||
local text = self:GetText()
|
local text = self:GetText()
|
||||||
local oncopy = self.OnCopy
|
local oncopy = self.OnCopy
|
||||||
love.system.setClipboardText(text)
|
love.system.setClipboardText(text)
|
||||||
if oncopy then
|
if oncopy then
|
||||||
oncopy(self, text)
|
oncopy(self, text)
|
||||||
end
|
end
|
||||||
elseif key == "x" and alltextselected and version == "0.9.0" and editable then
|
elseif key == "x" and alltextselected and editable then
|
||||||
local text = self:GetText()
|
local text = self:GetText()
|
||||||
local oncut = self.OnCut
|
local oncut = self.OnCut
|
||||||
love.system.setClipboardText(text)
|
love.system.setClipboardText(text)
|
||||||
@ -501,16 +480,13 @@ function newobject:keypressed(key, unicode)
|
|||||||
else
|
else
|
||||||
self:SetText("")
|
self:SetText("")
|
||||||
end
|
end
|
||||||
elseif key == "v" and version == "0.9.0" and editable then
|
elseif key == "v" and editable then
|
||||||
self:Paste()
|
self:Paste()
|
||||||
|
else
|
||||||
|
self:RunKey(key, false)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local version = love._version
|
self:RunKey(key, false)
|
||||||
if version == "0.8.0" then
|
|
||||||
self:RunKey(key, unicode, true)
|
|
||||||
else
|
|
||||||
self:RunKey(key, unicode, false)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -543,25 +519,19 @@ end
|
|||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:textinput(text)
|
function newobject:textinput(text)
|
||||||
|
|
||||||
local unicode = unicode
|
|
||||||
if text:find("kp.") then
|
if text:find("kp.") then
|
||||||
text = text:gsub("kp", "")
|
text = text:gsub("kp", "")
|
||||||
end
|
end
|
||||||
if text:len() == 1 then
|
|
||||||
unicode = string.byte(text)
|
|
||||||
else
|
|
||||||
unicode = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
self:RunKey(text, unicode, true)
|
self:RunKey(text, true)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: RunKey(key, unicode)
|
- func: RunKey(key, istext)
|
||||||
- desc: runs a key event on the object
|
- desc: runs a key event on the object
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:RunKey(key, unicode, is_text)
|
function newobject:RunKey(key, istext)
|
||||||
|
|
||||||
local visible = self.visible
|
local visible = self.visible
|
||||||
local focus = self.focus
|
local focus = self.focus
|
||||||
@ -593,277 +563,264 @@ function newobject:RunKey(key, unicode, is_text)
|
|||||||
local ontextchanged = self.OnTextChanged
|
local ontextchanged = self.OnTextChanged
|
||||||
local onenter = self.OnEnter
|
local onenter = self.OnEnter
|
||||||
|
|
||||||
if key == "left" then
|
if not istext then
|
||||||
indicatornum = self.indicatornum
|
if key == "left" then
|
||||||
if not multiline then
|
indicatornum = self.indicatornum
|
||||||
self:MoveIndicator(-1)
|
if not multiline then
|
||||||
local indicatorx = self.indicatorx
|
self:MoveIndicator(-1)
|
||||||
if indicatorx <= x and indicatornum ~= 0 then
|
local indicatorx = self.indicatorx
|
||||||
local width = font:getWidth(text:sub(indicatornum, indicatornum + 1))
|
if indicatorx <= x and indicatornum ~= 0 then
|
||||||
self.offsetx = offsetx - width
|
local width = font:getWidth(text:sub(indicatornum, indicatornum + 1))
|
||||||
elseif indicatornum == 0 and offsetx ~= 0 then
|
self.offsetx = offsetx - width
|
||||||
self.offsetx = 0
|
elseif indicatornum == 0 and offsetx ~= 0 then
|
||||||
|
self.offsetx = 0
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if indicatornum == 0 then
|
||||||
|
if line > 1 then
|
||||||
|
self.line = line - 1
|
||||||
|
local numchars = #lines[self.line]
|
||||||
|
self:MoveIndicator(numchars)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self:MoveIndicator(-1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
if alltextselected then
|
||||||
if indicatornum == 0 then
|
self.line = 1
|
||||||
|
self.indicatornum = 0
|
||||||
|
self.alltextselected = false
|
||||||
|
end
|
||||||
|
return
|
||||||
|
elseif key == "right" then
|
||||||
|
indicatornum = self.indicatornum
|
||||||
|
if not multiline then
|
||||||
|
self:MoveIndicator(1)
|
||||||
|
local indicatorx = self.indicatorx
|
||||||
|
if indicatorx >= (x + swidth) and indicatornum ~= #text then
|
||||||
|
local width = font:getWidth(text:sub(indicatornum, indicatornum))
|
||||||
|
self.offsetx = offsetx + width
|
||||||
|
elseif indicatornum == #text and offsetx ~= ((font:getWidth(text)) - swidth + 10) and font:getWidth(text) + textoffsetx > swidth then
|
||||||
|
self.offsetx = ((font:getWidth(text)) - swidth + 10)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if indicatornum == #text then
|
||||||
|
if line < numlines then
|
||||||
|
self.line = line + 1
|
||||||
|
self:MoveIndicator(0, true)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self:MoveIndicator(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if alltextselected then
|
||||||
|
self.line = #lines
|
||||||
|
self.indicatornum = lines[#lines]:len()
|
||||||
|
self.alltextselected = false
|
||||||
|
end
|
||||||
|
return
|
||||||
|
elseif key == "up" then
|
||||||
|
if multiline then
|
||||||
if line > 1 then
|
if line > 1 then
|
||||||
self.line = line - 1
|
self.line = line - 1
|
||||||
local numchars = #lines[self.line]
|
if indicatornum > #lines[self.line] then
|
||||||
self:MoveIndicator(numchars)
|
self.indicatornum = #lines[self.line]
|
||||||
end
|
|
||||||
else
|
|
||||||
self:MoveIndicator(-1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if alltextselected then
|
|
||||||
self.line = 1
|
|
||||||
self.indicatornum = 0
|
|
||||||
self.alltextselected = false
|
|
||||||
end
|
|
||||||
return
|
|
||||||
elseif key == "right" then
|
|
||||||
indicatornum = self.indicatornum
|
|
||||||
if not multiline then
|
|
||||||
self:MoveIndicator(1)
|
|
||||||
local indicatorx = self.indicatorx
|
|
||||||
if indicatorx >= (x + swidth) and indicatornum ~= #text then
|
|
||||||
local width = font:getWidth(text:sub(indicatornum, indicatornum))
|
|
||||||
self.offsetx = offsetx + width
|
|
||||||
elseif indicatornum == #text and offsetx ~= ((font:getWidth(text)) - swidth + 10) and font:getWidth(text) + textoffsetx > swidth then
|
|
||||||
self.offsetx = ((font:getWidth(text)) - swidth + 10)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if indicatornum == #text then
|
|
||||||
if line < numlines then
|
|
||||||
self.line = line + 1
|
|
||||||
self:MoveIndicator(0, true)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self:MoveIndicator(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if alltextselected then
|
|
||||||
self.line = #lines
|
|
||||||
self.indicatornum = lines[#lines]:len()
|
|
||||||
self.alltextselected = false
|
|
||||||
end
|
|
||||||
return
|
|
||||||
elseif key == "up" then
|
|
||||||
if multiline then
|
|
||||||
if line > 1 then
|
|
||||||
self.line = line - 1
|
|
||||||
if indicatornum > #lines[self.line] then
|
|
||||||
self.indicatornum = #lines[self.line]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return
|
|
||||||
elseif key == "down" then
|
|
||||||
if multiline then
|
|
||||||
if line < #lines then
|
|
||||||
self.line = line + 1
|
|
||||||
if indicatornum > #lines[self.line] then
|
|
||||||
self.indicatornum = #lines[self.line]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if not editable then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- key input checking system
|
|
||||||
if key == "backspace" then
|
|
||||||
ckey = key
|
|
||||||
if alltextselected then
|
|
||||||
self:Clear()
|
|
||||||
self.alltextselected = false
|
|
||||||
indicatornum = self.indicatornum
|
|
||||||
else
|
|
||||||
if text ~= "" and indicatornum ~= 0 then
|
|
||||||
text = self:RemoveFromText(indicatornum)
|
|
||||||
self:MoveIndicator(-1)
|
|
||||||
lines[line] = text
|
|
||||||
end
|
|
||||||
if multiline then
|
|
||||||
if line > 1 and indicatornum == 0 then
|
|
||||||
local newindicatornum = 0
|
|
||||||
local oldtext = lines[line]
|
|
||||||
table.remove(lines, line)
|
|
||||||
self.line = line - 1
|
|
||||||
if #oldtext > 0 then
|
|
||||||
newindicatornum = #lines[self.line]
|
|
||||||
lines[self.line] = lines[self.line] .. oldtext
|
|
||||||
self:MoveIndicator(newindicatornum)
|
|
||||||
else
|
|
||||||
self:MoveIndicator(#lines[self.line])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local masked = self.masked
|
return
|
||||||
local cwidth = 0
|
elseif key == "down" then
|
||||||
if masked then
|
if multiline then
|
||||||
local maskchar = self.maskchar
|
if line < #lines then
|
||||||
cwidth = font:getWidth(text:sub(#text):gsub(".", maskchar))
|
self.line = line + 1
|
||||||
else
|
if indicatornum > #lines[self.line] then
|
||||||
cwidth = font:getWidth(text:sub(#text))
|
self.indicatornum = #lines[self.line]
|
||||||
end
|
end
|
||||||
if self.offsetx > 0 then
|
end
|
||||||
self.offsetx = self.offsetx - cwidth
|
|
||||||
elseif self.offsetx < 0 then
|
|
||||||
self.offsetx = 0
|
|
||||||
end
|
end
|
||||||
|
return
|
||||||
end
|
end
|
||||||
elseif key == "delete" then
|
|
||||||
if not editable then
|
if not editable then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
ckey = key
|
|
||||||
if alltextselected then
|
-- key input checking system
|
||||||
self:Clear()
|
if key == "backspace" then
|
||||||
self.alltextselected = false
|
ckey = key
|
||||||
indicatornum = self.indicatornum
|
|
||||||
else
|
|
||||||
if text ~= "" and indicatornum < #text then
|
|
||||||
text = self:RemoveFromText(indicatornum + 1)
|
|
||||||
lines[line] = text
|
|
||||||
elseif indicatornum == #text and line < #lines then
|
|
||||||
local oldtext = lines[line + 1]
|
|
||||||
if #oldtext > 0 then
|
|
||||||
newindicatornum = #lines[self.line]
|
|
||||||
lines[self.line] = lines[self.line] .. oldtext
|
|
||||||
end
|
|
||||||
table.remove(lines, line + 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif key == "return" or key == "kpenter" then
|
|
||||||
ckey = key
|
|
||||||
-- call onenter if it exists
|
|
||||||
if onenter then
|
|
||||||
onenter(self, text)
|
|
||||||
end
|
|
||||||
-- newline calculations for multiline mode
|
|
||||||
if multiline then
|
|
||||||
if alltextselected then
|
if alltextselected then
|
||||||
self.alltextselected = false
|
|
||||||
self:Clear()
|
self:Clear()
|
||||||
|
self.alltextselected = false
|
||||||
indicatornum = self.indicatornum
|
indicatornum = self.indicatornum
|
||||||
line = self.line
|
|
||||||
end
|
|
||||||
local newtext = ""
|
|
||||||
if indicatornum == 0 then
|
|
||||||
newtext = self.lines[line]
|
|
||||||
self.lines[line] = ""
|
|
||||||
elseif indicatornum > 0 and indicatornum < #self.lines[line] then
|
|
||||||
newtext = self.lines[line]:sub(indicatornum + 1, #self.lines[line])
|
|
||||||
self.lines[line] = self.lines[line]:sub(1, indicatornum)
|
|
||||||
end
|
|
||||||
if line ~= #lines then
|
|
||||||
table.insert(self.lines, line + 1, newtext)
|
|
||||||
self.line = line + 1
|
|
||||||
else
|
else
|
||||||
table.insert(self.lines, newtext)
|
if text ~= "" and indicatornum ~= 0 then
|
||||||
self.line = line + 1
|
text = self:RemoveFromText(indicatornum)
|
||||||
end
|
self:MoveIndicator(-1)
|
||||||
self.indicatornum = 0
|
lines[line] = text
|
||||||
end
|
end
|
||||||
elseif key == "tab" then
|
if multiline then
|
||||||
ckey = key
|
if line > 1 and indicatornum == 0 then
|
||||||
for i=1, #self.tabreplacement do
|
local newindicatornum = 0
|
||||||
local number = string.byte(self.tabreplacement:sub(i, i))
|
local oldtext = lines[line]
|
||||||
self.lines[self.line] = self:AddIntoText(number, self.indicatornum)
|
table.remove(lines, line)
|
||||||
self:MoveIndicator(1)
|
self.line = line - 1
|
||||||
end
|
if #oldtext > 0 then
|
||||||
else
|
newindicatornum = #lines[self.line]
|
||||||
if not is_text then
|
lines[self.line] = lines[self.line] .. oldtext
|
||||||
return
|
self:MoveIndicator(newindicatornum)
|
||||||
end
|
else
|
||||||
self.unicode = unicode
|
self:MoveIndicator(#lines[self.line])
|
||||||
if unicode > 31 and unicode < 127 then
|
end
|
||||||
-- do not continue if the text limit has been reached or exceeded
|
|
||||||
if #text >= self.limit and self.limit ~= 0 and not alltextselected then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
-- set the current key
|
|
||||||
ckey = string.char(unicode)
|
|
||||||
-- check for unusable characters
|
|
||||||
if #self.usable > 0 then
|
|
||||||
local found = false
|
|
||||||
for k, v in ipairs(self.usable) do
|
|
||||||
if v == ckey then
|
|
||||||
found = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not found then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- check for usable characters
|
|
||||||
if #self.unusable > 0 then
|
|
||||||
local found = false
|
|
||||||
for k, v in ipairs(self.unusable) do
|
|
||||||
if v == ckey then
|
|
||||||
found = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if found then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if alltextselected then
|
|
||||||
self.alltextselected = false
|
|
||||||
self:Clear()
|
|
||||||
indicatornum = self.indicatornum
|
|
||||||
text = ""
|
|
||||||
lines = self.lines
|
|
||||||
line = self.line
|
|
||||||
end
|
|
||||||
if indicatornum ~= 0 and indicatornum ~= #text then
|
|
||||||
text = self:AddIntoText(unicode, indicatornum)
|
|
||||||
lines[line] = text
|
|
||||||
self:MoveIndicator(1)
|
|
||||||
elseif indicatornum == #text then
|
|
||||||
text = text .. ckey
|
|
||||||
lines[line] = text
|
|
||||||
self:MoveIndicator(1)
|
|
||||||
elseif indicatornum == 0 then
|
|
||||||
text = self:AddIntoText(unicode, indicatornum)
|
|
||||||
lines[line] = text
|
|
||||||
self:MoveIndicator(1)
|
|
||||||
end
|
|
||||||
lines = self.lines
|
|
||||||
line = self.line
|
|
||||||
curline = lines[line]
|
|
||||||
text = curline
|
|
||||||
if not multiline then
|
|
||||||
local masked = self.masked
|
local masked = self.masked
|
||||||
local twidth = 0
|
|
||||||
local cwidth = 0
|
local cwidth = 0
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = self.maskchar
|
local maskchar = self.maskchar
|
||||||
twidth = font:getWidth(text:gsub(".", maskchar))
|
cwidth = font:getWidth(text:sub(#text):gsub(".", maskchar))
|
||||||
cwidth = font:getWidth(ckey:gsub(".", maskchar))
|
|
||||||
else
|
else
|
||||||
twidth = font:getWidth(text)
|
cwidth = font:getWidth(text:sub(#text))
|
||||||
cwidth = font:getWidth(ckey)
|
|
||||||
end
|
end
|
||||||
-- swidth - 1 is for the "-" character
|
if self.offsetx > 0 then
|
||||||
if (twidth + textoffsetx) >= (swidth - 1) then
|
self.offsetx = self.offsetx - cwidth
|
||||||
self.offsetx = self.offsetx + cwidth
|
elseif self.offsetx < 0 then
|
||||||
|
self.offsetx = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elseif key == "delete" then
|
||||||
|
if not editable then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ckey = key
|
||||||
|
if alltextselected then
|
||||||
|
self:Clear()
|
||||||
|
self.alltextselected = false
|
||||||
|
indicatornum = self.indicatornum
|
||||||
|
else
|
||||||
|
if text ~= "" and indicatornum < #text then
|
||||||
|
text = self:RemoveFromText(indicatornum + 1)
|
||||||
|
lines[line] = text
|
||||||
|
elseif indicatornum == #text and line < #lines then
|
||||||
|
local oldtext = lines[line + 1]
|
||||||
|
if #oldtext > 0 then
|
||||||
|
newindicatornum = #lines[self.line]
|
||||||
|
lines[self.line] = lines[self.line] .. oldtext
|
||||||
|
end
|
||||||
|
table.remove(lines, line + 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif key == "return" or key == "kpenter" then
|
||||||
|
ckey = key
|
||||||
|
-- call onenter if it exists
|
||||||
|
if onenter then
|
||||||
|
onenter(self, text)
|
||||||
|
end
|
||||||
|
-- newline calculations for multiline mode
|
||||||
|
if multiline then
|
||||||
|
if alltextselected then
|
||||||
|
self.alltextselected = false
|
||||||
|
self:Clear()
|
||||||
|
indicatornum = self.indicatornum
|
||||||
|
line = self.line
|
||||||
|
end
|
||||||
|
local newtext = ""
|
||||||
|
if indicatornum == 0 then
|
||||||
|
newtext = self.lines[line]
|
||||||
|
self.lines[line] = ""
|
||||||
|
elseif indicatornum > 0 and indicatornum < #self.lines[line] then
|
||||||
|
newtext = self.lines[line]:sub(indicatornum + 1, #self.lines[line])
|
||||||
|
self.lines[line] = self.lines[line]:sub(1, indicatornum)
|
||||||
|
end
|
||||||
|
if line ~= #lines then
|
||||||
|
table.insert(self.lines, line + 1, newtext)
|
||||||
|
self.line = line + 1
|
||||||
|
else
|
||||||
|
table.insert(self.lines, newtext)
|
||||||
|
self.line = line + 1
|
||||||
|
end
|
||||||
|
self.indicatornum = 0
|
||||||
|
end
|
||||||
|
elseif key == "tab" then
|
||||||
|
ckey = key
|
||||||
|
self.lines[self.line] = self:AddIntoText(self.tabreplacement, self.indicatornum)
|
||||||
|
self:MoveIndicator(#self.tabreplacement)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- do not continue if the text limit has been reached or exceeded
|
||||||
|
if #text >= self.limit and self.limit ~= 0 and not alltextselected then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- check for unusable characters
|
||||||
|
if #self.usable > 0 then
|
||||||
|
local found = false
|
||||||
|
for k, v in ipairs(self.usable) do
|
||||||
|
if v == key then
|
||||||
|
found = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not found then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- check for usable characters
|
||||||
|
if #self.unusable > 0 then
|
||||||
|
local found = false
|
||||||
|
for k, v in ipairs(self.unusable) do
|
||||||
|
if v == key then
|
||||||
|
found = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if found then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if alltextselected then
|
||||||
|
self.alltextselected = false
|
||||||
|
self:Clear()
|
||||||
|
indicatornum = self.indicatornum
|
||||||
|
text = ""
|
||||||
|
lines = self.lines
|
||||||
|
line = self.line
|
||||||
|
end
|
||||||
|
if indicatornum ~= 0 and indicatornum ~= #text then
|
||||||
|
text = self:AddIntoText(key, indicatornum)
|
||||||
|
lines[line] = text
|
||||||
|
self:MoveIndicator(1)
|
||||||
|
elseif indicatornum == #text then
|
||||||
|
text = text .. key
|
||||||
|
lines[line] = text
|
||||||
|
self:MoveIndicator(1)
|
||||||
|
elseif indicatornum == 0 then
|
||||||
|
text = self:AddIntoText(key, indicatornum)
|
||||||
|
lines[line] = text
|
||||||
|
self:MoveIndicator(1)
|
||||||
|
end
|
||||||
|
lines = self.lines
|
||||||
|
line = self.line
|
||||||
|
curline = lines[line]
|
||||||
|
text = curline
|
||||||
|
if not multiline then
|
||||||
|
local masked = self.masked
|
||||||
|
local twidth = 0
|
||||||
|
local cwidth = 0
|
||||||
|
if masked then
|
||||||
|
local maskchar = self.maskchar
|
||||||
|
twidth = font:getWidth(text:gsub(".", maskchar))
|
||||||
|
cwidth = font:getWidth(key:gsub(".", maskchar))
|
||||||
|
else
|
||||||
|
twidth = font:getWidth(text)
|
||||||
|
cwidth = font:getWidth(key)
|
||||||
|
end
|
||||||
|
-- swidth - 1 is for the "-" character
|
||||||
|
if (twidth + textoffsetx) >= (swidth - 1) then
|
||||||
|
self.offsetx = self.offsetx + cwidth
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if love._version == "0.9.0" then
|
|
||||||
self.unicode = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local curtext = self:GetText()
|
local curtext = self:GetText()
|
||||||
if ontextchanged and initialtext ~= curtext then
|
if ontextchanged and initialtext ~= curtext then
|
||||||
ontextchanged(self, ckey)
|
ontextchanged(self, key)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -975,7 +932,7 @@ function newobject:AddIntoText(t, p)
|
|||||||
local text = curline
|
local text = curline
|
||||||
local part1 = text:sub(1, p)
|
local part1 = text:sub(1, p)
|
||||||
local part2 = text:sub(p + 1)
|
local part2 = text:sub(p + 1)
|
||||||
local new = part1 .. string.char(t) .. part2
|
local new = part1 .. t .. part2
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
@ -1833,12 +1790,8 @@ end
|
|||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:Copy()
|
function newobject:Copy()
|
||||||
|
|
||||||
local version = love._version
|
local text = self:GetText()
|
||||||
|
love.system.setClipboardText(text)
|
||||||
if version == "0.9.0" then
|
|
||||||
local text = self:GetText()
|
|
||||||
love.system.setClipboardText(text)
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user