diff options
author | Torbjörn Andersson | 2004-05-12 06:21:44 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2004-05-12 06:21:44 +0000 |
commit | d40de10534c5f69c9aa49a9fcffe1d6e6dca7d88 (patch) | |
tree | 8d5df2bf9c854cc918acf1aec3cac83ba020e9b7 | |
parent | 576e2986dd2453bc46567a40a4f84df369a3cfcd (diff) | |
download | scummvm-rg350-d40de10534c5f69c9aa49a9fcffe1d6e6dca7d88.tar.gz scummvm-rg350-d40de10534c5f69c9aa49a9fcffe1d6e6dca7d88.tar.bz2 scummvm-rg350-d40de10534c5f69c9aa49a9fcffe1d6e6dca7d88.zip |
Some usability fixes to the control panel code:
* Draw a blinking cursor when typing savegame names. (Bug #908679)
* Number the savegame slots. At the moment they are numbered differently
than in BS2 in that they start on 1 instead of 0. As far as I recall,
this was the case with the original engine as well, but we may want to
reconsider.
* Added scroll wheel support. This wasn't in the original, but it's a nice
thing to have. Particularly since the scroll buttons don't repeat. (It
would be nice if they did.)
I would like this patch to be considered for 0.6.1, if there aren't any
obvious problems with it.
svn-id: r13833
-rw-r--r-- | sword1/control.cpp | 48 | ||||
-rw-r--r-- | sword1/control.h | 2 | ||||
-rw-r--r-- | sword1/mouse.h | 2 |
3 files changed, 47 insertions, 5 deletions
diff --git a/sword1/control.cpp b/sword1/control.cpp index 038af5c084..047a91c3c0 100644 --- a/sword1/control.cpp +++ b/sword1/control.cpp @@ -257,6 +257,8 @@ uint8 Control::runPanel(void) { fullRefresh = true; destroyButtons(); memset(_screenBuf, 0, 640 * 480); + if (mode != BUTTON_SAVE_PANEL) + _cursorVisible = false; } switch (mode) { case BUTTON_MAIN_PANEL: @@ -268,8 +270,19 @@ uint8 Control::runPanel(void) { _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); setupSaveRestorePanel(true); } - if (_keyPressed) - handleSaveKey(_keyPressed); + if (_selectedSavegame < 255) { + bool visible = _cursorVisible; + if (_cursorTick == 0) + _cursorVisible = true; + else if (_cursorTick == 3) + _cursorVisible = false; + if (_keyPressed) + handleSaveKey(_keyPressed); + else if (_cursorVisible != visible) + showSavegameNames(); + if (++_cursorTick > 5) + _cursorTick = 0; + } break; case BUTTON_RESTORE_PANEL: if (fullRefresh) @@ -335,6 +348,16 @@ uint8 Control::getClicks(uint8 mode, uint8 *retVal) { } _selectedButton = 255; } + if (_mouseState & BS1_WHEEL_UP) { + for (uint8 cnt = 0; cnt < checkButtons; cnt++) + if (_buttons[cnt]->_id == BUTTON_SCROLL_UP_SLOW) + return handleButtonClick(_buttons[cnt]->_id, mode, retVal); + } + if (_mouseState & BS1_WHEEL_DOWN) { + for (uint8 cnt = 0; cnt < checkButtons; cnt++) + if (_buttons[cnt]->_id == BUTTON_SCROLL_DOWN_SLOW) + return handleButtonClick(_buttons[cnt]->_id, mode, retVal); + } return 0; } @@ -731,11 +754,15 @@ void Control::showSavegameNames(void) { _buttons[cnt]->draw(); uint8 textMode = TEXT_LEFT_ALIGN; uint16 ycoord = _saveButtons[cnt].y + 2; + uint8 str[40]; + sprintf((char*)str, "%d. %s", cnt + _saveScrollPos + 1, _saveNames[cnt + _saveScrollPos]); if (cnt + _saveScrollPos == _selectedSavegame) { textMode |= TEXT_RED_FONT; ycoord += 2; + if (_cursorVisible) + strcat((char*)str, "_"); } - renderText(_saveNames[cnt + _saveScrollPos], _saveButtons[cnt].x + 6, ycoord, textMode); + renderText(str, _saveButtons[cnt].x + 6, ycoord, textMode); } } @@ -758,6 +785,8 @@ void Control::saveNameSelect(uint8 id, bool saving) { _oldName[0] = '\0'; } } + if (_selectedSavegame < 255) + _cursorTick = 0; showSavegameNames(); } @@ -814,9 +843,10 @@ uint16 Control::getTextWidth(const uint8 *str) { void Control::renderText(const uint8 *str, uint16 x, uint16 y, uint8 mode) { uint8 *font = _font; - if (mode & TEXT_RED_FONT) + if (mode & TEXT_RED_FONT) { + mode &= ~TEXT_RED_FONT; font = _redFont; - mode &= ~TEXT_RED_FONT; + } if (mode == TEXT_RIGHT_ALIGN) // negative x coordinate means right-aligned. x -= getTextWidth(str); @@ -996,6 +1026,14 @@ void Control::delay(uint32 msecs) { _mouseDown = false; _mouseState |= BS1L_BUTTON_UP; break; + case OSystem::EVENT_WHEELUP: + _mouseDown = false; + _mouseState |= BS1_WHEEL_UP; + break; + case OSystem::EVENT_WHEELDOWN: + _mouseDown = false; + _mouseState |= BS1_WHEEL_DOWN; + break; case OSystem::EVENT_QUIT: _system->quit(); break; diff --git a/sword1/control.h b/sword1/control.h index ace9c3b14e..0c111cd469 100644 --- a/sword1/control.h +++ b/sword1/control.h @@ -88,6 +88,8 @@ private: uint8 _selectedSavegame; uint8 _saveNames[64][32]; uint8 _oldName[32]; + uint8 _cursorTick; + bool _cursorVisible; uint8 getClicks(uint8 mode, uint8 *retVal); uint8 handleButtonClick(uint8 id, uint8 mode, uint8 *retVal); diff --git a/sword1/mouse.h b/sword1/mouse.h index 443698473e..059dd41909 100644 --- a/sword1/mouse.h +++ b/sword1/mouse.h @@ -36,6 +36,8 @@ namespace Sword1 { #define BS1L_BUTTON_UP 4 #define BS1R_BUTTON_DOWN 8 #define BS1R_BUTTON_UP 16 +#define BS1_WHEEL_UP 32 +#define BS1_WHEEL_DOWN 64 #define MOUSE_BOTH_BUTTONS (BS1L_BUTTON_DOWN | BS1R_BUTTON_DOWN) #define MOUSE_DOWN_MASK (BS1L_BUTTON_DOWN | BS1R_BUTTON_DOWN) #define MOUSE_UP_MASK (BS1L_BUTTON_UP | BS1R_BUTTON_UP) |