aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2002-07-08 00:10:11 +0000
committerMax Horn2002-07-08 00:10:11 +0000
commitc9b1d393b836dc4239a42c0efad7712fb786930f (patch)
tree613ba6e70de76d499adbe793652289ca2b64c6aa
parentc3b606cd9b0b0445b0360f9a95225186252ae1c1 (diff)
downloadscummvm-rg350-c9b1d393b836dc4239a42c0efad7712fb786930f.tar.gz
scummvm-rg350-c9b1d393b836dc4239a42c0efad7712fb786930f.tar.bz2
scummvm-rg350-c9b1d393b836dc4239a42c0efad7712fb786930f.zip
delay creation of dialogs till they are used; fixed new pause dialog & use it instead of the old one; dirty area handling in new gui code is more logical/useful now
svn-id: r4487
-rw-r--r--gui/dialog.cpp3
-rw-r--r--gui/widget.cpp12
-rw-r--r--init.cpp8
-rw-r--r--newgui.cpp38
-rw-r--r--newgui.h4
-rw-r--r--scummvm.cpp6
6 files changed, 41 insertions, 30 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index ab64eafe67..9d253db2cf 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -29,6 +29,7 @@ void Dialog::draw()
_gui->clearArea(_x, _y, _w, _h);
_gui->box(_x, _y, _w, _h);
+ _gui->setAreaDirty(_x, _y, _w, _h);
while (w) {
w->draw();
@@ -194,5 +195,5 @@ void OptionsDialog::handleCommand(uint32 cmd)
PauseDialog::PauseDialog(NewGui *gui)
: Dialog (gui, 50, 80, 220, 16)
{
- addResText(2, 2, 220, 16, 10);
+ addResText(4, 4, 220, 16, 10);
}
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 38033a2d06..ecc4c66608 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -34,6 +34,8 @@ Widget::Widget (Dialog *boss, int x, int y, int w, int h)
void Widget::draw()
{
+ NewGui *gui = _boss->_gui;
+
if (_flags & WIDGET_INVISIBLE)
return;
@@ -43,24 +45,26 @@ void Widget::draw()
// Clear background
if (_flags & WIDGET_CLEARBG)
- _boss->_gui->clearArea(_x, _y, _w, _h);
+ gui->clearArea(_x, _y, _w, _h);
// Draw border
if (_flags & WIDGET_BORDER) {
- _boss->_gui->box(_x, _y, _w, _h);
+ gui->box(_x, _y, _w, _h);
_x += 4;
_y += 4;
}
// Now perform the actual widget draw
drawWidget(_flags & WIDGET_HILITED);
+
+ // Flag the draw area as dirty
+ gui->setAreaDirty(_x, _y, _w, _h);
+ // Restore x/y
if (_flags & WIDGET_BORDER) {
_x -= 4;
_y -= 4;
}
-
- // Restore x/y
_x -= _boss->_x;
_y -= _boss->_y;
}
diff --git a/init.cpp b/init.cpp
index 3fd5843aff..79db4c4382 100644
--- a/init.cpp
+++ b/init.cpp
@@ -20,10 +20,10 @@
*
*/
-#include"stdafx.h"
-#include"scumm.h"
-#include"actor.h"
-#include"newgui.h"
+#include "stdafx.h"
+#include "scumm.h"
+#include "actor.h"
+#include "newgui.h"
Scumm::Scumm (void) {
_newgui = new NewGui(this);
diff --git a/newgui.cpp b/newgui.cpp
index ab79428254..d74c79f325 100644
--- a/newgui.cpp
+++ b/newgui.cpp
@@ -39,31 +39,36 @@
* - ...
*/
-NewGui::NewGui(Scumm *s) : _s(s), _need_redraw(false)
+NewGui::NewGui(Scumm *s) : _s(s), _need_redraw(false), _pauseDialog(0),
+ _saveLoadDialog(0), _aboutDialog(0), _optionsDialog(0)
{
- _pauseDialog = new PauseDialog(this);
- _saveLoadDialog = new SaveLoadDialog(this);
-// _aboutDialog = new AboutDialog(this);
- _optionsDialog = new OptionsDialog(this);
}
void NewGui::pauseDialog()
{
+ if (!_pauseDialog)
+ _pauseDialog = new PauseDialog(this);
openDialog(_pauseDialog);
}
void NewGui::saveloadDialog()
{
+ if (!_saveLoadDialog)
+ _saveLoadDialog = new SaveLoadDialog(this);
openDialog(_saveLoadDialog);
}
void NewGui::aboutDialog()
{
+// if (!_aboutDialog)
+// _aboutDialog = new AboutDialog(this);
// openDialog(_aboutDialog);
}
void NewGui::optionsDialog()
{
+ if (!_optionsDialog)
+ _optionsDialog = new OptionsDialog(this);
openDialog(_optionsDialog);
}
@@ -183,10 +188,9 @@ const char *NewGui::queryCustomString(int stringno)
#pragma mark -
-byte *NewGui::getBasePtr(int x, int y, VirtScreen *vs)
+byte *NewGui::getBasePtr(int x, int y)
{
- if (vs == NULL)
- vs = _s->findVirtScreen(y);
+ VirtScreen *vs = _s->findVirtScreen(y);
if (vs == NULL)
return NULL;
@@ -239,13 +243,10 @@ void NewGui::line(int x, int y, int x2, int y2, byte color)
void NewGui::clearArea(int x, int y, int w, int h)
{
- VirtScreen *vs = _s->findVirtScreen(y);
- byte *ptr = getBasePtr(x, y, vs);
+ byte *ptr = getBasePtr(x, y);
if (ptr == NULL)
return;
- _s->setVirtscreenDirty(vs, x, y, x + w, y + h);
-
while (h--) {
for (int i = 0; i < w; i++)
ptr[i] = _bgcolor;
@@ -253,6 +254,14 @@ void NewGui::clearArea(int x, int y, int w, int h)
}
}
+void NewGui::setAreaDirty(int x, int y, int w, int h)
+{
+ VirtScreen *vs = _s->findVirtScreen(y);
+
+ if (vs != NULL)
+ _s->setVirtscreenDirty(vs, x, y, x + w, y + h);
+}
+
void NewGui::drawChar(const char str, int xx, int yy)
{
unsigned int buffer = 0, mask = 0, x, y;
@@ -309,8 +318,7 @@ void NewGui::drawString(const char *str, int x, int y, int w, byte color)
*/
void NewGui::drawBitmap(uint32 bitmap[8], int x, int y, byte color)
{
- VirtScreen *vs = _s->findVirtScreen(y);
- byte *ptr = getBasePtr(x, y, vs);
+ byte *ptr = getBasePtr(x, y);
if (ptr == NULL)
return;
@@ -323,6 +331,4 @@ void NewGui::drawBitmap(uint32 bitmap[8], int x, int y, byte color)
}
ptr += 320;
}
-
- _s->setVirtscreenDirty(vs, x, y, x + 8, y + 8);
}
diff --git a/newgui.h b/newgui.h
index 34e4e54812..3bab0773e7 100644
--- a/newgui.h
+++ b/newgui.h
@@ -25,7 +25,6 @@
class Dialog;
class Scumm;
-class VirtScreen;
// Extremly simple stack class, doesn't even do any error checking (for now)
class DialogStack {
@@ -93,10 +92,11 @@ protected:
public:
// Drawing
- byte *getBasePtr(int x, int y, VirtScreen *vs = 0);
+ byte *getBasePtr(int x, int y);
void box(int x, int y, int width, int height);
void line(int x, int y, int x2, int y2, byte color);
void clearArea(int x, int y, int w, int h);
+ void setAreaDirty(int x, int y, int w, int h);
void drawChar(const char c, int x, int y);
void drawString(const char *str, int x, int y, int w, byte color);
void drawBitmap(uint32 bitmap[8], int x, int y, byte color);
diff --git a/scummvm.cpp b/scummvm.cpp
index 3a5f6f2490..938837c23b 100644
--- a/scummvm.cpp
+++ b/scummvm.cpp
@@ -846,12 +846,14 @@ void Scumm::palManipulate(int palettes, int brightness, int color, int time, int
void Scumm::pauseGame(bool user)
{
- _gui->pause();
+ //_gui->pause();
+ _newgui->pauseDialog();
}
void Scumm::setOptions()
{
_gui->options();
+ //_newgui->optionsDialog();
}
void Scumm::shutDown(int i)
@@ -954,8 +956,6 @@ void Scumm::processKbd()
_defaultTalkDelay = 5;
_vars[VAR_CHARINC] = _defaultTalkDelay / 20;
- } else if (_lastKeyHit == 320) { // F6, display new GUI
- _newgui->pauseDialog();
} else if (_lastKeyHit == 321) { // F7, display new GUI
_newgui->saveloadDialog();
}