aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/text.cpp
diff options
context:
space:
mode:
authorDavid Turner2011-12-18 18:29:05 -0800
committerDavid Turner2011-12-18 18:29:05 -0800
commit538d83408091e9077f451f45c1ac1127f302b47d (patch)
treea8b3ffaf9199665b41e8f990549fc267c6421b46 /engines/agi/text.cpp
parentf0eee81d327957cddb85c5a1ffe7a308a377f636 (diff)
parentf722542ceea557e906699c60b10b3ace1f41c238 (diff)
downloadscummvm-rg350-538d83408091e9077f451f45c1ac1127f302b47d.tar.gz
scummvm-rg350-538d83408091e9077f451f45c1ac1127f302b47d.tar.bz2
scummvm-rg350-538d83408091e9077f451f45c1ac1127f302b47d.zip
Merge pull request #131 from digitall/goto_considered_harmful
Goto Considered Harmful... The following commits should improve the ScummVM code structure by reducing the number of gotos used in various engine code. They should implement identical functionality, but without using goto and without the result being less readable/maintainable than the version with goto.
Diffstat (limited to 'engines/agi/text.cpp')
-rw-r--r--engines/agi/text.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 3247862e32..1886a74ab1 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -340,8 +340,6 @@ int AgiEngine::messageBox(const char *s) {
int AgiEngine::selectionBox(const char *m, const char **b) {
int numButtons = 0;
int x, y, i, s;
- int key, active = 0;
- int rc = -1;
int bx[5], by[5];
_noSaveLoadAllowed = true;
@@ -380,7 +378,9 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
AllowSyntheticEvents on(this);
debugC(4, kDebugLevelText, "selectionBox(): waiting...");
- while (!(shouldQuit() || _restartGame)) {
+ int key, active = 0;
+ int rc = -1;
+ while (rc == -1 && !(shouldQuit() || _restartGame)) {
for (i = 0; b[i]; i++)
_gfx->drawCurrentStyleButton(bx[i], by[i], b[i], i == active, false, i == 0);
@@ -389,10 +389,8 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
switch (key) {
case KEY_ENTER:
rc = active;
- goto press;
- case KEY_ESCAPE:
- rc = -1;
- goto getout;
+ debugC(4, kDebugLevelText, "selectionBox(): Button pressed: %d", rc);
+ break;
case KEY_RIGHT:
active++;
if (active >= numButtons)
@@ -407,7 +405,8 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
for (i = 0; b[i]; i++) {
if (_gfx->testButton(bx[i], by[i], b[i])) {
rc = active = i;
- goto press;
+ debugC(4, kDebugLevelText, "selectionBox(): Button pressed: %d", rc);
+ break;
}
}
break;
@@ -418,12 +417,11 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
break;
}
_gfx->doUpdate();
- }
-press:
- debugC(4, kDebugLevelText, "selectionBox(): Button pressed: %d", rc);
+ if (key == KEY_ESCAPE)
+ break;
+ }
-getout:
closeWindow();
debugC(2, kDebugLevelText, "selectionBox(): Result = %d", rc);