From 4692f1e6d854c124c8027cc48ae84c78cb0e5d2d Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Thu, 23 Oct 2014 18:36:16 -0400 Subject: [PATCH 1/8] Keep the Love Frames table out of the global namespace --- init.lua | 111 ++++++++---------- libraries/common.lua | 1 + libraries/debug.lua | 4 + libraries/skins.lua | 4 + libraries/templates.lua | 4 + libraries/util.lua | 4 + objects/base.lua | 4 + objects/button.lua | 4 + objects/checkbox.lua | 4 + objects/collapsiblecategory.lua | 4 + objects/columnlist.lua | 4 + objects/form.lua | 4 + objects/frame.lua | 4 + objects/grid.lua | 4 + objects/image.lua | 4 + objects/imagebutton.lua | 3 + objects/internal/closebutton.lua | 4 + .../internal/columnlist/columnlistarea.lua | 4 + .../internal/columnlist/columnlistheader.lua | 4 + objects/internal/columnlist/columnlistrow.lua | 4 + objects/internal/linenumberspanel.lua | 4 + objects/internal/menuoption.lua | 4 + objects/internal/modalbackground.lua | 4 + .../internal/multichoice/multichoicelist.lua | 4 + .../internal/multichoice/multichoicerow.lua | 4 + objects/internal/scrollable/scrollarea.lua | 4 + objects/internal/scrollable/scrollbar.lua | 4 + objects/internal/scrollable/scrollbody.lua | 4 + objects/internal/scrollable/scrollbutton.lua | 4 + objects/internal/sliderbutton.lua | 4 + objects/internal/tabbutton.lua | 4 + objects/internal/tooltip.lua | 4 + objects/internal/treenode.lua | 4 + objects/internal/treenodebutton.lua | 4 + objects/list.lua | 4 + objects/menu.lua | 4 + objects/multichoice.lua | 4 + objects/numberbox.lua | 4 + objects/panel.lua | 4 + objects/progressbar.lua | 4 + objects/radiobutton.lua | 4 + objects/slider.lua | 4 + objects/tabs.lua | 4 + objects/text.lua | 4 + objects/textinput.lua | 4 + objects/tree.lua | 4 + skins/Blue/skin.lua | 4 + skins/Orange/skin.lua | 4 + templates/base.lua | 2 +- 49 files changed, 237 insertions(+), 60 deletions(-) create mode 100644 libraries/common.lua diff --git a/init.lua b/init.lua index 511faa3..1686ae3 100644 --- a/init.lua +++ b/init.lua @@ -4,9 +4,11 @@ --]]------------------------------------------------ local path = ... - --- central library table -loveframes = {} +require(path .. ".libraries.util") +require(path .. ".libraries.skins") +require(path .. ".libraries.templates") +require(path .. ".libraries.debug") +local loveframes = require(path .. ".libraries.common") -- library info loveframes.author = "Kenny Shields" @@ -39,60 +41,22 @@ loveframes.basicfontsmall = love.graphics.newFont(10) loveframes.objects = {} loveframes.collisions = {} ---[[--------------------------------------------------------- - - func: load() - - desc: loads the library ---]]--------------------------------------------------------- -function loveframes.load() - - -- install directory of the library - local dir = loveframes.config["DIRECTORY"] or path - - -- require the internal base libraries - loveframes.class = require(dir .. ".third-party.middleclass") - require(dir .. ".libraries.util") - require(dir .. ".libraries.skins") - require(dir .. ".libraries.templates") - require(dir .. ".libraries.debug") - - -- replace all "." with "/" in the directory setting - dir = dir:gsub("\\", "/"):gsub("(%a)%.(%a)", "%1/%2") - loveframes.config["DIRECTORY"] = dir - - -- create a list of gui objects, skins and 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.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.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.requirepath) - end - end - - -- create the base gui object - local base = loveframes.objects["base"] - loveframes.base = base:new() - - -- enable key repeat - love.keyboard.setKeyRepeat(true) - -end +-- install directory of the library +local dir = loveframes.config["DIRECTORY"] or path + +-- require the internal base libraries +loveframes.class = require(dir .. ".third-party.middleclass") +require(dir .. ".libraries.util") +require(dir .. ".libraries.skins") +require(dir .. ".libraries.templates") +require(dir .. ".libraries.debug") + +-- replace all "." with "/" in the directory setting +dir = dir:gsub("\\", "/"):gsub("(%a)%.(%a)", "%1/%2") +loveframes.config["DIRECTORY"] = dir + +-- enable key repeat +love.keyboard.setKeyRepeat(true) --[[--------------------------------------------------------- - func: update(deltatime) @@ -454,5 +418,34 @@ function loveframes.GetState() end --- load the library -loveframes.load() +-- create a list of gui objects, skins and 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.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.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.requirepath) + end +end + +-- create the base gui object +local base = loveframes.objects["base"] +loveframes.base = base:new() + +return loveframes diff --git a/libraries/common.lua b/libraries/common.lua new file mode 100644 index 0000000..3941af5 --- /dev/null +++ b/libraries/common.lua @@ -0,0 +1 @@ +return {} \ No newline at end of file diff --git a/libraries/debug.lua b/libraries/debug.lua index 30220f3..18ca38e 100644 --- a/libraries/debug.lua +++ b/libraries/debug.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".debug")) +local loveframes = require(path .. ".common") + -- debug library loveframes.debug = {} diff --git a/libraries/skins.lua b/libraries/skins.lua index c1abe8d..8f1f244 100644 --- a/libraries/skins.lua +++ b/libraries/skins.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".skins")) +local loveframes = require(path .. ".common") + -- skins library loveframes.skins = {} diff --git a/libraries/templates.lua b/libraries/templates.lua index bcf7a7b..02f59c9 100644 --- a/libraries/templates.lua +++ b/libraries/templates.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".templates")) +local loveframes = require(path .. ".common") + -- templates library loveframes.templates = {} diff --git a/libraries/util.lua b/libraries/util.lua index e87538a..275d25d 100644 --- a/libraries/util.lua +++ b/libraries/util.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".util")) +local loveframes = require(path .. ".common") + -- util library loveframes.util = {} diff --git a/objects/base.lua b/objects/base.lua index 931babf..ff8e4bd 100644 --- a/objects/base.lua +++ b/objects/base.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.base")) +local loveframes = require(path .. ".libraries.common") + -- base object local newobject = loveframes.NewObject("base", "loveframes_object_base") diff --git a/objects/button.lua b/objects/button.lua index 70d6c18..6e03f5f 100644 --- a/objects/button.lua +++ b/objects/button.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.button")) +local loveframes = require(path .. ".libraries.common") + -- button object local newobject = loveframes.NewObject("button", "loveframes_object_button", true) diff --git a/objects/checkbox.lua b/objects/checkbox.lua index 9c51590..a6d2337 100644 --- a/objects/checkbox.lua +++ b/objects/checkbox.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.checkbox")) +local loveframes = require(path .. ".libraries.common") + -- checkbox object local newobject = loveframes.NewObject("checkbox", "loveframes_object_checkbox", true) diff --git a/objects/collapsiblecategory.lua b/objects/collapsiblecategory.lua index 4b08844..9977711 100644 --- a/objects/collapsiblecategory.lua +++ b/objects/collapsiblecategory.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.collapsiblecategory")) +local loveframes = require(path .. ".libraries.common") + -- collapsiblecategory object local newobject = loveframes.NewObject("collapsiblecategory", "loveframes_object_collapsiblecategory", true) diff --git a/objects/columnlist.lua b/objects/columnlist.lua index 5758db9..2aa2101 100644 --- a/objects/columnlist.lua +++ b/objects/columnlist.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.columnlist")) +local loveframes = require(path .. ".libraries.common") + -- columnlist object local newobject = loveframes.NewObject("columnlist", "loveframes_object_columnlist", true) diff --git a/objects/form.lua b/objects/form.lua index e7d0b2b..cf05485 100644 --- a/objects/form.lua +++ b/objects/form.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.form")) +local loveframes = require(path .. ".libraries.common") + -- form object local newobject = loveframes.NewObject("form", "loveframes_object_form", true) diff --git a/objects/frame.lua b/objects/frame.lua index db577da..f4ff33f 100644 --- a/objects/frame.lua +++ b/objects/frame.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.frame")) +local loveframes = require(path .. ".libraries.common") + -- frame object local newobject = loveframes.NewObject("frame", "loveframes_object_frame", true) diff --git a/objects/grid.lua b/objects/grid.lua index 618776a..93a7928 100644 --- a/objects/grid.lua +++ b/objects/grid.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.grid")) +local loveframes = require(path .. ".libraries.common") + -- grid object local newobject = loveframes.NewObject("grid", "loveframes_object_grid", true) diff --git a/objects/image.lua b/objects/image.lua index 619162f..28847cb 100644 --- a/objects/image.lua +++ b/objects/image.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.image")) +local loveframes = require(path .. ".libraries.common") + -- image object local newobject = loveframes.NewObject("image", "loveframes_object_image", true) diff --git a/objects/imagebutton.lua b/objects/imagebutton.lua index cc3f62c..58ca099 100644 --- a/objects/imagebutton.lua +++ b/objects/imagebutton.lua @@ -2,6 +2,9 @@ -- Love Frames - A GUI library for LOVE -- -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.imagebutton")) +local loveframes = require(path .. ".libraries.common") -- imagebutton object local newobject = loveframes.NewObject("imagebutton", "loveframes_object_imagebutton", true) diff --git a/objects/internal/closebutton.lua b/objects/internal/closebutton.lua index f273943..f5516e0 100644 --- a/objects/internal/closebutton.lua +++ b/objects/internal/closebutton.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.closebutton")) +local loveframes = require(path .. ".libraries.common") + -- closebutton class local newobject = loveframes.NewObject("closebutton", "loveframes_object_closebutton", true) diff --git a/objects/internal/columnlist/columnlistarea.lua b/objects/internal/columnlist/columnlistarea.lua index 80e5af0..8314a3a 100644 --- a/objects/internal/columnlist/columnlistarea.lua +++ b/objects/internal/columnlist/columnlistarea.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.columnlist.columnlistarea")) +local loveframes = require(path .. ".libraries.common") + -- columnlistarea class local newobject = loveframes.NewObject("columnlistarea", "loveframes_object_columnlistarea", true) diff --git a/objects/internal/columnlist/columnlistheader.lua b/objects/internal/columnlist/columnlistheader.lua index 829f0e8..c991b84 100644 --- a/objects/internal/columnlist/columnlistheader.lua +++ b/objects/internal/columnlist/columnlistheader.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.columnlist.columnlistheader")) +local loveframes = require(path .. ".libraries.common") + -- columnlistheader class local newobject = loveframes.NewObject("columnlistheader", "loveframes_object_columnlistheader", true) diff --git a/objects/internal/columnlist/columnlistrow.lua b/objects/internal/columnlist/columnlistrow.lua index 6cb4f1c..2692da3 100644 --- a/objects/internal/columnlist/columnlistrow.lua +++ b/objects/internal/columnlist/columnlistrow.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.columnlist.columnlistrow")) +local loveframes = require(path .. ".libraries.common") + -- columnlistrow class local newobject = loveframes.NewObject("columnlistrow", "loveframes_object_columnlistrow", true) diff --git a/objects/internal/linenumberspanel.lua b/objects/internal/linenumberspanel.lua index 348d364..944bc84 100644 --- a/objects/internal/linenumberspanel.lua +++ b/objects/internal/linenumberspanel.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.linenumberspanel")) +local loveframes = require(path .. ".libraries.common") + -- linenumberspanel class local newobject = loveframes.NewObject("linenumberspanel", "loveframes_object_linenumberspanel", true) diff --git a/objects/internal/menuoption.lua b/objects/internal/menuoption.lua index 076804b..9e427ed 100644 --- a/objects/internal/menuoption.lua +++ b/objects/internal/menuoption.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.menuoption")) +local loveframes = require(path .. ".libraries.common") + -- menuoption object local newobject = loveframes.NewObject("menuoption", "loveframes_object_menuoption", true) diff --git a/objects/internal/modalbackground.lua b/objects/internal/modalbackground.lua index a3abd60..b1a5c5b 100644 --- a/objects/internal/modalbackground.lua +++ b/objects/internal/modalbackground.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.modalbackground")) +local loveframes = require(path .. ".libraries.common") + -- modalbackground class local newobject = loveframes.NewObject("modalbackground", "loveframes_object_modalbackground", true) diff --git a/objects/internal/multichoice/multichoicelist.lua b/objects/internal/multichoice/multichoicelist.lua index 79edc63..e787446 100644 --- a/objects/internal/multichoice/multichoicelist.lua +++ b/objects/internal/multichoice/multichoicelist.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.multichoice.multichoicelist")) +local loveframes = require(path .. ".libraries.common") + -- multichoicelist class local newobject = loveframes.NewObject("multichoicelist", "loveframes_object_multichoicelist", true) diff --git a/objects/internal/multichoice/multichoicerow.lua b/objects/internal/multichoice/multichoicerow.lua index 09c095c..73e4280 100644 --- a/objects/internal/multichoice/multichoicerow.lua +++ b/objects/internal/multichoice/multichoicerow.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.multichoice.multichoicerow")) +local loveframes = require(path .. ".libraries.common") + -- multichoicerow class local newobject = loveframes.NewObject("multichoicerow", "loveframes_object_multichoicerow", true) diff --git a/objects/internal/scrollable/scrollarea.lua b/objects/internal/scrollable/scrollarea.lua index 124420a..2c28bfa 100644 --- a/objects/internal/scrollable/scrollarea.lua +++ b/objects/internal/scrollable/scrollarea.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.scrollable.scrollarea")) +local loveframes = require(path .. ".libraries.common") + -- scrollarea class local newobject = loveframes.NewObject("scrollarea", "loveframes_object_scrollarea", true) diff --git a/objects/internal/scrollable/scrollbar.lua b/objects/internal/scrollable/scrollbar.lua index c48a7bd..8f0dd24 100644 --- a/objects/internal/scrollable/scrollbar.lua +++ b/objects/internal/scrollable/scrollbar.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.scrollable.scrollbar")) +local loveframes = require(path .. ".libraries.common") + -- scrollbar class local newobject = loveframes.NewObject("scrollbar", "loveframes_object_scrollbar", true) diff --git a/objects/internal/scrollable/scrollbody.lua b/objects/internal/scrollable/scrollbody.lua index 343cd5a..43fd6f3 100644 --- a/objects/internal/scrollable/scrollbody.lua +++ b/objects/internal/scrollable/scrollbody.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.scrollable.scrollbody")) +local loveframes = require(path .. ".libraries.common") + -- scrollbar class local newobject = loveframes.NewObject("scrollbody", "loveframes_object_scrollbody", true) diff --git a/objects/internal/scrollable/scrollbutton.lua b/objects/internal/scrollable/scrollbutton.lua index 8443e71..92d96b2 100644 --- a/objects/internal/scrollable/scrollbutton.lua +++ b/objects/internal/scrollable/scrollbutton.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.scrollable.scrollbutton")) +local loveframes = require(path .. ".libraries.common") + -- scrollbutton clas local newobject = loveframes.NewObject("scrollbutton", "loveframes_object_scrollbutton", true) diff --git a/objects/internal/sliderbutton.lua b/objects/internal/sliderbutton.lua index 4d3ed55..6425da5 100644 --- a/objects/internal/sliderbutton.lua +++ b/objects/internal/sliderbutton.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.sliderbutton")) +local loveframes = require(path .. ".libraries.common") + -- sliderbutton class local newobject = loveframes.NewObject("sliderbutton", "loveframes_object_sliderbutton", true) diff --git a/objects/internal/tabbutton.lua b/objects/internal/tabbutton.lua index be67469..e61e66d 100644 --- a/objects/internal/tabbutton.lua +++ b/objects/internal/tabbutton.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.tabbutton")) +local loveframes = require(path .. ".libraries.common") + -- tabbutton class local newobject = loveframes.NewObject("tabbutton", "loveframes_object_tabbutton", true) diff --git a/objects/internal/tooltip.lua b/objects/internal/tooltip.lua index aaed7fd..0732428 100644 --- a/objects/internal/tooltip.lua +++ b/objects/internal/tooltip.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.tooltip")) +local loveframes = require(path .. ".libraries.common") + -- tooltip clas local newobject = loveframes.NewObject("tooltip", "loveframes_object_tooltip", true) diff --git a/objects/internal/treenode.lua b/objects/internal/treenode.lua index 281ef69..85a0ad4 100644 --- a/objects/internal/treenode.lua +++ b/objects/internal/treenode.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.treenode")) +local loveframes = require(path .. ".libraries.common") + -- button object local newobject = loveframes.NewObject("treenode", "loveframes_object_treenode", true) diff --git a/objects/internal/treenodebutton.lua b/objects/internal/treenodebutton.lua index ae203e8..bbd465e 100644 --- a/objects/internal/treenodebutton.lua +++ b/objects/internal/treenodebutton.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.treenodebutton")) +local loveframes = require(path .. ".libraries.common") + -- button object local newobject = loveframes.NewObject("treenodebutton", "loveframes_object_treenodebutton", true) diff --git a/objects/list.lua b/objects/list.lua index 283098e..d8678bb 100644 --- a/objects/list.lua +++ b/objects/list.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.list")) +local loveframes = require(path .. ".libraries.common") + -- list object local newobject = loveframes.NewObject("list", "loveframes_object_list", true) diff --git a/objects/menu.lua b/objects/menu.lua index 6331c9b..053ac76 100644 --- a/objects/menu.lua +++ b/objects/menu.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.menu")) +local loveframes = require(path .. ".libraries.common") + -- menu object local newobject = loveframes.NewObject("menu", "loveframes_object_menu", true) diff --git a/objects/multichoice.lua b/objects/multichoice.lua index 6a79cff..bf78ac5 100644 --- a/objects/multichoice.lua +++ b/objects/multichoice.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.multichoice")) +local loveframes = require(path .. ".libraries.common") + -- multichoice object local newobject = loveframes.NewObject("multichoice", "loveframes_object_multichoice", true) diff --git a/objects/numberbox.lua b/objects/numberbox.lua index 119a66e..317ec87 100644 --- a/objects/numberbox.lua +++ b/objects/numberbox.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.numberbox")) +local loveframes = require(path .. ".libraries.common") + -- numberbox object local newobject = loveframes.NewObject("numberbox", "loveframes_object_numberbox", true) diff --git a/objects/panel.lua b/objects/panel.lua index 824f793..8487189 100644 --- a/objects/panel.lua +++ b/objects/panel.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.panel")) +local loveframes = require(path .. ".libraries.common") + -- panel object local newobject = loveframes.NewObject("panel", "loveframes_object_panel", true) diff --git a/objects/progressbar.lua b/objects/progressbar.lua index 5505a4b..2acfc74 100644 --- a/objects/progressbar.lua +++ b/objects/progressbar.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.progressbar")) +local loveframes = require(path .. ".libraries.common") + -- progressbar object local newobject = loveframes.NewObject("progressbar", "loveframes_object_progressbar", true) diff --git a/objects/radiobutton.lua b/objects/radiobutton.lua index 2df230f..2f3feab 100644 --- a/objects/radiobutton.lua +++ b/objects/radiobutton.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.radiobutton")) +local loveframes = require(path .. ".libraries.common") + -- radiobutton object local newobject = loveframes.NewObject("radiobutton", "loveframes_object_radiobutton", true) diff --git a/objects/slider.lua b/objects/slider.lua index 655bb96..4db6673 100644 --- a/objects/slider.lua +++ b/objects/slider.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.slider")) +local loveframes = require(path .. ".libraries.common") + -- slider object local newobject = loveframes.NewObject("slider", "loveframes_object_slider", true) diff --git a/objects/tabs.lua b/objects/tabs.lua index c6bc8c6..d0589db 100644 --- a/objects/tabs.lua +++ b/objects/tabs.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.tabs")) +local loveframes = require(path .. ".libraries.common") + -- tabs object local newobject = loveframes.NewObject("tabs", "loveframes_object_tabs", true) diff --git a/objects/text.lua b/objects/text.lua index 6a4e074..eded0bd 100644 --- a/objects/text.lua +++ b/objects/text.lua @@ -8,6 +8,10 @@ experimental and not final --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.text")) +local loveframes = require(path .. ".libraries.common") + -- text object local newobject = loveframes.NewObject("text", "loveframes_object_text", true) diff --git a/objects/textinput.lua b/objects/textinput.lua index 07241d5..5433fc6 100644 --- a/objects/textinput.lua +++ b/objects/textinput.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.textinput")) +local loveframes = require(path .. ".libraries.common") + -- textinput object local newobject = loveframes.NewObject("textinput", "loveframes_object_textinput", true) diff --git a/objects/tree.lua b/objects/tree.lua index 418f4f4..65f8ca8 100644 --- a/objects/tree.lua +++ b/objects/tree.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".objects.tree")) +local loveframes = require(path .. ".libraries.common") + -- button object local newobject = loveframes.NewObject("tree", "loveframes_object_tree", true) diff --git a/skins/Blue/skin.lua b/skins/Blue/skin.lua index 9d835b2..59a26b2 100644 --- a/skins/Blue/skin.lua +++ b/skins/Blue/skin.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".skins.Blue.skin")) +local loveframes = require(path .. ".libraries.common") + -- skin table local skin = {} diff --git a/skins/Orange/skin.lua b/skins/Orange/skin.lua index 9cd2fbf..015fb3f 100644 --- a/skins/Orange/skin.lua +++ b/skins/Orange/skin.lua @@ -3,6 +3,10 @@ -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ +-- get the current require path +local path = string.sub(..., 1, string.len(...) - string.len(".skins.Orange.skin")) +local loveframes = require(path .. ".libraries.common") + -- skin table local skin = {} diff --git a/templates/base.lua b/templates/base.lua index 4b6a05c..3055836 100644 --- a/templates/base.lua +++ b/templates/base.lua @@ -1 +1 @@ ---[[------------------------------------------------ -- Love Frames - A GUI library for LOVE -- -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ --[[------------------------------------------------ -- note: This is the base template for all Love Frames objects. You should not edit or delete this template unless you know what you are doing. --]]------------------------------------------------ -- template table local template = {} -- template name template.name = "Base" -- template properties template.properties = {} template.properties["*"] = { state = "none", x = 0, y = 0, width = 5, height = 5, staticx = 0, staticy = 0, draworder = 0, collide = true, internal = false, visible = true, hover = false, alwaysupdate = false, retainsize = false, calledmousefunc = false, skin = nil, clickbounds = nil, Draw = nil, Update = nil, OnMouseEnter = nil, OnMouseExit = nil } -- register the template loveframes.templates.Register(template) \ No newline at end of file +--[[------------------------------------------------ -- Love Frames - A GUI library for LOVE -- -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ --[[------------------------------------------------ -- note: This is the base template for all Love Frames objects. You should not edit or delete this template unless you know what you are doing. --]]------------------------------------------------ -- get the current require path local path = string.sub(..., 1, string.len(...) - string.len(".templates.base")) local loveframes = require(path .. ".libraries.common") -- template table local template = {} -- template name template.name = "Base" -- template properties template.properties = {} template.properties["*"] = { state = "none", x = 0, y = 0, width = 5, height = 5, staticx = 0, staticy = 0, draworder = 0, collide = true, internal = false, visible = true, hover = false, alwaysupdate = false, retainsize = false, calledmousefunc = false, skin = nil, clickbounds = nil, Draw = nil, Update = nil, OnMouseEnter = nil, OnMouseExit = nil } -- register the template loveframes.templates.Register(template) \ No newline at end of file From 9977d8e106b086c24b5ab80ac3fc63bba4ff4211 Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Thu, 23 Oct 2014 18:52:55 -0400 Subject: [PATCH 2/8] Template files are now expected to return a template table instead of calling loveframes.templates.Register --- init.lua | 3 ++- templates/base.lua | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 1686ae3..8d7af98 100644 --- a/init.lua +++ b/init.lua @@ -433,7 +433,8 @@ 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.requirepath) + local template = require(v.requirepath) + loveframes.templates.Register(template) end end diff --git a/templates/base.lua b/templates/base.lua index 3055836..abd7ddb 100644 --- a/templates/base.lua +++ b/templates/base.lua @@ -1 +1 @@ ---[[------------------------------------------------ -- Love Frames - A GUI library for LOVE -- -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ --[[------------------------------------------------ -- note: This is the base template for all Love Frames objects. You should not edit or delete this template unless you know what you are doing. --]]------------------------------------------------ -- get the current require path local path = string.sub(..., 1, string.len(...) - string.len(".templates.base")) local loveframes = require(path .. ".libraries.common") -- template table local template = {} -- template name template.name = "Base" -- template properties template.properties = {} template.properties["*"] = { state = "none", x = 0, y = 0, width = 5, height = 5, staticx = 0, staticy = 0, draworder = 0, collide = true, internal = false, visible = true, hover = false, alwaysupdate = false, retainsize = false, calledmousefunc = false, skin = nil, clickbounds = nil, Draw = nil, Update = nil, OnMouseEnter = nil, OnMouseExit = nil } -- register the template loveframes.templates.Register(template) \ No newline at end of file +--[[------------------------------------------------ -- Love Frames - A GUI library for LOVE -- -- Copyright (c) 2012-2014 Kenny Shields -- --]]------------------------------------------------ --[[------------------------------------------------ -- note: This is the base template for all Love Frames objects. You should not edit or delete this template unless you know what you are doing. --]]------------------------------------------------ -- template table local template = {} -- template name template.name = "Base" -- template properties template.properties = {} template.properties["*"] = { state = "none", x = 0, y = 0, width = 5, height = 5, staticx = 0, staticy = 0, draworder = 0, collide = true, internal = false, visible = true, hover = false, alwaysupdate = false, retainsize = false, calledmousefunc = false, skin = nil, clickbounds = nil, Draw = nil, Update = nil, OnMouseEnter = nil, OnMouseExit = nil } return template \ No newline at end of file From 15c0fae285587d08c4d4ccd00c34a39ddb16d344 Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Thu, 23 Oct 2014 18:59:01 -0400 Subject: [PATCH 3/8] Add list:GetAutoScroll --- objects/list.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/objects/list.lua b/objects/list.lua index d8678bb..9d3ca87 100644 --- a/objects/list.lua +++ b/objects/list.lua @@ -704,6 +704,18 @@ function newobject:SetAutoScroll(bool) end +--[[--------------------------------------------------------- + - func: GetAutoScroll() + - desc: gets whether or not the list's scrollbar should + auto scroll to the bottom when a new object is + added to the list +--]]--------------------------------------------------------- +function newobject:GetAutoScroll() + + return self.autoscroll + +end + --[[--------------------------------------------------------- - func: SetButtonScrollAmount(speed) - desc: sets the scroll amount of the object's scrollbar From 2e0b3a2feb689c0498ff39a0dba7f06bc9e1d0be Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Thu, 23 Oct 2014 19:07:37 -0400 Subject: [PATCH 4/8] Add missing method comment for tree:AddNode --- objects/tree.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/objects/tree.lua b/objects/tree.lua index 65f8ca8..e7f6506 100644 --- a/objects/tree.lua +++ b/objects/tree.lua @@ -271,6 +271,10 @@ function newobject:mousereleased(x, y, button) end +--[[--------------------------------------------------------- + - func: AddNode(text) + - desc: adds a node to the object +--]]--------------------------------------------------------- function newobject:AddNode(text) local node = loveframes.objects["treenode"]:new() From dd5ae7d519e8f3b10747e7e5dad651ecc12d3a9b Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Thu, 23 Oct 2014 19:29:21 -0400 Subject: [PATCH 5/8] Add tree:RemoveNode --- objects/tree.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/objects/tree.lua b/objects/tree.lua index e7f6506..d145190 100644 --- a/objects/tree.lua +++ b/objects/tree.lua @@ -288,6 +288,21 @@ function newobject:AddNode(text) end +--[[--------------------------------------------------------- + - func: RemoveNode(id) + - desc: removes a node from the object +--]]--------------------------------------------------------- +function newobject:RemoveNode(id) + + for k, v in ipairs(self.children) do + if k == id then + v:Remove() + break + end + end + +end + --[[--------------------------------------------------------- - func: GetVerticalScrollBody() - desc: gets the object's vertical scroll body From f4416ca5190e5a123718fbca578075037d6b3cb8 Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Fri, 24 Oct 2014 17:19:54 -0400 Subject: [PATCH 6/8] Add treenode:RemoveNode --- objects/internal/treenode.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/objects/internal/treenode.lua b/objects/internal/treenode.lua index 85a0ad4..7c795e7 100644 --- a/objects/internal/treenode.lua +++ b/objects/internal/treenode.lua @@ -268,6 +268,22 @@ function newobject:AddNode(text) end +--[[--------------------------------------------------------- + - func: RemoveNode(id) + - desc: removes a node from the object +--]]--------------------------------------------------------- +function newobject:RemoveNode(id) + + id = id + 1 + for k, v in ipairs(self.internals) do + if k == id then + v:Remove() + break + end + end + +end + --[[--------------------------------------------------------- - func: SetOpen(bool) - desc: sets whether or not the object is open From cc52f38f380744b62d9ce33321780c06db4271aa Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Fri, 24 Oct 2014 17:22:49 -0400 Subject: [PATCH 7/8] Update changelog --- changelog.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index b6aec65..06bb4e2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,5 @@ ================================================ -Version 0.9.9 - Alpha (Release Date TBD) +Version 0.10 - Alpha (Release Date TBD) ================================================ [ADDED] a new object: tree [ADDED] a new object: radiobutton @@ -22,12 +22,15 @@ Version 0.9.9 - Alpha (Release Date TBD) [ADDED] a new columnlist method: SetColumnResizeEnabled(bool) [ADDED] a new columnlist method: GetColumnResizeEnabled() [ADDED] a new columnlist method: SizeColumnToData() +[ADDED] a new columnlist method: SetColumnOrder(curid, newid) [ADDED] a new columnlistheader method: SetName(name) [ADDED] a new scrollbody method: GetScrollBar() [ADDED] a new frame method: SetMaxSize(width, height) [ADDED] a new frame method: GetMaxSize() [ADDED] a new frame method: SetMinSize(width, height) [ADDED] a new frame method: GetMinSize() +[ADDED] a new textinput method: ClearLine(line) +[ADDED] a new list method: GetAutoScroll() [FIXED] bug that would cause tabbuttons to be positioned incorrectly when scrolling with the mouse wheel [FIXED] collision detection issue caused by list child objects not being updated when outside of their parent's bounding box @@ -35,12 +38,18 @@ Version 0.9.9 - Alpha (Release Date TBD) [FIXED] an error caused by calling base:MoveToTop on an object parented to a panel object [FIXED] nested list positioning issues [FIXED] textinput.alltextselected being set to true when calling the SelectAll method on an empty single-line textinput +[FIXED] a bug that allowed frames to be resized when they where not being hovered +[FIXED] text:GetLines always returning nil +[FIXED] creating a newline in a multiline textinput with the return key would not reset the object's xoffset +[FIXED] the last character of a long line in a multiline textinput not being shown due to a text offset calculation issue [CHANGED] columnlist row colors are now adjusted when a row is removed from the list [CHANGED] columnlistarea.rowcolorindex now resets to 1 when the list is cleared [CHANGED] columnlist:SetRowColumnText to columnlist:SetCellText [CHANGED] columnlist:AdjustColumns to columnlist:PositionColumns [CHANGED] license to zlib/libpng +[CHANGED] the loveframes table is now returned by init.lua +[CHANGED] template files are now expected to return a template table instead of calling loveframes.templates.Register ================================================ Version 0.9.8.1 - Alpha (May 17 - 2014) From 7f1ace5b81a1185612b749c21f3a29778e04c1c6 Mon Sep 17 00:00:00 2001 From: Stepets Date: Sat, 25 Oct 2014 14:48:28 +0400 Subject: [PATCH 8/8] fully removed debug output --- objects/textinput.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/objects/textinput.lua b/objects/textinput.lua index 6ff74cd..5fc58b9 100644 --- a/objects/textinput.lua +++ b/objects/textinput.lua @@ -969,7 +969,6 @@ function newobject:UpdateIndicator() if indicatorRelativeX < leftlimit then correction = correction * -1 end - print(correction) hbody:GetScrollBar():ScrollTo((width + correction) / twidth) end end