Jump to content
  • Advertisement
Sign in to follow this  
valrin

User Interface

This topic is 4414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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<string> 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!