Problems with needed subroutines...
If you couldn't already tell, I'm a serious VC++ noob, so bear with me...
Working on a mudd game, details are fairly irrelevant, but I don't know how to get a bunch of different menus in the same program without errors.
The other thing is that one of the first menu options, "New Game", isn't working for some reason. All that option should be is some cout commands and a menu call, but I keep getting errors on the compile. Can someone just post me some code with multiple menu calls and a text-only option that calls another menu instead of creating one?
Re: Problems with needed subroutines...
Are you talking about a geniune Windows program menu as in "File, Edit, View...etc", or are you talking about a basic text printed menu that will get input like this:
[A]ttack
[B]lock
[R]un
[U]se Item
>...
Re: Problems with needed subroutines...
#include <iostream.h>
Pure DOS, nothing else. I just started it a couple days ago, so I'm not into anything big. Just cout<< and cin>> stuff...
Re: Problems with needed subroutines...
well you won't be making a MUDD anytime soon.
Re: Problems with needed subroutines...
Hopefully this will help you to get started I grabbed it from something I wrote a while back.
Displaying the main menu(s)...
Code:
ldBOOL LetsDecideClient::DoLogin()
{
while(true)
{
system("cls"); //windows only
cout<<"----------------------------"<<endl;
cout<<"-----Let's Decide Login-----"<<endl;
cout<<"----------------------------"<<endl;
cout<<"Please enter your username:";
cin>>myUser.userName;
cout<<"Please enter your password:";
cin>>myUser.password;
myUser.userID = 0;
myUser.isManager = ldFALSE;
if(!myServer.LogIn(myUser.userName, myUser.password, myUser.userID, myUser.isManager))
{
char temp;
do
{
DisplayLastFailure();
cout<<"Would you like to retry (y/n)?";
cin>>temp;
}
while((temp != 'y') && (temp != 'n'));
if(temp == 'n')
{
return ldFALSE;
}
}
else
{
return ldTRUE;
}
}
}
char LetsDecideClient::DisplayMainMenu()
{
char temp;
system("cls"); //windows only
cout<<"--------------------------------"<<endl;
cout<<"-----Let's Decide Main Menu-----"<<endl;
cout<<"--------------------------------"<<endl;
cout<<"(P)oll selection"<<endl;
if(myUser.isManager)
{
cout<<"Check login (f)ailures"<<endl;
cout<<"(S)end notification"<<endl;
cout<<"Add/Modify (u)ser"<<endl;
cout<<"Add/Modify p(o)ll"<<endl;
}
cout<<"(Q)uit"<<endl;
cout<<"--------------------------------"<<endl;
cout<<"Select an option:";
cin>>temp;
return temp;
}
Catching keystrokes from the main menu...
Code:
char mainSelection, mainLogin;
do
{
mainLogin = DisplayLogin();
switch(mainLogin)
{
case 'q':
case 'Q':
break;
case 'l':
case 'L':
if(DoLogin())
{
do
{
mainSelection = DisplayMainMenu();
switch(mainSelection)
{
case 'p':
case 'P':
DisplayPollSelection();
break;
case 'q':
case 'Q':
DoLogout();
break;
case 'f':
case 'F':
if(myUser.isManager)
{
DisplayFailures();
break;
}
case 's':
case 'S':
if(myUser.isManager)
{
DoNotify();
break;
}
case 'u':
case 'U':
if(myUser.isManager)
{
DisplayUserMenu();
break;
}
case 'o':
case 'O':
if(myUser.isManager)
{
break;
}
default:
cout<<"You have not selected a valid option!"<<endl;
sleep(1000);
break;
//system("pause"); //Windows only
}
}
while((mainSelection != 'q') && (mainSelection != 'Q'));
}
break;
default:
cout<<"You have not selected a valid option!"<<endl;
sleep(1000);
break;
}
}
while((mainLogin != 'q') && (mainLogin != 'Q'));
cout<<endl<<"------------------------------"<<endl;
cout<<"Thanks for using Let's Decide!"<<endl;
cout<<"------------------------------"<<endl;
cout<<"By: The Flapping Cats"<<endl;
sleep(2000);
}