aboutsummaryrefslogtreecommitdiff
path: root/gui/launcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/launcher.cpp')
-rw-r--r--gui/launcher.cpp104
1 files changed, 82 insertions, 22 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 4e35b54db8..5abf0aba26 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#include "base/version.h"
@@ -37,6 +38,11 @@
#include "gui/message.h"
#include "gui/gui-manager.h"
#include "gui/options.h"
+#ifdef ENABLE_EVENTRECORDER
+#include "gui/onscreendialog.h"
+#include "gui/recorderdialog.h"
+#include "gui/EventRecorder.h"
+#endif
#include "gui/saveload.h"
#include "gui/widgets/edittext.h"
#include "gui/widgets/list.h"
@@ -188,10 +194,10 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
// GUI: Label & edit widget for the game ID
if (g_system->getOverlayWidth() > 320)
- new StaticTextWidget(tab, "GameOptions_Game.Id", _("ID:"), _("Short game identifier used for referring to savegames and running the game from the command line"));
+ new StaticTextWidget(tab, "GameOptions_Game.Id", _("ID:"), _("Short game identifier used for referring to saved games and running the game from the command line"));
else
- new StaticTextWidget(tab, "GameOptions_Game.Id", _c("ID:", "lowres"), _("Short game identifier used for referring to savegames and running the game from the command line"));
- _domainWidget = new DomainEditTextWidget(tab, "GameOptions_Game.Domain", _domain, _("Short game identifier used for referring to savegames and running the game from the command line"));
+ new StaticTextWidget(tab, "GameOptions_Game.Id", _c("ID:", "lowres"), _("Short game identifier used for referring to saved games and running the game from the command line"));
+ _domainWidget = new DomainEditTextWidget(tab, "GameOptions_Game.Domain", _domain, _("Short game identifier used for referring to saved games and running the game from the command line"));
// GUI: Label & edit widget for the description
if (g_system->getOverlayWidth() > 320)
@@ -321,19 +327,19 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
// GUI: Button + Label for the additional path
if (g_system->getOverlayWidth() > 320)
- new ButtonWidget(tab, "GameOptions_Paths.Extrapath", _("Extra Path:"), _("Specifies path to additional data used the game"), kCmdExtraBrowser);
+ new ButtonWidget(tab, "GameOptions_Paths.Extrapath", _("Extra Path:"), _("Specifies path to additional data used by the game"), kCmdExtraBrowser);
else
- new ButtonWidget(tab, "GameOptions_Paths.Extrapath", _c("Extra Path:", "lowres"), _("Specifies path to additional data used the game"), kCmdExtraBrowser);
- _extraPathWidget = new StaticTextWidget(tab, "GameOptions_Paths.ExtrapathText", extraPath, _("Specifies path to additional data used the game"));
+ new ButtonWidget(tab, "GameOptions_Paths.Extrapath", _c("Extra Path:", "lowres"), _("Specifies path to additional data used by the game"), kCmdExtraBrowser);
+ _extraPathWidget = new StaticTextWidget(tab, "GameOptions_Paths.ExtrapathText", extraPath, _("Specifies path to additional data used by the game"));
_extraPathClearButton = addClearButton(tab, "GameOptions_Paths.ExtraPathClearButton", kCmdExtraPathClear);
// GUI: Button + Label for the save path
if (g_system->getOverlayWidth() > 320)
- new ButtonWidget(tab, "GameOptions_Paths.Savepath", _("Save Path:"), _("Specifies where your savegames are put"), kCmdSaveBrowser);
+ new ButtonWidget(tab, "GameOptions_Paths.Savepath", _("Save Path:"), _("Specifies where your saved games are put"), kCmdSaveBrowser);
else
- new ButtonWidget(tab, "GameOptions_Paths.Savepath", _c("Save Path:", "lowres"), _("Specifies where your savegames are put"), kCmdSaveBrowser);
- _savePathWidget = new StaticTextWidget(tab, "GameOptions_Paths.SavepathText", savePath, _("Specifies where your savegames are put"));
+ new ButtonWidget(tab, "GameOptions_Paths.Savepath", _c("Save Path:", "lowres"), _("Specifies where your saved games are put"), kCmdSaveBrowser);
+ _savePathWidget = new StaticTextWidget(tab, "GameOptions_Paths.SavepathText", savePath, _("Specifies where your saved games are put"));
_savePathClearButton = addClearButton(tab, "GameOptions_Paths.SavePathClearButton", kCmdSavePathClear);
@@ -596,7 +602,6 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
LauncherDialog::LauncherDialog()
: Dialog(0, 0, 320, 200) {
_backgroundType = GUI::ThemeEngine::kDialogBackgroundMain;
-
const int screenW = g_system->getOverlayWidth();
const int screenH = g_system->getOverlayHeight();
@@ -625,7 +630,7 @@ LauncherDialog::LauncherDialog()
new ButtonWidget(this, "Launcher.StartButton", _("~S~tart"), _("Start selected game"), kStartCmd);
_loadButton =
- new ButtonWidget(this, "Launcher.LoadGameButton", _("~L~oad..."), _("Load savegame for selected game"), kLoadGameCmd);
+ new ButtonWidget(this, "Launcher.LoadGameButton", _("~L~oad..."), _("Load saved game for selected game"), kLoadGameCmd);
// Above the lowest button rows: two more buttons (directly below the list box)
if (g_system->getOverlayWidth() > 320) {
@@ -779,10 +784,9 @@ void LauncherDialog::updateListing() {
}
void LauncherDialog::addGame() {
- int modifiers = g_system->getEventManager()->getModifierState();
#ifndef DISABLE_MASS_ADD
- const bool massAdd = (modifiers & Common::KBD_SHIFT) != 0;
+ const bool massAdd = checkModifier(Common::KBD_SHIFT);
if (massAdd) {
MessageDialog alert(_("Do you really want to run the mass game detector? "
@@ -975,6 +979,49 @@ void LauncherDialog::editGame(int item) {
}
}
+void LauncherDialog::loadGameButtonPressed(int item) {
+#ifdef ENABLE_EVENTRECORDER
+ const bool shiftPressed = checkModifier(Common::KBD_SHIFT);
+ if (shiftPressed) {
+ recordGame(item);
+ } else {
+ loadGame(item);
+ }
+ updateButtons();
+#else
+ loadGame(item);
+#endif
+}
+
+#ifdef ENABLE_EVENTRECORDER
+void LauncherDialog::recordGame(int item) {
+ RecorderDialog recorderDialog;
+ MessageDialog alert(_("Do you want to load saved game?"),
+ _("Yes"), _("No"));
+ switch(recorderDialog.runModal(_domains[item])) {
+ case RecorderDialog::kRecordDialogClose:
+ break;
+ case RecorderDialog::kRecordDialogPlayback:
+ ConfMan.setActiveDomain(_domains[item]);
+ close();
+ ConfMan.set("record_mode", "playback", ConfigManager::kTransientDomain);
+ ConfMan.set("record_file_name", recorderDialog.getFileName(), ConfigManager::kTransientDomain);
+ break;
+ case RecorderDialog::kRecordDialogRecord:
+ ConfMan.setActiveDomain(_domains[item]);
+ if (alert.runModal() == GUI::kMessageOK) {
+ loadGame(item);
+ }
+ close();
+ g_eventRec.setAuthor(recorderDialog._author);
+ g_eventRec.setName(recorderDialog._name);
+ g_eventRec.setNotes(recorderDialog._notes);
+ ConfMan.set("record_mode", "record", ConfigManager::kTransientDomain);
+ break;
+ }
+}
+#endif
+
void LauncherDialog::loadGame(int item) {
String gameId = ConfMan.get("gameid", _domains[item]);
if (gameId.empty())
@@ -1039,7 +1086,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
editGame(item);
break;
case kLoadGameCmd:
- loadGame(item);
+ loadGameButtonPressed(item);
break;
case kOptionsCmd: {
GlobalOptionsDialog options;
@@ -1109,20 +1156,28 @@ void LauncherDialog::updateButtons() {
_loadButton->setEnabled(en);
_loadButton->draw();
}
+ switchButtonsText(_addButton, "~A~dd Game...", _s("Mass Add..."));
+#ifdef ENABLE_EVENTRECORDER
+ switchButtonsText(_loadButton, "~L~oad...", _s("Record..."));
+#endif
+}
- // Update the label of the "Add" button depending on whether shift is pressed or not
- int modifiers = g_system->getEventManager()->getModifierState();
- const bool massAdd = (modifiers & Common::KBD_SHIFT) != 0;
+// Update the label of the button depending on whether shift is pressed or not
+void LauncherDialog::switchButtonsText(ButtonWidget *button, const char *normalText, const char *shiftedText) {
+ const bool shiftPressed = checkModifier(Common::KBD_SHIFT);
const bool lowRes = g_system->getOverlayWidth() <= 320;
- const char *newAddButtonLabel = massAdd
- ? (lowRes ? _c("Mass Add...", "lowres") : _("Mass Add..."))
- : (lowRes ? _c("~A~dd Game...", "lowres") : _("~A~dd Game..."));
+ const char *newAddButtonLabel = shiftPressed
+ ? (lowRes ? _c(shiftedText, "lowres") : _(shiftedText))
+ : (lowRes ? _c(normalText, "lowres") : _(normalText));
- if (_addButton->getLabel() != newAddButtonLabel)
- _addButton->setLabel(newAddButtonLabel);
+ if (button->getLabel() != newAddButtonLabel)
+ button->setLabel(newAddButtonLabel);
}
+
+
+
void LauncherDialog::reflowLayout() {
#ifndef DISABLE_FANCY_THEMES
if (g_gui.xmlEval()->getVar("Globals.ShowLauncherLogo") == 1 && g_gui.theme()->supportsImages()) {
@@ -1186,4 +1241,9 @@ void LauncherDialog::reflowLayout() {
Dialog::reflowLayout();
}
+bool LauncherDialog::checkModifier(int checkedModifier) {
+ int modifiers = g_system->getEventManager()->getModifierState();
+ return (modifiers & checkedModifier) != 0;
+}
+
} // End of namespace GUI