- fixed key movement in result screen

- prevent closing of result screen is now done for all input variants
   and without odd side effects (and with less lines of code)
 - convert mouse buttons, joystick buttons and axes to key input for easier management
 - added note


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1274 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
thebohemian 2007-10-06 16:39:18 +00:00
parent e153a6592b
commit 02b8c37aac
3 changed files with 45 additions and 64 deletions

View File

@ -39,21 +39,22 @@ void BaseGUI::input(InputType type, int id0, int id1, int id2, int value)
select();
break;
case SDL_BUTTON_RIGHT:
if (menu_manager->getMenuStackSize() > 1)
{
if(menu_manager->isCurrentMenu(MENUID_RACEMENU))
{
world->unpause();
}
menu_manager->popMenu();
}
inputKeyboard(SDLK_ESCAPE, 0);
break;
}
break;
case IT_STICKMOTION:
widgetSet -> pulse(widgetSet -> stick(m_menu_id, id1, id2, value), 1.2f);
if (id1 == 0)
{
// X-Axis
inputKeyboard((id2 == AD_NEGATIVE) ? SDLK_LEFT : SDLK_RIGHT, !value);
}
else if (id1 == 1)
{
// Y-Axis
inputKeyboard((id2 == AD_NEGATIVE) ? SDLK_UP : SDLK_DOWN, !value);
}
break;
case IT_STICKBUTTON:
@ -61,18 +62,10 @@ void BaseGUI::input(InputType type, int id0, int id1, int id2, int value)
switch (id1) // Button no
{
case 0:
select();
inputKeyboard(SDLK_RETURN, 0);
break;
case 1:
if (menu_manager->getMenuStackSize() > 1)
{
if(menu_manager->isCurrentMenu(MENUID_RACEMENU))
{
world->unpause();
}
menu_manager->popMenu();
}
inputKeyboard(SDLK_ESCAPE, 0);
break;
}
break;
@ -83,6 +76,23 @@ void BaseGUI::input(InputType type, int id0, int id1, int id2, int value)
}
//-----------------------------------------------------------------------------
/**
* Important note: One day the STK engine code will have no notion of SDL
* key, button, axes and so on. It will only know actions like menu up, menu
* down, enter menu, leave menu, ...
*
* However this requires some major reworking. Until this is done SDL's keys
* take the role of the actions. That is why joystick axes & buttons and mouse
* buttons are converted to key input (see BaseGUI::input).
*
* When the game actions are implemented not dealing with the input mechanisms
* gives more flexibility:
* - issue no game actions when input sensing is active
* - what issues a certain game action can be conveniently selected
* (at compile or runtime, depending on the need)
*
* Please keep this goal in mind when you work on the input stuff.
*/
void BaseGUI::inputKeyboard(int key, int pressed)
{
// Skip on keypress, act on keyrelease only.
@ -106,11 +116,10 @@ void BaseGUI::inputKeyboard(int key, int pressed)
case SDLK_ESCAPE:
if (menu_manager->getMenuStackSize() > 1)
{
//We don't need to handle the race gui pause with the keyboard
//(but we have to with the joystick & mouse) because it has it's
//own keyboard handling function.
menu_manager->popMenu();
if(menu_manager->isCurrentMenu(MENUID_RACEMENU))
world->unpause();
menu_manager->popMenu();
}
break;

View File

@ -174,43 +174,16 @@ void RaceResultsGUI::select()
break;
}
} // select
//-----------------------------------------------------------------------------
void RaceResultsGUI::input(InputType type, int id0, int id1, int id2, int value)
void
RaceResultsGUI::inputKeyboard(int key, int pressed)
{
if( (type==IT_STICKBUTTON && value && id1==1 ) ||
(type==IT_MOUSEBUTTON && value && id0==SDL_BUTTON_RIGHT) )
{ // Usually here would be code to close this gui. Not only
// that doesn't has any real function in this gui,
// but also closing this gui causes bug #9157.
world->unpause();
race_manager->next();
}
else
{
BaseGUI::input(type, id0, id1, id2, value);
}
} // input
//-----------------------------------------------------------------------------
void RaceResultsGUI::inputKeyboard(int key, int pressed)
{
if (!pressed)
return;
if(key!=SDLK_ESCAPE)
{
BaseGUI::inputKeyboard(key, pressed);
}
else
{ // Usually here would be code to close this gui. Not only
// that doesn't has any real function in this gui,
// but also causes bug #9157.
world->unpause();
race_manager->next();
} // sif SDLK_ESCAPE
} // inputKeyboard
// Attempts to close the menu are silently discarded
// since they do not make sense at this point.
if (key == SDLK_ESCAPE)
return;
else
BaseGUI::inputKeyboard(key, pressed);
}
/* EOF */

View File

@ -33,10 +33,9 @@ public:
RaceResultsGUI();
~RaceResultsGUI();
void select();
void inputKeyboard(int, int);
void input(InputType type, int id0, int id1, int id2, int value);
void inputKeyboard(int key, int pressed);
void select();
};
#endif