AlfaSub's Widget Window System v0.1

AlfaSub's Widget Window System v0.1

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
AlfaSub
Posts: 17
Joined: 07 Feb 2006, 20:28

AlfaSub's Widget Window System v0.1

Post by AlfaSub »

I've seen several people on this forum talk about creating a general window system for the Lua UI, but haven't actually seen it materialize. As I've had a ton of free time recently, I decided to give it a shot, and actually am somewhat proud of the result.

FEATURES (v0.1)
- easily create scalable windows, which can have as many child windows as your heart desires
- pre-coded button and drag controls
- window manager that automatically handles most basic widget calls
- helper functions that take some of the pain out of learning the new system

I coded an example camera widget to demonstrate a lot of these features, and it ended up requiring less than half of the code otherwise necessary to achieve the same level of functionality.

The main focus of this package is re-usability. I have already spent 10+ hours programming its various parts, and really hope that it is useful to all the UI developers out there. If you do use it, I recommend that you read the included primer so you understand the conventions used.

I hope to release updates as issues and suggestions arise. If you have any questions, suggestions, or bug reports, please either PM me or post them here.

Of course, feel free to redistribute it as you see fit. If you modify it, please PM me, so we can include your modification in future releases, and everyone can benefit.

Link: http://spring.unknown-files.net/file/23 ... stem_v0.1/
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Post by LordMatt »

I, however, can hyperlink. ;) Will be interesting to see trepan's take on this.
User avatar
AlfaSub
Posts: 17
Joined: 07 Feb 2006, 20:28

Post by AlfaSub »

Thanks Matt. I'm new here so...
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Post by BrainDamage »

how about adding integration with the LuaUi edit mode?
ie. special functions that can be enbled only in the edit mode (resize-move windows for example)
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Post by MelTraX »

Nice... I didn't take a look at it yet but it looks quite promising..

I on the other hand had very little time lately.. My system is kinda "materializing" but I do have some problems.. Maybe we can just join forces.. I will take a look at your work the next days but unfortunately I'll be snowboarding starting Saturday..

I hope I can fix the most annoying bugs of my widgets before my trip..

edit: you left me as the author of your widget :P
User avatar
AlfaSub
Posts: 17
Joined: 07 Feb 2006, 20:28

Post by AlfaSub »

MelTraX-> Just tell me what you want/have already. I'm open to any suggestions for improvement. To create the camera widget, I took the source from your playerinfo widget and modified it until your name was pretty much the only thing left (and that was an oversight). Enjoy snowboarding, I just went to a mountain here a couple days ago :-)

Brain Damage-> Didn't even know LuaUI had an edit mode, I'll check it out tonight.
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Post by LordMatt »

MelTraX wrote:I'll be snowboarding starting Saturday..
Snowboarding > Lua coding any day! :-)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I'd like it if I could see the title bars and controls etc without entering tweak mode if I wanted.
User avatar
AlfaSub
Posts: 17
Joined: 07 Feb 2006, 20:28

Post by AlfaSub »

AF, do you mean adding high-visibility debug window borders to all controls (using a color that stands out, like fluorescent green or purple)? Cause this would be trivial, and I've already considered doing it. You could just set a variable like dbgBorderColor, and you would be able to see the exact position/size of each control/window.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

look at IceXuicks GUI design. Panels ahve title abrs and have 2 buttons to collapse or exit, whereas trepan and meltrax want to sue the tweak mode and get rid of these, I would prefer to have the option to see these title bars than enter tweak mdoe and move them around that way. It also makes more sense from a user design/user friendliness stand point
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Seconded to the title bars/buttons. Basically make it a fully windowed system with the abilty for specific elements to disable them if need be.
User avatar
AlfaSub
Posts: 17
Joined: 07 Feb 2006, 20:28

Post by AlfaSub »

I hadn't gotten around to creating close/collapse controls yet. Right now, windows do not have title bars by default, nor is there any easy way to add them. I was going to put them in the next release, and when I do I'll add the ability to enable/disable them.

Does anyone know how to have one lua widget call a function in another? For example, can one lua widget somehow call a locally-defined function in each loaded widget that changes its transparency?
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Post by LordMatt »

I think you can define a function in one lua, and then "include" that lua in the second lua.
tinnut
Posts: 67
Joined: 09 Sep 2006, 08:17

Post by tinnut »

Hi AlfaSub,

If using an include doesn't work, then you might be able to use the
widget:ConfigureLayout call-in, something like this:

Code: Select all

function widget:ConfigureLayout(command)
  if string.find(command, "set_transparency") ~= nil then
    myTransparency = tonumber(string.sub(command, 16))
  end
end
With this, another widget could set the transparency with a call to SendCommands like this:

Code: Select all

Spring.SendCommands({"luaui set_transparency 5"})
I have not tried to do something like this, but maybe it will work :-)

It might be more appropriate to use the call-in "TextCommand" instead of "ConfigureLayout".

Cheers.
Tim-the-maniac
Posts: 250
Joined: 22 Jul 2006, 19:58

Post by Tim-the-maniac »

You still around AlfaSub?
User avatar
AlfaSub
Posts: 17
Joined: 07 Feb 2006, 20:28

Post by AlfaSub »

I'm still around (kinda). After some consideration, I realized that I was more or less doing the same thing that several other UI authors were attempting. I'v decided that barring any sudden surge in interest, I'm going to stop development of this project. It seems that Meltrax already has made a lot of progress in this area, and there's no sense re-inventing the wheel. I might take a look at his system to try and spot the performance loss so many people are complaining about.
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Post by MelTraX »

Feel free to search.. :-)

But the problem seems to be the actual drawing of screen elements.. If I do all the calculations but don't draw the stuff, I hardly feel any slowdowns..

I still have some ideas that could enhance performance but I really tried to make it as efficient as possible..

If you find anything, please let me know.. I'm almost always in the TASClient if I'm not sleeping so if you start to dig around in my code feel free to ask me stuff.. :wink:
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

The main slowdown is probably the font rendering. Other then
that, I've previously mentionned that display lists can be used to
speed up access to rendering (useful for rendered shapes that
do not change, or change infrequently (ex: screen resizing)).
Something that folks may not realize is that texture bindings can
also be stored in display lists.

The next version of the Spring LUA interface also provides some
faster functions for drawing rectangles without using glShape().
gl.Rect() is directly compatible with the standard OpenGL glRect(),
and gl.TexRect() is a custom call I created for rendering textured
rectangles

Using it is much easier then reading the definition ;)
gl.TexRect(x1, y1, x2, y2[, < bool flipX [,bool flipY ] > | < s1, t1, s2, t2 > ])

I've also added gl.BeginEnd(function, args ...) and the gl.Vertex(),
gl.Normal(), gl.TexCoords() calls as an alternative to the gl.Shape()
call. I found that when loading large models (10K+ triangles), it would
speed up the process by about x3 (probably because of the LUA
table handling).

*NOTE: gl.TexRect() corrects Spring's default flipping of T texcoords
(vertical axis), unless you specify them directly using s1/t1/s2/t2.
Tim-the-maniac
Posts: 250
Joined: 22 Jul 2006, 19:58

Post by Tim-the-maniac »

AlfaSub wrote:I'm still around (kinda). After some consideration, I realized that I was more or less doing the same thing that several other UI authors were attempting. I'v decided that barring any sudden surge in interest, I'm going to stop development of this project. It seems that Meltrax already has made a lot of progress in this area, and there's no sense re-inventing the wheel. I might take a look at his system to try and spot the performance loss so many people are complaining about.
Do I count as a surge of interest? =)
While Meltrax has made a great framework thingy I still think yours is very usefull for simpler tasks.
If you do want to do some more work on it what do ya think of these features: (off the top of my head)
-Make it so that functions called by a ButtonClass can take arguments
-Make dragging of windows only possible when in tweak mode

Also, if you dont, I'll probly wanna use it anyway so do I have permission to release a slightly modified version?
User avatar
AlfaSub
Posts: 17
Joined: 07 Feb 2006, 20:28

Post by AlfaSub »

Sure tim, its released under GPL v2, so modify it to your hearts content.
Unfortunately, the OTHER good RTS (supcom) has captured my interest currently (just bought it), and I'm not sure how active I'll be in the future.

While I'm by no means signing off, I'm not sure how much more programming I feel up to doing in the next two or three months.

EDIT: only making windows draggable in an edit mode would be trivial to implement if you have a working knowledge of LUA. You should just have to set a flag in the draggable window mouse handler.
Post Reply

Return to “Lua Scripts”