void menu(int couleur)
{
system("cls");
HANDLE handle_input;
HANDLE handle_output;
INPUT_RECORD input_record;
DWORD events;
handle_output = GetStdHandle(STD_OUTPUT_HANDLE);
handle_input = GetStdHandle(STD_INPUT_HANDLE);
SetConsoleTextAttribute(handle_output, FOREGROUND_RED);
if(couleur == 1)
SetConsoleTextAttribute(handle_output, FOREGROUND_RED | BACKGROUND_BLUE);
cout<< "1.Lire le Journal";
SetConsoleTextAttribute(handle_output, FOREGROUND_RED);
cout<< endl;
if(couleur == 2)
SetConsoleTextAttribute(handle_output, FOREGROUND_RED | BACKGROUND_BLUE);
cout<< "2.Regarder la Carte";
SetConsoleTextAttribute(handle_output, FOREGROUND_RED);
cout<< endl;
if(couleur == 3)
SetConsoleTextAttribute(handle_output, FOREGROUND_RED | BACKGROUND_BLUE);
cout<< "3.Changer de Lieu";
SetConsoleTextAttribute(handle_output, FOREGROUND_RED);
cout<< endl;
cout<< "Entrez votre choix:\n";
LireInput();
}
void LireInput()
{
HANDLE handle_input;
HANDLE handle_output;
INPUT_RECORD input_record;
DWORD events;
handle_output = GetStdHandle(STD_OUTPUT_HANDLE);
handle_input = GetStdHandle(STD_INPUT_HANDLE);
ReadConsoleInput(handle_input, &input_record, 1, &events);
if(input_record.EventType == KEY_EVENT && input_record.Event.KeyEvent.bKeyDown)
{
switch(input_record.Event.KeyEvent.wVirtualKeyCode)
{
case 49: LireJournal();
break;
case 50: carte();
break;
case 51: ChangerLieu();
break;
default:cout<< "Erreur, choix pas valable.";
Sleep(1000);
menu(0);
break;
}
}
if(input_record.EventType == MOUSE_EVENT)
{
if(input_record.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)
{
if((input_record.Event.MouseEvent.dwMousePosition.X < 20) && (input_record.Event.MouseEvent.dwMousePosition.Y == 0))
{
LireJournal();
return;
}
else if((input_record.Event.MouseEvent.dwMousePosition.X < 20) && (input_record.Event.MouseEvent.dwMousePosition.Y == 1))
{
carte();
return;
}
else if((input_record.Event.MouseEvent.dwMousePosition.X < 20) && (input_record.Event.MouseEvent.dwMousePosition.Y == 2))
{
ChangerLieu();
return;
}
else
{
LireInput();
}
}
if((input_record.Event.MouseEvent.dwMousePosition.X < 20) && (input_record.Event.MouseEvent.dwMousePosition.Y == 0))
{
menu(1);
}
else if((input_record.Event.MouseEvent.dwMousePosition.X < 20) && (input_record.Event.MouseEvent.dwMousePosition.Y == 1))
{
menu(2);
}
else if((input_record.Event.MouseEvent.dwMousePosition.X < 20) && (input_record.Event.MouseEvent.dwMousePosition.Y == 2))
{
menu(3);
}
else
{
LireInput();
}
}
}
Mouse Problem
Hi all, I am trying to create a menu for my text based rpg game, but when I try to use it in Full screen mode, it doesn't work.
Here is my menu():
it works fine when I run it in windowed mode, but in full screen the cursor ALWAYS comes back to the middle of the screen. I can't get the mouse up the my menu and actually click. I can try, but before I reach my menu I am back in the middle of the screen.
[Edited by - Joshnathan on November 9, 2004 9:56:28 AM]
I found out the problem occurs when I redraw my menu, but I can't find a way to solve it. Any ideas?
Looks like you are re-initilizing your INPUT_RECORD input_record
every time you call your mouse function, which in might reset it every time its called.
My advice is to move it into a global, so that it's information stays valid throughout your program.
I really don't know if that will fix it. Looks like it should work the way it is. Also make sure your not resetting your mouse coords somewhere else in the code.
Another idea I would use to figure out whats going on, is write out the mouse coords to the screen every frame if you can to see what is going on with the mouse.
every time you call your mouse function, which in might reset it every time its called.
My advice is to move it into a global, so that it's information stays valid throughout your program.
I really don't know if that will fix it. Looks like it should work the way it is. Also make sure your not resetting your mouse coords somewhere else in the code.
Another idea I would use to figure out whats going on, is write out the mouse coords to the screen every frame if you can to see what is going on with the mouse.
I try'd it but it won't work :( I don't know how to display per frame, but got any other ideas?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement