The New GUI
Moderator: Moderators
Cegui has a layout editor, so you dont need to edit the xml by hand.
Ka-Ching!
Oh, btw, I absolutely detest XML also. But, Its benifits are huge when you realise why it is required, and how it's parsers etc are implemented. It is easily validated, pretty simple to read and understand, and there are hundreds of ways to integrate it into your system.
Just hating it is not good enough :)
Ka-Ching!
Oh, btw, I absolutely detest XML also. But, Its benifits are huge when you realise why it is required, and how it's parsers etc are implemented. It is easily validated, pretty simple to read and understand, and there are hundreds of ways to integrate it into your system.
Just hating it is not good enough :)
-
- Posts: 8
- Joined: 01 Aug 2006, 21:25
I have been doing some further experiments with the TASpring source code.
I think I petty much succeeded in writing a small (but incomplete) object orient user interface system. It basically consists of a UI manager (the CUiManager class), a style provider (the CUiStyleProvider class) and a simple demonstration control (the CUiLabel class).
Integrating the user interface in spring is easy: just call the CUiManager::GetSingleton()->Draw() function each time spring is drawn, resulting the CUiManager drawing all the registered controls (like the CUiLabel class).
The CUiManager also provides a style provider, which allows you to load an xml based ├óÔé¼╦£stylesheet├óÔé¼Ôäó by calling the CUiManager::GetSingleton()->GetStyleProvider()->LoadStyleSheet(const char* file) function.
Each style in the stylesheet carry├óÔé¼Ôäós a unique identifier like ├óÔé¼┼ôblue├óÔé¼┬Ø. A control can be easily styled by calling the CUiStyleProvider::GetStyle(const char* id, CUiDisplayStyle* &hStyle) function, which attempts to point the controls style to a style from the loaded stylesheet.
For the interested; a small code example which could be anywhere in the code:
And the following code somewhere in the Game::Draw function:
I used the xerces-c XML parser which seems to work very well, however getting it to work was, well how do you say it... a pain in the ass, because the wchar_t being treated as a native type in spring (which I was of course not aware of and causing the linker to fail, resulting in me messing hopelessly with the linkeroptions)
Anyone interested in seeing this all in action can download a zip file containing the modified spring.exe, xerces-c_2_y.dll and a sample stylesheet at vereyon.nl/files/TASpring.zip
Just backup your original spring.exe and unzip into the spring folder
Feel free to modify the [springfolder]/uidata/test.xml file.
Note: the code is far from perfect and I am not a c++ prof so even if I think it├óÔé¼Ôäós close to perfect├óÔé¼┬ª well you know
I don├óÔé¼Ôäót really like the xml file layout either, but this is just a little experiment.
Anyone interested in the source code? (It's petty well documented)
By the way, I do like XML
I think I petty much succeeded in writing a small (but incomplete) object orient user interface system. It basically consists of a UI manager (the CUiManager class), a style provider (the CUiStyleProvider class) and a simple demonstration control (the CUiLabel class).
Integrating the user interface in spring is easy: just call the CUiManager::GetSingleton()->Draw() function each time spring is drawn, resulting the CUiManager drawing all the registered controls (like the CUiLabel class).
The CUiManager also provides a style provider, which allows you to load an xml based ├óÔé¼╦£stylesheet├óÔé¼Ôäó by calling the CUiManager::GetSingleton()->GetStyleProvider()->LoadStyleSheet(const char* file) function.
Each style in the stylesheet carry├óÔé¼Ôäós a unique identifier like ├óÔé¼┼ôblue├óÔé¼┬Ø. A control can be easily styled by calling the CUiStyleProvider::GetStyle(const char* id, CUiDisplayStyle* &hStyle) function, which attempts to point the controls style to a style from the loaded stylesheet.
For the interested; a small code example which could be anywhere in the code:
Code: Select all
// Create new CUiLabel
newLabel = new CUiLabel;
newLabel->Location.X = 0.65f;
newLabel->Location.Y = 0.15f;
newLabel->Size.Width = 0.1f;
newLabel->Size.Height = 0.1f;
newLabel->SetText("Test1");
newLabel->Visible = true;
CUiManager::GetSingleton()->AddControl(newLabel);
// Create new CUiLabel
newLabel = new CUiLabel;
newLabel->Location.X = 0.8f;
newLabel->Location.Y = 0.15f;
newLabel->Size.Width = 0.1f;
newLabel->Size.Height = 0.1f;
newLabel->SetText("Test2");
newLabel->Visible = true;
CUiManager::GetSingleton()->AddControl(newLabel);
// Load & apply styles
CUiManager::GetSingleton()->GetStyleProvider()->LoadStyleSheet("uidata/text.xml");
CUiManager::GetSingleton()->GetStyleProvider()->GetStyle("test", CUiManager::GetSingleton()->GetControl(0)->Style);
CUiManager::GetSingleton()->GetStyleProvider()->GetStyle("red", CUiManager::GetSingleton()->GetControl(1)->Style);
Code: Select all
if(!hideInterface) {
CUiManager::GetSingleton()->Draw();
}
Anyone interested in seeing this all in action can download a zip file containing the modified spring.exe, xerces-c_2_y.dll and a sample stylesheet at vereyon.nl/files/TASpring.zip
Just backup your original spring.exe and unzip into the spring folder
Feel free to modify the [springfolder]/uidata/test.xml file.
Note: the code is far from perfect and I am not a c++ prof so even if I think it├óÔé¼Ôäós close to perfect├óÔé¼┬ª well you know

I don├óÔé¼Ôäót really like the xml file layout either, but this is just a little experiment.
Anyone interested in the source code? (It's petty well documented)
By the way, I do like XML

Last edited by SjaakOnderkaak on 05 Aug 2006, 18:56, edited 2 times in total.
-
- Posts: 8
- Joined: 01 Aug 2006, 21:25
Yeah yeah, sure. I posted it in my previous post, but i'm not allowed to post real links with ubb tags yet because i'm new (anti spam policy), so you might have read over itMaelstrom wrote:Can we have a link to this? It sounds great.

Get is here:
vereyon.nl/files/TASpring.zip
Just backup your original spring.exe and unzip into the spring folder
>_> Just because you CAN use XML doesnt mean you SHOULD <this is in response to the blindly pro-XML guys a ways back>
its akin to using Perl to write a webserver (yes i know its been done).
I actually made a DTD some ways back for the TA FBI format. It took me a while, but i nthe end, it was completely compliant and was 'technically' good.
as i learned, wthe bottom line is getting data into a readable format. Line-seperated values is far better because it is quicker and doesnt need lots of extraneous tags. With XML, you either need lots of " " (which are redundant in our case) for attribs, or tons of < tag > </ tag>, or still <tag />. Either way, its a lot of hugely unecessary typing. You'd be surprised how quickly those damn <> and / can get annoying.
I'm actually an advocate of removing the semicolon at the end of the line as a requirement for lineending. TA values in FBIs are short and concise; C++, Java, etc use semiolons so you cna type a really really long statement on multiple lines and have the compiler recognize "this is one statement". TA FBI/TDF/etc has nothing like it.
its akin to using Perl to write a webserver (yes i know its been done).
I actually made a DTD some ways back for the TA FBI format. It took me a while, but i nthe end, it was completely compliant and was 'technically' good.
as i learned, wthe bottom line is getting data into a readable format. Line-seperated values is far better because it is quicker and doesnt need lots of extraneous tags. With XML, you either need lots of " " (which are redundant in our case) for attribs, or tons of < tag > </ tag>, or still <tag />. Either way, its a lot of hugely unecessary typing. You'd be surprised how quickly those damn <> and / can get annoying.
I'm actually an advocate of removing the semicolon at the end of the line as a requirement for lineending. TA values in FBIs are short and concise; C++, Java, etc use semiolons so you cna type a really really long statement on multiple lines and have the compiler recognize "this is one statement". TA FBI/TDF/etc has nothing like it.
Related to that http://vereyon.nl/files/TASpring.zip
I like the transparent black gradient on the chat and resource bars!
But could you put the resource bar into top right corner exactly, without spaces and that how you cant move the bar?
I like the transparent black gradient on the chat and resource bars!
But could you put the resource bar into top right corner exactly, without spaces and that how you cant move the bar?
What... the current GUI buildpics are 96x72 (at resolution 1600x1200), not squares at all.zwzsg wrote:But the builpics are still squashed! BUILPICS ARE SQUARE, DON'T PUT SQUARES INTO RECTANGLES.
I tried to use squares too, but then i noticed they looks ugly :S
Also rectangles takes less vertical space...
Where you can see next Spring release stuff??zwzsg wrote:I noticed a new gui in next Spring release.
BTW, how to get in the group which tests the next versions?
!
- Tim Blokdijk
- Posts: 1242
- Joined: 29 May 2005, 11:18
http://taspring.clan-sy.com/download.php
The "Development release" JC put it there a week ago or so.
And if you compile from svn you can test new developments as it's coded.
The "Development release" JC put it there a week ago or so.
And if you compile from svn you can test new developments as it's coded.