Skip to main content
gamedev.net
🔒 Locked

User Interface

Started by valrin Jun 13, 2006 at 8:58 PM 3 replies 800+ views
Original Post
valrin
valrin
I'm working on a tile-based rpg, and I'm having trouble coming up with a way to implement the GUI. I would prefer to not use a pre-made library, and create it all myself, mainly for the experience and to say I did it. I'm looking to design the interface a bit like Baldur's Gate/Icewind Dale. The most trouble i'm having is thinking of a way to do the textbox at the bottom, where conversations, story, etc. is placed. I haven't had much luck finding any tutorials or anything, so I thought someone here might have some good advice or could point me in the right direction. Any advice would be great.
Trienco
Trienco
So many ways to do it. You could try to "unify" it all and make the actual "game view" a specialized part of the GUI (to handle mouse clicks and keys without any form of "if the GUI didn't handle it, the game should"). But that mentioned textbox is just that. A box/window with text in it, maybe scroll buttons. I prefer having each line of text as a seperate string. So say you would have a vector and reserve memory for 100 entries (reserving might not help a lot in this case). You need to know how many lines your window can show at it's current size and simply "print" (with whatever you're using for text output) the lines last-x to last. Scrolling is simply a matter of shifting where "last" is. If you want to be really fancy, you could implement it as a ring like structure. It would introduce a % operation, and while it won't be a critical place, you could use a power of two number of lines and instead of doing index%size it would be index&(size-1) (one of many often pointless tricks to make your code more confusing).

If you want to be able to change the width of this box at any time, things are getting a bit more messy, because then a single line could turn into multiple lines, screwing up your calculations. So you would probably have to go over each string and update how many lines it uses. If you split it, don't insert a \n. They would make a good marker when you make the box wider again and need to know where a line really ends and where it just wrapped.

Short version: you can do it very quick and simple or add just about as many complications as you feel like. Searching for infos about doing your own console window (and ignoring everything about input) might get more results that searching for stuff about GUIs.
f@dzhttp://festini.device-zero.de
i deal napalm
i deal napalm
Check out the DXUT source that comes with the DirectX SDK too. DXUT is a GUI used for the DirectX samples.
Ravuya
Ravuya
There are a couple articles right here on GDNet about implementing a good UI.

I implemented mine using the design from this tutorial.
valrin
valrin
Thanks a lot, guys. I think I've got a clearer view of how to implement it all now, combining Trienco's idea with the tutorial. Thanks a bunch.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.