MYST3: Implement keyboard input for savegame file name
This commit is contained in:
parent
49075bc1ff
commit
be8b8d8909
4 changed files with 38 additions and 1 deletions
|
@ -285,7 +285,7 @@ void Renderer::draw2DText(const Common::String &text, const Common::Point &posit
|
|||
glVertex3f(x, y + h, 1.0f);
|
||||
glEnd();
|
||||
|
||||
x += textureRect.width() - 2;
|
||||
x += textureRect.width() - 3;
|
||||
}
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
|
|
@ -483,6 +483,38 @@ void Menu::draw() {
|
|||
}
|
||||
}
|
||||
|
||||
void Menu::handleInput(const Common::KeyState &e) {
|
||||
uint16 node = _vm->_state->getLocationNode();
|
||||
uint16 room = _vm->_state->getLocationRoom();
|
||||
uint16 item = _vm->_state->getMenuSaveLoadSelectedItem();
|
||||
|
||||
if (room != 901 || node != 300 || item != 7)
|
||||
return;
|
||||
|
||||
Common::String display = prepareSaveNameForDisplay(_saveName);
|
||||
|
||||
if (e.keycode == Common::KEYCODE_BACKSPACE
|
||||
|| e.keycode == Common::KEYCODE_DELETE) {
|
||||
display.deleteLastChar();
|
||||
_saveName = display;
|
||||
return;
|
||||
} else if (e.keycode == Common::KEYCODE_RETURN
|
||||
|| e.keycode == Common::KEYCODE_KP_ENTER) {
|
||||
saveMenuSave();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((e.ascii >= 'a' && e.ascii <= 'z'
|
||||
|| e.ascii >= 'A' && e.ascii <= 'Z'
|
||||
|| e.ascii >= '0' && e.ascii <= '9'
|
||||
|| e.ascii == ' ')
|
||||
&& (display.size() < 17)) {
|
||||
display += e.ascii;
|
||||
display.toUppercase();
|
||||
_saveName = display;
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::loadMenuChangePage() {
|
||||
saveLoadUpdateVars();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "engines/myst3/gfx.h"
|
||||
|
||||
#include "common/events.h"
|
||||
#include "common/memstream.h"
|
||||
#include "common/rect.h"
|
||||
#include "common/savefile.h"
|
||||
|
@ -44,6 +45,7 @@ public:
|
|||
virtual ~Menu();
|
||||
|
||||
void draw();
|
||||
void handleInput(const Common::KeyState &e);
|
||||
|
||||
void updateMainMenu(uint16 action);
|
||||
void goToNode(uint16 node);
|
||||
|
|
|
@ -271,6 +271,9 @@ void Myst3Engine::processInput(bool lookOnly) {
|
|||
}
|
||||
|
||||
} else if (event.type == Common::EVENT_KEYDOWN) {
|
||||
// Save file name input
|
||||
_menu->handleInput(event.kbd);
|
||||
|
||||
switch (event.kbd.keycode) {
|
||||
case Common::KEYCODE_ESCAPE:
|
||||
// Open main menu
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue