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
This commit is contained in:
Max Horn 2002-07-08 00:10:11 +00:00
parent c3b606cd9b
commit c9b1d393b8
6 changed files with 41 additions and 30 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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();
}