Fixed #312 (Games freeze on pit stop) Was a bug in r3193 (added support for user keys redifinition in menus) + removed duplicate F1/F12 definitions
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3309 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 85d021bf2ddfef022236ebe593ae3ab7de3d7734 Former-commit-id: 7ed8d30b79522be39ceb0b2379e1c9e416f2d112
This commit is contained in:
parent
a2ad87f88d
commit
849e550e02
3 changed files with 30 additions and 21 deletions
|
@ -90,8 +90,6 @@ rmNStateScreen(const char *title, const tButtonDesc aButtons[], int nButtons, in
|
|||
GfuiMenuDefaultKeysAdd(screenHdle);
|
||||
GfuiAddKey(screenHdle, GFUIK_ESCAPE, aButtons[nCancelIndex].tip,
|
||||
aButtons[nCancelIndex].screen, GfuiScreenActivate, NULL);
|
||||
GfuiAddKey(screenHdle, GFUIK_F1, "Help", screenHdle, GfuiHelpScreen, NULL);
|
||||
GfuiAddKey(screenHdle, GFUIK_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL);
|
||||
|
||||
// Activate the created screen.
|
||||
GfuiScreenActivate(screenHdle);
|
||||
|
|
|
@ -91,14 +91,15 @@ rmRepair(void* /* dummy */)
|
|||
void
|
||||
RmPitMenuStart(tCarElt *car, tfuiCallback callback)
|
||||
{
|
||||
char buf[256];
|
||||
char buf[32];
|
||||
|
||||
rmCar = car;
|
||||
rmCallback = callback;
|
||||
|
||||
if (menuHandle) {
|
||||
if (menuHandle)
|
||||
GfuiScreenRelease(menuHandle);
|
||||
}
|
||||
|
||||
GfLogInfo("Entering Pit menu\n");
|
||||
|
||||
// Create screen, load menu XML descriptor and create static controls.
|
||||
menuHandle = GfuiScreenCreateEx(NULL, NULL, NULL, NULL, NULL, 1);
|
||||
|
@ -137,8 +138,7 @@ RmPitMenuStart(tCarElt *car, tfuiCallback callback)
|
|||
|
||||
// Register keyboard shortcuts.
|
||||
GfuiMenuDefaultKeysAdd(menuHandle);
|
||||
GfuiAddKey(menuHandle, GFUIK_F1, "Help", menuHandle, GfuiHelpScreen, NULL);
|
||||
GfuiAddKey(menuHandle, GFUIK_F12, "Screen-Shot", NULL, GfuiScreenShot, NULL);
|
||||
|
||||
// Activate the created screen.
|
||||
GfuiScreenActivate(menuHandle);
|
||||
}
|
||||
|
|
|
@ -324,13 +324,13 @@ gfuiKeyboardDown(int key, int modifier, int /* x */, int /* y */)
|
|||
tGfuiKey *curKey;
|
||||
tGfuiObject *obj;
|
||||
|
||||
/* user preempt key */
|
||||
/* User-preempted key */
|
||||
if (GfuiScreen->onKeyAction && GfuiScreen->onKeyAction(key, modifier, GFUI_KEY_DOWN))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* now see the user's defined keys */
|
||||
/* Now look at the user's defined keys */
|
||||
if (GfuiScreen->userKeys) {
|
||||
curKey = GfuiScreen->userKeys;
|
||||
do
|
||||
|
@ -363,13 +363,13 @@ gfuiKeyboardUp(int key, int modifier, int /* x */, int /* y */)
|
|||
{
|
||||
tGfuiKey *curKey;
|
||||
|
||||
/* user preempt key */
|
||||
/* User-preempted key */
|
||||
if (GfuiScreen->onKeyAction && GfuiScreen->onKeyAction(key, modifier, GFUI_KEY_UP))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* now see the user's defined keys */
|
||||
/* Now look at the user's defined keys */
|
||||
if (GfuiScreen->userKeys)
|
||||
{
|
||||
curKey = GfuiScreen->userKeys;
|
||||
|
@ -502,10 +502,12 @@ GfuiScreenActivate(void *screen)
|
|||
{
|
||||
gfuiSelectNext(NULL);
|
||||
}
|
||||
GfLogDebug("GfuiScreenActivate : GfelSetDisplayCB(GfuiDisplay)\n");
|
||||
GfelSetDisplayCB(GfuiDisplay);
|
||||
}
|
||||
else
|
||||
{
|
||||
GfLogDebug("GfuiScreenActivate : GfelSetDisplayCB(GfuiDisplayNothing)\n");
|
||||
GfelSetDisplayCB(GfuiDisplayNothing);
|
||||
}
|
||||
|
||||
|
@ -551,6 +553,7 @@ GfuiScreenDeactivate(void)
|
|||
GfelSetMouseMotionCB(0);
|
||||
GfelSetMousePassiveMotionCB(0);
|
||||
GfelSetIdleCB(0);
|
||||
GfLogDebug("GfuiScreenDeactivate : GfelSetDisplayCB(GfuiDisplayNothing)\n");
|
||||
GfelSetDisplayCB(GfuiDisplayNothing);
|
||||
}
|
||||
|
||||
|
@ -746,6 +749,7 @@ void
|
|||
GfuiAddKey(void *scr, int key, const char *descr, void *userData,
|
||||
tfuiCallback onKeyPressed, tfuiCallback onKeyReleased)
|
||||
{
|
||||
// TODO: Support for modifier ?
|
||||
tGfuiKey *curKey;
|
||||
tGfuiScreen *screen = (tGfuiScreen*)scr;
|
||||
char buf[32];
|
||||
|
@ -863,20 +867,27 @@ GfuiAddKey(void *scr, int key, const char *descr, void *userData,
|
|||
screen->userKeys = curKey->next = curKey;
|
||||
} else {
|
||||
// Search in the list for a definition for the same key.
|
||||
bool bFound = false;
|
||||
tGfuiKey* curKey2 = screen->userKeys;
|
||||
do {
|
||||
// Found => replace with new one.
|
||||
if (curKey2->next->key == key) {
|
||||
curKey->next = curKey2->next->next;
|
||||
free(curKey2->next);
|
||||
curKey2->next = curKey;
|
||||
// Found => replace with the new definition.
|
||||
if (curKey2->key == key) {
|
||||
free(curKey2->name);
|
||||
curKey2->name = curKey->name;
|
||||
free(curKey2->descr);
|
||||
curKey2->descr = curKey->descr;
|
||||
curKey2->modifier = curKey->modifier;
|
||||
curKey2->userData = curKey->userData;
|
||||
curKey2->onPress = curKey->onPress;
|
||||
curKey2->onRelease = curKey->onRelease;
|
||||
free(curKey);
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
curKey2 = curKey2->next;
|
||||
} while (curKey2 != screen->userKeys);
|
||||
} while ((curKey2 = curKey2->next) != screen->userKeys);
|
||||
|
||||
// Not found => add at the end of the list.
|
||||
if (curKey2 == screen->userKeys) {
|
||||
// Not found => add at the beginning of the list.
|
||||
if (not bFound) {
|
||||
curKey->next = screen->userKeys->next;
|
||||
screen->userKeys->next = curKey;
|
||||
screen->userKeys = curKey;
|
||||
|
|
Loading…
Reference in a new issue