mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
Version 0.9.4.12 - Alpha (see changelog.txt)
This commit is contained in:
parent
f8356fbd36
commit
069ed45963
@ -1,3 +1,9 @@
|
||||
================================================
|
||||
Version 0.9.4.12 - Alpha (December 30 - 2012)
|
||||
================================================
|
||||
[CHANGED] newlines created on the text object with \n now display properly
|
||||
[CHANGED] Love Frames now resets the current drawing color to the last color used before calling loveframes.draw() after it has finished all drawing operations
|
||||
|
||||
================================================
|
||||
Version 0.9.4.11 - Alpha (December 28 - 2012)
|
||||
================================================
|
||||
|
@ -128,7 +128,7 @@ end
|
||||
objects
|
||||
--]]---------------------------------------------------------
|
||||
function loveframes.debug.ExamplesMenu()
|
||||
|
||||
|
||||
------------------------------------
|
||||
-- examples frame
|
||||
------------------------------------
|
||||
|
6
init.lua
6
init.lua
@ -9,7 +9,7 @@ loveframes = {}
|
||||
-- library info
|
||||
loveframes.info = {}
|
||||
loveframes.info.author = "Kenny Shields"
|
||||
loveframes.info.version = "0.9.4.11"
|
||||
loveframes.info.version = "0.9.4.12"
|
||||
loveframes.info.stage = "Alpha"
|
||||
|
||||
-- library configurations
|
||||
@ -99,11 +99,15 @@ end
|
||||
function loveframes.draw()
|
||||
|
||||
local base = loveframes.base
|
||||
local r, g, b, a = love.graphics.getColor()
|
||||
|
||||
base:draw()
|
||||
|
||||
loveframes.drawcount = 0
|
||||
loveframes.debug.draw()
|
||||
|
||||
love.graphics.setColor(r, g, b, a)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
|
@ -193,8 +193,8 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:keypressed(key, unicode)
|
||||
|
||||
local checked = self.checked
|
||||
local onchanged = self.OnChanged
|
||||
local checked = self.checked
|
||||
local onchanged = self.OnChanged
|
||||
local selectedobject = loveframes.selectedobject
|
||||
|
||||
if key == "return" and selectedobject == self then
|
||||
|
@ -75,7 +75,7 @@ function newobject:draw()
|
||||
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
if not visible then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -132,13 +132,10 @@ function newobject:mousepressed(x, y, button)
|
||||
local internals = self.internals
|
||||
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
|
@ -158,8 +158,9 @@ function newobject:SetText(t)
|
||||
elseif dtype == "number" then
|
||||
table.insert(self.formattedtext, {color = prevcolor, text = tostring(v)})
|
||||
elseif dtype == "string" then
|
||||
if self.ignorenewlines == false then
|
||||
v = v:gsub(string.char(92) .. string.char(110), string.char(10))
|
||||
if self.ignorenewlines then
|
||||
v = v:gsub(" \n ", " ")
|
||||
v = v:gsub("\n", "")
|
||||
end
|
||||
v = v:gsub(string.char(9), " ")
|
||||
local parts = loveframes.util.SplitString(v, " ")
|
||||
@ -171,11 +172,11 @@ function newobject:SetText(t)
|
||||
|
||||
if maxw > 0 then
|
||||
for k, v in ipairs(self.formattedtext) do
|
||||
local data = v.text
|
||||
local data = v.text
|
||||
local width = font:getWidth(data)
|
||||
local curw = 0
|
||||
local new = ""
|
||||
local key = k
|
||||
local curw = 0
|
||||
local new = ""
|
||||
local key = k
|
||||
if width > maxw then
|
||||
table.remove(self.formattedtext, k)
|
||||
for n=1, #data do
|
||||
@ -212,6 +213,8 @@ function newobject:SetText(t)
|
||||
local drawx = 0
|
||||
local drawy = 0
|
||||
local lines = 0
|
||||
local textwidth = 0
|
||||
local lastwidth = 0
|
||||
local totalwidth = 0
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
@ -240,7 +243,6 @@ function newobject:SetText(t)
|
||||
twidth = twidth + width
|
||||
drawx = drawx + prevtextwidth
|
||||
end
|
||||
|
||||
else
|
||||
twidth = twidth + width
|
||||
end
|
||||
@ -249,7 +251,20 @@ function newobject:SetText(t)
|
||||
v.y = drawy
|
||||
else
|
||||
if k ~= 1 then
|
||||
drawx = drawx + prevtextwidth
|
||||
if string.byte(text) == 10 then
|
||||
twidth = 0
|
||||
drawx = 0
|
||||
width = 0
|
||||
drawy = drawy + height
|
||||
text = ""
|
||||
if lastwidth < textwidth then
|
||||
lastwidth = textwidth
|
||||
end
|
||||
textwidth = 0
|
||||
else
|
||||
drawx = drawx + prevtextwidth
|
||||
textwidth = textwidth + width
|
||||
end
|
||||
end
|
||||
prevtextwidth = width
|
||||
v.x = drawx
|
||||
@ -258,10 +273,14 @@ function newobject:SetText(t)
|
||||
end
|
||||
end
|
||||
|
||||
if lastwidth == 0 then
|
||||
textwidth = totalwidth
|
||||
end
|
||||
|
||||
if maxw > 0 then
|
||||
self.width = maxw
|
||||
else
|
||||
self.width = totalwidth
|
||||
self.width = textwidth
|
||||
end
|
||||
|
||||
self.height = drawy + height
|
||||
@ -296,7 +315,7 @@ function newobject:DrawText()
|
||||
|
||||
local textdata = self.formattedtext
|
||||
local font = self.font
|
||||
local theight = font:getHeight("a")
|
||||
local theight = font:getHeight("a")
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
local shadow = self.shadow
|
||||
@ -305,7 +324,7 @@ function newobject:DrawText()
|
||||
local shadowcolor = self.shadowcolor
|
||||
|
||||
for k, v in ipairs(textdata) do
|
||||
local text = v.text
|
||||
local text = v.text
|
||||
local color = v.color
|
||||
if self.parent.type == "list" then
|
||||
if (y + v.y) <= (self.parent.y + self.parent.height) and self.y + ((v.y + theight)) >= self.parent.y then
|
||||
|
14
skins.lua
14
skins.lua
@ -15,13 +15,13 @@ loveframes.skins.available = {}
|
||||
--]]---------------------------------------------------------
|
||||
function loveframes.skins.Register(skin)
|
||||
|
||||
local name = skin.name
|
||||
local author = skin.author
|
||||
local version = skin.version
|
||||
local namecheck = loveframes.skins.available[name]
|
||||
local dir = loveframes.config["DIRECTORY"] .. "/skins/" ..name
|
||||
local dircheck = love.filesystem.isDirectory(dir)
|
||||
local images = loveframes.util.GetDirectoryContents(dir .. "/images")
|
||||
local name = skin.name
|
||||
local author = skin.author
|
||||
local version = skin.version
|
||||
local namecheck = loveframes.skins.available[name]
|
||||
local dir = loveframes.config["DIRECTORY"] .. "/skins/" ..name
|
||||
local dircheck = love.filesystem.isDirectory(dir)
|
||||
local images = loveframes.util.GetDirectoryContents(dir .. "/images")
|
||||
local indeximages = loveframes.config["INDEXSKINIMAGES"]
|
||||
|
||||
if name == "" or not name then
|
||||
|
@ -35,9 +35,9 @@ function loveframes.templates.AddProperty(templatename, object, property, value)
|
||||
end
|
||||
|
||||
local templatename = tostring(templatename)
|
||||
local property = tostring(property)
|
||||
local templates = loveframes.templates.available
|
||||
local template = templates[templatename]
|
||||
local property = tostring(property)
|
||||
local templates = loveframes.templates.available
|
||||
local template = templates[templatename]
|
||||
|
||||
-- display an error message if the property is not a string
|
||||
if type(property) ~= "string" then
|
||||
@ -82,14 +82,14 @@ function loveframes.templates.Register(template)
|
||||
loveframes.util.Error("Could not register template: Template argument must be a table.")
|
||||
end
|
||||
|
||||
local templates = loveframes.templates.available
|
||||
local templates = loveframes.templates.available
|
||||
local registeredobjects = loveframes.templates.objects
|
||||
local name = template.name
|
||||
local properties = template.properties
|
||||
local objects = loveframes.objects
|
||||
local base = objects["base"]
|
||||
local found = false
|
||||
local foundall = false
|
||||
local name = template.name
|
||||
local properties = template.properties
|
||||
local objects = loveframes.objects
|
||||
local base = objects["base"]
|
||||
local found = false
|
||||
local foundall = false
|
||||
|
||||
-- display an error message if a template name was not given
|
||||
if not name then
|
||||
@ -116,9 +116,9 @@ function loveframes.templates.Get(name)
|
||||
loveframes.util.Error("Could not create property: No template name given.")
|
||||
end
|
||||
|
||||
local name = tostring(name)
|
||||
local name = tostring(name)
|
||||
local templates = loveframes.templates.available
|
||||
local template = templates[name]
|
||||
local template = templates[name]
|
||||
|
||||
-- display an error message if the template is invalid
|
||||
if not template then
|
||||
@ -156,35 +156,25 @@ function loveframes.templates.ApplyToObject(object)
|
||||
|
||||
-- loop through all available templates
|
||||
for k, v in pairs(templates) do
|
||||
|
||||
-- make sure the base template doesn't get applied more than once
|
||||
if k ~= "Base" then
|
||||
|
||||
local properties = v.properties
|
||||
local hasall = loveframes.util.TableHasKey(properties, "*")
|
||||
local hasobject = false
|
||||
|
||||
local hasall = loveframes.util.TableHasKey(properties, "*")
|
||||
local hasobject = false
|
||||
if not hasall then
|
||||
hasobject = loveframes.util.TableHasKey(properties, type)
|
||||
end
|
||||
|
||||
if hasall then
|
||||
|
||||
for k, v in pairs(properties["*"]) do
|
||||
object[k] = v
|
||||
end
|
||||
|
||||
elseif hasobject then
|
||||
|
||||
-- apply the template properties to the object
|
||||
for k, v in pairs(properties[type]) do
|
||||
object[k] = v
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
19
util.lua
19
util.lua
@ -56,9 +56,7 @@ function loveframes.util.GetCollisions(object, t)
|
||||
|
||||
-- add the current object if colliding
|
||||
if object.visible == true then
|
||||
|
||||
local col = loveframes.util.BoundingBox(x, object.x, y, object.y, 1, object.width, 1, object.height)
|
||||
|
||||
if col == true and object.collide ~= false then
|
||||
if object.clickbounds then
|
||||
local clickcol = loveframes.util.BoundingBox(x, object.clickbounds.x, y, object.clickbounds.y, 1, object.clickbounds.width, 1, object.clickbounds.height)
|
||||
@ -69,29 +67,24 @@ function loveframes.util.GetCollisions(object, t)
|
||||
table.insert(t, object)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- check for children
|
||||
if object.children then
|
||||
|
||||
for k, v in ipairs(object.children) do
|
||||
if v.visible then
|
||||
loveframes.util.GetCollisions(v, t)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- check for internals
|
||||
if object.internals then
|
||||
|
||||
for k, v in ipairs(object.internals) do
|
||||
if v.visible and v.type ~= "tooltip" then
|
||||
loveframes.util.GetCollisions(v, t)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return t
|
||||
@ -132,10 +125,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function loveframes.util.GetDirectoryContents(dir, t)
|
||||
|
||||
local dir = dir
|
||||
local t = t or {}
|
||||
local dir = dir
|
||||
local t = t or {}
|
||||
local files = love.filesystem.enumerate(dir)
|
||||
local dirs = {}
|
||||
local dirs = {}
|
||||
|
||||
for k, v in ipairs(files) do
|
||||
|
||||
@ -144,10 +137,10 @@ function loveframes.util.GetDirectoryContents(dir, t)
|
||||
if isdir == true then
|
||||
table.insert(dirs, dir.. "/" ..v)
|
||||
else
|
||||
local parts = loveframes.util.SplitString(v, "([.])")
|
||||
local parts = loveframes.util.SplitString(v, "([.])")
|
||||
local extension = parts[#parts]
|
||||
parts[#parts] = nil
|
||||
local name = table.concat(parts)
|
||||
parts[#parts] = nil
|
||||
local name = table.concat(parts)
|
||||
table.insert(t, {path = dir, fullpath = dir.. "/" ..v, requirepath = dir .. "." ..name, name = name, extension = extension})
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user