Don't track the modifier state, use the eventmanager instead (this also fixes bug #1657322, GUI: 'Mass Add' button text does not revert after mass add)
svn-id: r26174
This commit is contained in:
parent
b765e998f7
commit
cfe7ecd6d9
4 changed files with 25 additions and 22 deletions
|
@ -23,6 +23,7 @@
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
#include "base/plugins.h"
|
#include "base/plugins.h"
|
||||||
#include "base/version.h"
|
#include "base/version.h"
|
||||||
|
#include "common/events.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "gui/about.h"
|
#include "gui/about.h"
|
||||||
|
@ -64,7 +65,7 @@ static const char *gpl_text[] = {
|
||||||
|
|
||||||
AboutDialog::AboutDialog()
|
AboutDialog::AboutDialog()
|
||||||
: Dialog(10, 20, 300, 174),
|
: Dialog(10, 20, 300, 174),
|
||||||
_scrollPos(0), _scrollTime(0), _modifiers(0), _willClose(false) {
|
_scrollPos(0), _scrollTime(0), _willClose(false) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -184,7 +185,6 @@ void AboutDialog::addLine(const char *str) {
|
||||||
void AboutDialog::open() {
|
void AboutDialog::open() {
|
||||||
_scrollTime = getMillis() + kScrollStartDelay;
|
_scrollTime = getMillis() + kScrollStartDelay;
|
||||||
_scrollPos = 0;
|
_scrollPos = 0;
|
||||||
_modifiers = 0;
|
|
||||||
_willClose = false;
|
_willClose = false;
|
||||||
|
|
||||||
Dialog::open();
|
Dialog::open();
|
||||||
|
@ -267,11 +267,13 @@ void AboutDialog::handleTickle() {
|
||||||
const uint32 t = getMillis();
|
const uint32 t = getMillis();
|
||||||
int scrollOffset = ((int)t - (int)_scrollTime) / kScrollMillisPerPixel;
|
int scrollOffset = ((int)t - (int)_scrollTime) / kScrollMillisPerPixel;
|
||||||
if (scrollOffset > 0) {
|
if (scrollOffset > 0) {
|
||||||
|
int modifiers = g_system->getEventManager()->getModifierState();
|
||||||
|
|
||||||
// Scroll faster when shift is pressed
|
// Scroll faster when shift is pressed
|
||||||
if (_modifiers & OSystem::KBD_SHIFT)
|
if (modifiers & OSystem::KBD_SHIFT)
|
||||||
scrollOffset *= 4;
|
scrollOffset *= 4;
|
||||||
// Reverse scrolling when alt is pressed
|
// Reverse scrolling when alt is pressed
|
||||||
if (_modifiers & OSystem::KBD_ALT)
|
if (modifiers & OSystem::KBD_ALT)
|
||||||
scrollOffset *= -1;
|
scrollOffset *= -1;
|
||||||
_scrollPos += scrollOffset;
|
_scrollPos += scrollOffset;
|
||||||
_scrollTime = t;
|
_scrollTime = t;
|
||||||
|
@ -292,13 +294,11 @@ void AboutDialog::handleMouseUp(int x, int y, int button, int clickCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
void AboutDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
||||||
_modifiers = modifiers;
|
|
||||||
if (ascii)
|
if (ascii)
|
||||||
_willClose = true;
|
_willClose = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) {
|
void AboutDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) {
|
||||||
_modifiers = modifiers;
|
|
||||||
if (ascii && _willClose)
|
if (ascii && _willClose)
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ protected:
|
||||||
uint32 _scrollTime;
|
uint32 _scrollTime;
|
||||||
StringList _lines;
|
StringList _lines;
|
||||||
uint32 _lineHeight;
|
uint32 _lineHeight;
|
||||||
byte _modifiers;
|
|
||||||
bool _willClose;
|
bool _willClose;
|
||||||
|
|
||||||
int _xOff, _yOff;
|
int _xOff, _yOff;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "base/version.h"
|
#include "base/version.h"
|
||||||
|
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
|
#include "common/events.h"
|
||||||
#include "common/fs.h"
|
#include "common/fs.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
|
@ -479,7 +480,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
LauncherDialog::LauncherDialog()
|
LauncherDialog::LauncherDialog()
|
||||||
: Dialog(0, 0, 320, 200), _modifiers(0) {
|
: Dialog(0, 0, 320, 200) {
|
||||||
_drawingHints |= THEME_HINT_MAIN_DIALOG;
|
_drawingHints |= THEME_HINT_MAIN_DIALOG;
|
||||||
|
|
||||||
const int screenW = g_system->getOverlayWidth();
|
const int screenW = g_system->getOverlayWidth();
|
||||||
|
@ -561,6 +562,8 @@ void LauncherDialog::open() {
|
||||||
// re-launch the same game again.
|
// re-launch the same game again.
|
||||||
ConfMan.setActiveDomain("");
|
ConfMan.setActiveDomain("");
|
||||||
Dialog::open();
|
Dialog::open();
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherDialog::close() {
|
void LauncherDialog::close() {
|
||||||
|
@ -616,7 +619,8 @@ void LauncherDialog::updateListing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherDialog::addGame() {
|
void LauncherDialog::addGame() {
|
||||||
bool massAdd = (_modifiers & OSystem::KBD_SHIFT) != 0;
|
int modifiers = g_system->getEventManager()->getModifierState();
|
||||||
|
bool massAdd = (modifiers & OSystem::KBD_SHIFT) != 0;
|
||||||
|
|
||||||
if (massAdd) {
|
if (massAdd) {
|
||||||
MessageDialog alert("Do you really want to run the mass game detector? "
|
MessageDialog alert("Do you really want to run the mass game detector? "
|
||||||
|
@ -792,23 +796,13 @@ void LauncherDialog::editGame(int item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
void LauncherDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
||||||
_modifiers = modifiers;
|
|
||||||
Dialog::handleKeyDown(ascii, keycode, modifiers);
|
Dialog::handleKeyDown(ascii, keycode, modifiers);
|
||||||
|
updateButtons();
|
||||||
if ((modifiers & OSystem::KBD_SHIFT) != 0) {
|
|
||||||
_addButton->setLabel("Mass Add...");
|
|
||||||
_addButton->draw();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) {
|
void LauncherDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) {
|
||||||
_modifiers = modifiers;
|
|
||||||
Dialog::handleKeyUp(ascii, keycode, modifiers);
|
Dialog::handleKeyUp(ascii, keycode, modifiers);
|
||||||
|
updateButtons();
|
||||||
if ((modifiers & OSystem::KBD_SHIFT) == 0) {
|
|
||||||
_addButton->setLabel("Add Game...");
|
|
||||||
_addButton->draw();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||||
|
@ -869,6 +863,17 @@ void LauncherDialog::updateButtons() {
|
||||||
_removeButton->setEnabled(enable);
|
_removeButton->setEnabled(enable);
|
||||||
_removeButton->draw();
|
_removeButton->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the label of the "Add" button depending on whether shift is pressed or not
|
||||||
|
int modifiers = g_system->getEventManager()->getModifierState();
|
||||||
|
const char *newAddButtonLabel = ((modifiers & OSystem::KBD_SHIFT) != 0)
|
||||||
|
? "Mass Add..."
|
||||||
|
: "Add Game...";
|
||||||
|
|
||||||
|
if (_addButton->getLabel() != newAddButtonLabel) {
|
||||||
|
_addButton->setLabel(newAddButtonLabel);
|
||||||
|
_addButton->draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherDialog::reflowLayout() {
|
void LauncherDialog::reflowLayout() {
|
||||||
|
|
|
@ -58,7 +58,6 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
StringList _domains;
|
StringList _domains;
|
||||||
BrowserDialog *_browser;
|
BrowserDialog *_browser;
|
||||||
byte _modifiers;
|
|
||||||
|
|
||||||
virtual void reflowLayout();
|
virtual void reflowLayout();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue