aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-07-12 18:31:48 +0000
committerTorbjörn Andersson2005-07-12 18:31:48 +0000
commitf756b74d043d7a76ce09b80078ad5f77a9b6af9c (patch)
tree3e10da2ece179ab150696c39a5e062f8b09514f1
parenta2d809f854d7717f30b6595edd3a0509ea24fcf6 (diff)
downloadscummvm-rg350-f756b74d043d7a76ce09b80078ad5f77a9b6af9c.tar.gz
scummvm-rg350-f756b74d043d7a76ce09b80078ad5f77a9b6af9c.tar.bz2
scummvm-rg350-f756b74d043d7a76ce09b80078ad5f77a9b6af9c.zip
Made it possible to terminate dialog windows with Enter. (We could already
terminate them with Esc.) This is so that, for instance, if you type a savegame name you can press Enter, rather than clicking on the "Save" button. I don't know if the original did this as well, but it feels natural to me. svn-id: r18537
-rw-r--r--saga/interface.cpp84
-rw-r--r--saga/interface.h2
2 files changed, 50 insertions, 36 deletions
diff --git a/saga/interface.cpp b/saga/interface.cpp
index 855ded1cf2..286e8460eb 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -320,6 +320,11 @@ void Interface::setMode(int mode) {
}
bool Interface::processAscii(uint16 ascii, bool synthetic) {
+ // TODO: Checking for Esc and Enter below is a bit hackish, and
+ // and probably only works with the English version. Maybe we should
+ // add a flag to the button so it can indicate if it's the default or
+ // cancel button?
+
int i;
PanelButton *panelButton;
if (!synthetic)
@@ -330,7 +335,7 @@ bool Interface::processAscii(uint16 ascii, bool synthetic) {
}
switch (_panelMode) {
case kPanelNull:
- if (ascii == 27) {// Esc
+ if (ascii == 27) { // Esc
if (_vm->_scene->isInDemo()) {
_vm->_scene->skipScene();
} else {
@@ -340,48 +345,54 @@ bool Interface::processAscii(uint16 ascii, bool synthetic) {
}
break;
case kPanelOption:
- //TODO: check input dialog keys
- if (ascii == 27) {// Esc
+ // TODO: check input dialog keys
+ if (ascii == 27 || ascii == 13) { // Esc or Enter
ascii = 'c'; //continue
}
+
for (i = 0; i < _optionPanel.buttonsCount; i++) {
panelButton = &_optionPanel.buttons[i];
if (panelButton->type == kPanelButtonOption) {
if (panelButton->ascii == ascii) {
- setOption(panelButton);
+ setOption(panelButton);
return true;
}
}
}
break;
case kPanelSave:
- if (_textInput) {
- processTextInput(ascii);
+ if (_textInput && processTextInput(ascii)) {
return true;
- } else {
- if (ascii == 27) {// Esc
- ascii = 'c'; //cancel
- }
- for (i = 0; i < _savePanel.buttonsCount; i++) {
- panelButton = &_savePanel.buttons[i];
- if (panelButton->type == kPanelButtonSave) {
- if (panelButton->ascii == ascii) {
- setSave(panelButton);
- return true;
- }
+ }
+
+ if (ascii == 27) { // Esc
+ ascii = 'c'; // cancel
+ } else if (ascii == 13) { // Enter
+ ascii = 's'; // save
+ }
+
+ for (i = 0; i < _savePanel.buttonsCount; i++) {
+ panelButton = &_savePanel.buttons[i];
+ if (panelButton->type == kPanelButtonSave) {
+ if (panelButton->ascii == ascii) {
+ setSave(panelButton);
+ return true;
}
}
}
break;
case kPanelQuit:
- if (ascii == 27) {// Esc
- ascii = 'c'; //cancel
+ if (ascii == 27) { // Esc
+ ascii = 'c'; // cancel
+ } else if (ascii == 13) { // Enter
+ ascii = 'q'; // quit
}
+
for (i = 0; i < _quitPanel.buttonsCount; i++) {
panelButton = &_quitPanel.buttons[i];
if (panelButton->type == kPanelButtonQuit) {
if (panelButton->ascii == ascii) {
- setQuit(panelButton);
+ setQuit(panelButton);
return true;
}
}
@@ -392,7 +403,7 @@ bool Interface::processAscii(uint16 ascii, bool synthetic) {
panelButton = &_loadPanel.buttons[i];
if (panelButton->type == kPanelButtonLoad) {
if (panelButton->ascii == ascii) {
- setLoad(panelButton);
+ setLoad(panelButton);
return true;
}
}
@@ -827,17 +838,17 @@ void Interface::processStatusTextInput(uint16 ascii) {
textInputStartRepeat(ascii);
switch (ascii) {
- case(27): // esc
+ case 27: // esc
_statusTextInputState = kStatusTextInputAborted;
_statusTextInput = false;
_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
break;
- case(13): // return
+ case 13: // return
_statusTextInputState = kStatusTextInputEntered;
_statusTextInput = false;
_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
break;
- case(8): // backspace
+ case 8: // backspace
if (_statusTextInputPos == 0) {
break;
}
@@ -858,7 +869,7 @@ void Interface::processStatusTextInput(uint16 ascii) {
setStatusText(_statusTextInputString);
}
-void Interface::processTextInput(uint16 ascii) {
+bool Interface::processTextInput(uint16 ascii) {
char ch[2];
char tempString[SAVE_TITLE_SIZE];
uint tempWidth;
@@ -868,15 +879,17 @@ void Interface::processTextInput(uint16 ascii) {
textInputStartRepeat(ascii);
switch (ascii) {
- case(27): // esc
+ case 13:
+ return false;
+ case 27: // esc
_textInput = false;
break;
- case(8): // backspace
+ case 8: // backspace
if (_textInputPos <= 1) {
break;
}
_textInputPos--;
- case(127): // del
+ case 127: // del
if (_textInputPos <= _textInputStringLength) {
if (_textInputPos != 1) {
strncpy(tempString, _textInputString, _textInputPos - 1);
@@ -888,12 +901,12 @@ void Interface::processTextInput(uint16 ascii) {
_textInputStringLength = strlen(_textInputString);
}
break;
- case(276): // left
+ case 276: // left
if (_textInputPos > 1) {
_textInputPos--;
}
break;
- case(275): // right
+ case 275: // right
if (_textInputPos <= _textInputStringLength) {
_textInputPos++;
}
@@ -928,6 +941,7 @@ void Interface::processTextInput(uint16 ascii) {
}
break;
}
+ return true;
}
void Interface::drawTextInput(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) {
@@ -1578,7 +1592,7 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo
byte odl, our, idl, iur;
switch (kind ) {
- case( kSlider):
+ case kSlider:
cornerColor = 0x8b;
frameColor = kITEColorBlack;
fillColor = kITEColorLightBlue96;
@@ -1588,7 +1602,7 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo
iur = 0x94;
solidColor = down ? kITEColorLightBlue94 : kITEColorLightBlue96;
break;
- case( kEdit):
+ case kEdit:
cornerColor = kITEColorLightBlue96;
frameColor = kITEColorLightBlue96;
fillColor = kITEColorLightBlue96;
@@ -1675,13 +1689,13 @@ void Interface::drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelBut
textId = panelButton->id;
switch(panelButton->id) {
- case(kTextReadingSpeed):
+ case kTextReadingSpeed:
textId = kTextFast;
break;
- case(kTextMusic):
+ case kTextMusic:
textId = kTextOn;
break;
- case(kTextSound):
+ case kTextSound:
textId = kTextOn;
break;
}
diff --git a/saga/interface.h b/saga/interface.h
index afc0853275..050169a9bd 100644
--- a/saga/interface.h
+++ b/saga/interface.h
@@ -335,7 +335,7 @@ private:
void drawVerbPanelText(Surface *ds, PanelButton *panelButton, int textColor, int textShadowColor);
void drawVerbPanel(Surface *backBuffer, PanelButton* panelButton);
void calcOptionSaveSlider();
- void processTextInput(uint16 ascii);
+ bool processTextInput(uint16 ascii);
void processStatusTextInput(uint16 ascii);
void textInputStartRepeat(uint16 ascii);
void textInputRepeat(void);