[Scummvm-cvs-logs] CVS: scummvm/gui EditTextWidget.cpp,1.15,1.16 EditTextWidget.h,1.8,1.9 ListWidget.cpp,1.25,1.26 PopUpWidget.cpp,1.18,1.19 ScrollBarWidget.cpp,1.9,1.10 about.cpp,1.5,1.6 about.h,1.1,1.2 browser.cpp,1.13,1.14 browser.h,1.8,1.9 chooser.cpp,1.5,1.6 chooser.h,1.4,1.5 console.cpp,1.34,1.35 console.h,1.18,1.19 dialog.cpp,1.31,1.32 dialog.h,1.21,1.22 launcher.cpp,1.61,1.62 launcher.h,1.12,1.13 message.cpp,1.13,1.14 message.h,1.9,1.10 newgui.cpp,1.62,1.63 newgui.h,1.29,1.30 options.cpp,1.27,1.28 options.h,1.6,1.7 widget.cpp,1.18,1.19 widget.h,1.21,1.22
Max Horn
fingolfin at users.sourceforge.net
Sat Nov 1 18:19:09 CET 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common debugger.cpp,1.1,1.2 debugger.h,1.1,1.2 module.mk,1.11,1.12 singleton.h,1.1,1.2 system.h,1.45,1.46
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm debugger.cpp,1.96,1.97 dialogs.cpp,1.77,1.78 dialogs.h,1.26,1.27 resource.cpp,1.169,1.170 script_v6.cpp,1.203,1.204 scumm.h,1.318,1.319 scummvm.cpp,2.465,2.466 string.cpp,1.163,1.164
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv15749/gui
Modified Files:
EditTextWidget.cpp EditTextWidget.h ListWidget.cpp
PopUpWidget.cpp ScrollBarWidget.cpp about.cpp about.h
browser.cpp browser.h chooser.cpp chooser.h console.cpp
console.h dialog.cpp dialog.h launcher.cpp launcher.h
message.cpp message.h newgui.cpp newgui.h options.cpp
options.h widget.cpp widget.h
Log Message:
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)
Index: EditTextWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/EditTextWidget.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- EditTextWidget.cpp 1 Oct 2003 15:00:23 -0000 1.15
+++ EditTextWidget.cpp 2 Nov 2003 02:18:13 -0000 1.16
@@ -33,14 +33,13 @@
_pos = _label.size();
- NewGui *gui = _boss->getGui();
- _labelOffset = (gui->getStringWidth(_label) - (_w - 6));
+ _labelOffset = (g_gui.getStringWidth(_label) - (_w - 6));
if (_labelOffset < 0)
_labelOffset = 0;
}
void EditTextWidget::handleTickle() {
- uint32 time = _boss->getGui()->get_time();
+ uint32 time = g_system->get_msecs();
if (_caretTime < time) {
_caretTime = time + kCaretBlinkTime;
if (_caretVisible) {
@@ -56,7 +55,7 @@
if (_caretVisible)
drawCaret(true);
- NewGui *gui = _boss->getGui();
+ NewGui *gui = &g_gui;
x += _labelOffset;
@@ -90,7 +89,7 @@
case 27: // escape
_label = _backupString;
_pos = _label.size() - 1;
- _labelOffset = (_boss->getGui()->getStringWidth(_label) - (_w-6));
+ _labelOffset = (g_gui.getStringWidth(_label) - (_w-6));
if (_labelOffset < 0)
_labelOffset = 0;
_boss->releaseFocus();
@@ -144,24 +143,21 @@
}
void EditTextWidget::drawWidget(bool hilite) {
- NewGui *gui = _boss->getGui();
-
// Draw a thin frame around us.
- gui->hLine(_x, _y, _x + _w - 1, gui->_color);
- gui->hLine(_x, _y + _h - 1, _x +_w - 1, gui->_shadowcolor);
- gui->vLine(_x, _y, _y + _h - 1, gui->_color);
- gui->vLine(_x + _w - 1, _y, _y + _h - 1, gui->_shadowcolor);
+ g_gui.hLine(_x, _y, _x + _w - 1, g_gui._color);
+ g_gui.hLine(_x, _y + _h - 1, _x +_w - 1, g_gui._shadowcolor);
+ g_gui.vLine(_x, _y, _y + _h - 1, g_gui._color);
+ g_gui.vLine(_x + _w - 1, _y, _y + _h - 1, g_gui._shadowcolor);
// Draw the text
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() {
- NewGui *gui = _boss->getGui();
int caretpos = 0;
for (int i = 0; i < _pos; i++)
- caretpos += gui->getCharWidth(_label[i]);
+ caretpos += g_gui.getCharWidth(_label[i]);
caretpos -= _labelOffset;
@@ -173,17 +169,15 @@
if (!isVisible() || !_boss->isVisible())
return;
- NewGui *gui = _boss->getGui();
-
- int16 color = erase ? gui->_bgcolor : gui->_textcolorhi;
+ int16 color = erase ? g_gui._bgcolor : g_gui._textcolorhi;
int x = _x + _boss->getX() + 2;
int y = _y + _boss->getY() + 1;
int width = getCaretPos();
x += width;
- gui->vLine(x, y, y + kLineHeight, color);
- gui->addDirtyRect(x, y, 2, kLineHeight);
+ g_gui.vLine(x, y, y + kLineHeight, color);
+ g_gui.addDirtyRect(x, y, 2, kLineHeight);
_caretVisible = !erase;
}
@@ -209,7 +203,7 @@
}
else if (_labelOffset > 0)
{
- int width = _boss->getGui()->getStringWidth(_label);
+ int width = g_gui.getStringWidth(_label);
if (width - _labelOffset < (_w - 6)) {
// scroll right
_labelOffset = (width - (_w - 6));
Index: EditTextWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/EditTextWidget.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- EditTextWidget.h 2 Oct 2003 17:43:01 -0000 1.8
+++ EditTextWidget.h 2 Nov 2003 02:18:13 -0000 1.9
@@ -31,10 +31,10 @@
typedef Common::String String;
protected:
String _backupString;
- bool _caretVisible;
+ bool _caretVisible;
uint32 _caretTime;
- int _pos;
- int _labelOffset;
+ int _pos;
+ int _labelOffset;
public:
EditTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text);
Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- ListWidget.cpp 2 Oct 2003 17:43:01 -0000 1.25
+++ ListWidget.cpp 2 Nov 2003 02:18:13 -0000 1.26
@@ -84,7 +84,7 @@
}
void ListWidget::handleTickle() {
- uint32 time = _boss->getGui()->get_time();
+ uint32 time = g_system->get_msecs();
if (_editMode && _caretTime < time) {
_caretTime = time + kCaretBlinkTime;
if (_caretVisible) {
@@ -253,7 +253,7 @@
}
void ListWidget::drawWidget(bool hilite) {
- NewGui *gui = _boss->getGui();
+ NewGui *gui = &g_gui;
int i, pos, len = _list.size();
Common::String buffer;
@@ -290,7 +290,7 @@
if (!isVisible() || !_boss->isVisible())
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
int16 color = erase ? gui->_textcolorhi : gui->_bgcolor;
Index: PopUpWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/PopUpWidget.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- PopUpWidget.cpp 2 Oct 2003 17:43:01 -0000 1.18
+++ PopUpWidget.cpp 2 Nov 2003 02:18:13 -0000 1.19
@@ -75,7 +75,7 @@
};
PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY)
- : Dialog(boss->_boss->getGui(), 0, 0, 16, 16),
+ : Dialog(0, 0, 16, 16),
_popUpBoss(boss) {
// Copy the selection index
_selection = _popUpBoss->_selectedItem;
@@ -104,15 +104,15 @@
_clickY = clickY - _y;
// Time the popup was opened
- _openTime = _gui->get_time();
+ _openTime = g_system->get_msecs();
}
void PopUpDialog::drawDialog() {
// Draw the menu border
- _gui->hLine(_x, _y, _x+_w - 1, _gui->_color);
- _gui->hLine(_x, _y + _h - 1, _x + _w - 1, _gui->_shadowcolor);
- _gui->vLine(_x, _y, _y+_h - 1, _gui->_color);
- _gui->vLine(_x + _w - 1, _y, _y + _h - 1, _gui->_shadowcolor);
+ g_gui.hLine(_x, _y, _x+_w - 1, g_gui._color);
+ g_gui.hLine(_x, _y + _h - 1, _x + _w - 1, g_gui._shadowcolor);
+ g_gui.vLine(_x, _y, _y+_h - 1, g_gui._color);
+ g_gui.vLine(_x + _w - 1, _y, _y + _h - 1, g_gui._shadowcolor);
// Draw the entries
int count = _popUpBoss->_entries.size();
@@ -120,14 +120,14 @@
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) {
// 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.
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);
close();
}
@@ -253,15 +253,15 @@
int w = _w - 2;
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) {
// Draw a seperator
- _gui->hLine(x, y + kLineHeight / 2, x + w - 1, _gui->_color);
- _gui->hLine(x + 1, y + 1 + kLineHeight / 2, x + w - 1, _gui->_shadowcolor);
+ g_gui.hLine(x, y + kLineHeight / 2, x + w - 1, g_gui._color);
+ g_gui.hLine(x + 1, y + 1 + kLineHeight / 2, x + w - 1, g_gui._shadowcolor);
} 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::drawWidget(bool hilite) {
- NewGui *gui = _boss->getGui();
+ NewGui *gui = &g_gui;
// Draw a thin frame around us.
// TODO - should look different than the EditTextWidget fram
Index: ScrollBarWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ScrollBarWidget.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ScrollBarWidget.cpp 6 Mar 2003 21:45:36 -0000 1.9
+++ ScrollBarWidget.cpp 2 Nov 2003 02:18:13 -0000 1.10
@@ -212,7 +212,7 @@
}
void ScrollBarWidget::drawWidget(bool hilite) {
- NewGui *gui = _boss->getGui();
+ NewGui *gui = &g_gui;
int bottomY = _y + _h;
bool isSinglePage = (_numEntries <= _entriesPerPage);
Index: about.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/about.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- about.cpp 2 Oct 2003 17:43:02 -0000 1.5
+++ about.cpp 2 Nov 2003 02:18:13 -0000 1.6
@@ -24,8 +24,8 @@
#include "base/engine.h"
#include "common/str.h"
-AboutDialog::AboutDialog(NewGui *gui)
- : Dialog(gui, 10, 20, 300, 124) {
+AboutDialog::AboutDialog()
+ : Dialog(10, 20, 300, 124) {
addButton((_w - kButtonWidth)/2, 100, "OK", kCloseCmd, '\r'); // Close dialog - FIXME
Common::String version("ScummVM ");
Index: about.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/about.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- about.h 22 Jul 2003 16:05:51 -0000 1.1
+++ about.h 2 Nov 2003 02:18:13 -0000 1.2
@@ -25,7 +25,7 @@
class AboutDialog : public Dialog {
public:
- AboutDialog(NewGui *gui);
+ AboutDialog();
};
#endif
Index: browser.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/browser.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- browser.cpp 2 Oct 2003 17:43:02 -0000 1.13
+++ browser.cpp 2 Nov 2003 02:18:14 -0000 1.14
@@ -19,9 +19,9 @@
*/
#include "stdafx.h"
-#include "browser.h"
-#include "newgui.h"
-#include "ListWidget.h"
+#include "gui/browser.h"
+#include "gui/newgui.h"
+#include "gui/ListWidget.h"
#include "backends/fs/fs.h"
@@ -36,8 +36,8 @@
kGoUpCmd = 'GoUp'
};
-BrowserDialog::BrowserDialog(NewGui *gui, const char *title)
- : Dialog(gui, 20, 10, 320 -2 * 20, 200 - 2 * 10),
+BrowserDialog::BrowserDialog(const char *title)
+ : Dialog(20, 10, 320 -2 * 20, 200 - 2 * 10),
_node(0), _nodeContent(0) {
_fileList = NULL;
Index: browser.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/browser.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- browser.h 2 Oct 2003 17:43:02 -0000 1.8
+++ browser.h 2 Nov 2003 02:18:14 -0000 1.9
@@ -35,7 +35,7 @@
typedef Common::String String;
typedef Common::StringList StringList;
public:
- BrowserDialog(NewGui *gui, const char *title);
+ BrowserDialog(const char *title);
virtual ~BrowserDialog();
virtual void open();
Index: chooser.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/chooser.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- chooser.cpp 10 Aug 2003 20:57:41 -0000 1.5
+++ chooser.cpp 2 Nov 2003 02:18:14 -0000 1.6
@@ -27,8 +27,8 @@
kChooseCmd = 'Chos'
};
-ChooserDialog::ChooserDialog(NewGui *gui, const String title, const StringList& list)
- : Dialog(gui, 8, 24, 320 -2 * 8, 141) {
+ChooserDialog::ChooserDialog(const String title, const StringList& list)
+ : Dialog(8, 24, 320 -2 * 8, 141) {
// Headline
new StaticTextWidget(this, 10, 8, _w - 2 * 10, kLineHeight, title, kTextAlignCenter);
Index: chooser.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/chooser.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- chooser.h 2 Oct 2003 17:43:02 -0000 1.4
+++ chooser.h 2 Nov 2003 02:18:14 -0000 1.5
@@ -36,7 +36,7 @@
typedef Common::String String;
typedef Common::StringList StringList;
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);
Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/console.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- console.cpp 1 Oct 2003 15:00:25 -0000 1.34
+++ console.cpp 2 Nov 2003 02:18:14 -0000 1.35
@@ -34,8 +34,8 @@
* to erase a single character, do scrolling etc.
* - a *lot* of others things, this code is in no way complete and heavily under progress
*/
-ConsoleDialog::ConsoleDialog(NewGui *gui, float widthPercent, float heightPercent)
- : Dialog(gui, 0, 0, 1, 1),
+ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent)
+ : Dialog(0, 0, 1, 1),
_widthPercent(widthPercent), _heightPercent(heightPercent) {
// Setup basic layout/dialog size
@@ -95,10 +95,10 @@
void ConsoleDialog::drawDialog() {
// 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
- _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
int start = _scrollLine - _linesPerPage + 1;
@@ -108,7 +108,7 @@
for (int column = 0; column < _lineWidth; column++) {
int l = (start + line) % _linesInBuffer;
byte c = _buffer[l * _lineWidth + column];
- _gui->drawChar(c, x, y, _gui->_textcolor);
+ g_gui.drawChar(c, x, y, g_gui._textcolor);
x += kCharWidth;
}
y += kLineHeight;
@@ -118,11 +118,11 @@
_scrollBar->draw();
// Finally blit it all to the screen
- _gui->addDirtyRect(_x, _y, _w, _h);
+ g_gui.addDirtyRect(_x, _y, _w, _h);
}
void ConsoleDialog::handleTickle() {
- uint32 time = _gui->get_time();
+ uint32 time = g_system->get_msecs();
if (_caretTime < time) {
_caretTime = time + kCaretBlinkTime;
if (_caretVisible) {
@@ -506,13 +506,13 @@
char c = _buffer[getBufferPos()];
if (erase) {
- _gui->fillRect(x, y, kCharWidth, kLineHeight, _gui->_bgcolor);
- _gui->drawChar(c, x, y + 2, _gui->_textcolor);
+ g_gui.fillRect(x, y, kCharWidth, kLineHeight, g_gui._bgcolor);
+ g_gui.drawChar(c, x, y + 2, g_gui._textcolor);
} else {
- _gui->fillRect(x, y, kCharWidth, kLineHeight, _gui->_textcolor);
- _gui->drawChar(c, x, y + 2, _gui->_bgcolor);
+ g_gui.fillRect(x, y, kCharWidth, kLineHeight, g_gui._textcolor);
+ 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;
}
Index: console.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/console.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- console.h 26 Oct 2003 19:16:59 -0000 1.18
+++ console.h 2 Nov 2003 02:18:14 -0000 1.19
@@ -21,8 +21,8 @@
#ifndef CONSOLE_DIALOG_H
#define CONSOLE_DIALOG_H
-#include "dialog.h"
-#include "newgui.h"
+#include "gui/dialog.h"
+#include "gui/newgui.h"
#include <stdarg.h>
@@ -79,7 +79,7 @@
void reflowLayout();
public:
- ConsoleDialog(NewGui *gui, float widthPercent, float heightPercent);
+ ConsoleDialog(float widthPercent, float heightPercent);
void open();
void drawDialog();
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- dialog.cpp 2 Oct 2003 17:43:02 -0000 1.31
+++ dialog.cpp 2 Nov 2003 02:18:14 -0000 1.32
@@ -54,7 +54,7 @@
open();
// Start processing events
- _gui->runLoop();
+ g_gui.runLoop();
// Return the result code
return _result;
@@ -65,7 +65,7 @@
_result = 0;
_visible = true;
- _gui->openDialog(this);
+ g_gui.openDialog(this);
// Search for the first objects that wantsFocus() (if any) and give it the focus
while (w && !w->wantsFocus()) {
@@ -80,7 +80,7 @@
void Dialog::close() {
_visible = false;
- _gui->closeTopDialog();
+ g_gui.closeTopDialog();
if (_mouseWidget) {
_mouseWidget->handleMouseLeft(0);
@@ -97,7 +97,7 @@
}
void Dialog::draw() {
- _gui->_needRedraw = true;
+ g_gui._needRedraw = true;
}
void Dialog::drawDialog() {
@@ -106,15 +106,15 @@
if (!isVisible())
return;
- _gui->blendRect(_x, _y, _w, _h, _gui->_bgcolor);
- _gui->box(_x, _y, _w, _h);
+ g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor);
+ g_gui.box(_x, _y, _w, _h);
while (w) {
w->draw();
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) {
@@ -276,6 +276,8 @@
break;
w = w->_next;
}
+ if (w)
+ w = w->findWidget(x - w->_x, y - w->_y);
return w;
}
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- dialog.h 2 Oct 2003 17:43:02 -0000 1.21
+++ dialog.h 2 Nov 2003 02:18:14 -0000 1.22
@@ -37,7 +37,6 @@
friend class Widget;
friend class NewGui;
protected:
- NewGui *_gui;
int16 _x, _y;
uint16 _w, _h;
Widget *_firstWidget;
@@ -49,15 +48,14 @@
int _result;
public:
- Dialog(NewGui *gui, int x, int y, int w, int h)
- : _gui(gui), _x(x), _y(y), _w(w), _h(h), _firstWidget(0),
+ Dialog(int x, int y, int w, int h)
+ : _x(x), _y(y), _w(w), _h(h), _firstWidget(0),
_mouseWidget(0), _focusedWidget(0), _visible(false) {
}
virtual ~Dialog();
virtual int runModal();
- NewGui *getGui() { return _gui; }
bool isVisible() const { return _visible; }
int16 getX() const { return _x; }
int16 getY() const { return _y; }
Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- launcher.cpp 1 Nov 2003 23:45:39 -0000 1.61
+++ launcher.cpp 2 Nov 2003 02:18:14 -0000 1.62
@@ -78,7 +78,7 @@
typedef Common::String String;
typedef Common::StringList StringList;
public:
- EditGameDialog(NewGui *gui, const String &domain, GameSettings target);
+ EditGameDialog(const String &domain, GameSettings target);
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
@@ -89,8 +89,8 @@
CheckboxWidget *_fullscreenCheckbox;
};
-EditGameDialog::EditGameDialog(NewGui *gui, const String &domain, GameSettings target)
- : Dialog(gui, 8, 50, 320 - 2 * 8, 200 - 2 * 40),
+EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
+ : Dialog(8, 50, 320 - 2 * 8, 200 - 2 * 40),
_domain(domain) {
// Determine the description string
@@ -130,7 +130,7 @@
String newDomain(_domainWidget->getLabel());
if (newDomain != _domain) {
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();
return;
}
@@ -156,8 +156,8 @@
* - ...
*/
-LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector)
- : Dialog(gui, 0, 0, 320, 200), _detector(detector) {
+LauncherDialog::LauncherDialog(GameDetector &detector)
+ : Dialog(0, 0, 320, 200), _detector(detector) {
// Show game name
new StaticTextWidget(this, 10, 8, 300, kLineHeight, gScummVMFullVersion, kTextAlignCenter);
@@ -194,7 +194,7 @@
updateButtons();
// Create file browser dialog
- _browser = new BrowserDialog(_gui, "Select directory with game data");
+ _browser = new BrowserDialog("Select directory with game data");
}
LauncherDialog::~LauncherDialog() {
@@ -286,7 +286,7 @@
int idx;
if (candidates.isEmpty()) {
// 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();
idx = -1;
} else if (candidates.size() == 1) {
@@ -298,7 +298,7 @@
for (idx = 0; idx < candidates.size(); idx++)
list.push_back(candidates[idx].description);
- ChooserDialog dialog(_gui, "Pick the game:", list);
+ ChooserDialog dialog("Pick the game:", list);
idx = dialog.runModal();
}
if (0 <= idx && idx < candidates.size()) {
@@ -323,7 +323,7 @@
ConfMan.set("path", dir->path(), domain);
// Display edit dialog for the new entry
- EditGameDialog editDialog(_gui, domain, result);
+ EditGameDialog editDialog(domain, result);
if (editDialog.runModal()) {
// User pressed OK, so make changes permanent
@@ -363,7 +363,7 @@
String gameId(ConfMan.get("gameid", _domains[item]));
if (gameId.isEmpty())
gameId = _domains[item];
- EditGameDialog editDialog(_gui, _domains[item], GameDetector::findGame(gameId));
+ EditGameDialog editDialog(_domains[item], GameDetector::findGame(gameId));
if (editDialog.runModal()) {
// User pressed OK, so make changes permanent
@@ -382,12 +382,12 @@
// - music & graphics driver (but see also the comments on EditGameDialog
// for some techincal difficulties with this)
// - default volumes (sfx/master/music)
- GlobalOptionsDialog options(_gui, _detector);
+ GlobalOptionsDialog options(_detector);
options.runModal();
}
break;
case kAboutCmd: {
- AboutDialog about(_gui);
+ AboutDialog about;
about.runModal();
}
break;
Index: launcher.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- launcher.h 17 Oct 2003 12:18:58 -0000 1.12
+++ launcher.h 2 Nov 2003 02:18:14 -0000 1.13
@@ -33,7 +33,7 @@
typedef Common::String String;
typedef Common::StringList StringList;
public:
- LauncherDialog(NewGui *gui, GameDetector &detector);
+ LauncherDialog(GameDetector &detector);
~LauncherDialog();
virtual void open();
Index: message.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/message.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- message.cpp 1 Nov 2003 22:20:14 -0000 1.13
+++ message.cpp 2 Nov 2003 02:18:14 -0000 1.14
@@ -29,8 +29,8 @@
kCancelCmd = 'CNCL'
};
-MessageDialog::MessageDialog(NewGui *gui, const String &message, const char *defaultButton, const char *altButton)
- : Dialog(gui, 30, 20, 260, 124) {
+MessageDialog::MessageDialog(const String &message, const char *defaultButton, const char *altButton)
+ : Dialog(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.
// Using this, and accounting for the space the button(s) need, we can set
@@ -95,9 +95,10 @@
int width = 0, maxWidth = 0;
const char *start = line, *pos = line, *end = start + size;
String tmp;
+ NewGui *gui = &g_gui;
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.
// If possible we split at whitespaces.
@@ -114,7 +115,7 @@
lines.push_back(tmp);
// Determine the width of the string, and adjust maxWidth accordingly
- width = _gui->getStringWidth(tmp);
+ width = gui->getStringWidth(tmp);
if (maxWidth < width)
maxWidth = width;
@@ -148,13 +149,13 @@
}
}
-TimedMessageDialog::TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 duration)
- : MessageDialog(gui, message, 0, 0) {
- _timer = _gui->get_time() + duration;
+TimedMessageDialog::TimedMessageDialog(const Common::String &message, uint32 duration)
+ : MessageDialog(message, 0, 0) {
+ _timer = g_system->get_msecs() + duration;
}
void TimedMessageDialog::handleTickle() {
MessageDialog::handleTickle();
- if (_gui->get_time() > _timer)
+ if (g_system->get_msecs() > _timer)
close();
}
Index: message.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/message.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- message.h 1 Nov 2003 22:20:14 -0000 1.9
+++ message.h 2 Nov 2003 02:18:14 -0000 1.10
@@ -35,7 +35,7 @@
typedef Common::String String;
typedef Common::StringList StringList;
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);
@@ -48,7 +48,7 @@
*/
class TimedMessageDialog : public MessageDialog {
public:
- TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 duration);
+ TimedMessageDialog(const Common::String &message, uint32 duration);
void handleTickle();
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- newgui.cpp 1 Oct 2003 15:00:26 -0000 1.62
+++ newgui.cpp 2 Nov 2003 02:18:14 -0000 1.63
@@ -82,8 +82,11 @@
#endif
// Constructor
-NewGui::NewGui(OSystem *system) : _system(system), _screen(0), _needRedraw(false),
+NewGui::NewGui() : _screen(0), _needRedraw(false),
_stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) {
+
+ _system = OSystem::instance();
+
// Clear the cursor
memset(_cursor, 0xFF, sizeof(_cursor));
@@ -144,7 +147,7 @@
_system->update_screen();
OSystem::Event event;
- uint32 time = get_time();
+ uint32 time = _system->get_msecs();
while (_system->poll_event(&event)) {
switch (event.event_code) {
@@ -504,7 +507,7 @@
// We could plug in a different cursor here if we like to.
//
void NewGui::animateCursor() {
- int time = get_time();
+ int time = _system->get_msecs();
if (time > _cursorAnimateTimer + kCursorAnimateDelay) {
const byte colors[4] = { 15, 15, 7, 8 };
const byte color = colors[_cursorAnimateCounter];
Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- newgui.h 2 Oct 2003 17:43:02 -0000 1.29
+++ newgui.h 2 Nov 2003 02:18:14 -0000 1.30
@@ -22,14 +22,18 @@
#define NEWGUI_H
#include "common/scummsys.h"
-#include "common/system.h" // For events
+#include "common/singleton.h"
#include "common/str.h"
+#include "common/system.h" // For events
class Dialog;
#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 g_gui (NewGui::instance())
+
+
// Height of a single text line
enum {
kLineHeight = 11
@@ -60,9 +64,11 @@
};
// This class hopefully will replace the old Gui class completly one day
-class NewGui {
- friend class Dialog;
+class NewGui : public Common::Singleton<NewGui> {
typedef Common::String String;
+ friend class Dialog;
+ friend class Common::Singleton<NewGui>;
+ NewGui();
public:
// Main entry for the GUI: this will start an event loop that keeps running
@@ -71,8 +77,6 @@
bool isActive() { return ! _dialogStack.empty(); }
- NewGui(OSystem *system);
-
protected:
OSystem *_system;
NewGuiColor *_screen;
@@ -121,9 +125,6 @@
NewGuiColor _bgcolor;
NewGuiColor _textcolor;
NewGuiColor _textcolorhi;
-
- // Misc util
- uint32 get_time() const { return _system->get_msecs(); }
// Drawing primitives
NewGuiColor *getBasePtr(int x, int y);
Index: options.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- options.cpp 1 Nov 2003 22:21:18 -0000 1.27
+++ options.cpp 2 Nov 2003 02:18:14 -0000 1.28
@@ -61,8 +61,8 @@
kOKCmd = 'ok '
};
-GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui, GameDetector &detector)
- : Dialog(gui, 10, 15, 320 - 2 * 10, 200 - 2 * 15) {
+GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector)
+ : Dialog(10, 15, 320 - 2 * 10, 200 - 2 * 15) {
// The GFX mode popup & a label
// 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);
@@ -156,7 +156,7 @@
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
// Create file browser dialog
- _browser = new BrowserDialog(_gui, "Select directory for savegames");
+ _browser = new BrowserDialog("Select directory for savegames");
}
GlobalOptionsDialog::~GlobalOptionsDialog() {
Index: options.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- options.h 8 Oct 2003 21:59:22 -0000 1.6
+++ options.h 2 Nov 2003 02:18:14 -0000 1.7
@@ -32,7 +32,7 @@
class GlobalOptionsDialog : public Dialog {
typedef Common::String String;
public:
- GlobalOptionsDialog(NewGui *gui, GameDetector &detector);
+ GlobalOptionsDialog(GameDetector &detector);
~GlobalOptionsDialog();
void open();
Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- widget.cpp 1 Nov 2003 22:21:18 -0000 1.18
+++ widget.cpp 2 Nov 2003 02:18:14 -0000 1.19
@@ -23,7 +23,7 @@
#include "dialog.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),
_id(0), _flags(0), _hasFocus(false) {
// Insert into the widget list of the boss
@@ -32,7 +32,7 @@
}
void Widget::draw() {
- NewGui *gui = _boss->getGui();
+ NewGui *gui = &g_gui;
if (!isVisible() || !_boss->isVisible())
return;
@@ -75,7 +75,7 @@
#pragma mark -
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;
setLabel(text);
}
@@ -87,7 +87,7 @@
}
void StaticTextWidget::drawWidget(bool hilite) {
- NewGui *gui = _boss->getGui();
+ NewGui *gui = &g_gui;
gui->drawString(_label, _x, _y, _w, gui->_textcolor, _align);
}
@@ -106,7 +106,7 @@
}
void ButtonWidget::drawWidget(bool hilite) {
- NewGui *gui = _boss->getGui();
+ NewGui *gui = &g_gui;
gui->drawString(_label, _x, _y, _w,
!isEnabled() ? gui->_color :
hilite ? gui->_textcolorhi : gui->_textcolor, _align);
@@ -156,7 +156,7 @@
}
void CheckboxWidget::drawWidget(bool hilite) {
- NewGui *gui = _boss->getGui();
+ NewGui *gui = &g_gui;
// Draw the box
gui->box(_x, _y, 14, 14);
@@ -213,7 +213,7 @@
}
void SliderWidget::drawWidget(bool hilite) {
- NewGui *gui = _boss->getGui();
+ NewGui *gui = &g_gui;
// Draw the box
gui->box(_x, _y, _w, _h);
Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- widget.h 1 Nov 2003 22:21:18 -0000 1.21
+++ widget.h 2 Nov 2003 02:18:14 -0000 1.22
@@ -87,7 +87,7 @@
/* Widget */
class Widget {
-friend class Dialog;
+ friend class Dialog;
protected:
uint32 _type;
Dialog *_boss;
@@ -129,6 +129,8 @@
virtual void receivedFocusWidget() {}
virtual void lostFocusWidget() {}
+
+ virtual Widget *findWidget(int x, int y) { return this; }
};
/* StaticTextWidget */
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common debugger.cpp,1.1,1.2 debugger.h,1.1,1.2 module.mk,1.11,1.12 singleton.h,1.1,1.2 system.h,1.45,1.46
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm debugger.cpp,1.96,1.97 dialogs.cpp,1.77,1.78 dialogs.h,1.26,1.27 resource.cpp,1.169,1.170 script_v6.cpp,1.203,1.204 scumm.h,1.318,1.319 scummvm.cpp,2.465,2.466 string.cpp,1.163,1.164
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list