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);
|
GfuiMenuDefaultKeysAdd(screenHdle);
|
||||||
GfuiAddKey(screenHdle, GFUIK_ESCAPE, aButtons[nCancelIndex].tip,
|
GfuiAddKey(screenHdle, GFUIK_ESCAPE, aButtons[nCancelIndex].tip,
|
||||||
aButtons[nCancelIndex].screen, GfuiScreenActivate, NULL);
|
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.
|
// Activate the created screen.
|
||||||
GfuiScreenActivate(screenHdle);
|
GfuiScreenActivate(screenHdle);
|
||||||
|
|
|
@ -91,14 +91,15 @@ rmRepair(void* /* dummy */)
|
||||||
void
|
void
|
||||||
RmPitMenuStart(tCarElt *car, tfuiCallback callback)
|
RmPitMenuStart(tCarElt *car, tfuiCallback callback)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[32];
|
||||||
|
|
||||||
rmCar = car;
|
rmCar = car;
|
||||||
rmCallback = callback;
|
rmCallback = callback;
|
||||||
|
|
||||||
if (menuHandle) {
|
if (menuHandle)
|
||||||
GfuiScreenRelease(menuHandle);
|
GfuiScreenRelease(menuHandle);
|
||||||
}
|
|
||||||
|
GfLogInfo("Entering Pit menu\n");
|
||||||
|
|
||||||
// Create screen, load menu XML descriptor and create static controls.
|
// Create screen, load menu XML descriptor and create static controls.
|
||||||
menuHandle = GfuiScreenCreateEx(NULL, NULL, NULL, NULL, NULL, 1);
|
menuHandle = GfuiScreenCreateEx(NULL, NULL, NULL, NULL, NULL, 1);
|
||||||
|
@ -137,8 +138,7 @@ RmPitMenuStart(tCarElt *car, tfuiCallback callback)
|
||||||
|
|
||||||
// Register keyboard shortcuts.
|
// Register keyboard shortcuts.
|
||||||
GfuiMenuDefaultKeysAdd(menuHandle);
|
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);
|
GfuiScreenActivate(menuHandle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,13 +324,13 @@ gfuiKeyboardDown(int key, int modifier, int /* x */, int /* y */)
|
||||||
tGfuiKey *curKey;
|
tGfuiKey *curKey;
|
||||||
tGfuiObject *obj;
|
tGfuiObject *obj;
|
||||||
|
|
||||||
/* user preempt key */
|
/* User-preempted key */
|
||||||
if (GfuiScreen->onKeyAction && GfuiScreen->onKeyAction(key, modifier, GFUI_KEY_DOWN))
|
if (GfuiScreen->onKeyAction && GfuiScreen->onKeyAction(key, modifier, GFUI_KEY_DOWN))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now see the user's defined keys */
|
/* Now look at the user's defined keys */
|
||||||
if (GfuiScreen->userKeys) {
|
if (GfuiScreen->userKeys) {
|
||||||
curKey = GfuiScreen->userKeys;
|
curKey = GfuiScreen->userKeys;
|
||||||
do
|
do
|
||||||
|
@ -363,13 +363,13 @@ gfuiKeyboardUp(int key, int modifier, int /* x */, int /* y */)
|
||||||
{
|
{
|
||||||
tGfuiKey *curKey;
|
tGfuiKey *curKey;
|
||||||
|
|
||||||
/* user preempt key */
|
/* User-preempted key */
|
||||||
if (GfuiScreen->onKeyAction && GfuiScreen->onKeyAction(key, modifier, GFUI_KEY_UP))
|
if (GfuiScreen->onKeyAction && GfuiScreen->onKeyAction(key, modifier, GFUI_KEY_UP))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now see the user's defined keys */
|
/* Now look at the user's defined keys */
|
||||||
if (GfuiScreen->userKeys)
|
if (GfuiScreen->userKeys)
|
||||||
{
|
{
|
||||||
curKey = GfuiScreen->userKeys;
|
curKey = GfuiScreen->userKeys;
|
||||||
|
@ -502,10 +502,12 @@ GfuiScreenActivate(void *screen)
|
||||||
{
|
{
|
||||||
gfuiSelectNext(NULL);
|
gfuiSelectNext(NULL);
|
||||||
}
|
}
|
||||||
|
GfLogDebug("GfuiScreenActivate : GfelSetDisplayCB(GfuiDisplay)\n");
|
||||||
GfelSetDisplayCB(GfuiDisplay);
|
GfelSetDisplayCB(GfuiDisplay);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
GfLogDebug("GfuiScreenActivate : GfelSetDisplayCB(GfuiDisplayNothing)\n");
|
||||||
GfelSetDisplayCB(GfuiDisplayNothing);
|
GfelSetDisplayCB(GfuiDisplayNothing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,6 +553,7 @@ GfuiScreenDeactivate(void)
|
||||||
GfelSetMouseMotionCB(0);
|
GfelSetMouseMotionCB(0);
|
||||||
GfelSetMousePassiveMotionCB(0);
|
GfelSetMousePassiveMotionCB(0);
|
||||||
GfelSetIdleCB(0);
|
GfelSetIdleCB(0);
|
||||||
|
GfLogDebug("GfuiScreenDeactivate : GfelSetDisplayCB(GfuiDisplayNothing)\n");
|
||||||
GfelSetDisplayCB(GfuiDisplayNothing);
|
GfelSetDisplayCB(GfuiDisplayNothing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,6 +749,7 @@ void
|
||||||
GfuiAddKey(void *scr, int key, const char *descr, void *userData,
|
GfuiAddKey(void *scr, int key, const char *descr, void *userData,
|
||||||
tfuiCallback onKeyPressed, tfuiCallback onKeyReleased)
|
tfuiCallback onKeyPressed, tfuiCallback onKeyReleased)
|
||||||
{
|
{
|
||||||
|
// TODO: Support for modifier ?
|
||||||
tGfuiKey *curKey;
|
tGfuiKey *curKey;
|
||||||
tGfuiScreen *screen = (tGfuiScreen*)scr;
|
tGfuiScreen *screen = (tGfuiScreen*)scr;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
@ -863,20 +867,27 @@ GfuiAddKey(void *scr, int key, const char *descr, void *userData,
|
||||||
screen->userKeys = curKey->next = curKey;
|
screen->userKeys = curKey->next = curKey;
|
||||||
} else {
|
} else {
|
||||||
// Search in the list for a definition for the same key.
|
// Search in the list for a definition for the same key.
|
||||||
|
bool bFound = false;
|
||||||
tGfuiKey* curKey2 = screen->userKeys;
|
tGfuiKey* curKey2 = screen->userKeys;
|
||||||
do {
|
do {
|
||||||
// Found => replace with new one.
|
// Found => replace with the new definition.
|
||||||
if (curKey2->next->key == key) {
|
if (curKey2->key == key) {
|
||||||
curKey->next = curKey2->next->next;
|
free(curKey2->name);
|
||||||
free(curKey2->next);
|
curKey2->name = curKey->name;
|
||||||
curKey2->next = curKey;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
curKey2 = curKey2->next;
|
} while ((curKey2 = curKey2->next) != screen->userKeys);
|
||||||
} while (curKey2 != screen->userKeys);
|
|
||||||
|
|
||||||
// Not found => add at the end of the list.
|
// Not found => add at the beginning of the list.
|
||||||
if (curKey2 == screen->userKeys) {
|
if (not bFound) {
|
||||||
curKey->next = screen->userKeys->next;
|
curKey->next = screen->userKeys->next;
|
||||||
screen->userKeys->next = curKey;
|
screen->userKeys->next = curKey;
|
||||||
screen->userKeys = curKey;
|
screen->userKeys = curKey;
|
||||||
|
|
Loading…
Reference in a new issue