CGUIExtendedText (colored text and images)

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

CGUIExtendedText (colored text and images)

Post by Klasker »

The static text element didn't really cut it for me so I made a new GUI component that supports text of different colors and fonts, images (inline and anchored), tabs, and horizontal lines(!).

Screens:
ImageImageImage

The scrollbar isn't part of the element, but another element I made which I called CGUIPanel. It simply adds a scrollbar to scroll through the elements inside it.

So how does it work? I invented a simple syntax that lets you add "control tags" in the text. So if I write:
This is an armor: #img:armor#. This #col:red#text is red#col#.
It will look like this:
This is an armor: Image. This text is red.
These are all the tags supported:
  • #img:(name):(anchor)# : Displays an image. If anchor is specified (optional) it will be anchored to either left or right.
  • #col:xxxx# ... #col# : Changes text color. #col# returns to original color.
  • #font:xxxx# ... #font# : Changes font. #font# returns to original font.
  • #tab# : Indents the text. Similar to pressing the TAB key.
  • #hline# : Inserts a horizontal line. Uses the text color. Width can be specified by writing #hline:2# for a 2-pixel thick line.
  • #align#: Changes text alignment. #align:center# is centered text and #align:right# is right-aligned text. #align# makes it left-aligned again.
So what you waiting for? Download it now.
NOTE: It uses the core::map<> class from the SVN version, so I included "irrMap.h" in the download (so you don't need SVN to use it). I hope that's OK with everyone.

Now that I see what can be done with this, I think I'll now take it one step further and make an HTML-like GUI component. I'm thinking I could make an entire GUI out of HTML-like code. That would be awesome! That would pretty much obsolete this component, but I thought I'd share what I found anyways.

If you like it, please tell me what you think 8)
If you don't like it, please press Alt+F4. :evil:
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

wow, great idea, looks amazing too. nice work :)
*opens msn*
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

This is awesome!! I haven't yet looked at the code but the examples look sweet. Mine, if I add it to IrrSpintz? I'd have to change it to use STL Map and probably some other things...but I'd love to add it!!!
Image
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

Spintz wrote:This is awesome!! I haven't yet looked at the code but the examples look sweet. Mine, if I add it to IrrSpintz? I'd have to change it to use STL Map and probably some other things...but I'd love to add it!!!
Sure you can add it. Though, I'm working on the HTML GUI component right now, so you might want to wait and see if something better comes up.
IPv6
Posts: 188
Joined: Tue Aug 08, 2006 11:58 am

Post by IPv6 »

Heh, i did the same thing for my game (still in progress)...
As a suggestion for futher improvement: you can add tag that make text between certain tags dynamic (jumping chars for example) since you do paining for yourself anyway :) quite funny! :)
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

very very nice! I could use this...
RapchikProgrammer
Posts: 279
Joined: Fri Dec 24, 2004 6:37 pm

Post by RapchikProgrammer »

Awesome work dude, i might need something like this for my game. Thanx a lot!
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

ooooh aaaah! 8)
KillerXX7
Posts: 22
Joined: Sat Oct 07, 2006 4:50 pm
Location: Russian Federation
Contact:

Post by KillerXX7 »

Looks really cool :!:
Think Fast, Act Right... OR Be Dead :)
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Superb work! I hope this gets integrated.
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Dammit Klasker, how are you so damn cool! :) Thanks a bunch.
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

It's been nearly two weeks now so I thought I'd give a heads up about the HTML renderer I mentioned. I made a working HTML renderer so far, with all the features of old version, and <table> tags and nested tags. BUT the code is not very good. In fact, the CHTMLContainer class has become a blob class full of spaghetti code, which is why I am not releasing anything at the moment. I want to release something decent instead, and next time it may not be based on true HTML but rather a similar XML-based language.

Bitplane mentioned having IGUIElements as HTML elements, and I want that possible too, but with the design I came up with it didn't seem to be very feasible. But that's probably because of the way IGUIElement works: It will only take the clipping plane from its parent, so I have to make IHTMLElement an IGUIElement too. Geez!

Technically it's working now, but if this is to be useful it needs to be better than that, so I'll be back when I have something better.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Wonderful, thanks for keeping us posted.

One thing to bear in mind is that it's perhaps easier (for hybrid and bitplane) to get new functionality integrated if you submit it in smaller patches and updates, rather than big blobs.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

Looks professional. Keep it up. :D
mooreaa
Posts: 2
Joined: Fri Apr 27, 2007 11:07 am

Post by mooreaa »

Hmm sorry to hear about the HTML version giving u problems. Have you looked at using an external parser like TinyXML?

Looks really cool, can't wait for the next version. Keep us updated!
Post Reply