GRIM: Add a dialogue to tell the user he has a DATAUSR.lab patch

This also gives the user a chance to avoid loading the patch,
by clicking Cancel in the dialogue that pops up. Only minor
changes were done to InputDialog for this.
This commit is contained in:
Einar Johan T. Sømåen 2011-11-19 17:30:43 +01:00
parent b708973ecf
commit 5d01e5696d
3 changed files with 27 additions and 9 deletions

View File

@ -31,8 +31,8 @@
namespace Grim {
InputDialog::InputDialog(const Common::String &message, const Common::String &string) :
GUI::Dialog(30, 20, 260, 124) {
InputDialog::InputDialog(const Common::String &message, const Common::String &string, bool hasTextField) :
GUI::Dialog(30, 20, 260, 124), _hasTextField(hasTextField) {
const int screenW = g_system->getOverlayWidth();
const int screenH = g_system->getOverlayHeight();
@ -74,16 +74,24 @@ InputDialog::InputDialog(const Common::String &message, const Common::String &st
height += kLineHeight;
}
height += 10;
m_text = new GUI::EditTextWidget(this, 10, height, _w - 20, kLineHeight, string, "input");
height += kLineHeight + 10;
if (_hasTextField) {
m_text = new GUI::EditTextWidget(this, 10, height, _w - 20, kLineHeight, string, "input");
height += kLineHeight + 10;
}
new GUI::ButtonWidget(this, 10, height, buttonWidth, buttonHeight, "Ok", 0, GUI::kOKCmd, Common::ASCII_RETURN); // Confirm dialog
new GUI::ButtonWidget(this, _w - buttonWidth - 10, height, buttonWidth, buttonHeight, "Cancel", 0, GUI::kCloseCmd, Common::ASCII_ESCAPE); // Cancel dialog
}
const Common::String &InputDialog::getString() const {
return m_text->getEditString();
if (_hasTextField) {
return m_text->getEditString();
} else {
// TextBox-less dialogs shouldn't need any getString, but
// this is needed for safety and to avoid warnings.
return _name;
}
}
void InputDialog::handleKeyDown(Common::KeyState state) {

View File

@ -34,7 +34,7 @@ namespace Grim {
class InputDialog : public GUI::Dialog {
public:
InputDialog(const Common::String &message, const Common::String &string);
InputDialog(const Common::String &message, const Common::String &string, bool hasTextField = true);
const Common::String &getString() const;
@ -43,8 +43,8 @@ protected:
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
private:
bool _hasTextField;
GUI::EditTextWidget *m_text;
};
}

View File

@ -32,6 +32,8 @@
#include "engines/grim/bitmap.h"
#include "engines/grim/font.h"
#include "engines/grim/model.h"
#include "engines/grim/inputdialog.h"
#include "engines/grim/debug.h"
namespace Grim {
@ -56,7 +58,15 @@ ResourceLoader::ResourceLoader() {
l = new Lab();
if (l->open(filename)) {
if (filename.equalsIgnoreCase("data005.lab") || filename.equalsIgnoreCase("datausr.lab"))
if (filename.equalsIgnoreCase("datausr.lab")) {
Grim::InputDialog d("User-patch detected, the Residual-team\n provides no support for using such patches.\n Click OK to load, or Cancel\n to skip the patch.", "OK", false);
int res = d.runModal();
if (res) {
warning("Loading %s",filename.c_str());
_labs.push_front(l);
}
}
else if (filename.equalsIgnoreCase("data005.lab"))
_labs.push_front(l);
else
_labs.push_back(l);