TypeGL, cin replacement
Before i start, note that i didnt take the time to check and see if something was already created like what i did. I''m sure there is, but i haevnt seen it so either way i dont care.
I came up with a way to enable a user to type in text and have it shown on the screen. Kind of liek a word processor (thats a laugh). Pretty much more like a dos prompt, enter a command and press enter to execute it.
It allows for lower case and upper case numbers and what not. Still need work so if anyone wishes to improve it, please please do so and let me know.
Has bugs, they are listed inside the code.
download it here http://www.700r4.com/temp/typegl.zip
Give me comments, suggestions and what not.
around line #250, you have this:
if(tmp=="exit") {
active=false;
}
AFAIK, you cannot compare dynamic strings with the == operator.
Someone correct me if I am wrong...
also, setting ''active'' to false will not quit the program, but actually make it appear frozen because all the computer will do is swap the frame buffer forever... a quick (and dirty) fix for this is to make the ''done'' variable from WinMain global, and set it to true when "exit" is typed. it is not good practice however to make such critical variables global, but who cares?
try changing this function to:
BOOL done = false; // this is now global
void ExecCommand()
{
if(!strcmp(strlwr(TEXT), "exit"))
done = true;
strcpy(TEXT, "\0");
}
if(tmp=="exit") {
active=false;
}
AFAIK, you cannot compare dynamic strings with the == operator.
Someone correct me if I am wrong...
also, setting ''active'' to false will not quit the program, but actually make it appear frozen because all the computer will do is swap the frame buffer forever... a quick (and dirty) fix for this is to make the ''done'' variable from WinMain global, and set it to true when "exit" is typed. it is not good practice however to make such critical variables global, but who cares?

try changing this function to:
BOOL done = false; // this is now global
void ExecCommand()
{
if(!strcmp(strlwr(TEXT), "exit"))
done = true;
strcpy(TEXT, "\0");
}
This sounds interesting, Titan. I''ll check it out! =)
Kenneth Wilhelmsen
Try my little 3D Engine project, and mail me the FPS. WEngine
Or just visit my site
--------------------------
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder
Kenneth Wilhelmsen
Try my little 3D Engine project, and mail me the FPS. WEngine
Or just visit my site
--------------------------
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder
wow, thank you, i was looking for somethign to compare strings! I will change the code and re-upload it.
lol, ur smart
Ok, changes were made an di re-uploaded it.
[edited by - _Titan_ on April 25, 2002 11:39:00 AM]
lol, ur smart

Ok, changes were made an di re-uploaded it.
[edited by - _Titan_ on April 25, 2002 11:39:00 AM]
smart, no. Just observant
~
anyway, when this project of yours is complete, you will have the basis for an in-game console. sweet indeed!
Good luck with this...

anyway, when this project of yours is complete, you will have the basis for an in-game console. sweet indeed!
Good luck with this...
well, it needs alot of work, i''m probably gonan re-do it. For now, this project has turned into a commadn line driven 3d editor. Dont ask why command line driven, its just something to do for fun

If you wanna do
if (str == "exit")...
You can overload the == operator
bool operator==(char* s1,char* s2)
{
return (strcmp(s1,s2) == 0);
}
if (str == "exit")...
You can overload the == operator
bool operator==(char* s1,char* s2)
{
return (strcmp(s1,s2) == 0);
}
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
A bit OT : Why do people make consoles for their engines? Is is becoue there is one in quake or is there soome hidden meaning I just can not see. Personaly I realy cant find use for it. Creating some kind of GUI/menu system to change in-engine variables with click of a mouse sounds a much better idea to me...
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
an ingame console is not really meant for users, its meant more for testing, debugging and what not. More for the developers. thats why when in quake you enter "GOD" in the console, it gives you god mode, these are codes the developers use and the testers use to check for bugs, test maps and what not. Its hard to test a lebvel if you keep dying before you can test a certian area. See? And changing things with the click of amouse would require coding new gui''s and alot more code than a command console.
Hoep thi smkaes sense
Hoep thi smkaes sense
April 26, 2002 03:02 PM
quote:
Original post by George2
If you wanna do
if (str == "exit"...
You can overload the == operator
bool operator==(char* s1,char* s2)
{
return (strcmp(s1,s2) == 0);
}
No, you can''t. You can only overload operators if one of the operands is a user-defined type, ie struct or class. In particular, you can''t overload operators that work exclusively on pointers.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement