mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
WAGE: Implemented saveDialog()
This commit is contained in:
parent
c7eed7f0ad
commit
936609fb11
@ -56,24 +56,23 @@
|
||||
namespace Wage {
|
||||
|
||||
enum {
|
||||
kDialogWidth = 199,
|
||||
kDialogHeight = 113
|
||||
};
|
||||
|
||||
Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gui), _text(text), _buttons(buttons) {
|
||||
Dialog::Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons, int defaultButton) :
|
||||
_gui(gui), _text(text), _buttons(buttons), _defaultButton(defaultButton) {
|
||||
assert(_gui->_engine);
|
||||
assert(_gui->_engine->_world);
|
||||
|
||||
_font = getDialogFont();
|
||||
|
||||
_tempSurface.create(kDialogWidth, kDialogHeight, Graphics::PixelFormat::createFormatCLUT8());
|
||||
_tempSurface.create(width, kDialogHeight, Graphics::PixelFormat::createFormatCLUT8());
|
||||
|
||||
_bbox.left = (_gui->_screen.w - kDialogWidth) / 2;
|
||||
_bbox.left = (_gui->_screen.w - width) / 2;
|
||||
_bbox.top = (_gui->_screen.h - kDialogHeight) / 2;
|
||||
_bbox.right = (_gui->_screen.w + kDialogWidth) / 2;
|
||||
_bbox.right = (_gui->_screen.w + width) / 2;
|
||||
_bbox.bottom = (_gui->_screen.h + kDialogHeight) / 2;
|
||||
|
||||
_defaultButton = -1;
|
||||
_pressedButton = -1;
|
||||
|
||||
_mouseOverPressedButton = false;
|
||||
@ -81,9 +80,6 @@ Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gu
|
||||
// Adjust button positions
|
||||
for (int i = 0; i < _buttons->size(); i++)
|
||||
_buttons->operator[](i)->bounds.translate(_bbox.left, _bbox.top);
|
||||
|
||||
if (_buttons->size() == 1)
|
||||
_defaultButton = 0;
|
||||
}
|
||||
|
||||
Dialog::~Dialog() {
|
||||
@ -151,8 +147,11 @@ void Dialog::run() {
|
||||
while (_gui->_engine->_eventMan->pollEvent(event)) {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_QUIT:
|
||||
_gui->_engine->_shouldQuit = true;
|
||||
shouldQuit = true;
|
||||
break;
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ typedef Common::Array<DialogButton *> DialogButtonArray;
|
||||
|
||||
class Dialog {
|
||||
public:
|
||||
Dialog(Gui *gui, const char *text, DialogButtonArray *buttons);
|
||||
Dialog(Gui *gui, int width, const char *text, DialogButtonArray *buttons, int defaultButton);
|
||||
~Dialog();
|
||||
|
||||
void run();
|
||||
|
@ -140,6 +140,7 @@ void WageEngine::processEvents() {
|
||||
while (_eventMan->pollEvent(event)) {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_QUIT:
|
||||
saveDialog();
|
||||
_shouldQuit = true;
|
||||
break;
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
@ -222,13 +223,27 @@ void WageEngine::gameOver() {
|
||||
|
||||
buttons.push_back(new DialogButton("OK", 66, 67, 68, 28));
|
||||
|
||||
Dialog gameOver(_gui, _world->_gameOverMessage->c_str(), &buttons);
|
||||
Dialog gameOver(_gui, 199, _world->_gameOverMessage->c_str(), &buttons, 0);
|
||||
|
||||
gameOver.run();
|
||||
|
||||
doClose();
|
||||
}
|
||||
|
||||
void WageEngine::saveDialog() {
|
||||
DialogButtonArray buttons;
|
||||
|
||||
buttons.push_back(new DialogButton("No", 19, 67, 68, 28));
|
||||
buttons.push_back(new DialogButton("Yes", 112, 67, 68, 28));
|
||||
buttons.push_back(new DialogButton("Cancel", 205, 67, 68, 28));
|
||||
|
||||
Dialog save(_gui, 291, "Save changes before closing?", &buttons, 1);
|
||||
|
||||
save.run();
|
||||
|
||||
doClose();
|
||||
}
|
||||
|
||||
void WageEngine::performInitialSetup() {
|
||||
debug(5, "Resetting Objs: %d", _world->_orderedObjs.size());
|
||||
for (uint i = 0; i < _world->_orderedObjs.size() - 1; i++)
|
||||
|
@ -162,6 +162,7 @@ public:
|
||||
void appendText(String &str);
|
||||
void appendText(char *str);
|
||||
void gameOver();
|
||||
void saveDialog();
|
||||
Obj *getOffer();
|
||||
Chr *getMonster();
|
||||
void processEvents();
|
||||
|
Loading…
x
Reference in New Issue
Block a user