PRIVATE: more stuff
This commit is contained in:
parent
92a892008d
commit
0c3a74fdd8
4 changed files with 174 additions and 62 deletions
|
@ -1,6 +1,4 @@
|
|||
#include "common/scummsys.h"
|
||||
|
||||
#include "private.h"
|
||||
#include "private/cursors.h"
|
||||
|
||||
namespace Private {
|
||||
|
||||
|
@ -23,7 +21,7 @@ const byte MOUSECURSOR_SCI[] = {
|
|||
0,0,0,0,0,0,1,2,2,1,0
|
||||
};
|
||||
|
||||
const byte MOUSECURSOR_kExit[] = {
|
||||
extern const byte MOUSECURSOR_kExit[] = {
|
||||
0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,1,2,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,1,1,2,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
@ -268,10 +266,34 @@ const byte MOUSECURSOR_kPhone[] {
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
const byte cursorPalette[] = {
|
||||
extern const byte cursorPalette[] = {
|
||||
0, 0, 0, // Black / Transparent
|
||||
0x01, 0x01, 0x01, // Gray
|
||||
0xff, 0xff, 0xff // White
|
||||
};
|
||||
|
||||
static struct CursorTable {
|
||||
const char *name;
|
||||
const byte *cursor;
|
||||
} cursorTable[] = {
|
||||
{ "kExit", MOUSECURSOR_kExit},
|
||||
{ "kInventory", MOUSECURSOR_kInventory},
|
||||
{ "kTurnLeft", MOUSECURSOR_kTurnLeft},
|
||||
{ "kTurnRight", MOUSECURSOR_kTurnRight},
|
||||
{ "kZoomIn", MOUSECURSOR_kZoomIn},
|
||||
{ "kZoomOut", MOUSECURSOR_kZoomOut},
|
||||
{ "kPhone", MOUSECURSOR_kPhone},
|
||||
{ "default", MOUSECURSOR_SCI},
|
||||
{ 0, 0}
|
||||
};
|
||||
|
||||
CursorMap _cursors;
|
||||
|
||||
void initCursors() {
|
||||
for (Private::CursorTable *cur = Private::cursorTable; cur->name; cur++) {
|
||||
Common::String *name = new Common::String(cur->name);
|
||||
_cursors.setVal(*name, cur->cursor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
28
engines/private/cursors.h
Normal file
28
engines/private/cursors.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
#include "common/hash-str.h"
|
||||
|
||||
#ifndef PRIVATE_CURSORS_H
|
||||
#define PRIVATE_CURSORS_H
|
||||
|
||||
typedef Common::HashMap<Common::String, const byte*> CursorMap;
|
||||
|
||||
namespace Private {
|
||||
|
||||
extern const byte MOUSECURSOR_SCI[];
|
||||
extern const byte MOUSECURSOR_kExit[];
|
||||
extern const byte MOUSECURSOR_kZoomIn[];
|
||||
extern const byte MOUSECURSOR_kZoomOut[];
|
||||
extern const byte MOUSECURSOR_kInventory[];
|
||||
extern const byte MOUSECURSOR_kTurnLeft[];
|
||||
extern const byte MOUSECURSOR_kTurnRight[];
|
||||
extern const byte MOUSECURSOR_kPhone[];
|
||||
|
||||
extern const byte cursorPalette[];
|
||||
extern void initCursors();
|
||||
|
||||
extern CursorMap _cursors;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -18,10 +18,12 @@
|
|||
#include "image/bmp.h"
|
||||
#include "graphics/cursorman.h"
|
||||
|
||||
#include "private/cursors.h"
|
||||
#include "private/private.h"
|
||||
#include "private/grammar.tab.h"
|
||||
#include "private/grammar.h"
|
||||
|
||||
|
||||
namespace Private {
|
||||
|
||||
PrivateEngine *g_private = NULL;
|
||||
|
@ -76,8 +78,12 @@ Common::Error PrivateEngine::run() {
|
|||
|
||||
void *buf = malloc(191000);
|
||||
file->read(buf, 191000);
|
||||
|
||||
// Initialize stuff
|
||||
initInsts();
|
||||
initFuncs();
|
||||
initCursors();
|
||||
|
||||
parse((char *) buf);
|
||||
assert(constants.size() > 0);
|
||||
|
||||
|
@ -89,7 +95,7 @@ Common::Error PrivateEngine::run() {
|
|||
_transparentColor = _pixelFormat.RGBToColor(0,255,0);
|
||||
initGraphics(_screenW, _screenH, &_pixelFormat);
|
||||
|
||||
CursorMan.replaceCursor(MOUSECURSOR_kExit, 32, 32, 0, 0, 0);
|
||||
CursorMan.replaceCursor(_cursors.getVal("default"), 11, 16, 0, 0, 0, true);
|
||||
CursorMan.replaceCursorPalette(cursorPalette, 0, 3);
|
||||
|
||||
_origin = new Common::Point(0, 0);
|
||||
|
@ -123,6 +129,7 @@ Common::Error PrivateEngine::run() {
|
|||
|
||||
while (!shouldQuit()) {
|
||||
while (g_system->getEventManager()->pollEvent(event)) {
|
||||
mousePos = g_system->getEventManager()->getMousePos();
|
||||
// Events
|
||||
switch (event.type) {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
|
@ -135,12 +142,18 @@ Common::Error PrivateEngine::run() {
|
|||
break;
|
||||
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
mousePos = g_system->getEventManager()->getMousePos();
|
||||
selectMask(mousePos);
|
||||
if (!_nextSetting)
|
||||
selectExit(mousePos);
|
||||
break;
|
||||
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
CursorMan.replaceCursor(_cursors.getVal("default"), 11, 16, 0, 0, 0, true);
|
||||
cursorExit(mousePos);
|
||||
cursorMask(mousePos);
|
||||
//
|
||||
break;
|
||||
|
||||
default:
|
||||
{}
|
||||
|
||||
|
@ -186,9 +199,64 @@ Common::Error PrivateEngine::run() {
|
|||
return Common::kNoError;
|
||||
}
|
||||
|
||||
void PrivateEngine::selectExit(Common::Point mousePos) {
|
||||
debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
bool PrivateEngine::cursorExit(Common::Point mousePos) {
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return false;
|
||||
|
||||
ExitInfo e;
|
||||
bool inside = false;
|
||||
for (ExitList::iterator it = _exits.begin(); it != _exits.end(); ++it) {
|
||||
e = *it;
|
||||
if (e.rect->contains(mousePos)) {
|
||||
inside = true;
|
||||
if (e.cursor != NULL)
|
||||
CursorMan.replaceCursor(_cursors.getVal(*e.cursor), 32, 32, 0, 0, 0, true);
|
||||
}
|
||||
}
|
||||
//if (!inside)
|
||||
// CursorMan.replaceCursor(_cursors.getVal("default"), 11, 16, 0, 0, 0, true);
|
||||
|
||||
return inside;
|
||||
}
|
||||
|
||||
bool PrivateEngine::cursorMask(Common::Point mousePos) {
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return false;
|
||||
|
||||
MaskInfo m;
|
||||
bool inside = false;
|
||||
for (MaskList::iterator it = _masks.begin(); it != _masks.end(); ++it) {
|
||||
m = *it;
|
||||
|
||||
//debug("Testing mask %s", m.nextSetting->c_str());
|
||||
if ( *((uint32*) m.surf->getBasePtr(mousePos.x, mousePos.y)) != _transparentColor) {
|
||||
//debug("Inside!");
|
||||
if (m.nextSetting != NULL) { // TODO: check this
|
||||
inside = true;
|
||||
debug("Rendering cursor mask %s", m.cursor->c_str());
|
||||
assert(_cursors.contains(*m.cursor));
|
||||
CursorMan.replaceCursor(_cursors.getVal(*m.cursor), 32, 32, 0, 0, 0, true);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//if (!inside)
|
||||
// CursorMan.replaceCursor(_cursors.getVal("default"), 11, 16, 0, 0, 0, true);
|
||||
return inside;
|
||||
}
|
||||
|
||||
|
||||
void PrivateEngine::selectExit(Common::Point mousePos) {
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return;
|
||||
|
||||
Common::String *ns = NULL;
|
||||
int rs = 100000000;
|
||||
int cs = 0;
|
||||
|
@ -196,7 +264,7 @@ void PrivateEngine::selectExit(Common::Point mousePos) {
|
|||
for (ExitList::iterator it = _exits.begin(); it != _exits.end(); ++it) {
|
||||
e = *it;
|
||||
cs = e.rect->width()*e.rect->height();
|
||||
debug("Testing exit %s %d", e.nextSetting->c_str(), cs);
|
||||
//debug("Testing exit %s %d", e.nextSetting->c_str(), cs);
|
||||
if (e.rect->contains(mousePos)) {
|
||||
debug("Inside! %d %d", cs, rs);
|
||||
if (cs < rs && e.nextSetting != NULL) { // TODO: check this
|
||||
|
@ -216,12 +284,15 @@ void PrivateEngine::selectExit(Common::Point mousePos) {
|
|||
void PrivateEngine::selectMask(Common::Point mousePos) {
|
||||
//debug("Mousepos %d %d", mousePos.x, mousePos.y);
|
||||
mousePos = mousePos - *_origin;
|
||||
if (mousePos.x < 0 || mousePos.y < 0)
|
||||
return;
|
||||
|
||||
Common::String *ns = NULL;
|
||||
MaskInfo m;
|
||||
for (MaskList::iterator it = _masks.begin(); it != _masks.end(); ++it) {
|
||||
m = *it;
|
||||
|
||||
debug("Testing mask %s", m.nextSetting->c_str());
|
||||
//debug("Testing mask %s", m.nextSetting->c_str());
|
||||
if ( *((uint32*) m.surf->getBasePtr(mousePos.x, mousePos.y)) != _transparentColor) {
|
||||
debug("Inside!");
|
||||
if (m.nextSetting != NULL) { // TODO: check this
|
||||
|
@ -364,25 +435,18 @@ Graphics::ManagedSurface *PrivateEngine::loadMask(const Common::String &name, in
|
|||
surf->transBlitFrom(*_image->getSurface()->convertTo(_pixelFormat, _image->getPalette()), Common::Point(x,y));
|
||||
|
||||
if (drawn) {
|
||||
_compositeSurface->transBlitFrom(surf->rawSurface(), Common::Point(x,y), _transparentColor);
|
||||
_compositeSurface->transBlitFrom(surf->rawSurface(), *_origin + Common::Point(x,y), _transparentColor);
|
||||
drawScreen();
|
||||
}
|
||||
|
||||
return surf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void PrivateEngine::drawScreen() {
|
||||
if (_videoDecoder ? _videoDecoder->needsUpdate() : false || _compositeSurface) {
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
//screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), 0);
|
||||
//
|
||||
//if (_mode == 1)
|
||||
// drawScreenFrame();
|
||||
|
||||
Graphics::ManagedSurface *surface = _compositeSurface;
|
||||
int w = surface->w;
|
||||
int h = surface->h;
|
||||
|
||||
if (_videoDecoder) {
|
||||
Graphics::Surface *frame = new Graphics::Surface;
|
||||
|
@ -392,12 +456,9 @@ void PrivateEngine::drawScreen() {
|
|||
surface->transBlitFrom(*frame->convertTo(_pixelFormat, _videoDecoder->getPalette()), o);
|
||||
}
|
||||
|
||||
int w = surface->w; //CLIP<int>(surface->w, 0, _screenW);
|
||||
int h = surface->h; //CLIP<int>(surface->h, 0, _screenH);
|
||||
assert(w == _screenW && h == _screenH);
|
||||
|
||||
screen->copyRectToSurface(*surface, 0, 0, Common::Rect(0, 0, _screenW, _screenH));
|
||||
|
||||
g_system->unlockScreen();
|
||||
//if (_image->getPalette() != nullptr)
|
||||
// g_system->getPaletteManager()->setPalette(_image->getPalette(), _image->getPaletteStartIndex(), _image->getPaletteColorCount());
|
||||
|
@ -405,7 +466,7 @@ void PrivateEngine::drawScreen() {
|
|||
// g_system->getPaletteManager()->setPalette(_image->getPalette(), 0, 256);
|
||||
//g_system->getPaletteManager()->setPalette(_videoDecoder->getPalette(), 0, 256);
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,10 +23,6 @@ struct ManagedSurface;
|
|||
|
||||
namespace Private {
|
||||
|
||||
extern const byte MOUSECURSOR_SCI[];
|
||||
extern const byte MOUSECURSOR_kExit[];
|
||||
extern const byte cursorPalette[];
|
||||
|
||||
class Console;
|
||||
|
||||
// our engine debug channels
|
||||
|
@ -77,6 +73,11 @@ public:
|
|||
Common::Error run() override;
|
||||
void selectMask(Common::Point);
|
||||
void selectExit(Common::Point);
|
||||
|
||||
bool cursorExit(Common::Point);
|
||||
bool cursorMask(Common::Point);
|
||||
|
||||
|
||||
bool hasFeature(EngineFeature f) const override;
|
||||
bool canLoadGameStateCurrently() override { return true; }
|
||||
bool canSaveGameStateCurrently() override { return true; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue