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
This commit is contained in:
parent
a2d809f854
commit
f756b74d04
2 changed files with 50 additions and 36 deletions
|
@ -320,6 +320,11 @@ void Interface::setMode(int mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Interface::processAscii(uint16 ascii, bool synthetic) {
|
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;
|
int i;
|
||||||
PanelButton *panelButton;
|
PanelButton *panelButton;
|
||||||
if (!synthetic)
|
if (!synthetic)
|
||||||
|
@ -330,7 +335,7 @@ bool Interface::processAscii(uint16 ascii, bool synthetic) {
|
||||||
}
|
}
|
||||||
switch (_panelMode) {
|
switch (_panelMode) {
|
||||||
case kPanelNull:
|
case kPanelNull:
|
||||||
if (ascii == 27) {// Esc
|
if (ascii == 27) { // Esc
|
||||||
if (_vm->_scene->isInDemo()) {
|
if (_vm->_scene->isInDemo()) {
|
||||||
_vm->_scene->skipScene();
|
_vm->_scene->skipScene();
|
||||||
} else {
|
} else {
|
||||||
|
@ -340,48 +345,54 @@ bool Interface::processAscii(uint16 ascii, bool synthetic) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kPanelOption:
|
case kPanelOption:
|
||||||
//TODO: check input dialog keys
|
// TODO: check input dialog keys
|
||||||
if (ascii == 27) {// Esc
|
if (ascii == 27 || ascii == 13) { // Esc or Enter
|
||||||
ascii = 'c'; //continue
|
ascii = 'c'; //continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < _optionPanel.buttonsCount; i++) {
|
for (i = 0; i < _optionPanel.buttonsCount; i++) {
|
||||||
panelButton = &_optionPanel.buttons[i];
|
panelButton = &_optionPanel.buttons[i];
|
||||||
if (panelButton->type == kPanelButtonOption) {
|
if (panelButton->type == kPanelButtonOption) {
|
||||||
if (panelButton->ascii == ascii) {
|
if (panelButton->ascii == ascii) {
|
||||||
setOption(panelButton);
|
setOption(panelButton);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kPanelSave:
|
case kPanelSave:
|
||||||
if (_textInput) {
|
if (_textInput && processTextInput(ascii)) {
|
||||||
processTextInput(ascii);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
if (ascii == 27) {// Esc
|
|
||||||
ascii = 'c'; //cancel
|
if (ascii == 27) { // Esc
|
||||||
}
|
ascii = 'c'; // cancel
|
||||||
for (i = 0; i < _savePanel.buttonsCount; i++) {
|
} else if (ascii == 13) { // Enter
|
||||||
panelButton = &_savePanel.buttons[i];
|
ascii = 's'; // save
|
||||||
if (panelButton->type == kPanelButtonSave) {
|
}
|
||||||
if (panelButton->ascii == ascii) {
|
|
||||||
setSave(panelButton);
|
for (i = 0; i < _savePanel.buttonsCount; i++) {
|
||||||
return true;
|
panelButton = &_savePanel.buttons[i];
|
||||||
}
|
if (panelButton->type == kPanelButtonSave) {
|
||||||
|
if (panelButton->ascii == ascii) {
|
||||||
|
setSave(panelButton);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kPanelQuit:
|
case kPanelQuit:
|
||||||
if (ascii == 27) {// Esc
|
if (ascii == 27) { // Esc
|
||||||
ascii = 'c'; //cancel
|
ascii = 'c'; // cancel
|
||||||
|
} else if (ascii == 13) { // Enter
|
||||||
|
ascii = 'q'; // quit
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < _quitPanel.buttonsCount; i++) {
|
for (i = 0; i < _quitPanel.buttonsCount; i++) {
|
||||||
panelButton = &_quitPanel.buttons[i];
|
panelButton = &_quitPanel.buttons[i];
|
||||||
if (panelButton->type == kPanelButtonQuit) {
|
if (panelButton->type == kPanelButtonQuit) {
|
||||||
if (panelButton->ascii == ascii) {
|
if (panelButton->ascii == ascii) {
|
||||||
setQuit(panelButton);
|
setQuit(panelButton);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,7 +403,7 @@ bool Interface::processAscii(uint16 ascii, bool synthetic) {
|
||||||
panelButton = &_loadPanel.buttons[i];
|
panelButton = &_loadPanel.buttons[i];
|
||||||
if (panelButton->type == kPanelButtonLoad) {
|
if (panelButton->type == kPanelButtonLoad) {
|
||||||
if (panelButton->ascii == ascii) {
|
if (panelButton->ascii == ascii) {
|
||||||
setLoad(panelButton);
|
setLoad(panelButton);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -827,17 +838,17 @@ void Interface::processStatusTextInput(uint16 ascii) {
|
||||||
|
|
||||||
textInputStartRepeat(ascii);
|
textInputStartRepeat(ascii);
|
||||||
switch (ascii) {
|
switch (ascii) {
|
||||||
case(27): // esc
|
case 27: // esc
|
||||||
_statusTextInputState = kStatusTextInputAborted;
|
_statusTextInputState = kStatusTextInputAborted;
|
||||||
_statusTextInput = false;
|
_statusTextInput = false;
|
||||||
_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
|
_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
|
||||||
break;
|
break;
|
||||||
case(13): // return
|
case 13: // return
|
||||||
_statusTextInputState = kStatusTextInputEntered;
|
_statusTextInputState = kStatusTextInputEntered;
|
||||||
_statusTextInput = false;
|
_statusTextInput = false;
|
||||||
_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
|
_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
|
||||||
break;
|
break;
|
||||||
case(8): // backspace
|
case 8: // backspace
|
||||||
if (_statusTextInputPos == 0) {
|
if (_statusTextInputPos == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -858,7 +869,7 @@ void Interface::processStatusTextInput(uint16 ascii) {
|
||||||
setStatusText(_statusTextInputString);
|
setStatusText(_statusTextInputString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interface::processTextInput(uint16 ascii) {
|
bool Interface::processTextInput(uint16 ascii) {
|
||||||
char ch[2];
|
char ch[2];
|
||||||
char tempString[SAVE_TITLE_SIZE];
|
char tempString[SAVE_TITLE_SIZE];
|
||||||
uint tempWidth;
|
uint tempWidth;
|
||||||
|
@ -868,15 +879,17 @@ void Interface::processTextInput(uint16 ascii) {
|
||||||
textInputStartRepeat(ascii);
|
textInputStartRepeat(ascii);
|
||||||
|
|
||||||
switch (ascii) {
|
switch (ascii) {
|
||||||
case(27): // esc
|
case 13:
|
||||||
|
return false;
|
||||||
|
case 27: // esc
|
||||||
_textInput = false;
|
_textInput = false;
|
||||||
break;
|
break;
|
||||||
case(8): // backspace
|
case 8: // backspace
|
||||||
if (_textInputPos <= 1) {
|
if (_textInputPos <= 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_textInputPos--;
|
_textInputPos--;
|
||||||
case(127): // del
|
case 127: // del
|
||||||
if (_textInputPos <= _textInputStringLength) {
|
if (_textInputPos <= _textInputStringLength) {
|
||||||
if (_textInputPos != 1) {
|
if (_textInputPos != 1) {
|
||||||
strncpy(tempString, _textInputString, _textInputPos - 1);
|
strncpy(tempString, _textInputString, _textInputPos - 1);
|
||||||
|
@ -888,12 +901,12 @@ void Interface::processTextInput(uint16 ascii) {
|
||||||
_textInputStringLength = strlen(_textInputString);
|
_textInputStringLength = strlen(_textInputString);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(276): // left
|
case 276: // left
|
||||||
if (_textInputPos > 1) {
|
if (_textInputPos > 1) {
|
||||||
_textInputPos--;
|
_textInputPos--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(275): // right
|
case 275: // right
|
||||||
if (_textInputPos <= _textInputStringLength) {
|
if (_textInputPos <= _textInputStringLength) {
|
||||||
_textInputPos++;
|
_textInputPos++;
|
||||||
}
|
}
|
||||||
|
@ -928,6 +941,7 @@ void Interface::processTextInput(uint16 ascii) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interface::drawTextInput(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) {
|
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;
|
byte odl, our, idl, iur;
|
||||||
|
|
||||||
switch (kind ) {
|
switch (kind ) {
|
||||||
case( kSlider):
|
case kSlider:
|
||||||
cornerColor = 0x8b;
|
cornerColor = 0x8b;
|
||||||
frameColor = kITEColorBlack;
|
frameColor = kITEColorBlack;
|
||||||
fillColor = kITEColorLightBlue96;
|
fillColor = kITEColorLightBlue96;
|
||||||
|
@ -1588,7 +1602,7 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo
|
||||||
iur = 0x94;
|
iur = 0x94;
|
||||||
solidColor = down ? kITEColorLightBlue94 : kITEColorLightBlue96;
|
solidColor = down ? kITEColorLightBlue94 : kITEColorLightBlue96;
|
||||||
break;
|
break;
|
||||||
case( kEdit):
|
case kEdit:
|
||||||
cornerColor = kITEColorLightBlue96;
|
cornerColor = kITEColorLightBlue96;
|
||||||
frameColor = kITEColorLightBlue96;
|
frameColor = kITEColorLightBlue96;
|
||||||
fillColor = kITEColorLightBlue96;
|
fillColor = kITEColorLightBlue96;
|
||||||
|
@ -1675,13 +1689,13 @@ void Interface::drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelBut
|
||||||
|
|
||||||
textId = panelButton->id;
|
textId = panelButton->id;
|
||||||
switch(panelButton->id) {
|
switch(panelButton->id) {
|
||||||
case(kTextReadingSpeed):
|
case kTextReadingSpeed:
|
||||||
textId = kTextFast;
|
textId = kTextFast;
|
||||||
break;
|
break;
|
||||||
case(kTextMusic):
|
case kTextMusic:
|
||||||
textId = kTextOn;
|
textId = kTextOn;
|
||||||
break;
|
break;
|
||||||
case(kTextSound):
|
case kTextSound:
|
||||||
textId = kTextOn;
|
textId = kTextOn;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ private:
|
||||||
void drawVerbPanelText(Surface *ds, PanelButton *panelButton, int textColor, int textShadowColor);
|
void drawVerbPanelText(Surface *ds, PanelButton *panelButton, int textColor, int textShadowColor);
|
||||||
void drawVerbPanel(Surface *backBuffer, PanelButton* panelButton);
|
void drawVerbPanel(Surface *backBuffer, PanelButton* panelButton);
|
||||||
void calcOptionSaveSlider();
|
void calcOptionSaveSlider();
|
||||||
void processTextInput(uint16 ascii);
|
bool processTextInput(uint16 ascii);
|
||||||
void processStatusTextInput(uint16 ascii);
|
void processStatusTextInput(uint16 ascii);
|
||||||
void textInputStartRepeat(uint16 ascii);
|
void textInputStartRepeat(uint16 ascii);
|
||||||
void textInputRepeat(void);
|
void textInputRepeat(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue