Skip to content

Commit

Permalink
Simplify diaExecuteDialog sfx
Browse files Browse the repository at this point in the history
  • Loading branch information
rickgaiser authored and KrahJohlito committed Jul 5, 2020
1 parent 620b71c commit 417f20c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 55 deletions.
68 changes: 19 additions & 49 deletions src/dia.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,66 +899,36 @@ int diaExecuteDialog(struct UIItem *ui, int uiId, short inMenu, int (*updater)(i
}
} else {
modified = 0;
if (getKey(KEY_LEFT)) {
struct UIItem *newf = diaGetPrevControl(cur, ui);

if (!toggleSfx) {
sfxPlay(SFX_CURSOR);
}
struct UIItem *newf = cur;

if (newf == cur) {
cur = diaGetLastControl(ui);
}
else {
cur = newf;
}
if (getKey(KEY_LEFT)) {
newf = diaGetPrevControl(cur, ui);
if (newf == cur)
newf = diaGetLastControl(ui);
}

if (getKey(KEY_RIGHT)) {
struct UIItem *newf = diaGetNextControl(cur, cur);

if (!toggleSfx) {
sfxPlay(SFX_CURSOR);
}

if (newf == cur) {
cur = diaGetFirstControl(ui);
}
else {
cur = newf;
}
newf = diaGetNextControl(cur, cur);
if (newf == cur)
newf = diaGetFirstControl(ui);
}

if (getKey(KEY_UP)) {
// find
struct UIItem *newf = diaGetPrevLine(cur, ui);

if (!toggleSfx) {
sfxPlay(SFX_CURSOR);
}

if (newf == cur) {
cur = diaGetLastControl(ui);
}
else {
cur = newf;
}
newf = diaGetPrevLine(cur, ui);
if (newf == cur)
newf = diaGetLastControl(ui);
}

if (getKey(KEY_DOWN)) {
// find
struct UIItem *newf = diaGetNextLine(cur, ui);

if (!toggleSfx) {
sfxPlay(SFX_CURSOR);
}
newf = diaGetNextLine(cur, ui);
if (newf == cur)
newf = diaGetFirstControl(ui);
}

if (newf == cur) {
cur = diaGetFirstControl(ui);
}
else {
cur = newf;
}
if (newf != cur) {
// Navigation change detected
sfxPlay(SFX_CURSOR);
cur = newf;
}

// Cancel button breaks focus or exits with false result
Expand Down
2 changes: 0 additions & 2 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ void guiShowAbout()
char OPLVersion[40];
char OPLBuildDetails[40];

toggleSfx = 1; //user cannot navigate we don't want to hear cursor sfx
snprintf(OPLVersion, sizeof(OPLVersion), _l(_STR_OPL_VER), OPL_VERSION);
diaSetLabel(diaAbout, ABOUT_TITLE, OPLVersion);

Expand All @@ -220,7 +219,6 @@ void guiShowAbout()
diaSetLabel(diaAbout, ABOUT_BUILD_DETAILS, OPLBuildDetails);

diaExecuteDialog(diaAbout, -1, 1, NULL);
toggleSfx = 0;
}

void guiCheckNotifications(int checkTheme, int checkLang)
Expand Down
4 changes: 0 additions & 4 deletions src/guigame.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ static int guiGameRefreshVMCConfig(item_list_t *support, char *name)
diaSetEnabled(diaVMC, VMC_SIZE, 0);
diaSetEnabled(diaVMC, VMC_BUTTON_CREATE, 0);
diaSetEnabled(diaVMC, VMC_BUTTON_DELETE, 0);
toggleSfx = 1; //user cannot navigate we don't want to hear cursor sfx
}
} else {
diaSetLabel(diaVMC, VMC_BUTTON_CREATE, _l(_STR_CREATE));
Expand Down Expand Up @@ -253,7 +252,6 @@ static int guiGameShowVMCConfig(int id, item_list_t *support, char *VMCName, int
break;

} while (1);
toggleSfx = 0;

return result;
}
Expand Down Expand Up @@ -724,7 +722,6 @@ void guiGameShowPadEmuConfig(void)
}

if (result == PADCFG_BTINFO) {
toggleSfx = 1; //user cannot navigate we don't want to hear cursor sfx
for (i = PADCFG_FEAT_START; i < PADCFG_FEAT_END + 1; i++)
diaSetLabel(diaPadEmuInfo, i, _l(_STR_NO));

Expand All @@ -738,7 +735,6 @@ void guiGameShowPadEmuConfig(void)
ver_set = 0;
feat_set = 0;
diaExecuteDialog(diaPadEmuInfo, -1, 1, &guiGamePadEmuInfoUpdater);
toggleSfx = 0;
}

if (result == UIID_BTN_OK)
Expand Down

0 comments on commit 417f20c

Please sign in to comment.