AlfaSub's Widget Window System v0.1
Moderator: Moderators
AlfaSub's Widget Window System v0.1
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/
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/
- BrainDamage
- Lobby Developer
- Posts: 1164
- Joined: 25 Sep 2006, 13:56
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
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

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.

Brain Damage-> Didn't even know LuaUI had an edit mode, I'll check it out tonight.
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.
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
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?
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?
Hi AlfaSub,
If using an include doesn't work, then you might be able to use the
widget:ConfigureLayout call-in, something like this:
With this, another widget could set the transparency with a call to SendCommands like this:
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.
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
Code: Select all
Spring.SendCommands({"luaui set_transparency 5"})

It might be more appropriate to use the call-in "TextCommand" instead of "ConfigureLayout".
Cheers.
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.
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..

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..

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.
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.
-
- Posts: 250
- Joined: 22 Jul 2006, 19:58
Do I count as a surge of interest? =)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.
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?
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.
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.