Version 0.9.5 - Alpha (see changelog.txt)

This commit is contained in:
Kenny Shields 2013-02-11 16:15:40 -05:00
parent 2fc9df1deb
commit b0bd3a33cc
64 changed files with 16988 additions and 15623 deletions

View File

@ -1,458 +1,501 @@
================================================
Version 0.9.4.15 - Alpha (January 5 - 2013)
================================================
[ADDED] a new base method: GetInternals()
[ADDED] a new tooltip method: SetFollowObject(bool)
================================================
Version 0.9.4.14 - Alpha (January 4 - 2013)
================================================
[ADDED] a new util library function: loveframes.util.CheckForUpdates() (note: this function is meant to be used by the developer and is never called internally by Love Frames)
[ADDED] a new callback for the tabbutton object: OnOpened(object)
[ADDED] a new callback for the tabbutton object: OnClosed(object)
[CHANGED] tabs:AddTab(name, object, tip, image) now accepts two new optional arguments for tabbutton callbacks (ex: tabs:AddTab(name, object, tip, image, onopened, onclosed))
================================================
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)
================================================
[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)
================================================
[ADDED] a new textinput method: SetAutoScroll(bool)
[ADDED] a new textinput method: GetAutoScroll()
[FIXED] a couple of typos in the changelog
[FIXED] a sliderbutton calculation error that caused the sliderbutton object to flash while moving the cursor out of it's bounding box while it was down
[CHANGED] cleaned up a lot of code
[CHANGED] the text object's shadow color now defaults to black
================================================
Version 0.9.4.10 - Alpha (December 26 - 2012)
================================================
[FIXED] registration errors for the new default skins
================================================
Version 0.9.4.9 - Alpha (December 26 - 2012)
================================================
[ADDED] a new default skin: Blue (basic)
[ADDED] a new default skin: Orange (basic)
[ADDED] a new skins library function: loveframes.skins.GetAvailable()
[CHANGED] the license from CC BY-SA 3.0 to CC BY 3.0
[CHANGED] made minor improvements to the default skins
================================================
Version 0.9.4.8 - Alpha (December 24 - 2012)
================================================
[ADDED] a new text method: SetShadow(bool)
[ADDED] a new text method: GetShadow()
[ADDED] a new text method: SetShadowOffsets(offsetx, offsety)
[ADDED] a new text method: GetShadowOffsets()
[ADDED] a new text method: SetShadowColor(r, g, b, a)
[ADDED] a new text method: GetShadowColor()
[ADDED] a new columnlist method: SetColumnHeight(height)
[FIXED] templates not being applied to objects
[CHANGED] the columnlistarea object now has better sorting
[CHANGED] the frame object no longer sets the size of it's close button
================================================
Version 0.9.4.7 - Alpha (December 19 - 2012)
================================================
[FIXED] textinput:SetFocus(focus) not working properly
[CHANGED] the tooltip object is now positionable via the standard positioning methods when not set to follow the cursor
================================================
Version 0.9.4.6 - Alpha (December 10 - 2012)
================================================
[ADDED] a new textinput event callback: OnFocusGained(object)
[ADDED] a new textinput event callback: OnFocusLost(object)
[FIXED] the textinput object accepting input from the tab and delete keys when object.editable was set to false
[CHANGED] all "." are now replaced with "/" in loveframes.config["DIRECTORY"] after all inernal Love Frames libraries have been loaded (this is to prevent filesystem errors)
[REMOVED] loveframes.util.TrimString(string)
================================================
Version 0.9.4.5 - Alpha (November 28 - 2012)
================================================
[FIXED] text inputs not losing focus in certain situations
================================================
Version 0.9.4.4 - Alpha (November 24 - 2012)
================================================
[ADDED] a new text input method: SetButtonScrollAmount(amount)
[ADDED] a new text input method: GetButtonScrollAmount()
[ADDED] a new text input method: SetMouseWheelScrollAmount(amount)
[ADDED] a new text input method: GetMouseWheelScrollAmount()
[ADDED] a new multichoice method: SetButtonScrollAmount(amount)
[ADDED] a new multichoice method: GetButtonScrollAmount()
[ADDED] a new multichoice method: SetMouseWheelScrollAmount(amount)
[ADDED] a new multichoice method: GetMouseWheelScrollAmount()
[ADDED] a new column list method: SetButtonScrollAmount(amount)
[ADDED] a new column list method: GetButtonScrollAmount()
[ADDED] a new column list method: SetMouseWheelScrollAmount(amount)
[ADDED] a new column list method: GetMouseWheelScrollAmount()
[ADDED] a new frame method: SetParentLocked(bool)
[ADDED] a new frame method: GetParentLocked()
[ADDED] a new base method: CenterWithinArea(x, y, width, height)
[ADDED] a new library function: loveframes.NewObject(id, name, inherit_from_base)
[FIXED] an error that would occur when clicking a scroll button on a multiline text input or a multichoice list
[FIXED] a button calculation error that caused the button object to flash while moving the cursor out of it's bounding box while it was down
[FIXED] several errors that could occur when a collapsible category did not have an object
[FIXED] the value of the slider object becoming -0 in certain situations
[CHANGED] the close button object is no longer positioned internally by the frame object and should now be positioned by it's skin drawing function
[CHANGED] all Love Frames objects are now stored within loveframes.objects
[CHANGED] frames are now draggable when parented to any object
[CHANGED] the look of the debug overlay
================================================
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)
================================================
[ADDED] a new text object method: SetIgnoreNewlines(bool)
[ADDED] a new text object method: GetIgnoreNewlines()
[ADDED] a new text image method: SetOrientation(orientation)
[ADDED] a new text image method: GetOrientation()
[ADDED] a new text image method: SetScaleX(scalex)
[ADDED] a new text image method: GetScaleX()
[ADDED] a new text image method: SetScaleY(scaley)
[ADDED] a new text image method: GetScaleY()
[ADDED] a new text image method: SetScale(scalex, scaley)
[ADDED] a new text image method: GetScale()
[ADDED] a new text image method: SetOffsetX(x)
[ADDED] a new text image method: GetOffsetX()
[ADDED] a new text image method: SetOffsetY(y)
[ADDED] a new text image method: GetOffsetY()
[ADDED] a new text image method: SetOffset(x, y)
[ADDED] a new text image method: GetOffset()
[ADDED] a new text image method: SetShearX(x)
[ADDED] a new text image method: GetShearX()
[ADDED] a new text image method: SetShearY(y)
[ADDED] a new text image method: GetShearY()
[ADDED] a new text image method: SetShear(x, y)
[ADDED] a new text image method: GetShear()
[FIXED] an error that ocurred after pressing enter on a multiline text input while all of it's text was selected
[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 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
================================================
Version 0.9.4.1 - Alpha (October 25 - 2012)
================================================
[ADDED] support for using the delete key in text input objects
[FIXED] textinupt:GetText() only returning the first line of a multiline text input
[FIXED] an error that occurred when clicking a multiline text input object after setting the object's text to an empty string with textinput:SetText("")
[FIXED] incorrect positioning of the text input object's indicator when using the left or right arrow keys to move the object's indicator to a different line
[FIXED] the text input object not creating a new line correctly in certain situations
[CHANGED] textinput:GetText() now returns the object's text with line breaks
================================================
Version 0.9.4 - Alpha (October 22 - 2012)
================================================
[ADDED] a new base method: SetDrawOrder()
[ADDED] a new base method: GetDrawOrder()
[ADDED] a new text method: GetFormattedText()
[ADDED] a new text input method: SetEditable(bool)
[ADDED] a new text input method: GetEditable()
[ADDED] a new text input method: GetUsable()
[ADDED] a new text input method: GetUnusable()
[ADDED] a new system for creating and applying templates to objects
[FIXED] a few incorrent entries in the changelog and added a few entries that were meant to be in the last upadte's changelog
[FIXED] an error that occured when clicking on a frame that was parented to another frame
[FIXED] frames not being positioned properly if they were parented to another object
[FIXED] modal background object not drawing over umodaled objects in certain situations
[FIXED] an error that would occur when a multichoice list object would become scrollable
[FIXED] an error that would occur when a the column list object had no columns
[FIXED] multichoice object not positioning itself properly if it's parent was the base object
[CHANGED] text:GetText() now returns a string of the object's text
[CHANGED] parented frames can no longer be modaled
================================================
Version 0.9.3.2 - Alpha (Spetember 29 - 2012)
================================================
[ADDED] a new base method: SetDrawOrder()
[ADDED] a new text input method: SetMultiline(bool)
[ADDED] a new text input method: GetVerticalScrollBody()
[ADDED] a new text input method: GetHorizontalScrollBody()
[ADDED] a new text input method: SetText(text)
[ADDED] a new text input method: HasVerticalScrollBar()
[ADDED] a new text input method: HasHorizontalScrollBar()
[ADDED] a new text input method: GetFont()
[ADDED] a new text input method: GetLineNumbersPanel()
[ADDED] a new text input method: GetMultiline()
[ADDED] a new text input method: GetTextX()
[ADDED] a new text input method: GetTextY()
[ADDED] a new text input method: IsAllTextSelected()
[ADDED] a new text input method: GetLines()
[ADDED] a new text input method: GetOffsetX()
[ADDED] a new text input method: GetOffsetY()
[ADDED] a new text input method: GetIndicatorX()
[ADDED] a new text input method: GetIndicatorY()
[ADDED] a new text input method: SetLineNumbersEnabled(enabled)
[ADDED] a new text input method: GetLineNumbersEnabled()
[ADDED] a new text input method: GetItemWidth()
[ADDED] a new text input method: GetItemHeight()
[ADDED] a new text input method: SetTabReplacement(tabreplacement)
[ADDED] a new text input method: GetTabReplacement()
[ADDED] a new scroll area method: GetBarType()
[ADDED] a new scroll bar method: IsDragging()
[ADDED] a new scroll bar method: GetBarType()
[ADDED] a new scroll button method: GetScrollType()
[ADDED] a new tab button method: GetText()
[ADDED] a new tab button method: GetImage()
[ADDED] a new tab button method: GetTabNumber()
[ADDED] a new column list header method: GetName()
[ADDED] a new column list row method: GetColumnData()
[ADDED] a new multichoice method: SetText(text)
[ADDED] a new multichoice method: GetText()
[ADDED] a new multichoice row method: GetText()
[ADDED] a new progressbar method: GetBarWidth()
[ADDED] a new internal object: linenumberspanel
[ADDED] multiline support for the text input object
[ADDED] ability to select all text within a text input
[FIXED] progressbar object not positioning itself properly if it's parent was the base object
[FIXED] a typo in the syntax of loveframes.util.SplitString (was "SplitSring", changed to "SplitString")
[FIXED] the tooltip object not disapearing if it was visible when it's object's visibility was changed to false
[FIXED] the text input object's x offset not being adjusted initially when the width of it's text would would become wider than it's drawing area
[CHANGED] massive code cleanup for optimization and
[CHANGED] frames can now be parent to other objects
[CHANGED] textinput:RunBlink() to textinput:UpdateIndicator()
[CHANGED] textinput:GetBlinkerVisisbility() to textinput:GetIndicatorVisisbility()
[CHANGED] textinput:MoveBlinker(num, exact) to textinput:MoveIndicator(num, exact)
[CHANGED] scrollbars now only autoscroll when their list's item width/height is greater thant their previous list's previous item width/height
[CHANGED] cleaned up the code for the default skins
[CHANGED] the text input object's text is no longer drawn internally by the object and should now be draw within the object's skin drawing function
[CHANGED] the column list row object's text is no longer drawn internally by the object and should now be draw within the object's skin drawing function
[REMOVED] textinput:SetTextColor(color)
[REMOVED] columnlistrow:SetTextColor()
================================================
Version 0.9.3.1 - Alpha (Spetember 2 - 2012)
================================================
[ADDED] numpad enter key support for textinput.OnEnter
[FIXED] duplicate progressbar:GetCompleted() in progressbar.lua
[CHANGED] textinput.OnTextEnterd to textinput.OnTextChanged
[CHANGED] textinput.OnTextChanged is now also called when the backspace key is pressed
================================================
Version 0.9.3 - Alpha (Spetember 1 - 2012)
================================================
[ADDED] a new base method: GetParents()
[ADDED] a new base method: IsTopInternal()
[ADDED] a new base method: IsInternal()
[ADDED] a new base method: GetType()
[ADDED] a new checkbox method: GetFont()
[ADDED] a new checkbox method: GetBoxSize()
[ADDED] a new checkbox method: GetBoxWidth()
[ADDED] a new checkbox method: GetBoxHeight()
[ADDED] a new image method: GetImage()
[ADDED] a new image method: GetColor()
[ADDED] a new progressbar method: GetCompleted()
[ADDED] a new tabs method: GetTabNumber()
[ADDED] a new text method: GetLines()
[ADDED] a new text input method: SetLimit(limit)
[ADDED] a new text input method: SetUsable(usable)
[ADDED] a new text input method: SetUnusable(unusable)
[ADDED] a new text input method: Clear()
[ADDED] a new text input method: GetText()
[ADDED] support for line breaks in the text object (please refer to the wiki on how to format your text with line breaks)
[ADDED] more information to the debug overlay
[FIXED] tooltips and multichoice lists not functioning properly when a frame was modaled
[FIXED] the text object not moving it's base parent to the top when clicked if it's base parent was a frame
[FIXED] the list object not scrolling via the mouse wheel due to certain collision detection issues
[FIXED] tooltips flickering when in a hover state
[FIXED] slider calculation errors
[FIXED] skin.DrawRepeatingImage creating a new image every frame
[FIXED] checkbox text not scrolling properly when in a list
[FIXED] the collapsible category's object not scrolling properly when in a list
[FIXED] skins not assuming the drawing functions of the default skins if drawing functions in the active skin were missing
[FIXED] some objects not being removed
[FIXED] sliders not scrolling properly when in a list
[CHANGED] various code for a small cleanup
[CHANGED] tooltips from being children of the base object to internals of the base object
[CHANGED] tooltips from never being removed to being removed when their assigned object is removed
[CHANGED] tooltips are now not able to be assigned to the base object (this would cause an error due to the way the tooltip currently functions)
[CHANGED] the text object now positions it's text when SetText is called instead of positioning it's text every frame
[CHANGED] slider:SetMax(max), slider:SetMin(min) and slider:SetMinMax(min, max) now adjust the slider's value if the slider's value is out of the range specified
[CHANGED] loveframes.Create(data, parent) now activates an error screen if the object specified is invalid
================================================
Version 0.9.2.5 - Alpha (June 1 - 2012)
================================================
[FIXED] the text object not drawing numbers in certain situations
[FIXED] a typo in the changelog
================================================
Version 0.9.2.4 - Alpha (May 29 - 2012)
================================================
[FIXED] the SetSkin(skin) method causing a stack overflow
================================================
Version 0.9.2.3 - Alpha (May 27 - 2012)
================================================
[FIXED] imagebutton.OnClick not working
[FIXED] text being added into the text input object at incorrect positions when the value of textinput.blinknum was 0
[FIXED] a bug that would cause an error when running SetVisible on a frame object when the value of frame.showclose was true
================================================
Version 0.9.2.2 - Alpha (May 23 - 2012)
================================================
[FIXED] vertical slider value direction (top is now max value and bottom is 0)
[FIXED] text flashing in the text input object when moving the text blinker to the right
[FIXED] text blinker in the text input object not appearing in certain situations
================================================
Version 0.9.2 - Alpha (May 22 - 2012)
================================================
[ADDED] a new slider method: SetButtonSize(width, height)
[ADDED] a new slider method: GetButtonSize()
[ADDED] a new slider method: SetSlideType(slidetype)
[ADDED] a new slider button method: MoveToY(y)
[REMOVED] slider method: SetButtonYCenter(y)
[REMOVED] slider method: GetButtonYCenter()
[FIXED] the column list row object not setting it's text's font to it's font
[FIXED] a small graient error in the default skins
[FIXED] an error that caused tab buttons to be overscrolled with the middle mouse button
[FIXED] the scroll area object not moving it's base parent to the top when clicked (only in situatuions where it'sbase parent was a frame)
[CHANGED] sliders no longer use ycenter for button positioning
[CHANGED] slider functionality, sliders can now be horizontal or vertical (use slider:SetSlideType("horizontal" or "vertical"))
[CHANGED] lots of code for optimization and general cleanliness
[CHANGED] a few minor things in the default skins
[CHANGED] scrollbar hover behavior when being moved via it's scroll area being clicked (will no longer auto hover when it reaches the mouse position)
================================================
Version 0.9.1.6 - Alpha (May 17 - 2012)
================================================
[ADDED] a new column list method: Clear()
[ADDED] a new column list method: SetAutoScroll(bool)
[ADDED] "autoscroll" property for the column list object
[ADDED] a new column list area method: Clear()
[ADDED] a new skin function: DrawOverTextInput()
[FIXED] not being able to move the column list object's scrollbar by clicking on it's scroll area
[FIXED] column list rows color indexs becoming disorderd when the list was sorted via a column list header
[CHANGED] a few minor things in the default skins
================================================
Version 0.9.1.5 - Alpha (May 16 - 2012)
================================================
[FIXED] a bug that caused scrollbars to always autoscroll
================================================
Version 0.9.1.4 - Alpha (May 16 - 2012)
================================================
[FIXED] list:SetAutoScroll() not working
================================================
Version 0.9.1.3 - Alpha (May 14 - 2012)
================================================
[ADDED] modal system for frames
[ADDED] a new frame method: SetModal(bool)
[ADDED] a new frame method: GetModal()
[ADDED] a new frame method: SetVisible(bool) - this override is part of a frame bug fix
[ADDED] "showclose" property for the frame object
[ADDED] a new internal object: modal background
[ADDED] a new base method: IsActive()
[ADDED] a new base method: CenterX()
[ADDED] a new base method: CenterY()
[ADDED] a new skin function: DrawOverColumList()
[FIXED] a bug that made the frame's close button become visisble when the frame was made visible and show close button was set to false
================================================
Version 0.9.1.2 - Alpha (May 12 - 2012)
================================================
[ADDED] a system for preventing objects from being hovered over when another object is being pressed or is "down"
[ADDED] "down" property for the checkbox object
[ADDED] "down" property for the collapsible category object
[ADDED] a new method for the tabs object: SetToolTipFont(font)
[FIXED] list:GetScrollBar() crashing when the list had no scroll bar
[FIXED] not being able to move the text input blinker to the front or end of the it's text by clicking on it's whitespace
[FIXED] the multichoice row object being "down" when mouse buttons other than the left mouse button were pressed
[CHANGED] collapsible category opening and closing system (will now only open or close when "down")
================================================
Version 0.9.1 - Alpha (May 8 - 2012)
================================================
[ADDED] a new object: image button
[ADDED] a new skin: Orange
[ADDED] a new column list row method: SetTextPos(x, y)
[ADDED] a new column list row method: SetFont(font)
[ADDED] a new column list row method: GetFont()
[ADDED] a new column list row method: GetColorIndex()
[ADDED] a new column list row method: SetTextColor(color)
[ADDED] a new debug function: SkinSelector()
[ADDED] license.txt
[ADDED] changelog.txt
[CHANGED] the name of the default skin to Blue
[CHANGED] the drawing system of the image object, the image object will now draw it's image from it's skin function instead of it's internal drawing function
[CHANGED] argument type for adding an image to a tab in tabs:AddTab(), the image argument can now be either an image object or a string containg the path to an image
[CHANGED] the look of the debug overlay
[CHANGED] some of the code within the default skins to improve performance (as suggested by kikito)
[REMOVED] license.html
[REMOVED] loveframes.graphics and graphics.lua
================================================
Version 0.9 - Alpha (May 5 - 2012)
================================================
================================================
Version 0.9.5 - Alpha (February 11 - 2013)
================================================
[ADDED] state system
[ADDED] a new base method: SetState(name)
[ADDED] a new base method: GetState()
[ADDED] a new list method: EnableHorizontalStacking(bool)
[ADDED] a new list method: GetHorizontalStacking()
[ADDED] a new list method: SetDTScrolling(bool)
[ADDED] a new list method: GetDTScrolling()
[ADDED] a new image method: GetImageSize()
[ADDED] a new image method: GetImageWidth()
[ADDED] a new image method: GetImageHeight()
[ADDED] a new imagebutton method: GetImageSize()
[ADDED] a new imagebutton method: GetImageWidth()
[ADDED] a new imagebutton method: GetImageHeight()
[ADDED] a new tabs method: RemoveTab(id)
[ADDED] a new tabs method: SetButtonScrollAmount(amount)
[ADDED] a new tabs method: GetButtonScrollAmount()
[ADDED] a new tabs method: SetMouseWheelScrollAmount(amount)
[ADDED] a new tabs method: GetMouseWheelScrollAmount()
[ADDED] a new tabs method: SetDTScrolling(bool)
[ADDED] a new tabs method: GetDTScrolling()
[ADDED] a new columlist method: SetDTScrolling(bool)
[ADDED] a new columlist method: GetDTScrolling()
[ADDED] a new multichoice method: SetDTScrolling(bool)
[ADDED] a new multichoice method: GetDTScrolling()
[ADDED] a new base library function: loveframes.SetState(name)
[ADDED] a new base library function: loveframes.GetState()
[ADDED] a new object: numberbox
[ADDED] support for horizontal stacking of list object items when the list object's display mode is set to vertical
[FIXED] an error that would occur when providing a number as the text argument for textinput:SetText(text)
[FIXED] default skin images becoming distorted at certain positions on the screen
[FIXED] being able to clear a textinput's text by pressing an unusable key while all of the object's text was selected
[FIXED] several typos in the changelog
[CHANGED] the SetColor method for the image object now checks for four arguments (r, g, b, a) instead of one (table)
[CHANGED] major code cleanup for the default skins
[CHANGED] list:RemoveItem now accepts either an object or a number as an argument
[CHANGED] miscellaneous changes/improvements to various sections of code
[CHANGED] the images of the default skins
================================================
Version 0.9.4.15 - Alpha (January 5 - 2013)
================================================
[ADDED] a new base method: GetInternals()
[ADDED] a new tooltip method: SetFollowObject(bool)
================================================
Version 0.9.4.14 - Alpha (January 4 - 2013)
================================================
[ADDED] a new util library function: loveframes.util.CheckForUpdates() (note: this function is meant to be used by the developer and is never called internally by Love Frames)
[ADDED] a new callback for the tabbutton object: OnOpened(object)
[ADDED] a new callback for the tabbutton object: OnClosed(object)
[CHANGED] tabs:AddTab(name, object, tip, image) now accepts two new optional arguments for tabbutton callbacks (ex: tabs:AddTab(name, object, tip, image, onopened, onclosed))
================================================
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)
================================================
[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)
================================================
[ADDED] a new textinput method: SetAutoScroll(bool)
[ADDED] a new textinput method: GetAutoScroll()
[FIXED] a couple of typos in the changelog
[FIXED] a sliderbutton calculation error that caused the sliderbutton object to flash while moving the cursor out of it's bounding box while it was down
[CHANGED] cleaned up a lot of code
[CHANGED] the text object's shadow color now defaults to black
================================================
Version 0.9.4.10 - Alpha (December 26 - 2012)
================================================
[FIXED] registration errors for the new default skins
================================================
Version 0.9.4.9 - Alpha (December 26 - 2012)
================================================
[ADDED] a new default skin: Blue (basic)
[ADDED] a new default skin: Orange (basic)
[ADDED] a new skins library function: loveframes.skins.GetAvailable()
[CHANGED] the license from CC BY-SA 3.0 to CC BY 3.0
[CHANGED] made minor improvements to the default skins
================================================
Version 0.9.4.8 - Alpha (December 24 - 2012)
================================================
[ADDED] a new text method: SetShadow(bool)
[ADDED] a new text method: GetShadow()
[ADDED] a new text method: SetShadowOffsets(offsetx, offsety)
[ADDED] a new text method: GetShadowOffsets()
[ADDED] a new text method: SetShadowColor(r, g, b, a)
[ADDED] a new text method: GetShadowColor()
[ADDED] a new columnlist method: SetColumnHeight(height)
[FIXED] templates not being applied to objects
[CHANGED] the columnlistarea object now has better sorting
[CHANGED] the frame object no longer sets the size of it's close button
================================================
Version 0.9.4.7 - Alpha (December 19 - 2012)
================================================
[FIXED] textinput:SetFocus(focus) not working properly
[CHANGED] the tooltip object is now positionable via the standard positioning methods when not set to follow the cursor
================================================
Version 0.9.4.6 - Alpha (December 10 - 2012)
================================================
[ADDED] a new textinput event callback: OnFocusGained(object)
[ADDED] a new textinput event callback: OnFocusLost(object)
[FIXED] the textinput object accepting input from the tab and delete keys when object.editable was set to false
[CHANGED] all "." are now replaced with "/" in loveframes.config["DIRECTORY"] after all inernal Love Frames libraries have been loaded (this is to prevent filesystem errors)
[REMOVED] loveframes.util.TrimString(string)
================================================
Version 0.9.4.5 - Alpha (November 28 - 2012)
================================================
[FIXED] text inputs not losing focus in certain situations
================================================
Version 0.9.4.4 - Alpha (November 24 - 2012)
================================================
[ADDED] a new text input method: SetButtonScrollAmount(amount)
[ADDED] a new text input method: GetButtonScrollAmount()
[ADDED] a new text input method: SetMouseWheelScrollAmount(amount)
[ADDED] a new text input method: GetMouseWheelScrollAmount()
[ADDED] a new multichoice method: SetButtonScrollAmount(amount)
[ADDED] a new multichoice method: GetButtonScrollAmount()
[ADDED] a new multichoice method: SetMouseWheelScrollAmount(amount)
[ADDED] a new multichoice method: GetMouseWheelScrollAmount()
[ADDED] a new column list method: SetButtonScrollAmount(amount)
[ADDED] a new column list method: GetButtonScrollAmount()
[ADDED] a new column list method: SetMouseWheelScrollAmount(amount)
[ADDED] a new column list method: GetMouseWheelScrollAmount()
[ADDED] a new frame method: SetParentLocked(bool)
[ADDED] a new frame method: GetParentLocked()
[ADDED] a new base method: CenterWithinArea(x, y, width, height)
[ADDED] a new library function: loveframes.NewObject(id, name, inherit_from_base)
[FIXED] an error that would occur when clicking a scroll button on a multiline text input or a multichoice list
[FIXED] a button calculation error that caused the button object to flash while moving the cursor out of it's bounding box while it was down
[FIXED] several errors that could occur when a collapsible category did not have an object
[FIXED] the value of the slider object becoming -0 in certain situations
[CHANGED] the close button object is no longer positioned internally by the frame object and should now be positioned by it's skin drawing function
[CHANGED] all Love Frames objects are now stored within loveframes.objects
[CHANGED] frames are now draggable when parented to any object
[CHANGED] the look of the debug overlay
================================================
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)
================================================
[ADDED] a new text object method: SetIgnoreNewlines(bool)
[ADDED] a new text object method: GetIgnoreNewlines()
[ADDED] a new text image method: SetOrientation(orientation)
[ADDED] a new text image method: GetOrientation()
[ADDED] a new text image method: SetScaleX(scalex)
[ADDED] a new text image method: GetScaleX()
[ADDED] a new text image method: SetScaleY(scaley)
[ADDED] a new text image method: GetScaleY()
[ADDED] a new text image method: SetScale(scalex, scaley)
[ADDED] a new text image method: GetScale()
[ADDED] a new text image method: SetOffsetX(x)
[ADDED] a new text image method: GetOffsetX()
[ADDED] a new text image method: SetOffsetY(y)
[ADDED] a new text image method: GetOffsetY()
[ADDED] a new text image method: SetOffset(x, y)
[ADDED] a new text image method: GetOffset()
[ADDED] a new text image method: SetShearX(x)
[ADDED] a new text image method: GetShearX()
[ADDED] a new text image method: SetShearY(y)
[ADDED] a new text image method: GetShearY()
[ADDED] a new text image method: SetShear(x, y)
[ADDED] a new text image method: GetShear()
[FIXED] an error that occurred after pressing enter on a multiline text input while all of it's text was selected
[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 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
================================================
Version 0.9.4.1 - Alpha (October 25 - 2012)
================================================
[ADDED] support for using the delete key in text input objects
[FIXED] textinupt:GetText() only returning the first line of a multiline text input
[FIXED] an error that occurred when clicking a multiline text input object after setting the object's text to an empty string with textinput:SetText("")
[FIXED] incorrect positioning of the text input object's indicator when using the left or right arrow keys to move the object's indicator to a different line
[FIXED] the text input object not creating a new line correctly in certain situations
[CHANGED] textinput:GetText() now returns the object's text with line breaks
================================================
Version 0.9.4 - Alpha (October 22 - 2012)
================================================
[ADDED] a new base method: SetDrawOrder()
[ADDED] a new base method: GetDrawOrder()
[ADDED] a new text method: GetFormattedText()
[ADDED] a new text input method: SetEditable(bool)
[ADDED] a new text input method: GetEditable()
[ADDED] a new text input method: GetUsable()
[ADDED] a new text input method: GetUnusable()
[ADDED] a new system for creating and applying templates to objects
[FIXED] a few incorrect entries in the changelog and added a few entries that were meant to be in the last upadte's changelog
[FIXED] an error that occurred when clicking on a frame that was parented to another frame
[FIXED] frames not being positioned properly if they were parented to another object
[FIXED] modal background object not drawing over umodaled objects in certain situations
[FIXED] an error that would occur when a multichoice list object would become scrollable
[FIXED] an error that would occur when a the column list object had no columns
[FIXED] multichoice object not positioning itself properly if it's parent was the base object
[CHANGED] text:GetText() now returns a string of the object's text
[CHANGED] parented frames can no longer be modaled
================================================
Version 0.9.3.2 - Alpha (Spetember 29 - 2012)
================================================
[ADDED] a new base method: SetDrawOrder()
[ADDED] a new text input method: SetMultiline(bool)
[ADDED] a new text input method: GetVerticalScrollBody()
[ADDED] a new text input method: GetHorizontalScrollBody()
[ADDED] a new text input method: SetText(text)
[ADDED] a new text input method: HasVerticalScrollBar()
[ADDED] a new text input method: HasHorizontalScrollBar()
[ADDED] a new text input method: GetFont()
[ADDED] a new text input method: GetLineNumbersPanel()
[ADDED] a new text input method: GetMultiline()
[ADDED] a new text input method: GetTextX()
[ADDED] a new text input method: GetTextY()
[ADDED] a new text input method: IsAllTextSelected()
[ADDED] a new text input method: GetLines()
[ADDED] a new text input method: GetOffsetX()
[ADDED] a new text input method: GetOffsetY()
[ADDED] a new text input method: GetIndicatorX()
[ADDED] a new text input method: GetIndicatorY()
[ADDED] a new text input method: SetLineNumbersEnabled(enabled)
[ADDED] a new text input method: GetLineNumbersEnabled()
[ADDED] a new text input method: GetItemWidth()
[ADDED] a new text input method: GetItemHeight()
[ADDED] a new text input method: SetTabReplacement(tabreplacement)
[ADDED] a new text input method: GetTabReplacement()
[ADDED] a new scroll area method: GetBarType()
[ADDED] a new scroll bar method: IsDragging()
[ADDED] a new scroll bar method: GetBarType()
[ADDED] a new scroll button method: GetScrollType()
[ADDED] a new tab button method: GetText()
[ADDED] a new tab button method: GetImage()
[ADDED] a new tab button method: GetTabNumber()
[ADDED] a new column list header method: GetName()
[ADDED] a new column list row method: GetColumnData()
[ADDED] a new multichoice method: SetText(text)
[ADDED] a new multichoice method: GetText()
[ADDED] a new multichoice row method: GetText()
[ADDED] a new progressbar method: GetBarWidth()
[ADDED] a new internal object: linenumberspanel
[ADDED] multiline support for the text input object
[ADDED] ability to select all text within a text input
[FIXED] progressbar object not positioning itself properly if it's parent was the base object
[FIXED] a typo in the syntax of loveframes.util.SplitString (was "SplitSring", changed to "SplitString")
[FIXED] the tooltip object not disappearing if it was visible when it's object's visibility was changed to false
[FIXED] the text input object's x offset not being adjusted initially when the width of it's text would would become wider than it's drawing area
[CHANGED] massive code cleanup for optimization and
[CHANGED] frames can now be parent to other objects
[CHANGED] textinput:RunBlink() to textinput:UpdateIndicator()
[CHANGED] textinput:GetBlinkerVisisbility() to textinput:GetIndicatorVisisbility()
[CHANGED] textinput:MoveBlinker(num, exact) to textinput:MoveIndicator(num, exact)
[CHANGED] scrollbars now only autoscroll when their list's item width/height is greater than their previous list's previous item width/height
[CHANGED] cleaned up the code for the default skins
[CHANGED] the text input object's text is no longer drawn internally by the object and should now be draw within the object's skin drawing function
[CHANGED] the column list row object's text is no longer drawn internally by the object and should now be draw within the object's skin drawing function
[REMOVED] textinput:SetTextColor(color)
[REMOVED] columnlistrow:SetTextColor()
================================================
Version 0.9.3.1 - Alpha (Spetember 2 - 2012)
================================================
[ADDED] numpad enter key support for textinput.OnEnter
[FIXED] duplicate progressbar:GetCompleted() in progressbar.lua
[CHANGED] textinput.OnTextEnterd to textinput.OnTextChanged
[CHANGED] textinput.OnTextChanged is now also called when the backspace key is pressed
================================================
Version 0.9.3 - Alpha (Spetember 1 - 2012)
================================================
[ADDED] a new base method: GetParents()
[ADDED] a new base method: IsTopInternal()
[ADDED] a new base method: IsInternal()
[ADDED] a new base method: GetType()
[ADDED] a new checkbox method: GetFont()
[ADDED] a new checkbox method: GetBoxSize()
[ADDED] a new checkbox method: GetBoxWidth()
[ADDED] a new checkbox method: GetBoxHeight()
[ADDED] a new image method: GetImage()
[ADDED] a new image method: GetColor()
[ADDED] a new progressbar method: GetCompleted()
[ADDED] a new tabs method: GetTabNumber()
[ADDED] a new text method: GetLines()
[ADDED] a new text input method: SetLimit(limit)
[ADDED] a new text input method: SetUsable(usable)
[ADDED] a new text input method: SetUnusable(unusable)
[ADDED] a new text input method: Clear()
[ADDED] a new text input method: GetText()
[ADDED] support for line breaks in the text object (please refer to the wiki on how to format your text with line breaks)
[ADDED] more information to the debug overlay
[FIXED] tooltips and multichoice lists not functioning properly when a frame was modaled
[FIXED] the text object not moving it's base parent to the top when clicked if it's base parent was a frame
[FIXED] the list object not scrolling via the mouse wheel due to certain collision detection issues
[FIXED] tooltips flickering when in a hover state
[FIXED] slider calculation errors
[FIXED] skin.DrawRepeatingImage creating a new image every frame
[FIXED] checkbox text not scrolling properly when in a list
[FIXED] the collapsible category's object not scrolling properly when in a list
[FIXED] skins not assuming the drawing functions of the default skins if drawing functions in the active skin were missing
[FIXED] some objects not being removed
[FIXED] sliders not scrolling properly when in a list
[CHANGED] various code for a small cleanup
[CHANGED] tooltips from being children of the base object to internals of the base object
[CHANGED] tooltips from never being removed to being removed when their assigned object is removed
[CHANGED] tooltips are now not able to be assigned to the base object (this would cause an error due to the way the tooltip currently functions)
[CHANGED] the text object now positions it's text when SetText is called instead of positioning it's text every frame
[CHANGED] slider:SetMax(max), slider:SetMin(min) and slider:SetMinMax(min, max) now adjust the slider's value if the slider's value is out of the range specified
[CHANGED] loveframes.Create(data, parent) now activates an error screen if the object specified is invalid
================================================
Version 0.9.2.5 - Alpha (June 1 - 2012)
================================================
[FIXED] the text object not drawing numbers in certain situations
[FIXED] a typo in the changelog
================================================
Version 0.9.2.4 - Alpha (May 29 - 2012)
================================================
[FIXED] the SetSkin(skin) method causing a stack overflow
================================================
Version 0.9.2.3 - Alpha (May 27 - 2012)
================================================
[FIXED] imagebutton.OnClick not working
[FIXED] text being added into the text input object at incorrect positions when the value of textinput.blinknum was 0
[FIXED] a bug that would cause an error when running SetVisible on a frame object when the value of frame.showclose was true
================================================
Version 0.9.2.2 - Alpha (May 23 - 2012)
================================================
[FIXED] vertical slider value direction (top is now max value and bottom is 0)
[FIXED] text flashing in the text input object when moving the text blinker to the right
[FIXED] text blinker in the text input object not appearing in certain situations
================================================
Version 0.9.2 - Alpha (May 22 - 2012)
================================================
[ADDED] a new slider method: SetButtonSize(width, height)
[ADDED] a new slider method: GetButtonSize()
[ADDED] a new slider method: SetSlideType(slidetype)
[ADDED] a new slider button method: MoveToY(y)
[REMOVED] slider method: SetButtonYCenter(y)
[REMOVED] slider method: GetButtonYCenter()
[FIXED] the column list row object not setting it's text's font to it's font
[FIXED] a small gradient error in the default skins
[FIXED] an error that caused tab buttons to be over-scrolled with the middle mouse button
[FIXED] the scroll area object not moving it's base parent to the top when clicked (only in situations where it's base parent was a frame)
[CHANGED] sliders no longer use ycenter for button positioning
[CHANGED] slider functionality, sliders can now be horizontal or vertical (use slider:SetSlideType("horizontal" or "vertical"))
[CHANGED] lots of code for optimization and general cleanliness
[CHANGED] a few minor things in the default skins
[CHANGED] scrollbar hover behavior when being moved via it's scroll area being clicked (will no longer auto hover when it reaches the mouse position)
================================================
Version 0.9.1.6 - Alpha (May 17 - 2012)
================================================
[ADDED] a new column list method: Clear()
[ADDED] a new column list method: SetAutoScroll(bool)
[ADDED] "autoscroll" property for the column list object
[ADDED] a new column list area method: Clear()
[ADDED] a new skin function: DrawOverTextInput()
[FIXED] not being able to move the column list object's scrollbar by clicking on it's scroll area
[FIXED] column list rows color indexes becoming disordered when the list was sorted via a column list header
[CHANGED] a few minor things in the default skins
================================================
Version 0.9.1.5 - Alpha (May 16 - 2012)
================================================
[FIXED] a bug that caused scrollbars to always autoscroll
================================================
Version 0.9.1.4 - Alpha (May 16 - 2012)
================================================
[FIXED] list:SetAutoScroll() not working
================================================
Version 0.9.1.3 - Alpha (May 14 - 2012)
================================================
[ADDED] modal system for frames
[ADDED] a new frame method: SetModal(bool)
[ADDED] a new frame method: GetModal()
[ADDED] a new frame method: SetVisible(bool) - this override is part of a frame bug fix
[ADDED] "showclose" property for the frame object
[ADDED] a new internal object: modal background
[ADDED] a new base method: IsActive()
[ADDED] a new base method: CenterX()
[ADDED] a new base method: CenterY()
[ADDED] a new skin function: DrawOverColumList()
[FIXED] a bug that made the frame's close button become visible when the frame was made visible and show close button was set to false
================================================
Version 0.9.1.2 - Alpha (May 12 - 2012)
================================================
[ADDED] a system for preventing objects from being hovered over when another object is being pressed or is "down"
[ADDED] "down" property for the checkbox object
[ADDED] "down" property for the collapsible category object
[ADDED] a new method for the tabs object: SetToolTipFont(font)
[FIXED] list:GetScrollBar() crashing when the list had no scroll bar
[FIXED] not being able to move the text input blinker to the front or end of the it's text by clicking on it's whitespace
[FIXED] the multichoice row object being "down" when mouse buttons other than the left mouse button were pressed
[CHANGED] collapsible category opening and closing system (will now only open or close when "down")
================================================
Version 0.9.1 - Alpha (May 8 - 2012)
================================================
[ADDED] a new object: image button
[ADDED] a new skin: Orange
[ADDED] a new column list row method: SetTextPos(x, y)
[ADDED] a new column list row method: SetFont(font)
[ADDED] a new column list row method: GetFont()
[ADDED] a new column list row method: GetColorIndex()
[ADDED] a new column list row method: SetTextColor(color)
[ADDED] a new debug function: SkinSelector()
[ADDED] license.txt
[ADDED] changelog.txt
[CHANGED] the name of the default skin to Blue
[CHANGED] the drawing system of the image object, the image object will now draw it's image from it's skin function instead of it's internal drawing function
[CHANGED] argument type for adding an image to a tab in tabs:AddTab(), the image argument can now be either an image object or a string containg the path to an image
[CHANGED] the look of the debug overlay
[CHANGED] some of the code within the default skins to improve performance (as suggested by kikito)
[REMOVED] license.html
[REMOVED] loveframes.graphics and graphics.lua
================================================
Version 0.9 - Alpha (May 5 - 2012)
================================================
Initial commit

1590
debug.lua

File diff suppressed because it is too large Load Diff

592
init.lua
View File

@ -1,286 +1,308 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- central library table
loveframes = {}
-- library info
loveframes.info = {}
loveframes.info.author = "Kenny Shields"
loveframes.info.version = "0.9.4.15"
loveframes.info.stage = "Alpha"
-- library configurations
loveframes.config = {}
loveframes.config["DIRECTORY"] = ""
loveframes.config["DEFAULTSKIN"] = "Blue"
loveframes.config["ACTIVESKIN"] = "Blue"
loveframes.config["INDEXSKINIMAGES"] = true
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 = {}
--[[---------------------------------------------------------
- func: load()
- desc: loads the library
--]]---------------------------------------------------------
function loveframes.load()
-- install directory of the library
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")
-- replace all "." with "/" in the directory setting
dir = dir:gsub("%.", "/")
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()
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates all library objects
--]]---------------------------------------------------------
function loveframes.update(dt)
local base = loveframes.base
base:update(dt)
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws all library objects
--]]---------------------------------------------------------
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
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function loveframes.mousepressed(x, y, button)
local base = loveframes.base
base:mousepressed(x, y, button)
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function loveframes.mousereleased(x, y, button)
local base = loveframes.base
base:mousereleased(x, y, button)
-- reset the hover object
if button == "l" then
loveframes.hoverobject = false
loveframes.selectedobject = false
end
end
--[[---------------------------------------------------------
- func: keypressed(key)
- desc: called when the player presses a key
--]]---------------------------------------------------------
function loveframes.keypressed(key, unicode)
local base = loveframes.base
base:keypressed(key, unicode)
end
--[[---------------------------------------------------------
- func: keyreleased(key)
- desc: called when the player releases a key
--]]---------------------------------------------------------
function loveframes.keyreleased(key)
local base = loveframes.base
base:keyreleased(key)
end
--[[---------------------------------------------------------
- func: Create(type, parent)
- desc: creates a new object or multiple new objects
(based on the method used) and returns said
object or objects for further manipulation
--]]---------------------------------------------------------
function loveframes.Create(data, parent)
if type(data) == "string" then
local objects = loveframes.objects
local object = objects[data]
if not object then
loveframes.util.Error("Error creating object: Invalid object '" ..data.. "'.")
end
-- create the object
local newobject = object:new()
-- apply template properties to the object
loveframes.templates.ApplyToObject(newobject)
-- if the object is a tooltip, return it and go no further
if data == "tooltip" then
return newobject
end
-- remove the object if it is an internal
if newobject.internal then
newobject:Remove()
return
end
-- parent the new object by default to the base gui object
newobject.parent = loveframes.base
table.insert(loveframes.base.children, newobject)
-- if the parent argument is not nil, make that argument the object's new parent
if parent then
newobject:SetParent(parent)
end
-- return the object for further manipulation
return newobject
elseif type(data) == "table" then
-- table for creation of multiple objects
local objects = {}
-- this function reads a table that contains a layout of object properties and then
-- creates objects based on those properties
local function CreateObjects(t, o, c)
local child = c or false
for k, v in pairs(t) do
-- current default object
local object = _G[v.type]:new()
-- indert the object into the table of objects being created
table.insert(objects, object)
-- parent the new object by default to the base gui object
object.parent = loveframes.base
table.insert(loveframes.base.children, object)
if o then
object:SetParent(o)
end
-- loop through the current layout table and assign the properties found
-- to the current object
for i, j in pairs(v) do
if i ~= "children" and i ~= "func" then
if child == true then
if i == "x" then
object["staticx"] = j
elseif i == "y" then
object["staticy"] = j
else
object[i] = j
end
else
object[i] = j
end
elseif i == "children" then
CreateObjects(j, object, true)
end
end
if v.func then
v.func(object)
end
end
end
-- create the objects
CreateObjects(data)
return objects
end
end
--[[---------------------------------------------------------
- func: NewObject(id, name, inherit_from_base)
- desc: creates a new object
--]]---------------------------------------------------------
function loveframes.NewObject(id, name, inherit_from_base)
local objects = loveframes.objects
local object = false
if inherit_from_base then
local base = objects["base"]
object = class(name, base)
objects[id] = object
else
object = class(name)
objects[id] = object
end
return object
end
-- load the library
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- central library table
loveframes = {}
-- library info
loveframes.info = {}
loveframes.info.author = "Kenny Shields"
loveframes.info.version = "0.9.5"
loveframes.info.stage = "Alpha"
-- library configurations
loveframes.config = {}
loveframes.config["DIRECTORY"] = ""
loveframes.config["DEFAULTSKIN"] = "Blue"
loveframes.config["ACTIVESKIN"] = "Blue"
loveframes.config["INDEXSKINIMAGES"] = true
loveframes.config["DEBUG"] = false
-- misc library vars
loveframes.state = "none"
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()
- desc: loads the library
--]]---------------------------------------------------------
function loveframes.load()
-- install directory of the library
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")
-- replace all "." with "/" in the directory setting
dir = dir:gsub("%.", "/")
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()
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates all library objects
--]]---------------------------------------------------------
function loveframes.update(dt)
local base = loveframes.base
base:update(dt)
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws all library objects
--]]---------------------------------------------------------
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
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function loveframes.mousepressed(x, y, button)
local base = loveframes.base
base:mousepressed(x, y, button)
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function loveframes.mousereleased(x, y, button)
local base = loveframes.base
base:mousereleased(x, y, button)
-- reset the hover object
if button == "l" then
loveframes.hoverobject = false
loveframes.selectedobject = false
end
end
--[[---------------------------------------------------------
- func: keypressed(key)
- desc: called when the player presses a key
--]]---------------------------------------------------------
function loveframes.keypressed(key, unicode)
local base = loveframes.base
base:keypressed(key, unicode)
end
--[[---------------------------------------------------------
- func: keyreleased(key)
- desc: called when the player releases a key
--]]---------------------------------------------------------
function loveframes.keyreleased(key)
local base = loveframes.base
base:keyreleased(key)
end
--[[---------------------------------------------------------
- func: Create(type, parent)
- desc: creates a new object or multiple new objects
(based on the method used) and returns said
object or objects for further manipulation
--]]---------------------------------------------------------
function loveframes.Create(data, parent)
if type(data) == "string" then
local objects = loveframes.objects
local object = objects[data]
if not object then
loveframes.util.Error("Error creating object: Invalid object '" ..data.. "'.")
end
-- create the object
local newobject = object:new()
-- apply template properties to the object
loveframes.templates.ApplyToObject(newobject)
-- if the object is a tooltip, return it and go no further
if data == "tooltip" then
return newobject
end
-- remove the object if it is an internal
if newobject.internal then
newobject:Remove()
return
end
-- parent the new object by default to the base gui object
newobject.parent = loveframes.base
table.insert(loveframes.base.children, newobject)
-- if the parent argument is not nil, make that argument the object's new parent
if parent then
newobject:SetParent(parent)
end
-- return the object for further manipulation
return newobject
elseif type(data) == "table" then
-- table for creation of multiple objects
local objects = {}
-- this function reads a table that contains a layout of object properties and then
-- creates objects based on those properties
local function CreateObjects(t, o, c)
local child = c or false
for k, v in pairs(t) do
-- current default object
local object = _G[v.type]:new()
-- indert the object into the table of objects being created
table.insert(objects, object)
-- parent the new object by default to the base gui object
object.parent = loveframes.base
table.insert(loveframes.base.children, object)
if o then
object:SetParent(o)
end
-- loop through the current layout table and assign the properties found
-- to the current object
for i, j in pairs(v) do
if i ~= "children" and i ~= "func" then
if child == true then
if i == "x" then
object["staticx"] = j
elseif i == "y" then
object["staticy"] = j
else
object[i] = j
end
else
object[i] = j
end
elseif i == "children" then
CreateObjects(j, object, true)
end
end
if v.func then
v.func(object)
end
end
end
-- create the objects
CreateObjects(data)
return objects
end
end
--[[---------------------------------------------------------
- func: NewObject(id, name, inherit_from_base)
- desc: creates a new object
--]]---------------------------------------------------------
function loveframes.NewObject(id, name, inherit_from_base)
local objects = loveframes.objects
local object = false
if inherit_from_base then
local base = objects["base"]
object = class(name, base)
objects[id] = object
else
object = class(name)
objects[id] = object
end
return object
end
--[[---------------------------------------------------------
- func: SetState(name)
- desc: sets the current state
--]]---------------------------------------------------------
function loveframes.SetState(name)
loveframes.state = name
loveframes.base.state = name
end
--[[---------------------------------------------------------
- func: GetState()
- desc: gets the current state
--]]---------------------------------------------------------
function loveframes.GetState()
return loveframes.state
end
-- load the library
loveframes.load()

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- button class
@ -30,6 +30,13 @@ end
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
@ -77,6 +84,13 @@ end
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -109,6 +123,13 @@ end
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -134,6 +155,13 @@ end
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -158,27 +186,6 @@ function newobject:mousereleased(x, y, button)
end
--[[---------------------------------------------------------
- func: keypressed(key)
- desc: called when the player presses a key
--]]---------------------------------------------------------
function newobject:keypressed(key, unicode)
local visible = self.visible
if not visible then
return
end
local selectedobject = loveframes.selectedobject
local onclick = self.OnClick
if key == "return" and selectedobject == self then
onclick(self, 0, 0)
end
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text

View File

@ -1,375 +1,380 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- checkbox class
local newobject = loveframes.NewObject("checkbox", "loveframes_object_checkbox", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "checkbox"
self.width = 0
self.height = 0
self.boxwidth = 20
self.boxheight = 20
self.font = loveframes.basicfont
self.checked = false
self.lastvalue = false
self.internal = false
self.down = true
self.internals = {}
self.OnChanged = nil
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local hover = self.hover
local internals = self.internals
local boxwidth = self.boxwidth
local boxheight = self.boxheight
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
else
if loveframes.hoverobject == self then
self.down = true
end
end
if not self.down and loveframes.hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if internals[1] then
self.width = boxwidth + 5 + internals[1].width
if internals[1].height == boxheight then
self.height = boxheight
else
if internals[1].height > boxheight then
self.height = internals[1].height
else
self.height = boxheight
end
end
else
self.width = boxwidth
self.height = boxheight
end
for k, v in ipairs(internals) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawCheckBox or skins[defaultskin].DrawCheckBox
local draw = self.Draw
local internals = self.internals
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
for k, v in ipairs(internals) do
v:draw()
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local checked = self.checked
local onchanged = self.OnChanged
if hover and button == "l" then
if checked then
self.checked = false
else
self.checked = true
end
if onchanged then
onchanged(self)
end
end
end
--[[---------------------------------------------------------
- func: keypressed(key)
- desc: called when the player presses a key
--]]---------------------------------------------------------
function newobject:keypressed(key, unicode)
local checked = self.checked
local onchanged = self.OnChanged
local selectedobject = loveframes.selectedobject
if key == "return" and selectedobject == self then
if checked then
self.checked = false
else
self.checked = true
end
if onchanged then
onchanged(self)
end
end
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
local boxwidth = self.boxwidth
local boxheight = self.boxheight
if text ~= "" then
self.internals = {}
local textobject = loveframes.Create("text")
textobject:Remove()
textobject.parent = self
textobject.collide = false
textobject:SetFont(self.font)
textobject:SetText(text)
textobject.Update = function(object, dt)
if object.height > boxheight then
object:SetPos(boxwidth + 5, 0)
else
object:SetPos(boxwidth + 5, boxheight/2 - object.height/2)
end
end
table.insert(self.internals, textobject)
else
self.width = boxwidth
self.height = boxheight
self.internals = {}
end
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
local internals = self.internals
local text = internals[1]
if text then
return text.text
else
return false
end
end
--[[---------------------------------------------------------
- func: SetSize(width, height)
- desc: sets the object's size
--]]---------------------------------------------------------
function newobject:SetSize(width, height)
self.boxwidth = width
self.boxheight = height
end
--[[---------------------------------------------------------
- func: SetWidth(width)
- desc: sets the object's width
--]]---------------------------------------------------------
function newobject:SetWidth(width)
self.boxwidth = width
end
--[[---------------------------------------------------------
- func: SetHeight(height)
- desc: sets the object's height
--]]---------------------------------------------------------
function newobject:SetHeight(height)
self.boxheight = height
end
--[[---------------------------------------------------------
- func: SetChecked(bool)
- desc: sets whether the object is checked or not
--]]---------------------------------------------------------
function newobject:SetChecked(bool)
local onchanged = self.OnChanged
self.checked = bool
if onchanged then
onchanged(self)
end
end
--[[---------------------------------------------------------
- func: GetChecked()
- desc: gets whether the object is checked or not
--]]---------------------------------------------------------
function newobject:GetChecked()
return self.checked
end
--[[---------------------------------------------------------
- func: SetFont(font)
- desc: sets the font of the object's text
--]]---------------------------------------------------------
function newobject:SetFont(font)
local internals = self.internals
local text = internals[1]
self.font = font
if text then
text:SetFont(font)
end
end
--[[---------------------------------------------------------
- func: newobject:GetFont()
- desc: gets the font of the object's text
--]]---------------------------------------------------------
function newobject:GetFont()
return self.font
end
--[[---------------------------------------------------------
- func: newobject:GetBoxHeight()
- desc: gets the object's box size
--]]---------------------------------------------------------
function newobject:GetBoxSize()
return self.boxwidth, self.boxheight
end
--[[---------------------------------------------------------
- func: newobject:GetBoxWidth()
- desc: gets the object's box width
--]]---------------------------------------------------------
function newobject:GetBoxWidth()
return self.boxwidth
end
--[[---------------------------------------------------------
- func: newobject:GetBoxHeight()
- desc: gets the object's box height
--]]---------------------------------------------------------
function newobject:GetBoxHeight()
return self.boxheight
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- checkbox class
local newobject = loveframes.NewObject("checkbox", "loveframes_object_checkbox", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "checkbox"
self.width = 0
self.height = 0
self.boxwidth = 20
self.boxheight = 20
self.font = loveframes.basicfont
self.checked = false
self.lastvalue = false
self.internal = false
self.down = true
self.internals = {}
self.OnChanged = nil
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local hover = self.hover
local internals = self.internals
local boxwidth = self.boxwidth
local boxheight = self.boxheight
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
else
if loveframes.hoverobject == self then
self.down = true
end
end
if not self.down and loveframes.hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if internals[1] then
self.width = boxwidth + 5 + internals[1].width
if internals[1].height == boxheight then
self.height = boxheight
else
if internals[1].height > boxheight then
self.height = internals[1].height
else
self.height = boxheight
end
end
else
self.width = boxwidth
self.height = boxheight
end
for k, v in ipairs(internals) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawCheckBox or skins[defaultskin].DrawCheckBox
local draw = self.Draw
local internals = self.internals
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
for k, v in ipairs(internals) do
v:draw()
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local checked = self.checked
local onchanged = self.OnChanged
if hover and button == "l" then
if checked then
self.checked = false
else
self.checked = true
end
if onchanged then
onchanged(self)
end
end
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
local boxwidth = self.boxwidth
local boxheight = self.boxheight
if text ~= "" then
self.internals = {}
local textobject = loveframes.Create("text")
textobject:Remove()
textobject.parent = self
textobject.collide = false
textobject:SetFont(self.font)
textobject:SetText(text)
textobject.Update = function(object, dt)
if object.height > boxheight then
object:SetPos(boxwidth + 5, 0)
else
object:SetPos(boxwidth + 5, boxheight/2 - object.height/2)
end
end
table.insert(self.internals, textobject)
else
self.width = boxwidth
self.height = boxheight
self.internals = {}
end
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
local internals = self.internals
local text = internals[1]
if text then
return text.text
else
return false
end
end
--[[---------------------------------------------------------
- func: SetSize(width, height)
- desc: sets the object's size
--]]---------------------------------------------------------
function newobject:SetSize(width, height)
self.boxwidth = width
self.boxheight = height
end
--[[---------------------------------------------------------
- func: SetWidth(width)
- desc: sets the object's width
--]]---------------------------------------------------------
function newobject:SetWidth(width)
self.boxwidth = width
end
--[[---------------------------------------------------------
- func: SetHeight(height)
- desc: sets the object's height
--]]---------------------------------------------------------
function newobject:SetHeight(height)
self.boxheight = height
end
--[[---------------------------------------------------------
- func: SetChecked(bool)
- desc: sets whether the object is checked or not
--]]---------------------------------------------------------
function newobject:SetChecked(bool)
local onchanged = self.OnChanged
self.checked = bool
if onchanged then
onchanged(self)
end
end
--[[---------------------------------------------------------
- func: GetChecked()
- desc: gets whether the object is checked or not
--]]---------------------------------------------------------
function newobject:GetChecked()
return self.checked
end
--[[---------------------------------------------------------
- func: SetFont(font)
- desc: sets the font of the object's text
--]]---------------------------------------------------------
function newobject:SetFont(font)
local internals = self.internals
local text = internals[1]
self.font = font
if text then
text:SetFont(font)
end
end
--[[---------------------------------------------------------
- func: newobject:GetFont()
- desc: gets the font of the object's text
--]]---------------------------------------------------------
function newobject:GetFont()
return self.font
end
--[[---------------------------------------------------------
- func: newobject:GetBoxHeight()
- desc: gets the object's box size
--]]---------------------------------------------------------
function newobject:GetBoxSize()
return self.boxwidth, self.boxheight
end
--[[---------------------------------------------------------
- func: newobject:GetBoxWidth()
- desc: gets the object's box width
--]]---------------------------------------------------------
function newobject:GetBoxWidth()
return self.boxwidth
end
--[[---------------------------------------------------------
- func: newobject:GetBoxHeight()
- desc: gets the object's box height
--]]---------------------------------------------------------
function newobject:GetBoxHeight()
return self.boxheight
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- collapsiblecategory class
@ -32,6 +32,13 @@ end
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
@ -73,6 +80,13 @@ end
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -112,6 +126,13 @@ end
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -147,6 +168,13 @@ end
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -213,6 +241,7 @@ function newobject:SetObject(object)
object:Remove()
object.parent = self
object:SetState(self.state)
object:SetWidth(self.width - self.padding*2)
object:SetPos(self.padding, self.closedheight + self.padding)
table.insert(self.children, object)

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- columnlist class
@ -16,9 +16,10 @@ function newobject:initialize()
self.width = 300
self.height = 100
self.columnheight = 16
self.buttonscrollamount = 0.10
self.mousewheelscrollamount = 5
self.buttonscrollamount = 200
self.mousewheelscrollamount = 1000
self.autoscroll = false
self.dtscrolling = true
self.internal = false
self.children = {}
self.internals = {}
@ -36,6 +37,13 @@ end
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
@ -79,6 +87,13 @@ end
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -121,9 +136,16 @@ end
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -131,7 +153,7 @@ function newobject:mousepressed(x, y, button)
local children = self.children
local internals = self.internals
if hover == true and button == "l" then
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
@ -154,9 +176,16 @@ end
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -192,7 +221,7 @@ function newobject:AdjustColumns()
local x = 0
for k, v in ipairs(children) do
if bar == true then
if bar then
v:SetWidth(columnwidth)
else
v:SetWidth(columnwidth)
@ -417,4 +446,27 @@ function newobject:SetColumnHeight(height)
list:CalculateSize()
list:RedoLayout()
end
--[[---------------------------------------------------------
- func: SetDTScrolling(bool)
- desc: sets whether or not the object should use delta
time when scrolling
--]]---------------------------------------------------------
function newobject:SetDTScrolling(bool)
self.dtscrolling = bool
self.internals[1].dtscrolling = bool
end
--[[---------------------------------------------------------
- func: GetDTScrolling()
- desc: gets whether or not the object should use delta
time when scrolling
--]]---------------------------------------------------------
function newobject:GetDTScrolling()
return self.dtscrolling
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- frame class
@ -51,6 +51,13 @@ end
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
@ -173,6 +180,13 @@ end
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -215,7 +229,14 @@ end
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -267,6 +288,13 @@ end
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then

View File

@ -1,342 +1,398 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- progressbar class
local newobject = loveframes.NewObject("image", "loveframes_object_image", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "image"
self.width = 0
self.height = 0
self.orientation = 0
self.scalex = 1
self.scaley = 1
self.offsetx = 0
self.offsety = 0
self.shearx = 0
self.sheary = 0
self.internal = false
self.image = nil
self.imagecolor = nil
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawImage or skins[defaultskin].DrawImage
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: SetImage(image)
- desc: sets the object's image
--]]---------------------------------------------------------
function newobject:SetImage(image)
if type(image) == "string" then
self.image = love.graphics.newImage(image)
else
self.image = image
end
self.width = self.image:getWidth()
self.height = self.image:getHeight()
end
--[[---------------------------------------------------------
- func: GetImage()
- desc: gets the object's image
--]]---------------------------------------------------------
function newobject:GetImage()
return self.image
end
--[[---------------------------------------------------------
- func: SetColor(table)
- desc: sets the object's color
--]]---------------------------------------------------------
function newobject:SetColor(data)
self.imagecolor = data
end
--[[---------------------------------------------------------
- func: GetColor()
- desc: gets the object's color
--]]---------------------------------------------------------
function newobject:GetColor()
return self.imagecolor
end
--[[---------------------------------------------------------
- func: SetOrientation(orientation)
- desc: sets the object's orientation
--]]---------------------------------------------------------
function newobject:SetOrientation(orientation)
self.orientation = orientation
end
--[[---------------------------------------------------------
- func: GetOrientation()
- desc: gets the object's orientation
--]]---------------------------------------------------------
function newobject:GetOrientation()
return self.orientation
end
--[[---------------------------------------------------------
- func: SetScaleX(scalex)
- desc: sets the object's x scale
--]]---------------------------------------------------------
function newobject:SetScaleX(scalex)
self.scalex = scalex
end
--[[---------------------------------------------------------
- func: GetScaleX()
- desc: gets the object's x scale
--]]---------------------------------------------------------
function newobject:GetScaleX()
return self.scalex
end
--[[---------------------------------------------------------
- func: SetScaleY(scaley)
- desc: sets the object's y scale
--]]---------------------------------------------------------
function newobject:SetScaleY(scaley)
self.scaley = scaley
end
--[[---------------------------------------------------------
- func: GetScaleY()
- desc: gets the object's y scale
--]]---------------------------------------------------------
function newobject:GetScaleY()
return self.scaley
end
--[[---------------------------------------------------------
- func: SetScale(scalex, scaley)
- desc: sets the object's x and y scale
--]]---------------------------------------------------------
function newobject:SetScale(scalex, scaley)
self.scalex = scalex
self.scaley = scaley
end
--[[---------------------------------------------------------
- func: GetScale()
- desc: gets the object's x and y scale
--]]---------------------------------------------------------
function newobject:GetScale()
return self.scalex, self.scaley
end
--[[---------------------------------------------------------
- func: SetOffsetX(x)
- desc: sets the object's x offset
--]]---------------------------------------------------------
function newobject:SetOffsetX(x)
self.offsetx = x
end
--[[---------------------------------------------------------
- func: GetOffsetX()
- desc: gets the object's x offset
--]]---------------------------------------------------------
function newobject:GetOffsetX()
return self.offsetx
end
--[[---------------------------------------------------------
- func: SetOffsetY(y)
- desc: sets the object's y offset
--]]---------------------------------------------------------
function newobject:SetOffsetY(y)
self.offsety = y
end
--[[---------------------------------------------------------
- func: GetOffsetY()
- desc: gets the object's y offset
--]]---------------------------------------------------------
function newobject:GetOffsetY()
return self.offsety
end
--[[---------------------------------------------------------
- func: SetOffset(x, y)
- desc: sets the object's x and y offset
--]]---------------------------------------------------------
function newobject:SetOffset(x, y)
self.offsetx = x
self.offsety = y
end
--[[---------------------------------------------------------
- func: GetOffset()
- desc: gets the object's x and y offset
--]]---------------------------------------------------------
function newobject:GetOffset()
return self.offsetx, self.offsety
end
--[[---------------------------------------------------------
- func: SetShearX(shearx)
- desc: sets the object's x shear
--]]---------------------------------------------------------
function newobject:SetShearX(shearx)
self.shearx = shearx
end
--[[---------------------------------------------------------
- func: GetShearX()
- desc: gets the object's x shear
--]]---------------------------------------------------------
function newobject:GetShearX()
return self.shearx
end
--[[---------------------------------------------------------
- func: SetShearY(sheary)
- desc: sets the object's y shear
--]]---------------------------------------------------------
function newobject:SetShearY(sheary)
self.sheary = sheary
end
--[[---------------------------------------------------------
- func: GetShearY()
- desc: gets the object's y shear
--]]---------------------------------------------------------
function newobject:GetShearY()
return self.sheary
end
--[[---------------------------------------------------------
- func: SetShear(shearx, sheary)
- desc: sets the object's x and y shear
--]]---------------------------------------------------------
function newobject:SetShear(shearx, sheary)
self.shearx = shearx
self.sheary = sheary
end
--[[---------------------------------------------------------
- func: GetShear()
- desc: gets the object's x and y shear
--]]---------------------------------------------------------
function newobject:GetShear()
return self.shearx, self.sheary
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- progressbar class
local newobject = loveframes.NewObject("image", "loveframes_object_image", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "image"
self.width = 0
self.height = 0
self.orientation = 0
self.scalex = 1
self.scaley = 1
self.offsetx = 0
self.offsety = 0
self.shearx = 0
self.sheary = 0
self.internal = false
self.image = nil
self.imagecolor = nil
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawImage or skins[defaultskin].DrawImage
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: SetImage(image)
- desc: sets the object's image
--]]---------------------------------------------------------
function newobject:SetImage(image)
if type(image) == "string" then
self.image = love.graphics.newImage(image)
else
self.image = image
end
self.width = self.image:getWidth()
self.height = self.image:getHeight()
end
--[[---------------------------------------------------------
- func: GetImage()
- desc: gets the object's image
--]]---------------------------------------------------------
function newobject:GetImage()
return self.image
end
--[[---------------------------------------------------------
- func: SetColor(r, g, b, a)
- desc: sets the object's color
--]]---------------------------------------------------------
function newobject:SetColor(r, g, b, a)
self.imagecolor = {r, g, b, a}
end
--[[---------------------------------------------------------
- func: GetColor()
- desc: gets the object's color
--]]---------------------------------------------------------
function newobject:GetColor()
return unpack(self.imagecolor)
end
--[[---------------------------------------------------------
- func: SetOrientation(orientation)
- desc: sets the object's orientation
--]]---------------------------------------------------------
function newobject:SetOrientation(orientation)
self.orientation = orientation
end
--[[---------------------------------------------------------
- func: GetOrientation()
- desc: gets the object's orientation
--]]---------------------------------------------------------
function newobject:GetOrientation()
return self.orientation
end
--[[---------------------------------------------------------
- func: SetScaleX(scalex)
- desc: sets the object's x scale
--]]---------------------------------------------------------
function newobject:SetScaleX(scalex)
self.scalex = scalex
end
--[[---------------------------------------------------------
- func: GetScaleX()
- desc: gets the object's x scale
--]]---------------------------------------------------------
function newobject:GetScaleX()
return self.scalex
end
--[[---------------------------------------------------------
- func: SetScaleY(scaley)
- desc: sets the object's y scale
--]]---------------------------------------------------------
function newobject:SetScaleY(scaley)
self.scaley = scaley
end
--[[---------------------------------------------------------
- func: GetScaleY()
- desc: gets the object's y scale
--]]---------------------------------------------------------
function newobject:GetScaleY()
return self.scaley
end
--[[---------------------------------------------------------
- func: SetScale(scalex, scaley)
- desc: sets the object's x and y scale
--]]---------------------------------------------------------
function newobject:SetScale(scalex, scaley)
self.scalex = scalex
self.scaley = scaley
end
--[[---------------------------------------------------------
- func: GetScale()
- desc: gets the object's x and y scale
--]]---------------------------------------------------------
function newobject:GetScale()
return self.scalex, self.scaley
end
--[[---------------------------------------------------------
- func: SetOffsetX(x)
- desc: sets the object's x offset
--]]---------------------------------------------------------
function newobject:SetOffsetX(x)
self.offsetx = x
end
--[[---------------------------------------------------------
- func: GetOffsetX()
- desc: gets the object's x offset
--]]---------------------------------------------------------
function newobject:GetOffsetX()
return self.offsetx
end
--[[---------------------------------------------------------
- func: SetOffsetY(y)
- desc: sets the object's y offset
--]]---------------------------------------------------------
function newobject:SetOffsetY(y)
self.offsety = y
end
--[[---------------------------------------------------------
- func: GetOffsetY()
- desc: gets the object's y offset
--]]---------------------------------------------------------
function newobject:GetOffsetY()
return self.offsety
end
--[[---------------------------------------------------------
- func: SetOffset(x, y)
- desc: sets the object's x and y offset
--]]---------------------------------------------------------
function newobject:SetOffset(x, y)
self.offsetx = x
self.offsety = y
end
--[[---------------------------------------------------------
- func: GetOffset()
- desc: gets the object's x and y offset
--]]---------------------------------------------------------
function newobject:GetOffset()
return self.offsetx, self.offsety
end
--[[---------------------------------------------------------
- func: SetShearX(shearx)
- desc: sets the object's x shear
--]]---------------------------------------------------------
function newobject:SetShearX(shearx)
self.shearx = shearx
end
--[[---------------------------------------------------------
- func: GetShearX()
- desc: gets the object's x shear
--]]---------------------------------------------------------
function newobject:GetShearX()
return self.shearx
end
--[[---------------------------------------------------------
- func: SetShearY(sheary)
- desc: sets the object's y shear
--]]---------------------------------------------------------
function newobject:SetShearY(sheary)
self.sheary = sheary
end
--[[---------------------------------------------------------
- func: GetShearY()
- desc: gets the object's y shear
--]]---------------------------------------------------------
function newobject:GetShearY()
return self.sheary
end
--[[---------------------------------------------------------
- func: SetShear(shearx, sheary)
- desc: sets the object's x and y shear
--]]---------------------------------------------------------
function newobject:SetShear(shearx, sheary)
self.shearx = shearx
self.sheary = sheary
end
--[[---------------------------------------------------------
- func: GetShear()
- desc: gets the object's x and y shear
--]]---------------------------------------------------------
function newobject:GetShear()
return self.shearx, self.sheary
end
--[[---------------------------------------------------------
- func: GetImageSize()
- desc: gets the size of the object's image
--]]---------------------------------------------------------
function newobject:GetImageSize()
local image = self.image
if image then
return image:getWidth(), image:getHeight()
end
end
--[[---------------------------------------------------------
- func: GetImageWidth()
- desc: gets the width of the object's image
--]]---------------------------------------------------------
function newobject:GetImageWidth()
local image = self.image
if image then
return image:getWidth()
end
end
--[[---------------------------------------------------------
- func: GetImageWidth()
- desc: gets the height of the object's image
--]]---------------------------------------------------------
function newobject:GetImageHeight()
local image = self.image
if image then
return image:getHeight()
end
end

View File

@ -1,260 +1,330 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- imagebutton class
local newobject = loveframes.NewObject("imagebutton", "loveframes_object_imagebutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "imagebutton"
self.text = "Image Button"
self.width = 50
self.height = 50
self.internal = false
self.down = false
self.clickable = true
self.enabled = true
self.image = nil
self.OnClick = nil
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local hover = self.hover
local hoverobject = loveframes.hoverobject
local down = self.down
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
else
if hoverobject == self then
self.down = true
end
end
if not down and hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawImageButton or skins[defaultskin].DrawImageButton
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local down = self.down
local clickable = self.clickable
local enabled = self.enabled
local onclick = self.OnClick
if hover and down and clickable and button == "l" then
if enabled then
if onclick then
onclick(self, x, y)
end
end
end
self.down = false
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetClickable(bool)
- desc: sets whether the object can be clicked or not
--]]---------------------------------------------------------
function newobject:SetClickable(bool)
self.clickable = bool
end
--[[---------------------------------------------------------
- func: GetClickable(bool)
- desc: gets whether the object can be clicked or not
--]]---------------------------------------------------------
function newobject:GetClickable()
return self.clickable
end
--[[---------------------------------------------------------
- func: SetClickable(bool)
- desc: sets whether the object is enabled or not
--]]---------------------------------------------------------
function newobject:SetEnabled(bool)
self.enabled = bool
end
--[[---------------------------------------------------------
- func: GetEnabled()
- desc: gets whether the object is enabled or not
--]]---------------------------------------------------------
function newobject:GetEnabled()
return self.enabled
end
--[[---------------------------------------------------------
- func: SetImage(image)
- desc: sets the object's image
--]]---------------------------------------------------------
function newobject:SetImage(image)
if type(image) == "string" then
self.image = love.graphics.newImage(image)
else
self.image = image
end
end
--[[---------------------------------------------------------
- func: GetImage()
- desc: gets whether the object is enabled or not
--]]---------------------------------------------------------
function newobject:GetImage()
return self.image
end
--[[---------------------------------------------------------
- func: SizeToImage()
- desc: makes the object the same size as it's image
--]]---------------------------------------------------------
function newobject:SizeToImage()
local image = self.image
if image then
self.width = image:getWidth()
self.height = image:getHeight()
end
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- imagebutton class
local newobject = loveframes.NewObject("imagebutton", "loveframes_object_imagebutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "imagebutton"
self.text = "Image Button"
self.width = 50
self.height = 50
self.internal = false
self.down = false
self.clickable = true
self.enabled = true
self.image = nil
self.OnClick = nil
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local hover = self.hover
local hoverobject = loveframes.hoverobject
local down = self.down
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
else
if hoverobject == self then
self.down = true
end
end
if not down and hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawImageButton or skins[defaultskin].DrawImageButton
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local down = self.down
local clickable = self.clickable
local enabled = self.enabled
local onclick = self.OnClick
if hover and down and clickable and button == "l" then
if enabled then
if onclick then
onclick(self, x, y)
end
end
end
self.down = false
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetClickable(bool)
- desc: sets whether the object can be clicked or not
--]]---------------------------------------------------------
function newobject:SetClickable(bool)
self.clickable = bool
end
--[[---------------------------------------------------------
- func: GetClickable(bool)
- desc: gets whether the object can be clicked or not
--]]---------------------------------------------------------
function newobject:GetClickable()
return self.clickable
end
--[[---------------------------------------------------------
- func: SetClickable(bool)
- desc: sets whether the object is enabled or not
--]]---------------------------------------------------------
function newobject:SetEnabled(bool)
self.enabled = bool
end
--[[---------------------------------------------------------
- func: GetEnabled()
- desc: gets whether the object is enabled or not
--]]---------------------------------------------------------
function newobject:GetEnabled()
return self.enabled
end
--[[---------------------------------------------------------
- func: SetImage(image)
- desc: sets the object's image
--]]---------------------------------------------------------
function newobject:SetImage(image)
if type(image) == "string" then
self.image = love.graphics.newImage(image)
else
self.image = image
end
end
--[[---------------------------------------------------------
- func: GetImage()
- desc: gets whether the object is enabled or not
--]]---------------------------------------------------------
function newobject:GetImage()
return self.image
end
--[[---------------------------------------------------------
- func: SizeToImage()
- desc: makes the object the same size as it's image
--]]---------------------------------------------------------
function newobject:SizeToImage()
local image = self.image
if image then
self.width = image:getWidth()
self.height = image:getHeight()
end
end
--[[---------------------------------------------------------
- func: GetImageSize()
- desc: gets the size of the object's image
--]]---------------------------------------------------------
function newobject:GetImageSize()
local image = self.image
if image then
return image:getWidth(), image:getHeight()
end
end
--[[---------------------------------------------------------
- func: GetImageWidth()
- desc: gets the width of the object's image
--]]---------------------------------------------------------
function newobject:GetImageWidth()
local image = self.image
if image then
return image:getWidth()
end
end
--[[---------------------------------------------------------
- func: GetImageWidth()
- desc: gets the height of the object's image
--]]---------------------------------------------------------
function newobject:GetImageHeight()
local image = self.image
if image then
return image:getHeight()
end
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- closebutton class

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- columnlistarea class
@ -28,6 +28,7 @@ function newobject:initialize(parent)
self.buttonscrollamount = parent.buttonscrollamount
self.mousewheelscrollamount = parent.mousewheelscrollamount
self.bar = false
self.dtscrolling = parent.dtscrolling
self.internal = true
self.internals = {}
self.children = {}
@ -160,10 +161,20 @@ function newobject:mousepressed(x, y, button)
if self.bar and toplist then
local bar = self:GetScrollBar()
if button == "wu" then
bar:Scroll(-scrollamount)
elseif button == "wd" then
bar:Scroll(scrollamount)
local dtscrolling = self.dtscrolling
if dtscrolling then
local dt = love.timer.getDelta()
if button == "wu" then
bar:Scroll(-scrollamount * dt)
elseif button == "wd" then
bar:Scroll(scrollamount * dt)
end
else
if button == "wu" then
bar:Scroll(-scrollamount)
elseif button == "wd" then
bar:Scroll(scrollamount)
end
end
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- columnlistrow class

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- columnlistheader class

View File

@ -1,160 +1,160 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- linenumberspanel class
local newobject = loveframes.NewObject("linenumberspanel", "loveframes_object_linenumberspanel", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent)
self.parent = parent
self.type = "linenumberspanel"
self.width = 5
self.height = 5
self.offsety = 0
self.staticx = 0
self.staticy = 0
self.internal = true
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the element
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
local height = self.parent.height
local parentinternals = parent.internals
self.height = height
self.offsety = self.parent.offsety - self.parent.textoffsety
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if parentinternals[1] ~= self then
self:Remove()
table.insert(parentinternals, 1, self)
return
end
self:CheckHover()
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawLineNumbersPanel or skins[defaultskin].DrawLineNumbersPanel
local draw = self.Draw
local drawcount = loveframes.drawcount
local stencilfunc = function() love.graphics.rectangle("fill", self.parent.x, self.parent.y, self.width, self.height) end
local stencil = love.graphics.newStencil(stencilfunc)
if self.parent.hbar then
stencilfunc = function() love.graphics.rectangle("fill", self.parent.x, self.parent.y, self.width, self.parent.height - 16) end
end
-- set the object's draw order
self:SetDrawOrder()
love.graphics.setStencil(stencilfunc)
if draw then
draw(self)
else
drawfunc(self)
end
love.graphics.setStencil()
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
end
--[[---------------------------------------------------------
- func: GetOffsetY()
- desc: gets the object's y offset
--]]---------------------------------------------------------
function newobject:GetOffsetY()
return self.offsety
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- linenumberspanel class
local newobject = loveframes.NewObject("linenumberspanel", "loveframes_object_linenumberspanel", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent)
self.parent = parent
self.type = "linenumberspanel"
self.width = 5
self.height = 5
self.offsety = 0
self.staticx = 0
self.staticy = 0
self.internal = true
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the element
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
local height = self.parent.height
local parentinternals = parent.internals
self.height = height
self.offsety = self.parent.offsety - self.parent.textoffsety
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if parentinternals[1] ~= self then
self:Remove()
table.insert(parentinternals, 1, self)
return
end
self:CheckHover()
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawLineNumbersPanel or skins[defaultskin].DrawLineNumbersPanel
local draw = self.Draw
local drawcount = loveframes.drawcount
local stencilfunc = function() love.graphics.rectangle("fill", self.parent.x, self.parent.y, self.width, self.height) end
local stencil = love.graphics.newStencil(stencilfunc)
if self.parent.hbar then
stencilfunc = function() love.graphics.rectangle("fill", self.parent.x, self.parent.y, self.width, self.parent.height - 16) end
end
-- set the object's draw order
self:SetDrawOrder()
love.graphics.setStencil(stencilfunc)
if draw then
draw(self)
else
drawfunc(self)
end
love.graphics.setStencil()
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
end
--[[---------------------------------------------------------
- func: GetOffsetY()
- desc: gets the object's y offset
--]]---------------------------------------------------------
function newobject:GetOffsetY()
return self.offsety
end

View File

@ -1,101 +1,101 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- modalbackground class
local newobject = loveframes.NewObject("modalbackground", "loveframes_object_modalbackground", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(object)
self.type = "modalbackground"
self.width = love.graphics.getWidth()
self.height = love.graphics.getHeight()
self.x = 0
self.y = 0
self.internal = true
self.parent = loveframes.base
self.object = object
table.insert(loveframes.base.children, self)
if self.object.type ~= "frame" then
self:Remove()
end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the element
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local object = self.object
local update = self.Update
local base = loveframes.base
local basechildren = base.children
if #basechildren > 1 then
if basechildren[#basechildren - 1] ~= self then
self:Remove()
table.insert(basechildren, self)
end
end
if not object:IsActive() then
self:Remove()
loveframes.modalobject = false
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
if not self.visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawModalBackground or skins[defaultskin].DrawModalBackground
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- modalbackground class
local newobject = loveframes.NewObject("modalbackground", "loveframes_object_modalbackground", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(object)
self.type = "modalbackground"
self.width = love.graphics.getWidth()
self.height = love.graphics.getHeight()
self.x = 0
self.y = 0
self.internal = true
self.parent = loveframes.base
self.object = object
table.insert(loveframes.base.children, self)
if self.object.type ~= "frame" then
self:Remove()
end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the element
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local object = self.object
local update = self.Update
local base = loveframes.base
local basechildren = base.children
if #basechildren > 1 then
if basechildren[#basechildren - 1] ~= self then
self:Remove()
table.insert(basechildren, self)
end
end
if not object:IsActive() then
self:Remove()
loveframes.modalobject = false
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
if not self.visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawModalBackground or skins[defaultskin].DrawModalBackground
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- multichoicelist class
@ -30,6 +30,7 @@ function newobject:initialize(object)
self.extrawidth = 0
self.extraheight = 0
self.canremove = false
self.dtscrolling = self.list.dtscrolling
self.internal = true
self.vbar = false
self.children = {}
@ -54,6 +55,13 @@ end
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
@ -118,6 +126,13 @@ end
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -174,6 +189,13 @@ end
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -191,10 +213,21 @@ function newobject:mousepressed(x, y, button)
end
if self.vbar and toplist then
if button == "wu" then
internals[1].internals[1].internals[1]:Scroll(-scrollamount)
elseif button == "wd" then
internals[1].internals[1].internals[1]:Scroll(scrollamount)
local bar = internals[1].internals[1].internals[1]
local dtscrolling = self.dtscrolling
if dtscrolling then
local dt = love.timer.getDelta()
if button == "wu" then
bar:Scroll(-scrollamount * dt)
elseif button == "wd" then
bar:Scroll(scrollamount * dt)
end
else
if button == "wu" then
bar:Scroll(-scrollamount)
elseif button == "wd" then
bar:Scroll(scrollamount)
end
end
end
@ -214,6 +247,13 @@ end
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- multichoicerow class

View File

@ -1,237 +1,237 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- scrollarea class
local newobject = loveframes.NewObject("scrollarea", "loveframes_object_scrollarea", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, bartype)
self.type = "scroll-area"
self.bartype = bartype
self.parent = parent
self.x = 0
self.y = 0
self.scrolldelay = 0
self.delayamount = 0.05
self.down = false
self.internal = true
self.internals = {}
table.insert(self.internals, loveframes.objects["scrollbar"]:new(self, bartype))
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
self:CheckHover()
local parent = self.parent
local pinternals = parent.internals
local button = pinternals[2]
local bartype = self.bartype
local time = love.timer.getTime()
local x, y = love.mouse.getPosition()
local listo = parent.parent
local down = self.down
local scrolldelay = self.scrolldelay
local delayamount = self.delayamount
local internals = self.internals
local bar = internals[1]
local hover = self.hover
if button then
if bartype == "vertical" then
self.staticx = 0
self.staticy = button.height - 1
self.width = parent.width
self.height = parent.height - button.height*2 + 2
elseif bartype == "horizontal" then
self.staticx = button.width - 1
self.staticy = 0
self.width = parent.width - button.width*2 + 2
self.height = parent.height
end
end
if down then
if scrolldelay < time then
self.scrolldelay = time + delayamount
if self.bartype == "vertical" then
if y > bar.y then
bar:Scroll(bar.height)
else
bar:Scroll(-bar.height)
end
elseif self.bartype == "horizontal" then
if x > bar.x then
bar:Scroll(bar.width)
else
bar:Scroll(-bar.width)
end
end
end
if not hover then
self.down = false
end
end
for k, v in ipairs(internals) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local internals = self.internals
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollArea or skins[defaultskin].DrawScrollArea
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
for k, v in ipairs(internals) do
v:draw()
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local listo = self.parent.parent
local time = love.timer.getTime()
local internals = self.internals
local bar = internals[1]
local hover = self.hover
local delayamount = self.delayamount
if hover and button == "l" then
self.down = true
self.scrolldelay = time + delayamount + 0.5
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
if self.bartype == "vertical" then
if y > self.internals[1].y then
bar:Scroll(bar.height)
else
bar:Scroll(-bar.height)
end
elseif self.bartype == "horizontal" then
if x > bar.x then
bar:Scroll(bar.width)
else
bar:Scroll(-bar.width)
end
end
loveframes.hoverobject = self
end
for k, v in ipairs(internals) do
v:mousepressed(x, y, button)
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local internals = self.internals
if button == "l" then
self.down = false
end
for k, v in ipairs(internals) do
v:mousereleased(x, y, button)
end
end
--[[---------------------------------------------------------
- func: GetBarType()
- desc: gets the object's bar type
--]]---------------------------------------------------------
function newobject:GetBarType()
return self.bartype
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- scrollarea class
local newobject = loveframes.NewObject("scrollarea", "loveframes_object_scrollarea", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, bartype)
self.type = "scroll-area"
self.bartype = bartype
self.parent = parent
self.x = 0
self.y = 0
self.scrolldelay = 0
self.delayamount = 0.05
self.down = false
self.internal = true
self.internals = {}
table.insert(self.internals, loveframes.objects["scrollbar"]:new(self, bartype))
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
self:CheckHover()
local parent = self.parent
local pinternals = parent.internals
local button = pinternals[2]
local bartype = self.bartype
local time = love.timer.getTime()
local x, y = love.mouse.getPosition()
local listo = parent.parent
local down = self.down
local scrolldelay = self.scrolldelay
local delayamount = self.delayamount
local internals = self.internals
local bar = internals[1]
local hover = self.hover
if button then
if bartype == "vertical" then
self.staticx = 0
self.staticy = button.height - 1
self.width = parent.width
self.height = parent.height - button.height*2 + 2
elseif bartype == "horizontal" then
self.staticx = button.width - 1
self.staticy = 0
self.width = parent.width - button.width*2 + 2
self.height = parent.height
end
end
if down then
if scrolldelay < time then
self.scrolldelay = time + delayamount
if self.bartype == "vertical" then
if y > bar.y then
bar:Scroll(bar.height)
else
bar:Scroll(-bar.height)
end
elseif self.bartype == "horizontal" then
if x > bar.x then
bar:Scroll(bar.width)
else
bar:Scroll(-bar.width)
end
end
end
if not hover then
self.down = false
end
end
for k, v in ipairs(internals) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local internals = self.internals
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollArea or skins[defaultskin].DrawScrollArea
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
for k, v in ipairs(internals) do
v:draw()
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local listo = self.parent.parent
local time = love.timer.getTime()
local internals = self.internals
local bar = internals[1]
local hover = self.hover
local delayamount = self.delayamount
if hover and button == "l" then
self.down = true
self.scrolldelay = time + delayamount + 0.5
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
if self.bartype == "vertical" then
if y > self.internals[1].y then
bar:Scroll(bar.height)
else
bar:Scroll(-bar.height)
end
elseif self.bartype == "horizontal" then
if x > bar.x then
bar:Scroll(bar.width)
else
bar:Scroll(-bar.width)
end
end
loveframes.hoverobject = self
end
for k, v in ipairs(internals) do
v:mousepressed(x, y, button)
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local internals = self.internals
if button == "l" then
self.down = false
end
for k, v in ipairs(internals) do
v:mousereleased(x, y, button)
end
end
--[[---------------------------------------------------------
- func: GetBarType()
- desc: gets the object's bar type
--]]---------------------------------------------------------
function newobject:GetBarType()
return self.bartype
end

View File

@ -1,350 +1,350 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- scrollbar class
local newobject = loveframes.NewObject("scrollbar", "loveframes_object_scrollbar", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, bartype)
self.type = "scrollbar"
self.bartype = bartype
self.parent = parent
self.x = 0
self.y = 0
self.staticx = 0
self.staticy = 0
self.maxx = 0
self.maxy = 0
self.clickx = 0
self.clicky = 0
self.starty = 0
self.lastwidth = 0
self.lastheight = 0
self.lastx = 0
self.lasty = 0
self.internal = true
self.hover = false
self.dragging = false
self.autoscroll = false
self.internal = true
if self.bartype == "vertical" then
self.width = self.parent.width
self.height = 5
elseif self.bartype == "horizontal" then
self.width = 5
self.height = self.parent.height
end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local x, y = love.mouse.getPosition()
local bartype = self.bartype
local cols = {}
local basecols = {}
local dragging = self.dragging
if bartype == "vertical" then
self.width = self.parent.width
elseif bartype == "horizontal" then
self.height = self.parent.height
end
if bartype == "vertical" then
local parent = self.parent
local listo = parent.parent.parent
local height = parent.height * (listo.height/listo.itemheight)
local update = self.Update
if height < 20 then
self.height = 20
else
self.height = height
end
self.maxy = parent.y + (parent.height - self.height)
self.x = parent.x + parent.width - self.width
self.y = parent.y + self.staticy
if dragging then
if self.staticy ~= self.lasty then
if listo.OnScroll then
listo.OnScroll(listo)
end
self.lasty = self.staticy
end
self.staticy = self.starty + (y - self.clicky)
end
local space = (self.maxy - parent.y)
local remaining = (0 + self.staticy)
local percent = remaining/space
local extra = listo.extraheight * percent
local autoscroll = self.autoscroll
local lastheight = self.lastheight
listo.offsety = 0 + extra
if self.staticy > space then
self.staticy = space
listo.offsety = listo.extraheight
end
if self.staticy < 0 then
self.staticy = 0
listo.offsety = 0
end
if autoscroll then
if listo.itemheight > lastheight then
local type = listo.type
self.lastheight = listo.itemheight
if type == "textinput" then
local indicatory = listo.indicatory
local font = listo.font
local theight = font:getHeight("a")
local y = listo.y
local height = listo.height
local linecount = #listo.lines
local parentheight = self.parent.height
if (indicatory + theight) > (y + height) then
self:Scroll(parentheight/linecount)
end
else
local maxy = self.maxy
self:Scroll(maxy)
end
end
end
elseif bartype == "horizontal" then
local parent = self.parent
local listo = self.parent.parent.parent
local width = self.parent.width * (listo.width/listo.itemwidth)
if width < 20 then
self.width = 20
else
self.width = width
end
self.maxx = parent.x + (parent.width) - self.width
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
if dragging then
if self.staticx ~= self.lastx then
if listo.OnScroll then
listo.OnScroll(listo)
end
self.lastx = self.staticx
end
self.staticx = self.startx + (x - self.clickx)
end
local space = (self.maxx - parent.x)
local remaining = (0 + self.staticx)
local percent = remaining/space
local extra = listo.extrawidth * percent
local autoscroll = self.autoscroll
local lastwidth = self.lastwidth
listo.offsetx = 0 + extra
if self.staticx > space then
self.staticx = space
listo.offsetx = listo.extrawidth
end
if self.staticx < 0 then
self.staticx = 0
listo.offsetx = 0
end
if autoscroll then
if listo.itemwidth > lastwidth then
self.lastwidth = listo.itemwidth
self:Scroll(self.maxx)
end
end
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollBar or skins[defaultskin].DrawScrollBar
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
local hover = self.hover
if not visible then
return
end
if not hover then
return
end
local baseparent = self:GetBaseParent()
if baseparent.type == "frame" then
baseparent:MakeTop()
end
local dragging = self.dragging
if not dragging then
if button == "l" then
self.starty = self.staticy
self.startx = self.staticx
self.clickx = x
self.clicky = y
self.dragging = true
loveframes.hoverobject = self
end
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
if self.dragging then
self.dragging = false
end
end
--[[---------------------------------------------------------
- func: SetMaxX(x)
- desc: sets the object's max x position
--]]---------------------------------------------------------
function newobject:SetMaxX(x)
self.maxx = x
end
--[[---------------------------------------------------------
- func: SetMaxY(y)
- desc: sets the object's max y position
--]]---------------------------------------------------------
function newobject:SetMaxY(y)
self.maxy = y
end
--[[---------------------------------------------------------
- func: Scroll(amount)
- desc: scrolls the object
--]]---------------------------------------------------------
function newobject:Scroll(amount)
local bartype = self.bartype
local listo = self.parent.parent.parent
local onscroll = listo.OnScroll
if bartype == "vertical" then
local newy = (self.y + amount)
if newy > self.maxy then
self.staticy = self.maxy - self.parent.y
elseif newy < self.parent.y then
self.staticy = 0
else
self.staticy = self.staticy + amount
end
elseif bartype == "horizontal" then
local newx = (self.x + amount)
if newx > self.maxx then
self.staticx = self.maxx - self.parent.x
elseif newx < self.parent.x then
self.staticx = 0
else
self.staticx = self.staticx + amount
end
end
if onscroll then
onscroll(listo)
end
end
--[[---------------------------------------------------------
- func: IsDragging()
- desc: gets whether the object is being dragged or not
--]]---------------------------------------------------------
function newobject:IsDragging()
return self.dragging
end
--[[---------------------------------------------------------
- func: GetBarType()
- desc: gets the object's bartype
--]]---------------------------------------------------------
function newobject:GetBarType()
return self.bartype
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- scrollbar class
local newobject = loveframes.NewObject("scrollbar", "loveframes_object_scrollbar", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, bartype)
self.type = "scrollbar"
self.bartype = bartype
self.parent = parent
self.x = 0
self.y = 0
self.staticx = 0
self.staticy = 0
self.maxx = 0
self.maxy = 0
self.clickx = 0
self.clicky = 0
self.starty = 0
self.lastwidth = 0
self.lastheight = 0
self.lastx = 0
self.lasty = 0
self.internal = true
self.hover = false
self.dragging = false
self.autoscroll = false
self.internal = true
if self.bartype == "vertical" then
self.width = self.parent.width
self.height = 5
elseif self.bartype == "horizontal" then
self.width = 5
self.height = self.parent.height
end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local x, y = love.mouse.getPosition()
local bartype = self.bartype
local cols = {}
local basecols = {}
local dragging = self.dragging
if bartype == "vertical" then
self.width = self.parent.width
elseif bartype == "horizontal" then
self.height = self.parent.height
end
if bartype == "vertical" then
local parent = self.parent
local listo = parent.parent.parent
local height = parent.height * (listo.height/listo.itemheight)
local update = self.Update
if height < 20 then
self.height = 20
else
self.height = height
end
self.maxy = parent.y + (parent.height - self.height)
self.x = parent.x + parent.width - self.width
self.y = parent.y + self.staticy
if dragging then
if self.staticy ~= self.lasty then
if listo.OnScroll then
listo.OnScroll(listo)
end
self.lasty = self.staticy
end
self.staticy = self.starty + (y - self.clicky)
end
local space = (self.maxy - parent.y)
local remaining = (0 + self.staticy)
local percent = remaining/space
local extra = listo.extraheight * percent
local autoscroll = self.autoscroll
local lastheight = self.lastheight
listo.offsety = 0 + extra
if self.staticy > space then
self.staticy = space
listo.offsety = listo.extraheight
end
if self.staticy < 0 then
self.staticy = 0
listo.offsety = 0
end
if autoscroll then
if listo.itemheight > lastheight then
local type = listo.type
self.lastheight = listo.itemheight
if type == "textinput" then
local indicatory = listo.indicatory
local font = listo.font
local theight = font:getHeight("a")
local y = listo.y
local height = listo.height
local linecount = #listo.lines
local parentheight = self.parent.height
if (indicatory + theight) > (y + height) then
self:Scroll(parentheight/linecount)
end
else
local maxy = self.maxy
self:Scroll(maxy)
end
end
end
elseif bartype == "horizontal" then
local parent = self.parent
local listo = self.parent.parent.parent
local width = self.parent.width * (listo.width/listo.itemwidth)
if width < 20 then
self.width = 20
else
self.width = width
end
self.maxx = parent.x + (parent.width) - self.width
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
if dragging then
if self.staticx ~= self.lastx then
if listo.OnScroll then
listo.OnScroll(listo)
end
self.lastx = self.staticx
end
self.staticx = self.startx + (x - self.clickx)
end
local space = (self.maxx - parent.x)
local remaining = (0 + self.staticx)
local percent = remaining/space
local extra = listo.extrawidth * percent
local autoscroll = self.autoscroll
local lastwidth = self.lastwidth
listo.offsetx = 0 + extra
if self.staticx > space then
self.staticx = space
listo.offsetx = listo.extrawidth
end
if self.staticx < 0 then
self.staticx = 0
listo.offsetx = 0
end
if autoscroll then
if listo.itemwidth > lastwidth then
self.lastwidth = listo.itemwidth
self:Scroll(self.maxx)
end
end
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollBar or skins[defaultskin].DrawScrollBar
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
local hover = self.hover
if not visible then
return
end
if not hover then
return
end
local baseparent = self:GetBaseParent()
if baseparent.type == "frame" then
baseparent:MakeTop()
end
local dragging = self.dragging
if not dragging then
if button == "l" then
self.starty = self.staticy
self.startx = self.staticx
self.clickx = x
self.clicky = y
self.dragging = true
loveframes.hoverobject = self
end
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
if self.dragging then
self.dragging = false
end
end
--[[---------------------------------------------------------
- func: SetMaxX(x)
- desc: sets the object's max x position
--]]---------------------------------------------------------
function newobject:SetMaxX(x)
self.maxx = x
end
--[[---------------------------------------------------------
- func: SetMaxY(y)
- desc: sets the object's max y position
--]]---------------------------------------------------------
function newobject:SetMaxY(y)
self.maxy = y
end
--[[---------------------------------------------------------
- func: Scroll(amount)
- desc: scrolls the object
--]]---------------------------------------------------------
function newobject:Scroll(amount)
local bartype = self.bartype
local listo = self.parent.parent.parent
local onscroll = listo.OnScroll
if bartype == "vertical" then
local newy = (self.y + amount)
if newy > self.maxy then
self.staticy = self.maxy - self.parent.y
elseif newy < self.parent.y then
self.staticy = 0
else
self.staticy = self.staticy + amount
end
elseif bartype == "horizontal" then
local newx = (self.x + amount)
if newx > self.maxx then
self.staticx = self.maxx - self.parent.x
elseif newx < self.parent.x then
self.staticx = 0
else
self.staticx = self.staticx + amount
end
end
if onscroll then
onscroll(listo)
end
end
--[[---------------------------------------------------------
- func: IsDragging()
- desc: gets whether the object is being dragged or not
--]]---------------------------------------------------------
function newobject:IsDragging()
return self.dragging
end
--[[---------------------------------------------------------
- func: GetBarType()
- desc: gets the object's bartype
--]]---------------------------------------------------------
function newobject:GetBarType()
return self.bartype
end

View File

@ -1,161 +1,187 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- scrollbar class
local newobject = loveframes.NewObject("scrollbody", "loveframes_object_scrollbody", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, bartype)
self.type = "scrollbody"
self.bartype = bartype
self.parent = parent
self.x = 0
self.y = 0
self.internal = true
self.internals = {}
if self.bartype == "vertical" then
self.width = 16
self.height = self.parent.height
self.staticx = self.parent.width - self.width
self.staticy = 0
elseif self.bartype == "horizontal" then
self.width = self.parent.width
self.height = 16
self.staticx = 0
self.staticy = self.parent.height - self.height
end
table.insert(self.internals, loveframes.objects["scrollarea"]:new(self, bartype))
local bar = self.internals[1].internals[1]
if self.bartype == "vertical" then
local upbutton = loveframes.objects["scrollbutton"]:new("up")
upbutton.parent = self
upbutton.Update = function(object, dt)
upbutton.staticx = 0 + self.width - upbutton.width
upbutton.staticy = 0
if object.down and object.hover then
bar:Scroll(-self.parent.buttonscrollamount)
end
end
local downbutton = loveframes.objects["scrollbutton"]:new("down")
downbutton.parent = self
downbutton.Update = function(object, dt)
downbutton.staticx = 0 + self.width - downbutton.width
downbutton.staticy = 0 + self.height - downbutton.height
if object.down and object.hover then
bar:Scroll(self.parent.buttonscrollamount)
end
end
table.insert(self.internals, upbutton)
table.insert(self.internals, downbutton)
elseif self.bartype == "horizontal" then
local leftbutton = loveframes.objects["scrollbutton"]:new("left")
leftbutton.parent = self
leftbutton.Update = function(object, dt)
leftbutton.staticx = 0
leftbutton.staticy = 0
if object.down and object.hover then
bar:Scroll(-self.parent.buttonscrollamount)
end
end
local rightbutton = loveframes.objects["scrollbutton"]:new("right")
rightbutton.parent = self
rightbutton.Update = function(object, dt)
rightbutton.staticx = 0 + self.width - rightbutton.width
rightbutton.staticy = 0
if object.down and object.hover then
bar:Scroll(self.parent.buttonscrollamount)
end
end
table.insert(self.internals, leftbutton)
table.insert(self.internals, rightbutton)
end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
local internals = self.internals
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
self:CheckHover()
for k, v in ipairs(internals) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollBody or skins[defaultskin].DrawScrollBody
local draw = self.Draw
local drawcount = loveframes.drawcount
local internals = self.internals
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
for k, v in ipairs(internals) do
v:draw()
end
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- scrollbar class
local newobject = loveframes.NewObject("scrollbody", "loveframes_object_scrollbody", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, bartype)
self.type = "scrollbody"
self.bartype = bartype
self.parent = parent
self.x = 0
self.y = 0
self.internal = true
self.internals = {}
if self.bartype == "vertical" then
self.width = 16
self.height = self.parent.height
self.staticx = self.parent.width - self.width
self.staticy = 0
elseif self.bartype == "horizontal" then
self.width = self.parent.width
self.height = 16
self.staticx = 0
self.staticy = self.parent.height - self.height
end
table.insert(self.internals, loveframes.objects["scrollarea"]:new(self, bartype))
local bar = self.internals[1].internals[1]
if self.bartype == "vertical" then
local upbutton = loveframes.objects["scrollbutton"]:new("up")
upbutton.parent = self
upbutton.Update = function(object, dt)
upbutton.staticx = 0 + self.width - upbutton.width
upbutton.staticy = 0
if object.down and object.hover then
local dtscrolling = self.parent.dtscrolling
if dtscrolling then
local dt = love.timer.getDelta()
bar:Scroll(-self.parent.buttonscrollamount * dt)
else
bar:Scroll(-self.parent.buttonscrollamount)
end
end
end
local downbutton = loveframes.objects["scrollbutton"]:new("down")
downbutton.parent = self
downbutton.Update = function(object, dt)
downbutton.staticx = 0 + self.width - downbutton.width
downbutton.staticy = 0 + self.height - downbutton.height
if object.down and object.hover then
local dtscrolling = self.parent.dtscrolling
if dtscrolling then
local dt = love.timer.getDelta()
bar:Scroll(self.parent.buttonscrollamount * dt)
else
bar:Scroll(self.parent.buttonscrollamount)
end
end
end
table.insert(self.internals, upbutton)
table.insert(self.internals, downbutton)
elseif self.bartype == "horizontal" then
local leftbutton = loveframes.objects["scrollbutton"]:new("left")
leftbutton.parent = self
leftbutton.Update = function(object, dt)
leftbutton.staticx = 0
leftbutton.staticy = 0
if object.down and object.hover then
local dtscrolling = self.parent.dtscrolling
if dtscrolling then
local dt = love.timer.getDelta()
bar:Scroll(-self.parent.buttonscrollamount * dt)
else
bar:Scroll(-self.parent.buttonscrollamount)
end
end
end
local rightbutton = loveframes.objects["scrollbutton"]:new("right")
rightbutton.parent = self
rightbutton.Update = function(object, dt)
rightbutton.staticx = 0 + self.width - rightbutton.width
rightbutton.staticy = 0
if object.down and object.hover then
local dtscrolling = self.parent.dtscrolling
if dtscrolling then
local dt = love.timer.getDelta()
bar:Scroll(self.parent.buttonscrollamount * dt)
else
bar:Scroll(self.parent.buttonscrollamount)
end
end
end
table.insert(self.internals, leftbutton)
table.insert(self.internals, rightbutton)
end
self:SetState(parent.state)
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
local internals = self.internals
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
self:CheckHover()
for k, v in ipairs(internals) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollBody or skins[defaultskin].DrawScrollBody
local draw = self.Draw
local drawcount = loveframes.drawcount
local internals = self.internals
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
for k, v in ipairs(internals) do
v:draw()
end
end

View File

@ -1,165 +1,165 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- scrollbutton clas
local newobject = loveframes.NewObject("scrollbutton", "loveframes_object_scrollbutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(scrolltype)
self.type = "scrollbutton"
self.scrolltype = scrolltype
self.width = 16
self.height = 16
self.down = false
self.internal = true
self.OnClick = function() end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local hover = self.hover
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
else
if loveframes.hoverobject == self then
self.down = true
end
end
if not self.down and loveframes.hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollButton or skins[defaultskin].DrawScrollButton
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local down = self.down
local onclick = self.OnClick
if hover and down then
if button == "l" then
onclick(x, y, self)
end
end
self.down = false
end
--[[---------------------------------------------------------
- func: GetScrollType()
- desc: gets the object's scroll type
--]]---------------------------------------------------------
function newobject:GetScrollType()
return self.scrolltype
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- scrollbutton clas
local newobject = loveframes.NewObject("scrollbutton", "loveframes_object_scrollbutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(scrolltype)
self.type = "scrollbutton"
self.scrolltype = scrolltype
self.width = 16
self.height = 16
self.down = false
self.internal = true
self.OnClick = function() end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local hover = self.hover
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
else
if loveframes.hoverobject == self then
self.down = true
end
end
if not self.down and loveframes.hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollButton or skins[defaultskin].DrawScrollButton
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local down = self.down
local onclick = self.OnClick
if hover and down then
if button == "l" then
onclick(x, y, self)
end
end
self.down = false
end
--[[---------------------------------------------------------
- func: GetScrollType()
- desc: gets the object's scroll type
--]]---------------------------------------------------------
function newobject:GetScrollType()
return self.scrolltype
end

View File

@ -1,244 +1,244 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- sliderbutton class
local newobject = loveframes.NewObject("sliderbutton", "loveframes_object_sliderbutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent)
self.type = "sliderbutton"
self.width = 10
self.height = 20
self.staticx = 0
self.staticy = 0
self.startx = 0
self.clickx = 0
self.starty = 0
self.clicky = 0
self.intervals = true
self.internal = true
self.down = false
self.dragging = false
self.parent = parent
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local x, y = love.mouse.getPosition()
local intervals = self.intervals
local progress = 0
local nvalue = 0
local pvalue = self.parent.value
local hover = self.hover
local down = self.down
local hoverobject = loveframes.hoverobject
local parent = self.parent
local slidetype = parent.slidetype
local dragging = self.dragging
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
if hoverobject == self then
self.hover = true
end
else
if hoverobject == self then
self.down = true
end
end
if not down and hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
-- start calculations if the button is being dragged
if dragging then
-- calculations for horizontal sliders
if slidetype == "horizontal" then
self.staticx = self.startx + (x - self.clickx)
progress = self.staticx/(self.parent.width - self.width)
nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
-- calculations for vertical sliders
elseif slidetype == "vertical" then
self.staticy = self.starty + (y - self.clicky)
local space = self.parent.height - self.height
local remaining = (self.parent.height - self.height) - self.staticy
local percent = remaining/space
nvalue = self.parent.min + (self.parent.max - self.parent.min) * percent
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
end
if nvalue > self.parent.max then
nvalue = self.parent.max
end
if nvalue < self.parent.min then
nvalue = self.parent.min
end
self.parent.value = nvalue
if self.parent.value == -0 then
self.parent.value = math.abs(self.parent.value)
end
if nvalue ~= pvalue and nvalue >= self.parent.min and nvalue <= self.parent.max then
if self.parent.OnValueChanged then
self.parent.OnValueChanged(self.parent, self.parent.value)
end
end
loveframes.hoverobject = self
end
if slidetype == "horizontal" then
if (self.staticx + self.width) > self.parent.width then
self.staticx = self.parent.width - self.width
end
if self.staticx < 0 then
self.staticx = 0
end
end
if slidetype == "vertical" then
if (self.staticy + self.height) > self.parent.height then
self.staticy = self.parent.height - self.height
end
if self.staticy < 0 then
self.staticy = 0
end
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawSliderButton or skins[defaultskin].DrawSliderButton
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
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
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
self.down = false
self.dragging = false
end
--[[---------------------------------------------------------
- func: MoveToX(x)
- desc: moves the object to the specified x position
--]]---------------------------------------------------------
function newobject:MoveToX(x)
self.staticx = x
end
--[[---------------------------------------------------------
- func: MoveToY(y)
- desc: moves the object to the specified y position
--]]---------------------------------------------------------
function newobject:MoveToY(y)
self.staticy = y
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- sliderbutton class
local newobject = loveframes.NewObject("sliderbutton", "loveframes_object_sliderbutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent)
self.type = "sliderbutton"
self.width = 10
self.height = 20
self.staticx = 0
self.staticy = 0
self.startx = 0
self.clickx = 0
self.starty = 0
self.clicky = 0
self.intervals = true
self.internal = true
self.down = false
self.dragging = false
self.parent = parent
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local x, y = love.mouse.getPosition()
local intervals = self.intervals
local progress = 0
local nvalue = 0
local pvalue = self.parent.value
local hover = self.hover
local down = self.down
local hoverobject = loveframes.hoverobject
local parent = self.parent
local slidetype = parent.slidetype
local dragging = self.dragging
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
if hoverobject == self then
self.hover = true
end
else
if hoverobject == self then
self.down = true
end
end
if not down and hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
-- start calculations if the button is being dragged
if dragging then
-- calculations for horizontal sliders
if slidetype == "horizontal" then
self.staticx = self.startx + (x - self.clickx)
progress = self.staticx/(self.parent.width - self.width)
nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
-- calculations for vertical sliders
elseif slidetype == "vertical" then
self.staticy = self.starty + (y - self.clicky)
local space = self.parent.height - self.height
local remaining = (self.parent.height - self.height) - self.staticy
local percent = remaining/space
nvalue = self.parent.min + (self.parent.max - self.parent.min) * percent
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
end
if nvalue > self.parent.max then
nvalue = self.parent.max
end
if nvalue < self.parent.min then
nvalue = self.parent.min
end
self.parent.value = nvalue
if self.parent.value == -0 then
self.parent.value = math.abs(self.parent.value)
end
if nvalue ~= pvalue and nvalue >= self.parent.min and nvalue <= self.parent.max then
if self.parent.OnValueChanged then
self.parent.OnValueChanged(self.parent, self.parent.value)
end
end
loveframes.hoverobject = self
end
if slidetype == "horizontal" then
if (self.staticx + self.width) > self.parent.width then
self.staticx = self.parent.width - self.width
end
if self.staticx < 0 then
self.staticx = 0
end
end
if slidetype == "vertical" then
if (self.staticy + self.height) > self.parent.height then
self.staticy = self.parent.height - self.height
end
if self.staticy < 0 then
self.staticy = 0
end
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawSliderButton or skins[defaultskin].DrawSliderButton
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
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
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
self.down = false
self.dragging = false
end
--[[---------------------------------------------------------
- func: MoveToX(x)
- desc: moves the object to the specified x position
--]]---------------------------------------------------------
function newobject:MoveToX(x)
self.staticx = x
end
--[[---------------------------------------------------------
- func: MoveToY(y)
- desc: moves the object to the specified y position
--]]---------------------------------------------------------
function newobject:MoveToY(y)
self.staticy = y
end

View File

@ -1,233 +1,231 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- tabbutton class
local newobject = loveframes.NewObject("tabbutton", "loveframes_object_tabbutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, text, tabnumber, tip, image, onopened, onclosed)
self.type = "tabbutton"
self.font = loveframes.smallfont
self.text = text
self.tabnumber = tabnumber
self.parent = parent
self.staticx = 0
self.staticy = 0
self.width = 50
self.height = 25
self.internal = true
self.down = false
self.image = nil
self.OnOpened = nil
self.OnClosed = nil
if tip then
self.tooltip = loveframes.objects["tooltip"]:new(self, tip)
self.tooltip:SetFollowCursor(false)
self.tooltip:SetFollowObject(true)
self.tooltip:SetOffsets(0, -(self.tooltip.text:GetHeight() + 12))
end
if image then
self:SetImage(image)
end
if onopened then
self.OnOpened = onopened
end
if onclosed then
self.OnClosed = onclosed
end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
self:SetClickBounds(parent.x, parent.y, parent.width, parent.height)
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
if not self.visible then
return
end
local image = self.image
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawTabButton or skins[defaultskin].DrawTabButton
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local parent = self.parent
local tabnumber = self.tabnumber
if hover and button == "l" then
if button == "l" then
local tab = self.parent.tab
local internals = parent.internals
local onopened = self.OnOpened
local prevtab = internals[tab]
local onclosed = prevtab.OnClosed
parent:SwitchToTab(tabnumber)
if onopened then
onopened(self)
end
if onclosed then
onclosed(prevtab)
end
end
end
self.down = false
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetImage(image)
- desc: adds an image to the object
--]]---------------------------------------------------------
function newobject:SetImage(image)
if type(image) == "string" then
self.image = love.graphics.newImage(image)
else
self.image = image
end
end
--[[---------------------------------------------------------
- func: GetImage()
- desc: gets the object's image
--]]---------------------------------------------------------
function newobject:GetImage()
return self.image
end
--[[---------------------------------------------------------
- func: GetTabNumber()
- desc: gets the object's tab number
--]]---------------------------------------------------------
function newobject:GetTabNumber()
return self.tabnumber
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- tabbutton class
local newobject = loveframes.NewObject("tabbutton", "loveframes_object_tabbutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, text, tabnumber, tip, image, onopened, onclosed)
self.type = "tabbutton"
self.font = loveframes.smallfont
self.text = text
self.tabnumber = tabnumber
self.parent = parent
self.staticx = 0
self.staticy = 0
self.width = 50
self.height = 25
self.internal = true
self.down = false
self.image = nil
self.OnOpened = nil
self.OnClosed = nil
if tip then
self.tooltip = loveframes.objects["tooltip"]:new(self, tip)
self.tooltip:SetFollowCursor(false)
self.tooltip:SetFollowObject(true)
self.tooltip:SetOffsets(0, -(self.tooltip.text:GetHeight() + 12))
end
if image then
self:SetImage(image)
end
if onopened then
self.OnOpened = onopened
end
if onclosed then
self.OnClosed = onclosed
end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
local internals = self.internals
self:CheckHover()
self:SetClickBounds(parent.x, parent.y, parent.width, parent.height)
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
if not self.visible then
return
end
local image = self.image
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawTabButton or skins[defaultskin].DrawTabButton
local draw = self.Draw
local drawcount = loveframes.drawcount
local internals = self.internals
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local internals = self.internals
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local parent = self.parent
local tabnumber = self.tabnumber
local internals = self.internals
if hover and button == "l" then
if button == "l" then
local tab = self.parent.tab
local internals = parent.internals
local onopened = self.OnOpened
local prevtab = internals[tab]
local onclosed = prevtab.OnClosed
parent:SwitchToTab(tabnumber)
if onopened then
onopened(self)
end
if onclosed then
onclosed(prevtab)
end
end
end
self.down = false
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetImage(image)
- desc: adds an image to the object
--]]---------------------------------------------------------
function newobject:SetImage(image)
if type(image) == "string" then
self.image = love.graphics.newImage(image)
else
self.image = image
end
end
--[[---------------------------------------------------------
- func: GetImage()
- desc: gets the object's image
--]]---------------------------------------------------------
function newobject:GetImage()
return self.image
end
--[[---------------------------------------------------------
- func: GetTabNumber()
- desc: gets the object's tab number
--]]---------------------------------------------------------
function newobject:GetTabNumber()
return self.tabnumber
end

View File

@ -1,236 +1,256 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- tooltip clas
local newobject = loveframes.NewObject("tooltip", "loveframes_object_tooltip", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(object, text, width)
local width = width or 0
self.type = "tooltip"
self.parent = loveframes.base
self.object = object or nil
self.width = width or 0
self.height = 0
self.padding = 5
self.xoffset = 10
self.yoffset = -10
self.internal = true
self.show = false
self.followcursor = true
self.followobject = false
self.alwaysupdate = true
-- create the object's text
self.text = loveframes.Create("text")
self.text:Remove()
self.text.parent = self
self.text:SetText(text or "")
self.text:SetWidth(width or 0)
self.text:SetPos(0, 0)
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
table.insert(loveframes.base.internals, self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local text = self.text
local object = self.object
local draworder = self.draworder
local update = self.Update
self.width = text.width + self.padding * 2
self.height = text.height + self.padding * 2
if object then
if object == loveframes.base then
self:Remove()
return
end
local hover = object.hover
local odraworder = object.draworder
local ovisible = object.visible
local ohover = object.hover
self.show = ohover
self.visible = ovisible
if ohover and ovisible then
local top = self:IsTopInternal()
local followcursor = self.followcursor
local followobject = self.followobject
if followcursor then
local x, y = love.mouse.getPosition()
self.x = x + self.xoffset
self.y = y - self.height + self.yoffset
elseif followobject then
self.x = object.x + self.xoffset
self.y = object.y + self.yoffset
end
if not top then
self:MoveToTop()
end
text:SetPos(self.padding, self.padding)
end
local baseparent = object:GetBaseParent()
if baseparent then
if baseparent.removed and baseparent.removed then
self:Remove()
end
elseif object.removed then
self:Remove()
end
end
text:update(dt)
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local show = self.show
local text = self.text
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawToolTip or skins[defaultskin].DrawToolTip
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if show then
if draw then
draw(self)
else
drawfunc(self)
end
text:draw()
end
end
--[[---------------------------------------------------------
- func: SetFollowCursor(bool)
- desc: sets whether or not the tooltip should follow the
cursor
--]]---------------------------------------------------------
function newobject:SetFollowCursor(bool)
self.followcursor = bool
end
--[[---------------------------------------------------------
- func: SetObject(object)
- desc: sets the tooltip's object
--]]---------------------------------------------------------
function newobject:SetObject(object)
self.object = object
self.x = object.x
self.y = object.y
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the tooltip's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text:SetText(text)
self.text2 = text
end
--[[---------------------------------------------------------
- func: SetTextMaxWidth(text)
- desc: sets the tooltip's text max width
--]]---------------------------------------------------------
function newobject:SetTextMaxWidth(width)
self.text:SetMaxWidth(width)
end
--[[---------------------------------------------------------
- func: SetOffsets(xoffset, yoffset)
- desc: sets the tooltip's x and y offset
--]]---------------------------------------------------------
function newobject:SetOffsets(xoffset, yoffset)
self.xoffset = xoffset
self.yoffset = yoffset
end
--[[---------------------------------------------------------
- func: SetPadding(padding)
- desc: sets the tooltip's padding
--]]---------------------------------------------------------
function newobject:SetPadding(padding)
self.padding = padding
end
--[[---------------------------------------------------------
- func: SetFont(font)
- desc: sets the tooltip's font
--]]---------------------------------------------------------
function newobject:SetFont(font)
self.text:SetFont(font)
end
--[[---------------------------------------------------------
- func: SetFollowObject(bool)
- desc: sets whether or not the tooltip should follow
it's assigned object
--]]---------------------------------------------------------
function newobject:SetFollowObject(bool)
self.followobject = bool
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- tooltip clas
local newobject = loveframes.NewObject("tooltip", "loveframes_object_tooltip", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(object, text, width)
local width = width or 0
self.type = "tooltip"
self.parent = loveframes.base
self.object = object or nil
self.width = width or 0
self.height = 0
self.padding = 5
self.xoffset = 10
self.yoffset = -10
self.internal = true
self.show = false
self.followcursor = true
self.followobject = false
self.alwaysupdate = true
-- create the object's text
self.text = loveframes.Create("text")
self.text:Remove()
self.text.parent = self
self.text:SetText(text or "")
self.text:SetWidth(width or 0)
self.text:SetPos(0, 0)
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
table.insert(loveframes.base.internals, self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local text = self.text
local object = self.object
local draworder = self.draworder
local update = self.Update
self.width = text.width + self.padding * 2
self.height = text.height + self.padding * 2
if object then
if object == loveframes.base then
self:Remove()
return
end
local hover = object.hover
local odraworder = object.draworder
local ovisible = object.visible
local ohover = object.hover
local ostate = object.state
if ostate ~= state then
self.show = false
self.visible = false
return
end
self.show = ohover
self.visible = ovisible
if ohover and ovisible then
local top = self:IsTopInternal()
local followcursor = self.followcursor
local followobject = self.followobject
if followcursor then
local x, y = love.mouse.getPosition()
self.x = x + self.xoffset
self.y = y - self.height + self.yoffset
elseif followobject then
self.x = object.x + self.xoffset
self.y = object.y + self.yoffset
end
if not top then
self:MoveToTop()
end
text:SetPos(self.padding, self.padding)
end
local baseparent = object:GetBaseParent()
if baseparent then
if baseparent.removed and baseparent.removed then
self:Remove()
end
elseif object.removed then
self:Remove()
end
end
text:update(dt)
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local show = self.show
local text = self.text
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawToolTip or skins[defaultskin].DrawToolTip
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if show then
if draw then
draw(self)
else
drawfunc(self)
end
text:draw()
end
end
--[[---------------------------------------------------------
- func: SetFollowCursor(bool)
- desc: sets whether or not the tooltip should follow the
cursor
--]]---------------------------------------------------------
function newobject:SetFollowCursor(bool)
self.followcursor = bool
end
--[[---------------------------------------------------------
- func: SetObject(object)
- desc: sets the tooltip's object
--]]---------------------------------------------------------
function newobject:SetObject(object)
self.object = object
self.x = object.x
self.y = object.y
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the tooltip's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text:SetText(text)
self.text2 = text
end
--[[---------------------------------------------------------
- func: SetTextMaxWidth(text)
- desc: sets the tooltip's text max width
--]]---------------------------------------------------------
function newobject:SetTextMaxWidth(width)
self.text:SetMaxWidth(width)
end
--[[---------------------------------------------------------
- func: SetOffsets(xoffset, yoffset)
- desc: sets the tooltip's x and y offset
--]]---------------------------------------------------------
function newobject:SetOffsets(xoffset, yoffset)
self.xoffset = xoffset
self.yoffset = yoffset
end
--[[---------------------------------------------------------
- func: SetPadding(padding)
- desc: sets the tooltip's padding
--]]---------------------------------------------------------
function newobject:SetPadding(padding)
self.padding = padding
end
--[[---------------------------------------------------------
- func: SetFont(font)
- desc: sets the tooltip's font
--]]---------------------------------------------------------
function newobject:SetFont(font)
self.text:SetFont(font)
end
--[[---------------------------------------------------------
- func: SetFollowObject(bool)
- desc: sets whether or not the tooltip should follow
it's assigned object
--]]---------------------------------------------------------
function newobject:SetFollowObject(bool)
self.followobject = bool
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- list class
@ -24,12 +24,14 @@ function newobject:initialize()
self.offsetx = 0
self.extrawidth = 0
self.extraheight = 0
self.buttonscrollamount = 0.10
self.mousewheelscrollamount = 5
self.buttonscrollamount = 200
self.mousewheelscrollamount = 1000
self.internal = false
self.hbar = false
self.vbar = false
self.autoscroll = false
self.horizontalstacking = false
self.dtscrolling = true
self.internals = {}
self.children = {}
self.OnScroll = nil
@ -42,6 +44,13 @@ end
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
@ -55,6 +64,7 @@ function newobject:update(dt)
local children = self.children
local display = self.display
local parent = self.parent
local horizontalstacking = self.horizontalstacking
local base = loveframes.base
local update = self.Update
@ -70,15 +80,23 @@ function newobject:update(dt)
v:update(dt)
end
local x = self.x
local y = self.y
local width = self.width
local height = self.height
local offsetx = self.offsetx
local offsety = self.offsety
for k, v in ipairs(children) do
v:update(dt)
v:SetClickBounds(self.x, self.y, self.width, self.height)
v.y = (v.parent.y + v.staticy) - self.offsety
v.x = (v.parent.x + v.staticx) - self.offsetx
v:SetClickBounds(x, y, width, height)
v.x = (v.parent.x + v.staticx) - offsetx
v.y = (v.parent.y + v.staticy) - offsety
if display == "vertical" then
if v.lastheight ~= v.height then
self:CalculateSize()
self:RedoLayout()
print("!")
end
end
end
@ -95,15 +113,26 @@ end
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local x = self.x
local y = self.y
local width = self.width
local height = self.height
local internals = self.internals
local children = self.children
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
local stencil = love.graphics.newStencil(stencilfunc)
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
@ -127,8 +156,8 @@ function newobject:draw()
love.graphics.setStencil(stencil)
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)
if col == true then
local col = loveframes.util.BoundingBox(x, v.x, y, v.y, width, v.width, height, v.height)
if col then
v:draw()
end
end
@ -151,6 +180,13 @@ end
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
@ -175,10 +211,20 @@ function newobject:mousepressed(x, y, button)
if vbar or hbar then
if toplist then
local bar = self:GetScrollBar()
if button == "wu" then
bar:Scroll(-scrollamount)
elseif button == "wd" then
bar:Scroll(scrollamount)
local dtscrolling = self.dtscrolling
if dtscrolling then
local dt = love.timer.getDelta()
if button == "wu" then
bar:Scroll(-scrollamount * dt)
elseif button == "wd" then
bar:Scroll(scrollamount * dt)
end
else
if button == "wu" then
bar:Scroll(-scrollamount)
elseif button == "wd" then
bar:Scroll(scrollamount)
end
end
end
end
@ -208,6 +254,7 @@ function newobject:AddItem(object)
-- remove the item object from it's current parent and make it's new parent the list object
object:Remove()
object.parent = self
object.state = self.state
-- insert the item object into the list object's children table
table.insert(children, object)
@ -219,14 +266,24 @@ function newobject:AddItem(object)
end
--[[---------------------------------------------------------
- func: RemoveItem(object)
- func: RemoveItem(object or number)
- desc: removes an item from the object
--]]---------------------------------------------------------
function newobject:RemoveItem(object)
function newobject:RemoveItem(data)
object:Remove()
self:CalculateSize()
self:RedoLayout()
local dtype = type(data)
if dtype == "number" then
local children = self.children
local item = children[data]
if item then
item:Remove()
end
else
object:Remove()
self:CalculateSize()
self:RedoLayout()
end
end
@ -248,12 +305,39 @@ function newobject:CalculateSize()
local hbar = self.hbar
local internals = self.internals
local children = self.children
local horizontalstacking = self.horizontalstacking
if display == "vertical" then
for k, v in ipairs(self.children) do
itemheight = itemheight + v.height + spacing
if horizontalstacking then
local curwidth = 0
local maxwidth = width - padding * 2
local prevheight = 0
local scrollbar = self:GetScrollBar()
if scrollbar then
maxwidth = maxwidth - scrollbar.width
end
for k, v in ipairs(children) do
if v.height > prevheight then
prevheight = v.height
end
curwidth = curwidth + v.width + spacing
if children[k + 1] then
if curwidth + children[k + 1].width > maxwidth then
curwidth = padding
itemheight = itemheight + prevheight + spacing
prevheight = 0
end
else
itemheight = itemheight + prevheight + padding
end
end
self.itemheight = itemheight
else
for k, v in ipairs(children) do
itemheight = itemheight + v.height + spacing
end
self.itemheight = (itemheight - spacing) + padding
end
self.itemheight = (itemheight - spacing) + padding
local itemheight = self.itemheight
if itemheight > height then
self.extraheight = itemheight - height
@ -303,7 +387,10 @@ end
--]]---------------------------------------------------------
function newobject:RedoLayout()
local width = self.width
local height = self.height
local children = self.children
local internals = self.internals
local padding = self.padding
local spacing = self.spacing
local starty = padding
@ -311,48 +398,91 @@ function newobject:RedoLayout()
local vbar = self.vbar
local hbar = self.hbar
local display = self.display
local horizontalstacking = self.horizontalstacking
local scrollbody, scrollbodywidth, scrollbodyheight
if vbar or hbar then
scrollbody = internals[1]
scrollbodywidth = scrollbody.width
scrollbodyheight = scrollbody.height
end
if #children > 0 then
for k, v in ipairs(children) do
if display == "vertical" then
local height = v.height
v.staticx = padding
v.staticy = starty
v.lastheight = v.height
if vbar then
if v.width + padding > (self.width - self.internals[1].width) then
v:SetWidth((self.width - self.internals[1].width) - (padding*2))
if display == "vertical" then
if horizontalstacking then
local curwidth = padding
local curheight = padding
local maxwidth = self.width - padding * 2
local prevheight = 0
local scrollbar = self:GetScrollBar()
if scrollbar then
maxwidth = maxwidth - scrollbar.width
end
for k, v in ipairs(children) do
local itemheight = v.height
v.lastheight = itemheight
v.staticx = curwidth
v.staticy = curheight
if v.height > prevheight then
prevheight = v.height
end
if not v.retainsize then
v:SetWidth((self.width - self.internals[1].width) - (padding*2))
end
self.internals[1].staticx = self.width - self.internals[1].width
self.internals[1].height = self.height
else
if not v.retainsize then
v:SetWidth(self.width - (padding*2))
if children[k + 1] then
curwidth = curwidth + v.width + spacing
if curwidth + (children[k + 1].width) > maxwidth then
curwidth = padding
curheight = curheight + prevheight + spacing
prevheight = 0
end
end
end
starty = starty + v.height
starty = starty + spacing
elseif display == "horizontal" then
else
for k, v in ipairs(children) do
local itemwidth = v.width
local itemheight = v.height
local retainsize = v.retainsize
v.staticx = padding
v.staticy = starty
v.lastheight = itemheight
if vbar then
if itemwidth + padding > (width - scrollbodywidth) then
v:SetWidth((width - scrollbodywidth) - (padding * 2))
end
if not retainsize then
v:SetWidth((width - scrollbodywidth) - (padding * 2))
end
scrollbody.staticx = width - scrollbodywidth
scrollbody.height = height
else
if not retainsize then
v:SetWidth(width - (padding * 2))
end
end
starty = starty + itemheight
starty = starty + spacing
end
end
elseif display == "horizontal" then
for k, v in ipairs(children) do
local itemwidth = v.width
local itemheight = v.height
local retainsize = v.retainsize
v.staticx = startx
v.staticy = padding
if hbar then
if v.height + padding > (self.height - self.internals[1].height) then
v:SetHeight((self.height - self.internals[1].height) - (padding*2))
if itemheight + padding > (height - scrollbodyheight) then
v:SetHeight((height - scrollbodyheight) - (padding * 2))
end
if not v.retainsize then
v:SetHeight((self.height - self.internals[1].height) - (padding*2))
if not retainsize then
v:SetHeight((height - scrollbodyheight) - (padding * 2))
end
self.internals[1].staticy = self.height - self.internals[1].height
self.internals[1].width = self.width
scrollbody.staticy = height - scrollbodyheight
scrollbody.width = width
else
if not v.retainsize then
v:SetHeight(self.height - (padding*2))
if not retainsize then
v:SetHeight(height - (padding * 2))
end
end
startx = startx + v.width
startx = startx + itemwidth
startx = startx + spacing
end
end
@ -557,4 +687,55 @@ function newobject:GetButtonScrollAmount()
return self.mousewheelscrollamount
end
--[[---------------------------------------------------------
- func: EnableHorizontalStacking(bool)
- desc: enables or disables horizontal stacking
--]]---------------------------------------------------------
function newobject:EnableHorizontalStacking(bool)
local children = self.children
local numchildren = #children
self.horizontalstacking = bool
if numchildren > 0 then
self:CalculateSize()
self:RedoLayout()
end
end
--[[---------------------------------------------------------
- func: GetHorizontalStacking()
- desc: gets whether or not the object allows horizontal
stacking
--]]---------------------------------------------------------
function newobject:GetHorizontalStacking()
return self.horizontalstacking
end
--[[---------------------------------------------------------
- func: SetDTScrolling(bool)
- desc: sets whether or not the object should use delta
time when scrolling
--]]---------------------------------------------------------
function newobject:SetDTScrolling(bool)
self.dtscrolling = bool
end
--[[---------------------------------------------------------
- func: GetDTScrolling()
- desc: gets whether or not the object should use delta
time when scrolling
--]]---------------------------------------------------------
function newobject:GetDTScrolling()
return self.dtscrolling
end

View File

@ -1,285 +1,337 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- multichoice class
local newobject = loveframes.NewObject("multichoice", "loveframes_object_multichoice", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "multichoice"
self.choice = ""
self.text = "Select an option"
self.width = 200
self.height = 25
self.listpadding = 0
self.listspacing = 0
self.buttonscrollamount = 0.10
self.mousewheelscrollamount = 5
self.haslist = false
self.internal = false
self.choices = {}
self.listheight = nil
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawMultiChoice or skins[defaultskin].DrawMultiChoice
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local haslist = self.haslist
if hover and not haslist and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.haslist = true
self.list = loveframes.objects["multichoicelist"]:new(self)
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
end
--[[---------------------------------------------------------
- func: AddChoice(choice)
- desc: adds a choice to the current list of choices
--]]---------------------------------------------------------
function newobject:AddChoice(choice)
local choices = self.choices
table.insert(choices, choice)
end
--[[---------------------------------------------------------
- func: SetChoice(choice)
- desc: sets the current choice
--]]---------------------------------------------------------
function newobject:SetChoice(choice)
self.choice = choice
end
--[[---------------------------------------------------------
- func: SelectChoice(choice)
- desc: selects a choice
--]]---------------------------------------------------------
function newobject:SelectChoice(choice)
local onchoiceselected = self.OnChoiceSelected
self.choice = choice
self.list:Close()
if onchoiceselected then
onchoiceselected(self, choice)
end
end
--[[---------------------------------------------------------
- func: SetListHeight(height)
- desc: sets the height of the list of choices
--]]---------------------------------------------------------
function newobject:SetListHeight(height)
self.listheight = height
end
--[[---------------------------------------------------------
- func: SetPadding(padding)
- desc: sets the padding of the list of choices
--]]---------------------------------------------------------
function newobject:SetPadding(padding)
self.listpadding = padding
end
--[[---------------------------------------------------------
- func: SetSpacing(spacing)
- desc: sets the spacing of the list of choices
--]]---------------------------------------------------------
function newobject:SetSpacing(spacing)
self.listspacing = spacing
end
--[[---------------------------------------------------------
- func: GetValue()
- desc: gets the value (choice) of the object
--]]---------------------------------------------------------
function newobject:GetValue()
return self.choice
end
--[[---------------------------------------------------------
- func: GetChoice()
- desc: gets the current choice (same as get value)
--]]---------------------------------------------------------
function newobject:GetChoice()
return self.choice
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetButtonScrollAmount(speed)
- desc: sets the scroll amount of the object's scrollbar
buttons
--]]---------------------------------------------------------
function newobject:SetButtonScrollAmount(amount)
self.buttonscrollamount = amount
end
--[[---------------------------------------------------------
- func: GetButtonScrollAmount()
- desc: gets the scroll amount of the object's scrollbar
buttons
--]]---------------------------------------------------------
function newobject:GetButtonScrollAmount()
return self.buttonscrollamount
end
--[[---------------------------------------------------------
- func: SetMouseWheelScrollAmount(amount)
- desc: sets the scroll amount of the mouse wheel
--]]---------------------------------------------------------
function newobject:SetMouseWheelScrollAmount(amount)
self.mousewheelscrollamount = amount
end
--[[---------------------------------------------------------
- func: GetMouseWheelScrollAmount()
- desc: gets the scroll amount of the mouse wheel
--]]---------------------------------------------------------
function newobject:GetButtonScrollAmount()
return self.mousewheelscrollamount
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- multichoice class
local newobject = loveframes.NewObject("multichoice", "loveframes_object_multichoice", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "multichoice"
self.choice = ""
self.text = "Select an option"
self.width = 200
self.height = 25
self.listpadding = 0
self.listspacing = 0
self.buttonscrollamount = 200
self.mousewheelscrollamount = 1000
self.haslist = false
self.dtscrolling = true
self.internal = false
self.choices = {}
self.listheight = nil
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawMultiChoice or skins[defaultskin].DrawMultiChoice
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local haslist = self.haslist
if hover and not haslist and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.haslist = true
self.list = loveframes.objects["multichoicelist"]:new(self)
self.list:SetState(self.state)
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
end
--[[---------------------------------------------------------
- func: AddChoice(choice)
- desc: adds a choice to the current list of choices
--]]---------------------------------------------------------
function newobject:AddChoice(choice)
local choices = self.choices
table.insert(choices, choice)
end
--[[---------------------------------------------------------
- func: SetChoice(choice)
- desc: sets the current choice
--]]---------------------------------------------------------
function newobject:SetChoice(choice)
self.choice = choice
end
--[[---------------------------------------------------------
- func: SelectChoice(choice)
- desc: selects a choice
--]]---------------------------------------------------------
function newobject:SelectChoice(choice)
local onchoiceselected = self.OnChoiceSelected
self.choice = choice
self.list:Close()
if onchoiceselected then
onchoiceselected(self, choice)
end
end
--[[---------------------------------------------------------
- func: SetListHeight(height)
- desc: sets the height of the list of choices
--]]---------------------------------------------------------
function newobject:SetListHeight(height)
self.listheight = height
end
--[[---------------------------------------------------------
- func: SetPadding(padding)
- desc: sets the padding of the list of choices
--]]---------------------------------------------------------
function newobject:SetPadding(padding)
self.listpadding = padding
end
--[[---------------------------------------------------------
- func: SetSpacing(spacing)
- desc: sets the spacing of the list of choices
--]]---------------------------------------------------------
function newobject:SetSpacing(spacing)
self.listspacing = spacing
end
--[[---------------------------------------------------------
- func: GetValue()
- desc: gets the value (choice) of the object
--]]---------------------------------------------------------
function newobject:GetValue()
return self.choice
end
--[[---------------------------------------------------------
- func: GetChoice()
- desc: gets the current choice (same as get value)
--]]---------------------------------------------------------
function newobject:GetChoice()
return self.choice
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetButtonScrollAmount(speed)
- desc: sets the scroll amount of the object's scrollbar
buttons
--]]---------------------------------------------------------
function newobject:SetButtonScrollAmount(amount)
self.buttonscrollamount = amount
end
--[[---------------------------------------------------------
- func: GetButtonScrollAmount()
- desc: gets the scroll amount of the object's scrollbar
buttons
--]]---------------------------------------------------------
function newobject:GetButtonScrollAmount()
return self.buttonscrollamount
end
--[[---------------------------------------------------------
- func: SetMouseWheelScrollAmount(amount)
- desc: sets the scroll amount of the mouse wheel
--]]---------------------------------------------------------
function newobject:SetMouseWheelScrollAmount(amount)
self.mousewheelscrollamount = amount
end
--[[---------------------------------------------------------
- func: GetMouseWheelScrollAmount()
- desc: gets the scroll amount of the mouse wheel
--]]---------------------------------------------------------
function newobject:GetButtonScrollAmount()
return self.mousewheelscrollamount
end
--[[---------------------------------------------------------
- func: SetDTScrolling(bool)
- desc: sets whether or not the object should use delta
time when scrolling
--]]---------------------------------------------------------
function newobject:SetDTScrolling(bool)
self.dtscrolling = bool
end
--[[---------------------------------------------------------
- func: GetDTScrolling()
- desc: gets whether or not the object should use delta
time when scrolling
--]]---------------------------------------------------------
function newobject:GetDTScrolling()
return self.dtscrolling
end

478
objects/numberbox.lua Normal file
View File

@ -0,0 +1,478 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- numberbox class
local newobject = loveframes.NewObject("numberbox", "loveframes_object_numberbox", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "numberbox"
self.width = 80
self.height = 20
self.value = 0
self.increaseamount = 1
self.descreaseamount = 1
self.min = -100
self.max = 100
self.delay = 0
self.internal = false
self.canmodify = false
self.lastbuttonclicked = false
self.internals = {}
self.OnValueChanged = nil
local input = loveframes.objects["textinput"]:new()
input.parent = self
input:SetSize(50, 20)
input:SetUsable({"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", ".", "-"})
input:SetText(self.value)
input.OnTextChanged = function(object)
local value = self.value
self.value = tonumber(object.lines[1])
if not self.value then
return
end
if self.value > self.max then
self.value = self.max
object:SetText(self.value)
end
if self.value < self.min then
self.value = self.min
object:SetText(self.value)
end
if value ~= self.value then
if self.OnValueChanged then
self.OnValueChanged(self, self.value)
end
end
end
input.Update = function(object)
object:SetSize(object.parent.width - 20, object.parent.height)
end
local increasebutton = loveframes.objects["button"]:new()
increasebutton.parent = self
increasebutton:SetWidth(21)
increasebutton:SetText("+")
increasebutton.OnClick = function()
local canmodify = self.canmodify
if not canmodify then
self:ModifyValue("add")
else
self.canmodify = false
end
end
increasebutton.Update = function(object)
local time = love.timer.getMicroTime()
local delay = self.delay
local down = object.down
local canmodify = self.canmodify
local lastbuttonclicked = self.lastbuttonclicked
object:SetPos(object.parent.width - 21, 0)
object:SetHeight(object.parent.height/2 + 1)
if down and not canmodify then
self:ModifyValue("add")
self.canmodify = true
self.delay = time + 0.80
self.lastbuttonclicked = object
elseif down and canmodify and delay < time then
self:ModifyValue("add")
self.delay = time + 0.02
elseif not down and canmodify and lastbuttonclicked == object then
self.canmodify = false
self.delay = time + 0.80
end
end
local decreasesbutton = loveframes.objects["button"]:new()
decreasesbutton.parent = self
decreasesbutton:SetWidth(21)
decreasesbutton:SetText("-")
decreasesbutton.OnClick = function()
local canmodify = self.canmodify
if not canmodify then
self:ModifyValue("subtract")
else
self.canmodify = false
end
end
decreasesbutton.Update = function(object)
local time = love.timer.getMicroTime()
local delay = self.delay
local down = object.down
local canmodify = self.canmodify
local lastbuttonclicked = self.lastbuttonclicked
object:SetPos(object.parent.width - 21, object.parent.height/2)
object:SetHeight(object.parent.height/2)
if down and not canmodify then
self:ModifyValue("subtract")
self.canmodify = true
self.delay = time + 0.80
self.lastbuttonclicked = object
elseif down and canmodify and delay < time then
self:ModifyValue("subtract")
self.delay = time + 0.02
elseif not down and canmodify and lastbuttonclicked == object then
self.canmodify = false
self.delay = time + 0.80
end
end
table.insert(self.internals, input)
table.insert(self.internals, increasebutton)
table.insert(self.internals, decreasesbutton)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the element
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local internals = self.internals
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent
if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
self:CheckHover()
for k, v in ipairs(internals) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local internals = self.internals
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawNumberBox or skins[defaultskin].DrawNumberBox
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
-- loop through the object's internals and draw them
for k, v in ipairs(internals) do
v:draw()
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local internals = self.internals
local hover = self.hover
if hover 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
v:mousepressed(x, y, button)
end
end
--[[---------------------------------------------------------
- func: SetValue(value)
- desc: sets the object's value
--]]---------------------------------------------------------
function newobject:SetValue(value)
local min = self.min
local curvalue = self.value
local value = tonumber(value) or min
local internals = self.internals
local input = internals[1]
local onvaluechanged = self.OnValueChanged
self.value = value
input:SetValue(value)
if value ~= curvalue then
onvaluechanged(self, value)
end
end
--[[---------------------------------------------------------
- func: GetValue()
- desc: gets the object's value
--]]---------------------------------------------------------
function newobject:GetValue()
return self.value
end
--[[---------------------------------------------------------
- func: SetIncreaseAmount(amount)
- desc: sets the object's increase amount
--]]---------------------------------------------------------
function newobject:SetIncreaseAmount(amount)
self.increaseamount = amount
end
--[[---------------------------------------------------------
- func: GetIncreaseAmount()
- desc: gets the object's increase amount
--]]---------------------------------------------------------
function newobject:GetIncreaseAmount()
return self.increaseamount
end
--[[---------------------------------------------------------
- func: SetDescreaseAmount(amount)
- desc: sets the object's decrease amount
--]]---------------------------------------------------------
function newobject:SetDescreaseAmount(amount)
self.decreaseamount = amount
end
--[[---------------------------------------------------------
- func: GetDescreaseAmount()
- desc: gets the object's decrease amount
--]]---------------------------------------------------------
function newobject:GetDescreaseAmount()
return self.decreaseamount
end
--[[---------------------------------------------------------
- func: SetMax(max)
- desc: sets the object's maximum value
--]]---------------------------------------------------------
function newobject:SetMax(max)
local internals = self.internals
local input = internals[1]
local onvaluechanged = self.OnValueChanged
self.max = max
if self.value > max then
self.value = max
input:SetValue(max)
if onvaluechanged then
onvaluechanged(self, max)
end
end
end
--[[---------------------------------------------------------
- func: GetMax()
- desc: gets the object's maximum value
--]]---------------------------------------------------------
function newobject:GetMax()
return self.max
end
--[[---------------------------------------------------------
- func: SetMin(min)
- desc: sets the object's minimum value
--]]---------------------------------------------------------
function newobject:SetMin(min)
local internals = self.internals
local input = internals[1]
local onvaluechanged = self.OnValueChanged
self.min = min
if self.value < min then
self.value = min
input:SetValue(min)
if onvaluechanged then
onvaluechanged(self, min)
end
end
end
--[[---------------------------------------------------------
- func: GetMin()
- desc: gets the object's minimum value
--]]---------------------------------------------------------
function newobject:GetMin()
return self.min
end
--[[---------------------------------------------------------
- func: SetMinMax()
- desc: sets the object's minimum and maximum values
--]]---------------------------------------------------------
function newobject:SetMinMax(min, max)
local internals = self.internals
local input = internals[1]
local onvaluechanged = self.OnValueChanged
self.min = min
self.max = max
if self.value > max then
self.value = max
input:SetValue(max)
if onvaluechanged then
onvaluechanged(self, max)
end
end
if self.value < min then
self.value = min
input:SetValue(min)
if onvaluechanged then
onvaluechanged(self, min)
end
end
end
--[[---------------------------------------------------------
- func: GetMinMax()
- desc: gets the object's minimum and maximum values
--]]---------------------------------------------------------
function newobject:GetMinMax()
return self.min, self.max
end
--[[---------------------------------------------------------
- func: ModifyValue(type)
- desc: modifies the object's value
--]]---------------------------------------------------------
function newobject:ModifyValue(type)
local value = self.value
local internals = self.internals
local input = internals[1]
local onvaluechanged = self.OnValueChanged
if not value then
return
end
if type == "add" then
local increaseamount = self.increaseamount
local max = self.max
self.value = value + increaseamount
if self.value > max then
self.value = max
end
input:SetText(self.value)
if value ~= self.value then
if onvaluechanged then
onvaluechanged(self, self.value)
end
end
elseif type == "subtract" then
local descreaseamount = self.descreaseamount
local min = self.min
self.value = value - descreaseamount
if self.value < min then
self.value = min
end
input:SetText(self.value)
if value ~= self.value then
if onvaluechanged then
onvaluechanged(self, self.value)
end
end
end
end

View File

@ -1,144 +1,172 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- panel class
local newobject = loveframes.NewObject("panel", "loveframes_object_panel", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "panel"
self.width = 200
self.height = 50
self.internal = false
self.children = {}
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the element
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local children = self.children
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent
if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
self:CheckHover()
for k, v in ipairs(children) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local children = self.children
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawPanel or skins[defaultskin].DrawPanel
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
-- loop through the object's children and draw them
for k, v in ipairs(children) do
v:draw()
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local children = self.children
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
end
for k, v in ipairs(children) do
v:mousepressed(x, y, button)
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
local children = self.children
if not visible then
return
end
for k, v in ipairs(children) do
v:mousereleased(x, y, button)
end
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- panel class
local newobject = loveframes.NewObject("panel", "loveframes_object_panel", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "panel"
self.width = 200
self.height = 50
self.internal = false
self.children = {}
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the element
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local children = self.children
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent
if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
self:CheckHover()
for k, v in ipairs(children) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local children = self.children
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawPanel or skins[defaultskin].DrawPanel
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
-- loop through the object's children and draw them
for k, v in ipairs(children) do
v:draw()
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local children = self.children
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
end
for k, v in ipairs(children) do
v:mousepressed(x, y, button)
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local children = self.children
if not visible then
return
end
for k, v in ipairs(children) do
v:mousereleased(x, y, button)
end
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- progressbar class
@ -36,6 +36,13 @@ end
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
@ -123,6 +130,13 @@ end
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then

View File

@ -1,388 +1,409 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- slider class
local newobject = loveframes.NewObject("slider", "loveframes_object_slider", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "slider"
self.text = "Slider"
self.slidetype = "horizontal"
self.width = 5
self.height = 5
self.max = 10
self.min = 0
self.value = 0
self.decimals = 5
self.internal = false
self.internals = {}
self.OnValueChanged = nil
-- create the slider button
table.insert(self.internals, loveframes.objects["sliderbutton"]:new(self))
-- set initial value to minimum
self:SetValue(self.min)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local internals = self.internals
local sliderbutton = internals[1]
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
-- move to parent if there is a parent
if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if sliderbutton then
if self.slidetype == "horizontal" then
self.height = sliderbutton.height
elseif self.slidetype == "vertical" then
self.width = sliderbutton.width
end
end
-- update internals
for k, v in ipairs(self.internals) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local internals = self.internals
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawSlider or skins[defaultskin].DrawSlider
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
-- draw internals
for k, v in ipairs(internals) do
v:draw()
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local internals = self.internals
if self.hover and button == "l" then
if self.slidetype == "horizontal" then
local xpos = x - self.x
local button = internals[1]
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
button:MoveToX(xpos)
button.down = true
button.dragging = true
button.startx = button.staticx
button.clickx = x
elseif self.slidetype == "vertical" then
local ypos = y - self.y
local button = internals[1]
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
button:MoveToY(ypos)
button.down = true
button.dragging = true
button.starty = button.staticy
button.clicky = y
end
end
for k, v in ipairs(internals) do
v:mousepressed(x, y, button)
end
end
--[[---------------------------------------------------------
- func: SetValue(value)
- desc: sets the object's value
--]]---------------------------------------------------------
function newobject:SetValue(value)
if value > self.max then
return
end
if value < self.min then
return
end
local decimals = self.decimals
local newval = loveframes.util.Round(value, decimals)
local internals = self.internals
local onvaluechanged = self.OnValueChanged
-- set the new value
self.value = newval
-- slider button object
local sliderbutton = internals[1]
local slidetype = self.slidetype
local width = self.width
local height = self.height
local min = self.min
local max = self.max
-- move the slider button to the new position
if slidetype == "horizontal" then
local xpos = width * ((newval - min) / (max - min))
sliderbutton:MoveToX(xpos)
elseif slidetype == "vertical" then
local ypos = height - height * ((newval - min) / (max - min))
sliderbutton:MoveToY(ypos)
end
-- call OnValueChanged
if onvaluechanged then
onvaluechanged(self)
end
end
--[[---------------------------------------------------------
- func: GetValue()
- desc: gets the object's value
--]]---------------------------------------------------------
function newobject:GetValue()
return self.value
end
--[[---------------------------------------------------------
- func: SetMax(max)
- desc: sets the object's maximum value
--]]---------------------------------------------------------
function newobject:SetMax(max)
self.max = max
if self.value > self.max then
self.value = self.max
end
end
--[[---------------------------------------------------------
- func: GetMax()
- desc: gets the object's maximum value
--]]---------------------------------------------------------
function newobject:GetMax()
return self.max
end
--[[---------------------------------------------------------
- func: SetMin(min)
- desc: sets the object's minimum value
--]]---------------------------------------------------------
function newobject:SetMin(min)
self.min = min
if self.value < self.min then
self.value = self.min
end
end
--[[---------------------------------------------------------
- func: GetMin()
- desc: gets the object's minimum value
--]]---------------------------------------------------------
function newobject:GetMin()
return self.min
end
--[[---------------------------------------------------------
- func: SetMinMax()
- desc: sets the object's minimum and maximum values
--]]---------------------------------------------------------
function newobject:SetMinMax(min, max)
self.min = min
self.max = max
if self.value > self.max then
self.value = self.max
end
if self.value < self.min then
self.value = self.min
end
end
--[[---------------------------------------------------------
- func: GetMinMax()
- desc: gets the object's minimum and maximum values
--]]---------------------------------------------------------
function newobject:GetMinMax()
return self.min, self.max
end
--[[---------------------------------------------------------
- func: SetText(name)
- desc: sets the objects's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the objects's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetDecimals(decimals)
- desc: sets the objects's decimals
--]]---------------------------------------------------------
function newobject:SetDecimals(decimals)
self.decimals = decimals
end
--[[---------------------------------------------------------
- func: SetButtonSize(width, height)
- desc: sets the objects's button size
--]]---------------------------------------------------------
function newobject:SetButtonSize(width, height)
local internals = self.internals
local sliderbutton = internals[1]
if sliderbutton then
sliderbutton.width = width
sliderbutton.height = height
end
end
--[[---------------------------------------------------------
- func: GetButtonSize()
- desc: gets the objects's button size
--]]---------------------------------------------------------
function newobject:GetButtonSize()
local internals = self.internals
local sliderbutton = internals[1]
if sliderbutton then
return sliderbutton.width, sliderbutton.height
else
return false
end
end
--[[---------------------------------------------------------
- func: SetSlideType(slidetype)
- desc: sets the objects's slide type
--]]---------------------------------------------------------
function newobject:SetSlideType(slidetype)
self.slidetype = slidetype
if slidetype == "vertical" then
self:SetValue(self.min)
end
end
--[[---------------------------------------------------------
- func: GetSlideType()
- desc: gets the objects's slide type
--]]---------------------------------------------------------
function newobject:GetSlideType()
return self.slidetype
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- slider class
local newobject = loveframes.NewObject("slider", "loveframes_object_slider", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "slider"
self.text = "Slider"
self.slidetype = "horizontal"
self.width = 5
self.height = 5
self.max = 10
self.min = 0
self.value = 0
self.decimals = 5
self.internal = false
self.internals = {}
self.OnValueChanged = nil
-- create the slider button
local sliderbutton = loveframes.objects["sliderbutton"]:new(self)
sliderbutton.state = self.state
table.insert(self.internals, sliderbutton)
-- set initial value to minimum
self:SetValue(self.min)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local internals = self.internals
local sliderbutton = internals[1]
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
-- move to parent if there is a parent
if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if sliderbutton then
if self.slidetype == "horizontal" then
self.height = sliderbutton.height
elseif self.slidetype == "vertical" then
self.width = sliderbutton.width
end
end
-- update internals
for k, v in ipairs(self.internals) do
v:update(dt)
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local internals = self.internals
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawSlider or skins[defaultskin].DrawSlider
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
-- draw internals
for k, v in ipairs(internals) do
v:draw()
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local internals = self.internals
if self.hover and button == "l" then
if self.slidetype == "horizontal" then
local xpos = x - self.x
local button = internals[1]
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
button:MoveToX(xpos)
button.down = true
button.dragging = true
button.startx = button.staticx
button.clickx = x
elseif self.slidetype == "vertical" then
local ypos = y - self.y
local button = internals[1]
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
button:MoveToY(ypos)
button.down = true
button.dragging = true
button.starty = button.staticy
button.clicky = y
end
end
for k, v in ipairs(internals) do
v:mousepressed(x, y, button)
end
end
--[[---------------------------------------------------------
- func: SetValue(value)
- desc: sets the object's value
--]]---------------------------------------------------------
function newobject:SetValue(value)
if value > self.max then
return
end
if value < self.min then
return
end
local decimals = self.decimals
local newval = loveframes.util.Round(value, decimals)
local internals = self.internals
local onvaluechanged = self.OnValueChanged
-- set the new value
self.value = newval
-- slider button object
local sliderbutton = internals[1]
local slidetype = self.slidetype
local width = self.width
local height = self.height
local min = self.min
local max = self.max
-- move the slider button to the new position
if slidetype == "horizontal" then
local xpos = width * ((newval - min) / (max - min))
sliderbutton:MoveToX(xpos)
elseif slidetype == "vertical" then
local ypos = height - height * ((newval - min) / (max - min))
sliderbutton:MoveToY(ypos)
end
-- call OnValueChanged
if onvaluechanged then
onvaluechanged(self)
end
end
--[[---------------------------------------------------------
- func: GetValue()
- desc: gets the object's value
--]]---------------------------------------------------------
function newobject:GetValue()
return self.value
end
--[[---------------------------------------------------------
- func: SetMax(max)
- desc: sets the object's maximum value
--]]---------------------------------------------------------
function newobject:SetMax(max)
self.max = max
if self.value > self.max then
self.value = self.max
end
end
--[[---------------------------------------------------------
- func: GetMax()
- desc: gets the object's maximum value
--]]---------------------------------------------------------
function newobject:GetMax()
return self.max
end
--[[---------------------------------------------------------
- func: SetMin(min)
- desc: sets the object's minimum value
--]]---------------------------------------------------------
function newobject:SetMin(min)
self.min = min
if self.value < self.min then
self.value = self.min
end
end
--[[---------------------------------------------------------
- func: GetMin()
- desc: gets the object's minimum value
--]]---------------------------------------------------------
function newobject:GetMin()
return self.min
end
--[[---------------------------------------------------------
- func: SetMinMax()
- desc: sets the object's minimum and maximum values
--]]---------------------------------------------------------
function newobject:SetMinMax(min, max)
self.min = min
self.max = max
if self.value > self.max then
self.value = self.max
end
if self.value < self.min then
self.value = self.min
end
end
--[[---------------------------------------------------------
- func: GetMinMax()
- desc: gets the object's minimum and maximum values
--]]---------------------------------------------------------
function newobject:GetMinMax()
return self.min, self.max
end
--[[---------------------------------------------------------
- func: SetText(name)
- desc: sets the objects's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the objects's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetDecimals(decimals)
- desc: sets the objects's decimals
--]]---------------------------------------------------------
function newobject:SetDecimals(decimals)
self.decimals = decimals
end
--[[---------------------------------------------------------
- func: SetButtonSize(width, height)
- desc: sets the objects's button size
--]]---------------------------------------------------------
function newobject:SetButtonSize(width, height)
local internals = self.internals
local sliderbutton = internals[1]
if sliderbutton then
sliderbutton.width = width
sliderbutton.height = height
end
end
--[[---------------------------------------------------------
- func: GetButtonSize()
- desc: gets the objects's button size
--]]---------------------------------------------------------
function newobject:GetButtonSize()
local internals = self.internals
local sliderbutton = internals[1]
if sliderbutton then
return sliderbutton.width, sliderbutton.height
end
end
--[[---------------------------------------------------------
- func: SetSlideType(slidetype)
- desc: sets the objects's slide type
--]]---------------------------------------------------------
function newobject:SetSlideType(slidetype)
self.slidetype = slidetype
if slidetype == "vertical" then
self:SetValue(self.min)
end
end
--[[---------------------------------------------------------
- func: GetSlideType()
- desc: gets the objects's slide type
--]]---------------------------------------------------------
function newobject:GetSlideType()
return self.slidetype
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
# Love Frames
## Information
Love Frames is a GUI library for [LOVE](https://love2d.org/). For information on installation and usage, please visit the [wiki](https://github.com/NikolaiResokav/LoveFrames/wiki). A demo of the library can be found at: http://nikolairesokav.com/projects/loveframes/
## License
Love Frames is licensed under the Creative Commons Attribution 3.0 Unported (CC BY 3.0) license.
For more information on this license, please read license.txt or visit this web page: http://creativecommons.org/licenses/by/3.0/
## Credits
Created by Kenny Shields
**Third-Party Libraries**
# Love Frames
## Information
Love Frames is a GUI library for [LOVE](https://love2d.org/). For information on installation and usage, please visit the [wiki](http://nikolairesokav.com/documents/?page=loveframes/main). A demo of the library can be found at: http://nikolairesokav.com/projects/loveframes/
## License
Love Frames is licensed under the Creative Commons Attribution 3.0 Unported (CC BY 3.0) license.
For more information on this license, please read license.txt or visit this web page: http://creativecommons.org/licenses/by/3.0/
## Credits
Created by Kenny Shields
**Third-Party Libraries**
- middleclass by kikito - https://github.com/kikito/middleclass

138
skins.lua
View File

@ -1,70 +1,70 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- skins library
loveframes.skins = {}
-- available skins
loveframes.skins.available = {}
--[[---------------------------------------------------------
- func: Register(skin)
- desc: registers a skin
--]]---------------------------------------------------------
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 indeximages = loveframes.config["INDEXSKINIMAGES"]
if name == "" or not name then
loveframes.util.Error("Could not register skin: Invalid or missing name data.")
end
if author == "" or not author then
loveframes.util.Error("Could not register skin: Invalid or missing author data.")
end
if version == "" or version == nil then
loveframes.util.Error("Could not register skin: Invalid or missing version data.")
end
if namecheck then
loveframes.util.Error("Could not register skin: A skin with the name '" ..name.. "' already exists.")
end
if not dircheck then
loveframes.util.Error("Could not register skin: Could not find a directory for skin '" ..name.. "'.")
end
loveframes.skins.available[name] = skin
loveframes.skins.available[name].dir = dir
loveframes.skins.available[name].images = {}
if #images > 0 and indeximages == true then
for k, v in ipairs(images) do
loveframes.skins.available[name].images[v.name .. "." .. v.extension] = love.graphics.newImage(v.fullpath)
end
end
end
--[[---------------------------------------------------------
- func: GetAvailable()
- desc: gets all available skins
--]]---------------------------------------------------------
function loveframes.skins.GetAvailable()
local available = loveframes.skins.available
return available
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- skins library
loveframes.skins = {}
-- available skins
loveframes.skins.available = {}
--[[---------------------------------------------------------
- func: Register(skin)
- desc: registers a skin
--]]---------------------------------------------------------
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 indeximages = loveframes.config["INDEXSKINIMAGES"]
if name == "" or not name then
loveframes.util.Error("Could not register skin: Invalid or missing name data.")
end
if author == "" or not author then
loveframes.util.Error("Could not register skin: Invalid or missing author data.")
end
if version == "" or version == nil then
loveframes.util.Error("Could not register skin: Invalid or missing version data.")
end
if namecheck then
loveframes.util.Error("Could not register skin: A skin with the name '" ..name.. "' already exists.")
end
if not dircheck then
loveframes.util.Error("Could not register skin: Could not find a directory for skin '" ..name.. "'.")
end
loveframes.skins.available[name] = skin
loveframes.skins.available[name].dir = dir
loveframes.skins.available[name].images = {}
if #images > 0 and indeximages == true then
for k, v in ipairs(images) do
loveframes.skins.available[name].images[v.name .. "." .. v.extension] = love.graphics.newImage(v.fullpath)
end
end
end
--[[---------------------------------------------------------
- func: GetAvailable()
- desc: gets all available skins
--]]---------------------------------------------------------
function loveframes.skins.GetAvailable()
local available = loveframes.skins.available
return available
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 284 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 284 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 284 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 284 B

File diff suppressed because it is too large Load Diff

View File

@ -1,175 +1,175 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- templates library
loveframes.templates = {}
-- available templates
loveframes.templates.available = {}
-- objects
loveframes.templates.objects = {}
--[[---------------------------------------------------------
- func: AddProperty(templatename, property, value)
- desc: creates a property within the specified template
and assigns it to the specified object
--]]---------------------------------------------------------
function loveframes.templates.AddProperty(templatename, object, property, value)
-- 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 an error if property is nil or false
if not property then
loveframes.util.Error("Could not create property: No property name given.")
end
local templatename = tostring(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
loveframes.util.Error("Could not create property: Property names must be strings.")
end
-- display an error message if the property is an empty string
if property == "" then
loveframes.util.Error("Could not create property: Property names must not be empty.")
end
-- display an error message if the template is invalid
if not template then
loveframes.util.Error("Could not add property '" ..property.. "' to template '" ..templatename.. "': Invalid template.")
end
local properties = template.properties
local object = properties[object]
if not object then
loveframes.util.Error("Could not add property '" ..property.. "' to template '" ..templatename.. "': Invalid object.")
end
-- create the property within the template
object[property] = value
end
--[[---------------------------------------------------------
- func: Register(template)
- desc: registers a template
--]]---------------------------------------------------------
function loveframes.templates.Register(template)
-- display and error message if template is nil or false
if not template then
loveframes.util.Error("Could not register template: Missing template argument.")
end
-- display an error message if template is not a table
if type(template) ~= "table" then
loveframes.util.Error("Could not register template: Template argument must be a table.")
end
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
-- display an error message if a template name was not given
if not name then
loveframes.util.Error("Could not register template: No template name given.")
end
if name == "Base" then
base:include(template.properties["*"])
end
-- insert the template into the available templates table
templates[name] = template
end
--[[---------------------------------------------------------
- func: Get(name)
- desc: gets a template
--]]---------------------------------------------------------
function loveframes.templates.Get(name)
-- display and error if name is nil or false
if not name then
loveframes.util.Error("Could not create property: No template name given.")
end
local name = tostring(name)
local templates = loveframes.templates.available
local template = templates[name]
-- display an error message if the template is invalid
if not template then
loveframes.util.Error("Could not get template: Invalid template.")
end
-- return the template
return template
end
--[[---------------------------------------------------------
- func: GetAvailable()
- desc: gets all available templates
--]]---------------------------------------------------------
function loveframes.templates.GetAvailable()
-- available templates
local templates = loveframes.templates.available
-- return the templates
return templates
end
--[[---------------------------------------------------------
- func: loveframes.templates.ApplyToObject(object)
- desc: applies the properties of registered templates
to an object
--]]---------------------------------------------------------
function loveframes.templates.ApplyToObject(object)
local templates = loveframes.templates.GetAvailable()
local type = object.type
-- 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
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
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- templates library
loveframes.templates = {}
-- available templates
loveframes.templates.available = {}
-- objects
loveframes.templates.objects = {}
--[[---------------------------------------------------------
- func: AddProperty(templatename, property, value)
- desc: creates a property within the specified template
and assigns it to the specified object
--]]---------------------------------------------------------
function loveframes.templates.AddProperty(templatename, object, property, value)
-- 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 an error if property is nil or false
if not property then
loveframes.util.Error("Could not create property: No property name given.")
end
local templatename = tostring(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
loveframes.util.Error("Could not create property: Property names must be strings.")
end
-- display an error message if the property is an empty string
if property == "" then
loveframes.util.Error("Could not create property: Property names must not be empty.")
end
-- display an error message if the template is invalid
if not template then
loveframes.util.Error("Could not add property '" ..property.. "' to template '" ..templatename.. "': Invalid template.")
end
local properties = template.properties
local object = properties[object]
if not object then
loveframes.util.Error("Could not add property '" ..property.. "' to template '" ..templatename.. "': Invalid object.")
end
-- create the property within the template
object[property] = value
end
--[[---------------------------------------------------------
- func: Register(template)
- desc: registers a template
--]]---------------------------------------------------------
function loveframes.templates.Register(template)
-- display and error message if template is nil or false
if not template then
loveframes.util.Error("Could not register template: Missing template argument.")
end
-- display an error message if template is not a table
if type(template) ~= "table" then
loveframes.util.Error("Could not register template: Template argument must be a table.")
end
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
-- display an error message if a template name was not given
if not name then
loveframes.util.Error("Could not register template: No template name given.")
end
if name == "Base" then
base:include(template.properties["*"])
end
-- insert the template into the available templates table
templates[name] = template
end
--[[---------------------------------------------------------
- func: Get(name)
- desc: gets a template
--]]---------------------------------------------------------
function loveframes.templates.Get(name)
-- display and error if name is nil or false
if not name then
loveframes.util.Error("Could not create property: No template name given.")
end
local name = tostring(name)
local templates = loveframes.templates.available
local template = templates[name]
-- display an error message if the template is invalid
if not template then
loveframes.util.Error("Could not get template: Invalid template.")
end
-- return the template
return template
end
--[[---------------------------------------------------------
- func: GetAvailable()
- desc: gets all available templates
--]]---------------------------------------------------------
function loveframes.templates.GetAvailable()
-- available templates
local templates = loveframes.templates.available
-- return the templates
return templates
end
--[[---------------------------------------------------------
- func: loveframes.templates.ApplyToObject(object)
- desc: applies the properties of registered templates
to an object
--]]---------------------------------------------------------
function loveframes.templates.ApplyToObject(object)
local templates = loveframes.templates.GetAvailable()
local type = object.type
-- 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
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

View File

@ -1 +1 @@
--[[------------------------------------------------ -- Love Frames - A GUI library for LOVE -- -- Copyright (c) 2012 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["*"] = { x = 0, y = 0, width = 5, height = 5, staticx = 0, staticy = 0, draworder = 0, 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)
--[[------------------------------------------------ -- Love Frames - A GUI library for LOVE -- -- Copyright (c) 2013 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, 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)

560
util.lua
View File

@ -1,280 +1,282 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- util library
loveframes.util = {}
--[[---------------------------------------------------------
- func: SetActiveSkin(name)
- desc: sets the active skin
--]]---------------------------------------------------------
function loveframes.util.SetActiveSkin(name)
loveframes.config["ACTIVESKIN"] = name
end
--[[---------------------------------------------------------
- func: GetActiveSkin()
- desc: gets the active skin
--]]---------------------------------------------------------
function loveframes.util.GetActiveSkin()
local index = loveframes.config["ACTIVESKIN"]
local skin = loveframes.skins.available[index]
return skin
end
--[[---------------------------------------------------------
- func: BoundingBox(x1, x2, y1, y2, w1, w2, h1, h2)
- desc: checks for a collision between two boxes
- note: i take no credit for this function
--]]---------------------------------------------------------
function loveframes.util.BoundingBox(x1, x2, y1, y2, w1, w2, h1, h2)
if x1 > x2 + w2 - 1 or y1 > y2 + h2 - 1 or x2 > x1 + w1 - 1 or y2 > y1 + h1 - 1 then
return false
else
return true
end
end
--[[---------------------------------------------------------
- func: loveframes.util.GetCollisions(object, table)
- desc: gets all objects colliding with the mouse
--]]---------------------------------------------------------
function loveframes.util.GetCollisions(object, t)
local x, y = love.mouse.getPosition()
local object = object or loveframes.base
local t = t or {}
-- 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)
if clickcol then
table.insert(t, object)
end
else
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
end
--[[---------------------------------------------------------
- func: loveframes.util.GetAllObjects(object, table)
- desc: gets all active objects
--]]---------------------------------------------------------
function loveframes.util.GetAllObjects(object, t)
local object = object or loveframes.base
local t = t or {}
table.insert(t, object)
if object.internals then
for k, v in ipairs(object.internals) do
loveframes.util.GetAllObjects(v, t)
end
end
if object.children then
for k, v in ipairs(object.children) do
loveframes.util.GetAllObjects(v, t)
end
end
return t
end
--[[---------------------------------------------------------
- func: GetDirectoryContents(directory, table)
- desc: gets the contents of a directory and all of
it's subdirectories
--]]---------------------------------------------------------
function loveframes.util.GetDirectoryContents(dir, t)
local dir = dir
local t = t or {}
local files = love.filesystem.enumerate(dir)
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
local parts = loveframes.util.SplitString(v, "([.])")
local extension = parts[#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
end
if #dirs > 0 then
for k, v in ipairs(dirs) do
t = loveframes.util.GetDirectoryContents(v, t)
end
end
return t
end
--[[---------------------------------------------------------
- func: Round(num, idp)
- desc: rounds a number based on the decimal limit
- note: i take no credit for this function
--]]---------------------------------------------------------
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
end
--[[---------------------------------------------------------
- func: SplitString(string, pattern)
- desc: splits a string into a table based on a given pattern
- note: i take no credit for this function
--]]---------------------------------------------------------
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)
while s do
if s ~= #str then
cap = cap .. " "
end
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
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)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
end
return t
end
--[[---------------------------------------------------------
- func: RemoveAll()
- desc: removes all gui elements
--]]---------------------------------------------------------
function loveframes.util.RemoveAll()
loveframes.base.children = {}
loveframes.base.internals = {}
end
--[[---------------------------------------------------------
- func: loveframes.util.TableHasKey(table, key)
- desc: checks to see if a table has a specific key
--]]---------------------------------------------------------
function loveframes.util.TableHasKey(table, key)
local haskey = false
for k, v in pairs(table) do
if k == key then
haskey = true
break
end
end
return haskey
end
--[[---------------------------------------------------------
- func: loveframes.util.Error(message)
- desc: displays a formatted error message
--]]---------------------------------------------------------
function loveframes.util.Error(message)
error("[Love Frames] " ..message)
end
--[[---------------------------------------------------------
- func: loveframes.util.CheckForUpdates()
- desc: checks for more recent versions of Love Frames
--]]---------------------------------------------------------
function loveframes.util.CheckForUpdates()
local info = loveframes.info
local version = info.version
local stage = info.stage
local socket = require("socket.http")
local b, c, h = socket.request("http://update.nikolairesokav.com/?id=loveframes&version=" ..version.. "&stage=" ..stage)
if c == 200 then
return b
else
return "An error occurred while checking for updates. Please try again later."
end
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- util library
loveframes.util = {}
--[[---------------------------------------------------------
- func: SetActiveSkin(name)
- desc: sets the active skin
--]]---------------------------------------------------------
function loveframes.util.SetActiveSkin(name)
loveframes.config["ACTIVESKIN"] = name
end
--[[---------------------------------------------------------
- func: GetActiveSkin()
- desc: gets the active skin
--]]---------------------------------------------------------
function loveframes.util.GetActiveSkin()
local index = loveframes.config["ACTIVESKIN"]
local skin = loveframes.skins.available[index]
return skin
end
--[[---------------------------------------------------------
- func: BoundingBox(x1, x2, y1, y2, w1, w2, h1, h2)
- desc: checks for a collision between two boxes
- note: i take no credit for this function
--]]---------------------------------------------------------
function loveframes.util.BoundingBox(x1, x2, y1, y2, w1, w2, h1, h2)
if x1 > x2 + w2 - 1 or y1 > y2 + h2 - 1 or x2 > x1 + w1 - 1 or y2 > y1 + h1 - 1 then
return false
else
return true
end
end
--[[---------------------------------------------------------
- func: loveframes.util.GetCollisions(object, table)
- desc: gets all objects colliding with the mouse
--]]---------------------------------------------------------
function loveframes.util.GetCollisions(object, t)
local x, y = love.mouse.getPosition()
local object = object or loveframes.base
local t = t or {}
-- 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)
if clickcol then
table.insert(t, object)
end
else
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
end
--[[---------------------------------------------------------
- func: loveframes.util.GetAllObjects(object, table)
- desc: gets all active objects
--]]---------------------------------------------------------
function loveframes.util.GetAllObjects(object, t)
local object = object or loveframes.base
local internals = object.internals
local children = object.children
local t = t or {}
table.insert(t, object)
if internals then
for k, v in ipairs(internals) do
loveframes.util.GetAllObjects(v, t)
end
end
if children then
for k, v in ipairs(children) do
loveframes.util.GetAllObjects(v, t)
end
end
return t
end
--[[---------------------------------------------------------
- func: GetDirectoryContents(directory, table)
- desc: gets the contents of a directory and all of
it's subdirectories
--]]---------------------------------------------------------
function loveframes.util.GetDirectoryContents(dir, t)
local dir = dir
local t = t or {}
local files = love.filesystem.enumerate(dir)
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
local parts = loveframes.util.SplitString(v, "([.])")
local extension = parts[#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
end
if #dirs > 0 then
for k, v in ipairs(dirs) do
t = loveframes.util.GetDirectoryContents(v, t)
end
end
return t
end
--[[---------------------------------------------------------
- func: Round(num, idp)
- desc: rounds a number based on the decimal limit
- note: i take no credit for this function
--]]---------------------------------------------------------
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
end
--[[---------------------------------------------------------
- func: SplitString(string, pattern)
- desc: splits a string into a table based on a given pattern
- note: i take no credit for this function
--]]---------------------------------------------------------
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)
while s do
if s ~= #str then
cap = cap .. " "
end
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
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)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
end
return t
end
--[[---------------------------------------------------------
- func: RemoveAll()
- desc: removes all gui elements
--]]---------------------------------------------------------
function loveframes.util.RemoveAll()
loveframes.base.children = {}
loveframes.base.internals = {}
end
--[[---------------------------------------------------------
- func: loveframes.util.TableHasKey(table, key)
- desc: checks to see if a table has a specific key
--]]---------------------------------------------------------
function loveframes.util.TableHasKey(table, key)
local haskey = false
for k, v in pairs(table) do
if k == key then
haskey = true
break
end
end
return haskey
end
--[[---------------------------------------------------------
- func: loveframes.util.Error(message)
- desc: displays a formatted error message
--]]---------------------------------------------------------
function loveframes.util.Error(message)
error("[Love Frames] " ..message)
end
--[[---------------------------------------------------------
- func: loveframes.util.CheckForUpdates()
- desc: checks for more recent versions of Love Frames
--]]---------------------------------------------------------
function loveframes.util.CheckForUpdates()
local info = loveframes.info
local version = info.version
local stage = info.stage
local socket = require("socket.http")
local b, c, h = socket.request("http://update.nikolairesokav.com/?id=loveframes&version=" ..version.. "&stage=" ..stage)
if c == 200 then
return b
else
return "An error occurred while checking for updates. Please try again later."
end
end