[Scummvm-cvs-logs] CVS: scummvm/sword1 control.cpp,1.32,1.33 control.h,1.13,1.14 mouse.h,1.12,1.13
Torbj?rn Andersson
eriktorbjorn at users.sourceforge.net
Tue May 11 23:22:01 CEST 2004
Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9170
Modified Files:
control.cpp control.h mouse.h
Log Message:
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.
Index: control.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/control.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- control.cpp 30 Mar 2004 22:56:57 -0000 1.32
+++ control.cpp 12 May 2004 06:21:44 -0000 1.33
@@ -257,6 +257,8 @@
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 @@
_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 @@
}
_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 @@
_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 @@
_oldName[0] = '\0';
}
}
+ if (_selectedSavegame < 255)
+ _cursorTick = 0;
showSavegameNames();
}
@@ -814,9 +843,10 @@
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 @@
_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;
Index: control.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/control.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- control.h 28 Mar 2004 12:59:51 -0000 1.13
+++ control.h 12 May 2004 06:21:44 -0000 1.14
@@ -88,6 +88,8 @@
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);
Index: mouse.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/mouse.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mouse.h 11 Jan 2004 15:47:41 -0000 1.12
+++ mouse.h 12 May 2004 06:21:44 -0000 1.13
@@ -36,6 +36,8 @@
#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)
More information about the Scummvm-git-logs
mailing list