Jump to content

LuaGui


AggrorJorn
 Share

Recommended Posts

Had to repost due to the server change. Here is WIP 1:

http://www.youtube.com/watch?v=Ai-c0Vyop1w

 

WIP 2.

Small update on the simple LuaGui.

You can easily add text:

button1:SetButtonText("Leadwerks")

 

Set a font:

button1:SetButtonFont("Arial12Shadow")

 

Set the fontcolor for normal, hover and click:

button1:SetFontColor(Vec4(0,0,1,1),Vec4(0,1,0,1),Vec4(1,1,0,1))

 

Set the text position to the 9 button positions (see the image) and the margin on the X and Y axis.

button1:SetTextPosition("UpperLeft",0,0)

 

post-45-12770495847777_thumb.png

 

 

WIP 3.

This was made way quicker then I had anticipated:

Autoscaling and AutoPositioning for different resolutions.

button1:SetBaseResolution(400,300)

Important!

Has to be placed directly after the button has been created!

 

Lets say you create a button in a screen 400 x 300. The button is placed at Vec2(50,50) and has a size of 75 x 30.

When the user uses a new resolution of 800 x 600, your image would be the same size and still be placed at Vec2(50,50).

With the SetBaseResolution() command the new position of the button would be Vec2(100,100) and the size of the button would be 150 x 60.

Link to comment
Share on other sites

So far it has been quite fun to make this. I think that I am going to extend this with extra button types after all :D. Never created such a working and functional project before.

 

At the moment 1 button can be used with the following:

--Creation and reslution
button1 = LuaGui.CreateButton()
button1:SetBaseResolution(400,300)

--images and position
button1:SetImages("abstract::a.dds","abstract::a.dds","abstract::a.dds")
button1:Position(0,100)

--text
button1:SetButtonFont("Arial12Shadow")
button1:SetFontColor(Vec4(0,0,1,1),Vec4(0,1,0,1),Vec4(1,1,0,1))
button1:SetButtonText("Leadwerks")
button1:SetTextPosition("Center",0,0)

--main loop
button1:UpdateButton()

button1:MouseClicked()
button1:MouseHold()

--main loop, after fw:Render()
button1:DrawButton()

 

Only thing left to do is creating callbacks or callback function for the Mouse events. Instead of having the main loop to constanly check for an event, you can make the event before the main loop (like a function).

 

 

Feedback welcome. Do you like the function names? For instance:

 

button1:SetButtonText("Leadwerks")
button1:SetTextPosition("Center",0,0)

 

or

 

button1:SetButtonText("Leadwerks")
button1:SetButtonTextPosition("Center",0,0)

This, to create more consistency in the functions name. But at the cost of the length of a function name.

Link to comment
Share on other sites

Looks good.

 

I have only small comment to method names. You don't need add "Button" to method again when object is inherited from button class. Developer knows of what was created.

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Link to comment
Share on other sites

  • 1 year later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...