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] 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
[REMOVED] support for LOVE 0.8.0
================================================
Version 0.9.7.2 - Alpha (January 29 - 2014)
================================================

View File

@ -45,12 +45,6 @@ loveframes.collisions = {}
--]]---------------------------------------------------------
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
local dir = loveframes.config["DIRECTORY"] or path
@ -95,6 +89,9 @@ function loveframes.load()
local base = loveframes.objects["base"]
loveframes.base = base:new()
-- enable key repeat
love.keyboard.setKeyRepeat(true)
end
--[[---------------------------------------------------------
@ -105,7 +102,6 @@ function loveframes.update(dt)
local base = loveframes.base
local input_cursor_set = loveframes.input_cursor_set
local version = love._version
loveframes.collisioncount = 0
loveframes.objectcount = 0
@ -124,7 +120,6 @@ function loveframes.update(dt)
end
end
if version == "0.9.0" then
local hoverobject = loveframes.hoverobject
local arrow = love.mouse.getSystemCursor("arrow")
local curcursor = love.mouse.getCursor()
@ -204,7 +199,6 @@ function loveframes.update(dt)
love.mouse.setCursor(arrow)
end
end
end
loveframes.collisions = {}
base:update(dt)
@ -281,13 +275,13 @@ function loveframes.mousereleased(x, y, button)
end
--[[---------------------------------------------------------
- func: keypressed(key)
- func: keypressed(key, isrepeat)
- desc: called when the player presses a key
--]]---------------------------------------------------------
function loveframes.keypressed(key, unicode)
function loveframes.keypressed(key, isrepeat)
local base = loveframes.base
base:keypressed(key, unicode)
base:keypressed(key, isrepeat)
end

View File

@ -136,17 +136,10 @@ end
--]]---------------------------------------------------------
function loveframes.util.GetDirectoryContents(dir, t)
local version = love._version
local dir = dir
local t = t or {}
local dirs = {}
local files
if version == "0.9.0" then
files = love.filesystem.getDirectoryItems(dir)
else
files = love.filesystem.enumerate(dir)
end
local files = love.filesystem.getDirectoryItems(dir)
for k, v in ipairs(files) do
local isdir = love.filesystem.isDirectory(dir.. "/" ..v)

View File

@ -151,10 +151,10 @@ function newobject:mousereleased(x, y, button)
end
--[[---------------------------------------------------------
- func: keypressed(key)
- func: keypressed(key, isrepeat)
- desc: called when the player presses a key
--]]---------------------------------------------------------
function newobject:keypressed(key, unicode)
function newobject:keypressed(key, isrepeat)
local state = loveframes.state
local selfstate = self.state

View File

@ -105,7 +105,6 @@ function newobject:draw()
local width = self.width
local height = self.height
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
local loveversion = love._version
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
@ -127,12 +126,7 @@ function newobject:draw()
drawfunc(self)
end
if loveversion == "0.8.0" then
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc)
end
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)

View File

@ -87,7 +87,6 @@ function newobject:draw()
local width = self.width
local height = self.height
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
local loveversion = love._version
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
@ -105,12 +104,7 @@ function newobject:draw()
-- set the object's draw order
self:SetDrawOrder()
if loveversion == "0.8.0" then
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc)
end
if draw then
draw(self)

View File

@ -144,7 +144,6 @@ function newobject:draw()
local width = self.width
local height = self.height
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
local loveversion = love._version
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
@ -170,12 +169,7 @@ function newobject:draw()
v:draw()
end
if loveversion == "0.8.0" then
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc)
end
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)

View File

@ -147,10 +147,10 @@ function newobject:mousereleased(x, y, button)
end
--[[---------------------------------------------------------
- func: keypressed(key)
- func: keypressed(key, isrepeat)
- desc: called when the player presses a key
--]]---------------------------------------------------------
function newobject:keypressed(key, unicode)
function newobject:keypressed(key, isrepeat)
local text = self.text
local selectedobject = loveframes.selectedobject

View File

@ -133,7 +133,6 @@ function newobject:draw()
local width = self.width
local height = self.height
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
local loveversion = love._version
local internals = self.internals
local children = self.children
local skins = loveframes.skins.available
@ -155,12 +154,7 @@ function newobject:draw()
drawfunc(self)
end
if loveversion == "0.8.0" then
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc)
end
for k, v in ipairs(children) do
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
increasebutton.Update = function(object)
local loveversion = love._version
local time = 0
if loveversion == "0.8.0" then
time = love.timer.getMicroTime()
else
time = love.timer.getTime()
end
local delay = self.delay
local down = object.down
local canmodify = self.canmodify
@ -114,13 +109,8 @@ function newobject:initialize()
end
end
decreasesbutton.Update = function(object)
local loveversion = love._version
local time = 0
if loveversion == "0.8.0" then
time = love.timer.getMicroTime()
else
time = love.timer.getTime()
end
local delay = self.delay
local down = object.down
local canmodify = self.canmodify

View File

@ -140,7 +140,6 @@ function newobject:draw()
local internals = self.internals
local tabheight = self:GetHeightOfButtons()
local stencilfunc = function() love.graphics.rectangle("fill", x + self.buttonareax, y, self.buttonareawidth, height) end
local loveversion = love._version
local internals = self.internals
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
@ -161,12 +160,7 @@ function newobject:draw()
drawfunc(self)
end
if loveversion == "0.8.0" then
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc)
end
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)

View File

@ -92,7 +92,6 @@ function newobject:update(dt)
local hover = self.hover
local linksenabled = self.linksenabled
local version = love._version
local linkcol = false
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 keydown = self.keydown
local unicode = self.unicode
local parent = self.parent
local base = loveframes.base
local update = self.Update
@ -116,7 +115,6 @@ function newobject:update(dt)
local internals = self.internals
local repeatrate = self.repeatrate
local hover = self.hover
local version = love._version
-- move to parent if there is a parent
if parent ~= base then
@ -133,18 +131,6 @@ function newobject:update(dt)
self.alltextselected = false
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:UpdateIndicator()
@ -294,7 +280,6 @@ function newobject:draw()
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
local loveversion = love._version
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
end
if loveversion == "0.8.0" then
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc)
end
if draw then
draw(self)
@ -454,10 +434,10 @@ function newobject:mousereleased(x, y, button)
end
--[[---------------------------------------------------------
- func: keypressed(key)
- func: keypressed(key, isrepeat)
- desc: called when the player presses a key
--]]---------------------------------------------------------
function newobject:keypressed(key, unicode)
function newobject:keypressed(key, isrepeat)
local state = loveframes.state
local selfstate = self.state
@ -477,7 +457,6 @@ function newobject:keypressed(key, unicode)
local repeatdelay = self.repeatdelay
local alltextselected = self.alltextselected
local editable = self.editable
local version = love._version
self.delay = time + repeatdelay
self.keydown = key
@ -485,14 +464,14 @@ function newobject:keypressed(key, unicode)
if (loveframes.util.IsCtrlDown()) and focus then
if key == "a" then
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 oncopy = self.OnCopy
love.system.setClipboardText(text)
if oncopy then
oncopy(self, text)
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 oncut = self.OnCut
love.system.setClipboardText(text)
@ -501,16 +480,13 @@ function newobject:keypressed(key, unicode)
else
self:SetText("")
end
elseif key == "v" and version == "0.9.0" and editable then
elseif key == "v" and editable then
self:Paste()
else
self:RunKey(key, false)
end
else
local version = love._version
if version == "0.8.0" then
self:RunKey(key, unicode, true)
else
self:RunKey(key, unicode, false)
end
self:RunKey(key, false)
end
end
@ -543,25 +519,19 @@ end
--]]---------------------------------------------------------
function newobject:textinput(text)
local unicode = unicode
if text:find("kp.") then
text = text:gsub("kp", "")
end
if text:len() == 1 then
unicode = string.byte(text)
else
unicode = 0
end
self:RunKey(text, unicode, true)
self:RunKey(text, true)
end
--[[---------------------------------------------------------
- func: RunKey(key, unicode)
- func: RunKey(key, istext)
- 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 focus = self.focus
@ -593,6 +563,7 @@ function newobject:RunKey(key, unicode, is_text)
local ontextchanged = self.OnTextChanged
local onenter = self.OnEnter
if not istext then
if key == "left" then
indicatornum = self.indicatornum
if not multiline then
@ -771,28 +742,19 @@ function newobject:RunKey(key, unicode, is_text)
end
elseif key == "tab" then
ckey = key
for i=1, #self.tabreplacement do
local number = string.byte(self.tabreplacement:sub(i, i))
self.lines[self.line] = self:AddIntoText(number, self.indicatornum)
self:MoveIndicator(1)
self.lines[self.line] = self:AddIntoText(self.tabreplacement, self.indicatornum)
self:MoveIndicator(#self.tabreplacement)
end
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
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
if v == key then
found = true
end
end
@ -804,7 +766,7 @@ function newobject:RunKey(key, unicode, is_text)
if #self.unusable > 0 then
local found = false
for k, v in ipairs(self.unusable) do
if v == ckey then
if v == key then
found = true
end
end
@ -821,15 +783,15 @@ function newobject:RunKey(key, unicode, is_text)
line = self.line
end
if indicatornum ~= 0 and indicatornum ~= #text then
text = self:AddIntoText(unicode, indicatornum)
text = self:AddIntoText(key, indicatornum)
lines[line] = text
self:MoveIndicator(1)
elseif indicatornum == #text then
text = text .. ckey
text = text .. key
lines[line] = text
self:MoveIndicator(1)
elseif indicatornum == 0 then
text = self:AddIntoText(unicode, indicatornum)
text = self:AddIntoText(key, indicatornum)
lines[line] = text
self:MoveIndicator(1)
end
@ -844,10 +806,10 @@ function newobject:RunKey(key, unicode, is_text)
if masked then
local maskchar = self.maskchar
twidth = font:getWidth(text:gsub(".", maskchar))
cwidth = font:getWidth(ckey:gsub(".", maskchar))
cwidth = font:getWidth(key:gsub(".", maskchar))
else
twidth = font:getWidth(text)
cwidth = font:getWidth(ckey)
cwidth = font:getWidth(key)
end
-- swidth - 1 is for the "-" character
if (twidth + textoffsetx) >= (swidth - 1) then
@ -855,15 +817,10 @@ function newobject:RunKey(key, unicode, is_text)
end
end
end
end
if love._version == "0.9.0" then
self.unicode = 0
end
local curtext = self:GetText()
if ontextchanged and initialtext ~= curtext then
ontextchanged(self, ckey)
ontextchanged(self, key)
end
return self
@ -975,7 +932,7 @@ function newobject:AddIntoText(t, p)
local text = curline
local part1 = text:sub(1, p)
local part2 = text:sub(p + 1)
local new = part1 .. string.char(t) .. part2
local new = part1 .. t .. part2
return new
@ -1833,12 +1790,8 @@ end
--]]---------------------------------------------------------
function newobject:Copy()
local version = love._version
if version == "0.9.0" then
local text = self:GetText()
love.system.setClipboardText(text)
end
return self