diff --git a/changelog.txt b/changelog.txt index b475777..a383bab 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,19 @@ +================================================ +Version 0.9.4.3 - Alpha (November 20 - 2012) +================================================ +[ADDED] a new base method: SetProperty(name, value) +[ADDED] a new base method: GetProperty(name) +[ADDED] a new list method: SetButtonScrollAmount(amount) +[ADDED] a new list method: GetButtonScrollAmount() +[ADDED] a new list method: SetMouseWheelScrollAmount(amount) +[ADDED] a new list method: GetMouseWheelScrollAmount() + +[FIXED] a typo in the changelog +[FIXED] image:SetScale(scalex, scaley) not working correctly + +[CHANGED] loveframes.util.GetDirContents(dir, t) to loveframes.util.GetDirectoryContents(dir, t) +[CHANGED] arguments passed to require() to use "." instead of "/" which should fix file loading issues on certain systems + ================================================ Version 0.9.4.2 - Alpha (November 5 - 2012) ================================================ @@ -28,7 +44,7 @@ Version 0.9.4.2 - Alpha (November 5 - 2012) [FIXED] text in a single line text input always being cleared when the enter key was pressed [FIXED] a syntax error in both default skin files that caused imaged to draw incorrect when they had a custom color [FIXED] an error that would occur when a tab button was being drawn while no font had been set -[FIXED] textinput.OnTextChanged being called to early when using the backspace key or the delete key +[FIXED] textinput.OnTextChanged being called too early when using the backspace key or the delete key [CHANGED] tab buttons no longer calculate their width from within their internal drawing function and should be sized externally from now on [CHANGED] the text object now calculates what characters should be drawn while in a list object to improve performance with list objects that contain large amounts of text diff --git a/debug.lua b/debug.lua index 524d69e..467af7f 100644 --- a/debug.lua +++ b/debug.lua @@ -6,11 +6,17 @@ -- debug library loveframes.debug = {} -local font = love.graphics.newFont(10) -local changelog, size = love.filesystem.read("libraries/loveframes/changelog.txt") -local loremipsum = -[[ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dui enim, porta eget facilisis quis, laoreet sit amet urna. Maecenas lobortis venenatis euismod. Sed at diam sit amet odio feugiat pretium nec quis libero. Quisque auctor semper imperdiet. Maecenas risus eros, varius pharetra volutpat in, fermentum scelerisque lacus. Proin lectus erat, luctus non facilisis vel, hendrerit vitae nisl. Aliquam vulputate scelerisque odio id faucibus. +local font = love.graphics.newFont(10) +local loremipsum = +[[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet massa mattis tortor faucibus non congue mauris mattis. Aliquam ultricies scelerisque mi, sit amet tempor metus pharetra vel. Etiam eu arcu a dolor porttitor condimentum in malesuada urna. Mauris vel nulla mi, quis aliquet neque. In aliquet turpis eget purus malesuada tincidunt. Donec rutrum purus vel diam suscipit vehicula. Cras sem nibh, tempus at dictum non, consequat non justo. In sed tellus nec orci scelerisque scelerisque id vitae leo. Maecenas pharetra, nibh eget commodo gravida, augue nisl blandit dui, ut malesuada augue dui nec erat. Phasellus nec mauris pharetra metus iaculis viverra sit amet ut tortor. Duis et viverra magna. Nunc orci dolor, placerat a iaculis non, mattis sed nibh. + + Mauris ac erat sit amet ante condimentum scelerisque. Cras eleifend lorem dictum mi euismod non placerat lorem gravida. Vestibulum sodales dapibus eros, non iaculis risus commodo eu. Maecenas dapibus purus accumsan metus euismod suscipit. Etiam eleifend lorem eget quam ornare interdum sed at nulla. Suspendisse viverra sapien ut felis viverra pellentesque. Ut convallis hendrerit est, in imperdiet purus placerat ut. Curabitur sapien nibh, molestie et elementum a, sagittis et tortor. Vestibulum sed quam eu velit euismod rutrum vitae et sem. Morbi accumsan quam vitae sapien scelerisque tincidunt. Nulla ipsum leo, scelerisque at consequat sit amet, venenatis eget mauris. Aliquam at nibh vel lorem hendrerit dignissim. Cras et risus sit amet est vehicula auctor at a leo. Curabitur euismod mi sit amet nunc consequat sed fringilla justo sagittis. + + Nulla ut arcu felis, a laoreet tellus. Vivamus ligula nibh, bibendum ut ultrices sed, ullamcorper et est. Pellentesque nisi diam, sollicitudin lacinia fermentum quis, aliquam fermentum elit. Donec egestas vestibulum mollis. Vivamus sollicitudin nisl vestibulum nisi fermentum scelerisque. Nunc enim magna, posuere ornare faucibus a, bibendum vestibulum felis. Etiam laoreet molestie elit, vitae ultrices sem faucibus in. Fusce rutrum convallis lacus, vitae scelerisque eros tincidunt sed. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. + + Quisque ornare arcu sed enim sodales dictum. Suspendisse at convallis mi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Maecenas et nibh odio, eu lacinia lacus. Mauris at pulvinar urna. Pellentesque vel justo erat, a congue nibh. Nunc tristique mattis euismod. Suspendisse potenti. + + Sed dictum faucibus cursus. Integer nisi ipsum, dapibus vel blandit laoreet, bibendum congue massa. Vestibulum tincidunt vulputate nunc, facilisis consequat lacus posuere at. Aenean sed mollis urna. Vivamus congue neque non arcu malesuada lobortis. Curabitur suscipit pretium massa eu rutrum. Nulla vehicula imperdiet dui in blandit. Curabitur vitae felis ut massa scelerisque consequat. Nulla a magna quis risus consequat hendrerit. Maecenas quis lacus sit amet ipsum condimentum interdum. Proin condimentum erat id enim elementum ut tincidunt neque vulputate. ]] --[[--------------------------------------------------------- @@ -27,16 +33,16 @@ function loveframes.debug.draw() return end - local cols = loveframes.util.GetCollisions() - local topcol = {type = none, children = {}, x = 0, y = 0, width = 0, height = 0} - local objects = loveframes.util.GetAllObjects() - local author = loveframes.info.author - local version = loveframes.info.version - local stage = loveframes.info.stage - local basedir = loveframes.config["DIRECTORY"] - local loveversion = love._version - local fps = love.timer.getFPS() - local deltatime = love.timer.getDelta() + local cols = loveframes.util.GetCollisions() + local topcol = {type = none, children = {}, x = 0, y = 0, width = 0, height = 0} + local objects = loveframes.util.GetAllObjects() + local author = loveframes.info.author + local version = loveframes.info.version + local stage = loveframes.info.stage + local basedir = loveframes.config["DIRECTORY"] + local loveversion = love._version + local fps = love.timer.getFPS() + local deltatime = love.timer.getDelta() -- set the top most collision object for k, v in ipairs(cols) do @@ -670,11 +676,11 @@ function loveframes.debug.ExamplesMenu() list1:SetPadding(5) list1:SetSpacing(5) - for i=1, 5 do + --for i=1, 5 do local text1 = loveframes.Create("text") text1:SetText(loremipsum) list1:AddItem(text1) - end + --end end exampleslist:AddItem(textexample) @@ -719,7 +725,7 @@ function loveframes.debug.ExamplesMenu() togglebutton:SetPos(5, 335) textinput1:SetMultiline(true) textinput1:SetHeight(300) - textinput1:SetText(changelog) + textinput1:SetText("") end end diff --git a/init.lua b/init.lua index d951439..3a0066c 100644 --- a/init.lua +++ b/init.lua @@ -8,27 +8,22 @@ loveframes = {} -- library info loveframes.info = {} -loveframes.info.author = "Nikolai Resokav" -loveframes.info.version = "0.9.4.2" +loveframes.info.author = "Kenny Shields" +loveframes.info.version = "0.9.4.3" loveframes.info.stage = "Alpha" -- library configurations loveframes.config = {} -loveframes.config["DIRECTORY"] = "libraries/loveframes" +loveframes.config["DIRECTORY"] = "" loveframes.config["DEFAULTSKIN"] = "Blue" loveframes.config["ACTIVESKIN"] = "Blue" loveframes.config["INDEXSKINIMAGES"] = true -loveframes.config["DEBUG"] = true +loveframes.config["DEBUG"] = false -- misc library vars loveframes.drawcount = 0 -loveframes.lastselection = 0 -loveframes.selectiondelay = 0.05 -loveframes.selectionstartdelay = 0.50 -loveframes.selecting = false loveframes.hoverobject = false loveframes.modalobject = false -loveframes.selectedobject = false loveframes.basicfont = love.graphics.newFont(12) loveframes.basicfontsmall = love.graphics.newFont(10) @@ -42,35 +37,35 @@ function loveframes.load() local dir = loveframes.config["DIRECTORY"] -- require the internal base libraries - require(dir .. "/third-party/middleclass") - require(dir .. "/util") - require(dir .. "/skins") - require(dir .. "/templates") - require(dir .. "/debug") + require(dir .. ".third-party.middleclass") + require(dir .. ".util") + require(dir .. ".skins") + require(dir .. ".templates") + require(dir .. ".debug") -- create a list of gui objects and skins - local objects = loveframes.util.GetDirContents(dir .. "/objects") - local skins = loveframes.util.GetDirContents(dir .. "/skins") - local templates = loveframes.util.GetDirContents(dir .. "/templates") + local objects = loveframes.util.GetDirectoryContents(dir .. "/objects") + local skins = loveframes.util.GetDirectoryContents(dir .. "/skins") + local templates = loveframes.util.GetDirectoryContents(dir .. "/templates") -- loop through a list of all gui objects and require them for k, v in ipairs(objects) do if v.extension == "lua" then - require(v.path .. "/" ..v.name) + require(v.requirepath) end end -- loop through a list of all gui templates and require them for k, v in ipairs(templates) do if v.extension == "lua" then - require(v.path .. "/" ..v.name) + require(v.requirepath) end end -- loop through a list of all gui skins and require them for k, v in ipairs(skins) do if v.extension == "lua" then - require(v.path .. "/" ..v.name) + require(v.requirepath) end end diff --git a/objects/base.lua b/objects/base.lua index 0518b80..fb6d48e 100644 --- a/objects/base.lua +++ b/objects/base.lua @@ -1033,4 +1033,24 @@ function base:GetDrawOrder() return self.draworder +end + +--[[--------------------------------------------------------- + - func: SetProperty(name, value) + - desc: sets a property on the object +--]]--------------------------------------------------------- +function base:SetProperty(name, value) + + self[name] = value + +end + +--[[--------------------------------------------------------- + - func: GetProperty(name) + - desc: gets the value of an object's property +--]]--------------------------------------------------------- +function base:GetProperty(name) + + return self[name] + end \ No newline at end of file diff --git a/objects/image.lua b/objects/image.lua index 7a8f4f8..7b40dba 100644 --- a/objects/image.lua +++ b/objects/image.lua @@ -204,8 +204,8 @@ end --]]--------------------------------------------------------- function image:SetScale(scalex, scaley) - self.scalex = x - self.scaley = y + self.scalex = scalex + self.scaley = scaley end diff --git a/objects/internal/scrollable/scrollbody.lua b/objects/internal/scrollable/scrollbody.lua index 51f1c57..a7fb301 100644 --- a/objects/internal/scrollable/scrollbody.lua +++ b/objects/internal/scrollable/scrollbody.lua @@ -44,7 +44,7 @@ function scrollbody:initialize(parent, bartype) upbutton.staticx = 0 + self.width - upbutton.width upbutton.staticy = 0 if object.down and object.hover then - bar:Scroll(-0.10) + bar:Scroll(-self.parent.buttonscrollamount) end end @@ -54,7 +54,7 @@ function scrollbody:initialize(parent, bartype) downbutton.staticx = 0 + self.width - downbutton.width downbutton.staticy = 0 + self.height - downbutton.height if object.down and object.hover then - bar:Scroll(0.10) + bar:Scroll(self.parent.buttonscrollamount) end end @@ -69,7 +69,7 @@ function scrollbody:initialize(parent, bartype) leftbutton.staticx = 0 leftbutton.staticy = 0 if object.down and object.hover then - bar:Scroll(-0.10) + bar:Scroll(-self.parent.buttonscrollamount) end end @@ -79,7 +79,7 @@ function scrollbody:initialize(parent, bartype) rightbutton.staticx = 0 + self.width - rightbutton.width rightbutton.staticy = 0 if object.down and object.hover then - bar:Scroll(0.10) + bar:Scroll(self.parent.buttonscrollamount) end end diff --git a/objects/list.lua b/objects/list.lua index 884f3a0..f956832 100644 --- a/objects/list.lua +++ b/objects/list.lua @@ -12,25 +12,27 @@ list = class("list", base) --]]--------------------------------------------------------- function list:initialize() - self.type = "list" - self.display = "vertical" - self.width = 300 - self.height = 150 - self.clickx = 0 - self.clicky = 0 - self.padding = 0 - self.spacing = 0 - self.offsety = 0 - self.offsetx = 0 - self.extrawidth = 0 - self.extraheight = 0 - self.internal = false - self.hbar = false - self.vbar = false - self.autoscroll = false - self.internals = {} - self.children = {} - self.OnScroll = nil + self.type = "list" + self.display = "vertical" + self.width = 300 + self.height = 150 + self.clickx = 0 + self.clicky = 0 + self.padding = 0 + self.spacing = 0 + self.offsety = 0 + self.offsetx = 0 + self.extrawidth = 0 + self.extraheight = 0 + self.buttonscrollamount = 0.10 + self.mousewheelscrollamount = 5 + self.internal = false + self.hbar = false + self.vbar = false + self.autoscroll = false + self.internals = {} + self.children = {} + self.OnScroll = nil end @@ -157,12 +159,13 @@ function list:mousepressed(x, y, button) return end - local toplist = self:IsTopList() - local hover = self.hover - local vbar = self.vbar - local hbar = self.hbar - local children = self.children - local internals = self.internals + local toplist = self:IsTopList() + local hover = self.hover + local vbar = self.vbar + local hbar = self.hbar + local scrollamount = self.mousewheelscrollamount + local children = self.children + local internals = self.internals if hover and button == "l" then @@ -181,9 +184,9 @@ function list:mousepressed(x, y, button) local bar = self:GetScrollBar() if button == "wu" then - bar:Scroll(-5) + bar:Scroll(-scrollamount) elseif button == "wd" then - bar:Scroll(5) + bar:Scroll(scrollamount) end end @@ -555,4 +558,46 @@ function list:SetAutoScroll(bool) scrollbar.autoscroll = bool end +end + +--[[--------------------------------------------------------- + - func: SetButtonScrollAmount(speed) + - desc: sets the scroll amount of the object's scrollbar + buttons +--]]--------------------------------------------------------- +function list:SetButtonScrollAmount(amount) + + self.buttonscrollamount = amount + +end + +--[[--------------------------------------------------------- + - func: GetButtonScrollAmount() + - desc: gets the scroll amount of the object's scrollbar + buttons +--]]--------------------------------------------------------- +function list:GetButtonScrollAmount() + + return self.buttonscrollamount + +end + +--[[--------------------------------------------------------- + - func: SetMouseWheelScrollAmount(amount) + - desc: sets the scroll amount of the mouse wheel +--]]--------------------------------------------------------- +function list:SetMouseWheelScrollAmount(amount) + + self.mousewheelscrollamount = amount + +end + +--[[--------------------------------------------------------- + - func: GetMouseWheelScrollAmount() + - desc: gets the scroll amount of the mouse wheel +--]]--------------------------------------------------------- +function list:GetButtonScrollAmount() + + return self.mousewheelscrollamount + end \ No newline at end of file diff --git a/skins.lua b/skins.lua index 402a869..8f9b413 100644 --- a/skins.lua +++ b/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.GetDirContents(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 diff --git a/util.lua b/util.lua index 43f2f6f..e94e59a 100644 --- a/util.lua +++ b/util.lua @@ -126,35 +126,16 @@ function loveframes.util.GetAllObjects(object, t) end --[[--------------------------------------------------------- - - func: GetDirContents(directory, table) + - func: GetDirectoryContents(directory, table) - desc: gets the contents of a directory and all of it's subdirectories --]]--------------------------------------------------------- -function loveframes.util.GetDirContents(dir, t) +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 function to restore a string to it's original state after being split - local function restore(t) - - local s = "" - - t[#t] = nil - - for k, v in ipairs(t) do - if k ~= #t then - s = s .. v .. "." - else - s = s .. v - end - end - - return s - - end + local dirs = {} for k, v in ipairs(files) do @@ -163,17 +144,18 @@ function loveframes.util.GetDirContents(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] - local name = restore(parts) - table.insert(t, {path = dir, fullpath = dir.. "/" ..v, name = name, extension = extension}) + parts[#parts] = nil + 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 for k, v in ipairs(dirs) do - t = loveframes.util.GetDirContents(v, t) + t = loveframes.util.GetDirectoryContents(v, t) end end @@ -181,6 +163,7 @@ function loveframes.util.GetDirContents(dir, t) end + --[[--------------------------------------------------------- - func: Round(num, idp) - desc: rounds a number based on the decimal limit