AGI: Make inner loop handlers consistent

This commit is contained in:
Martin Kiewitz 2016-02-03 01:41:32 +01:00
parent 8271058a45
commit 702b66a49d
9 changed files with 39 additions and 39 deletions

View file

@ -228,7 +228,7 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) {
if (!handleController(key)) { if (!handleController(key)) {
if (key) { if (key) {
if (_text->promptIsEnabled()) { if (_text->promptIsEnabled()) {
_text->promptCharPress(key); _text->promptKeyPress(key);
} }
} }
} }
@ -241,19 +241,19 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) {
case CYCLE_INNERLOOP_GETSTRING: // loop called from TextMgr::stringEdit() case CYCLE_INNERLOOP_GETSTRING: // loop called from TextMgr::stringEdit()
case CYCLE_INNERLOOP_GETNUMBER: case CYCLE_INNERLOOP_GETNUMBER:
if (key) { if (key) {
_text->stringCharPress(key); _text->stringKeyPress(key);
} }
break; break;
case CYCLE_INNERLOOP_INVENTORY: // loop called from InventoryMgr::show() case CYCLE_INNERLOOP_INVENTORY: // loop called from InventoryMgr::show()
if (key) { if (key) {
_inventory->charPress(key); _inventory->keyPress(key);
} }
break; break;
case CYCLE_INNERLOOP_MENU_VIA_KEYBOARD: case CYCLE_INNERLOOP_MENU_VIA_KEYBOARD:
if (key) { if (key) {
_menu->charPress(key); _menu->keyPress(key);
} }
return false; return false;
@ -263,13 +263,13 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) {
case CYCLE_INNERLOOP_SYSTEMUI_SELECTSAVEDGAMESLOT: case CYCLE_INNERLOOP_SYSTEMUI_SELECTSAVEDGAMESLOT:
if (key) { if (key) {
_systemUI->savedGameSlot_CharPress(key); _systemUI->savedGameSlot_KeyPress(key);
} }
break; break;
case CYCLE_INNERLOOP_MESSAGEBOX: case CYCLE_INNERLOOP_MESSAGEBOX:
if (key) { if (key) {
_text->messageBox_CharPress(key); _text->messageBox_KeyPress(key);
} }
break; break;

View file

@ -165,8 +165,8 @@ void InventoryMgr::show() {
} }
} }
void InventoryMgr::charPress(int16 newChar) { void InventoryMgr::keyPress(uint16 newKey) {
switch (newChar) { switch (newKey) {
case AGI_KEY_ENTER: { case AGI_KEY_ENTER: {
_vm->cycleInnerLoopInactive(); // exit show-loop _vm->cycleInnerLoopInactive(); // exit show-loop
break; break;

View file

@ -52,7 +52,7 @@ public:
void drawItem(int16 itemNr); void drawItem(int16 itemNr);
void show(); void show();
void charPress(int16 newChar); void keyPress(uint16 newKey);
void changeActiveItem(int16 direction); void changeActiveItem(int16 direction);
}; };

View file

@ -433,13 +433,13 @@ void GfxMenu::removeActiveMenu(int16 selectedMenuNr) {
_gfx->render_Block(_drawnMenuColumn, _drawnMenuRow, _drawnMenuWidth, _drawnMenuHeight); _gfx->render_Block(_drawnMenuColumn, _drawnMenuRow, _drawnMenuWidth, _drawnMenuHeight);
} }
void GfxMenu::charPress(uint16 newChar) { void GfxMenu::keyPress(uint16 newKey) {
GuiMenuEntry *menuEntry = _array[_drawnMenuNr]; GuiMenuEntry *menuEntry = _array[_drawnMenuNr];
GuiMenuItemEntry *itemEntry = _itemArray[menuEntry->selectedItemNr]; GuiMenuItemEntry *itemEntry = _itemArray[menuEntry->selectedItemNr];
int16 newMenuNr = _drawnMenuNr; int16 newMenuNr = _drawnMenuNr;
int16 newItemNr = menuEntry->selectedItemNr; int16 newItemNr = menuEntry->selectedItemNr;
switch (newChar) { switch (newKey) {
case AGI_KEY_ENTER: case AGI_KEY_ENTER:
// check, if current item is actually enabled // check, if current item is actually enabled
if (!itemEntry->enabled) if (!itemEntry->enabled)
@ -529,7 +529,7 @@ void GfxMenu::charPress(uint16 newChar) {
// During "via keyboard" mode in case user actively clicks on something // During "via keyboard" mode in case user actively clicks on something
// During "via mouse" mode all the time, so that current mouse cursor position modifies active selection // During "via mouse" mode all the time, so that current mouse cursor position modifies active selection
// In "via mouse" mode, we check if user let go of the left mouse button and then select the item that way // In "via mouse" mode, we check if user let go of the left mouse button and then select the item that way
void GfxMenu::mouseEvent(uint16 newChar) { void GfxMenu::mouseEvent(uint16 newKey) {
// Find out, where current mouse cursor actually is // Find out, where current mouse cursor actually is
int16 mouseRow = _vm->_mouse.pos.y / FONT_DISPLAY_HEIGHT; int16 mouseRow = _vm->_mouse.pos.y / FONT_DISPLAY_HEIGHT;
int16 mouseColumn = _vm->_mouse.pos.x / FONT_DISPLAY_WIDTH; int16 mouseColumn = _vm->_mouse.pos.x / FONT_DISPLAY_WIDTH;
@ -537,7 +537,7 @@ void GfxMenu::mouseEvent(uint16 newChar) {
int16 activeMenuNr, activeItemNr; int16 activeMenuNr, activeItemNr;
mouseFindMenuSelection(mouseRow, mouseColumn, activeMenuNr, activeItemNr); mouseFindMenuSelection(mouseRow, mouseColumn, activeMenuNr, activeItemNr);
switch (newChar) { switch (newKey) {
case AGI_MOUSE_BUTTON_LEFT: case AGI_MOUSE_BUTTON_LEFT:
// User clicked somewhere, in this case check if user clicked on status bar or on one of the currently shown menu items // User clicked somewhere, in this case check if user clicked on status bar or on one of the currently shown menu items
// Happens in "via keyboard" mode only // Happens in "via keyboard" mode only

View file

@ -65,8 +65,8 @@ public:
void itemDisable(uint16 controllerSlot); void itemDisable(uint16 controllerSlot);
void itemEnableAll(); void itemEnableAll();
void charPress(uint16 newChar); void keyPress(uint16 newKey);
void mouseEvent(uint16 newChar); void mouseEvent(uint16 newKey);
bool isAvailable(); bool isAvailable();

View file

@ -295,13 +295,13 @@ int16 SystemUI::askForSavedGameSlot(const char *slotListText) {
return _savedGameSelectedSlotNr; return _savedGameSelectedSlotNr;
} }
void SystemUI::savedGameSlot_CharPress(int16 newChar) { void SystemUI::savedGameSlot_KeyPress(uint16 newKey) {
int16 slotCount = _savedGameArray.size(); int16 slotCount = _savedGameArray.size();
int16 newUpmostSlotNr = _savedGameUpmostSlotNr; int16 newUpmostSlotNr = _savedGameUpmostSlotNr;
int16 newSelectedSlotNr = _savedGameSelectedSlotNr; int16 newSelectedSlotNr = _savedGameSelectedSlotNr;
bool slotsScrolled = false; bool slotsScrolled = false;
switch (newChar) { switch (newKey) {
case AGI_KEY_ENTER: case AGI_KEY_ENTER:
_vm->cycleInnerLoopInactive(); // exit savedGameSlot-loop _vm->cycleInnerLoopInactive(); // exit savedGameSlot-loop
return; return;

View file

@ -71,7 +71,7 @@ public:
int16 askForRestoreGameSlot(); int16 askForRestoreGameSlot();
bool askForSaveGameDescription(int16 slotId, Common::String &newDescription); bool askForSaveGameDescription(int16 slotId, Common::String &newDescription);
void savedGameSlot_CharPress(int16 newChar); void savedGameSlot_KeyPress(uint16 newKey);
private: private:
int16 askForSavedGameSlot(const char *slotListText); int16 askForSavedGameSlot(const char *slotListText);

View file

@ -383,7 +383,7 @@ bool TextMgr::messageBox(const char *textPtr) {
return true; return true;
} }
void TextMgr::messageBox_CharPress(uint16 newKey) { void TextMgr::messageBox_KeyPress(uint16 newKey) {
switch (newKey) { switch (newKey) {
case AGI_KEY_ENTER: case AGI_KEY_ENTER:
_vm->cycleInnerLoopInactive(); // exit messagebox-loop _vm->cycleInnerLoopInactive(); // exit messagebox-loop
@ -616,7 +616,7 @@ bool TextMgr::promptIsEnabled() {
return _promptEnabled; return _promptEnabled;
} }
void TextMgr::promptCharPress(int16 newChar) { void TextMgr::promptKeyPress(uint16 newKey) {
int16 maxChars = 0; int16 maxChars = 0;
int16 scriptsInputLen = _vm->getVar(VM_VAR_MAX_INPUT_CHARACTERS); int16 scriptsInputLen = _vm->getVar(VM_VAR_MAX_INPUT_CHARACTERS);
@ -634,12 +634,12 @@ void TextMgr::promptCharPress(int16 newChar) {
inputEditOn(); inputEditOn();
switch (newChar) { switch (newKey) {
case AGI_KEY_BACKSPACE: { case AGI_KEY_BACKSPACE: {
if (_promptCursorPos) { if (_promptCursorPos) {
_promptCursorPos--; _promptCursorPos--;
_prompt[_promptCursorPos] = 0; _prompt[_promptCursorPos] = 0;
displayCharacter(newChar); displayCharacter(newKey);
promptRememberForAutoComplete(); promptRememberForAutoComplete();
} }
@ -671,20 +671,20 @@ void TextMgr::promptCharPress(int16 newChar) {
// but as soon as invalid characters were used in graphics mode they weren't properly shown // but as soon as invalid characters were used in graphics mode they weren't properly shown
switch (_vm->getLanguage()) { switch (_vm->getLanguage()) {
case Common::RU_RUS: case Common::RU_RUS:
if (newChar >= 0x20) if (newKey >= 0x20)
acceptableInput = true; acceptableInput = true;
break; break;
default: default:
if ((newChar >= 0x20) && (newChar <= 0x7f)) if ((newKey >= 0x20) && (newKey <= 0x7f))
acceptableInput = true; acceptableInput = true;
break; break;
} }
if (acceptableInput) { if (acceptableInput) {
_prompt[_promptCursorPos] = newChar; _prompt[_promptCursorPos] = newKey;
_promptCursorPos++; _promptCursorPos++;
_prompt[_promptCursorPos] = 0; _prompt[_promptCursorPos] = 0;
displayCharacter(newChar); displayCharacter(newKey);
promptRememberForAutoComplete(); promptRememberForAutoComplete();
} }
@ -697,7 +697,7 @@ void TextMgr::promptCharPress(int16 newChar) {
void TextMgr::promptCancelLine() { void TextMgr::promptCancelLine() {
while (_promptCursorPos) { while (_promptCursorPos) {
promptCharPress(0x08); // Backspace until prompt is empty promptKeyPress(0x08); // Backspace until prompt is empty
} }
} }
@ -708,7 +708,7 @@ void TextMgr::promptEchoLine() {
inputEditOn(); inputEditOn();
while (_promptPrevious[_promptCursorPos]) { while (_promptPrevious[_promptCursorPos]) {
promptCharPress(_promptPrevious[_promptCursorPos]); promptKeyPress(_promptPrevious[_promptCursorPos]);
} }
promptRememberForAutoComplete(); promptRememberForAutoComplete();
@ -795,10 +795,10 @@ void TextMgr::stringEdit(int16 stringMaxLen) {
_vm->nonBlockingText_Forget(); _vm->nonBlockingText_Forget();
} }
void TextMgr::stringCharPress(int16 newChar) { void TextMgr::stringKeyPress(uint16 newKey) {
inputEditOn(); inputEditOn();
switch (newChar) { switch (newKey) {
case 0x3: // ctrl-c case 0x3: // ctrl-c
case 0x18: { // ctrl-x case 0x18: { // ctrl-x
// clear string // clear string
@ -814,7 +814,7 @@ void TextMgr::stringCharPress(int16 newChar) {
if (_inputStringCursorPos) { if (_inputStringCursorPos) {
_inputStringCursorPos--; _inputStringCursorPos--;
_inputString[_inputStringCursorPos] = 0; _inputString[_inputStringCursorPos] = 0;
displayCharacter(newChar); displayCharacter(newKey);
stringRememberForAutoComplete(); stringRememberForAutoComplete();
} }
@ -848,23 +848,23 @@ void TextMgr::stringCharPress(int16 newChar) {
// but as soon as invalid characters were used in graphics mode they weren't properly shown // but as soon as invalid characters were used in graphics mode they weren't properly shown
switch (_vm->getLanguage()) { switch (_vm->getLanguage()) {
case Common::RU_RUS: case Common::RU_RUS:
if (newChar >= 0x20) if (newKey >= 0x20)
acceptableInput = true; acceptableInput = true;
break; break;
default: default:
if ((newChar >= 0x20) && (newChar <= 0x7f)) if ((newKey >= 0x20) && (newKey <= 0x7f))
acceptableInput = true; acceptableInput = true;
break; break;
} }
if (acceptableInput) { if (acceptableInput) {
if ((_vm->_game.cycleInnerLoopType == CYCLE_INNERLOOP_GETSTRING) || ((newChar >= '0') && (newChar <= '9'))) { if ((_vm->_game.cycleInnerLoopType == CYCLE_INNERLOOP_GETSTRING) || ((newKey >= '0') && (newKey <= '9'))) {
// Additionally check for GETNUMBER-mode, if character is a number // Additionally check for GETNUMBER-mode, if character is a number
// Sierra also did not do this // Sierra also did not do this
_inputString[_inputStringCursorPos] = newChar; _inputString[_inputStringCursorPos] = newKey;
_inputStringCursorPos++; _inputStringCursorPos++;
_inputString[_inputStringCursorPos] = 0; _inputString[_inputStringCursorPos] = 0;
displayCharacter(newChar); displayCharacter(newKey);
stringRememberForAutoComplete(); stringRememberForAutoComplete();
} }

View file

@ -132,7 +132,7 @@ public:
void print(int16 textNr); void print(int16 textNr);
bool messageBox(const char *textPtr); bool messageBox(const char *textPtr);
void messageBox_CharPress(uint16 newKey); void messageBox_KeyPress(uint16 newKey);
bool _messageBoxCancelled; bool _messageBoxCancelled;
@ -180,7 +180,7 @@ public:
void promptRow_Set(int16 row); void promptRow_Set(int16 row);
int16 promptRow_Get(); int16 promptRow_Get();
void promptCharPress(int16 newChar); void promptKeyPress(uint16 newKey);
void promptCancelLine(); void promptCancelLine();
void promptEchoLine(); void promptEchoLine();
void promptRedraw(); void promptRedraw();
@ -199,7 +199,7 @@ public:
int16 stringGetMaxLen(); int16 stringGetMaxLen();
void stringSet(const char *text); void stringSet(const char *text);
void stringEdit(int16 stringMaxLen); void stringEdit(int16 stringMaxLen);
void stringCharPress(int16 newChar); void stringKeyPress(uint16 newKey);
void stringRememberForAutoComplete(bool entered = false); // for auto-completion void stringRememberForAutoComplete(bool entered = false); // for auto-completion
char *stringPrintf(const char *originalText); char *stringPrintf(const char *originalText);