The New GUI - Page 9

The New GUI

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Domipheus
Spring Developer
Posts: 20
Joined: 10 Jul 2006, 22:14

Post by Domipheus »

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 :)
User avatar
LOrDo
Posts: 1154
Joined: 27 Feb 2006, 00:21

Post by LOrDo »

Yayz.
User avatar
mehere101
Posts: 293
Joined: 15 Mar 2006, 02:38

Post by mehere101 »

Yeah, no one actually likes XML to hand edit, they just like parsing it because it is really easy on their end.
SjaakOnderkaak
Posts: 8
Joined: 01 Aug 2006, 21:25

Post by SjaakOnderkaak »

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:

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); 
And the following code somewhere in the Game::Draw function:

Code: Select all

if(!hideInterface) {
	CUiManager::GetSingleton()->Draw();
}
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 :P
Last edited by SjaakOnderkaak on 05 Aug 2006, 18:56, edited 2 times in total.
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Post by SinbadEV »

I think we have at least 3 or 4 people pokeing at GUIing spring at this point I deffinitely think it's great that this is happening and I hope that y'all can work together on it... also YAY YAY YAY YAY YAY!!!!

/me does a new gui dance.
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Can we have a link to this? It sounds great.
SjaakOnderkaak
Posts: 8
Joined: 01 Aug 2006, 21:25

Post by SjaakOnderkaak »

Maelstrom wrote:Can we have a link to this? It sounds great.
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 it :wink:

Get is here:

vereyon.nl/files/TASpring.zip

Just backup your original spring.exe and unzip into the spring folder
User avatar
diggz2k
Posts: 208
Joined: 04 Mar 2005, 06:34

Post by diggz2k »

So how close are we to getting the new gui up and running?
User avatar
Min3mat
Posts: 3455
Joined: 17 Nov 2004, 20:19

Post by Min3mat »

lol :P
hawkki
Posts: 222
Joined: 01 Jan 2006, 19:47

Post by hawkki »

Min3mat wrote:lol :P
and your point was ?
User avatar
LOrDo
Posts: 1154
Joined: 27 Feb 2006, 00:21

Post by LOrDo »

hawkki wrote:
Min3mat wrote:lol :P
and your point was ?
It already is!
User avatar
diggz2k
Posts: 208
Joined: 04 Mar 2005, 06:34

Post by diggz2k »

Then I guess my question is when is the next update heh
User avatar
Neuralize
Posts: 876
Joined: 17 Aug 2004, 23:15

Post by Neuralize »

Screenshots, I love gui screenshots, they make me giddy.
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

>_> 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.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Post by TradeMark »

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?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Actually I believe it is possible to have several values on a line because of the semicolons and though I see your point, I disagree with it.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Post by zwzsg »

I noticed a new gui in next Spring release.

But the builpics are still squashed! BUILPICS ARE SQUARE, DON'T PUT SQUARES INTO RECTANGLES. There. I had to say it. Sorry if it wasn't the right place.
User avatar
LOrDo
Posts: 1154
Joined: 27 Feb 2006, 00:21

Post by LOrDo »

zwzsg wrote:I noticed a new gui in next Spring release.

But the builpics are still squashed! BUILPICS ARE SQUARE, DON'T PUT SQUARES INTO RECTANGLES. There. I had to say it. Sorry if it wasn't the right place.
If the BP's are indeed rectangular, QFT.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Post by TradeMark »

zwzsg wrote:But the builpics are still squashed! BUILPICS ARE SQUARE, DON'T PUT SQUARES INTO RECTANGLES.
What... the current GUI buildpics are 96x72 (at resolution 1600x1200), not squares at all.
I tried to use squares too, but then i noticed they looks ugly :S

Also rectangles takes less vertical space...
zwzsg wrote:I noticed a new gui in next Spring release.
Where you can see next Spring release stuff??

BTW, how to get in the group which tests the next versions?

!
User avatar
Tim Blokdijk
Posts: 1242
Joined: 29 May 2005, 11:18

Post by Tim Blokdijk »

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

Return to “Engine”