diff --git a/changelog.txt b/changelog.txt index 3db3b58..b9d646b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,13 @@ +================================================ +Version 0.9.4.13 - Alpha (January 4 - 2013) +================================================ +[ADDED] a new base method: IsInList() + +[FIXED] not being able to add the boolean "false" to a template as a property with loveframes.templates.AddProperty(templatename, object, property, value) + +[CHANGED] small code cleanup +[CHANGED] improved performance of the text object while parented within a list object + ================================================ Version 0.9.4.12 - Alpha (December 30 - 2012) ================================================ diff --git a/debug.lua b/debug.lua index cbfedd3..5c2f57c 100644 --- a/debug.lua +++ b/debug.lua @@ -755,7 +755,7 @@ function loveframes.debug.SkinSelector() frame:SetName("Skin Selector") frame:SetSize(200, 60) frame:SetPos(5, 255) - + local skinslist = loveframes.Create("multichoice", frame) skinslist:SetPos(5, 30) skinslist:SetWidth(190) diff --git a/init.lua b/init.lua index 9665ca8..0fa7203 100644 --- a/init.lua +++ b/init.lua @@ -7,27 +7,27 @@ loveframes = {} -- library info -loveframes.info = {} -loveframes.info.author = "Kenny Shields" -loveframes.info.version = "0.9.4.12" -loveframes.info.stage = "Alpha" +loveframes.info = {} +loveframes.info.author = "Kenny Shields" +loveframes.info.version = "0.9.4.13" +loveframes.info.stage = "Alpha" -- library configurations -loveframes.config = {} -loveframes.config["DIRECTORY"] = "" -loveframes.config["DEFAULTSKIN"] = "Blue" -loveframes.config["ACTIVESKIN"] = "Blue" +loveframes.config = {} +loveframes.config["DIRECTORY"] = "" +loveframes.config["DEFAULTSKIN"] = "Blue" +loveframes.config["ACTIVESKIN"] = "Blue" loveframes.config["INDEXSKINIMAGES"] = true -loveframes.config["DEBUG"] = false +loveframes.config["DEBUG"] = false -- misc library vars -loveframes.drawcount = 0 -loveframes.hoverobject = false -loveframes.modalobject = false -loveframes.inputobject = false -loveframes.basicfont = love.graphics.newFont(12) -loveframes.basicfontsmall = love.graphics.newFont(10) -loveframes.objects = {} +loveframes.drawcount = 0 +loveframes.hoverobject = false +loveframes.modalobject = false +loveframes.inputobject = false +loveframes.basicfont = love.graphics.newFont(12) +loveframes.basicfontsmall = love.graphics.newFont(10) +loveframes.objects = {} --[[--------------------------------------------------------- - func: load() diff --git a/objects/base.lua b/objects/base.lua index 18e1d6d..ee29c6d 100644 --- a/objects/base.lua +++ b/objects/base.lua @@ -523,8 +523,6 @@ function newobject:Remove() end end - self.removed = true - end --[[--------------------------------------------------------- @@ -1047,4 +1045,22 @@ function newobject:GetProperty(name) return self[name] +end + +--[[--------------------------------------------------------- + - func: IsInList() + - desc: checks to see if an object is in a list +--]]--------------------------------------------------------- +function newobject:IsInList() + + local parents = self:GetParents() + + for k, v in ipairs(parents) do + if v.type == "list" then + return true, v + end + end + + return false, false + end \ No newline at end of file diff --git a/objects/internal/columnlist/columnlistrow.lua b/objects/internal/columnlist/columnlistrow.lua index ef37a0e..1e57cac 100644 --- a/objects/internal/columnlist/columnlistrow.lua +++ b/objects/internal/columnlist/columnlistrow.lua @@ -123,15 +123,12 @@ function newobject:mousereleased(x, y, button) end if self.hover and button == "l" then - local parent1 = self:GetParent() local parent2 = parent1:GetParent() local onrowclicked = parent2.OnRowClicked - if onrowclicked then onrowclicked(parent2, self, self.columndata) end - end end diff --git a/objects/internal/columnlist/coulmnlistheader.lua b/objects/internal/columnlist/coulmnlistheader.lua index f041a40..8ceb98f 100644 --- a/objects/internal/columnlist/coulmnlistheader.lua +++ b/objects/internal/columnlist/coulmnlistheader.lua @@ -28,19 +28,23 @@ function newobject:initialize(name, parent) local key = 0 - for k, v in ipairs(self.parent.children) do + for k, v in ipairs(parent.children) do if v == self then key = k end end - self.OnClick = function() - if self.descending == true then - self.descending = false + self.OnClick = function(object) + local descending = object.descending + local parent = object.parent + local pinternals = parent.internals + local list = pinternals[1] + if descending then + object.descending = false else - self.descending = true + object.descending = true end - self.parent.internals[1]:Sort(key, self.descending) + list:Sort(key, object.descending) end -- apply template properties to the object diff --git a/objects/internal/linenumberspanel.lua b/objects/internal/linenumberspanel.lua index 164d9b6..bd98f37 100644 --- a/objects/internal/linenumberspanel.lua +++ b/objects/internal/linenumberspanel.lua @@ -141,7 +141,7 @@ end --]]--------------------------------------------------------- function newobject:mousereleased(x, y, button) - local visible = self.visible + local visible = self.visible if not visible then return diff --git a/objects/internal/sliderbutton.lua b/objects/internal/sliderbutton.lua index c6f9c9b..0f142a4 100644 --- a/objects/internal/sliderbutton.lua +++ b/objects/internal/sliderbutton.lua @@ -195,12 +195,12 @@ function newobject:mousepressed(x, y, button) if baseparent and baseparent.type == "frame" then baseparent:MakeTop() end - self.down = true - self.dragging = true - self.startx = self.staticx - self.clickx = x - self.starty = self.staticy - self.clicky = y + self.down = true + self.dragging = true + self.startx = self.staticx + self.clickx = x + self.starty = self.staticy + self.clicky = y loveframes.hoverobject = self end diff --git a/objects/internal/tooltip.lua b/objects/internal/tooltip.lua index d6d7da7..15b6d2e 100644 --- a/objects/internal/tooltip.lua +++ b/objects/internal/tooltip.lua @@ -27,6 +27,7 @@ function newobject:initialize(object, text, width) self.followcursor = true self.alwaysupdate = true + -- create the object's text self.text = loveframes.Create("text") self.text:Remove() self.text.parent = self diff --git a/objects/text.lua b/objects/text.lua index 4344d84..e4432a4 100644 --- a/objects/text.lua +++ b/objects/text.lua @@ -322,12 +322,13 @@ function newobject:DrawText() local shadowxoffset = self.shadowxoffset local shadowyoffset = self.shadowyoffset local shadowcolor = self.shadowcolor + local inlist, list = self:IsInList() for k, v in ipairs(textdata) do 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 + if inlist then + if (y + v.y) <= (list.y + list.height) and self.y + ((v.y + theight)) >= list.y then love.graphics.setFont(font) if shadow then love.graphics.setColor(unpack(shadowcolor)) diff --git a/templates.lua b/templates.lua index 9e1ca4e..d27541c 100644 --- a/templates.lua +++ b/templates.lua @@ -19,21 +19,16 @@ loveframes.templates.objects = {} --]]--------------------------------------------------------- function loveframes.templates.AddProperty(templatename, object, property, value) - -- display and error if name is nil or false + -- display an error if name is nil or false if not templatename then loveframes.util.Error("Could not create property: No template name given.") end - -- display and error if property is nil or false + -- display an error if property is nil or false if not property then loveframes.util.Error("Could not create property: No property name given.") end - -- display and error if value is nil or false - if not value then - loveframes.util.Error("Could not create property: No property value given.") - end - local templatename = tostring(templatename) local property = tostring(property) local templates = loveframes.templates.available diff --git a/util.lua b/util.lua index cfc8f53..791cb7b 100644 --- a/util.lua +++ b/util.lua @@ -131,9 +131,7 @@ function loveframes.util.GetDirectoryContents(dir, t) local dirs = {} for k, v in ipairs(files) do - local isdir = love.filesystem.isDirectory(dir.. "/" ..v) - if isdir == true then table.insert(dirs, dir.. "/" ..v) else @@ -143,7 +141,6 @@ function loveframes.util.GetDirectoryContents(dir, t) local name = table.concat(parts) table.insert(t, {path = dir, fullpath = dir.. "/" ..v, requirepath = dir .. "." ..name, name = name, extension = extension}) end - end if #dirs > 0 then @@ -165,8 +162,12 @@ end function loveframes.util.Round(num, idp) local mult = 10^(idp or 0) - if num >= 0 then return math.floor(num * mult + 0.5) / mult - else return math.ceil(num * mult - 0.5) / mult end + + if num >= 0 then + return math.floor(num * mult + 0.5) / mult + else + return math.ceil(num * mult - 0.5) / mult + end end @@ -180,7 +181,6 @@ function loveframes.util.SplitString(str, pat) local t = {} -- NOTE: use {n = 0} in Lua-5.0 if pat == " " then - local fpat = "(.-)" .. pat local last_end = 1 local s, e, cap = str:find(fpat, 1) @@ -198,9 +198,7 @@ function loveframes.util.SplitString(str, pat) cap = str:sub(last_end) table.insert(t, cap) end - else - local fpat = "(.-)" .. pat local last_end = 1 local s, e, cap = str:find(fpat, 1) @@ -215,7 +213,6 @@ function loveframes.util.SplitString(str, pat) cap = str:sub(last_end) table.insert(t, cap) end - end return t