• Advertisement
Sign in to follow this  

Text fields using C++

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

Hello again gentlemen, patrons, and developers. I have yet another problem to share with you. I've successfully implemented saving and loading in my program, and now I want to allow files to be loaded and saved using more than one file name. I need to know two things: 1: What command is available to obtain information pertaining to the files in a directory? 2: How can I implement a graphical text-field for inputting filenames? All I know is cin, which uses the console. Thank you very much for your time. Edit: Sorry everyone - To make things clearer, I'm using the SDL API.

Share this post


Link to post
Share on other sites
Advertisement
2 questions
1. how long have you been programming

2. can you use plain english?

assuming you have just finished fstream.h, you have a ways ahead of you before you will be on graphics.

Share this post


Link to post
Share on other sites
Pertaining to the first question, use FindFirstFile.
To do text fields, you're going to need to use another library, learn Win32 or something similar.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nahrix
Hello again gentlemen, patrons, and developers. I have yet another problem to share with you. I've successfully implemented saving and loading in my program, and now I want to allow files to be loaded and saved using more than one file name. I need to know two things:

1: What command is available to obtain information pertaining to the files in a directory?

2: How can I implement a graphical text-field for inputting filenames? All I know is cin, which uses the console.

Thank you very much for your time.


1. That's operating system-specific, to the best of my knowledge. Apparently it's getting rolled into C++0x though. In the meantime, consult POSIX and the MS knowledge base for OS-dependent crap.

2. That's also operating system-specific. What GUI API are you using? I recommend FLTK, though I suppose Win32 is fine.

Share this post


Link to post
Share on other sites
Quote:
Original post by game mercenary
2 questions
1. how long have you been programming

2. can you use plain english?

assuming you have just finished fstream.h, you have a ways ahead of you before you will be on graphics.


I'm not sure I understand the nature of your reply - be it serious or sarcastic. Nonetheless, I will attempt to explain my situation further.

1: I have been programming since I was three. Specifically, though, I have been programming C++ since I was eighteen. I am twenty-one now. As well, I am in the middle of a somewhat-complicated 2D simulation using the SDL API. I'm capable of grasping the basics of graphical programming by now, but I am no expert.

2: I have used cin in text-based programs to obtain C-style strings from the user. What I need now is the equvilant of Java's textfield, since I'm running a win32 window instead of a console. As well, I need to obtain a list of files in a directory, perhaps in array or vector format, to list the available map files which can be loaded.

Edit: I would like to appologise if I'm not making enough sense. My knowledge of graphical API's are limited to the basics of SDL, and I'm using what information I have to explain my situation to the best of my ability. Please excuse any explanation that doesn't use proper terminology.

Share this post


Link to post
Share on other sites
Quote:
assuming you have just finished fstream.h, you have a ways ahead of you before you will be on graphics.


Givin his journal, I don't think this will be a problem.

Nahrix, if your using SDL, you probably will still be able to use Win32 API functions. Try MSDN and see If you can find any info on text fields. There is also a windows programming site that has some good info. I'll look it up and see if the site has anything.

Hope this helps.

Share this post


Link to post
Share on other sites
Does the win32 API need any sort of library implementation equivilant to SDL, or is it out-of-the-box with Visual Studio 6?

Share this post


Link to post
Share on other sites
Quote:
1: What command is available to obtain information pertaining to the files in a directory?

I have used opendir() along with readdir() (a google search on them finds lots of resources) on both windows and linux platforms with come success but not sure how standard it actually is.

Quote:
2: How can I implement a graphical text-field for inputting filenames? All I know is cin, which uses the console.
...
Edit: Sorry everyone - To make things clearer, I'm using the SDL API.

Although you can use the win32 library to do these things quite easily (there are even common control dialog boxes available for you to use for opening/finding files) you lose out on the main reason for using SDL, getting away from platform specific code.
Here is a link to some free game development libraries Kylotan has been kind enough to compile. I am not sure how cross platform it is but I have looked at Crazy Eddy's GUI System (under the 2d graphics heading) and have thoughts of giving it at least a try.

Otherwise just use a library built for SDL like SDL_ttf for fonts and then make your own simple GUI system like text boxes and list boxes and scroll bars. This is obviously more work than the above options but if you are anything like me, probably provides you with more insight as to just how small and feeble your brain really is which is very helpful. (Sorry, I just couldn't help but share my pain as I am sure many people will with their own attempts at custom GUI implementations)

Hope that helps. [wink]

Share this post


Link to post
Share on other sites
Okay,

Some people haven't really explained well what generally happens in computer games.

The problem is a lot of GUI windowing frameworks, tend to interface well with fullscreen mode and the 3d graphics library, such as Direct3D. Win32 for example isn't designed to work when the 3d renderer has control of the window, at least for placing controls on the form.

So a solution is that a lot of 3d engines tend to program their own gui framework for use within the game. They put in the basics like combobox's etc. They use the internal functions of the renderer to create the items, often rendering sprites or billboards etc. Crazy ed gui system is a example of a free gui library designed to work within a 3d renderer environment.

Now here is where it gets interesting. A lot of editors however have a Panel or a Frame that the renderer is given the handle of. Anything outside that frame is editable by the editor program. The disadvantage in most cases you can't go fullscreen so you loose some performance. A popular choice for windowing that I like to use for cross platform nature is wxwidgets http://www.wxwidgets.org -- have a look at the library, nice a clean and abstracted. There are other windowing libraries out there.

So your choices are to look around at some pre-made free engines such as ogre, some gui libraries made to work with renderers such as crazy ed's or to just have a frame setup for the renderer and have your controls on the outside in toolbars, menus, dialogs etc.

Hope this help.

Share this post


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

  • Advertisement