[Scummvm-cvs-logs] CVS: scummvm/gui message.cpp,1.7,1.8 message.h,1.3,1.4
James Brown
ender at users.sourceforge.net
Thu Jan 2 02:37:21 CET 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v8.cpp,2.90,2.91 scummvm.cpp,2.29,2.30 vars.cpp,1.31,1.32
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.47,1.48 scumm.h,1.125,1.126 scummvm.cpp,2.30,2.31 sound.cpp,1.68,1.69
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv21456/gui
Modified Files:
message.cpp message.h
Log Message:
Plop in some better disk switching code for CMI - I have no idea how well this will work transitioning from a disk1 room to a disk2
room in-game, but it works for bootparams and saved games..
Index: message.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/message.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- message.cpp 21 Dec 2002 11:57:24 -0000 1.7
+++ message.cpp 2 Jan 2003 10:36:16 -0000 1.8
@@ -22,8 +22,13 @@
#include "message.h"
#include "newgui.h"
+enum {
+ kOkCmd = 'OK ',
+ kCancelCmd = 'CNCL'
+};
-MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, bool showButton)
+
+MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, bool showOkButton, bool showCancelButton)
: Dialog(gui, 30, 20, 260, 124)
{
// First, determine the size the dialog needs. For this we have to break
@@ -34,7 +39,7 @@
const char *str = message.c_str();
const char *start = str;
int lineWidth, maxlineWidth = 0;
- int lineCount;
+ int lineCount, okButtonPos, cancelButtonPos;
while (*str) {
if (*str == '\n') {
@@ -55,7 +60,7 @@
_w = maxlineWidth + 20;
lineCount = lines.size();
_h = lineCount * kLineHeight + 16;
- if (showButton)
+ if (showOkButton || showCancelButton)
_h += 24;
if (_h > 180) {
@@ -72,8 +77,18 @@
// FIXME - allow for multiple buttons, and return in runModal() which one
// was selected.
- if (showButton)
- addButton((_w - kButtonWidth)/2, _h - 24, "OK", kCloseCmd, '\n'); // Confirm dialog
+ if (showOkButton && showCancelButton) {
+ okButtonPos = (_w - (kButtonWidth * 2))/2;
+ cancelButtonPos = ((_w - (kButtonWidth * 2))/2) + kButtonWidth + 10;
+ } else {
+ okButtonPos = cancelButtonPos = (_w-kButtonWidth)/2;
+ }
+
+ if (showOkButton)
+ addButton(okButtonPos, _h - 24, "OK", kOkCmd, '\n'); // Confirm dialog
+
+ if (showCancelButton)
+ addButton(cancelButtonPos, _h - 24, "CANCEL", kCancelCmd, '\27'); // Cancel dialog
if (timer)
_timer = _gui->get_time() + timer;
@@ -132,5 +147,18 @@
lines.push_back(tmp);
}
return maxWidth;
+}
+
+void MessageDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
+{
+ if (cmd == kOkCmd) {
+ setResult(1);
+ close();
+ } else if (cmd == kCancelCmd) {
+ setResult(2);
+ close();
+ } else {
+ Dialog::handleCommand(sender, cmd, data);
+ }
}
Index: message.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/message.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- message.h 21 Dec 2002 11:57:24 -0000 1.3
+++ message.h 2 Jan 2003 10:36:17 -0000 1.4
@@ -29,9 +29,10 @@
typedef ScummVM::String String;
typedef ScummVM::StringList StringList;
public:
- MessageDialog(NewGui *gui, const String &message, uint32 timer = 0, bool showButton = true);
+ MessageDialog(NewGui *gui, const String &message, uint32 timer = 0, bool showOKButton = true, bool showCancelButton = false);
void handleTickle();
+ void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
protected:
uint32 _timer;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v8.cpp,2.90,2.91 scummvm.cpp,2.29,2.30 vars.cpp,1.31,1.32
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.47,1.48 scumm.h,1.125,1.126 scummvm.cpp,2.30,2.31 sound.cpp,1.68,1.69
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list