turned NewGui into a singleton, and made OSystem a pseudo-singleton; added Widget::findWidget (preparing to add support for nested widgets, for the tab widget)
svn-id: r11045
This commit is contained in:
parent
f2c4bbbdbf
commit
b27a871f87
46 changed files with 182 additions and 233 deletions
|
@ -48,7 +48,6 @@ static int lastvm=-1;
|
||||||
|
|
||||||
static void displaySaveResult(vmsaveResult res)
|
static void displaySaveResult(vmsaveResult res)
|
||||||
{
|
{
|
||||||
extern NewGui *g_gui;
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
switch(res) {
|
switch(res) {
|
||||||
|
@ -69,7 +68,7 @@ static void displaySaveResult(vmsaveResult res)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDialog dialog(g_gui, buf);
|
MessageDialog dialog(buf);
|
||||||
dialog.runModal();
|
dialog.runModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,6 @@ GameDetector detector;
|
||||||
Engine *engine;
|
Engine *engine;
|
||||||
bool is_simon;
|
bool is_simon;
|
||||||
bool is_bass;
|
bool is_bass;
|
||||||
NewGui *g_gui;
|
|
||||||
extern Scumm *g_scumm;
|
extern Scumm *g_scumm;
|
||||||
//extern SimonEngine *g_simon;
|
//extern SimonEngine *g_simon;
|
||||||
//OSystem *g_system;
|
//OSystem *g_system;
|
||||||
|
@ -851,9 +850,6 @@ void runGame(char *game_name) {
|
||||||
|
|
||||||
mainClass = (OSystem_WINCE3*)system;
|
mainClass = (OSystem_WINCE3*)system;
|
||||||
|
|
||||||
//g_system = system;
|
|
||||||
g_gui = new NewGui(system);
|
|
||||||
|
|
||||||
/* Start the engine */
|
/* Start the engine */
|
||||||
|
|
||||||
is_simon = (strcmp(detector._plugin.getName(), "simon") == 0);
|
is_simon = (strcmp(detector._plugin.getName(), "simon") == 0);
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "backends/intern.h"
|
|
||||||
#include "base/engine.h"
|
#include "base/engine.h"
|
||||||
#include "base/gameDetector.h"
|
#include "base/gameDetector.h"
|
||||||
#include "base/plugins.h"
|
#include "base/plugins.h"
|
||||||
|
@ -587,31 +586,6 @@ bool GameDetector::detectMain() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSystem *GameDetector::createSystem() {
|
|
||||||
int gfx_mode = parseGraphicsMode(ConfMan.get("gfx_mode")); // FIXME: Get rid of this again!
|
|
||||||
|
|
||||||
#if defined(USE_NULL_DRIVER)
|
|
||||||
return OSystem_NULL_create();
|
|
||||||
#elif defined(__DC__)
|
|
||||||
return OSystem_Dreamcast_create();
|
|
||||||
#elif defined(X11_BACKEND)
|
|
||||||
return OSystem_X11_create();
|
|
||||||
#elif defined(__MORPHOS__)
|
|
||||||
return OSystem_MorphOS_create(gfx_mode, ConfMan.getBool("fullscreen"));
|
|
||||||
#elif defined(_WIN32_WCE)
|
|
||||||
return OSystem_WINCE3_create();
|
|
||||||
#elif defined(MACOS_CARBON)
|
|
||||||
return OSystem_MAC_create(gfx_mode, ConfMan.getBool("fullscreen"));
|
|
||||||
#elif defined(__GP32__) // ph0x
|
|
||||||
return OSystem_GP32_create(GFX_NORMAL, true);
|
|
||||||
#elif defined(__PALM_OS__) //chrilith
|
|
||||||
return OSystem_PALMOS_create(gfx_mode, ConfMan.getBool("fullscreen"));
|
|
||||||
#else
|
|
||||||
/* SDL is the default driver for now */
|
|
||||||
return OSystem_SDL_create(gfx_mode);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
Engine *GameDetector::createEngine(OSystem *sys) {
|
Engine *GameDetector::createEngine(OSystem *sys) {
|
||||||
assert(_plugin);
|
assert(_plugin);
|
||||||
return _plugin->createInstance(this, sys);
|
return _plugin->createInstance(this, sys);
|
||||||
|
|
|
@ -74,7 +74,6 @@ public:
|
||||||
|
|
||||||
Engine *createEngine(OSystem *system);
|
Engine *createEngine(OSystem *system);
|
||||||
|
|
||||||
static OSystem *createSystem();
|
|
||||||
static SoundMixer *createMixer();
|
static SoundMixer *createMixer();
|
||||||
static MidiDriver *createMidi(int midiDriver);
|
static MidiDriver *createMidi(int midiDriver);
|
||||||
|
|
||||||
|
|
|
@ -83,9 +83,6 @@ const char *gScummVMBuildDate = __DATE__ " " __TIME__;
|
||||||
const char *gScummVMFullVersion = "ScummVM 0.5.4cvs (" __DATE__ " " __TIME__ ")";
|
const char *gScummVMFullVersion = "ScummVM 0.5.4cvs (" __DATE__ " " __TIME__ ")";
|
||||||
|
|
||||||
|
|
||||||
NewGui *g_gui = 0;
|
|
||||||
OSystem *g_system = 0;
|
|
||||||
|
|
||||||
#if defined(WIN32) && defined(NO_CONSOLE)
|
#if defined(WIN32) && defined(NO_CONSOLE)
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#define STDOUT_FILE TEXT("stdout.txt")
|
#define STDOUT_FILE TEXT("stdout.txt")
|
||||||
|
@ -186,7 +183,7 @@ static void launcherDialog(GameDetector &detector, OSystem *system) {
|
||||||
|
|
||||||
system->set_palette(dummy_palette, 0, 16);
|
system->set_palette(dummy_palette, 0, 16);
|
||||||
|
|
||||||
LauncherDialog dlg(g_gui, detector);
|
LauncherDialog dlg(detector);
|
||||||
dlg.runModal();
|
dlg.runModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,8 +241,7 @@ int main(int argc, char *argv[]) {
|
||||||
detector.parseCommandLine(argc, argv);
|
detector.parseCommandLine(argc, argv);
|
||||||
|
|
||||||
// Create the system object
|
// Create the system object
|
||||||
OSystem *system = detector.createSystem();
|
OSystem *system = OSystem::instance();
|
||||||
g_system = system;
|
|
||||||
|
|
||||||
// Create the timer services
|
// Create the timer services
|
||||||
g_timer = new Timer(system);
|
g_timer = new Timer(system);
|
||||||
|
@ -254,9 +250,6 @@ int main(int argc, char *argv[]) {
|
||||||
prop.caption = gScummVMFullVersion;
|
prop.caption = gScummVMFullVersion;
|
||||||
system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
|
system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
|
||||||
|
|
||||||
// Create the GUI manager
|
|
||||||
g_gui = new NewGui(system);
|
|
||||||
|
|
||||||
// Unless a game was specified, show the launcher dialog
|
// Unless a game was specified, show the launcher dialog
|
||||||
if (detector._targetName.isEmpty())
|
if (detector._targetName.isEmpty())
|
||||||
launcherDialog(detector, system);
|
launcherDialog(detector, system);
|
||||||
|
@ -307,8 +300,6 @@ int main(int argc, char *argv[]) {
|
||||||
delete engine;
|
delete engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete g_gui;
|
|
||||||
|
|
||||||
// ...and quit (the return 0 should never be reached)
|
// ...and quit (the return 0 should never be reached)
|
||||||
system->quit();
|
system->quit();
|
||||||
delete system;
|
delete system;
|
||||||
|
|
|
@ -33,7 +33,7 @@ extern void force_keyboard(bool);
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
Debugger<T>::Debugger(NewGui *gui) {
|
Debugger<T>::Debugger() {
|
||||||
_frame_countdown = 0;
|
_frame_countdown = 0;
|
||||||
_dvar_count = 0;
|
_dvar_count = 0;
|
||||||
_dcmd_count = 0;
|
_dcmd_count = 0;
|
||||||
|
@ -41,7 +41,7 @@ Debugger<T>::Debugger(NewGui *gui) {
|
||||||
_isAttached = false;
|
_isAttached = false;
|
||||||
_errStr = NULL;
|
_errStr = NULL;
|
||||||
_firstTime = true;
|
_firstTime = true;
|
||||||
_debuggerDialog = new ConsoleDialog(gui, 1.0, 0.67F);
|
_debuggerDialog = new ConsoleDialog(1.0, 0.67F);
|
||||||
_debuggerDialog->setInputCallback(debuggerInputCallback, this);
|
_debuggerDialog->setInputCallback(debuggerInputCallback, this);
|
||||||
_debuggerDialog->setCompletionCallback(debuggerCompletionCallback, this);
|
_debuggerDialog->setCompletionCallback(debuggerCompletionCallback, this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#define COMMON_DEBUGGER_H
|
#define COMMON_DEBUGGER_H
|
||||||
|
|
||||||
class ConsoleDialog;
|
class ConsoleDialog;
|
||||||
class NewGui;
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ namespace Common {
|
||||||
template <class T>
|
template <class T>
|
||||||
class Debugger {
|
class Debugger {
|
||||||
public:
|
public:
|
||||||
Debugger(NewGui *gui);
|
Debugger();
|
||||||
virtual ~Debugger();
|
virtual ~Debugger();
|
||||||
|
|
||||||
int DebugPrintf(const char *format, ...);
|
int DebugPrintf(const char *format, ...);
|
||||||
|
|
|
@ -8,6 +8,7 @@ MODULE_OBJS := \
|
||||||
common/timer.o \
|
common/timer.o \
|
||||||
common/util.o \
|
common/util.o \
|
||||||
common/savefile.o \
|
common/savefile.o \
|
||||||
|
common/system.o \
|
||||||
common/scaler/2xsai.o \
|
common/scaler/2xsai.o \
|
||||||
common/scaler/aspect.o \
|
common/scaler/aspect.o \
|
||||||
common/scaler/hq2x.o \
|
common/scaler/hq2x.o \
|
||||||
|
|
|
@ -48,8 +48,8 @@ protected:
|
||||||
~Singleton<T>() { }
|
~Singleton<T>() { }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Singleton(const Singleton&);
|
Singleton<T>(const Singleton<T>&);
|
||||||
Singleton& operator= (const Singleton&);
|
Singleton<T>& operator= (const Singleton<T>&);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Common
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
* control audio CD playback, and sound output.
|
* control audio CD playback, and sound output.
|
||||||
*/
|
*/
|
||||||
class OSystem {
|
class OSystem {
|
||||||
|
public:
|
||||||
|
static OSystem *instance();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef struct Mutex *MutexRef;
|
typedef struct Mutex *MutexRef;
|
||||||
typedef void (*SoundProc)(void *param, byte *buf, int len);
|
typedef void (*SoundProc)(void *param, byte *buf, int len);
|
||||||
|
|
|
@ -33,14 +33,13 @@ EditTextWidget::EditTextWidget(Dialog *boss, int x, int y, int w, int h, const S
|
||||||
|
|
||||||
_pos = _label.size();
|
_pos = _label.size();
|
||||||
|
|
||||||
NewGui *gui = _boss->getGui();
|
_labelOffset = (g_gui.getStringWidth(_label) - (_w - 6));
|
||||||
_labelOffset = (gui->getStringWidth(_label) - (_w - 6));
|
|
||||||
if (_labelOffset < 0)
|
if (_labelOffset < 0)
|
||||||
_labelOffset = 0;
|
_labelOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditTextWidget::handleTickle() {
|
void EditTextWidget::handleTickle() {
|
||||||
uint32 time = _boss->getGui()->get_time();
|
uint32 time = g_system->get_msecs();
|
||||||
if (_caretTime < time) {
|
if (_caretTime < time) {
|
||||||
_caretTime = time + kCaretBlinkTime;
|
_caretTime = time + kCaretBlinkTime;
|
||||||
if (_caretVisible) {
|
if (_caretVisible) {
|
||||||
|
@ -56,7 +55,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount){
|
||||||
if (_caretVisible)
|
if (_caretVisible)
|
||||||
drawCaret(true);
|
drawCaret(true);
|
||||||
|
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
|
|
||||||
x += _labelOffset;
|
x += _labelOffset;
|
||||||
|
|
||||||
|
@ -90,7 +89,7 @@ bool EditTextWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
||||||
case 27: // escape
|
case 27: // escape
|
||||||
_label = _backupString;
|
_label = _backupString;
|
||||||
_pos = _label.size() - 1;
|
_pos = _label.size() - 1;
|
||||||
_labelOffset = (_boss->getGui()->getStringWidth(_label) - (_w-6));
|
_labelOffset = (g_gui.getStringWidth(_label) - (_w-6));
|
||||||
if (_labelOffset < 0)
|
if (_labelOffset < 0)
|
||||||
_labelOffset = 0;
|
_labelOffset = 0;
|
||||||
_boss->releaseFocus();
|
_boss->releaseFocus();
|
||||||
|
@ -144,24 +143,21 @@ bool EditTextWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditTextWidget::drawWidget(bool hilite) {
|
void EditTextWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = _boss->getGui();
|
|
||||||
|
|
||||||
// Draw a thin frame around us.
|
// Draw a thin frame around us.
|
||||||
gui->hLine(_x, _y, _x + _w - 1, gui->_color);
|
g_gui.hLine(_x, _y, _x + _w - 1, g_gui._color);
|
||||||
gui->hLine(_x, _y + _h - 1, _x +_w - 1, gui->_shadowcolor);
|
g_gui.hLine(_x, _y + _h - 1, _x +_w - 1, g_gui._shadowcolor);
|
||||||
gui->vLine(_x, _y, _y + _h - 1, gui->_color);
|
g_gui.vLine(_x, _y, _y + _h - 1, g_gui._color);
|
||||||
gui->vLine(_x + _w - 1, _y, _y + _h - 1, gui->_shadowcolor);
|
g_gui.vLine(_x + _w - 1, _y, _y + _h - 1, g_gui._shadowcolor);
|
||||||
|
|
||||||
// Draw the text
|
// Draw the text
|
||||||
adjustOffset();
|
adjustOffset();
|
||||||
gui->drawString(_label, _x + 2, _y + 3, _w - 6, gui->_textcolor, kTextAlignLeft, -_labelOffset);
|
g_gui.drawString(_label, _x + 2, _y + 3, _w - 6, g_gui._textcolor, kTextAlignLeft, -_labelOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EditTextWidget::getCaretPos() {
|
int EditTextWidget::getCaretPos() {
|
||||||
NewGui *gui = _boss->getGui();
|
|
||||||
int caretpos = 0;
|
int caretpos = 0;
|
||||||
for (int i = 0; i < _pos; i++)
|
for (int i = 0; i < _pos; i++)
|
||||||
caretpos += gui->getCharWidth(_label[i]);
|
caretpos += g_gui.getCharWidth(_label[i]);
|
||||||
|
|
||||||
caretpos -= _labelOffset;
|
caretpos -= _labelOffset;
|
||||||
|
|
||||||
|
@ -173,17 +169,15 @@ void EditTextWidget::drawCaret(bool erase) {
|
||||||
if (!isVisible() || !_boss->isVisible())
|
if (!isVisible() || !_boss->isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NewGui *gui = _boss->getGui();
|
int16 color = erase ? g_gui._bgcolor : g_gui._textcolorhi;
|
||||||
|
|
||||||
int16 color = erase ? gui->_bgcolor : gui->_textcolorhi;
|
|
||||||
int x = _x + _boss->getX() + 2;
|
int x = _x + _boss->getX() + 2;
|
||||||
int y = _y + _boss->getY() + 1;
|
int y = _y + _boss->getY() + 1;
|
||||||
|
|
||||||
int width = getCaretPos();
|
int width = getCaretPos();
|
||||||
x += width;
|
x += width;
|
||||||
|
|
||||||
gui->vLine(x, y, y + kLineHeight, color);
|
g_gui.vLine(x, y, y + kLineHeight, color);
|
||||||
gui->addDirtyRect(x, y, 2, kLineHeight);
|
g_gui.addDirtyRect(x, y, 2, kLineHeight);
|
||||||
|
|
||||||
_caretVisible = !erase;
|
_caretVisible = !erase;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +203,7 @@ bool EditTextWidget::adjustOffset() {
|
||||||
}
|
}
|
||||||
else if (_labelOffset > 0)
|
else if (_labelOffset > 0)
|
||||||
{
|
{
|
||||||
int width = _boss->getGui()->getStringWidth(_label);
|
int width = g_gui.getStringWidth(_label);
|
||||||
if (width - _labelOffset < (_w - 6)) {
|
if (width - _labelOffset < (_w - 6)) {
|
||||||
// scroll right
|
// scroll right
|
||||||
_labelOffset = (width - (_w - 6));
|
_labelOffset = (width - (_w - 6));
|
||||||
|
|
|
@ -31,10 +31,10 @@ class EditTextWidget : public StaticTextWidget {
|
||||||
typedef Common::String String;
|
typedef Common::String String;
|
||||||
protected:
|
protected:
|
||||||
String _backupString;
|
String _backupString;
|
||||||
bool _caretVisible;
|
bool _caretVisible;
|
||||||
uint32 _caretTime;
|
uint32 _caretTime;
|
||||||
int _pos;
|
int _pos;
|
||||||
int _labelOffset;
|
int _labelOffset;
|
||||||
public:
|
public:
|
||||||
EditTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text);
|
EditTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text);
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ void ListWidget::scrollBarRecalc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::handleTickle() {
|
void ListWidget::handleTickle() {
|
||||||
uint32 time = _boss->getGui()->get_time();
|
uint32 time = g_system->get_msecs();
|
||||||
if (_editMode && _caretTime < time) {
|
if (_editMode && _caretTime < time) {
|
||||||
_caretTime = time + kCaretBlinkTime;
|
_caretTime = time + kCaretBlinkTime;
|
||||||
if (_caretVisible) {
|
if (_caretVisible) {
|
||||||
|
@ -253,7 +253,7 @@ void ListWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::drawWidget(bool hilite) {
|
void ListWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
int i, pos, len = _list.size();
|
int i, pos, len = _list.size();
|
||||||
Common::String buffer;
|
Common::String buffer;
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ void ListWidget::drawCaret(bool erase) {
|
||||||
if (!isVisible() || !_boss->isVisible())
|
if (!isVisible() || !_boss->isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
|
|
||||||
// The item is selected, thus _bgcolor is used to draw the caret and _textcolorhi to erase it
|
// The item is selected, thus _bgcolor is used to draw the caret and _textcolorhi to erase it
|
||||||
int16 color = erase ? gui->_textcolorhi : gui->_bgcolor;
|
int16 color = erase ? gui->_textcolorhi : gui->_bgcolor;
|
||||||
|
|
|
@ -75,7 +75,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY)
|
PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY)
|
||||||
: Dialog(boss->_boss->getGui(), 0, 0, 16, 16),
|
: Dialog(0, 0, 16, 16),
|
||||||
_popUpBoss(boss) {
|
_popUpBoss(boss) {
|
||||||
// Copy the selection index
|
// Copy the selection index
|
||||||
_selection = _popUpBoss->_selectedItem;
|
_selection = _popUpBoss->_selectedItem;
|
||||||
|
@ -104,15 +104,15 @@ PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY)
|
||||||
_clickY = clickY - _y;
|
_clickY = clickY - _y;
|
||||||
|
|
||||||
// Time the popup was opened
|
// Time the popup was opened
|
||||||
_openTime = _gui->get_time();
|
_openTime = g_system->get_msecs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpDialog::drawDialog() {
|
void PopUpDialog::drawDialog() {
|
||||||
// Draw the menu border
|
// Draw the menu border
|
||||||
_gui->hLine(_x, _y, _x+_w - 1, _gui->_color);
|
g_gui.hLine(_x, _y, _x+_w - 1, g_gui._color);
|
||||||
_gui->hLine(_x, _y + _h - 1, _x + _w - 1, _gui->_shadowcolor);
|
g_gui.hLine(_x, _y + _h - 1, _x + _w - 1, g_gui._shadowcolor);
|
||||||
_gui->vLine(_x, _y, _y+_h - 1, _gui->_color);
|
g_gui.vLine(_x, _y, _y+_h - 1, g_gui._color);
|
||||||
_gui->vLine(_x + _w - 1, _y, _y + _h - 1, _gui->_shadowcolor);
|
g_gui.vLine(_x + _w - 1, _y, _y + _h - 1, g_gui._shadowcolor);
|
||||||
|
|
||||||
// Draw the entries
|
// Draw the entries
|
||||||
int count = _popUpBoss->_entries.size();
|
int count = _popUpBoss->_entries.size();
|
||||||
|
@ -120,14 +120,14 @@ void PopUpDialog::drawDialog() {
|
||||||
drawMenuEntry(i, i == _selection);
|
drawMenuEntry(i, i == _selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
_gui->addDirtyRect(_x, _y, _w, _h);
|
g_gui.addDirtyRect(_x, _y, _w, _h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpDialog::handleMouseUp(int x, int y, int button, int clickCount) {
|
void PopUpDialog::handleMouseUp(int x, int y, int button, int clickCount) {
|
||||||
// Mouse was released. If it wasn't moved much since the original mouse down,
|
// Mouse was released. If it wasn't moved much since the original mouse down,
|
||||||
// let the popup stay open. If it did move, assume the user made his selection.
|
// let the popup stay open. If it did move, assume the user made his selection.
|
||||||
int dist = (_clickX - x) * (_clickX - x) + (_clickY - y) * (_clickY - y);
|
int dist = (_clickX - x) * (_clickX - x) + (_clickY - y) * (_clickY - y);
|
||||||
if (dist > 3 * 3 || _gui->get_time() - _openTime > 300) {
|
if (dist > 3 * 3 || g_system->get_msecs() - _openTime > 300) {
|
||||||
setResult(_selection);
|
setResult(_selection);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -253,15 +253,15 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
|
||||||
int w = _w - 2;
|
int w = _w - 2;
|
||||||
Common::String &name = _popUpBoss->_entries[entry].name;
|
Common::String &name = _popUpBoss->_entries[entry].name;
|
||||||
|
|
||||||
_gui->fillRect(x, y, w, kLineHeight, hilite ? _gui->_textcolorhi : _gui->_bgcolor);
|
g_gui.fillRect(x, y, w, kLineHeight, hilite ? g_gui._textcolorhi : g_gui._bgcolor);
|
||||||
if (name.size() == 0) {
|
if (name.size() == 0) {
|
||||||
// Draw a seperator
|
// Draw a seperator
|
||||||
_gui->hLine(x, y + kLineHeight / 2, x + w - 1, _gui->_color);
|
g_gui.hLine(x, y + kLineHeight / 2, x + w - 1, g_gui._color);
|
||||||
_gui->hLine(x + 1, y + 1 + kLineHeight / 2, x + w - 1, _gui->_shadowcolor);
|
g_gui.hLine(x + 1, y + 1 + kLineHeight / 2, x + w - 1, g_gui._shadowcolor);
|
||||||
} else {
|
} else {
|
||||||
_gui->drawString(name, x + 1, y + 2, w - 2, hilite ? _gui->_bgcolor : _gui->_textcolor);
|
g_gui.drawString(name, x + 1, y + 2, w - 2, hilite ? g_gui._bgcolor : g_gui._textcolor);
|
||||||
}
|
}
|
||||||
_gui->addDirtyRect(x, y, w, kLineHeight);
|
g_gui.addDirtyRect(x, y, w, kLineHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ void PopUpWidget::setSelected(int item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpWidget::drawWidget(bool hilite) {
|
void PopUpWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
|
|
||||||
// Draw a thin frame around us.
|
// Draw a thin frame around us.
|
||||||
// TODO - should look different than the EditTextWidget fram
|
// TODO - should look different than the EditTextWidget fram
|
||||||
|
|
|
@ -212,7 +212,7 @@ void ScrollBarWidget::recalc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollBarWidget::drawWidget(bool hilite) {
|
void ScrollBarWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
int bottomY = _y + _h;
|
int bottomY = _y + _h;
|
||||||
bool isSinglePage = (_numEntries <= _entriesPerPage);
|
bool isSinglePage = (_numEntries <= _entriesPerPage);
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#include "base/engine.h"
|
#include "base/engine.h"
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
|
|
||||||
AboutDialog::AboutDialog(NewGui *gui)
|
AboutDialog::AboutDialog()
|
||||||
: Dialog(gui, 10, 20, 300, 124) {
|
: Dialog(10, 20, 300, 124) {
|
||||||
addButton((_w - kButtonWidth)/2, 100, "OK", kCloseCmd, '\r'); // Close dialog - FIXME
|
addButton((_w - kButtonWidth)/2, 100, "OK", kCloseCmd, '\r'); // Close dialog - FIXME
|
||||||
|
|
||||||
Common::String version("ScummVM ");
|
Common::String version("ScummVM ");
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
class AboutDialog : public Dialog {
|
class AboutDialog : public Dialog {
|
||||||
public:
|
public:
|
||||||
AboutDialog(NewGui *gui);
|
AboutDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "browser.h"
|
#include "gui/browser.h"
|
||||||
#include "newgui.h"
|
#include "gui/newgui.h"
|
||||||
#include "ListWidget.h"
|
#include "gui/ListWidget.h"
|
||||||
|
|
||||||
#include "backends/fs/fs.h"
|
#include "backends/fs/fs.h"
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ enum {
|
||||||
kGoUpCmd = 'GoUp'
|
kGoUpCmd = 'GoUp'
|
||||||
};
|
};
|
||||||
|
|
||||||
BrowserDialog::BrowserDialog(NewGui *gui, const char *title)
|
BrowserDialog::BrowserDialog(const char *title)
|
||||||
: Dialog(gui, 20, 10, 320 -2 * 20, 200 - 2 * 10),
|
: Dialog(20, 10, 320 -2 * 20, 200 - 2 * 10),
|
||||||
_node(0), _nodeContent(0) {
|
_node(0), _nodeContent(0) {
|
||||||
|
|
||||||
_fileList = NULL;
|
_fileList = NULL;
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BrowserDialog : public Dialog {
|
||||||
typedef Common::String String;
|
typedef Common::String String;
|
||||||
typedef Common::StringList StringList;
|
typedef Common::StringList StringList;
|
||||||
public:
|
public:
|
||||||
BrowserDialog(NewGui *gui, const char *title);
|
BrowserDialog(const char *title);
|
||||||
virtual ~BrowserDialog();
|
virtual ~BrowserDialog();
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
|
|
@ -27,8 +27,8 @@ enum {
|
||||||
kChooseCmd = 'Chos'
|
kChooseCmd = 'Chos'
|
||||||
};
|
};
|
||||||
|
|
||||||
ChooserDialog::ChooserDialog(NewGui *gui, const String title, const StringList& list)
|
ChooserDialog::ChooserDialog(const String title, const StringList& list)
|
||||||
: Dialog(gui, 8, 24, 320 -2 * 8, 141) {
|
: Dialog(8, 24, 320 -2 * 8, 141) {
|
||||||
// Headline
|
// Headline
|
||||||
new StaticTextWidget(this, 10, 8, _w - 2 * 10, kLineHeight, title, kTextAlignCenter);
|
new StaticTextWidget(this, 10, 8, _w - 2 * 10, kLineHeight, title, kTextAlignCenter);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ChooserDialog : public Dialog {
|
||||||
typedef Common::String String;
|
typedef Common::String String;
|
||||||
typedef Common::StringList StringList;
|
typedef Common::StringList StringList;
|
||||||
public:
|
public:
|
||||||
ChooserDialog(NewGui *gui, const String title, const StringList &list);
|
ChooserDialog(const String title, const StringList &list);
|
||||||
|
|
||||||
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
* to erase a single character, do scrolling etc.
|
* to erase a single character, do scrolling etc.
|
||||||
* - a *lot* of others things, this code is in no way complete and heavily under progress
|
* - a *lot* of others things, this code is in no way complete and heavily under progress
|
||||||
*/
|
*/
|
||||||
ConsoleDialog::ConsoleDialog(NewGui *gui, float widthPercent, float heightPercent)
|
ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent)
|
||||||
: Dialog(gui, 0, 0, 1, 1),
|
: Dialog(0, 0, 1, 1),
|
||||||
_widthPercent(widthPercent), _heightPercent(heightPercent) {
|
_widthPercent(widthPercent), _heightPercent(heightPercent) {
|
||||||
|
|
||||||
// Setup basic layout/dialog size
|
// Setup basic layout/dialog size
|
||||||
|
@ -95,10 +95,10 @@ void ConsoleDialog::open() {
|
||||||
|
|
||||||
void ConsoleDialog::drawDialog() {
|
void ConsoleDialog::drawDialog() {
|
||||||
// Blend over the background
|
// Blend over the background
|
||||||
_gui->blendRect(_x, _y, _w, _h, _gui->_bgcolor, 2);
|
g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor, 2);
|
||||||
|
|
||||||
// Draw a border
|
// Draw a border
|
||||||
_gui->hLine(_x, _y + _h - 1, _x + _w - 1, _gui->_color);
|
g_gui.hLine(_x, _y + _h - 1, _x + _w - 1, g_gui._color);
|
||||||
|
|
||||||
// Draw text
|
// Draw text
|
||||||
int start = _scrollLine - _linesPerPage + 1;
|
int start = _scrollLine - _linesPerPage + 1;
|
||||||
|
@ -108,7 +108,7 @@ void ConsoleDialog::drawDialog() {
|
||||||
for (int column = 0; column < _lineWidth; column++) {
|
for (int column = 0; column < _lineWidth; column++) {
|
||||||
int l = (start + line) % _linesInBuffer;
|
int l = (start + line) % _linesInBuffer;
|
||||||
byte c = _buffer[l * _lineWidth + column];
|
byte c = _buffer[l * _lineWidth + column];
|
||||||
_gui->drawChar(c, x, y, _gui->_textcolor);
|
g_gui.drawChar(c, x, y, g_gui._textcolor);
|
||||||
x += kCharWidth;
|
x += kCharWidth;
|
||||||
}
|
}
|
||||||
y += kLineHeight;
|
y += kLineHeight;
|
||||||
|
@ -118,11 +118,11 @@ void ConsoleDialog::drawDialog() {
|
||||||
_scrollBar->draw();
|
_scrollBar->draw();
|
||||||
|
|
||||||
// Finally blit it all to the screen
|
// Finally blit it all to the screen
|
||||||
_gui->addDirtyRect(_x, _y, _w, _h);
|
g_gui.addDirtyRect(_x, _y, _w, _h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleDialog::handleTickle() {
|
void ConsoleDialog::handleTickle() {
|
||||||
uint32 time = _gui->get_time();
|
uint32 time = g_system->get_msecs();
|
||||||
if (_caretTime < time) {
|
if (_caretTime < time) {
|
||||||
_caretTime = time + kCaretBlinkTime;
|
_caretTime = time + kCaretBlinkTime;
|
||||||
if (_caretVisible) {
|
if (_caretVisible) {
|
||||||
|
@ -506,13 +506,13 @@ void ConsoleDialog::drawCaret(bool erase) {
|
||||||
|
|
||||||
char c = _buffer[getBufferPos()];
|
char c = _buffer[getBufferPos()];
|
||||||
if (erase) {
|
if (erase) {
|
||||||
_gui->fillRect(x, y, kCharWidth, kLineHeight, _gui->_bgcolor);
|
g_gui.fillRect(x, y, kCharWidth, kLineHeight, g_gui._bgcolor);
|
||||||
_gui->drawChar(c, x, y + 2, _gui->_textcolor);
|
g_gui.drawChar(c, x, y + 2, g_gui._textcolor);
|
||||||
} else {
|
} else {
|
||||||
_gui->fillRect(x, y, kCharWidth, kLineHeight, _gui->_textcolor);
|
g_gui.fillRect(x, y, kCharWidth, kLineHeight, g_gui._textcolor);
|
||||||
_gui->drawChar(c, x, y + 2, _gui->_bgcolor);
|
g_gui.drawChar(c, x, y + 2, g_gui._bgcolor);
|
||||||
}
|
}
|
||||||
_gui->addDirtyRect(x, y, kCharWidth, kLineHeight);
|
g_gui.addDirtyRect(x, y, kCharWidth, kLineHeight);
|
||||||
|
|
||||||
_caretVisible = !erase;
|
_caretVisible = !erase;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
#ifndef CONSOLE_DIALOG_H
|
#ifndef CONSOLE_DIALOG_H
|
||||||
#define CONSOLE_DIALOG_H
|
#define CONSOLE_DIALOG_H
|
||||||
|
|
||||||
#include "dialog.h"
|
#include "gui/dialog.h"
|
||||||
#include "newgui.h"
|
#include "gui/newgui.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ protected:
|
||||||
void reflowLayout();
|
void reflowLayout();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConsoleDialog(NewGui *gui, float widthPercent, float heightPercent);
|
ConsoleDialog(float widthPercent, float heightPercent);
|
||||||
|
|
||||||
void open();
|
void open();
|
||||||
void drawDialog();
|
void drawDialog();
|
||||||
|
|
|
@ -54,7 +54,7 @@ int Dialog::runModal() {
|
||||||
open();
|
open();
|
||||||
|
|
||||||
// Start processing events
|
// Start processing events
|
||||||
_gui->runLoop();
|
g_gui.runLoop();
|
||||||
|
|
||||||
// Return the result code
|
// Return the result code
|
||||||
return _result;
|
return _result;
|
||||||
|
@ -65,7 +65,7 @@ void Dialog::open() {
|
||||||
|
|
||||||
_result = 0;
|
_result = 0;
|
||||||
_visible = true;
|
_visible = true;
|
||||||
_gui->openDialog(this);
|
g_gui.openDialog(this);
|
||||||
|
|
||||||
// Search for the first objects that wantsFocus() (if any) and give it the focus
|
// Search for the first objects that wantsFocus() (if any) and give it the focus
|
||||||
while (w && !w->wantsFocus()) {
|
while (w && !w->wantsFocus()) {
|
||||||
|
@ -80,7 +80,7 @@ void Dialog::open() {
|
||||||
|
|
||||||
void Dialog::close() {
|
void Dialog::close() {
|
||||||
_visible = false;
|
_visible = false;
|
||||||
_gui->closeTopDialog();
|
g_gui.closeTopDialog();
|
||||||
|
|
||||||
if (_mouseWidget) {
|
if (_mouseWidget) {
|
||||||
_mouseWidget->handleMouseLeft(0);
|
_mouseWidget->handleMouseLeft(0);
|
||||||
|
@ -97,7 +97,7 @@ void Dialog::releaseFocus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::draw() {
|
void Dialog::draw() {
|
||||||
_gui->_needRedraw = true;
|
g_gui._needRedraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::drawDialog() {
|
void Dialog::drawDialog() {
|
||||||
|
@ -106,15 +106,15 @@ void Dialog::drawDialog() {
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_gui->blendRect(_x, _y, _w, _h, _gui->_bgcolor);
|
g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor);
|
||||||
_gui->box(_x, _y, _w, _h);
|
g_gui.box(_x, _y, _w, _h);
|
||||||
|
|
||||||
while (w) {
|
while (w) {
|
||||||
w->draw();
|
w->draw();
|
||||||
w = w->_next;
|
w = w->_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
_gui->addDirtyRect(_x, _y, _w, _h);
|
g_gui.addDirtyRect(_x, _y, _w, _h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
|
void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
|
||||||
|
@ -276,6 +276,8 @@ Widget *Dialog::findWidget(int x, int y) {
|
||||||
break;
|
break;
|
||||||
w = w->_next;
|
w = w->_next;
|
||||||
}
|
}
|
||||||
|
if (w)
|
||||||
|
w = w->findWidget(x - w->_x, y - w->_y);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ class Dialog : public CommandReceiver {
|
||||||
friend class Widget;
|
friend class Widget;
|
||||||
friend class NewGui;
|
friend class NewGui;
|
||||||
protected:
|
protected:
|
||||||
NewGui *_gui;
|
|
||||||
int16 _x, _y;
|
int16 _x, _y;
|
||||||
uint16 _w, _h;
|
uint16 _w, _h;
|
||||||
Widget *_firstWidget;
|
Widget *_firstWidget;
|
||||||
|
@ -49,15 +48,14 @@ private:
|
||||||
int _result;
|
int _result;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Dialog(NewGui *gui, int x, int y, int w, int h)
|
Dialog(int x, int y, int w, int h)
|
||||||
: _gui(gui), _x(x), _y(y), _w(w), _h(h), _firstWidget(0),
|
: _x(x), _y(y), _w(w), _h(h), _firstWidget(0),
|
||||||
_mouseWidget(0), _focusedWidget(0), _visible(false) {
|
_mouseWidget(0), _focusedWidget(0), _visible(false) {
|
||||||
}
|
}
|
||||||
virtual ~Dialog();
|
virtual ~Dialog();
|
||||||
|
|
||||||
virtual int runModal();
|
virtual int runModal();
|
||||||
|
|
||||||
NewGui *getGui() { return _gui; }
|
|
||||||
bool isVisible() const { return _visible; }
|
bool isVisible() const { return _visible; }
|
||||||
int16 getX() const { return _x; }
|
int16 getX() const { return _x; }
|
||||||
int16 getY() const { return _y; }
|
int16 getY() const { return _y; }
|
||||||
|
|
|
@ -78,7 +78,7 @@ class EditGameDialog : public Dialog {
|
||||||
typedef Common::String String;
|
typedef Common::String String;
|
||||||
typedef Common::StringList StringList;
|
typedef Common::StringList StringList;
|
||||||
public:
|
public:
|
||||||
EditGameDialog(NewGui *gui, const String &domain, GameSettings target);
|
EditGameDialog(const String &domain, GameSettings target);
|
||||||
|
|
||||||
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ protected:
|
||||||
CheckboxWidget *_fullscreenCheckbox;
|
CheckboxWidget *_fullscreenCheckbox;
|
||||||
};
|
};
|
||||||
|
|
||||||
EditGameDialog::EditGameDialog(NewGui *gui, const String &domain, GameSettings target)
|
EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
|
||||||
: Dialog(gui, 8, 50, 320 - 2 * 8, 200 - 2 * 40),
|
: Dialog(8, 50, 320 - 2 * 8, 200 - 2 * 40),
|
||||||
_domain(domain) {
|
_domain(domain) {
|
||||||
|
|
||||||
// Determine the description string
|
// Determine the description string
|
||||||
|
@ -130,7 +130,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
String newDomain(_domainWidget->getLabel());
|
String newDomain(_domainWidget->getLabel());
|
||||||
if (newDomain != _domain) {
|
if (newDomain != _domain) {
|
||||||
if (newDomain.isEmpty() || ConfMan.hasGameDomain(newDomain)) {
|
if (newDomain.isEmpty() || ConfMan.hasGameDomain(newDomain)) {
|
||||||
MessageDialog alert(_gui, "This game ID is already taken. Please choose another one.");
|
MessageDialog alert("This game ID is already taken. Please choose another one.");
|
||||||
alert.runModal();
|
alert.runModal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -156,8 +156,8 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
* - ...
|
* - ...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector)
|
LauncherDialog::LauncherDialog(GameDetector &detector)
|
||||||
: Dialog(gui, 0, 0, 320, 200), _detector(detector) {
|
: Dialog(0, 0, 320, 200), _detector(detector) {
|
||||||
// Show game name
|
// Show game name
|
||||||
new StaticTextWidget(this, 10, 8, 300, kLineHeight, gScummVMFullVersion, kTextAlignCenter);
|
new StaticTextWidget(this, 10, 8, 300, kLineHeight, gScummVMFullVersion, kTextAlignCenter);
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector)
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
|
||||||
// Create file browser dialog
|
// Create file browser dialog
|
||||||
_browser = new BrowserDialog(_gui, "Select directory with game data");
|
_browser = new BrowserDialog("Select directory with game data");
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherDialog::~LauncherDialog() {
|
LauncherDialog::~LauncherDialog() {
|
||||||
|
@ -286,7 +286,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
int idx;
|
int idx;
|
||||||
if (candidates.isEmpty()) {
|
if (candidates.isEmpty()) {
|
||||||
// No game was found in the specified directory
|
// No game was found in the specified directory
|
||||||
MessageDialog alert(_gui, "ScummVM could not find any game in the specified directory!");
|
MessageDialog alert("ScummVM could not find any game in the specified directory!");
|
||||||
alert.runModal();
|
alert.runModal();
|
||||||
idx = -1;
|
idx = -1;
|
||||||
} else if (candidates.size() == 1) {
|
} else if (candidates.size() == 1) {
|
||||||
|
@ -298,7 +298,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
for (idx = 0; idx < candidates.size(); idx++)
|
for (idx = 0; idx < candidates.size(); idx++)
|
||||||
list.push_back(candidates[idx].description);
|
list.push_back(candidates[idx].description);
|
||||||
|
|
||||||
ChooserDialog dialog(_gui, "Pick the game:", list);
|
ChooserDialog dialog("Pick the game:", list);
|
||||||
idx = dialog.runModal();
|
idx = dialog.runModal();
|
||||||
}
|
}
|
||||||
if (0 <= idx && idx < candidates.size()) {
|
if (0 <= idx && idx < candidates.size()) {
|
||||||
|
@ -323,7 +323,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
ConfMan.set("path", dir->path(), domain);
|
ConfMan.set("path", dir->path(), domain);
|
||||||
|
|
||||||
// Display edit dialog for the new entry
|
// Display edit dialog for the new entry
|
||||||
EditGameDialog editDialog(_gui, domain, result);
|
EditGameDialog editDialog(domain, result);
|
||||||
if (editDialog.runModal()) {
|
if (editDialog.runModal()) {
|
||||||
// User pressed OK, so make changes permanent
|
// User pressed OK, so make changes permanent
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
String gameId(ConfMan.get("gameid", _domains[item]));
|
String gameId(ConfMan.get("gameid", _domains[item]));
|
||||||
if (gameId.isEmpty())
|
if (gameId.isEmpty())
|
||||||
gameId = _domains[item];
|
gameId = _domains[item];
|
||||||
EditGameDialog editDialog(_gui, _domains[item], GameDetector::findGame(gameId));
|
EditGameDialog editDialog(_domains[item], GameDetector::findGame(gameId));
|
||||||
if (editDialog.runModal()) {
|
if (editDialog.runModal()) {
|
||||||
// User pressed OK, so make changes permanent
|
// User pressed OK, so make changes permanent
|
||||||
|
|
||||||
|
@ -382,12 +382,12 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
// - music & graphics driver (but see also the comments on EditGameDialog
|
// - music & graphics driver (but see also the comments on EditGameDialog
|
||||||
// for some techincal difficulties with this)
|
// for some techincal difficulties with this)
|
||||||
// - default volumes (sfx/master/music)
|
// - default volumes (sfx/master/music)
|
||||||
GlobalOptionsDialog options(_gui, _detector);
|
GlobalOptionsDialog options(_detector);
|
||||||
options.runModal();
|
options.runModal();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kAboutCmd: {
|
case kAboutCmd: {
|
||||||
AboutDialog about(_gui);
|
AboutDialog about;
|
||||||
about.runModal();
|
about.runModal();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -33,7 +33,7 @@ class LauncherDialog : public Dialog {
|
||||||
typedef Common::String String;
|
typedef Common::String String;
|
||||||
typedef Common::StringList StringList;
|
typedef Common::StringList StringList;
|
||||||
public:
|
public:
|
||||||
LauncherDialog(NewGui *gui, GameDetector &detector);
|
LauncherDialog(GameDetector &detector);
|
||||||
~LauncherDialog();
|
~LauncherDialog();
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
|
|
@ -29,8 +29,8 @@ enum {
|
||||||
kCancelCmd = 'CNCL'
|
kCancelCmd = 'CNCL'
|
||||||
};
|
};
|
||||||
|
|
||||||
MessageDialog::MessageDialog(NewGui *gui, const String &message, const char *defaultButton, const char *altButton)
|
MessageDialog::MessageDialog(const String &message, const char *defaultButton, const char *altButton)
|
||||||
: Dialog(gui, 30, 20, 260, 124) {
|
: Dialog(30, 20, 260, 124) {
|
||||||
// First, determine the size the dialog needs. For this we have to break
|
// 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.
|
// down the string into lines, and taking the maximum of their widths.
|
||||||
// Using this, and accounting for the space the button(s) need, we can set
|
// Using this, and accounting for the space the button(s) need, we can set
|
||||||
|
@ -95,9 +95,10 @@ int MessageDialog::addLine(StringList &lines, const char *line, int size) {
|
||||||
int width = 0, maxWidth = 0;
|
int width = 0, maxWidth = 0;
|
||||||
const char *start = line, *pos = line, *end = start + size;
|
const char *start = line, *pos = line, *end = start + size;
|
||||||
String tmp;
|
String tmp;
|
||||||
|
NewGui *gui = &g_gui;
|
||||||
|
|
||||||
while (pos < end) {
|
while (pos < end) {
|
||||||
int w = _gui->getCharWidth(*pos);
|
int w = gui->getCharWidth(*pos);
|
||||||
|
|
||||||
// Check if we exceed the maximum line width, if so, split the line.
|
// Check if we exceed the maximum line width, if so, split the line.
|
||||||
// If possible we split at whitespaces.
|
// If possible we split at whitespaces.
|
||||||
|
@ -114,7 +115,7 @@ int MessageDialog::addLine(StringList &lines, const char *line, int size) {
|
||||||
lines.push_back(tmp);
|
lines.push_back(tmp);
|
||||||
|
|
||||||
// Determine the width of the string, and adjust maxWidth accordingly
|
// Determine the width of the string, and adjust maxWidth accordingly
|
||||||
width = _gui->getStringWidth(tmp);
|
width = gui->getStringWidth(tmp);
|
||||||
if (maxWidth < width)
|
if (maxWidth < width)
|
||||||
maxWidth = width;
|
maxWidth = width;
|
||||||
|
|
||||||
|
@ -148,13 +149,13 @@ void MessageDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TimedMessageDialog::TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 duration)
|
TimedMessageDialog::TimedMessageDialog(const Common::String &message, uint32 duration)
|
||||||
: MessageDialog(gui, message, 0, 0) {
|
: MessageDialog(message, 0, 0) {
|
||||||
_timer = _gui->get_time() + duration;
|
_timer = g_system->get_msecs() + duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimedMessageDialog::handleTickle() {
|
void TimedMessageDialog::handleTickle() {
|
||||||
MessageDialog::handleTickle();
|
MessageDialog::handleTickle();
|
||||||
if (_gui->get_time() > _timer)
|
if (g_system->get_msecs() > _timer)
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class MessageDialog : public Dialog {
|
||||||
typedef Common::String String;
|
typedef Common::String String;
|
||||||
typedef Common::StringList StringList;
|
typedef Common::StringList StringList;
|
||||||
public:
|
public:
|
||||||
MessageDialog(NewGui *gui, const Common::String &message, const char *defaultButton = "OK", const char *altButton = 0);
|
MessageDialog(const Common::String &message, const char *defaultButton = "OK", const char *altButton = 0);
|
||||||
|
|
||||||
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
class TimedMessageDialog : public MessageDialog {
|
class TimedMessageDialog : public MessageDialog {
|
||||||
public:
|
public:
|
||||||
TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 duration);
|
TimedMessageDialog(const Common::String &message, uint32 duration);
|
||||||
|
|
||||||
void handleTickle();
|
void handleTickle();
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,11 @@ static byte guifont[] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
NewGui::NewGui(OSystem *system) : _system(system), _screen(0), _needRedraw(false),
|
NewGui::NewGui() : _screen(0), _needRedraw(false),
|
||||||
_stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) {
|
_stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) {
|
||||||
|
|
||||||
|
_system = OSystem::instance();
|
||||||
|
|
||||||
// Clear the cursor
|
// Clear the cursor
|
||||||
memset(_cursor, 0xFF, sizeof(_cursor));
|
memset(_cursor, 0xFF, sizeof(_cursor));
|
||||||
|
|
||||||
|
@ -144,7 +147,7 @@ void NewGui::runLoop() {
|
||||||
_system->update_screen();
|
_system->update_screen();
|
||||||
|
|
||||||
OSystem::Event event;
|
OSystem::Event event;
|
||||||
uint32 time = get_time();
|
uint32 time = _system->get_msecs();
|
||||||
|
|
||||||
while (_system->poll_event(&event)) {
|
while (_system->poll_event(&event)) {
|
||||||
switch (event.event_code) {
|
switch (event.event_code) {
|
||||||
|
@ -504,7 +507,7 @@ void NewGui::drawBitmap(uint32 *bitmap, int x, int y, NewGuiColor color, int h)
|
||||||
// We could plug in a different cursor here if we like to.
|
// We could plug in a different cursor here if we like to.
|
||||||
//
|
//
|
||||||
void NewGui::animateCursor() {
|
void NewGui::animateCursor() {
|
||||||
int time = get_time();
|
int time = _system->get_msecs();
|
||||||
if (time > _cursorAnimateTimer + kCursorAnimateDelay) {
|
if (time > _cursorAnimateTimer + kCursorAnimateDelay) {
|
||||||
const byte colors[4] = { 15, 15, 7, 8 };
|
const byte colors[4] = { 15, 15, 7, 8 };
|
||||||
const byte color = colors[_cursorAnimateCounter];
|
const byte color = colors[_cursorAnimateCounter];
|
||||||
|
|
17
gui/newgui.h
17
gui/newgui.h
|
@ -22,14 +22,18 @@
|
||||||
#define NEWGUI_H
|
#define NEWGUI_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/system.h" // For events
|
#include "common/singleton.h"
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
|
#include "common/system.h" // For events
|
||||||
|
|
||||||
class Dialog;
|
class Dialog;
|
||||||
|
|
||||||
#define hLine(x, y, x2, color) line(x, y, x2, y, color);
|
#define hLine(x, y, x2, color) line(x, y, x2, y, color);
|
||||||
#define vLine(x, y, y2, color) line(x, y, x, y2, color);
|
#define vLine(x, y, y2, color) line(x, y, x, y2, color);
|
||||||
|
|
||||||
|
#define g_gui (NewGui::instance())
|
||||||
|
|
||||||
|
|
||||||
// Height of a single text line
|
// Height of a single text line
|
||||||
enum {
|
enum {
|
||||||
kLineHeight = 11
|
kLineHeight = 11
|
||||||
|
@ -60,9 +64,11 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class hopefully will replace the old Gui class completly one day
|
// This class hopefully will replace the old Gui class completly one day
|
||||||
class NewGui {
|
class NewGui : public Common::Singleton<NewGui> {
|
||||||
friend class Dialog;
|
|
||||||
typedef Common::String String;
|
typedef Common::String String;
|
||||||
|
friend class Dialog;
|
||||||
|
friend class Common::Singleton<NewGui>;
|
||||||
|
NewGui();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Main entry for the GUI: this will start an event loop that keeps running
|
// Main entry for the GUI: this will start an event loop that keeps running
|
||||||
|
@ -71,8 +77,6 @@ public:
|
||||||
|
|
||||||
bool isActive() { return ! _dialogStack.empty(); }
|
bool isActive() { return ! _dialogStack.empty(); }
|
||||||
|
|
||||||
NewGui(OSystem *system);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OSystem *_system;
|
OSystem *_system;
|
||||||
NewGuiColor *_screen;
|
NewGuiColor *_screen;
|
||||||
|
@ -122,9 +126,6 @@ public:
|
||||||
NewGuiColor _textcolor;
|
NewGuiColor _textcolor;
|
||||||
NewGuiColor _textcolorhi;
|
NewGuiColor _textcolorhi;
|
||||||
|
|
||||||
// Misc util
|
|
||||||
uint32 get_time() const { return _system->get_msecs(); }
|
|
||||||
|
|
||||||
// Drawing primitives
|
// Drawing primitives
|
||||||
NewGuiColor *getBasePtr(int x, int y);
|
NewGuiColor *getBasePtr(int x, int y);
|
||||||
void box(int x, int y, int width, int height, bool inverted = false);
|
void box(int x, int y, int width, int height, bool inverted = false);
|
||||||
|
|
|
@ -61,8 +61,8 @@ enum {
|
||||||
kOKCmd = 'ok '
|
kOKCmd = 'ok '
|
||||||
};
|
};
|
||||||
|
|
||||||
GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui, GameDetector &detector)
|
GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector)
|
||||||
: Dialog(gui, 10, 15, 320 - 2 * 10, 200 - 2 * 15) {
|
: Dialog(10, 15, 320 - 2 * 10, 200 - 2 * 15) {
|
||||||
// The GFX mode popup & a label
|
// The GFX mode popup & a label
|
||||||
// TODO - add an API to query the list of available GFX modes, and to get/set the mode
|
// TODO - add an API to query the list of available GFX modes, and to get/set the mode
|
||||||
new StaticTextWidget(this, 5, 10+1, 100, kLineHeight, "Graphics mode: ", kTextAlignRight);
|
new StaticTextWidget(this, 5, 10+1, 100, kLineHeight, "Graphics mode: ", kTextAlignRight);
|
||||||
|
@ -156,7 +156,7 @@ GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui, GameDetector &detector)
|
||||||
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
||||||
|
|
||||||
// Create file browser dialog
|
// Create file browser dialog
|
||||||
_browser = new BrowserDialog(_gui, "Select directory for savegames");
|
_browser = new BrowserDialog("Select directory for savegames");
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalOptionsDialog::~GlobalOptionsDialog() {
|
GlobalOptionsDialog::~GlobalOptionsDialog() {
|
||||||
|
|
|
@ -32,7 +32,7 @@ class PopUpWidget;
|
||||||
class GlobalOptionsDialog : public Dialog {
|
class GlobalOptionsDialog : public Dialog {
|
||||||
typedef Common::String String;
|
typedef Common::String String;
|
||||||
public:
|
public:
|
||||||
GlobalOptionsDialog(NewGui *gui, GameDetector &detector);
|
GlobalOptionsDialog(GameDetector &detector);
|
||||||
~GlobalOptionsDialog();
|
~GlobalOptionsDialog();
|
||||||
|
|
||||||
void open();
|
void open();
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "newgui.h"
|
#include "newgui.h"
|
||||||
|
|
||||||
Widget::Widget (Dialog *boss, int x, int y, int w, int h)
|
Widget::Widget(Dialog *boss, int x, int y, int w, int h)
|
||||||
: _type(0), _boss(boss), _x(x), _y(y), _w(w), _h(h),
|
: _type(0), _boss(boss), _x(x), _y(y), _w(w), _h(h),
|
||||||
_id(0), _flags(0), _hasFocus(false) {
|
_id(0), _flags(0), _hasFocus(false) {
|
||||||
// Insert into the widget list of the boss
|
// Insert into the widget list of the boss
|
||||||
|
@ -32,7 +32,7 @@ Widget::Widget (Dialog *boss, int x, int y, int w, int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::draw() {
|
void Widget::draw() {
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
|
|
||||||
if (!isVisible() || !_boss->isVisible())
|
if (!isVisible() || !_boss->isVisible())
|
||||||
return;
|
return;
|
||||||
|
@ -75,7 +75,7 @@ void Widget::draw() {
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text, int align)
|
StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text, int align)
|
||||||
: Widget (boss, x, y, w, h), _align(align) {
|
: Widget(boss, x, y, w, h), _align(align) {
|
||||||
_type = kStaticTextWidget;
|
_type = kStaticTextWidget;
|
||||||
setLabel(text);
|
setLabel(text);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ void StaticTextWidget::setValue(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticTextWidget::drawWidget(bool hilite) {
|
void StaticTextWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
gui->drawString(_label, _x, _y, _w, gui->_textcolor, _align);
|
gui->drawString(_label, _x, _y, _w, gui->_textcolor, _align);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget::drawWidget(bool hilite) {
|
void ButtonWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
gui->drawString(_label, _x, _y, _w,
|
gui->drawString(_label, _x, _y, _w,
|
||||||
!isEnabled() ? gui->_color :
|
!isEnabled() ? gui->_color :
|
||||||
hilite ? gui->_textcolorhi : gui->_textcolor, _align);
|
hilite ? gui->_textcolorhi : gui->_textcolor, _align);
|
||||||
|
@ -156,7 +156,7 @@ void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckboxWidget::drawWidget(bool hilite) {
|
void CheckboxWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
|
|
||||||
// Draw the box
|
// Draw the box
|
||||||
gui->box(_x, _y, 14, 14);
|
gui->box(_x, _y, 14, 14);
|
||||||
|
@ -213,7 +213,7 @@ void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidget::drawWidget(bool hilite) {
|
void SliderWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = &g_gui;
|
||||||
|
|
||||||
// Draw the box
|
// Draw the box
|
||||||
gui->box(_x, _y, _w, _h);
|
gui->box(_x, _y, _w, _h);
|
||||||
|
|
|
@ -87,7 +87,7 @@ public:
|
||||||
|
|
||||||
/* Widget */
|
/* Widget */
|
||||||
class Widget {
|
class Widget {
|
||||||
friend class Dialog;
|
friend class Dialog;
|
||||||
protected:
|
protected:
|
||||||
uint32 _type;
|
uint32 _type;
|
||||||
Dialog *_boss;
|
Dialog *_boss;
|
||||||
|
@ -129,6 +129,8 @@ protected:
|
||||||
|
|
||||||
virtual void receivedFocusWidget() {}
|
virtual void receivedFocusWidget() {}
|
||||||
virtual void lostFocusWidget() {}
|
virtual void lostFocusWidget() {}
|
||||||
|
|
||||||
|
virtual Widget *findWidget(int x, int y) { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* StaticTextWidget */
|
/* StaticTextWidget */
|
||||||
|
|
|
@ -40,7 +40,7 @@ extern uint16 _debugLevel;
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
ScummDebugger::ScummDebugger(ScummEngine *s)
|
ScummDebugger::ScummDebugger(ScummEngine *s)
|
||||||
: Common::Debugger<ScummDebugger>(s->_newgui) {
|
: Common::Debugger<ScummDebugger>() {
|
||||||
_vm = s;
|
_vm = s;
|
||||||
|
|
||||||
// Register variables
|
// Register variables
|
||||||
|
|
|
@ -192,8 +192,8 @@ enum {
|
||||||
kQuitCmd = 'QUIT'
|
kQuitCmd = 'QUIT'
|
||||||
};
|
};
|
||||||
|
|
||||||
SaveLoadDialog::SaveLoadDialog(NewGui *gui, ScummEngine *scumm)
|
SaveLoadDialog::SaveLoadDialog(ScummEngine *scumm)
|
||||||
: ScummDialog(gui, scumm, 20, 8, 280, 184) {
|
: ScummDialog(scumm, 20, 8, 280, 184) {
|
||||||
const int x = _w - kButtonWidth - 8;
|
const int x = _w - kButtonWidth - 8;
|
||||||
int y = 20;
|
int y = 20;
|
||||||
|
|
||||||
|
@ -218,9 +218,9 @@ SaveLoadDialog::SaveLoadDialog(NewGui *gui, ScummEngine *scumm)
|
||||||
//
|
//
|
||||||
// Create the sub dialog(s)
|
// Create the sub dialog(s)
|
||||||
//
|
//
|
||||||
_aboutDialog = new AboutDialog(gui);
|
_aboutDialog = new AboutDialog();
|
||||||
#ifndef DISABLE_HELP
|
#ifndef DISABLE_HELP
|
||||||
_helpDialog = new HelpDialog(gui, scumm);
|
_helpDialog = new HelpDialog(scumm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The save game list
|
// The save game list
|
||||||
|
@ -388,11 +388,11 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
#ifndef _WIN32_WCE
|
||||||
OptionsDialog::OptionsDialog(NewGui *gui, ScummEngine *scumm)
|
OptionsDialog::OptionsDialog(ScummEngine *scumm)
|
||||||
: ScummDialog(gui, scumm, 40, 30, 240, 124) {
|
: ScummDialog(scumm, 40, 30, 240, 124) {
|
||||||
#else
|
#else
|
||||||
OptionsDialog::OptionsDialog(NewGui *gui, ScummEngine *scumm)
|
OptionsDialog::OptionsDialog(ScummEngine *scumm)
|
||||||
: ScummDialog(gui, scumm, 40, 30, 240, 124 + kButtonHeight + 4) {
|
: ScummDialog(scumm, 40, 30, 240, 124 + kButtonHeight + 4) {
|
||||||
#endif
|
#endif
|
||||||
//
|
//
|
||||||
// Add the buttons
|
// Add the buttons
|
||||||
|
@ -442,7 +442,7 @@ OptionsDialog::OptionsDialog(NewGui *gui, ScummEngine *scumm)
|
||||||
// Create the sub dialog(s)
|
// Create the sub dialog(s)
|
||||||
//
|
//
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
_keysDialog = new KeysDialog(gui, scumm);
|
_keysDialog = new KeysDialog(scumm);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,8 +538,8 @@ enum {
|
||||||
kPrevCmd = 'PREV'
|
kPrevCmd = 'PREV'
|
||||||
};
|
};
|
||||||
|
|
||||||
HelpDialog::HelpDialog(NewGui *gui, ScummEngine *scumm)
|
HelpDialog::HelpDialog(ScummEngine *scumm)
|
||||||
: ScummDialog(gui, scumm, 5, 5, 310, 190) {
|
: ScummDialog(scumm, 5, 5, 310, 190) {
|
||||||
|
|
||||||
_page = 1;
|
_page = 1;
|
||||||
_numPages = ScummHelp::numPages(scumm->_gameId);
|
_numPages = ScummHelp::numPages(scumm->_gameId);
|
||||||
|
@ -608,18 +608,18 @@ void HelpDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
InfoDialog::InfoDialog(NewGui *gui, ScummEngine *scumm, int res)
|
InfoDialog::InfoDialog(ScummEngine *scumm, int res)
|
||||||
: ScummDialog(gui, scumm, 0, 80, 0, 16) { // dummy x and w
|
: ScummDialog(scumm, 0, 80, 0, 16) { // dummy x and w
|
||||||
setInfoText(queryResString (res));
|
setInfoText(queryResString (res));
|
||||||
}
|
}
|
||||||
|
|
||||||
InfoDialog::InfoDialog(NewGui *gui, ScummEngine *scumm, const String& message)
|
InfoDialog::InfoDialog(ScummEngine *scumm, const String& message)
|
||||||
: ScummDialog(gui, scumm, 0, 80, 0, 16) { // dummy x and w
|
: ScummDialog(scumm, 0, 80, 0, 16) { // dummy x and w
|
||||||
setInfoText(message);
|
setInfoText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoDialog::setInfoText(const String& message) {
|
void InfoDialog::setInfoText(const String& message) {
|
||||||
int width = _gui->getStringWidth(message.c_str()) + 16;
|
int width = g_gui.getStringWidth(message) + 16;
|
||||||
|
|
||||||
_x = (_scumm->_screenWidth - width) >> 1;
|
_x = (_scumm->_screenWidth - width) >> 1;
|
||||||
_w = width;
|
_w = width;
|
||||||
|
@ -629,12 +629,12 @@ void InfoDialog::setInfoText(const String& message) {
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
PauseDialog::PauseDialog(NewGui *gui, ScummEngine *scumm)
|
PauseDialog::PauseDialog(ScummEngine *scumm)
|
||||||
: InfoDialog(gui, scumm, 10) {
|
: InfoDialog(scumm, 10) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmExitDialog::ConfirmExitDialog(NewGui *gui, ScummEngine *scumm)
|
ConfirmExitDialog::ConfirmExitDialog(ScummEngine *scumm)
|
||||||
: InfoDialog(gui, scumm, "Do you really want to quit (y/n)?") {
|
: InfoDialog(scumm, "Do you really want to quit (y/n)?") {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmExitDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
void ConfirmExitDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
||||||
|
@ -657,8 +657,8 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
KeysDialog::KeysDialog(NewGui *gui, ScummEngine *scumm)
|
KeysDialog::KeysDialog(ScummEngine *scumm)
|
||||||
: ScummDialog(gui, scumm, 30, 20, 260, 160) {
|
: ScummDialog(scumm, 30, 20, 260, 160) {
|
||||||
addButton(160, 20, "Map", kMapCmd, 'M'); // Map
|
addButton(160, 20, "Map", kMapCmd, 'M'); // Map
|
||||||
addButton(160, 40, "OK", kOKCmd, 'O'); // OK
|
addButton(160, 40, "OK", kOKCmd, 'O'); // OK
|
||||||
addButton(160, 60, "Cancel", kCancelCmd, 'C'); // Cancel
|
addButton(160, 60, "Cancel", kCancelCmd, 'C'); // Cancel
|
||||||
|
|
|
@ -37,8 +37,8 @@ class ScummEngine;
|
||||||
|
|
||||||
class ScummDialog : public Dialog {
|
class ScummDialog : public Dialog {
|
||||||
public:
|
public:
|
||||||
ScummDialog(NewGui *gui, ScummEngine *scumm, int x, int y, int w, int h)
|
ScummDialog(ScummEngine *scumm, int x, int y, int w, int h)
|
||||||
: Dialog(gui, x, y, w, h), _scumm(scumm) {}
|
: Dialog(x, y, w, h), _scumm(scumm) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef Common::String String;
|
typedef Common::String String;
|
||||||
|
@ -53,7 +53,7 @@ protected:
|
||||||
|
|
||||||
class SaveLoadDialog : public ScummDialog {
|
class SaveLoadDialog : public ScummDialog {
|
||||||
public:
|
public:
|
||||||
SaveLoadDialog(NewGui *gui, ScummEngine *scumm);
|
SaveLoadDialog(ScummEngine *scumm);
|
||||||
~SaveLoadDialog();
|
~SaveLoadDialog();
|
||||||
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
@ -83,7 +83,7 @@ protected:
|
||||||
|
|
||||||
class HelpDialog : public ScummDialog {
|
class HelpDialog : public ScummDialog {
|
||||||
public:
|
public:
|
||||||
HelpDialog(NewGui *gui, ScummEngine *scumm);
|
HelpDialog(ScummEngine *scumm);
|
||||||
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -111,7 +111,7 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OptionsDialog(NewGui *gui, ScummEngine *scumm);
|
OptionsDialog(ScummEngine *scumm);
|
||||||
~OptionsDialog();
|
~OptionsDialog();
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
@ -137,9 +137,9 @@ protected:
|
||||||
class InfoDialog : public ScummDialog {
|
class InfoDialog : public ScummDialog {
|
||||||
public:
|
public:
|
||||||
// arbitrary message
|
// arbitrary message
|
||||||
InfoDialog(NewGui *gui, ScummEngine *scumm, const String& message);
|
InfoDialog(ScummEngine *scumm, const String& message);
|
||||||
// from resources
|
// from resources
|
||||||
InfoDialog(NewGui *gui, ScummEngine *scumm, int res);
|
InfoDialog(ScummEngine *scumm, int res);
|
||||||
|
|
||||||
virtual void handleMouseDown(int x, int y, int button, int clickCount) {
|
virtual void handleMouseDown(int x, int y, int button, int clickCount) {
|
||||||
close();
|
close();
|
||||||
|
@ -155,7 +155,7 @@ protected:
|
||||||
|
|
||||||
class PauseDialog : public InfoDialog {
|
class PauseDialog : public InfoDialog {
|
||||||
public:
|
public:
|
||||||
PauseDialog(NewGui *gui, ScummEngine *scumm);
|
PauseDialog(ScummEngine *scumm);
|
||||||
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers)
|
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers)
|
||||||
{
|
{
|
||||||
if (ascii == ' ') // Close pause dialog if space key is pressed
|
if (ascii == ' ') // Close pause dialog if space key is pressed
|
||||||
|
@ -167,7 +167,7 @@ public:
|
||||||
|
|
||||||
class ConfirmExitDialog : public InfoDialog {
|
class ConfirmExitDialog : public InfoDialog {
|
||||||
public:
|
public:
|
||||||
ConfirmExitDialog(NewGui *gui, ScummEngine *scumm);
|
ConfirmExitDialog(ScummEngine *scumm);
|
||||||
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
|
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ public:
|
||||||
|
|
||||||
class KeysDialog : public ScummDialog {
|
class KeysDialog : public ScummDialog {
|
||||||
public:
|
public:
|
||||||
KeysDialog(NewGui *gui, ScummEngine *scumm);
|
KeysDialog(ScummEngine *scumm);
|
||||||
|
|
||||||
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||||
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
|
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
|
||||||
|
|
|
@ -240,7 +240,7 @@ void ScummEngine::askForDisk(const char *filename, int disknum) {
|
||||||
error("Cannot find file: '%s'", filename);
|
error("Cannot find file: '%s'", filename);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "Cannot find file: '%s'", filename);
|
sprintf(buf, "Cannot find file: '%s'", filename);
|
||||||
InfoDialog dialog(_newgui, this, (char*)buf);
|
InfoDialog dialog(this, (char*)buf);
|
||||||
runDialog(dialog);
|
runDialog(dialog);
|
||||||
error("Cannot find file: '%s'", filename);
|
error("Cannot find file: '%s'", filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2425,7 +2425,7 @@ void ScummEngine_v6::o6_kernelSetFunctions() {
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (readArray(233,0,50) == 0) {
|
if (readArray(233,0,50) == 0) {
|
||||||
InfoDialog info(_newgui, this, "Set MineRoad - You can now jump the gorge.");
|
InfoDialog info(this, "Set MineRoad - You can now jump the gorge.");
|
||||||
runDialog(info);
|
runDialog(info);
|
||||||
|
|
||||||
writeArray(233, 0, 50, 1); // INSANE callback: Chain
|
writeArray(233, 0, 50, 1); // INSANE callback: Chain
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
class Dialog;
|
class Dialog;
|
||||||
class GameDetector;
|
class GameDetector;
|
||||||
class NewGui;
|
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
|
@ -341,9 +340,6 @@ public:
|
||||||
/** We keep running until this is set to true. */
|
/** We keep running until this is set to true. */
|
||||||
bool _quit;
|
bool _quit;
|
||||||
|
|
||||||
// GUI
|
|
||||||
NewGui *_newgui;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Dialog *_pauseDialog;
|
Dialog *_pauseDialog;
|
||||||
Dialog *_optionsDialog;
|
Dialog *_optionsDialog;
|
||||||
|
|
|
@ -64,7 +64,6 @@
|
||||||
extern bool isSmartphone(void);
|
extern bool isSmartphone(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern NewGui *g_gui;
|
|
||||||
extern uint16 _debugLevel;
|
extern uint16 _debugLevel;
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
@ -307,7 +306,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
|
||||||
_videoFinished = false;
|
_videoFinished = false;
|
||||||
_smushPlay = false;
|
_smushPlay = false;
|
||||||
_quit = false;
|
_quit = false;
|
||||||
_newgui = NULL;
|
|
||||||
_pauseDialog = NULL;
|
_pauseDialog = NULL;
|
||||||
_optionsDialog = NULL;
|
_optionsDialog = NULL;
|
||||||
_saveLoadDialog = NULL;
|
_saveLoadDialog = NULL;
|
||||||
|
@ -650,8 +648,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
|
||||||
// Setup GDI object
|
// Setup GDI object
|
||||||
gdi._numStrips = _screenWidth / 8;
|
gdi._numStrips = _screenWidth / 8;
|
||||||
|
|
||||||
_newgui = g_gui;
|
|
||||||
|
|
||||||
// Create debugger
|
// Create debugger
|
||||||
_debugger = new ScummDebugger(this);
|
_debugger = new ScummDebugger(this);
|
||||||
|
|
||||||
|
@ -1366,7 +1362,7 @@ load_game:
|
||||||
#endif
|
#endif
|
||||||
sprintf(buf, "Successfully saved game state in file:\n\n%s", filename);
|
sprintf(buf, "Successfully saved game state in file:\n\n%s", filename);
|
||||||
|
|
||||||
TimedMessageDialog dialog(_newgui, buf, 1500);
|
TimedMessageDialog dialog(buf, 1500);
|
||||||
runDialog(dialog);
|
runDialog(dialog);
|
||||||
}
|
}
|
||||||
if (success && _saveLoadFlag != 1)
|
if (success && _saveLoadFlag != 1)
|
||||||
|
@ -2459,25 +2455,25 @@ int ScummEngine::runDialog(Dialog &dialog) {
|
||||||
|
|
||||||
void ScummEngine::pauseDialog() {
|
void ScummEngine::pauseDialog() {
|
||||||
if (!_pauseDialog)
|
if (!_pauseDialog)
|
||||||
_pauseDialog = new PauseDialog(_newgui, this);
|
_pauseDialog = new PauseDialog(this);
|
||||||
runDialog(*_pauseDialog);
|
runDialog(*_pauseDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine::saveloadDialog() {
|
void ScummEngine::saveloadDialog() {
|
||||||
if (!_saveLoadDialog)
|
if (!_saveLoadDialog)
|
||||||
_saveLoadDialog = new SaveLoadDialog(_newgui, this);
|
_saveLoadDialog = new SaveLoadDialog(this);
|
||||||
runDialog(*_saveLoadDialog);
|
runDialog(*_saveLoadDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine::optionsDialog() {
|
void ScummEngine::optionsDialog() {
|
||||||
if (!_optionsDialog)
|
if (!_optionsDialog)
|
||||||
_optionsDialog = new OptionsDialog(_newgui, this);
|
_optionsDialog = new OptionsDialog(this);
|
||||||
runDialog(*_optionsDialog);
|
runDialog(*_optionsDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine::confirmexitDialog() {
|
void ScummEngine::confirmexitDialog() {
|
||||||
if (!_confirmExitDialog)
|
if (!_confirmExitDialog)
|
||||||
_confirmExitDialog = new ConfirmExitDialog(_newgui, this);
|
_confirmExitDialog = new ConfirmExitDialog(this);
|
||||||
|
|
||||||
if (runDialog(*_confirmExitDialog)) {
|
if (runDialog(*_confirmExitDialog)) {
|
||||||
_quit = true;
|
_quit = true;
|
||||||
|
@ -2496,7 +2492,7 @@ char ScummEngine::displayError(bool showCancel, const char *message, ...) {
|
||||||
vsprintf(buf, message, va);
|
vsprintf(buf, message, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
MessageDialog dialog(_newgui, buf, "OK", "Cancel");
|
MessageDialog dialog(buf, "OK", "Cancel");
|
||||||
return runDialog(dialog);
|
return runDialog(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ void ScummEngine::unkMessage2() {
|
||||||
|
|
||||||
// FIXME: I know this is the right thing to do for MI1 and MI2. For
|
// FIXME: I know this is the right thing to do for MI1 and MI2. For
|
||||||
// all other games it's just a guess.
|
// all other games it's just a guess.
|
||||||
InfoDialog dialog(_newgui, this, (char*)buf);
|
InfoDialog dialog(this, (char*)buf);
|
||||||
VAR(VAR_KEYPRESS) = runDialog(dialog);
|
VAR(VAR_KEYPRESS) = runDialog(dialog);
|
||||||
|
|
||||||
_messagePtr = tmp;
|
_messagePtr = tmp;
|
||||||
|
|
|
@ -48,7 +48,7 @@ static void Var_set(int var, int val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Debugger::Debugger(Sword2Engine *s)
|
Debugger::Debugger(Sword2Engine *s)
|
||||||
: Common::Debugger<Debugger>(s->_newgui) {
|
: Common::Debugger<Debugger>() {
|
||||||
_vm = s;
|
_vm = s;
|
||||||
|
|
||||||
// Register commands
|
// Register commands
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
extern bool isSmartphone(void);
|
extern bool isSmartphone(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern NewGui *g_gui;
|
|
||||||
extern uint16 _debugLevel;
|
extern uint16 _debugLevel;
|
||||||
|
|
||||||
static const GameSettings sword2_settings[] = {
|
static const GameSettings sword2_settings[] = {
|
||||||
|
@ -117,7 +116,6 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
|
||||||
|
|
||||||
_detector = detector;
|
_detector = detector;
|
||||||
g_sword2 = this;
|
g_sword2 = this;
|
||||||
_newgui = NULL;
|
|
||||||
_debugger = NULL;
|
_debugger = NULL;
|
||||||
_features = detector->_game.features;
|
_features = detector->_game.features;
|
||||||
_targetName = strdup(detector->_targetName.c_str());
|
_targetName = strdup(detector->_targetName.c_str());
|
||||||
|
@ -139,7 +137,6 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
|
||||||
g_display = _display = new Display(640, 480);
|
g_display = _display = new Display(640, 480);
|
||||||
gui = new Gui();
|
gui = new Gui();
|
||||||
|
|
||||||
_newgui = g_gui;
|
|
||||||
_debugger = new Debugger(this);
|
_debugger = new Debugger(this);
|
||||||
|
|
||||||
_lastPaletteRes = 0;
|
_lastPaletteRes = 0;
|
||||||
|
|
|
@ -34,8 +34,6 @@ enum {
|
||||||
GF_DEMO = 1 << 0
|
GF_DEMO = 1 << 0
|
||||||
};
|
};
|
||||||
|
|
||||||
class NewGui;
|
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
// Bodge for PCF76 version so that their demo CD can be labelled "PCF76"
|
// Bodge for PCF76 version so that their demo CD can be labelled "PCF76"
|
||||||
|
@ -140,7 +138,6 @@ public:
|
||||||
Sound *_sound;
|
Sound *_sound;
|
||||||
Display *_display;
|
Display *_display;
|
||||||
|
|
||||||
NewGui *_newgui;
|
|
||||||
Debugger *_debugger;
|
Debugger *_debugger;
|
||||||
|
|
||||||
Common::RandomSource _rnd;
|
Common::RandomSource _rnd;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue