aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-11-01 20:52:41 +0000
committerMax Horn2003-11-01 20:52:41 +0000
commitf7ab7f62075107a8afbc071555b25612320664b9 (patch)
tree5151bc75f8e37ccf833f42f03699811df1c7c928
parente6eb3e234d4188a6753bfa3bf0cf637e6c716316 (diff)
downloadscummvm-rg350-f7ab7f62075107a8afbc071555b25612320664b9.tar.gz
scummvm-rg350-f7ab7f62075107a8afbc071555b25612320664b9.tar.bz2
scummvm-rg350-f7ab7f62075107a8afbc071555b25612320664b9.zip
cleanup: new MessageDialog subclass TimedMessageDialog
svn-id: r11033
-rw-r--r--backends/dc/vmsave.cpp5
-rw-r--r--gui/message.cpp29
-rw-r--r--gui/message.h27
-rw-r--r--scumm/scummvm.cpp4
4 files changed, 38 insertions, 27 deletions
diff --git a/backends/dc/vmsave.cpp b/backends/dc/vmsave.cpp
index 0a090cd244..9b57e583b8 100644
--- a/backends/dc/vmsave.cpp
+++ b/backends/dc/vmsave.cpp
@@ -69,9 +69,8 @@ static void displaySaveResult(vmsaveResult res)
break;
}
- Dialog *dialog = new MessageDialog(g_gui, buf);
- dialog->runModal();
- delete dialog;
+ MessageDialog dialog(g_gui, buf);
+ dialog.runModal();
}
static vmsaveResult trySave(const char *gamename, const char *data, int size,
diff --git a/gui/message.cpp b/gui/message.cpp
index 0a70f1e4ea..8c6f8c30ec 100644
--- a/gui/message.cpp
+++ b/gui/message.cpp
@@ -19,15 +19,17 @@
*/
#include "stdafx.h"
-#include "message.h"
-#include "newgui.h"
+#include "gui/message.h"
+#include "gui/newgui.h"
+#include "common/str.h"
+#include "common/list.h"
enum {
kOkCmd = 'OK ',
kCancelCmd = 'CNCL'
};
-MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, bool showOkButton, bool showCancelButton)
+MessageDialog::MessageDialog(NewGui *gui, const String &message, bool showOkButton, bool showCancelButton)
: Dialog(gui, 30, 20, 260, 124) {
// First, determine the size the dialog needs. For this we have to break
// down the string into lines, and taking the maximum of their widths.
@@ -87,17 +89,6 @@ MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, b
if (showCancelButton)
addButton(cancelButtonPos, _h - 24, "CANCEL", kCancelCmd, '\27'); // Cancel dialog
-
- if (timer)
- _timer = _gui->get_time() + timer;
- else
- _timer = 0;
-}
-
-void MessageDialog::handleTickle() {
- Dialog::handleTickle();
- if (_timer && _gui->get_time() > _timer)
- close();
}
int MessageDialog::addLine(StringList &lines, const char *line, int size) {
@@ -157,3 +148,13 @@ void MessageDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
}
}
+TimedMessageDialog::TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 timer)
+ : MessageDialog(gui, message, false, false) {
+ _timer = _gui->get_time() + timer;
+}
+
+void TimedMessageDialog::handleTickle() {
+ MessageDialog::handleTickle();
+ if (_gui->get_time() > _timer)
+ close();
+}
diff --git a/gui/message.h b/gui/message.h
index 69f630a538..8635d08245 100644
--- a/gui/message.h
+++ b/gui/message.h
@@ -21,23 +21,34 @@
#ifndef MESSAGE_DIALOG_H
#define MESSAGE_DIALOG_H
-#include "dialog.h"
-#include "common/str.h"
-#include "common/list.h"
+#include "gui/dialog.h"
+
+namespace Common {
+ class String;
+ class StringList;
+}
class MessageDialog : public Dialog {
typedef Common::String String;
typedef Common::StringList StringList;
public:
- MessageDialog(NewGui *gui, const String &message, uint32 timer = 0, bool showOKButton = true, bool showCancelButton = false);
-
- void handleTickle();
+ MessageDialog(NewGui *gui, const Common::String &message, bool showOKButton = true, bool showCancelButton = false);
+
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
protected:
- uint32 _timer;
+ int addLine(Common::StringList &lines, const char *line, int size);
+};
+
+class TimedMessageDialog : public MessageDialog {
+public:
+ TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 timer);
+
+ void handleTickle();
- int addLine(StringList &lines, const char *line, int size);
+protected:
+ uint32 _timer;
};
+
#endif
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index ea0674bd53..306016ccde 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -1366,7 +1366,7 @@ load_game:
#endif
sprintf(buf, "Successfully saved game state in file:\n\n%s", filename);
- MessageDialog dialog(_newgui, buf, 1500, false);
+ TimedMessageDialog dialog(_newgui, buf, 1500);
runDialog(dialog);
}
if (success && _saveLoadFlag != 1)
@@ -2496,7 +2496,7 @@ char ScummEngine::displayError(bool showCancel, const char *message, ...) {
vsprintf(buf, message, va);
va_end(va);
- MessageDialog dialog(_newgui, buf, 0, true, showCancel);
+ MessageDialog dialog(_newgui, buf, true, showCancel);
return runDialog(dialog);
}