Jump to content
  • Advertisement
Sign in to follow this  
Dandi8

[C++, SDL] Text input and level editors

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

Hey,
I was recently wondering - I'm making a level editor and I've stumbled upon a problem - getting text input from the user (like 'what is the name of that switch' and 'which door will that switch open' or simply 'what is the name of the level').

How do you guys do it?

I was thinking about ditching SDL for the level editor and going with VC++'s WinForms but that would be a bit inefficient and would make the editor windows-only (whereas I'd like it to be cross-platform).

Am I stuck using some GUI library or writing my own? If so, how should I go about writing my own library, which approach is more popular with indie games (own GUI or external lib), what is the most popular GUI lib out there and what would a reasonable person do?

Thanks in advance :)

Share this post


Link to post
Share on other sites
Advertisement
Writing your own seems to be drawing the focus away from your actual goal. I'm no expert, but Qt is cross platform and very pretty and you can embed OpenGL windows within it. I'd rather have an easy, fast and attractive GUI system handed to me so I could focus on the fun stuff. But hey, that's just me.

Share this post


Link to post
Share on other sites
Hmmm... Any other suggestions then?

What are all the SDL people using for their editors?

Share this post


Link to post
Share on other sites
If you don't want to use something like wxwidgets or qt, you could just use a quick and simple solution like immediate mode gui here:

http://sol.gfxile.net/imgui/ch07.html

Share this post


Link to post
Share on other sites
I have to ask, what's so 'immediate' about it?

It kinda looks like what I've been working on, too.

EDIT:
It does give me a few ideas on what a GUI should look like, though... Is this the proper way?

Share this post


Link to post
Share on other sites
It seems to me that you have a GUI already. If so, then I would make my own editbox on top of it (I actually implemented editbox 2-3 times myself, just with basic features).

You have to make the editbox receive key-presses, it's not a biggie to add/remove a character to/from a string, move the cursor etc.

But it's hard to go into details without knowing how you implemented the GUI.

Share this post


Link to post
Share on other sites
Oh, I'm far from implementing a GUI yet, in a proper way at least. It's just something I've been *trying to do* lately :P

So far I have a GUI class that I've implemented a few minutes ago, which has a quick TextField function which is supposed to work but doesn't. Tomorrow I'll try and finish this thing and finally make it work :)

But whatever you can say about writing my own GUIs between now and then, it will surely be extremely helpful to me :D

Also, my GUI class is mentioned in my Game class which makes it a bit impractical as I can't delete it without messing up the whole engine but oh well... I didn't have any better idea at getting input (my event handler is in my Game class)...


Ah... What the hell, this is my GUISystem header:

struct GUIState{
int activeItem;
int keychar;
int keyentered;
};

class GUISystem{
public:
int id;
string text;

void GetChar(SDL_Event event);
void GUIFinish();

int TextField(int id, int x, int y, string Text, TextSystem TextSys, int charWidth, GLfloat CR, GLfloat CG, GLfloat CB);
};


I won't post the cpp file as it's most probably very bad and incomplete and it's late and I'm tired and you'd call me a bad programmer :P But maybe it'll show my general idea (and how much I stole from that tutorial XD).

Share this post


Link to post
Share on other sites
I found guichan worked pretty well for me in SDL and the examples show how to use the most common controls. It pretty much stays out of the way once you get it in and if you compile it into your source you don't need the binaries although this takes a little bit of work to get right.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!