WAGE: Implement scene drawing

This commit is contained in:
Eugene Sandulenko 2015-12-26 11:55:55 +01:00
parent 6d3fe95689
commit ab34bafc31
5 changed files with 51 additions and 18 deletions

View File

@ -73,11 +73,11 @@ Design::~Design() {
free(_data);
}
void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask) {
Common::MemoryReadStream in(_data, _len);
if (mask || 1) {
canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
if (mask) {
surface->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
}
/*
@ -104,30 +104,30 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
while (true) {
byte fillType = in.readByte();
byte borderThickness = in.readByte();
byte borderFillType = in.readByte();
int type = in.readByte();
if (in.eos())
return;
byte borderThickness = in.readByte();
byte borderFillType = in.readByte();
int type = in.readByte();
debug(2, "fill: %d borderFill: %d border: %d type: %d", fillType, borderFillType, borderThickness, type);
switch (type) {
case 4:
drawRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
drawRect(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 8:
drawRoundRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
drawRoundRect(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 12:
drawOval(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
drawOval(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 16:
case 20:
drawPolygon(canvas, in, mask, patterns, fillType, borderThickness, borderFillType);
drawPolygon(surface, in, mask, patterns, fillType, borderThickness, borderFillType);
break;
case 24:
drawBitmap(canvas, in, mask);
drawBitmap(surface, in, mask);
break;
default:
warning("Unknown type => %d", type);
@ -139,9 +139,9 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
return;
}
g_system->copyRectToScreen(canvas->getPixels(), canvas->pitch, 0, 0, canvas->w, canvas->h);
((WageEngine *)g_engine)->processEvents();
g_system->updateScreen();
//g_system->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 0, surface->w, surface->h);
//((WageEngine *)g_engine)->processEvents();
//g_system->updateScreen();
}
}
@ -240,7 +240,9 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, b
void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
warning("ignored => %d", in.readSint16BE());
byte ignored = in.readSint16BE(); // ignored
assert(ignored == 0);
int numBytes = in.readSint16BE(); // #bytes used by polygon data, including the numBytes
int16 by1 = in.readSint16BE();
int16 bx1 = in.readSint16BE();

View File

@ -70,7 +70,7 @@ public:
}
Common::Rect *getBounds() {
return new Common::Rect(*_bounds);
return _bounds;
}
void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask);

View File

@ -48,6 +48,7 @@
#include "wage/wage.h"
#include "wage/entities.h"
#include "wage/design.h"
#include "wage/world.h"
#include "common/memstream.h"
@ -82,6 +83,22 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_visited = false;
}
void Scene::paint(Graphics::Surface *surface) {
surface->fillRect(Common::Rect(0, 0, _design->getBounds()->width(), _design->getBounds()->height()), kColorWhite);
_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false);
for (Common::List<Obj *>::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
debug(2, "paining Obj: %s", (*it)->_name.c_str());
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false);
}
for (Common::List<Chr *>::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
debug(2, "paining Chr: %s", (*it)->_name.c_str());
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, false);
}
}
Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
_name = name;
_classType = OBJ;

View File

@ -48,6 +48,10 @@
#ifndef WAGE_ENTITIES_H
#define WAGE_ENTITIES_H
namespace Graphics {
struct Surface;
}
namespace Wage {
class Design;
@ -397,6 +401,8 @@ public:
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
}
void paint(Graphics::Surface *screen);
#if 0
String getFontName() {
String[] fonts = {

View File

@ -112,7 +112,6 @@ Common::Error WageEngine::run() {
Graphics::Surface screen;
screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
_temporarilyHidden = true;
performInitialSetup();
@ -121,7 +120,16 @@ Common::Error WageEngine::run() {
Common::String input("look");
_world->_player->_currentScene = _world->_orderedScenes[1];
_world->_globalScript->execute(_world, 1, &input, NULL, this);
//_world->_globalScript->execute(_world, 1, &input, NULL, this);
_world->_orderedScenes[4]->paint(&screen);
g_system->copyRectToScreen(screen.getPixels(), screen.pitch, 0, 0, screen.w, screen.h);
while (true) {
processEvents();
g_system->updateScreen();
g_system->delayMillis(50);
}
//_world->_orderedScenes[1]->_design->paint(&screen, _world->_patterns, false);
//_world->_objs["frank.1"]->_design->setBounds(&r);