Skip to main content
gamedev.net
🔒 Locked

Input a string?

Started by BeanDog Apr 6, 2000 at 4:58 PM 2 replies 600+ views
Original Post
BeanDog
BeanDog
Is there someone out there who has written a string-input deal for DirectDraw? Like cin, but with a IDIRECTDRAWSURFACE7 object. You know what I mean? You call it, they type something in, the function returns it. Anybody?
Kylotan
Kylotan
quote:
Original post by BeanDog

Is there someone out there who has written a string-input deal for DirectDraw? Like cin, but with a IDIRECTDRAWSURFACE7 object. You know what I mean? You call it, they type something in, the function returns it.

Anybody?


Well, cin is just a standard wrapper object for the part of the console input system that the operating system provides. Therefore it isn''t handling moving the cursor when you type, moving onto the next line, etc etc. This means that, to do a windows version, you have to handle all this yourself. Hence the popularity of MFC, etc Is it not practical to use a Windows edit box on such a surface? I have never tried it myself, but I expect that if you knew what you were doing, that would be the fastest way.
Otherwise, you''re gonna need to implement letter drawing functions, a list/stack/array of characters to hold your input, some way to grab that input (DirectInput, for example) and a way of matching up the input to a letter to add to your string. If you are going to do it yourself, I recommend you start with fixed width characters and only upper or lower case until you get the hang of it
BeanDog
BeanDog
Surely someone has run into this. I mean, don''t you all have some game where the user can type in an alias? Seems like a simple enough task.
Cygon
Cygon
Your problem seems to be that cin uses stdout, which one can hardly see in graphics mode under DirectDraw

I''ve created a small DirectInput library which supports quake-like key binding - and - cursored text input. The library can be initialized with just 2 function calls, so this shouldn''t be the problem.
The text the user is typing is placed in an char * array, you just have to call an update() function (meaning your program keeps running, allowing you to draw the text onto the ddraw surface). Since the lib uses buffered mode, you won''t lose keystrokes even if the app runs very choppy

If you''d like to give it a try,
www.lunaticsystems.de/truefx
(a simple example app demonstrating string input is included, the lib is free and full-source, full english documentation)

-Markus-

P.S. Wow. Finally became a ''dedicated'' with this message :D
Professional C++ and .NET developer trying to break into indie game development.
Follow my progress: http://blog.nuclex-games.com/ or Twitter - Topics: Ogre3D, Blender, game architecture tips & code snippets.

Topic Locked

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

Sign in to reply to this topic.