Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


text box in SDL?

This topic is 5436 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

(Dev-)C++,Win2k,SDL [edit]:Sorry I double-posted. I asked a mod to delete the other one. I know that ticks people off. For starters, this will be used by a text-based RPG, but I hope to someday expand it to a graphical RPG and the web. I know that this will be a ton of work, which is why I am starting very small. I need to have a text box that can be scrolled. It will be filled with arbitiary text. I will have a list/vector of strings (I think list would be better, it will only be appended to at the end and small segments will be read in order) Each node in the list will have a member nType. This will determine whether it is rendered, and what color it is. Here is my idea of what it could look like (from my FTP program): here is my idea of the list:
class cTextNode {
  //public functions

    int nType;
    string sText;

std::list<cTextNode> lTextList;
What would be the easiest way to draw this using SDL? A diferent class or library would be OK if I would have to re-invent the wheel to do it this way, but I want to use as few libraries as possible. It would be really nice if I could just redirect cout to the box. Another thing I would need is a way to get input from a text bar above the box. How could I read text instead of just keypresses, and allow the mouse to focus between the little non-movable box and the screen, with the box always on top? [edited by - nagromo on November 30, 2003 2:23:18 PM]

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
SDL_ttf to render a line of text

SDL_EnableUnicode or something like that will put the unicode character of the keys pressed in the key down event (so you don''t have to write ugly piles of SDL_K means the letter ''K'' is shift is down or caps lock on...) Don''t be afraid of the big word Unicode, if the value is < 128, then its the same as ASCII.

Alternatively, you could look for a free SDL UI kit...

Share this post

Link to post
Share on other sites
Why don''t you just make it a console game? Then you don''t have to focus on the graphics, which is the whole point of making a text based game.

"Hey, what about those baggy pants you kids are wearin'' these days? Aren''t they hip and cool and poppin'' fresh?"-Peter Griffin
"Everytime I see an M followed by a dollar sign I just say "oh god" and go to the next post."-Neurokaotix
the D programming language

Share this post

Link to post
Share on other sites
good point... I will have a messagebox/chat interface in the final version, but I might as well start in the console and translate it to SDL later. I might just use the SDL_ttf thing, and hand-parse the strings, though. If they start in ASCII-equivalent, it shouldn''t be too terrible.

Share this post

Link to post
Share on other sites

  • 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!