Move functions from agi.cpp to more appropriate files.
svn-id: r42662
This commit is contained in:
parent
9bd355acf8
commit
483a4c0eeb
5 changed files with 153 additions and 151 deletions
|
@ -271,19 +271,6 @@ void AgiEngine::processEvents() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::checkQuickLoad() {
|
|
||||||
if (ConfMan.hasKey("save_slot")) {
|
|
||||||
char saveNameBuffer[256];
|
|
||||||
|
|
||||||
snprintf (saveNameBuffer, 256, "%s.%03d", _targetName.c_str(), ConfMan.getInt("save_slot"));
|
|
||||||
|
|
||||||
if (loadGame(saveNameBuffer, false) == errOK) { // Do not check game id
|
|
||||||
_game.exitAllLogics = 1;
|
|
||||||
_menu->enableAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AgiEngine::pollTimer(void) {
|
void AgiEngine::pollTimer(void) {
|
||||||
static uint32 m = 0;
|
static uint32 m = 0;
|
||||||
uint32 dm;
|
uint32 dm;
|
||||||
|
@ -301,40 +288,10 @@ void AgiEngine::pollTimer(void) {
|
||||||
m = g_tickTimer;
|
m = g_tickTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AgiEngine::isKeypress(void) {
|
|
||||||
processEvents();
|
|
||||||
return _keyQueueStart != _keyQueueEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AgiEngine::getKeypress(void) {
|
|
||||||
int k;
|
|
||||||
|
|
||||||
while (_keyQueueStart == _keyQueueEnd) // block
|
|
||||||
pollTimer();
|
|
||||||
|
|
||||||
keyDequeue(k);
|
|
||||||
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AgiEngine::clearKeyQueue(void) {
|
|
||||||
while (isKeypress()) {
|
|
||||||
getKeypress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AgiEngine::agiTimerFunctionLow(void *refCon) {
|
void AgiEngine::agiTimerFunctionLow(void *refCon) {
|
||||||
g_tickTimer++;
|
g_tickTimer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::clearImageStack(void) {
|
|
||||||
_imageStack.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AgiEngine::releaseImageStack(void) {
|
|
||||||
_imageStack.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AgiEngine::pause(uint32 msec) {
|
void AgiEngine::pause(uint32 msec) {
|
||||||
uint32 endTime = _system->getMillis() + msec;
|
uint32 endTime = _system->getMillis() + msec;
|
||||||
|
|
||||||
|
@ -348,38 +305,6 @@ void AgiEngine::pause(uint32 msec) {
|
||||||
_gfx->setCursor(_renderMode == Common::kRenderAmiga);
|
_gfx->setCursor(_renderMode == Common::kRenderAmiga);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
|
||||||
int16 p4, int16 p5, int16 p6, int16 p7) {
|
|
||||||
ImageStackElement pnew;
|
|
||||||
|
|
||||||
pnew.type = type;
|
|
||||||
pnew.pad = 0;
|
|
||||||
pnew.parm1 = p1;
|
|
||||||
pnew.parm2 = p2;
|
|
||||||
pnew.parm3 = p3;
|
|
||||||
pnew.parm4 = p4;
|
|
||||||
pnew.parm5 = p5;
|
|
||||||
pnew.parm6 = p6;
|
|
||||||
pnew.parm7 = p7;
|
|
||||||
|
|
||||||
_imageStack.push(pnew);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AgiEngine::replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
|
||||||
int16 p4, int16 p5, int16 p6, int16 p7) {
|
|
||||||
switch (type) {
|
|
||||||
case ADD_PIC:
|
|
||||||
debugC(8, kDebugLevelMain, "--- decoding picture %d ---", p1);
|
|
||||||
agiLoadResource(rPICTURE, p1);
|
|
||||||
_picture->decodePicture(p1, p2, p3 != 0);
|
|
||||||
break;
|
|
||||||
case ADD_VIEW:
|
|
||||||
agiLoadResource(rVIEW, p1);
|
|
||||||
_sprites->addToPic(p1, p2, p3, p4, p5, p6, p7);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AgiEngine::initPriTable() {
|
void AgiEngine::initPriTable() {
|
||||||
int i, p, y = 0;
|
int i, p, y = 0;
|
||||||
|
|
||||||
|
@ -525,21 +450,6 @@ int AgiEngine::agiDeinit() {
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AgiEngine::agiDetectGame() {
|
|
||||||
int ec = errOK;
|
|
||||||
|
|
||||||
assert(_gameDescription != NULL);
|
|
||||||
|
|
||||||
if (getVersion() <= 0x2999) {
|
|
||||||
_loader = new AgiLoader_v2(this);
|
|
||||||
} else {
|
|
||||||
_loader = new AgiLoader_v3(this);
|
|
||||||
}
|
|
||||||
ec = _loader->detectGame();
|
|
||||||
|
|
||||||
return ec;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AgiEngine::agiLoadResource(int r, int n) {
|
int AgiEngine::agiLoadResource(int r, int n) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -582,67 +492,6 @@ static const GameSettings agiSettings[] = {
|
||||||
{NULL, NULL, 0, 0, NULL}
|
{NULL, NULL, 0, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, bool positive) const {
|
|
||||||
if (_amigaStyle) {
|
|
||||||
if (positive) {
|
|
||||||
if (pressed) { // Positive pressed Amiga-style button
|
|
||||||
if (_olderAgi) {
|
|
||||||
return AgiTextColor(amigaBlack, amigaOrange);
|
|
||||||
} else {
|
|
||||||
return AgiTextColor(amigaBlack, amigaPurple);
|
|
||||||
}
|
|
||||||
} else { // Positive unpressed Amiga-style button
|
|
||||||
return AgiTextColor(amigaWhite, amigaGreen);
|
|
||||||
}
|
|
||||||
} else { // _amigaStyle && !positive
|
|
||||||
if (pressed) { // Negative pressed Amiga-style button
|
|
||||||
return AgiTextColor(amigaBlack, amigaCyan);
|
|
||||||
} else { // Negative unpressed Amiga-style button
|
|
||||||
return AgiTextColor(amigaWhite, amigaRed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // PC-style button
|
|
||||||
if (hasFocus || pressed) { // A pressed or in focus PC-style button
|
|
||||||
return AgiTextColor(pcWhite, pcBlack);
|
|
||||||
} else { // An unpressed PC-style button without focus
|
|
||||||
return AgiTextColor(pcBlack, pcWhite);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, int baseFgColor, int baseBgColor) const {
|
|
||||||
return getColor(hasFocus, pressed, AgiTextColor(baseFgColor, baseBgColor));
|
|
||||||
}
|
|
||||||
|
|
||||||
AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, const AgiTextColor &baseColor) const {
|
|
||||||
if (hasFocus || pressed)
|
|
||||||
return baseColor.swap();
|
|
||||||
else
|
|
||||||
return baseColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AgiButtonStyle::getTextOffset(bool hasFocus, bool pressed) const {
|
|
||||||
return (pressed && !_amigaStyle) ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AgiButtonStyle::getBorder(bool hasFocus, bool pressed) const {
|
|
||||||
return _amigaStyle && !_authenticAmiga && (hasFocus || pressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AgiButtonStyle::setAmigaStyle(bool amigaStyle, bool olderAgi, bool authenticAmiga) {
|
|
||||||
_amigaStyle = amigaStyle;
|
|
||||||
_olderAgi = olderAgi;
|
|
||||||
_authenticAmiga = authenticAmiga;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AgiButtonStyle::setPcStyle(bool pcStyle) {
|
|
||||||
setAmigaStyle(!pcStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
AgiButtonStyle::AgiButtonStyle(Common::RenderMode renderMode) {
|
|
||||||
setAmigaStyle(renderMode == Common::kRenderAmiga);
|
|
||||||
}
|
|
||||||
|
|
||||||
AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
|
AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
|
||||||
_noSaveLoadAllowed = false;
|
_noSaveLoadAllowed = false;
|
||||||
|
|
||||||
|
|
|
@ -1312,4 +1312,19 @@ bool AgiBase::canSaveGameStateCurrently() {
|
||||||
return (!(getGameType() == GType_PreAGI) && getflag(fMenusWork) && !_noSaveLoadAllowed && _game.inputEnabled);
|
return (!(getGameType() == GType_PreAGI) && getflag(fMenusWork) && !_noSaveLoadAllowed && _game.inputEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AgiEngine::agiDetectGame() {
|
||||||
|
int ec = errOK;
|
||||||
|
|
||||||
|
assert(_gameDescription != NULL);
|
||||||
|
|
||||||
|
if (getVersion() <= 0x2999) {
|
||||||
|
_loader = new AgiLoader_v2(this);
|
||||||
|
} else {
|
||||||
|
_loader = new AgiLoader_v3(this);
|
||||||
|
}
|
||||||
|
ec = _loader->detectGame();
|
||||||
|
|
||||||
|
return ec;
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Agi
|
} // End of namespace Agi
|
||||||
|
|
|
@ -421,4 +421,26 @@ int AgiEngine::waitAnyKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AgiEngine::isKeypress(void) {
|
||||||
|
processEvents();
|
||||||
|
return _keyQueueStart != _keyQueueEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AgiEngine::getKeypress(void) {
|
||||||
|
int k;
|
||||||
|
|
||||||
|
while (_keyQueueStart == _keyQueueEnd) // block
|
||||||
|
pollTimer();
|
||||||
|
|
||||||
|
keyDequeue(k);
|
||||||
|
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AgiEngine::clearKeyQueue(void) {
|
||||||
|
while (isKeypress()) {
|
||||||
|
getKeypress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Agi
|
} // End of namespace Agi
|
||||||
|
|
|
@ -493,4 +493,66 @@ void Menu::enableAll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, bool positive) const {
|
||||||
|
if (_amigaStyle) {
|
||||||
|
if (positive) {
|
||||||
|
if (pressed) { // Positive pressed Amiga-style button
|
||||||
|
if (_olderAgi) {
|
||||||
|
return AgiTextColor(amigaBlack, amigaOrange);
|
||||||
|
} else {
|
||||||
|
return AgiTextColor(amigaBlack, amigaPurple);
|
||||||
|
}
|
||||||
|
} else { // Positive unpressed Amiga-style button
|
||||||
|
return AgiTextColor(amigaWhite, amigaGreen);
|
||||||
|
}
|
||||||
|
} else { // _amigaStyle && !positive
|
||||||
|
if (pressed) { // Negative pressed Amiga-style button
|
||||||
|
return AgiTextColor(amigaBlack, amigaCyan);
|
||||||
|
} else { // Negative unpressed Amiga-style button
|
||||||
|
return AgiTextColor(amigaWhite, amigaRed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // PC-style button
|
||||||
|
if (hasFocus || pressed) { // A pressed or in focus PC-style button
|
||||||
|
return AgiTextColor(pcWhite, pcBlack);
|
||||||
|
} else { // An unpressed PC-style button without focus
|
||||||
|
return AgiTextColor(pcBlack, pcWhite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, int baseFgColor, int baseBgColor) const {
|
||||||
|
return getColor(hasFocus, pressed, AgiTextColor(baseFgColor, baseBgColor));
|
||||||
|
}
|
||||||
|
|
||||||
|
AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, const AgiTextColor &baseColor) const {
|
||||||
|
if (hasFocus || pressed)
|
||||||
|
return baseColor.swap();
|
||||||
|
else
|
||||||
|
return baseColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AgiButtonStyle::getTextOffset(bool hasFocus, bool pressed) const {
|
||||||
|
return (pressed && !_amigaStyle) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AgiButtonStyle::getBorder(bool hasFocus, bool pressed) const {
|
||||||
|
return _amigaStyle && !_authenticAmiga && (hasFocus || pressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AgiButtonStyle::setAmigaStyle(bool amigaStyle, bool olderAgi, bool authenticAmiga) {
|
||||||
|
_amigaStyle = amigaStyle;
|
||||||
|
_olderAgi = olderAgi;
|
||||||
|
_authenticAmiga = authenticAmiga;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AgiButtonStyle::setPcStyle(bool pcStyle) {
|
||||||
|
setAmigaStyle(!pcStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
AgiButtonStyle::AgiButtonStyle(Common::RenderMode renderMode) {
|
||||||
|
setAmigaStyle(renderMode == Common::kRenderAmiga);
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Agi
|
} // End of namespace Agi
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include "common/file.h"
|
#include "common/file.h"
|
||||||
#include "graphics/thumbnail.h"
|
#include "graphics/thumbnail.h"
|
||||||
|
#include "common/config-manager.h"
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
#include "agi/graphics.h"
|
#include "agi/graphics.h"
|
||||||
|
@ -925,4 +926,57 @@ int AgiEngine::loadGameSimple() {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AgiEngine::recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
||||||
|
int16 p4, int16 p5, int16 p6, int16 p7) {
|
||||||
|
ImageStackElement pnew;
|
||||||
|
|
||||||
|
pnew.type = type;
|
||||||
|
pnew.pad = 0;
|
||||||
|
pnew.parm1 = p1;
|
||||||
|
pnew.parm2 = p2;
|
||||||
|
pnew.parm3 = p3;
|
||||||
|
pnew.parm4 = p4;
|
||||||
|
pnew.parm5 = p5;
|
||||||
|
pnew.parm6 = p6;
|
||||||
|
pnew.parm7 = p7;
|
||||||
|
|
||||||
|
_imageStack.push(pnew);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AgiEngine::replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
||||||
|
int16 p4, int16 p5, int16 p6, int16 p7) {
|
||||||
|
switch (type) {
|
||||||
|
case ADD_PIC:
|
||||||
|
debugC(8, kDebugLevelMain, "--- decoding picture %d ---", p1);
|
||||||
|
agiLoadResource(rPICTURE, p1);
|
||||||
|
_picture->decodePicture(p1, p2, p3 != 0);
|
||||||
|
break;
|
||||||
|
case ADD_VIEW:
|
||||||
|
agiLoadResource(rVIEW, p1);
|
||||||
|
_sprites->addToPic(p1, p2, p3, p4, p5, p6, p7);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AgiEngine::clearImageStack(void) {
|
||||||
|
_imageStack.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AgiEngine::releaseImageStack(void) {
|
||||||
|
_imageStack.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AgiEngine::checkQuickLoad() {
|
||||||
|
if (ConfMan.hasKey("save_slot")) {
|
||||||
|
char saveNameBuffer[256];
|
||||||
|
|
||||||
|
snprintf (saveNameBuffer, 256, "%s.%03d", _targetName.c_str(), ConfMan.getInt("save_slot"));
|
||||||
|
|
||||||
|
if (loadGame(saveNameBuffer, false) == errOK) { // Do not check game id
|
||||||
|
_game.exitAllLogics = 1;
|
||||||
|
_menu->enableAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Agi
|
} // End of namespace Agi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue