AggrorJorn Posted July 12, 2010 Share Posted July 12, 2010 File Name: LuaGui File Submitter: Aggror File Submitted: 12 Jul 2010 File Updated: 29 Jul 2010 File Category: Lua Scripts LuaGui is an easy to use GUI command set. It is not really finished but can allready be used for your game project. The zip file contains several example files. Feel free to use or change LuaGui to your needs. Happy GUI writing! If you have any questions: don't hesitate to ask! Possibilities with LuaGui - Create a button (normal mode, hover mode and mousedown mode.) - Position the button on screen. - Draw text inside your button. - Specify the position of your text inside the button. - Let LuaGui automaticly addept your buttons to different resolutions. - Create a checkbox. - Create a slider button. - Easy handling of mouse events or when a checkbox is checked/unchecked. NOTE. This is still a work in progress. - The event handling will eventually be combined with callbacks.- Working on a slider and editbox. Commands: Create a button. buttonName = LuaGui.CreateButton() Specify a base resolution. lets say you make a button for a resolution of 1800 x 1200. The person playing your game has a resolution of 1440 x 900. If you set the base resolution command, LuaGui will automaticly scale and position your button according to the right resolution. buttonName:SetBaseResolution(1400,900) Specify the images that the button uses. (normal mode, hover mode and mousedown mode.) buttonName:SetImages("abstract::play_N.dds","abstract::play_H.dds","abstract::play_C.dds") Specify a position for the button. buttonName:SetPosition(200,200) Add some text to your button. buttonName:SetText("Leadwerks") Set the position of the text. See the image for the positions. The second and third parameter can be used for margins buttonName:SetTextPosition("BottomRight",0,0) http://leadwerks.com/werkspace/index.php?app=core&module=attach§ion=attach&attach_rel_module=post&attach_id=901 Set a different font for your button. buttonName:SetButtonFont("Arial12Shadow") Create a mouse event for when the mouse is clicked: MouseClicked(). The parameter can be used to specify which mouse button. 1 = left mouse button. 2 = right mouse button. 3 = mousewheel if button1:MouseClicked(1)==1 then test = test + 1 end Create a mouse event for when the mouse is clicked: MouseClicked(). The parameter can be used to specify which mouse button. 1 = left mouse button. 2 = right mouse button. 3 = mousewheel if button1:MouseDown(2)==1 then test = test - 1 end Create a checkbox. checkboxName = LuaGui.CreateCheckBox() Specify an 'unchecked' button and a 'checked' button. checkboxName:SetImages("abstract::unchecked.dds","abstract::checked.dds") Create an event for the CheckBox if checkbox1:Checked()==1 then test = 1 else test = 0 end Create a Slider. sliderName = LuaGui.CreateSlider() Specify the images that the slider uses. (normal mode, hover mode, mousedown mode and a background.) sliderName:SetImages("abstract::slider2_N.dds","abstract::slider2_H.dds","abstract::slider2_C.dds","abstract::slider2_B.dds") Specify whether the slider is horizontal or vertical. Horizontal by default. sliderName:SetDirection("vertical") Set the slider values. First 2 parameters: starting X and Y position of the slider. The last 2 parameters: minimum and maximum X or Y values. sliderName:SetValues(100,150,100,200) Returns the value of the slider button in percentages from 0 - 100. variable = sliderName:GetValue() LuaGui.zip Quote Link to comment Share on other sites More sharing options...
Pancakes Posted July 13, 2010 Share Posted July 13, 2010 book marked, downloaded, and ready to rock ^^ thanks Aggror Quote Core I5 2.67 / 16GB RAM / GTX 670 Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3 Link to comment Share on other sites More sharing options...
ZioRed Posted July 13, 2010 Share Posted July 13, 2010 Glad to see your work, just thinking that Position could be SetPosition as all the other methods Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 13, 2010 Author Share Posted July 13, 2010 @Pancakes: hope it can help you. @Ziored: I was thinking about that, but then I face a problem. This is the current function: --Place the button on an X and Y position. Also adjusts the position according to the resolution. function LuaGui:Position(x,y) self.buttonX = x * self.scaleX self.buttonY = y * self.scaleY end The x and y position are adjusted according to the resolution. If I remove these 2 lines, the correct position is no longer calculated. Perhaps I can fit it in the UpdateButton(). Thanks! Quote Link to comment Share on other sites More sharing options...
gordonramp Posted July 13, 2010 Share Posted July 13, 2010 Giving it a try.. Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
ZioRed Posted July 13, 2010 Share Posted July 13, 2010 @Ziored: I was thinking about that, but then I face a problem. This is the current function: --Place the button on an X and Y position. Also adjusts the position according to the resolution. function LuaGui:Position(x,y) self.buttonX = x * self.scaleX self.buttonY = y * self.scaleY end The x and y position are adjusted according to the resolution. If I remove these 2 lines, the correct position is no longer calculated. Perhaps I can fit it in the UpdateButton(). Thanks! I was only speaking about the name of the method, not its code content... I don't know very well how Lua works, perhaps there is already a global "SetPosition" method for any new object? Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 13, 2010 Author Share Posted July 13, 2010 I assumed that I couldn't use the SetPosition command because the LE command set for Lua already contains such a command. But I tried it out and it seems to work okay. I do not fully understand how this is possible though. Quote Link to comment Share on other sites More sharing options...
ZioRed Posted July 14, 2010 Share Posted July 14, 2010 I do not fully understand how this is possible though. Because SetPosition is a method and not a global function (LE's is PositionEntity) of a model object and your classes are not extending it but are new classes Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 29, 2010 Author Share Posted July 29, 2010 The slider button seems to be working. Tweaking stuff here and there to get some better results. A little video: http://visualknights.com/leadwerks/slider.mp4 The dropdown button hasn't been going that well but it will work eventually. And after that I will try to make edit boxes. Quote Link to comment Share on other sites More sharing options...
gordonramp Posted July 29, 2010 Share Posted July 29, 2010 Nice.. Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
dennis Posted October 13, 2011 Share Posted October 13, 2011 is this project still online? because I can't download it anymore Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 13, 2011 Author Share Posted October 13, 2011 Found it in a backup: http://www.leadwerks.com/werkspace/index.php?app=core&module=attach§ion=attach&attach_id=2758 Quote Link to comment Share on other sites More sharing options...
dennis Posted October 14, 2011 Share Posted October 14, 2011 Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.