Don't store the engine state in the SciGuiPalette class. The palette timestamps are now calculated from Epoch time, instead of game start time (the functionality is exactly the same, though)

svn-id: r44773
This commit is contained in:
Filippos Karapetis 2009-10-08 08:00:30 +00:00
parent 0120111416
commit 498d80a510
4 changed files with 20 additions and 29 deletions

View file

@ -41,6 +41,7 @@ SciGuiCursor::SciGuiCursor(ResourceManager *resMan, SciGuiPalette *palette)
_rawBitmap = NULL; _rawBitmap = NULL;
setPosition(Common::Point(160, 150)); // TODO: how is that different in 640x400 games? setPosition(Common::Point(160, 150)); // TODO: how is that different in 640x400 games?
setMoveZone(Common::Rect(0, 0, 320, 200)); // TODO: hires games
} }
SciGuiCursor::~SciGuiCursor() { SciGuiCursor::~SciGuiCursor() {

View file

@ -34,15 +34,8 @@
namespace Sci { namespace Sci {
SciGuiPalette::SciGuiPalette(EngineState *state, SciGuiScreen *screen) SciGuiPalette::SciGuiPalette(ResourceManager *resMan, SciGuiScreen *screen)
: _s(state), _screen(screen) { : _resMan(resMan), _screen(screen) {
init();
}
SciGuiPalette::~SciGuiPalette() {
}
void SciGuiPalette::init() {
int16 i; int16 i;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
_sysPalette.colors[i].used = 0; _sysPalette.colors[i].used = 0;
@ -72,6 +65,9 @@ void SciGuiPalette::init() {
_clrPowers[i] = i*i; _clrPowers[i] = i*i;
} }
SciGuiPalette::~SciGuiPalette() {
}
#define SCI_PAL_FORMAT_CONSTANT 1 #define SCI_PAL_FORMAT_CONSTANT 1
#define SCI_PAL_FORMAT_VARIABLE 0 #define SCI_PAL_FORMAT_VARIABLE 0
@ -177,7 +173,7 @@ void SciGuiPalette::setEGA() {
} }
bool SciGuiPalette::setFromResource(int16 resourceNo, int16 flag) { bool SciGuiPalette::setFromResource(int16 resourceNo, int16 flag) {
Resource *palResource = _s->resMan->findResource(ResourceId(kResourceTypePalette, resourceNo), 0); Resource *palResource = _resMan->findResource(ResourceId(kResourceTypePalette, resourceNo), 0);
GuiPalette palette; GuiPalette palette;
if (palResource) { if (palResource) {
@ -236,7 +232,7 @@ void SciGuiPalette::merge(GuiPalette *pFrom, GuiPalette *pTo, uint16 flag) {
pTo->colors[res & 0xFF].used |= 0x10; pTo->colors[res & 0xFF].used |= 0x10;
} }
} }
pTo->timestamp = (g_system->getMillis() - _s->game_start_time) * 60 / 1000;; pTo->timestamp = g_system->getMillis() * 60 / 1000;;
} }
uint16 SciGuiPalette::matchColor(GuiPalette *pPal, byte r, byte g, byte b) { uint16 SciGuiPalette::matchColor(GuiPalette *pPal, byte r, byte g, byte b) {
@ -282,7 +278,7 @@ void SciGuiPalette::setIntensity(int fromColor, int toColor, int intensity, GuiP
void SciGuiPalette::animate(byte fromColor, byte toColor, int speed) { void SciGuiPalette::animate(byte fromColor, byte toColor, int speed) {
GuiColor col; GuiColor col;
int len = toColor - fromColor - 1; int len = toColor - fromColor - 1;
uint32 now = (g_system->getMillis() - _s->game_start_time) * 60 / 1000;; uint32 now = g_system->getMillis() * 60 / 1000;;
// search for sheduled animations with the same 'from' value // search for sheduled animations with the same 'from' value
int sz = _palSchedules.size(); int sz = _palSchedules.size();
for (int i = 0; i < sz; i++) { for (int i = 0; i < sz; i++) {

View file

@ -33,7 +33,7 @@ namespace Sci {
class SciGuiScreen; class SciGuiScreen;
class SciGuiPalette { class SciGuiPalette {
public: public:
SciGuiPalette(EngineState *state, SciGuiScreen *screen); SciGuiPalette(ResourceManager *resMan, SciGuiScreen *screen);
~SciGuiPalette(); ~SciGuiPalette();
void createFromData(byte *data, GuiPalette *paletteOut); void createFromData(byte *data, GuiPalette *paletteOut);
@ -53,10 +53,8 @@ public:
GuiPalette _sysPalette; GuiPalette _sysPalette;
private: private:
void init();
EngineState *_s;
SciGuiScreen *_screen; SciGuiScreen *_screen;
ResourceManager *_resMan;
uint16 _clrPowers[256]; uint16 _clrPowers[256];

View file

@ -137,9 +137,16 @@ Common::Error SciEngine::run() {
_kernel = new Kernel(_resMan); _kernel = new Kernel(_resMan);
_vocabulary = new Vocabulary(_resMan); _vocabulary = new Vocabulary(_resMan);
SciGuiScreen *screen = new SciGuiScreen();
SciGuiPalette *palette = new SciGuiPalette(_resMan, screen);
SciGuiCursor *cursor = new SciGuiCursor(_resMan, palette);
// we'll set the gui and cursor below // We'll set the GUI below
_gamestate = new EngineState(_resMan, _kernel, _vocabulary, NULL, NULL, flags); _gamestate = new EngineState(_resMan, _kernel, _vocabulary, NULL, cursor, flags);
// Gui change
//_gamestate->_gui = new SciGui(_gamestate, screen, palette, cursor); // new
_gamestate->_gui = new SciGui32(_gamestate, screen, palette, cursor); // old
if (script_init_engine(_gamestate)) if (script_init_engine(_gamestate))
return Common::kUnknownError; return Common::kUnknownError;
@ -159,17 +166,6 @@ Common::Error SciEngine::run() {
GfxState gfx_state; GfxState gfx_state;
_gamestate->gfx_state = &gfx_state; _gamestate->gfx_state = &gfx_state;
SciGuiScreen *screen = new SciGuiScreen();
SciGuiPalette *palette = new SciGuiPalette(_gamestate, screen);
SciGuiCursor *cursor = new SciGuiCursor(_resMan, palette);
_gamestate->_cursor = cursor;
_gamestate->_cursor->setMoveZone(Common::Rect(0, 0, 320, 200));
// Gui change
//_gamestate->_gui = new SciGui(_gamestate, screen, palette, cursor); // new
_gamestate->_gui = new SciGui32(_gamestate, screen, palette, cursor); // old
// Assign default values to the config manager, in case settings are missing // Assign default values to the config manager, in case settings are missing
ConfMan.registerDefault("dither_mode", "0"); ConfMan.registerDefault("dither_mode", "0");