mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
fixed key repeat in NewGui; made the launcher game list non-editable
svn-id: r5052
This commit is contained in:
parent
4fc67f55c0
commit
8f7e3119bf
@ -125,7 +125,8 @@ bool ListWidget::handleKeyDown(char key, int modifiers)
|
||||
case '\n': // enter
|
||||
case '\r':
|
||||
if (_selectedItem >= 0) {
|
||||
if ((_currentKeyDown != '\n' && _currentKeyDown != '\r')) { // override continuous enter keydown
|
||||
// override continuous enter keydown
|
||||
if (_editable && (_currentKeyDown != '\n' && _currentKeyDown != '\r')) {
|
||||
_editMode = true;
|
||||
dirty = true;
|
||||
_backupString = _list[_selectedItem];
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
int getSelected() const { return _selectedItem; }
|
||||
const String& getSelectedString() const { return _list[_selectedItem]; }
|
||||
void setNumberingMode(int numberingMode) { _numberingMode = numberingMode; }
|
||||
bool isEditable() const { return _editable; }
|
||||
void setEditable(bool editable) { _editable = editable; }
|
||||
|
||||
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
||||
virtual void handleMouseUp(int x, int y, int button, int clickCount);
|
||||
|
@ -54,6 +54,7 @@ LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector)
|
||||
|
||||
// Add list with game titles
|
||||
_list = new ListWidget(this, 10, 10, 300, 112);
|
||||
_list->setEditable(false);
|
||||
_list->setNumberingMode(kListNumberingOff);
|
||||
|
||||
const VersionSettings *v = version_settings;
|
||||
|
@ -25,9 +25,7 @@
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
# pragma warning( disable : 4068 ) // unknown pragma
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -44,6 +42,14 @@
|
||||
* - ...
|
||||
*/
|
||||
|
||||
enum {
|
||||
kDoubleClickDelay = 500, // milliseconds
|
||||
kCursorAnimateDelay = 500,
|
||||
|
||||
kKeyRepeatInitialDelay = 400,
|
||||
kKeyRepeatSustainDelay = 100,
|
||||
};
|
||||
|
||||
// Built-in font
|
||||
static byte guifont[] = {
|
||||
0,0,99,1,226,8,4,8,6,8,6,0,0,0,0,0,0,0,0,0,0,0,8,2,1,8,0,0,0,0,0,0,0,0,0,0,0,0,4,3,7,8,7,7,8,4,5,5,8,7,4,7,3,8,7,7,7,7,8,7,7,7,7,7,3,4,7,5,7,7,8,7,7,7,7,7,7,7,7,5,7,7,
|
||||
@ -126,6 +132,8 @@ void NewGui::runLoop()
|
||||
|
||||
_system->update_screen();
|
||||
|
||||
uint32 time = _system->get_msecs();
|
||||
|
||||
while (_system->poll_event(&event)) {
|
||||
switch(event.event_code) {
|
||||
case OSystem::EVENT_KEYDOWN:
|
||||
@ -134,8 +142,7 @@ void NewGui::runLoop()
|
||||
// init continuous event stream
|
||||
_currentKeyDown = event.kbd.ascii;
|
||||
_currentKeyDownFlags = event.kbd.flags;
|
||||
_keyRepeatEvenCount = 1;
|
||||
_keyRepeatLoopCount = 0;
|
||||
_keyRepeatTime = time + kKeyRepeatInitialDelay;
|
||||
break;
|
||||
case OSystem::EVENT_KEYUP:
|
||||
activeDialog->handleKeyUp((byte)event.kbd.ascii, event.kbd.flags);
|
||||
@ -150,7 +157,6 @@ void NewGui::runLoop()
|
||||
// We don'event distinguish between mousebuttons (for now at least)
|
||||
case OSystem::EVENT_LBUTTONDOWN:
|
||||
case OSystem::EVENT_RBUTTONDOWN: {
|
||||
uint32 time = _system->get_msecs();
|
||||
if (_lastClick.count && (time < _lastClick.time + kDoubleClickDelay)
|
||||
&& ABS(_lastClick.x - event.mouse.x) < 3
|
||||
&& ABS(_lastClick.y - event.mouse.y) < 3) {
|
||||
@ -174,17 +180,12 @@ void NewGui::runLoop()
|
||||
// check if event should be sent again (keydown)
|
||||
if (_currentKeyDown != 0)
|
||||
{
|
||||
// if only fired once, wait longer
|
||||
if ( _keyRepeatLoopCount >= ((_keyRepeatEvenCount > 1) ? 2 : 4) )
|
||||
// ^ loops to wait first event
|
||||
// ^ loops to wait after first event
|
||||
if (_keyRepeatTime < time)
|
||||
{
|
||||
// fire event
|
||||
activeDialog->handleKeyDown(_currentKeyDown, _currentKeyDownFlags);
|
||||
_keyRepeatEvenCount++;
|
||||
_keyRepeatLoopCount = 0;
|
||||
_keyRepeatTime = time + kKeyRepeatSustainDelay;
|
||||
}
|
||||
_keyRepeatLoopCount++;
|
||||
}
|
||||
|
||||
// Delay for a moment
|
||||
|
@ -43,11 +43,6 @@ enum {
|
||||
kTextAlignRight,
|
||||
};
|
||||
|
||||
enum {
|
||||
kDoubleClickDelay = 500, // milliseconds
|
||||
kCursorAnimateDelay = 500
|
||||
};
|
||||
|
||||
// Extremly simple stack class, doesn't even do any error checking (for now)
|
||||
class DialogStack {
|
||||
protected:
|
||||
@ -88,8 +83,7 @@ protected:
|
||||
|
||||
// for continuous events (keyDown)
|
||||
int _currentKeyDown, _currentKeyDownFlags;
|
||||
int _keyRepeatLoopCount;
|
||||
int _keyRepeatEvenCount;
|
||||
uint32 _keyRepeatTime;
|
||||
|
||||
// position and time of last mouse click (used to detect double clicks)
|
||||
struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user