Remove support for LOVE 0.8.0

This commit is contained in:
Kenny Shields 2014-04-03 18:55:46 -04:00
parent 50718f04c3
commit 60ad73f8b7
13 changed files with 334 additions and 433 deletions

View File

@ -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)
================================================ ================================================

View File

@ -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,7 +120,6 @@ 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()
@ -204,7 +199,6 @@ function loveframes.update(dt)
love.mouse.setCursor(arrow) love.mouse.setCursor(arrow)
end end
end end
end
loveframes.collisions = {} loveframes.collisions = {}
base:update(dt) base:update(dt)
@ -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

View File

@ -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)

View File

@ -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

View File

@ -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
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc) 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)

View File

@ -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
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc) love.graphics.setStencil(stencilfunc)
end
if draw then if draw then
draw(self) draw(self)

View File

@ -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
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc) 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)

View File

@ -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

View File

@ -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
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc) 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)

View File

@ -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.getMicroTime()
else
time = love.timer.getTime() 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.getMicroTime()
else
time = love.timer.getTime() 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

View File

@ -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
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc) 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)

View File

@ -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

View File

@ -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
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc) 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,6 +563,7 @@ function newobject:RunKey(key, unicode, is_text)
local ontextchanged = self.OnTextChanged local ontextchanged = self.OnTextChanged
local onenter = self.OnEnter local onenter = self.OnEnter
if not istext then
if key == "left" then if key == "left" then
indicatornum = self.indicatornum indicatornum = self.indicatornum
if not multiline then if not multiline then
@ -771,28 +742,19 @@ function newobject:RunKey(key, unicode, is_text)
end end
elseif key == "tab" then elseif key == "tab" then
ckey = key ckey = key
for i=1, #self.tabreplacement do self.lines[self.line] = self:AddIntoText(self.tabreplacement, self.indicatornum)
local number = string.byte(self.tabreplacement:sub(i, i)) self:MoveIndicator(#self.tabreplacement)
self.lines[self.line] = self:AddIntoText(number, self.indicatornum)
self:MoveIndicator(1)
end end
else else
if not is_text then
return
end
self.unicode = unicode
if unicode > 31 and unicode < 127 then
-- do not continue if the text limit has been reached or exceeded -- do not continue if the text limit has been reached or exceeded
if #text >= self.limit and self.limit ~= 0 and not alltextselected then if #text >= self.limit and self.limit ~= 0 and not alltextselected then
return return
end end
-- set the current key
ckey = string.char(unicode)
-- check for unusable characters -- check for unusable characters
if #self.usable > 0 then if #self.usable > 0 then
local found = false local found = false
for k, v in ipairs(self.usable) do for k, v in ipairs(self.usable) do
if v == ckey then if v == key then
found = true found = true
end end
end end
@ -804,7 +766,7 @@ function newobject:RunKey(key, unicode, is_text)
if #self.unusable > 0 then if #self.unusable > 0 then
local found = false local found = false
for k, v in ipairs(self.unusable) do for k, v in ipairs(self.unusable) do
if v == ckey then if v == key then
found = true found = true
end end
end end
@ -821,15 +783,15 @@ function newobject:RunKey(key, unicode, is_text)
line = self.line line = self.line
end end
if indicatornum ~= 0 and indicatornum ~= #text then if indicatornum ~= 0 and indicatornum ~= #text then
text = self:AddIntoText(unicode, indicatornum) text = self:AddIntoText(key, indicatornum)
lines[line] = text lines[line] = text
self:MoveIndicator(1) self:MoveIndicator(1)
elseif indicatornum == #text then elseif indicatornum == #text then
text = text .. ckey text = text .. key
lines[line] = text lines[line] = text
self:MoveIndicator(1) self:MoveIndicator(1)
elseif indicatornum == 0 then elseif indicatornum == 0 then
text = self:AddIntoText(unicode, indicatornum) text = self:AddIntoText(key, indicatornum)
lines[line] = text lines[line] = text
self:MoveIndicator(1) self:MoveIndicator(1)
end end
@ -844,10 +806,10 @@ function newobject:RunKey(key, unicode, is_text)
if masked then if masked then
local maskchar = self.maskchar local maskchar = self.maskchar
twidth = font:getWidth(text:gsub(".", maskchar)) twidth = font:getWidth(text:gsub(".", maskchar))
cwidth = font:getWidth(ckey:gsub(".", maskchar)) cwidth = font:getWidth(key:gsub(".", maskchar))
else else
twidth = font:getWidth(text) twidth = font:getWidth(text)
cwidth = font:getWidth(ckey) cwidth = font:getWidth(key)
end end
-- swidth - 1 is for the "-" character -- swidth - 1 is for the "-" character
if (twidth + textoffsetx) >= (swidth - 1) then if (twidth + textoffsetx) >= (swidth - 1) then
@ -855,15 +817,10 @@ function newobject:RunKey(key, unicode, is_text)
end end
end end
end end
end
if love._version == "0.9.0" then
self.unicode = 0
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
if version == "0.9.0" then
local text = self:GetText() local text = self:GetText()
love.system.setClipboardText(text) love.system.setClipboardText(text)
end
return self return self