NANCY: Add underscore to class member names

Fixed many instances of class member names not beginning with an underscore.
This commit is contained in:
fracturehill 2021-03-14 12:33:56 +02:00 committed by Eugene Sandulenko
parent 3e3a8cd5c7
commit 6728c96e68
47 changed files with 1305 additions and 1307 deletions

View File

@ -41,48 +41,48 @@ namespace Action {
void ActionManager::handleInput(NancyInput &input) {
for (auto &rec : _records) {
if (rec->isActive) {
if (rec->_isActive) {
// Send input to all active records
rec->handleInput(input);
}
if (rec->isActive && rec->hasHotspot && NancySceneState.getViewport().convertViewportToScreen(rec->hotspot).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(rec->getHoverCursor());
if (rec->_isActive && rec->_hasHotspot && NancySceneState.getViewport().convertViewportToScreen(rec->_hotspot).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(rec->getHoverCursor());
if (input.input & NancyInput::kLeftMouseButtonUp) {
input.input &= ~NancyInput::kLeftMouseButtonUp;
bool shouldTrigger = false;
int16 heldItem = NancySceneState.getHeldItem();
if (rec->itemRequired != -1) {
if (heldItem == -1 && rec->itemRequired == -2) {
if (rec->_itemRequired != -1) {
if (heldItem == -1 && rec->_itemRequired == -2) {
shouldTrigger = true;
} else {
if (rec->itemRequired <= 100) {
if (heldItem == rec->itemRequired) {
if (rec->_itemRequired <= 100) {
if (heldItem == rec->_itemRequired) {
shouldTrigger = true;
}
} else if (rec->itemRequired <= 110 && rec->itemRequired - 100 != heldItem) {
} else if (rec->_itemRequired <= 110 && rec->_itemRequired - 100 != heldItem) {
// IDs 100 - 110 mean the record will activate when the object is _not_ the specified one
shouldTrigger = true;
}
}
if (!shouldTrigger) {
g_nancy->sound->playSound(17); // Hardcoded by original engine
g_nancy->_sound->playSound(17); // Hardcoded by original engine
}
} else {
shouldTrigger = true;
}
if (shouldTrigger) {
rec->state = ActionRecord::ExecutionState::kActionTrigger;
rec->_state = ActionRecord::ExecutionState::kActionTrigger;
if (rec->itemRequired > 100 && rec->itemRequired <= 110) {
rec->itemRequired -= 100;
if (rec->_itemRequired > 100 && rec->_itemRequired <= 110) {
rec->_itemRequired -= 100;
}
// Re-add the object to the inventory unless it's marked as a one-time use
if (rec->itemRequired == heldItem && rec->itemRequired != -1) {
if (rec->_itemRequired == heldItem && rec->_itemRequired != -1) {
if (NancySceneState.getInventoryBox().getItemDescription(heldItem).oneTimeUse != 0) {
NancySceneState.getInventoryBox().addItem(heldItem);
}
@ -105,11 +105,11 @@ bool ActionManager::addNewActionRecord(Common::SeekableReadStream &inputData) {
inputData.seek(0);
char *descBuf = new char[0x30];
inputData.read(descBuf, 0x30);
newRecord->description = Common::String(descBuf);
newRecord->_description = Common::String(descBuf);
delete[] descBuf;
newRecord->type = inputData.readByte(); // redundant
newRecord->execType = (ActionRecord::ExecutionType)inputData.readByte();
newRecord->_type = inputData.readByte(); // redundant
newRecord->_execType = (ActionRecord::ExecutionType)inputData.readByte();
uint16 localChunkSize = inputData.pos();
newRecord->readData(inputData);
@ -128,8 +128,8 @@ bool ActionManager::addNewActionRecord(Common::SeekableReadStream &inputData) {
// Initialize the dependencies data
inputData.seek(localChunkSize);
for (uint16 i = 0; i < numDependencies; ++i) {
newRecord->dependencies.push_back(DependencyRecord());
DependencyRecord &dep = newRecord->dependencies.back();
newRecord->_dependencies.push_back(DependencyRecord());
DependencyRecord &dep = newRecord->_dependencies.back();
dep.type = (DependencyType)inputData.readByte();
dep.label = inputData.readByte();
@ -146,7 +146,7 @@ bool ActionManager::addNewActionRecord(Common::SeekableReadStream &inputData) {
}
} else {
// Set new record to active if it doesn't depend on anything
newRecord->isActive = true;
newRecord->_isActive = true;
}
_records.push_back(newRecord);
@ -154,68 +154,68 @@ bool ActionManager::addNewActionRecord(Common::SeekableReadStream &inputData) {
debugC(1, kDebugActionRecord, "Loaded action record %i, type %s, typeID %i, description \"%s\", execType == %s",
_records.size() - 1,
newRecord->getRecordTypeName().c_str(),
newRecord->type,
newRecord->description.c_str(),
newRecord->execType == ActionRecord::kRepeating ? "kRepeating" : "kOneShot");
for (uint i = 0; i < newRecord->dependencies.size(); ++i) {
newRecord->_type,
newRecord->_description.c_str(),
newRecord->_execType == ActionRecord::kRepeating ? "kRepeating" : "kOneShot");
for (uint i = 0; i < newRecord->_dependencies.size(); ++i) {
debugCN(1, kDebugActionRecord, "\tDependency %i: type ", i);
switch (newRecord->dependencies[i].type) {
switch (newRecord->_dependencies[i].type) {
case kNone :
debugCN(1, kDebugActionRecord, "kNone");
break;
case kInventory :
debugCN(1, kDebugActionRecord, "kInventory, item ID %i %s",
newRecord->dependencies[i].label,
newRecord->dependencies[i].condition == kTrue ? "is in possession" : "is not in possession");
newRecord->_dependencies[i].label,
newRecord->_dependencies[i].condition == kTrue ? "is in possession" : "is not in possession");
break;
case kEventFlag :
debugCN(1, kDebugActionRecord, "kEventFlag, flag ID %i == %s",
newRecord->dependencies[i].label,
newRecord->dependencies[i].condition == kTrue ? "true" : "false");
newRecord->_dependencies[i].label,
newRecord->_dependencies[i].condition == kTrue ? "true" : "false");
break;
case kLogicCondition :
debugCN(1, kDebugActionRecord, "kLogicCondition, logic condition ID %i == %s",
newRecord->dependencies[i].label,
newRecord->dependencies[i].condition == kTrue ? "true" : "false");
newRecord->_dependencies[i].label,
newRecord->_dependencies[i].condition == kTrue ? "true" : "false");
break;
case kTotalTime :
debugCN(1, kDebugActionRecord, "kTotalTime, %i hours, %i minutes, %i seconds, %i milliseconds",
newRecord->dependencies[i].hours,
newRecord->dependencies[i].minutes,
newRecord->dependencies[i].seconds,
newRecord->dependencies[i].milliseconds);
newRecord->_dependencies[i].hours,
newRecord->_dependencies[i].minutes,
newRecord->_dependencies[i].seconds,
newRecord->_dependencies[i].milliseconds);
break;
case kSceneTime :
debugCN(1, kDebugActionRecord, "kSceneTime, %i hours, %i minutes, %i seconds, %i milliseconds",
newRecord->dependencies[i].hours,
newRecord->dependencies[i].minutes,
newRecord->dependencies[i].seconds,
newRecord->dependencies[i].milliseconds);
newRecord->_dependencies[i].hours,
newRecord->_dependencies[i].minutes,
newRecord->_dependencies[i].seconds,
newRecord->_dependencies[i].milliseconds);
break;
case kPlayerTime :
debugCN(1, kDebugActionRecord, "kPlayerTime, %i days, %i hours, %i minutes, %i seconds",
newRecord->dependencies[i].hours,
newRecord->dependencies[i].minutes,
newRecord->dependencies[i].seconds,
newRecord->dependencies[i].milliseconds);
newRecord->_dependencies[i].hours,
newRecord->_dependencies[i].minutes,
newRecord->_dependencies[i].seconds,
newRecord->_dependencies[i].milliseconds);
break;
case kSceneCount :
debugCN(1, kDebugActionRecord, "kSceneCount, scene ID %i, hit count %s %i",
newRecord->dependencies[i].hours,
newRecord->dependencies[i].milliseconds == 1 ? ">" : newRecord->dependencies[i].milliseconds == 2 ? "<" : "==",
newRecord->dependencies[i].seconds);
newRecord->_dependencies[i].hours,
newRecord->_dependencies[i].milliseconds == 1 ? ">" : newRecord->_dependencies[i].milliseconds == 2 ? "<" : "==",
newRecord->_dependencies[i].seconds);
break;
case kResetOnNewDay :
debugCN(1, kDebugActionRecord, "kResetOnNewDay");
break;
case kUseItem :
debugCN(1, kDebugActionRecord, "kUseItem, item ID %i %s",
newRecord->dependencies[i].label,
newRecord->dependencies[i].condition == kTrue ? "is held" : "is not held");
newRecord->_dependencies[i].label,
newRecord->_dependencies[i].condition == kTrue ? "is held" : "is not held");
break;
case kTimeOfDay :
debugCN(1, kDebugActionRecord, "kTimeOfDay, %s",
newRecord->dependencies[i].label == 0 ? "day" : newRecord->dependencies[i].label == 1 ? "night" : "dusk/dawn");
newRecord->_dependencies[i].label == 0 ? "day" : newRecord->_dependencies[i].label == 1 ? "night" : "dusk/dawn");
break;
case kTimerNotDone :
debugCN(1, kDebugActionRecord, "kTimerNotDone");
@ -224,13 +224,13 @@ bool ActionManager::addNewActionRecord(Common::SeekableReadStream &inputData) {
debugCN(1, kDebugActionRecord, "kTimerDone");
break;
case kDifficultyLevel :
debugCN(1, kDebugActionRecord, "kDifficultyLevel, level %i", newRecord->dependencies[i].condition);
debugCN(1, kDebugActionRecord, "kDifficultyLevel, level %i", newRecord->_dependencies[i].condition);
break;
default:
debugCN(1, kDebugActionRecord, "unknown");
break;
}
debugC(1, kDebugActionRecord, ", orFlag == %s", newRecord->dependencies[i].orFlag == true ? "true" : "false");
debugC(1, kDebugActionRecord, ", orFlag == %s", newRecord->_dependencies[i].orFlag == true ? "true" : "false");
}
return true;
@ -238,13 +238,13 @@ bool ActionManager::addNewActionRecord(Common::SeekableReadStream &inputData) {
void ActionManager::processActionRecords() {
for (auto record : _records) {
if (record->isDone) {
if (record->_isDone) {
continue;
}
if (!record->isActive) {
for (uint i = 0; i < record->dependencies.size(); ++i) {
DependencyRecord &dep = record->dependencies[i];
if (!record->_isActive) {
for (uint i = 0; i < record->_dependencies.size(); ++i) {
DependencyRecord &dep = record->_dependencies[i];
if (!dep.satisfied) {
switch (dep.type) {
@ -343,17 +343,17 @@ void ActionManager::processActionRecords() {
break;
case kResetOnNewDay:
if (record->days == -1) {
record->days = NancySceneState._timers.playerTime.getDays();
if (record->_days == -1) {
record->_days = NancySceneState._timers.playerTime.getDays();
dep.satisfied = true;
break;
}
if (record->days < NancySceneState._timers.playerTime.getDays()) {
record->days = NancySceneState._timers.playerTime.getDays();
for (uint j = 0; j < record->dependencies.size(); ++j) {
if (record->dependencies[j].type == kPlayerTime) {
record->dependencies[j].satisfied = false;
if (record->_days < NancySceneState._timers.playerTime.getDays()) {
record->_days = NancySceneState._timers.playerTime.getDays();
for (uint j = 0; j < record->_dependencies.size(); ++j) {
if (record->_dependencies[j].type == kPlayerTime) {
record->_dependencies[j].satisfied = false;
}
}
}
@ -361,8 +361,8 @@ void ActionManager::processActionRecords() {
break;
case kUseItem: {
bool hasUnsatisfiedDeps = false;
for (uint j = 0; j < record->dependencies.size(); ++j) {
if (j != i && record->dependencies[j].satisfied == false) {
for (uint j = 0; j < record->_dependencies.size(); ++j) {
if (j != i && record->_dependencies[j].satisfied == false) {
hasUnsatisfiedDeps = true;
}
}
@ -371,10 +371,10 @@ void ActionManager::processActionRecords() {
break;
}
record->itemRequired = dep.label;
record->_itemRequired = dep.label;
if (dep.condition == 1) {
record->itemRequired += 100;
record->_itemRequired += 100;
}
dep.satisfied = true;
@ -412,28 +412,28 @@ void ActionManager::processActionRecords() {
// An orFlag marks that its corresponding dependency and the one after it
// mutually satisfy each other; if one is satisfied, so is the other
for (uint i = 1; i < record->dependencies.size(); ++i) {
if (record->dependencies[i-1].orFlag) {
if (record->dependencies[i-1].satisfied)
record->dependencies[i].satisfied = true;
if (record->dependencies[i].satisfied)
record->dependencies[i-1].satisfied = true;
for (uint i = 1; i < record->_dependencies.size(); ++i) {
if (record->_dependencies[i-1].orFlag) {
if (record->_dependencies[i-1].satisfied)
record->_dependencies[i].satisfied = true;
if (record->_dependencies[i].satisfied)
record->_dependencies[i-1].satisfied = true;
}
}
// Check if all dependencies have been satisfied, and activate the record if they have
uint satisfied = 0;
for (uint i = 0; i < record->dependencies.size(); ++i) {
if (record->dependencies[i].satisfied)
for (uint i = 0; i < record->_dependencies.size(); ++i) {
if (record->_dependencies[i].satisfied)
++satisfied;
}
if (satisfied == record->dependencies.size())
record->isActive = true;
if (satisfied == record->_dependencies.size())
record->_isActive = true;
}
if (record->isActive) {
if (record->_isActive) {
record->execute();
}
}
@ -448,7 +448,7 @@ void ActionManager::clearActionRecords() {
void ActionManager::onPause(bool pause) {
for (auto &r : _records) {
if (r->isActive && !r->isDone) {
if (r->_isActive && !r->_isDone) {
r->onPause(pause);
}
}
@ -457,8 +457,8 @@ void ActionManager::onPause(bool pause) {
void ActionManager::synchronize(Common::Serializer &ser) {
// When loading, the records should already have been initialized by scene
for (auto &rec : _records) {
ser.syncAsByte(rec->isActive);
ser.syncAsByte(rec->isDone);
ser.syncAsByte(rec->_isActive);
ser.syncAsByte(rec->_isDone);
}
}

View File

@ -83,14 +83,14 @@ public:
enum ExecutionState { kBegin, kRun, kActionTrigger };
enum ExecutionType { kOneShot = 1, kRepeating = 2 };
ActionRecord() :
type(0),
execType(kOneShot),
isActive(false),
isDone(false),
hasHotspot(false),
state(ExecutionState::kBegin),
days(-1),
itemRequired(-1) {}
_type(0),
_execType(kOneShot),
_isActive(false),
_isDone(false),
_hasHotspot(false),
_state(ExecutionState::kBegin),
_days(-1),
_itemRequired(-1) {}
virtual ~ActionRecord() {}
virtual void readData(Common::SeekableReadStream &stream) =0;
@ -102,23 +102,23 @@ public:
protected:
void finishExecution() {
switch (execType) {
switch (_execType) {
case kOneShot:
isDone = true;
state = kBegin;
_isDone = true;
_state = kBegin;
break;
case kRepeating:
isDone = false;
isActive = false;
state = kBegin;
_isDone = false;
_isActive = false;
_state = kBegin;
for (uint i = 0; i < dependencies.size(); ++i) {
dependencies[i].satisfied = false;
for (uint i = 0; i < _dependencies.size(); ++i) {
_dependencies[i].satisfied = false;
}
break;
default:
state = kBegin;
_state = kBegin;
break;
}
}
@ -127,22 +127,22 @@ protected:
virtual Common::String getRecordTypeName() const =0;
public:
Common::String description; // 0x00
byte type; // 0x30
ExecutionType execType; // 0x31
Common::String _description; // 0x00
byte _type; // 0x30
ExecutionType _execType; // 0x31
// 0x32 data
Common::Array<DependencyRecord> dependencies; // 0x36
Common::Array<DependencyRecord> _dependencies; // 0x36
// 0x3A numDependencies
bool isActive; // 0x3B
bool _isActive; // 0x3B
// 0x3C satisfiedDependencies[]
// 0x48 timers[]
// 0x78 orFlags[]
bool isDone; // 0x84
bool hasHotspot; // 0x85
Common::Rect hotspot; // 0x89
ExecutionState state; // 0x91
int16 days; // 0x95
int8 itemRequired; // 0x97
bool _isDone; // 0x84
bool _hasHotspot; // 0x85
Common::Rect _hotspot; // 0x89
ExecutionState _state; // 0x91
int16 _days; // 0x95
int8 _itemRequired; // 0x97
};
} // End of namespace Action

View File

@ -38,97 +38,97 @@ void LeverPuzzle::init() {
setTransparent(true);
g_nancy->resource->loadImage(imageName, image);
g_nancy->_resource->loadImage(_imageName, _image);
}
void LeverPuzzle::readData(Common::SeekableReadStream &stream) {
char buf[10];
stream.read(buf, 10);
imageName = buf;
_imageName = buf;
for (uint leverID = 0; leverID < 3; ++leverID) {
srcRects.push_back(Common::Array<Common::Rect>());
_srcRects.push_back(Common::Array<Common::Rect>());
for (uint i = 0; i < 4; ++i) {
srcRects.back().push_back(Common::Rect());
readRect(stream, srcRects.back().back());
_srcRects.back().push_back(Common::Rect());
readRect(stream, _srcRects.back().back());
}
}
for (uint leverID = 0; leverID < 3; ++leverID) {
destRects.push_back(Common::Rect());
readRect(stream, destRects.back());
_destRects.push_back(Common::Rect());
readRect(stream, _destRects.back());
if (leverID == 0) {
_screenPosition = destRects.back();
_screenPosition = _destRects.back();
} else {
_screenPosition.extend(destRects.back());
_screenPosition.extend(_destRects.back());
}
}
for (uint leverID = 0; leverID < 3; ++leverID) {
playerSequence.push_back(stream.readByte());
leverDirection.push_back(true);
_playerSequence.push_back(stream.readByte());
_leverDirection.push_back(true);
}
for (uint leverID = 0; leverID < 3; ++leverID) {
correctSequence.push_back(stream.readByte());
_correctSequence.push_back(stream.readByte());
}
moveSound.read(stream, SoundDescription::kNormal);
noMoveSound.read(stream, SoundDescription::kNormal);
solveExitScene.readData(stream);
_moveSound.read(stream, SoundDescription::kNormal);
_noMoveSound.read(stream, SoundDescription::kNormal);
_solveExitScene.readData(stream);
stream.skip(2);
flagOnSolve.label = stream.readSint16LE();
flagOnSolve.flag = (NancyFlag)stream.readByte();
solveSoundDelay = stream.readUint16LE();
solveSound.read(stream, SoundDescription::kNormal);
exitScene.readData(stream);
_flagOnSolve.label = stream.readSint16LE();
_flagOnSolve.flag = (NancyFlag)stream.readByte();
_solveSoundDelay = stream.readUint16LE();
_solveSound.read(stream, SoundDescription::kNormal);
_exitScene.readData(stream);
stream.skip(2);
flagOnExit.label = stream.readSint16LE();
flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, exitHotspot);
_flagOnExit.label = stream.readSint16LE();
_flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, _exitHotspot);
}
void LeverPuzzle::execute() {
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
g_nancy->sound->loadSound(moveSound);
g_nancy->sound->loadSound(noMoveSound);
g_nancy->_sound->loadSound(_moveSound);
g_nancy->_sound->loadSound(_noMoveSound);
for (uint i = 0; i < 3; ++i) {
drawLever(i);
}
state = kRun;
_state = kRun;
// fall through
case kRun:
switch (solveState) {
switch (_solveState) {
case kNotSolved:
for (uint i = 0; i < 3; ++i) {
if (playerSequence[i] != correctSequence[i]) {
if (_playerSequence[i] != _correctSequence[i]) {
return;
}
}
NancySceneState.setEventFlag(flagOnSolve);
solveSoundPlayTime = g_nancy->getTotalPlayTime() + solveSoundDelay * 1000;
solveState = kPlaySound;
NancySceneState.setEventFlag(_flagOnSolve);
_solveSoundPlayTime = g_nancy->getTotalPlayTime() + _solveSoundDelay * 1000;
_solveState = kPlaySound;
break;
case kPlaySound:
if (g_nancy->getTotalPlayTime() <= solveSoundPlayTime) {
if (g_nancy->getTotalPlayTime() <= _solveSoundPlayTime) {
break;
}
g_nancy->sound->loadSound(solveSound);
g_nancy->sound->playSound(solveSound);
solveState = kWaitForSound;
g_nancy->_sound->loadSound(_solveSound);
g_nancy->_sound->playSound(_solveSound);
_solveState = kWaitForSound;
break;
case kWaitForSound:
if (!g_nancy->sound->isSoundPlaying(solveSound)) {
g_nancy->sound->stopSound(solveSound);
state = kActionTrigger;
if (!g_nancy->_sound->isSoundPlaying(_solveSound)) {
g_nancy->_sound->stopSound(_solveSound);
_state = kActionTrigger;
}
break;
@ -136,14 +136,14 @@ void LeverPuzzle::execute() {
break;
case kActionTrigger:
g_nancy->sound->stopSound(moveSound);
g_nancy->sound->stopSound(noMoveSound);
g_nancy->_sound->stopSound(_moveSound);
g_nancy->_sound->stopSound(_noMoveSound);
if (solveState == kNotSolved) {
NancySceneState.changeScene(exitScene);
NancySceneState.setEventFlag(flagOnExit);
if (_solveState == kNotSolved) {
NancySceneState.changeScene(_exitScene);
NancySceneState.setEventFlag(_flagOnExit);
} else {
NancySceneState.changeScene(solveExitScene);
NancySceneState.changeScene(_solveExitScene);
}
finishExecution();
@ -151,22 +151,22 @@ void LeverPuzzle::execute() {
}
void LeverPuzzle::handleInput(NancyInput &input) {
if (solveState != kNotSolved) {
if (_solveState != kNotSolved) {
return;
}
if (NancySceneState.getViewport().convertViewportToScreen(exitHotspot).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kExitArrow);
if (NancySceneState.getViewport().convertViewportToScreen(_exitHotspot).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kExitArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
state = kActionTrigger;
_state = kActionTrigger;
}
return;
}
for (uint i = 0; i < 3; ++i) {
if (NancySceneState.getViewport().convertViewportToScreen(destRects[i]).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspot);
if (NancySceneState.getViewport().convertViewportToScreen(_destRects[i]).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspot);
if (input.input & NancyInput::kLeftMouseButtonUp) {
bool isMoving = false;
@ -176,13 +176,13 @@ void LeverPuzzle::handleInput(NancyInput &input) {
isMoving = true;
break;
case 1:
if (playerSequence[0] == 1) {
if (_playerSequence[0] == 1) {
isMoving = true;
}
break;
case 2:
if (playerSequence[0] == 2) {
if (_playerSequence[0] == 2) {
isMoving = true;
}
@ -190,29 +190,29 @@ void LeverPuzzle::handleInput(NancyInput &input) {
}
if (isMoving) {
g_nancy->sound->playSound(moveSound);
g_nancy->_sound->playSound(_moveSound);
if (leverDirection[i]) {
if (_leverDirection[i]) {
// Moving down
if (playerSequence[i] == 3) {
--playerSequence[i];
leverDirection[i] = false;
if (_playerSequence[i] == 3) {
--_playerSequence[i];
_leverDirection[i] = false;
} else {
++playerSequence[i];
++_playerSequence[i];
}
} else {
// Moving up
if (playerSequence[i] == 0) {
++playerSequence[i];
leverDirection[i] = true;
if (_playerSequence[i] == 0) {
++_playerSequence[i];
_leverDirection[i] = true;
} else {
--playerSequence[i];
--_playerSequence[i];
}
}
drawLever(i);
} else {
g_nancy->sound->playSound(noMoveSound);
g_nancy->_sound->playSound(_noMoveSound);
return;
}
}
@ -227,8 +227,8 @@ void LeverPuzzle::onPause(bool pause) {
}
void LeverPuzzle::drawLever(uint id) {
Common::Point destPoint(destRects[id].left - _screenPosition.left, destRects[id].top - _screenPosition.top);
_drawSurface.blitFrom(image, srcRects[id][playerSequence[id]], destPoint);
Common::Point destPoint(_destRects[id].left - _screenPosition.left, _destRects[id].top - _screenPosition.top);
_drawSurface.blitFrom(_image, _srcRects[id][_playerSequence[id]], destPoint);
_needsRedraw = true;
}

View File

@ -49,25 +49,25 @@ public:
virtual void handleInput(NancyInput &input) override;
virtual void onPause(bool pause) override;
Common::String imageName; // 0x0
Common::Array<Common::Array<Common::Rect>> srcRects; // 0xA, 0xC0 bytes
Common::Array<Common::Rect> destRects; // 0xCA, 0x30 bytes
Common::Array<byte> correctSequence; // 0xFA, 3 bytes
SoundDescription moveSound; // 0x100
SoundDescription noMoveSound; // 0x122
SceneChangeDescription solveExitScene; // 0x144
EventFlagDescription flagOnSolve; // 0x14E
uint16 solveSoundDelay; // 0x151
SoundDescription solveSound; // 0x153
SceneChangeDescription exitScene; // 0x175
EventFlagDescription flagOnExit; // 0x17F
Common::Rect exitHotspot; // 0x182
Common::String _imageName; // 0x0
Common::Array<Common::Array<Common::Rect>> _srcRects; // 0xA, 0xC0 bytes
Common::Array<Common::Rect> _destRects; // 0xCA, 0x30 bytes
Common::Array<byte> _correctSequence; // 0xFA, 3 bytes
SoundDescription _moveSound; // 0x100
SoundDescription _noMoveSound; // 0x122
SceneChangeDescription _solveExitScene; // 0x144
EventFlagDescription _flagOnSolve; // 0x14E
uint16 _solveSoundDelay; // 0x151
SoundDescription _solveSound; // 0x153
SceneChangeDescription _exitScene; // 0x175
EventFlagDescription _flagOnExit; // 0x17F
Common::Rect _exitHotspot; // 0x182
Common::Array<byte> playerSequence;
Common::Array<bool> leverDirection;
Graphics::ManagedSurface image;
Time solveSoundPlayTime;
SolveState solveState = kNotSolved;
Common::Array<byte> _playerSequence;
Common::Array<bool> _leverDirection;
Graphics::ManagedSurface _image;
Time _solveSoundPlayTime;
SolveState _solveState = kNotSolved;
protected:
virtual Common::String getRecordTypeName() const override { return "LeverPuzzle"; }

View File

@ -45,7 +45,7 @@ void OrderingPuzzle::init() {
setTransparent(true);
g_nancy->resource->loadImage(imageName, image);
g_nancy->_resource->loadImage(_imageName, _image);
setVisible(false);
@ -56,102 +56,102 @@ void OrderingPuzzle::readData(Common::SeekableReadStream &stream) {
char buf[10];
stream.read(buf, 10);
imageName = buf;
_imageName = buf;
uint16 numElements = stream.readUint16LE();
for (uint i = 0; i < numElements; ++i) {
srcRects.push_back(Common::Rect());
readRect(stream, srcRects.back());
_srcRects.push_back(Common::Rect());
readRect(stream, _srcRects.back());
}
stream.skip(16 * (15 - numElements));
for (uint i = 0; i < numElements; ++i) {
destRects.push_back(Common::Rect());
readRect(stream, destRects.back());
_destRects.push_back(Common::Rect());
readRect(stream, _destRects.back());
if (i == 0) {
_screenPosition = destRects[i];
_screenPosition = _destRects[i];
} else {
_screenPosition.extend(destRects[i]);
_screenPosition.extend(_destRects[i]);
}
drawnElements.push_back(false);
_drawnElements.push_back(false);
}
stream.skip(16 * (15 - numElements));
sequenceLength = stream.readUint16LE();
_sequenceLength = stream.readUint16LE();
for (uint i = 0; i < 15; ++i) {
correctSequence.push_back(stream.readByte());
_correctSequence.push_back(stream.readByte());
}
clickSound.read(stream, SoundDescription::kNormal);
solveExitScene.readData(stream);
_clickSound.read(stream, SoundDescription::kNormal);
_solveExitScene.readData(stream);
stream.skip(2); // shouldStopRendering, useless
flagOnSolve.label = stream.readSint16LE();
flagOnSolve.flag = (NancyFlag)stream.readByte();
solveSoundDelay = stream.readUint16LE();
solveSound.read(stream, SoundDescription::kNormal);
exitScene.readData(stream);
_flagOnSolve.label = stream.readSint16LE();
_flagOnSolve.flag = (NancyFlag)stream.readByte();
_solveSoundDelay = stream.readUint16LE();
_solveSound.read(stream, SoundDescription::kNormal);
_exitScene.readData(stream);
stream.skip(2); // shouldStopRendering, useless
flagOnExit.label = stream.readSint16LE();
flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, exitHotspot);
_flagOnExit.label = stream.readSint16LE();
_flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, _exitHotspot);
}
void OrderingPuzzle::execute() {
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
g_nancy->sound->loadSound(clickSound);
g_nancy->sound->loadSound(solveSound);
state = kRun;
g_nancy->_sound->loadSound(_clickSound);
g_nancy->_sound->loadSound(_solveSound);
_state = kRun;
// fall through
case kRun:
switch (solveState) {
switch (_solveState) {
case kNotSolved:
if (clickedSequence.size() != sequenceLength) {
if (_clickedSequence.size() != _sequenceLength) {
return;
}
for (uint i = 0; i < sequenceLength; ++i) {
if (clickedSequence[i] != (int16)correctSequence[i]) {
for (uint i = 0; i < _sequenceLength; ++i) {
if (_clickedSequence[i] != (int16)_correctSequence[i]) {
return;
}
}
NancySceneState.setEventFlag(flagOnSolve);
solveSoundPlayTime = g_nancy->getTotalPlayTime() + solveSoundDelay * 1000;
solveState = kPlaySound;
NancySceneState.setEventFlag(_flagOnSolve);
_solveSoundPlayTime = g_nancy->getTotalPlayTime() + _solveSoundDelay * 1000;
_solveState = kPlaySound;
// fall through
case kPlaySound:
if (g_nancy->getTotalPlayTime() <= solveSoundPlayTime) {
if (g_nancy->getTotalPlayTime() <= _solveSoundPlayTime) {
break;
}
g_nancy->sound->playSound(solveSound);
solveState = kWaitForSound;
g_nancy->_sound->playSound(_solveSound);
_solveState = kWaitForSound;
break;
case kWaitForSound:
if (!g_nancy->sound->isSoundPlaying(solveSound)) {
state = kActionTrigger;
if (!g_nancy->_sound->isSoundPlaying(_solveSound)) {
_state = kActionTrigger;
}
break;
}
break;
case kActionTrigger:
g_nancy->sound->stopSound(clickSound);
g_nancy->sound->stopSound(solveSound);
g_nancy->_sound->stopSound(_clickSound);
g_nancy->_sound->stopSound(_solveSound);
if (solveState == kNotSolved) {
NancySceneState.changeScene(exitScene);
NancySceneState.setEventFlag(flagOnExit);
if (_solveState == kNotSolved) {
NancySceneState.changeScene(_exitScene);
NancySceneState.setEventFlag(_flagOnExit);
} else {
NancySceneState.changeScene(solveExitScene);
NancySceneState.changeScene(_solveExitScene);
}
finishExecution();
@ -160,40 +160,40 @@ void OrderingPuzzle::execute() {
}
void OrderingPuzzle::handleInput(NancyInput &input) {
if (solveState != kNotSolved) {
if (_solveState != kNotSolved) {
return;
}
if (NancySceneState.getViewport().convertViewportToScreen(exitHotspot).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kExitArrow);
if (NancySceneState.getViewport().convertViewportToScreen(_exitHotspot).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kExitArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
state = kActionTrigger;
_state = kActionTrigger;
}
return;
}
for (int i = 0; i < (int)destRects.size(); ++i) {
if (NancySceneState.getViewport().convertViewportToScreen(destRects[i]).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspot);
for (int i = 0; i < (int)_destRects.size(); ++i) {
if (NancySceneState.getViewport().convertViewportToScreen(_destRects[i]).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspot);
if (input.input & NancyInput::kLeftMouseButtonUp) {
g_nancy->sound->playSound(clickSound);
g_nancy->_sound->playSound(_clickSound);
for (uint j = 0; j < clickedSequence.size(); ++j) {
if (clickedSequence[j] == i && drawnElements[i] == true) {
for (uint j = 0; j < _clickedSequence.size(); ++j) {
if (_clickedSequence[j] == i && _drawnElements[i] == true) {
undrawElement(i);
if (clickedSequence.back() == i) {
clickedSequence.pop_back();
if (_clickedSequence.back() == i) {
_clickedSequence.pop_back();
}
return;
}
}
clickedSequence.push_back(i);
_clickedSequence.push_back(i);
if (clickedSequence.size() > (uint)sequenceLength + 1) {
if (_clickedSequence.size() > (uint)_sequenceLength + 1) {
clearAllElements();
} else {
drawElement(i);
@ -211,15 +211,15 @@ void OrderingPuzzle::onPause(bool pause) {
}
void OrderingPuzzle::drawElement(uint id) {
drawnElements[id] = true;
Common::Point destPoint(destRects[id].left - _screenPosition.left, destRects[id].top - _screenPosition.top);
_drawSurface.blitFrom(image, srcRects[id], destPoint);
_drawnElements[id] = true;
Common::Point destPoint(_destRects[id].left - _screenPosition.left, _destRects[id].top - _screenPosition.top);
_drawSurface.blitFrom(_image, _srcRects[id], destPoint);
setVisible(true);
}
void OrderingPuzzle::undrawElement(uint id) {
drawnElements[id] = false;
Common::Rect bounds = destRects[id];
_drawnElements[id] = false;
Common::Rect bounds = _destRects[id];
bounds.translate(-_screenPosition.left, -_screenPosition.top);
_drawSurface.fillRect(bounds, GraphicsManager::getTransColor());
@ -229,7 +229,7 @@ void OrderingPuzzle::undrawElement(uint id) {
void OrderingPuzzle::clearAllElements() {
_drawSurface.clear(GraphicsManager::getTransColor());
setVisible(false);
clickedSequence.clear();
_clickedSequence.clear();
return;
}

View File

@ -50,25 +50,25 @@ public:
virtual void handleInput(NancyInput &input) override;
virtual void onPause(bool pause) override;
Common::String imageName; // 0x00
Common::Array<Common::Rect> srcRects; // 0xC, 15
Common::Array<Common::Rect> destRects; // 0xFC, 15
uint16 sequenceLength; // 0x1EC;
Common::Array<byte> correctSequence; // 0x1EE, 15 bytes
Nancy::SoundDescription clickSound; // 0x1FD, kNormal
SceneChangeDescription solveExitScene; // 0x21F
EventFlagDescription flagOnSolve; // 0x229
uint16 solveSoundDelay; // 0x22C
Nancy::SoundDescription solveSound; // 0x22E
SceneChangeDescription exitScene; // 0x250
EventFlagDescription flagOnExit; // 0x25A
Common::Rect exitHotspot; // 0x25D
Common::String _imageName; // 0x00
Common::Array<Common::Rect> _srcRects; // 0xC, 15
Common::Array<Common::Rect> _destRects; // 0xFC, 15
uint16 _sequenceLength; // 0x1EC;
Common::Array<byte> _correctSequence; // 0x1EE, 15 bytes
Nancy::SoundDescription _clickSound; // 0x1FD, kNormal
SceneChangeDescription _solveExitScene; // 0x21F
EventFlagDescription _flagOnSolve; // 0x229
uint16 _solveSoundDelay; // 0x22C
Nancy::SoundDescription _solveSound; // 0x22E
SceneChangeDescription _exitScene; // 0x250
EventFlagDescription _flagOnExit; // 0x25A
Common::Rect _exitHotspot; // 0x25D
SolveState solveState = kNotSolved;
Graphics::ManagedSurface image;
Common::Array<int16> clickedSequence;
Common::Array<bool> drawnElements;
Time solveSoundPlayTime;
SolveState _solveState = kNotSolved;
Graphics::ManagedSurface _image;
Common::Array<int16> _clickedSequence;
Common::Array<bool> _drawnElements;
Time _solveSoundPlayTime;
protected:
virtual Common::String getRecordTypeName() const override { return "OrderingPuzzle"; }

View File

@ -44,51 +44,51 @@ void PasswordPuzzle::init() {
}
void PasswordPuzzle::readData(Common::SeekableReadStream &stream) {
fontID = stream.readUint16LE();
cursorBlinkTime = stream.readUint16LE();
readRect(stream, nameBounds);
readRect(stream, passwordBounds);
_fontID = stream.readUint16LE();
_cursorBlinkTime = stream.readUint16LE();
readRect(stream, _nameBounds);
readRect(stream, _passwordBounds);
readRect(stream, _screenPosition);
char buf[20];
stream.read(buf, 20);
name = buf;
_name = buf;
stream.read(buf, 20);
password = buf;
solveExitScene.readData(stream);
_password = buf;
_solveExitScene.readData(stream);
stream.skip(2);
flagOnSolve.label = stream.readSint16LE();
flagOnSolve.flag = (NancyFlag)stream.readByte();
solveSound.read(stream, SoundDescription::kNormal);
failExitScene.readData(stream);
_flagOnSolve.label = stream.readSint16LE();
_flagOnSolve.flag = (NancyFlag)stream.readByte();
_solveSound.read(stream, SoundDescription::kNormal);
_failExitScene.readData(stream);
stream.skip(2);
flagOnFail.label = stream.readSint16LE();
flagOnFail.flag = (NancyFlag)stream.readByte();
failSound.read(stream, SoundDescription::kNormal);
exitScene.readData(stream);
_flagOnFail.label = stream.readSint16LE();
_flagOnFail.flag = (NancyFlag)stream.readByte();
_failSound.read(stream, SoundDescription::kNormal);
_exitScene.readData(stream);
stream.skip(2);
flagOnExit.label = stream.readSint16LE();
flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, exitHotspot);
_flagOnExit.label = stream.readSint16LE();
_flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, _exitHotspot);
}
void PasswordPuzzle::execute() {
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
nextBlinkTime = g_nancy->getTotalPlayTime() + cursorBlinkTime;
state = kRun;
_nextBlinkTime = g_nancy->getTotalPlayTime() + _cursorBlinkTime;
_state = kRun;
// fall through
case kRun:
switch (solveState) {
switch (_solveState) {
case kNotSolved: {
Common::String &activeField = passwordFieldIsActive ? playerPasswordInput : playerNameInput;
Common::String &correctField = passwordFieldIsActive ? password : name;
Common::String &activeField = _passwordFieldIsActive ? _playerPasswordInput : _playerNameInput;
Common::String &correctField = _passwordFieldIsActive ? _password : _name;
Time currentTime = g_nancy->getTotalPlayTime();
if (playerHasHitReturn) {
playerHasHitReturn = false;
if (_playerHasHitReturn) {
_playerHasHitReturn = false;
if (activeField.lastChar() == '-') {
activeField.deleteLastChar();
@ -96,22 +96,22 @@ void PasswordPuzzle::execute() {
}
if (activeField.equalsIgnoreCase(correctField)) {
if (!passwordFieldIsActive) {
passwordFieldIsActive = true;
if (!_passwordFieldIsActive) {
_passwordFieldIsActive = true;
} else {
g_nancy->sound->loadSound(solveSound);
g_nancy->sound->playSound(solveSound);
solveState = kSolved;
g_nancy->_sound->loadSound(_solveSound);
g_nancy->_sound->playSound(_solveSound);
_solveState = kSolved;
}
} else {
g_nancy->sound->loadSound(failSound);
g_nancy->sound->playSound(failSound);
solveState = kFailed;
g_nancy->_sound->loadSound(_failSound);
g_nancy->_sound->playSound(_failSound);
_solveState = kFailed;
}
} else if (currentTime >= nextBlinkTime) {
nextBlinkTime = currentTime + cursorBlinkTime;
} else if (currentTime >= _nextBlinkTime) {
_nextBlinkTime = currentTime + _cursorBlinkTime;
if (activeField.size() && activeField.lastChar() == '-') {
activeField.deleteLastChar();
@ -125,16 +125,16 @@ void PasswordPuzzle::execute() {
break;
}
case kFailed:
if (!g_nancy->sound->isSoundPlaying(failSound)) {
g_nancy->sound->stopSound(failSound);
state = kActionTrigger;
if (!g_nancy->_sound->isSoundPlaying(_failSound)) {
g_nancy->_sound->stopSound(_failSound);
_state = kActionTrigger;
}
break;
case kSolved:
if (!g_nancy->sound->isSoundPlaying(solveSound)) {
g_nancy->sound->stopSound(solveSound);
state = kActionTrigger;
if (!g_nancy->_sound->isSoundPlaying(_solveSound)) {
g_nancy->_sound->stopSound(_solveSound);
_state = kActionTrigger;
}
break;
@ -142,18 +142,18 @@ void PasswordPuzzle::execute() {
break;
case kActionTrigger:
switch (solveState) {
switch (_solveState) {
case kNotSolved:
NancySceneState.changeScene(exitScene);
NancySceneState.setEventFlag(flagOnExit);
NancySceneState.changeScene(_exitScene);
NancySceneState.setEventFlag(_flagOnExit);
break;
case kFailed:
NancySceneState.changeScene(failExitScene);
NancySceneState.setEventFlag(flagOnFail.label);
NancySceneState.changeScene(_failExitScene);
NancySceneState.setEventFlag(_flagOnFail.label);
break;
case kSolved:
NancySceneState.changeScene(solveExitScene);
NancySceneState.setEventFlag(flagOnSolve.label);
NancySceneState.changeScene(_solveExitScene);
NancySceneState.setEventFlag(_flagOnSolve.label);
break;
}
@ -162,15 +162,15 @@ void PasswordPuzzle::execute() {
}
void PasswordPuzzle::handleInput(NancyInput &input) {
if (solveState != kNotSolved) {
if (_solveState != kNotSolved) {
return;
}
if (NancySceneState.getViewport().convertViewportToScreen(exitHotspot).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kExitArrow);
if (NancySceneState.getViewport().convertViewportToScreen(_exitHotspot).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kExitArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
state = kActionTrigger;
_state = kActionTrigger;
}
return;
@ -178,8 +178,8 @@ void PasswordPuzzle::handleInput(NancyInput &input) {
for (uint i = 0; i < input.otherKbdInput.size(); ++i) {
Common::KeyState &key = input.otherKbdInput[i];
Common::String &activeField = passwordFieldIsActive ? playerPasswordInput : playerNameInput;
Common::String &correctField = passwordFieldIsActive ? password : name;
Common::String &activeField = _passwordFieldIsActive ? _playerPasswordInput : _playerNameInput;
Common::String &correctField = _passwordFieldIsActive ? _password : _name;
if (key.keycode == Common::KEYCODE_BACKSPACE) {
if (activeField.size() && activeField.lastChar() == '-' ? activeField.size() > 1 : true) {
if (activeField.lastChar() == '-') {
@ -191,7 +191,7 @@ void PasswordPuzzle::handleInput(NancyInput &input) {
drawText();
}
} else if (key.keycode == Common::KEYCODE_RETURN) {
playerHasHitReturn = true;
_playerHasHitReturn = true;
} else if (Common::isAlnum(key.ascii) || Common::isSpace(key.ascii)) {
if (activeField.size() && activeField.lastChar() == '-') {
if (activeField.size() <= correctField.size() + 2) {
@ -218,20 +218,20 @@ void PasswordPuzzle::onPause(bool pause) {
void PasswordPuzzle::drawText() {
_drawSurface.clear(GraphicsManager::getTransColor());
Graphics::Font *font = g_nancy->graphicsManager->getFont(fontID);
Graphics::Font *font = g_nancy->_graphicsManager->getFont(_fontID);
Common::Rect bounds = nameBounds;
Common::Rect bounds = _nameBounds;
bounds = NancySceneState.getViewport().convertViewportToScreen(bounds);
bounds = convertToLocal(bounds);
Common::Point destPoint(bounds.left, bounds.bottom + 1 - font->getFontHeight());
font->drawString(&_drawSurface, playerNameInput, destPoint.x, destPoint.y, bounds.width(), 0);
font->drawString(&_drawSurface, _playerNameInput, destPoint.x, destPoint.y, bounds.width(), 0);
bounds = passwordBounds;
bounds = _passwordBounds;
bounds = NancySceneState.getViewport().convertViewportToScreen(bounds);
bounds = convertToLocal(bounds);
destPoint.x = bounds.left;
destPoint.y = bounds.bottom + 1 - font->getFontHeight();
font->drawString(&_drawSurface, playerPasswordInput, destPoint.x, destPoint.y, bounds.width(), 0);
font->drawString(&_drawSurface, _playerPasswordInput, destPoint.x, destPoint.y, bounds.width(), 0);
_needsRedraw = true;
}

View File

@ -40,9 +40,9 @@ public:
enum SolveState { kNotSolved, kFailed, kSolved };
PasswordPuzzle(RenderObject &redrawFrom) :
RenderObject(redrawFrom),
passwordFieldIsActive(false),
playerHasHitReturn(false),
solveState(kNotSolved) {}
_passwordFieldIsActive(false),
_playerHasHitReturn(false),
_solveState(kNotSolved) {}
virtual ~PasswordPuzzle() {}
virtual void init() override;
@ -52,29 +52,29 @@ public:
virtual void handleInput(NancyInput &input) override;
virtual void onPause(bool pause) override;
uint16 fontID; // 0x00
Time cursorBlinkTime; // 0x2
Common::Rect nameBounds; // 0x4
Common::Rect passwordBounds; // 0x14
uint16 _fontID; // 0x00
Time _cursorBlinkTime; // 0x2
Common::Rect _nameBounds; // 0x4
Common::Rect _passwordBounds; // 0x14
// _screenPosition 0x24
Common::String name; // 0x34, 20 bytes long
Common::String password; // 0x48, 20 bytes long
SceneChangeDescription solveExitScene; // 0x5A
EventFlagDescription flagOnSolve; // 0x66
SoundDescription solveSound; // 0x69
SceneChangeDescription failExitScene; // 0x8B
EventFlagDescription flagOnFail; // 0x95
SoundDescription failSound; // 0x98
SceneChangeDescription exitScene; // 0xBA
EventFlagDescription flagOnExit; // 0xC4
Common::Rect exitHotspot; // 0xC7
Common::String _name; // 0x34, 20 bytes long
Common::String _password; // 0x48, 20 bytes long
SceneChangeDescription _solveExitScene; // 0x5A
EventFlagDescription _flagOnSolve; // 0x66
SoundDescription _solveSound; // 0x69
SceneChangeDescription _failExitScene; // 0x8B
EventFlagDescription _flagOnFail; // 0x95
SoundDescription _failSound; // 0x98
SceneChangeDescription _exitScene; // 0xBA
EventFlagDescription _flagOnExit; // 0xC4
Common::Rect _exitHotspot; // 0xC7
Common::String playerNameInput;
Common::String playerPasswordInput;
Time nextBlinkTime;
bool passwordFieldIsActive;
bool playerHasHitReturn;
SolveState solveState;
Common::String _playerNameInput;
Common::String _playerPasswordInput;
Time _nextBlinkTime;
bool _passwordFieldIsActive;
bool _playerHasHitReturn;
SolveState _solveState;
protected:
virtual Common::String getRecordTypeName() const override { return "PasswordPuzzle"; }

View File

@ -37,7 +37,7 @@
namespace Nancy {
namespace Action {
PlayPrimaryVideoChan0 *PlayPrimaryVideoChan0::activePrimaryVideo = nullptr;
PlayPrimaryVideoChan0 *PlayPrimaryVideoChan0::_activePrimaryVideo = nullptr;
void PlayPrimaryVideoChan0::ConditionFlag::read(Common::SeekableReadStream &stream) {
type = (ConditionType)stream.readByte();
@ -109,8 +109,8 @@ bool PlayPrimaryVideoChan0::ConditionFlags::isSatisfied() const {
PlayPrimaryVideoChan0::~PlayPrimaryVideoChan0() {
_decoder.close();
if (activePrimaryVideo == this) {
activePrimaryVideo = nullptr;
if (_activePrimaryVideo == this) {
_activePrimaryVideo = nullptr;
}
NancySceneState.setShouldClearTextbox(true);
@ -118,8 +118,8 @@ PlayPrimaryVideoChan0::~PlayPrimaryVideoChan0() {
}
void PlayPrimaryVideoChan0::init() {
_decoder.loadFile(videoName + ".avf");
_drawSurface.create(src.width(), src.height(), _decoder.getPixelFormat());
_decoder.loadFile(_videoName + ".avf");
_drawSurface.create(_src.width(), _src.height(), _decoder.getPixelFormat());
RenderObject::init();
@ -136,7 +136,7 @@ void PlayPrimaryVideoChan0::updateGraphics() {
}
if (_decoder.needsUpdate()) {
_drawSurface.blitFrom(*_decoder.decodeNextFrame(), src, Common::Point());
_drawSurface.blitFrom(*_decoder.decodeNextFrame(), _src, Common::Point());
_needsRedraw = true;
}
@ -156,34 +156,34 @@ void PlayPrimaryVideoChan0::readData(Common::SeekableReadStream &stream) {
char name[10];
stream.read(name, 10);
videoName = Common::String(name);
_videoName = Common::String(name);
stream.skip(0x13);
readRect(stream, src);
readRect(stream, _src);
readRect(stream, _screenPosition);
char *rawText = new char[1500]();
stream.read(rawText, 1500);
UI::Textbox::assembleTextLine(rawText, text, 1500);
UI::Textbox::assembleTextLine(rawText, _text, 1500);
delete[] rawText;
sound.read(stream, SoundDescription::kNormal);
responseGenericSound.read(stream, SoundDescription::kNormal);
_sound.read(stream, SoundDescription::kNormal);
_responseGenericSound.read(stream, SoundDescription::kNormal);
stream.skip(1);
conditionalResponseCharacterID = stream.readByte();
goodbyeResponseCharacterID = stream.readByte();
isDialogueExitScene = (NancyFlag)stream.readByte();
doNotPop = (NancyFlag)stream.readByte();
sceneChange.readData(stream);
_conditionalResponseCharacterID = stream.readByte();
_goodbyeResponseCharacterID = stream.readByte();
_isDialogueExitScene = (NancyFlag)stream.readByte();
_doNotPop = (NancyFlag)stream.readByte();
_sceneChange.readData(stream);
stream.seek(beginOffset + 0x69C);
uint16 numResponses = stream.readUint16LE();
if (numResponses > 0) {
for (uint i = 0; i < numResponses; ++i) {
responses.push_back(ResponseStruct());
ResponseStruct &response = responses[i];
_responses.push_back(ResponseStruct());
ResponseStruct &response = _responses[i];
response.conditionFlags.read(stream);
rawText = new char[400];
stream.read(rawText, 400);
@ -193,7 +193,7 @@ void PlayPrimaryVideoChan0::readData(Common::SeekableReadStream &stream) {
stream.read(name, 10);
response.soundName = name;
stream.skip(1);
response.sceneChange.readData(stream);
response._sceneChange.readData(stream);
response.flagDesc.label = stream.readSint16LE();
response.flagDesc.flag = (NancyFlag)stream.readByte();
@ -209,8 +209,8 @@ void PlayPrimaryVideoChan0::readData(Common::SeekableReadStream &stream) {
uint16 numFlagsStructs = stream.readUint16LE();
if (numFlagsStructs > 0) {
for (uint16 i = 0; i < numFlagsStructs; ++i) {
flagsStructs.push_back(FlagsStruct());
FlagsStruct &flagsStruct = flagsStructs.back();
_flagsStructs.push_back(FlagsStruct());
FlagsStruct &flagsStruct = _flagsStructs.back();
flagsStruct.conditions.read(stream);
flagsStruct.flagToSet.type = (ConditionFlag::ConditionType)stream.readByte();
flagsStruct.flagToSet.flag.label = stream.readSint16LE();
@ -220,36 +220,36 @@ void PlayPrimaryVideoChan0::readData(Common::SeekableReadStream &stream) {
}
void PlayPrimaryVideoChan0::execute() {
if (activePrimaryVideo != this && activePrimaryVideo != nullptr) {
if (_activePrimaryVideo != this && _activePrimaryVideo != nullptr) {
return;
}
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
g_nancy->sound->loadSound(sound);
g_nancy->sound->playSound(sound);
state = kRun;
activePrimaryVideo = this;
g_nancy->_sound->loadSound(_sound);
g_nancy->_sound->playSound(_sound);
_state = kRun;
_activePrimaryVideo = this;
// fall through
case kRun:
if (!hasDrawnTextbox) {
hasDrawnTextbox = true;
if (!_hasDrawnTextbox) {
_hasDrawnTextbox = true;
NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().addTextLine(text);
NancySceneState.getTextbox().addTextLine(_text);
// Add responses when conditions have been satisfied
if (conditionalResponseCharacterID != 10) {
if (_conditionalResponseCharacterID != 10) {
addConditionalResponses();
}
if (goodbyeResponseCharacterID != 10) {
if (_goodbyeResponseCharacterID != 10) {
addGoodbye();
}
for (uint i = 0; i < responses.size(); ++i) {
auto &res = responses[i];
for (uint i = 0; i < _responses.size(); ++i) {
auto &res = _responses[i];
if (res.conditionFlags.isSatisfied()) {
NancySceneState.getTextbox().addTextLine(res.text);
@ -257,56 +257,56 @@ void PlayPrimaryVideoChan0::execute() {
}
}
if (!g_nancy->sound->isSoundPlaying(sound) && _decoder.endOfVideo()) {
g_nancy->sound->stopSound(sound);
if (!g_nancy->_sound->isSoundPlaying(_sound) && _decoder.endOfVideo()) {
g_nancy->_sound->stopSound(_sound);
if (responses.size() == 0) {
if (_responses.size() == 0) {
// NPC has finished talking with no responses available, auto-advance to next scene
state = kActionTrigger;
_state = kActionTrigger;
} else {
// NPC has finished talking, we have responses
for (uint i = 0; i < 30; ++i) {
if (NancySceneState.getLogicCondition(i, kTrue)) {
pickedResponse = i;
_pickedResponse = i;
break;
}
}
if (pickedResponse != -1) {
// Player has picked response, play sound file and change state
responseGenericSound.name = responses[pickedResponse].soundName;
if (_pickedResponse != -1) {
// Player has picked response, play sound file and change _state
_responseGenericSound.name = _responses[_pickedResponse].soundName;
// TODO this is probably not correct
g_nancy->sound->loadSound(responseGenericSound);
g_nancy->sound->playSound(responseGenericSound);
state = kActionTrigger;
g_nancy->_sound->loadSound(_responseGenericSound);
g_nancy->_sound->playSound(_responseGenericSound);
_state = kActionTrigger;
}
}
}
break;
case kActionTrigger:
// process flags structs
for (auto flags : flagsStructs) {
for (auto flags : _flagsStructs) {
if (flags.conditions.isSatisfied()) {
flags.flagToSet.set();
}
}
if (pickedResponse != -1) {
if (_pickedResponse != -1) {
// Set response's event flag, if any
NancySceneState.setEventFlag(responses[pickedResponse].flagDesc);
NancySceneState.setEventFlag(_responses[_pickedResponse].flagDesc);
}
if (!g_nancy->sound->isSoundPlaying(responseGenericSound)) {
g_nancy->sound->stopSound(responseGenericSound);
if (!g_nancy->_sound->isSoundPlaying(_responseGenericSound)) {
g_nancy->_sound->stopSound(_responseGenericSound);
if (pickedResponse != -1) {
NancySceneState.changeScene(responses[pickedResponse].sceneChange);
if (_pickedResponse != -1) {
NancySceneState.changeScene(_responses[_pickedResponse]._sceneChange);
} else {
// Evaluate scene branch structs here
if (isDialogueExitScene == kFalse) {
NancySceneState.changeScene(sceneChange);
} else if (doNotPop == kFalse) {
if (_isDialogueExitScene == kFalse) {
NancySceneState.changeScene(_sceneChange);
} else if (_doNotPop == kFalse) {
// Exit dialogue
NancySceneState.popScene();
}
@ -321,7 +321,7 @@ void PlayPrimaryVideoChan0::execute() {
void PlayPrimaryVideoChan0::addConditionalResponses() {
for (auto &res : nancy1ConditionalResponses) {
if (res.characterID == conditionalResponseCharacterID) {
if (res.characterID == _conditionalResponseCharacterID) {
bool isSatisfied = true;
for (auto & cond : res.conditions) {
if (cond.label == -1) {
@ -342,12 +342,12 @@ void PlayPrimaryVideoChan0::addConditionalResponses() {
file.seek(nancy1ResponseBaseFileOffset + res.fileOffset);
file.read(snd, 8);
responses.push_back(ResponseStruct());
ResponseStruct &newResponse = responses.back();
_responses.push_back(ResponseStruct());
ResponseStruct &newResponse = _responses.back();
newResponse.soundName = snd;
newResponse.text = file.readString();
newResponse.sceneChange.sceneID = res.sceneID;
newResponse.sceneChange.doNotStartSound = true;
newResponse._sceneChange.sceneID = res.sceneID;
newResponse._sceneChange.doNotStartSound = true;
file.close();
}
@ -357,7 +357,7 @@ void PlayPrimaryVideoChan0::addConditionalResponses() {
void PlayPrimaryVideoChan0::addGoodbye() {
for (auto &res : nancy1Goodbyes) {
if (res.characterID == goodbyeResponseCharacterID) {
if (res.characterID == _goodbyeResponseCharacterID) {
Common::File file;
char snd[10];
@ -365,13 +365,13 @@ void PlayPrimaryVideoChan0::addGoodbye() {
file.seek(nancy1ResponseBaseFileOffset + res.fileOffset);
file.read(snd, 8);
responses.push_back(ResponseStruct());
ResponseStruct &newResponse = responses.back();
_responses.push_back(ResponseStruct());
ResponseStruct &newResponse = _responses.back();
newResponse.soundName = snd;
newResponse.text = file.readString();
// response is picked randomly
newResponse.sceneChange.sceneID = res.sceneIDs[g_nancy->randomSource->getRandomNumber(3)];
newResponse.sceneChange.doNotStartSound = true;
newResponse._sceneChange.sceneID = res.sceneIDs[g_nancy->_randomSource->getRandomNumber(3)];
newResponse._sceneChange.doNotStartSound = true;
file.close();
}

View File

@ -64,7 +64,7 @@ struct ResponseStruct {
ConditionFlags conditionFlags; // 0x01
Common::String text; // 0x06
Common::String soundName; // 0x196
SceneChangeDescription sceneChange; // 0x1A0
SceneChangeDescription _sceneChange; // 0x1A0
EventFlagDescription flagDesc; // 0x1A8
};
@ -88,30 +88,30 @@ public:
void addConditionalResponses();
void addGoodbye();
Common::String videoName; // 0x00
Common::Rect src; // 0x1D
Common::String _videoName; // 0x00
Common::Rect _src; // 0x1D
// _screenPosition 0x2D
Common::String text; // 0x3D
Common::String _text; // 0x3D
SoundDescription sound; // 0x619
SoundDescription responseGenericSound; // 0x63B
SoundDescription _sound; // 0x619
SoundDescription _responseGenericSound; // 0x63B
byte conditionalResponseCharacterID; // 0x65E
byte goodbyeResponseCharacterID; // 0x65F
NancyFlag isDialogueExitScene; // 0x660
NancyFlag doNotPop; // 0x661
SceneChangeDescription sceneChange; // 0x662
byte _conditionalResponseCharacterID; // 0x65E
byte _goodbyeResponseCharacterID; // 0x65F
NancyFlag _isDialogueExitScene; // 0x660
NancyFlag _doNotPop; // 0x661
SceneChangeDescription _sceneChange; // 0x662
Common::Array<ResponseStruct> responses; // 0x69E
Common::Array<FlagsStruct> flagsStructs; // 0x6AA
Common::Array<ResponseStruct> _responses; // 0x69E
Common::Array<FlagsStruct> _flagsStructs; // 0x6AA
AVFDecoder _decoder;
bool hasDrawnTextbox = false;
int16 pickedResponse = -1;
bool _hasDrawnTextbox = false;
int16 _pickedResponse = -1;
// Used to avoid clashes between multiple instances in the same scene
static PlayPrimaryVideoChan0 *activePrimaryVideo;
static PlayPrimaryVideoChan0 *_activePrimaryVideo;
protected:
virtual Common::String getRecordTypeName() const override { return "PlayPrimaryVideoChan0"; }

View File

@ -41,12 +41,12 @@ namespace Nancy {
namespace Action {
void SceneChange::readData(Common::SeekableReadStream &stream) {
sceneChange.readData(stream);
_sceneChange.readData(stream);
}
void SceneChange::execute() {
NancySceneState.changeScene(sceneChange);
isDone = true;
NancySceneState.changeScene(_sceneChange);
_isDone = true;
}
void HotMultiframeSceneChange::readData(Common::SeekableReadStream &stream) {
@ -54,24 +54,24 @@ void HotMultiframeSceneChange::readData(Common::SeekableReadStream &stream) {
uint16 numHotspots = stream.readUint16LE();
for (uint i = 0; i < numHotspots; ++i) {
hotspots.push_back(HotspotDescription());
HotspotDescription &newDesc = hotspots[i];
_hotspots.push_back(HotspotDescription());
HotspotDescription &newDesc = _hotspots[i];
newDesc.readData(stream);
}
}
void HotMultiframeSceneChange::execute() {
switch (state) {
switch (_state) {
case kBegin:
// turn main rendering on
state = kRun;
_state = kRun;
// fall through
case kRun:
hasHotspot = false;
for (uint i = 0; i < hotspots.size(); ++i) {
if (hotspots[i].frameID == NancySceneState.getSceneInfo().frameID) {
hasHotspot = true;
hotspot = hotspots[i].coords;
_hasHotspot = false;
for (uint i = 0; i < _hotspots.size(); ++i) {
if (_hotspots[i].frameID == NancySceneState.getSceneInfo().frameID) {
_hasHotspot = true;
_hotspot = _hotspots[i].coords;
}
}
break;
@ -83,20 +83,20 @@ void HotMultiframeSceneChange::execute() {
void Hot1FrSceneChange::readData(Common::SeekableReadStream &stream) {
SceneChange::readData(stream);
hotspotDesc.readData(stream);
_hotspotDesc.readData(stream);
}
void Hot1FrSceneChange::execute() {
switch (state) {
switch (_state) {
case kBegin:
hotspot = hotspotDesc.coords;
state = kRun;
_hotspot = _hotspotDesc.coords;
_state = kRun;
// fall through
case kRun:
if (hotspotDesc.frameID == NancySceneState.getSceneInfo().frameID) {
hasHotspot = true;
if (_hotspotDesc.frameID == NancySceneState.getSceneInfo().frameID) {
_hasHotspot = true;
} else {
hasHotspot = false;
_hasHotspot = false;
}
break;
case kActionTrigger:
@ -124,7 +124,7 @@ void MapCall::readData(Common::SeekableReadStream &stream) {
}
void MapCall::execute() {
execType = kRepeating;
_execType = kRepeating;
NancySceneState.requestStateChange(NancyEngine::kMap);
finishExecution();
}
@ -134,14 +134,14 @@ void MapCallHot1Fr::readData(Common::SeekableReadStream &stream) {
}
void MapCallHot1Fr::execute() {
switch (state) {
switch (_state) {
case kBegin:
hotspot = hotspotDesc.coords;
state = kRun;
_hotspot = _hotspotDesc.coords;
_state = kRun;
// fall through
case kRun:
if (hotspotDesc.frameID == NancySceneState.getSceneInfo().frameID) {
hasHotspot = true;
if (_hotspotDesc.frameID == NancySceneState.getSceneInfo().frameID) {
_hasHotspot = true;
}
break;
case kActionTrigger:
@ -153,22 +153,22 @@ void MapCallHot1Fr::execute() {
void MapCallHotMultiframe::readData(Common::SeekableReadStream &stream) {
uint16 numDescs = stream.readUint16LE();
for (uint i = 0; i < numDescs; ++i) {
hotspots.push_back(HotspotDescription());
hotspots[i].readData(stream);
_hotspots.push_back(HotspotDescription());
_hotspots[i].readData(stream);
}
}
void MapCallHotMultiframe::execute() {
switch (state) {
switch (_state) {
case kBegin:
state = kRun;
_state = kRun;
// fall through
case kRun:
hasHotspot = false;
for (uint i = 0; i < hotspots.size(); ++i) {
if (hotspots[i].frameID == NancySceneState.getSceneInfo().frameID) {
hasHotspot = true;
hotspot = hotspots[i].coords;
_hasHotspot = false;
for (uint i = 0; i < _hotspots.size(); ++i) {
if (_hotspots[i].frameID == NancySceneState.getSceneInfo().frameID) {
_hasHotspot = true;
_hotspot = _hotspots[i].coords;
}
}
break;
@ -229,7 +229,7 @@ void ResetAndStartTimer::readData(Common::SeekableReadStream &stream) {
void ResetAndStartTimer::execute() {
NancySceneState.resetAndStartTimer();
isDone = true;
_isDone = true;
}
void StopTimer::readData(Common::SeekableReadStream &stream) {
@ -238,16 +238,16 @@ void StopTimer::readData(Common::SeekableReadStream &stream) {
void StopTimer::execute() {
NancySceneState.stopTimer();
isDone = true;
_isDone = true;
}
void EventFlags::readData(Common::SeekableReadStream &stream) {
flags.readData(stream);
_flags.readData(stream);
}
void EventFlags::execute() {
flags.execute();
isDone = true;
_flags.execute();
_isDone = true;
}
void EventFlagsMultiHS::readData(Common::SeekableReadStream &stream) {
@ -255,31 +255,31 @@ void EventFlagsMultiHS::readData(Common::SeekableReadStream &stream) {
uint16 numHotspots = stream.readUint16LE();
for (uint16 i = 0; i < numHotspots; ++i) {
hotspots.push_back(HotspotDescription());
HotspotDescription &newDesc = hotspots[i];
_hotspots.push_back(HotspotDescription());
HotspotDescription &newDesc = _hotspots[i];
newDesc.readData(stream);
}
}
void EventFlagsMultiHS::execute() {
switch (state) {
switch (_state) {
case kBegin:
// turn main rendering on
state = kRun;
_state = kRun;
// fall through
case kRun:
hasHotspot = false;
_hasHotspot = false;
for (uint i = 0; i < hotspots.size(); ++i) {
if (hotspots[i].frameID == NancySceneState.getSceneInfo().frameID) {
hasHotspot = true;
hotspot = hotspots[i].coords;
for (uint i = 0; i < _hotspots.size(); ++i) {
if (_hotspots[i].frameID == NancySceneState.getSceneInfo().frameID) {
_hasHotspot = true;
_hotspot = _hotspots[i].coords;
}
}
break;
case kActionTrigger:
hasHotspot = false;
_hasHotspot = false;
EventFlags::execute();
finishExecution();
break;
@ -291,10 +291,10 @@ void LoseGame::readData(Common::SeekableReadStream &stream) {
}
void LoseGame::execute() {
g_nancy->sound->stopAndUnloadSpecificSounds();
g_nancy->_sound->stopAndUnloadSpecificSounds();
g_nancy->setState(NancyEngine::kMainMenu);
NancySceneState.resetStateToInit();
isDone = true;
_isDone = true;
}
void PushScene::readData(Common::SeekableReadStream &stream) {
@ -310,24 +310,24 @@ void WinGame::readData(Common::SeekableReadStream &stream) {
}
void WinGame::execute() {
g_nancy->sound->stopAndUnloadSpecificSounds();
g_nancy->_sound->stopAndUnloadSpecificSounds();
g_nancy->setState(NancyEngine::kCredits, NancyEngine::kMainMenu);
// TODO replace with destroy()?
NancySceneState.resetStateToInit();
isDone = true;
_isDone = true;
}
void AddInventoryNoHS::readData(Common::SeekableReadStream &stream) {
itemID = stream.readUint16LE();
_itemID = stream.readUint16LE();
}
void AddInventoryNoHS::execute() {
if (NancySceneState.hasItem(itemID) == kFalse) {
NancySceneState.addItemToInventory(itemID);
if (NancySceneState.hasItem(_itemID) == kFalse) {
NancySceneState.addItemToInventory(_itemID);
}
isDone = true;
_isDone = true;
}
void RemoveInventoryNoHS::readData(Common::SeekableReadStream &stream) {
@ -335,67 +335,67 @@ void RemoveInventoryNoHS::readData(Common::SeekableReadStream &stream) {
}
void DifficultyLevel::readData(Common::SeekableReadStream &stream) {
difficulty = stream.readUint16LE();
flag.label = stream.readSint16LE();
flag.flag = (NancyFlag)stream.readUint16LE();
_difficulty = stream.readUint16LE();
_flag.label = stream.readSint16LE();
_flag.flag = (NancyFlag)stream.readUint16LE();
}
void DifficultyLevel::execute() {
NancySceneState.setDifficulty(difficulty);
NancySceneState.setEventFlag(flag);
isDone = true;
NancySceneState.setDifficulty(_difficulty);
NancySceneState.setEventFlag(_flag);
_isDone = true;
}
void ShowInventoryItem::init() {
g_nancy->resource->loadImage(imageName, _fullSurface);
g_nancy->_resource->loadImage(_imageName, _fullSurface);
_drawSurface.create(_fullSurface, bitmaps[0].src);
_drawSurface.create(_fullSurface, _bitmaps[0].src);
RenderObject::init();
}
void ShowInventoryItem::readData(Common::SeekableReadStream &stream) {
objectID = stream.readUint16LE();
_objectID = stream.readUint16LE();
char name[10];
stream.read(name, 10);
imageName = Common::String(name);
_imageName = Common::String(name);
uint16 numFrames = stream.readUint16LE();
for (uint i = 0; i < numFrames; ++i) {
bitmaps.push_back(BitmapDescription());
bitmaps[i].readData(stream);
_bitmaps.push_back(BitmapDescription());
_bitmaps[i].readData(stream);
}
}
void ShowInventoryItem::execute() {
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
state = kRun;
_state = kRun;
// fall through
case kRun: {
int newFrame = -1;
for (uint i = 0; i < bitmaps.size(); ++i) {
if (bitmaps[i].frameID == NancySceneState.getSceneInfo().frameID) {
for (uint i = 0; i < _bitmaps.size(); ++i) {
if (_bitmaps[i].frameID == NancySceneState.getSceneInfo().frameID) {
newFrame = i;
break;
}
}
if (newFrame != drawnFrameID) {
drawnFrameID = newFrame;
if (newFrame != _drawnFrameID) {
_drawnFrameID = newFrame;
if (newFrame != -1) {
hasHotspot = true;
hotspot = bitmaps[newFrame].dest;
_drawSurface.create(_fullSurface, bitmaps[newFrame].src);
_screenPosition = bitmaps[newFrame].dest;
_hasHotspot = true;
_hotspot = _bitmaps[newFrame].dest;
_drawSurface.create(_fullSurface, _bitmaps[newFrame].src);
_screenPosition = _bitmaps[newFrame].dest;
setVisible(true);
} else {
hasHotspot = false;
_hasHotspot = false;
setVisible(false);
}
}
@ -403,10 +403,10 @@ void ShowInventoryItem::execute() {
break;
}
case kActionTrigger:
g_nancy->sound->playSound(24); // Hardcoded by original engine
NancySceneState.addItemToInventory(objectID);
g_nancy->_sound->playSound(24); // Hardcoded by original engine
NancySceneState.addItemToInventory(_objectID);
setVisible(false);
hasHotspot = false;
_hasHotspot = false;
finishExecution();
break;
}
@ -419,33 +419,33 @@ void ShowInventoryItem::onPause(bool pause) {
}
void PlayDigiSoundAndDie::readData(Common::SeekableReadStream &stream) {
sound.read(stream, SoundDescription::kDIGI);
sceneChange.readData(stream);
flagOnTrigger.label = stream.readSint16LE();
flagOnTrigger.flag = (NancyFlag)stream.readByte();
_sound.read(stream, SoundDescription::kDIGI);
_sceneChange.readData(stream);
_flagOnTrigger.label = stream.readSint16LE();
_flagOnTrigger.flag = (NancyFlag)stream.readByte();
stream.skip(2);
}
void PlayDigiSoundAndDie::execute() {
switch (state) {
switch (_state) {
case kBegin:
g_nancy->sound->loadSound(sound);
g_nancy->sound->playSound(sound);
state = kRun;
g_nancy->_sound->loadSound(_sound);
g_nancy->_sound->playSound(_sound);
_state = kRun;
break;
case kRun:
if (!g_nancy->sound->isSoundPlaying(sound)) {
state = kActionTrigger;
if (!g_nancy->_sound->isSoundPlaying(_sound)) {
_state = kActionTrigger;
}
break;
case kActionTrigger:
if (sceneChange.sceneID != 9999) {
NancySceneState.changeScene(sceneChange);
if (_sceneChange.sceneID != 9999) {
NancySceneState.changeScene(_sceneChange);
}
NancySceneState.setEventFlag(flagOnTrigger);
g_nancy->sound->stopSound(sound);
NancySceneState.setEventFlag(_flagOnTrigger);
g_nancy->_sound->stopSound(_sound);
finishExecution();
break;
@ -457,33 +457,33 @@ void PlaySoundPanFrameAnchorAndDie::readData(Common::SeekableReadStream &stream)
}
void PlaySoundMultiHS::readData(Common::SeekableReadStream &stream) {
sound.read(stream, SoundDescription::kNormal);
sceneChange.readData(stream);
flag.label = stream.readSint16LE();
flag.flag = (NancyFlag)stream.readByte();
_sound.read(stream, SoundDescription::kNormal);
_sceneChange.readData(stream);
_flag.label = stream.readSint16LE();
_flag.flag = (NancyFlag)stream.readByte();
stream.skip(2);
uint16 numHotspots = stream.readUint16LE();
for (uint i = 0; i < numHotspots; ++i) {
hotspots.push_back(HotspotDescription());
hotspots.back().frameID = stream.readUint16LE();
readRect(stream, hotspots.back().coords);
_hotspots.push_back(HotspotDescription());
_hotspots.back().frameID = stream.readUint16LE();
readRect(stream, _hotspots.back().coords);
}
}
void PlaySoundMultiHS::execute() {
switch (state) {
switch (_state) {
case kBegin:
state = kRun;
_state = kRun;
// fall through
case kRun: {
hasHotspot = false;
_hasHotspot = false;
uint currentFrame = NancySceneState.getSceneInfo().frameID;
for (uint i = 0; i < hotspots.size(); ++i) {
if (hotspots[i].frameID == currentFrame) {
hotspot = hotspots[i].coords;
hasHotspot = true;
for (uint i = 0; i < _hotspots.size(); ++i) {
if (_hotspots[i].frameID == currentFrame) {
_hotspot = _hotspots[i].coords;
_hasHotspot = true;
break;
}
}
@ -491,22 +491,22 @@ void PlaySoundMultiHS::execute() {
break;
}
case kActionTrigger:
g_nancy->sound->loadSound(sound);
g_nancy->sound->playSound(sound);
NancySceneState.changeScene(sceneChange);
NancySceneState.setEventFlag(flag);
g_nancy->_sound->loadSound(_sound);
g_nancy->_sound->playSound(_sound);
NancySceneState.changeScene(_sceneChange);
NancySceneState.setEventFlag(_flag);
finishExecution();
break;
}
}
void HintSystem::readData(Common::SeekableReadStream &stream) {
characterID = stream.readByte();
genericSound.read(stream, SoundDescription::kNormal);
_characterID = stream.readByte();
_genericSound.read(stream, SoundDescription::kNormal);
}
void HintSystem::execute() {
switch (state) {
switch (_state) {
case kBegin:
if (NancySceneState.getHintsRemaining() > 0) {
selectHint();
@ -515,35 +515,35 @@ void HintSystem::execute() {
}
NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().addTextLine(text);
NancySceneState.getTextbox().addTextLine(_text);
g_nancy->sound->loadSound(genericSound);
g_nancy->sound->playSound(genericSound);
state = kRun;
g_nancy->_sound->loadSound(_genericSound);
g_nancy->_sound->playSound(_genericSound);
_state = kRun;
break;
case kRun:
if (!g_nancy->sound->isSoundPlaying(genericSound)) {
g_nancy->sound->stopSound(genericSound);
state = kActionTrigger;
if (!g_nancy->_sound->isSoundPlaying(_genericSound)) {
g_nancy->_sound->stopSound(_genericSound);
_state = kActionTrigger;
} else {
break;
}
// fall through
case kActionTrigger:
NancySceneState.useHint(hintID, hintWeight);
NancySceneState.useHint(_hintID, _hintWeight);
NancySceneState.getTextbox().clear();
NancySceneState.changeScene(sceneChange);
NancySceneState.changeScene(_sceneChange);
isDone = true;
_isDone = true;
break;
}
}
void HintSystem::selectHint() {
for (auto &hint : nancy1Hints) {
if (hint.characterID != characterID) {
if (hint.characterID != _characterID) {
continue;
}
@ -580,8 +580,8 @@ void HintSystem::selectHint() {
void HintSystem::getHint(uint hint, uint difficulty) {
uint fileOffset;
if (characterID < 3) {
fileOffset = nancy1HintOffsets[characterID];
if (_characterID < 3) {
fileOffset = nancy1HintOffsets[_characterID];
}
fileOffset += 0x288 * hint;
@ -590,26 +590,26 @@ void HintSystem::getHint(uint hint, uint difficulty) {
file.open("game.exe");
file.seek(fileOffset);
hintID = file.readSint16LE();
hintWeight = file.readSint16LE();
_hintID = file.readSint16LE();
_hintWeight = file.readSint16LE();
file.seek(difficulty * 10, SEEK_CUR);
char soundName[10];
file.read(soundName, 10);
genericSound.name = soundName;
_genericSound.name = soundName;
file.seek(-(difficulty * 10) - 10, SEEK_CUR);
file.seek(30 + difficulty * 200, SEEK_CUR);
char textBuf[200];
file.read(textBuf, 200);
text = textBuf;
_text = textBuf;
file.seek(-(difficulty * 200) - 200, SEEK_CUR);
file.seek(600, SEEK_CUR);
sceneChange.readData(file);
_sceneChange.readData(file);
}
}

View File

@ -44,7 +44,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
SceneChangeDescription sceneChange;
SceneChangeDescription _sceneChange;
protected:
virtual Common::String getRecordTypeName() const override { return "SceneChange"; }
@ -55,7 +55,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
Common::Array<HotspotDescription> hotspots;
Common::Array<HotspotDescription> _hotspots;
protected:
virtual Common::String getRecordTypeName() const override { return "HotMultiframeSceneChange"; }
@ -66,7 +66,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
HotspotDescription hotspotDesc;
HotspotDescription _hotspotDesc;
protected:
virtual Common::String getRecordTypeName() const override { return "Hot1FrSceneChange"; }
@ -100,7 +100,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
// TODO add a Start and Stop subclass
byte type = 0;
byte _type = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "StartStopPlayerScrolling"; }
@ -122,7 +122,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
HotspotDescription hotspotDesc;
HotspotDescription _hotspotDesc;
protected:
virtual Common::String getRecordTypeName() const override { return "MapCallHot1Fr"; }
@ -133,7 +133,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
Common::Array<HotspotDescription> hotspots;
Common::Array<HotspotDescription> _hotspots;
protected:
virtual Common::String getRecordTypeName() const override { return "MapCallHotMultiframe"; }
@ -242,7 +242,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
MultiEventFlagDescription flags;
MultiEventFlagDescription _flags;
protected:
virtual Common::String getRecordTypeName() const override { return "EventFlags"; }
@ -253,7 +253,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
Common::Array<HotspotDescription> hotspots;
Common::Array<HotspotDescription> _hotspots;
protected:
virtual Common::String getRecordTypeName() const override { return "EventFlagsMultiHS"; }
@ -298,7 +298,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
uint itemID;
uint _itemID;
protected:
virtual Common::String getRecordTypeName() const override { return "AddInventoryNoHS"; }
@ -317,8 +317,8 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
uint16 difficulty = 0;
EventFlagDescription flag;
uint16 _difficulty = 0;
EventFlagDescription _flag;
protected:
virtual Common::String getRecordTypeName() const override { return "DifficultyLevel"; }
@ -335,11 +335,11 @@ public:
virtual void init() override;
virtual void onPause(bool pause) override;
uint16 objectID = 0;
Common::String imageName;
Common::Array<BitmapDescription> bitmaps;
uint16 _objectID = 0;
Common::String _imageName;
Common::Array<BitmapDescription> _bitmaps;
int16 drawnFrameID = -1;
int16 _drawnFrameID = -1;
Graphics::ManagedSurface _fullSurface;
protected:
@ -355,9 +355,9 @@ public:
virtual void execute() override;
// TODO subclass into Play and Stop (?)
SoundDescription sound;
SceneChangeDescription sceneChange;
EventFlagDescription flagOnTrigger;
SoundDescription _sound;
SceneChangeDescription _sceneChange;
EventFlagDescription _flagOnTrigger;
protected:
virtual Common::String getRecordTypeName() const override { return "PlayDigiSoundAndDie"; }
@ -376,10 +376,10 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
SoundDescription sound; // 0x0
SceneChangeDescription sceneChange; // 0x22
EventFlagDescription flag; // 0x2A
Common::Array<HotspotDescription> hotspots; // 0x31
SoundDescription _sound; // 0x0
SceneChangeDescription _sceneChange; // 0x22
EventFlagDescription _flag; // 0x2A
Common::Array<HotspotDescription> _hotspots; // 0x31
protected:
virtual Common::String getRecordTypeName() const override { return "PlaySoundMultiHS"; }
@ -390,13 +390,13 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
byte characterID; // 0x00
SoundDescription genericSound; // 0x01
byte _characterID; // 0x00
SoundDescription _genericSound; // 0x01
Common::String text;
SceneChangeDescription sceneChange;
uint16 hintID;
int16 hintWeight;
Common::String _text;
SceneChangeDescription _sceneChange;
uint16 _hintID;
int16 _hintWeight;
void selectHint();
void getHint(uint hint, uint difficulty);

View File

@ -40,121 +40,121 @@ void RotatingLockPuzzle::init() {
setTransparent(true);
g_nancy->resource->loadImage(imageName, image);
g_nancy->_resource->loadImage(_imageName, _image);
}
void RotatingLockPuzzle::readData(Common::SeekableReadStream &stream) {
char buf[10];
stream.read(buf, 10);
imageName = buf;
_imageName = buf;
uint numDials = stream.readUint16LE();
for (uint i = 0; i < 10; ++i) {
srcRects.push_back(Common::Rect());
readRect(stream, srcRects.back());
_srcRects.push_back(Common::Rect());
readRect(stream, _srcRects.back());
}
for (uint i = 0; i < numDials; ++i) {
destRects.push_back(Common::Rect());
readRect(stream, destRects.back());
_destRects.push_back(Common::Rect());
readRect(stream, _destRects.back());
if (i == 0) {
_screenPosition = destRects.back();
_screenPosition = _destRects.back();
} else {
_screenPosition.extend(destRects.back());
_screenPosition.extend(_destRects.back());
}
}
stream.skip((8 - numDials) * 16);
for (uint i = 0; i < numDials; ++i) {
upHotspots.push_back(Common::Rect());
readRect(stream, upHotspots.back());
_upHotspots.push_back(Common::Rect());
readRect(stream, _upHotspots.back());
}
stream.skip((8 - numDials) * 16);
for (uint i = 0; i < numDials; ++i) {
downHotspots.push_back(Common::Rect());
readRect(stream, downHotspots.back());
_downHotspots.push_back(Common::Rect());
readRect(stream, _downHotspots.back());
}
stream.skip((8 - numDials) * 16);
for (uint i = 0; i < numDials; ++i) {
correctSequence.push_back(stream.readByte());
_correctSequence.push_back(stream.readByte());
}
stream.skip(8 - numDials);
clickSound.read(stream, SoundDescription::kNormal);
solveExitScene.readData(stream);
_clickSound.read(stream, SoundDescription::kNormal);
_solveExitScene.readData(stream);
stream.skip(2); // shouldStopRendering, useless
flagOnSolve.label = stream.readSint16LE();
flagOnSolve.flag = (NancyFlag)stream.readByte();
solveSoundDelay = stream.readUint16LE();
solveSound.read(stream, SoundDescription::kNormal);
exitScene.readData(stream);
_flagOnSolve.label = stream.readSint16LE();
_flagOnSolve.flag = (NancyFlag)stream.readByte();
_solveSoundDelay = stream.readUint16LE();
_solveSound.read(stream, SoundDescription::kNormal);
_exitScene.readData(stream);
stream.skip(2); // shouldStopRendering, useless
flagOnExit.label = stream.readSint16LE();
flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, exitHotspot);
_flagOnExit.label = stream.readSint16LE();
_flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, _exitHotspot);
}
void RotatingLockPuzzle::execute() {
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
for (uint i = 0; i < correctSequence.size(); ++i) {
currentSequence.push_back(g_nancy->randomSource->getRandomNumber(9));
for (uint i = 0; i < _correctSequence.size(); ++i) {
_currentSequence.push_back(g_nancy->_randomSource->getRandomNumber(9));
drawDial(i);
}
g_nancy->sound->loadSound(clickSound);
g_nancy->sound->loadSound(solveSound);
state = kRun;
g_nancy->_sound->loadSound(_clickSound);
g_nancy->_sound->loadSound(_solveSound);
_state = kRun;
// fall through
case kRun:
switch (solveState) {
switch (_solveState) {
case kNotSolved:
for (uint i = 0; i < correctSequence.size(); ++i) {
if (currentSequence[i] != (int16)correctSequence[i]) {
for (uint i = 0; i < _correctSequence.size(); ++i) {
if (_currentSequence[i] != (int16)_correctSequence[i]) {
return;
}
}
NancySceneState.setEventFlag(flagOnSolve);
solveSoundPlayTime = g_nancy->getTotalPlayTime() + solveSoundDelay * 1000;
solveState = kPlaySound;
NancySceneState.setEventFlag(_flagOnSolve);
_solveSoundPlayTime = g_nancy->getTotalPlayTime() + _solveSoundDelay * 1000;
_solveState = kPlaySound;
// fall through
case kPlaySound:
if (g_nancy->getTotalPlayTime() <= solveSoundPlayTime) {
if (g_nancy->getTotalPlayTime() <= _solveSoundPlayTime) {
break;
}
g_nancy->sound->playSound(solveSound);
solveState = kWaitForSound;
g_nancy->_sound->playSound(_solveSound);
_solveState = kWaitForSound;
break;
case kWaitForSound:
if (!g_nancy->sound->isSoundPlaying(solveSound)) {
state = kActionTrigger;
if (!g_nancy->_sound->isSoundPlaying(_solveSound)) {
_state = kActionTrigger;
}
break;
}
break;
case kActionTrigger:
g_nancy->sound->stopSound(clickSound);
g_nancy->sound->stopSound(solveSound);
g_nancy->_sound->stopSound(_clickSound);
g_nancy->_sound->stopSound(_solveSound);
if (solveState == kNotSolved) {
NancySceneState.changeScene(exitScene);
NancySceneState.setEventFlag(flagOnExit);
if (_solveState == kNotSolved) {
NancySceneState.changeScene(_exitScene);
NancySceneState.setEventFlag(_flagOnExit);
} else {
NancySceneState.changeScene(solveExitScene);
NancySceneState.changeScene(_solveExitScene);
}
finishExecution();
@ -162,28 +162,28 @@ void RotatingLockPuzzle::execute() {
}
void RotatingLockPuzzle::handleInput(NancyInput &input) {
if (solveState != kNotSolved) {
if (_solveState != kNotSolved) {
return;
}
if (NancySceneState.getViewport().convertViewportToScreen(exitHotspot).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kExitArrow);
if (NancySceneState.getViewport().convertViewportToScreen(_exitHotspot).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kExitArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
state = kActionTrigger;
_state = kActionTrigger;
}
return;
}
for (uint i = 0; i < upHotspots.size(); ++i) {
if (NancySceneState.getViewport().convertViewportToScreen(upHotspots[i]).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspot);
for (uint i = 0; i < _upHotspots.size(); ++i) {
if (NancySceneState.getViewport().convertViewportToScreen(_upHotspots[i]).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspot);
if (input.input & NancyInput::kLeftMouseButtonUp) {
g_nancy->sound->playSound(clickSound);
g_nancy->_sound->playSound(_clickSound);
currentSequence[i] = ++currentSequence[i] > 9 ? 0 : currentSequence[i];
_currentSequence[i] = ++_currentSequence[i] > 9 ? 0 : _currentSequence[i];
drawDial(i);
}
@ -191,16 +191,16 @@ void RotatingLockPuzzle::handleInput(NancyInput &input) {
}
}
for (uint i = 0; i < downHotspots.size(); ++i) {
if (NancySceneState.getViewport().convertViewportToScreen(downHotspots[i]).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspot);
for (uint i = 0; i < _downHotspots.size(); ++i) {
if (NancySceneState.getViewport().convertViewportToScreen(_downHotspots[i]).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspot);
if (input.input & NancyInput::kLeftMouseButtonUp) {
g_nancy->sound->playSound(clickSound);
g_nancy->_sound->playSound(_clickSound);
int8 n = currentSequence[i];
int8 n = _currentSequence[i];
n = --n < 0 ? 9 : n;
currentSequence[i] = n;
_currentSequence[i] = n;
drawDial(i);
}
@ -216,8 +216,8 @@ void RotatingLockPuzzle::onPause(bool pause) {
}
void RotatingLockPuzzle::drawDial(uint id) {
Common::Point destPoint(destRects[id].left - _screenPosition.left, destRects[id].top - _screenPosition.top);
_drawSurface.blitFrom(image, srcRects[currentSequence[id]], destPoint);
Common::Point destPoint(_destRects[id].left - _screenPosition.left, _destRects[id].top - _screenPosition.top);
_drawSurface.blitFrom(_image, _srcRects[_currentSequence[id]], destPoint);
_needsRedraw = true;
}

View File

@ -49,26 +49,26 @@ public:
virtual void handleInput(NancyInput &input) override;
virtual void onPause(bool pause) override;
Common::String imageName; // 0x00
Common::String _imageName; // 0x00
// 0xA numDials
Common::Array<Common::Rect> srcRects; // 0xC, 10
Common::Array<Common::Rect> destRects; // 0xAC, 8
Common::Array<Common::Rect> upHotspots; // 0x12C, 8
Common::Array<Common::Rect> downHotspots; // 0x1AC, 8
Common::Array<byte> correctSequence; // 0x22C
Nancy::SoundDescription clickSound; // 0x234, kNormal
SceneChangeDescription solveExitScene; // 0x256
EventFlagDescription flagOnSolve; // 0x260
uint16 solveSoundDelay; // 0x263
Nancy::SoundDescription solveSound; // 0x265
SceneChangeDescription exitScene; // 0x287
EventFlagDescription flagOnExit; // 0x291
Common::Rect exitHotspot; // 0x294
Common::Array<Common::Rect> _srcRects; // 0xC, 10
Common::Array<Common::Rect> _destRects; // 0xAC, 8
Common::Array<Common::Rect> _upHotspots; // 0x12C, 8
Common::Array<Common::Rect> _downHotspots; // 0x1AC, 8
Common::Array<byte> _correctSequence; // 0x22C
Nancy::SoundDescription _clickSound; // 0x234, kNormal
SceneChangeDescription _solveExitScene; // 0x256
EventFlagDescription _flagOnSolve; // 0x260
uint16 _solveSoundDelay; // 0x263
Nancy::SoundDescription _solveSound; // 0x265
SceneChangeDescription _exitScene; // 0x287
EventFlagDescription _flagOnExit; // 0x291
Common::Rect _exitHotspot; // 0x294
SolveState solveState = kNotSolved;
Graphics::ManagedSurface image;
Common::Array<byte> currentSequence;
Time solveSoundPlayTime;
SolveState _solveState = kNotSolved;
Graphics::ManagedSurface _image;
Common::Array<byte> _currentSequence;
Time _solveSoundPlayTime;
protected:

View File

@ -32,7 +32,7 @@ namespace Action {
PlaySecondaryMovie::~PlaySecondaryMovie() {
_decoder.close();
if (hideMouse == kTrue && unknown == 5) {
if (_hideMouse == kTrue && _unknown == 5) {
g_nancy->setMouseEnabled(true);
}
}
@ -40,29 +40,29 @@ PlaySecondaryMovie::~PlaySecondaryMovie() {
void PlaySecondaryMovie::readData(Common::SeekableReadStream &stream) {
char name[10];
stream.read(name, 10);
videoName = name;
_videoName = name;
stream.skip(0x12);
unknown = stream.readUint16LE();
hideMouse = (NancyFlag)stream.readUint16LE();
isReverse = (NancyFlag)stream.readUint16LE();
firstFrame = (NancyFlag)stream.readUint16LE();
lastFrame = (NancyFlag)stream.readUint16LE();
_unknown = stream.readUint16LE();
_hideMouse = (NancyFlag)stream.readUint16LE();
_isReverse = (NancyFlag)stream.readUint16LE();
_firstFrame = (NancyFlag)stream.readUint16LE();
_lastFrame = (NancyFlag)stream.readUint16LE();
for (uint i = 0; i < 15; ++i) {
frameFlags[i].frameID = stream.readSint16LE();
frameFlags[i].flagDesc.label = stream.readSint16LE();
frameFlags[i].flagDesc.flag = (NancyFlag)stream.readUint16LE();
_frameFlags[i].frameID = stream.readSint16LE();
_frameFlags[i].flagDesc.label = stream.readSint16LE();
_frameFlags[i].flagDesc.flag = (NancyFlag)stream.readUint16LE();
}
triggerFlags.readData(stream);
sound.read(stream, SoundDescription::kNormal);
sceneChange.readData(stream);
_triggerFlags.readData(stream);
_sound.read(stream, SoundDescription::kNormal);
_sceneChange.readData(stream);
uint16 numVideoDescs = stream.readUint16LE();
for (uint i = 0; i < numVideoDescs; ++i) {
videoDescs.push_back(SecondaryVideoDescription());
videoDescs[i].readData(stream);
_videoDescs.push_back(SecondaryVideoDescription());
_videoDescs[i].readData(stream);
}
}
@ -71,7 +71,7 @@ void PlaySecondaryMovie::init() {
_decoder.close();
}
_decoder.loadFile(videoName + ".avf");
_decoder.loadFile(_videoName + ".avf");
_drawSurface.create(_decoder.getWidth(), _decoder.getHeight(), GraphicsManager::getInputPixelFormat());
_screenPosition = _drawSurface.getBounds();
@ -83,43 +83,43 @@ void PlaySecondaryMovie::updateGraphics() {
return;
}
if (!_decoder.isPlaying() && _isVisible && !isFinished) {
if (!_decoder.isPlaying() && _isVisible && !_isFinished) {
_decoder.start();
if (isReverse == kTrue) {
if (_isReverse == kTrue) {
_decoder.setRate(-_decoder.getRate());
_decoder.seekToFrame(lastFrame);
_decoder.seekToFrame(_lastFrame);
} else {
_decoder.seekToFrame(firstFrame);
_decoder.seekToFrame(_firstFrame);
}
}
if (_decoder.needsUpdate()) {
uint descID = 0;
for (uint i = 0; i < videoDescs.size(); ++i) {
if (videoDescs[i].frameID == _curViewportFrame) {
for (uint i = 0; i < _videoDescs.size(); ++i) {
if (_videoDescs[i].frameID == _curViewportFrame) {
descID = i;
}
}
_drawSurface.blitFrom(*_decoder.decodeNextFrame(), videoDescs[descID].srcRect, Common::Point());
_drawSurface.blitFrom(*_decoder.decodeNextFrame(), _videoDescs[descID].srcRect, Common::Point());
_needsRedraw = true;
for (auto f : frameFlags) {
for (auto f : _frameFlags) {
if (_decoder.getCurFrame() == f.frameID) {
NancySceneState.setEventFlag(f.flagDesc);
}
}
}
if ((_decoder.getCurFrame() == lastFrame && isReverse == kFalse) ||
(_decoder.getCurFrame() == firstFrame && isReverse == kTrue)) {
if (!g_nancy->sound->isSoundPlaying(sound)) {
g_nancy->sound->stopSound(sound);
if ((_decoder.getCurFrame() == _lastFrame && _isReverse == kFalse) ||
(_decoder.getCurFrame() == _firstFrame && _isReverse == kTrue)) {
if (!g_nancy->_sound->isSoundPlaying(_sound)) {
g_nancy->_sound->stopSound(_sound);
_decoder.stop();
isFinished = true;
state = kActionTrigger;
_isFinished = true;
_state = kActionTrigger;
}
}
@ -135,18 +135,18 @@ void PlaySecondaryMovie::onPause(bool pause) {
}
void PlaySecondaryMovie::execute() {
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
g_nancy->sound->loadSound(sound);
g_nancy->sound->playSound(sound);
g_nancy->_sound->loadSound(_sound);
g_nancy->_sound->playSound(_sound);
if (hideMouse == kTrue) {
if (_hideMouse == kTrue) {
g_nancy->setMouseEnabled(false);
}
state = kRun;
_state = kRun;
// fall through
case kRun: {
int newFrame = NancySceneState.getSceneInfo().frameID;
@ -154,15 +154,15 @@ void PlaySecondaryMovie::execute() {
if (newFrame != _curViewportFrame) {
_curViewportFrame = newFrame;
int activeFrame = -1;
for (uint i = 0; i < videoDescs.size(); ++i) {
if (newFrame == videoDescs[i].frameID) {
for (uint i = 0; i < _videoDescs.size(); ++i) {
if (newFrame == _videoDescs[i].frameID) {
activeFrame = i;
break;
}
}
if (activeFrame != -1) {
_screenPosition = videoDescs[activeFrame].destRect;
_screenPosition = _videoDescs[activeFrame].destRect;
setVisible(true);
} else {
setVisible(false);
@ -172,12 +172,12 @@ void PlaySecondaryMovie::execute() {
break;
}
case kActionTrigger:
triggerFlags.execute();
if (unknown == 5) {
NancySceneState.changeScene(sceneChange);
_triggerFlags.execute();
if (_unknown == 5) {
NancySceneState.changeScene(_sceneChange);
} else {
// Not changing the scene so enable the mouse now
if (hideMouse == kTrue) {
if (_hideMouse == kTrue) {
g_nancy->setMouseEnabled(true);
}
}

View File

@ -45,7 +45,7 @@ public:
PlaySecondaryMovie(RenderObject &redrawFrom) :
RenderObject(redrawFrom),
_curViewportFrame(-1),
isFinished(false) {}
_isFinished(false) {}
virtual ~PlaySecondaryMovie();
virtual void init() override;
@ -55,20 +55,20 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
Common::String videoName; // 0x00
Common::String _videoName; // 0x00
uint16 unknown; // 0x1C
NancyFlag hideMouse; // 0x1E
NancyFlag isReverse; // 0x20
uint16 firstFrame; // 0x22
uint16 lastFrame; // 0x24
FlagAtFrame frameFlags[15]; // 0x26
MultiEventFlagDescription triggerFlags; // 0x80
uint16 _unknown; // 0x1C
NancyFlag _hideMouse; // 0x1E
NancyFlag _isReverse; // 0x20
uint16 _firstFrame; // 0x22
uint16 _lastFrame; // 0x24
FlagAtFrame _frameFlags[15]; // 0x26
MultiEventFlagDescription _triggerFlags; // 0x80
SoundDescription sound; // 0xA8
SoundDescription _sound; // 0xA8
SceneChangeDescription sceneChange; // 0xCA
Common::Array<SecondaryVideoDescription> videoDescs; // 0xD4
SceneChangeDescription _sceneChange; // 0xCA
Common::Array<SecondaryVideoDescription> _videoDescs; // 0xD4
protected:
virtual Common::String getRecordTypeName() const override { return "PlaySecondaryMovie"; }
@ -78,7 +78,7 @@ protected:
AVFDecoder _decoder;
int _curViewportFrame;
bool isFinished;
bool _isFinished;
};
} // End of namespace Action

View File

@ -45,14 +45,14 @@ void PlaySecondaryVideo::init() {
_decoder.close();
}
_decoder.loadFile(filename + ".avf");
_decoder.loadFile(_filename + ".avf");
// Every secondary video frame (in nancy1) plays exactly 12ms slower than what its metadata says.
// I'm still not sure how/why that happens so for now I'm using this hack to fix the timings
_decoder.addFrameTime(12);
_drawSurface.create(_decoder.getWidth(), _decoder.getHeight(), GraphicsManager::getInputPixelFormat());
if (paletteFilename.size()) {
GraphicsManager::loadSurfacePalette(_drawSurface, paletteFilename);
if (_paletteFilename.size()) {
GraphicsManager::loadSurfacePalette(_drawSurface, _paletteFilename);
}
setVisible(false);
@ -71,16 +71,16 @@ void PlaySecondaryVideo::updateGraphics() {
_decoder.start();
}
switch (hoverState) {
switch (_hoverState) {
case kNoHover:
if (_isHovered) {
_decoder.seekToFrame(onHoverFirstFrame);
_decoder.seekToFrame(_onHoverFirstFrame);
hoverState = kHover;
_hoverState = kHover;
} else {
if (_decoder.getCurFrame() == loopLastFrame) {
if (_decoder.getCurFrame() == _loopLastFrame) {
// loop back to beginning
_decoder.seekToFrame(loopFirstFrame);
_decoder.seekToFrame(_loopFirstFrame);
}
break;
@ -89,33 +89,33 @@ void PlaySecondaryVideo::updateGraphics() {
case kHover:
if (!_isHovered) {
// Stopped hovering, reverse playback
_decoder.seekToFrame(onHoverEndLastFrame);
_decoder.seekToFrame(_onHoverEndLastFrame);
_decoder.setRate(-_decoder.getRate());
if (!_decoder.isPlaying()) {
_decoder.start();
}
hoverState = kEndHover;
_hoverState = kEndHover;
} else {
break;
}
// fall through
case kEndHover:
if (_decoder.getCurFrame() == onHoverEndFirstFrame) {
// reversed playback has ended, go back to no hover state
_decoder.seekToFrame(loopFirstFrame);
if (_decoder.getCurFrame() == _onHoverEndFirstFrame) {
// reversed playback has ended, go back to no hover _state
_decoder.seekToFrame(_loopFirstFrame);
_decoder.setRate(-_decoder.getRate());
hoverState = kNoHover;
_hoverState = kNoHover;
}
break;
}
if (_decoder.needsUpdate() && !_screenPosition.isEmpty()) {
for (uint i = 0; i < videoDescs.size(); ++i) {
if ((uint16)videoDescs[i].frameID == _currentViewportFrame) {
for (uint i = 0; i < _videoDescs.size(); ++i) {
if ((uint16)_videoDescs[i].frameID == _currentViewportFrame) {
// This ignores the srcRects for every frame
GraphicsManager::copyToManaged(*_decoder.decodeNextFrame(), _drawSurface, paletteFilename.size() > 0);
GraphicsManager::copyToManaged(*_decoder.decodeNextFrame(), _drawSurface, _paletteFilename.size() > 0);
break;
}
}
@ -138,7 +138,7 @@ void PlaySecondaryVideo::onPause(bool pause) {
}
void PlaySecondaryVideo::handleInput(NancyInput &input) {
if (hasHotspot && NancySceneState.getViewport().convertViewportToScreen(hotspot).contains(input.mousePos)) {
if (_hasHotspot && NancySceneState.getViewport().convertViewportToScreen(_hotspot).contains(input.mousePos)) {
_isHovered = true;
} else {
_isHovered = false;
@ -148,25 +148,25 @@ void PlaySecondaryVideo::handleInput(NancyInput &input) {
void PlaySecondaryVideo::readData(Common::SeekableReadStream &stream) {
char buf[10];
stream.read(buf, 10);
filename = buf;
_filename = buf;
stream.read(buf, 10);
paletteFilename = buf;
_paletteFilename = buf;
stream.skip(10);
if (paletteFilename.size()) {
if (_paletteFilename.size()) {
stream.skip(14); // unknown data
}
loopFirstFrame = stream.readUint16LE();
loopLastFrame = stream.readUint16LE();
onHoverFirstFrame = stream.readUint16LE();
onHoverLastFrame = stream.readUint16LE();
onHoverEndFirstFrame = stream.readUint16LE();
onHoverEndLastFrame = stream.readUint16LE();
_loopFirstFrame = stream.readUint16LE();
_loopLastFrame = stream.readUint16LE();
_onHoverFirstFrame = stream.readUint16LE();
_onHoverLastFrame = stream.readUint16LE();
_onHoverEndFirstFrame = stream.readUint16LE();
_onHoverEndLastFrame = stream.readUint16LE();
sceneChange.readData(stream);
_sceneChange.readData(stream);
if (paletteFilename.size()) {
if (_paletteFilename.size()) {
stream.skip(3);
} else {
stream.skip(1);
@ -174,17 +174,17 @@ void PlaySecondaryVideo::readData(Common::SeekableReadStream &stream) {
uint16 numVideoDescs = stream.readUint16LE();
for (uint i = 0; i < numVideoDescs; ++i) {
videoDescs.push_back(SecondaryVideoDescription());
videoDescs[i].readData(stream);
_videoDescs.push_back(SecondaryVideoDescription());
_videoDescs[i].readData(stream);
}
}
void PlaySecondaryVideo::execute() {
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
state = kRun;
_state = kRun;
// fall through
case kRun: {
// Set correct position according to viewport frame
@ -193,24 +193,24 @@ void PlaySecondaryVideo::execute() {
int activeFrame = -1;
for (uint i = 0; i < videoDescs.size(); ++i) {
if ((uint16)videoDescs[i].frameID == _currentViewportFrame) {
for (uint i = 0; i < _videoDescs.size(); ++i) {
if ((uint16)_videoDescs[i].frameID == _currentViewportFrame) {
activeFrame = i;
}
}
if (activeFrame != -1) {
// Make the drawing destination rectangle valid
_screenPosition = videoDescs[activeFrame].destRect;
_screenPosition = _videoDescs[activeFrame].destRect;
// Activate the hotspot
hotspot = videoDescs[activeFrame].destRect;
hasHotspot = true;
_hotspot = _videoDescs[activeFrame].destRect;
_hasHotspot = true;
_isPlaying = true;
setVisible(true);
} else {
setVisible(false);
hasHotspot = false;
_hasHotspot = false;
_isPlaying = false;
}
}
@ -219,7 +219,7 @@ void PlaySecondaryVideo::execute() {
}
case kActionTrigger:
NancySceneState.pushScene();
NancySceneState.changeScene(sceneChange);
NancySceneState.changeScene(_sceneChange);
finishExecution();
break;
}

View File

@ -52,17 +52,17 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
Common::String filename;
Common::String paletteFilename;
uint16 loopFirstFrame = 0; // 0x1E
uint16 loopLastFrame = 0; // 0x20
uint16 onHoverFirstFrame = 0; // 0x22
uint16 onHoverLastFrame = 0; // 0x24
uint16 onHoverEndFirstFrame = 0; // 0x26
uint16 onHoverEndLastFrame = 0; // 0x28
SceneChangeDescription sceneChange; // 0x2A
Common::String _filename;
Common::String _paletteFilename;
uint16 _loopFirstFrame = 0; // 0x1E
uint16 _loopLastFrame = 0; // 0x20
uint16 _onHoverFirstFrame = 0; // 0x22
uint16 _onHoverLastFrame = 0; // 0x24
uint16 _onHoverEndFirstFrame = 0; // 0x26
uint16 _onHoverEndLastFrame = 0; // 0x28
SceneChangeDescription _sceneChange; // 0x2A
// unknown byte
Common::Array<SecondaryVideoDescription> videoDescs; // 0x35
Common::Array<SecondaryVideoDescription> _videoDescs; // 0x35
protected:
virtual Common::String getRecordTypeName() const override { return Common::String::format("PlaySecondaryVideoChan%i", channel); }
@ -70,7 +70,7 @@ protected:
virtual uint16 getZOrder() const override { return 8; }
virtual bool isViewportRelative() const override { return true; }
HoverState hoverState = kNoHover;
HoverState _hoverState = kNoHover;
AVFDecoder _decoder;
int _currentViewportFrame = -1;
bool _isPlaying = false;

View File

@ -34,8 +34,8 @@
namespace Nancy {
namespace Action {
Common::Array<Common::Array<int16>> SliderPuzzle::playerTileOrder = Common::Array<Common::Array<int16>>();
bool SliderPuzzle::playerHasTriedPuzzle = false;
Common::Array<Common::Array<int16>> SliderPuzzle::_playerTileOrder = Common::Array<Common::Array<int16>>();
bool SliderPuzzle::_playerHasTriedPuzzle = false;
void SliderPuzzle::init() {
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), GraphicsManager::getInputPixelFormat());
@ -43,118 +43,118 @@ void SliderPuzzle::init() {
setTransparent(true);
g_nancy->resource->loadImage(imageName, image);
g_nancy->_resource->loadImage(_imageName, _image);
}
void SliderPuzzle::readData(Common::SeekableReadStream &stream) {
char buf[10];
stream.read(buf, 10);
imageName = buf;
_imageName = buf;
width = stream.readUint16LE();
height = stream.readUint16LE();
_width = stream.readUint16LE();
_height = stream.readUint16LE();
for (uint y = 0; y < height; ++y) {
srcRects.push_back(Common::Array<Common::Rect>());
for (uint x = 0; x < width; ++x) {
srcRects.back().push_back(Common::Rect());
readRect(stream, srcRects.back().back());
for (uint y = 0; y < _height; ++y) {
_srcRects.push_back(Common::Array<Common::Rect>());
for (uint x = 0; x < _width; ++x) {
_srcRects.back().push_back(Common::Rect());
readRect(stream, _srcRects.back().back());
}
stream.skip((6 - width) * 16);
stream.skip((6 - _width) * 16);
}
stream.skip((6 - height) * 6 * 16);
stream.skip((6 - _height) * 6 * 16);
for (uint y = 0; y < height; ++y) {
destRects.push_back(Common::Array<Common::Rect>());
for (uint x = 0; x < width; ++x) {
destRects.back().push_back(Common::Rect());
readRect(stream, destRects.back().back());
for (uint y = 0; y < _height; ++y) {
_destRects.push_back(Common::Array<Common::Rect>());
for (uint x = 0; x < _width; ++x) {
_destRects.back().push_back(Common::Rect());
readRect(stream, _destRects.back().back());
if (x == 0 && y == 0) {
_screenPosition = destRects.back().back();
_screenPosition = _destRects.back().back();
} else {
_screenPosition.extend(destRects.back().back());
_screenPosition.extend(_destRects.back().back());
}
}
stream.skip((6 - width) * 16);
stream.skip((6 - _width) * 16);
}
stream.skip((6 - height) * 6 * 16);
stream.skip((6 - _height) * 6 * 16);
for (uint y = 0; y < height; ++y) {
correctTileOrder.push_back(Common::Array<int16>());
for (uint x = 0; x < width; ++x) {
correctTileOrder.back().push_back(stream.readSint16LE());
for (uint y = 0; y < _height; ++y) {
_correctTileOrder.push_back(Common::Array<int16>());
for (uint x = 0; x < _width; ++x) {
_correctTileOrder.back().push_back(stream.readSint16LE());
}
stream.skip((6 - width) * 2);
stream.skip((6 - _width) * 2);
}
stream.skip((6 - height) * 6 * 2);
stream.skip((6 - _height) * 6 * 2);
clickSound.read(stream, SoundDescription::kNormal);
solveExitScene.readData(stream);
_clickSound.read(stream, SoundDescription::kNormal);
_solveExitScene.readData(stream);
stream.skip(2);
flagOnSolve.label = stream.readSint16LE();
flagOnSolve.flag = (NancyFlag)stream.readByte();
solveSound.read(stream, SoundDescription::kNormal);
exitScene.readData(stream);
_flagOnSolve.label = stream.readSint16LE();
_flagOnSolve.flag = (NancyFlag)stream.readByte();
_solveSound.read(stream, SoundDescription::kNormal);
_exitScene.readData(stream);
stream.skip(2);
flagOnExit.label = stream.readSint16LE();
flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, exitHotspot);
_flagOnExit.label = stream.readSint16LE();
_flagOnExit.flag = (NancyFlag)stream.readByte();
readRect(stream, _exitHotspot);
}
void SliderPuzzle::execute() {
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
if (!playerHasTriedPuzzle) {
if (!_playerHasTriedPuzzle) {
Common::SeekableReadStream *spuz = g_nancy->getBootChunkStream("SPUZ");
playerTileOrder.clear();
_playerTileOrder.clear();
spuz->seek(NancySceneState.getDifficulty() * 0x48);
for (uint y = 0; y < height; ++y) {
playerTileOrder.push_back(Common::Array<int16>());
for (uint y = 0; y < _height; ++y) {
_playerTileOrder.push_back(Common::Array<int16>());
for (uint x = 0; x < width; ++x) {
playerTileOrder.back().push_back(spuz->readSint16LE());
for (uint x = 0; x < _width; ++x) {
_playerTileOrder.back().push_back(spuz->readSint16LE());
}
spuz->skip((6 - width) * 2);
spuz->skip((6 - _width) * 2);
}
playerHasTriedPuzzle = true;
_playerHasTriedPuzzle = true;
}
for (uint y = 0; y < height; ++y) {
for (uint x = 0; x < width; ++x) {
drawTile(playerTileOrder[y][x], x, y);
for (uint y = 0; y < _height; ++y) {
for (uint x = 0; x < _width; ++x) {
drawTile(_playerTileOrder[y][x], x, y);
}
}
g_nancy->sound->loadSound(clickSound);
state = kRun;
g_nancy->_sound->loadSound(_clickSound);
_state = kRun;
// fall through
case kRun:
switch (solveState) {
switch (_solveState) {
case kNotSolved:
for (uint y = 0; y < height; ++y) {
for (uint x = 0; x < width; ++x) {
if (playerTileOrder[y][x] != correctTileOrder[y][x]) {
for (uint y = 0; y < _height; ++y) {
for (uint x = 0; x < _width; ++x) {
if (_playerTileOrder[y][x] != _correctTileOrder[y][x]) {
return;
}
}
}
g_nancy->sound->loadSound(solveSound);
g_nancy->sound->playSound(solveSound);
solveState = kWaitForSound;
g_nancy->_sound->loadSound(_solveSound);
g_nancy->_sound->playSound(_solveSound);
_solveState = kWaitForSound;
break;
case kWaitForSound:
if (!g_nancy->sound->isSoundPlaying(solveSound)) {
g_nancy->sound->stopSound(solveSound);
state = kActionTrigger;
if (!g_nancy->_sound->isSoundPlaying(_solveSound)) {
g_nancy->_sound->stopSound(_solveSound);
_state = kActionTrigger;
}
break;
@ -162,33 +162,33 @@ void SliderPuzzle::execute() {
break;
case kActionTrigger:
switch (solveState) {
switch (_solveState) {
case kNotSolved:
NancySceneState.changeScene(exitScene);
NancySceneState.setEventFlag(flagOnExit);
NancySceneState.changeScene(_exitScene);
NancySceneState.setEventFlag(_flagOnExit);
break;
case kWaitForSound:
NancySceneState.changeScene(solveExitScene);
NancySceneState.setEventFlag(flagOnSolve);
playerHasTriedPuzzle = false;
NancySceneState.changeScene(_solveExitScene);
NancySceneState.setEventFlag(_flagOnSolve);
_playerHasTriedPuzzle = false;
break;
}
g_nancy->sound->stopSound(clickSound);
g_nancy->_sound->stopSound(_clickSound);
finishExecution();
}
}
void SliderPuzzle::handleInput(NancyInput &input) {
if (solveState != kNotSolved) {
if (_solveState != kNotSolved) {
return;
}
if (NancySceneState.getViewport().convertViewportToScreen(exitHotspot).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kExitArrow);
if (NancySceneState.getViewport().convertViewportToScreen(_exitHotspot).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kExitArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
state = kActionTrigger;
_state = kActionTrigger;
}
return;
@ -197,35 +197,35 @@ void SliderPuzzle::handleInput(NancyInput &input) {
int currentTileX = -1;
int currentTileY = -1;
uint direction = 0;
for (uint y = 0; y < height; ++y) {
for (uint y = 0; y < _height; ++y) {
bool shouldBreak = false;
for (uint x = 0; x < width; ++x) {
if (x > 0 && playerTileOrder[y][x - 1] < 0) {
if (NancySceneState.getViewport().convertViewportToScreen(destRects[y][x]).contains(input.mousePos)) {
for (uint x = 0; x < _width; ++x) {
if (x > 0 && _playerTileOrder[y][x - 1] < 0) {
if (NancySceneState.getViewport().convertViewportToScreen(_destRects[y][x]).contains(input.mousePos)) {
currentTileX = x;
currentTileY = y;
direction = kLeft;
shouldBreak = true;
break;
}
} else if ((int)x < width - 1 && playerTileOrder[y][x + 1] < 0) {
if (NancySceneState.getViewport().convertViewportToScreen(destRects[y][x]).contains(input.mousePos)) {
} else if ((int)x < _width - 1 && _playerTileOrder[y][x + 1] < 0) {
if (NancySceneState.getViewport().convertViewportToScreen(_destRects[y][x]).contains(input.mousePos)) {
currentTileX = x;
currentTileY = y;
direction = kRight;
shouldBreak = true;
break;
}
} else if (y > 0 && playerTileOrder[y - 1][x] < 0) {
if (NancySceneState.getViewport().convertViewportToScreen(destRects[y][x]).contains(input.mousePos)) {
} else if (y > 0 && _playerTileOrder[y - 1][x] < 0) {
if (NancySceneState.getViewport().convertViewportToScreen(_destRects[y][x]).contains(input.mousePos)) {
currentTileX = x;
currentTileY = y;
direction = kUp;
shouldBreak = true;
break;
}
} else if ((int)y < height - 1 && playerTileOrder[y + 1][x] < 0) {
if (NancySceneState.getViewport().convertViewportToScreen(destRects[y][x]).contains(input.mousePos)) {
} else if ((int)y < _height - 1 && _playerTileOrder[y + 1][x] < 0) {
if (NancySceneState.getViewport().convertViewportToScreen(_destRects[y][x]).contains(input.mousePos)) {
currentTileX = x;
currentTileY = y;
direction = kDown;
@ -241,41 +241,41 @@ void SliderPuzzle::handleInput(NancyInput &input) {
}
if (currentTileX != -1) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspot);
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspot);
if (input.input & NancyInput::kLeftMouseButtonUp) {
g_nancy->sound->playSound(clickSound);
g_nancy->_sound->playSound(_clickSound);
switch (direction) {
case kUp: {
uint curTileID = playerTileOrder[currentTileY][currentTileX];
uint curTileID = _playerTileOrder[currentTileY][currentTileX];
drawTile(curTileID, currentTileX, currentTileY - 1);
undrawTile(currentTileX, currentTileY);
playerTileOrder[currentTileY - 1][currentTileX] = curTileID;
playerTileOrder[currentTileY][currentTileX] = -10;
_playerTileOrder[currentTileY - 1][currentTileX] = curTileID;
_playerTileOrder[currentTileY][currentTileX] = -10;
break;
}
case kDown: {
uint curTileID = playerTileOrder[currentTileY][currentTileX];
uint curTileID = _playerTileOrder[currentTileY][currentTileX];
drawTile(curTileID, currentTileX, currentTileY + 1);
undrawTile(currentTileX, currentTileY);
playerTileOrder[currentTileY + 1][currentTileX] = curTileID;
playerTileOrder[currentTileY][currentTileX] = -10;
_playerTileOrder[currentTileY + 1][currentTileX] = curTileID;
_playerTileOrder[currentTileY][currentTileX] = -10;
break;
}
case kLeft: {
uint curTileID = playerTileOrder[currentTileY][currentTileX];
uint curTileID = _playerTileOrder[currentTileY][currentTileX];
drawTile(curTileID, currentTileX - 1, currentTileY);
undrawTile(currentTileX, currentTileY);
playerTileOrder[currentTileY][currentTileX - 1] = curTileID;
playerTileOrder[currentTileY][currentTileX] = -10;
_playerTileOrder[currentTileY][currentTileX - 1] = curTileID;
_playerTileOrder[currentTileY][currentTileX] = -10;
break;
}
case kRight: {
uint curTileID = playerTileOrder[currentTileY][currentTileX];
uint curTileID = _playerTileOrder[currentTileY][currentTileX];
drawTile(curTileID, currentTileX + 1, currentTileY);
undrawTile(currentTileX, currentTileY);
playerTileOrder[currentTileY][currentTileX + 1] = curTileID;
playerTileOrder[currentTileY][currentTileX] = -10;
_playerTileOrder[currentTileY][currentTileX + 1] = curTileID;
_playerTileOrder[currentTileY][currentTileX] = -10;
break;
}
}
@ -290,25 +290,25 @@ void SliderPuzzle::onPause(bool pause) {
}
void SliderPuzzle::synchronize(Common::Serializer &ser) {
ser.syncAsByte(playerHasTriedPuzzle);
ser.syncAsByte(_playerHasTriedPuzzle);
byte x, y;
if (ser.isSaving()) {
y = playerTileOrder.size();
y = _playerTileOrder.size();
if (y) {
x = playerTileOrder.back().size();
x = _playerTileOrder.back().size();
}
}
ser.syncAsByte(x);
ser.syncAsByte(y);
playerTileOrder.resize(y);
_playerTileOrder.resize(y);
for (int i = 0; i < y; ++i) {
playerTileOrder[i].resize(x);
ser.syncArray(playerTileOrder[i].data(), x, Common::Serializer::Sint16LE);
_playerTileOrder[i].resize(x);
ser.syncArray(_playerTileOrder[i].data(), x, Common::Serializer::Sint16LE);
}
}
@ -318,14 +318,14 @@ void SliderPuzzle::drawTile(int tileID, uint posX, uint posY) {
return;
}
Common::Point destPoint(destRects[posY][posX].left - _screenPosition.left, destRects[posY][posX].top - _screenPosition.top);
_drawSurface.blitFrom(image, srcRects[tileID / height][tileID % width], destPoint);
Common::Point destPoint(_destRects[posY][posX].left - _screenPosition.left, _destRects[posY][posX].top - _screenPosition.top);
_drawSurface.blitFrom(_image, _srcRects[tileID / _height][tileID % _width], destPoint);
_needsRedraw = true;
}
void SliderPuzzle::undrawTile(uint posX, uint posY) {
Common::Rect bounds = destRects[posY][posX];
Common::Rect bounds = _destRects[posY][posX];
bounds.translate(-_screenPosition.left, -_screenPosition.top);
_drawSurface.fillRect(bounds, GraphicsManager::getTransColor());

View File

@ -56,25 +56,25 @@ public:
static void synchronize(Common::Serializer &ser);
Common::String imageName; // 0x00
uint16 width; // 0xA
uint16 height; // 0xC
Common::Array<Common::Array<Common::Rect>> srcRects; // 0x0E, size 0x240
Common::Array<Common::Array<Common::Rect>> destRects; // 0x24E, size 0x240
Common::Array<Common::Array<int16>> correctTileOrder; // 0x48E, size 0x48
SoundDescription clickSound; // 0x4D6
SceneChangeDescription solveExitScene; // 0x4F8
EventFlagDescription flagOnSolve; // 0x502
SoundDescription solveSound; // 0x505
SceneChangeDescription exitScene; // 0x527
EventFlagDescription flagOnExit; // 0x531
Common::Rect exitHotspot; // 0x534
Common::String _imageName; // 0x00
uint16 _width; // 0xA
uint16 _height; // 0xC
Common::Array<Common::Array<Common::Rect>> _srcRects; // 0x0E, size 0x240
Common::Array<Common::Array<Common::Rect>> _destRects; // 0x24E, size 0x240
Common::Array<Common::Array<int16>> _correctTileOrder; // 0x48E, size 0x48
SoundDescription _clickSound; // 0x4D6
SceneChangeDescription _solveExitScene; // 0x4F8
EventFlagDescription _flagOnSolve; // 0x502
SoundDescription _solveSound; // 0x505
SceneChangeDescription _exitScene; // 0x527
EventFlagDescription _flagOnExit; // 0x531
Common::Rect _exitHotspot; // 0x534
SolveState solveState = kNotSolved;
Graphics::ManagedSurface image;
SolveState _solveState = kNotSolved;
Graphics::ManagedSurface _image;
static Common::Array<Common::Array<int16>> playerTileOrder;
static bool playerHasTriedPuzzle;
static Common::Array<Common::Array<int16>> _playerTileOrder;
static bool _playerHasTriedPuzzle;
protected:
virtual Common::String getRecordTypeName() const override { return "SliderPuzzle"; }

View File

@ -35,7 +35,7 @@ namespace Nancy {
namespace Action {
void PlayStaticBitmapAnimation::init() {
g_nancy->resource->loadImage(imageName, _fullSurface);
g_nancy->_resource->loadImage(_imageName, _fullSurface);
setFrame(0);
@ -45,40 +45,40 @@ void PlayStaticBitmapAnimation::init() {
void PlayStaticBitmapAnimation::readData(Common::SeekableReadStream &stream) {
char name[10];
stream.read(name, 10);
imageName = Common::String(name);
_imageName = Common::String(name);
stream.skip(0x2);
isTransparent = (NancyFlag)(stream.readUint16LE());
doNotChangeScene = (NancyFlag)(stream.readUint16LE());
isReverse = (NancyFlag)(stream.readUint16LE());
isLooping = (NancyFlag)(stream.readUint16LE());
firstFrame = stream.readUint16LE();
loopFirstFrame = stream.readUint16LE();
loopLastFrame = stream.readUint16LE();
frameTime = Common::Rational(1000, stream.readUint16LE()).toInt();
zOrder = stream.readUint16LE();
_isTransparent = (NancyFlag)(stream.readUint16LE());
_doNotChangeScene = (NancyFlag)(stream.readUint16LE());
_isReverse = (NancyFlag)(stream.readUint16LE());
_isLooping = (NancyFlag)(stream.readUint16LE());
_firstFrame = stream.readUint16LE();
_loopFirstFrame = stream.readUint16LE();
_loopLastFrame = stream.readUint16LE();
_frameTime = Common::Rational(1000, stream.readUint16LE()).toInt();
_zOrder = stream.readUint16LE();
if (isInterruptible) {
interruptCondition.label = stream.readSint16LE();
interruptCondition.flag = (NancyFlag)stream.readUint16LE();
if (_isInterruptible) {
_interruptCondition.label = stream.readSint16LE();
_interruptCondition.flag = (NancyFlag)stream.readUint16LE();
} else {
interruptCondition.label = -1;
interruptCondition.flag = kFalse;
_interruptCondition.label = -1;
_interruptCondition.flag = kFalse;
}
sceneChange.readData(stream);
triggerFlags.readData(stream);
sound.read(stream, SoundDescription::kNormal);
_sceneChange.readData(stream);
_triggerFlags.readData(stream);
_sound.read(stream, SoundDescription::kNormal);
uint numViewportFrames = stream.readUint16LE();
for (uint i = firstFrame; i <= loopLastFrame; ++i) {
srcRects.push_back(Common::Rect());
readRect(stream, srcRects[i]);
for (uint i = _firstFrame; i <= _loopLastFrame; ++i) {
_srcRects.push_back(Common::Rect());
readRect(stream, _srcRects[i]);
}
for (uint i = 0; i < numViewportFrames; ++i) {
bitmaps.push_back(BitmapDescription());
BitmapDescription &rects = bitmaps.back();
_bitmaps.push_back(BitmapDescription());
BitmapDescription &rects = _bitmaps.back();
rects.frameID = stream.readUint16LE();
readRect(stream, rects.src);
readRect(stream, rects.dest);
@ -86,58 +86,58 @@ void PlayStaticBitmapAnimation::readData(Common::SeekableReadStream &stream) {
}
void PlayStaticBitmapAnimation::execute() {
uint32 currentFrameTime = g_nancy->getTotalPlayTime();
switch (state) {
uint32 _currentFrameTime = g_nancy->getTotalPlayTime();
switch (_state) {
case kBegin:
init();
registerGraphics();
g_nancy->sound->loadSound(sound);
g_nancy->sound->playSound(sound);
state = kRun;
g_nancy->_sound->loadSound(_sound);
g_nancy->_sound->playSound(_sound);
_state = kRun;
// fall through
case kRun: {
// Check the timer to see if we need to draw the next animation frame
if (nextFrameTime <= currentFrameTime) {
if (_nextFrameTime <= _currentFrameTime) {
// World's worst if statement
if (NancySceneState.getEventFlag(interruptCondition) ||
( (((currentFrame == loopLastFrame) && (isReverse == kFalse) && (isLooping == kFalse)) ||
((currentFrame == loopFirstFrame) && (isReverse == kTrue) && (isLooping == kFalse))) &&
!g_nancy->sound->isSoundPlaying(sound)) ) {
if (NancySceneState.getEventFlag(_interruptCondition) ||
( (((_currentFrame == _loopLastFrame) && (_isReverse == kFalse) && (_isLooping == kFalse)) ||
((_currentFrame == _loopFirstFrame) && (_isReverse == kTrue) && (_isLooping == kFalse))) &&
!g_nancy->_sound->isSoundPlaying(_sound)) ) {
state = kActionTrigger;
_state = kActionTrigger;
// Not sure if hiding when triggered is a hack or the intended behavior, but it's here to fix
// nancy1's safe lock light not turning off.
setVisible(false);
if (!g_nancy->sound->isSoundPlaying(sound)) {
g_nancy->sound->stopSound(sound);
if (!g_nancy->_sound->isSoundPlaying(_sound)) {
g_nancy->_sound->stopSound(_sound);
}
} else {
// Check if we've moved the viewport
uint16 newFrame = NancySceneState.getSceneInfo().frameID;
if (currentViewportFrame != newFrame) {
currentViewportFrame = newFrame;
if (_currentViewportFrame != newFrame) {
_currentViewportFrame = newFrame;
for (uint i = 0; i < bitmaps.size(); ++i) {
if (currentViewportFrame == bitmaps[i].frameID) {
_screenPosition = bitmaps[i].dest;
for (uint i = 0; i < _bitmaps.size(); ++i) {
if (_currentViewportFrame == _bitmaps[i].frameID) {
_screenPosition = _bitmaps[i].dest;
break;
}
}
}
nextFrameTime = currentFrameTime + frameTime;
setFrame(currentFrame);
_nextFrameTime = _currentFrameTime + _frameTime;
setFrame(_currentFrame);
if (isReverse == kTrue) {
--currentFrame;
currentFrame = currentFrame < loopFirstFrame ? loopLastFrame : currentFrame;
if (_isReverse == kTrue) {
--_currentFrame;
_currentFrame = _currentFrame < _loopFirstFrame ? _loopLastFrame : _currentFrame;
return;
} else {
++currentFrame;
currentFrame = currentFrame > loopLastFrame ? loopFirstFrame : currentFrame;
++_currentFrame;
_currentFrame = _currentFrame > _loopLastFrame ? _loopFirstFrame : _currentFrame;
return;
}
}
@ -145,12 +145,12 @@ void PlayStaticBitmapAnimation::execute() {
// Check if we've moved the viewport
uint16 newFrame = NancySceneState.getSceneInfo().frameID;
if (currentViewportFrame != newFrame) {
currentViewportFrame = newFrame;
if (_currentViewportFrame != newFrame) {
_currentViewportFrame = newFrame;
for (uint i = 0; i < bitmaps.size(); ++i) {
if (currentViewportFrame == bitmaps[i].frameID) {
_screenPosition = bitmaps[i].dest;
for (uint i = 0; i < _bitmaps.size(); ++i) {
if (_currentViewportFrame == _bitmaps[i].frameID) {
_screenPosition = _bitmaps[i].dest;
break;
}
}
@ -160,9 +160,9 @@ void PlayStaticBitmapAnimation::execute() {
break;
}
case kActionTrigger:
triggerFlags.execute();
if (doNotChangeScene == kFalse) {
NancySceneState.changeScene(sceneChange);
_triggerFlags.execute();
if (_doNotChangeScene == kFalse) {
NancySceneState.changeScene(_sceneChange);
finishExecution();
}
break;
@ -176,10 +176,10 @@ void PlayStaticBitmapAnimation::onPause(bool pause) {
}
void PlayStaticBitmapAnimation::setFrame(uint frame) {
currentFrame = frame;
_drawSurface.create(_fullSurface, srcRects[frame]);
_currentFrame = frame;
_drawSurface.create(_fullSurface, _srcRects[frame]);
setTransparent(isTransparent == kTrue);
setTransparent(_isTransparent == kTrue);
_needsRedraw = true;
}

View File

@ -40,7 +40,7 @@ namespace Action {
// action record types, whose functionality is nearly identical
class PlayStaticBitmapAnimation : public ActionRecord, public RenderObject {
public:
PlayStaticBitmapAnimation(bool interruptible, RenderObject &redrawFrom) : RenderObject(redrawFrom), isInterruptible(interruptible) {}
PlayStaticBitmapAnimation(bool interruptible, RenderObject &redrawFrom) : RenderObject(redrawFrom), _isInterruptible(interruptible) {}
virtual ~PlayStaticBitmapAnimation() { _fullSurface.free(); }
virtual void init() override;
@ -49,38 +49,38 @@ public:
virtual void execute() override;
virtual void onPause(bool pause) override;
Common::String imageName;
Common::String _imageName;
NancyFlag isTransparent; // 0xC
NancyFlag doNotChangeScene; // 0xE
NancyFlag isReverse; // 0x10
NancyFlag isLooping; // 0x12
uint16 firstFrame; // 0x14
uint16 loopFirstFrame; // 0x16
uint16 loopLastFrame; // 0x18
Time frameTime;
uint16 zOrder; // 0x1C
EventFlagDescription interruptCondition; // 0x1E
SceneChangeDescription sceneChange;
MultiEventFlagDescription triggerFlags; // 0x2A
NancyFlag _isTransparent; // 0xC
NancyFlag _doNotChangeScene; // 0xE
NancyFlag _isReverse; // 0x10
NancyFlag _isLooping; // 0x12
uint16 _firstFrame; // 0x14
uint16 _loopFirstFrame; // 0x16
uint16 _loopLastFrame; // 0x18
Time _frameTime;
uint16 _zOrder; // 0x1C
EventFlagDescription _interruptCondition; // 0x1E
SceneChangeDescription _sceneChange;
MultiEventFlagDescription _triggerFlags; // 0x2A
Nancy::SoundDescription sound; // 0x52
Nancy::SoundDescription _sound; // 0x52
// Describes a single frame in this animation
Common::Array<Common::Rect> srcRects;
Common::Array<Common::Rect> _srcRects;
// Describes how the animation will be displayed on a single
// frame of the viewport
Common::Array<BitmapDescription> bitmaps;
Common::Array<BitmapDescription> _bitmaps;
int16 currentFrame = -1;
int16 currentViewportFrame = -1;
Time nextFrameTime;
bool isInterruptible;
int16 _currentFrame = -1;
int16 _currentViewportFrame = -1;
Time _nextFrameTime;
bool _isInterruptible;
protected:
virtual Common::String getRecordTypeName() const override { return isInterruptible ? "PlayIntStaticBitmapAnimation" : "PlayStaticBitmapAnimation"; }
virtual Common::String getRecordTypeName() const override { return _isInterruptible ? "PlayIntStaticBitmapAnimation" : "PlayStaticBitmapAnimation"; }
virtual uint16 getZOrder() const override { return zOrder; }
virtual uint16 getZOrder() const override { return _zOrder; }
virtual bool isViewportRelative() const override { return true; }
void setFrame(uint frame);

View File

@ -42,7 +42,7 @@ void Telephone::init() {
setTransparent(true);
g_nancy->resource->loadImage(imageName, image);
g_nancy->_resource->loadImage(_imageName, _image);
NancySceneState.setShouldClearTextbox(false);
}
@ -50,56 +50,56 @@ void Telephone::init() {
void Telephone::readData(Common::SeekableReadStream &stream) {
char buf[10];
stream.read(buf, 10);
imageName = buf;
_imageName = buf;
for (uint i = 0; i < 12; ++i) {
srcRects.push_back(Common::Rect());
readRect(stream, srcRects.back());
_srcRects.push_back(Common::Rect());
readRect(stream, _srcRects.back());
}
for (uint i = 0; i < 12; ++i) {
destRects.push_back(Common::Rect());
readRect(stream, destRects.back());
_destRects.push_back(Common::Rect());
readRect(stream, _destRects.back());
if (i == 0) {
_screenPosition = destRects.back();
_screenPosition = _destRects.back();
} else {
_screenPosition.extend(destRects.back());
_screenPosition.extend(_destRects.back());
}
}
genericDialogueSound.read(stream, SoundDescription::kNormal);
genericButtonSound.read(stream, SoundDescription::kNormal);
ringSound.read(stream, SoundDescription::kNormal);
dialToneSound.read(stream, SoundDescription::kNormal);
dialAgainSound.read(stream, SoundDescription::kNormal);
hangUpSound.read(stream, SoundDescription::kNormal);
_genericDialogueSound.read(stream, SoundDescription::kNormal);
_genericButtonSound.read(stream, SoundDescription::kNormal);
_ringSound.read(stream, SoundDescription::kNormal);
_dialToneSound.read(stream, SoundDescription::kNormal);
_dialAgainSound.read(stream, SoundDescription::kNormal);
_hangUpSound.read(stream, SoundDescription::kNormal);
for (uint i = 0; i < 12; ++i) {
stream.read(buf, 10);
buttonSoundNames.push_back(buf);
_buttonSoundNames.push_back(buf);
}
char buf2[200];
stream.read(buf2, 200);
addressBookString = buf2;
_addressBookString = buf2;
stream.read(buf2, 200);
dialAgainString = buf2;
reloadScene.readData(stream);
_dialAgainString = buf2;
_reloadScene.readData(stream);
stream.skip(2);
flagOnReload.label = stream.readSint16LE();
flagOnReload.flag = (NancyFlag)stream.readUint16LE();
exitScene.readData(stream);
_flagOnReload.label = stream.readSint16LE();
_flagOnReload.flag = (NancyFlag)stream.readUint16LE();
_exitScene.readData(stream);
stream.skip(2);
flagOnExit.label = stream.readSint16LE();
flagOnExit.flag = (NancyFlag)stream.readUint16LE();
readRect(stream, exitHotspot);
_flagOnExit.label = stream.readSint16LE();
_flagOnExit.flag = (NancyFlag)stream.readUint16LE();
readRect(stream, _exitHotspot);
uint numCalls = stream.readUint16LE();
for (uint i = 0; i < numCalls; ++i) {
calls.push_back(PhoneCall());
PhoneCall &call = calls.back();
_calls.push_back(PhoneCall());
PhoneCall &call = _calls.back();
for (uint j = 0; j < 11; ++j) {
call.phoneNumber.push_back(stream.readByte());
@ -109,7 +109,7 @@ void Telephone::readData(Common::SeekableReadStream &stream) {
call.soundName = buf;
stream.read(buf2, 200);
call.text = buf2;
call.sceneChange.readData(stream);
call._sceneChange.readData(stream);
stream.skip(2);
call.flag.label = stream.readSint16LE();
call.flag.flag = (NancyFlag)stream.readUint16LE();
@ -117,47 +117,47 @@ void Telephone::readData(Common::SeekableReadStream &stream) {
}
void Telephone::execute() {
switch (state) {
switch (_state) {
case kBegin:
init();
registerGraphics();
g_nancy->sound->loadSound(dialToneSound);
g_nancy->sound->playSound(dialToneSound);
g_nancy->_sound->loadSound(_dialToneSound);
g_nancy->_sound->playSound(_dialToneSound);
NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().addTextLine(addressBookString);
state = kRun;
NancySceneState.getTextbox().addTextLine(_addressBookString);
_state = kRun;
// fall through
case kRun:
switch (callState) {
switch (_callState) {
case kWaiting:
// Long phone numbers start with 1
if (calledNumber.size() >= 11 || (calledNumber.size() >= 7 && (calledNumber[0] != 1))) {
if (_calledNumber.size() >= 11 || (_calledNumber.size() >= 7 && (_calledNumber[0] != 1))) {
NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().addTextLine("ringing...<n><e>"); // Hardcoded in the original engine
g_nancy->sound->loadSound(ringSound);
g_nancy->sound->playSound(ringSound);
callState = kRinging;
g_nancy->_sound->loadSound(_ringSound);
g_nancy->_sound->playSound(_ringSound);
_callState = kRinging;
}
break;
case kButtonPress:
if (!g_nancy->sound->isSoundPlaying(genericButtonSound)) {
g_nancy->sound->stopSound(genericButtonSound);
undrawButton(selected);
callState = kWaiting;
if (!g_nancy->_sound->isSoundPlaying(_genericButtonSound)) {
g_nancy->_sound->stopSound(_genericButtonSound);
undrawButton(_selected);
_callState = kWaiting;
}
break;
case kRinging:
if (!g_nancy->sound->isSoundPlaying(ringSound)) {
g_nancy->sound->stopSound(ringSound);
uint numberLength = calledNumber[0] == 1 ? 11 : 7;
if (!g_nancy->_sound->isSoundPlaying(_ringSound)) {
g_nancy->_sound->stopSound(_ringSound);
uint numberLength = _calledNumber[0] == 1 ? 11 : 7;
for (uint i = 0; i < calls.size(); ++i) {
for (uint i = 0; i < _calls.size(); ++i) {
bool invalid = false;
for (uint j = 0; j < numberLength; ++j) {
if (calledNumber[j] != calls[i].phoneNumber[j]) {
if (_calledNumber[j] != _calls[i].phoneNumber[j]) {
// Invalid number, move onto next
invalid = true;
break;
@ -169,48 +169,48 @@ void Telephone::execute() {
}
NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().addTextLine(calls[i].text);
NancySceneState.getTextbox().addTextLine(_calls[i].text);
genericDialogueSound.name = calls[i].soundName;
g_nancy->sound->loadSound(genericDialogueSound);
g_nancy->sound->playSound(genericDialogueSound);
selected = i;
callState = kCall;
_genericDialogueSound.name = _calls[i].soundName;
g_nancy->_sound->loadSound(_genericDialogueSound);
g_nancy->_sound->playSound(_genericDialogueSound);
_selected = i;
_callState = kCall;
return;
}
NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().addTextLine(dialAgainString);
NancySceneState.getTextbox().addTextLine(_dialAgainString);
g_nancy->sound->loadSound(dialAgainSound);
g_nancy->sound->playSound(dialAgainSound);
callState = kBadNumber;
g_nancy->_sound->loadSound(_dialAgainSound);
g_nancy->_sound->playSound(_dialAgainSound);
_callState = kBadNumber;
return;
}
break;
case kBadNumber:
if (!g_nancy->sound->isSoundPlaying(dialAgainSound)) {
g_nancy->sound->stopSound(dialAgainSound);
if (!g_nancy->_sound->isSoundPlaying(_dialAgainSound)) {
g_nancy->_sound->stopSound(_dialAgainSound);
state = kActionTrigger;
_state = kActionTrigger;
}
break;
case kCall:
if (!g_nancy->sound->isSoundPlaying(genericDialogueSound)) {
g_nancy->sound->stopSound(genericDialogueSound);
if (!g_nancy->_sound->isSoundPlaying(_genericDialogueSound)) {
g_nancy->_sound->stopSound(_genericDialogueSound);
state = kActionTrigger;
_state = kActionTrigger;
}
break;
case kHangUp:
if (!g_nancy->sound->isSoundPlaying(hangUpSound)) {
g_nancy->sound->stopSound(hangUpSound);
if (!g_nancy->_sound->isSoundPlaying(_hangUpSound)) {
g_nancy->_sound->stopSound(_hangUpSound);
state = kActionTrigger;
_state = kActionTrigger;
}
break;
@ -218,25 +218,25 @@ void Telephone::execute() {
break;
case kActionTrigger:
switch (callState) {
switch (_callState) {
case kBadNumber:
NancySceneState.changeScene(reloadScene);
calledNumber.clear();
NancySceneState.setEventFlag(flagOnReload);
state = kRun;
callState = kWaiting;
NancySceneState.changeScene(_reloadScene);
_calledNumber.clear();
NancySceneState.setEventFlag(_flagOnReload);
_state = kRun;
_callState = kWaiting;
break;
case kCall: {
PhoneCall &call = calls[selected];
NancySceneState.changeScene(call.sceneChange);
PhoneCall &call = _calls[_selected];
NancySceneState.changeScene(call._sceneChange);
NancySceneState.setEventFlag(call.flag);
break;
}
case kHangUp:
NancySceneState.changeScene(exitScene);
NancySceneState.setEventFlag(flagOnExit);
NancySceneState.changeScene(_exitScene);
NancySceneState.setEventFlag(_flagOnExit);
break;
default:
@ -253,25 +253,25 @@ void Telephone::handleInput(NancyInput &input) {
int buttonNr = -1;
// Cursor gets changed regardless of state
for (uint i = 0; i < 12; ++i) {
if (NancySceneState.getViewport().convertViewportToScreen(destRects[i]).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspot);
if (NancySceneState.getViewport().convertViewportToScreen(_destRects[i]).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspot);
buttonNr = i;
break;
}
}
if (callState != kWaiting) {
if (_callState != kWaiting) {
return;
}
if (NancySceneState.getViewport().convertViewportToScreen(exitHotspot).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kExitArrow);
if (NancySceneState.getViewport().convertViewportToScreen(_exitHotspot).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kExitArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
g_nancy->sound->loadSound(hangUpSound);
g_nancy->sound->playSound(hangUpSound);
g_nancy->_sound->loadSound(_hangUpSound);
g_nancy->_sound->playSound(_hangUpSound);
callState = kHangUp;
_callState = kHangUp;
}
return;
@ -279,33 +279,33 @@ void Telephone::handleInput(NancyInput &input) {
if (buttonNr != -1) {
if (input.input & NancyInput::kLeftMouseButtonUp) {
if (g_nancy->sound->isSoundPlaying(dialToneSound)) {
g_nancy->sound->stopSound(dialToneSound);
if (g_nancy->_sound->isSoundPlaying(_dialToneSound)) {
g_nancy->_sound->stopSound(_dialToneSound);
}
calledNumber.push_back(buttonNr);
genericButtonSound.name = buttonSoundNames[buttonNr];
g_nancy->sound->loadSound(genericButtonSound);
g_nancy->sound->playSound(genericButtonSound);
_calledNumber.push_back(buttonNr);
_genericButtonSound.name = _buttonSoundNames[buttonNr];
g_nancy->_sound->loadSound(_genericButtonSound);
g_nancy->_sound->playSound(_genericButtonSound);
drawButton(buttonNr);
selected = buttonNr;
_selected = buttonNr;
callState = kButtonPress;
_callState = kButtonPress;
}
}
}
void Telephone::drawButton(uint id) {
Common::Point destPoint(destRects[id].left - _screenPosition.left, destRects[id].top - _screenPosition.top);
_drawSurface.blitFrom(image, srcRects[id], destPoint);
Common::Point destPoint(_destRects[id].left - _screenPosition.left, _destRects[id].top - _screenPosition.top);
_drawSurface.blitFrom(_image, _srcRects[id], destPoint);
_needsRedraw = true;
}
void Telephone::undrawButton(uint id) {
Common::Rect bounds = destRects[id];
Common::Rect bounds = _destRects[id];
bounds.translate(-_screenPosition.left, -_screenPosition.top);
_drawSurface.fillRect(bounds, GraphicsManager::getTransColor());

View File

@ -43,7 +43,7 @@ public:
Common::Array<byte> phoneNumber; // 0x0, 11 bytes
Common::String soundName; // 0xB
Common::String text; // 0x15, 0xC8 bytes
SceneChangeDescription sceneChange; // 0xDD
SceneChangeDescription _sceneChange; // 0xDD
// shouldStopRendering
EventFlagDescription flag; // 0xE7
};
@ -52,8 +52,8 @@ public:
Telephone(RenderObject &redrawFrom) :
RenderObject(redrawFrom),
callState(kWaiting),
selected(0) {}
_callState(kWaiting),
_selected(0) {}
virtual ~Telephone() {}
virtual void init() override;
@ -62,30 +62,30 @@ public:
virtual void execute() override;
virtual void handleInput(NancyInput &input) override;
Common::String imageName; // 0x00
Common::Array<Common::Rect> srcRects; // 0xA, 12
Common::Array<Common::Rect> destRects; // 0xCA, 12
SoundDescription genericDialogueSound; // 0x18A
SoundDescription genericButtonSound; // 0x1AC
SoundDescription ringSound; // 0x1CE
SoundDescription dialToneSound; // 0x1F0
SoundDescription dialAgainSound; // 0x212
SoundDescription hangUpSound; // 0x234
Common::Array<Common::String> buttonSoundNames; // 0x256, 12 * 0xA
Common::String addressBookString; // 0x2CE, 0xC8 long
Common::String dialAgainString; // 0x396
SceneChangeDescription reloadScene; // 0x45E
EventFlagDescription flagOnReload; // 0x468 ??
SceneChangeDescription exitScene; // 0x46C
EventFlagDescription flagOnExit; // 0x476
Common::Rect exitHotspot; // 0x47A
Common::String _imageName; // 0x00
Common::Array<Common::Rect> _srcRects; // 0xA, 12
Common::Array<Common::Rect> _destRects; // 0xCA, 12
SoundDescription _genericDialogueSound; // 0x18A
SoundDescription _genericButtonSound; // 0x1AC
SoundDescription _ringSound; // 0x1CE
SoundDescription _dialToneSound; // 0x1F0
SoundDescription _dialAgainSound; // 0x212
SoundDescription _hangUpSound; // 0x234
Common::Array<Common::String> _buttonSoundNames; // 0x256, 12 * 0xA
Common::String _addressBookString; // 0x2CE, 0xC8 long
Common::String _dialAgainString; // 0x396
SceneChangeDescription _reloadScene; // 0x45E
EventFlagDescription _flagOnReload; // 0x468 ??
SceneChangeDescription _exitScene; // 0x46C
EventFlagDescription _flagOnExit; // 0x476
Common::Rect _exitHotspot; // 0x47A
// 0x48A numConvos
Common::Array<PhoneCall> calls; // 0x48C
Common::Array<PhoneCall> _calls; // 0x48C
Common::Array<byte> calledNumber;
Graphics::ManagedSurface image;
CallState callState;
uint selected;
Common::Array<byte> _calledNumber;
Graphics::ManagedSurface _image;
CallState _callState;
uint _selected;
protected:
virtual Common::String getRecordTypeName() const override { return "Telephone"; }

View File

@ -85,7 +85,7 @@ void NancyConsole::postEnter() {
g_system->delayMillis(10);
}
g_nancy->graphicsManager->redrawAll();
g_nancy->_graphicsManager->redrawAll();
} else {
debugPrintf("Failed to load '%s'\n", _videoFile.c_str());
}
@ -96,7 +96,7 @@ void NancyConsole::postEnter() {
if (!_imageFile.empty()) {
Graphics::Surface surf;
if (g_nancy->resource->loadImage(_imageFile, surf)) {
if (g_nancy->_resource->loadImage(_imageFile, surf)) {
g_system->fillScreen(0);
g_system->copyRectToScreen(surf.getPixels(), surf.pitch, 0, 0, surf.w > 640 ? 640 : surf.w, surf.h > 480 ? 480 : surf.h);
g_system->updateScreen();
@ -116,7 +116,7 @@ void NancyConsole::postEnter() {
g_system->delayMillis(10);
}
g_nancy->graphicsManager->redrawAll();
g_nancy->_graphicsManager->redrawAll();
} else {
debugPrintf("Failed to load image '%s'\n", _imageFile.c_str());
}
@ -126,7 +126,7 @@ void NancyConsole::postEnter() {
// After calling the console, action end events get sent to it and the input manager
// can still think a keyboard button is being held when it is not; clearing all inputs fixes that
g_nancy->input->forceCleanInput();
g_nancy->_input->forceCleanInput();
}
bool NancyConsole::Cmd_cifHexDump(int argc, const char **argv) {
@ -137,7 +137,7 @@ bool NancyConsole::Cmd_cifHexDump(int argc, const char **argv) {
}
uint size;
byte *buf = g_nancy->resource->loadCif((argc == 2 ? "ciftree" : argv[2]), argv[1], size);
byte *buf = g_nancy->_resource->loadCif((argc == 2 ? "ciftree" : argv[2]), argv[1], size);
if (!buf) {
debugPrintf("Failed to load resource '%s'\n", argv[1]);
return true;
@ -155,7 +155,7 @@ bool NancyConsole::Cmd_cifExport(int argc, const char **argv) {
return true;
}
if (!g_nancy->resource->exportCif((argc == 2 ? "ciftree" : argv[2]), argv[1]))
if (!g_nancy->_resource->exportCif((argc == 2 ? "ciftree" : argv[2]), argv[1]))
debugPrintf("Failed to export '%s'\n", argv[1]);
return true;
@ -170,7 +170,7 @@ bool NancyConsole::Cmd_cifList(int argc, const char **argv) {
}
Common::Array<Common::String> list;
g_nancy->resource->list((argc == 2 ? "ciftree" : argv[2]), list, atoi(argv[1]));
g_nancy->_resource->list((argc == 2 ? "ciftree" : argv[2]), list, atoi(argv[1]));
for (uint i = 0; i < list.size(); i++) {
debugPrintf("%-38s", list[i].c_str());
if ((i % 2) == 1 && i + 1 != list.size())
@ -189,7 +189,7 @@ bool NancyConsole::Cmd_cifInfo(int argc, const char **argv) {
return true;
}
debugPrintf("%s", g_nancy->resource->getCifDescription((argc == 2 ? "ciftree" : argv[2]), argv[1]).c_str());
debugPrintf("%s", g_nancy->_resource->getCifDescription((argc == 2 ? "ciftree" : argv[2]), argv[1]).c_str());
return true;
}
@ -272,7 +272,7 @@ bool NancyConsole::Cmd_loadCal(int argc, const char **argv) {
return true;
}
if (!g_nancy->resource->loadCifTree(argv[1], "cal"))
if (!g_nancy->_resource->loadCifTree(argv[1], "cal"))
debugPrintf("Failed to load '%s.cal'\n", argv[1]);
return true;
}

View File

@ -51,7 +51,7 @@ void CursorManager::init() {
_primaryVideoInitialPos.x = chunk->readUint16LE();
_primaryVideoInitialPos.y = chunk->readUint16LE();
g_nancy->resource->loadImage(inventoryCursorsImageName, _invCursorsSurface);
g_nancy->_resource->loadImage(inventoryCursorsImageName, _invCursorsSurface);
setCursor(kNormalArrow, -1);
showCursor(false);
@ -106,7 +106,7 @@ void CursorManager::setCursor(CursorType type, int16 itemID) {
surf = &_invCursorsSurface;
} else {
surf = &g_nancy->graphicsManager->object0;
surf = &g_nancy->_graphicsManager->_object0;
}
// TODO this is ridiculous, figure out why just calling

View File

@ -38,7 +38,7 @@ void Font::read(Common::SeekableReadStream &stream) {
stream.read(name, 10);
Common::String imageName = name;
g_nancy->resource->loadImage(name, _image);
g_nancy->_resource->loadImage(name, _image);
char desc[0x20];
stream.read(desc, 0x20);

View File

@ -39,20 +39,20 @@
namespace Nancy {
const Graphics::PixelFormat GraphicsManager::inputPixelFormat = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
const Graphics::PixelFormat GraphicsManager::screenPixelFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
const Graphics::PixelFormat GraphicsManager::clut8Format = Graphics::PixelFormat::createFormatCLUT8();
const Graphics::PixelFormat GraphicsManager::_inputPixelFormat = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
const Graphics::PixelFormat GraphicsManager::_screenPixelFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
const Graphics::PixelFormat GraphicsManager::_clut8Format = Graphics::PixelFormat::createFormatCLUT8();
void GraphicsManager::init() {
initGraphics(640, 480, &screenPixelFormat);
_screen.create(640, 480, screenPixelFormat);
initGraphics(640, 480, &_screenPixelFormat);
_screen.create(640, 480, _screenPixelFormat);
_screen.setTransparentColor(getTransColor());
_screen.clear();
Common::SeekableReadStream *ob = g_nancy->getBootChunkStream("OB0");
ob->seek(0);
g_nancy->resource->loadImage(ob->readString(), object0);
g_nancy->_resource->loadImage(ob->readString(), _object0);
loadFonts();
}
@ -220,9 +220,9 @@ void GraphicsManager::copyToManaged(void *src, Graphics::ManagedSurface &dst, ui
const Graphics::PixelFormat &GraphicsManager::getInputPixelFormat() {
if (g_nancy->getGameFlags() & NGF_8BITCOLOR) {
return clut8Format;
return _clut8Format;
} else {
return inputPixelFormat;
return _inputPixelFormat;
}
}
@ -230,7 +230,7 @@ uint GraphicsManager::getTransColor() {
if (g_nancy->getGameFlags() & NGF_8BITCOLOR) {
return 1; // If this isn't correct, try picking the pixel at [0, 0] inside the palette bitmap
} else {
return inputPixelFormat.ARGBToColor(0, 0, 255, 0);
return _inputPixelFormat.ARGBToColor(0, 0, 255, 0);
}
}

View File

@ -57,9 +57,9 @@ public:
static const Graphics::PixelFormat &getInputPixelFormat();
static uint getTransColor();
Graphics::ManagedSurface object0;
Graphics::ManagedSurface _object0;
static const Graphics::PixelFormat screenPixelFormat;
static const Graphics::PixelFormat _screenPixelFormat;
private:
void loadFonts();
@ -69,8 +69,8 @@ private:
Common::SortedArray<RenderObject *> _objects;
static const Graphics::PixelFormat inputPixelFormat;
static const Graphics::PixelFormat clut8Format;
static const Graphics::PixelFormat _inputPixelFormat;
static const Graphics::PixelFormat _clut8Format;
Graphics::Screen _screen;
Common::Array<Font> _fonts;

View File

@ -69,7 +69,7 @@ bool IFF::callback(Common::IFFChunk &c) {
bool IFF::load() {
byte *data;
uint size;
data = g_nancy->resource->loadData(_name, size);
data = g_nancy->_resource->loadData(_name, size);
if (!data) {
return false;

View File

@ -42,7 +42,7 @@ void InputManager::processEvents() {
case EVENT_KEYDOWN:
if (event.kbd.keycode == KEYCODE_d && event.kbd.flags & Common::KBD_CTRL) {
// Launch debug console
g_nancy->launchConsole = true;
g_nancy->_launchConsole = true;
} else if (event.kbd.keycode == KEYCODE_q && event.kbd.flags & Common::KBD_CTRL) {
// Quit
g_nancy->quitGame();

View File

@ -72,26 +72,26 @@ NancyEngine::NancyEngine(OSystem *syst, const NancyGameDescription *gd) : Engine
DebugMan.addDebugChannel(kDebugScene, "Scene", "Scene debug level");
_console = new NancyConsole();
randomSource = new Common::RandomSource("Nancy");
randomSource->setSeed(randomSource->getSeed());
_randomSource = new Common::RandomSource("Nancy");
_randomSource->setSeed(_randomSource->getSeed());
input = new InputManager();
sound = new SoundManager();
graphicsManager = new GraphicsManager();
cursorManager = new CursorManager();
_input = new InputManager();
_sound = new SoundManager();
_graphicsManager = new GraphicsManager();
_cursorManager = new CursorManager();
launchConsole = false;
_launchConsole = false;
}
NancyEngine::~NancyEngine() {
clearBootChunks();
DebugMan.clearAllDebugChannels();
delete _console;
delete randomSource;
delete _randomSource;
delete graphicsManager;
delete input;
delete sound;
delete _graphicsManager;
delete _input;
delete _sound;
}
NancyEngine *NancyEngine::create(GameType type, OSystem *syst, const NancyGameDescription *gd) {
@ -130,7 +130,7 @@ bool NancyEngine::canLoadGameStateCurrently() {
bool NancyEngine::canSaveGameStateCurrently() {
// TODO also disable during secondary movie
return Action::PlayPrimaryVideoChan0::activePrimaryVideo == nullptr;
return Action::PlayPrimaryVideoChan0::_activePrimaryVideo == nullptr;
}
bool NancyEngine::hasFeature(EngineFeature f) const {
@ -193,13 +193,13 @@ void NancyEngine::setState(GameState state, GameState overridePrevious) {
runDialog(*dialog);
delete dialog;
}
input->forceCleanInput();
_input->forceCleanInput();
return;
default:
break;
}
graphicsManager->clearObjects();
_graphicsManager->clearObjects();
_gameFlow.previousState = _gameFlow.currentState;
_gameFlow.currentState = getStateObject(state);
@ -230,7 +230,7 @@ void NancyEngine::setPreviousState() {
}
void NancyEngine::setMouseEnabled(bool enabled) {
cursorManager->showCursor(enabled); input->setMouseInputEnabled(enabled);
_cursorManager->showCursor(enabled); _input->setMouseInputEnabled(enabled);
}
void NancyEngine::callCheatMenu(bool eventFlags)
@ -253,18 +253,18 @@ Common::Error NancyEngine::run() {
// Main loop
while (!shouldQuit()) {
cursorManager->setCursorType(CursorManager::kNormalArrow);
input->processEvents();
_cursorManager->setCursorType(CursorManager::kNormalArrow);
_input->processEvents();
if (_gameFlow.currentState) {
_gameFlow.currentState->process();
}
graphicsManager->draw();
_graphicsManager->draw();
if (launchConsole) {
if (_launchConsole) {
_console->attach();
launchConsole = false;
_launchConsole = false;
}
_console->onFrame();
@ -300,8 +300,8 @@ void NancyEngine::bootGameEngine() {
}
}
resource = new ResourceManager();
resource->initialize();
_resource = new ResourceManager();
_resource->initialize();
// Setup mixer
syncSoundSettings();
@ -332,22 +332,22 @@ void NancyEngine::bootGameEngine() {
// Persistent sounds that are used across the engine. These originally get loaded inside Logo
SoundDescription desc;
desc.read(*g_nancy->getBootChunkStream("BUOK"), SoundDescription::kNormal);
g_nancy->sound->loadSound(desc);
g_nancy->_sound->loadSound(desc);
desc.read(*g_nancy->getBootChunkStream("BUDE"), SoundDescription::kNormal);
g_nancy->sound->loadSound(desc);
g_nancy->_sound->loadSound(desc);
desc.read(*g_nancy->getBootChunkStream("BULS"), SoundDescription::kNormal);
g_nancy->sound->loadSound(desc);
g_nancy->_sound->loadSound(desc);
desc.read(*g_nancy->getBootChunkStream("GLOB"), SoundDescription::kNormal);
g_nancy->sound->loadSound(desc);
g_nancy->_sound->loadSound(desc);
desc.read(*g_nancy->getBootChunkStream("CURT"), SoundDescription::kNormal);
g_nancy->sound->loadSound(desc);
g_nancy->_sound->loadSound(desc);
desc.read(*g_nancy->getBootChunkStream("CANT"), SoundDescription::kNormal);
g_nancy->sound->loadSound(desc);
g_nancy->_sound->loadSound(desc);
delete boot;
graphicsManager->init();
cursorManager->init();
_graphicsManager->init();
_cursorManager->init();
}
State::State *NancyEngine::getStateObject(GameState state) {
@ -405,7 +405,7 @@ void NancyEngine::preloadCals(const IFF &boot) {
stream.read(name, nameLen);
name[nameLen - 1] = 0;
debugC(1, kDebugEngine, "Preloading CAL '%s'", name);
if (!resource->loadCifTree(name, "cal"))
if (!_resource->loadCifTree(name, "cal"))
error("Failed to preload CAL '%s'", name);
}
@ -436,9 +436,9 @@ void NancyEngine::readBootSummary(const IFF &boot) {
ser.skip(0x71, kGameTypeVampire, kGameTypeVampire);
ser.skip(0xA3, kGameTypeNancy1, kGameTypeNancy2);
ser.syncAsUint16LE(firstSceneID);
ser.syncAsUint16LE(_firstSceneID);
ser.skip(4, kGameTypeNancy1, kGameTypeNancy2);
ser.syncAsUint16LE(startTimeHours, kGameTypeNancy1, kGameTypeNancy2);
ser.syncAsUint16LE(_startTimeHours, kGameTypeNancy1, kGameTypeNancy2);
ser.skip(0xB8, kGameTypeVampire, kGameTypeVampire);
ser.skip(0xA6, kGameTypeNancy1, kGameTypeNancy1);
@ -457,15 +457,15 @@ void NancyEngine::readBootSummary(const IFF &boot) {
ser.skip(0x99, kGameTypeNancy1, kGameTypeNancy1);
int16 time = 0;
ser.syncAsSint16LE(time, kGameTypeNancy1, kGameTypeNancy1);
playerTimeMinuteLength = time;
_playerTimeMinuteLength = time;
ser.skip(2, kGameTypeNancy1, kGameTypeNancy1);
ser.syncAsByte(overrideMovementTimeDeltas, kGameTypeNancy1, kGameTypeNancy1);
ser.syncAsByte(_overrideMovementTimeDeltas, kGameTypeNancy1, kGameTypeNancy1);
if (overrideMovementTimeDeltas) {
if (_overrideMovementTimeDeltas) {
ser.syncAsSint16LE(time, kGameTypeNancy1, kGameTypeNancy1);
slowMovementTimeDelta = time;
_slowMovementTimeDelta = time;
ser.syncAsSint16LE(time, kGameTypeNancy1, kGameTypeNancy1);
fastMovementTimeDelta = time;
_fastMovementTimeDelta = time;
}
}

View File

@ -136,23 +136,23 @@ public:
void callCheatMenu(bool eventFlags);
// Managers
ResourceManager *resource;
GraphicsManager *graphicsManager;
CursorManager *cursorManager;
InputManager *input;
SoundManager *sound;
ResourceManager *_resource;
GraphicsManager *_graphicsManager;
CursorManager *_cursorManager;
InputManager *_input;
SoundManager *_sound;
Common::RandomSource *randomSource;
Common::RandomSource *_randomSource;
bool launchConsole;
bool _launchConsole;
uint16 firstSceneID;
uint16 startTimeHours;
uint16 _firstSceneID;
uint16 _startTimeHours;
bool overrideMovementTimeDeltas;
Time slowMovementTimeDelta;
Time fastMovementTimeDelta;
Time playerTimeMinuteLength;
bool _overrideMovementTimeDeltas;
Time _slowMovementTimeDelta;
Time _fastMovementTimeDelta;
Time _playerTimeMinuteLength;
private:
struct GameFlow {

View File

@ -37,11 +37,11 @@ void RenderObject::init() {
}
void RenderObject::registerGraphics() {
g_nancy->graphicsManager->addObject(this);
g_nancy->_graphicsManager->addObject(this);
}
RenderObject::~RenderObject() {
g_nancy->graphicsManager->removeObject(this);
g_nancy->_graphicsManager->removeObject(this);
if (_drawSurface.getPixels()) {
_drawSurface.free();
}

View File

@ -66,7 +66,7 @@ void Credits::init() {
_pixelsToScroll = cred->readUint16LE();
_sound.read(*cred, SoundDescription::kMenu);
g_nancy->resource->loadImage(buf, _fullTextSurface);
g_nancy->_resource->loadImage(buf, _fullTextSurface);
Common::Rect src = _text._screenPosition;
src.moveTo(Common::Point());
@ -74,25 +74,25 @@ void Credits::init() {
_text.setTransparent(true);
_text.init();
g_nancy->sound->loadSound(_sound);
g_nancy->sound->playSound(_sound);
g_nancy->_sound->loadSound(_sound);
g_nancy->_sound->playSound(_sound);
_background.registerGraphics();
_text.registerGraphics();
g_nancy->cursorManager->showCursor(false);
g_nancy->_cursorManager->showCursor(false);
_state = kRun;
}
void Credits::run() {
NancyInput input = g_nancy->input->getInput();
NancyInput input = g_nancy->_input->getInput();
if (input.input & NancyInput::kLeftMouseButtonDown) {
_state = kInit;
g_nancy->sound->stopSound(_sound);
g_nancy->_sound->stopSound(_sound);
g_nancy->setState(NancyEngine::kMainMenu);
g_nancy->cursorManager->showCursor(true);
g_nancy->_cursorManager->showCursor(true);
_fullTextSurface.free();
}

View File

@ -76,29 +76,29 @@ void Help::init() {
}
void Help::begin() {
g_nancy->sound->loadSound(_sound);
g_nancy->sound->playSound(_sound);
g_nancy->_sound->loadSound(_sound);
g_nancy->_sound->playSound(_sound);
_image.registerGraphics();
_image.setVisible(true);
g_nancy->cursorManager->setCursorType(CursorManager::kNormalArrow);
g_nancy->_cursorManager->setCursorType(CursorManager::kNormalArrow);
_state = kRun;
}
void Help::run() {
NancyInput input = g_nancy->input->getInput();
NancyInput input = g_nancy->_input->getInput();
if (_hotspot.contains(input.mousePos) && input.input & NancyInput::kLeftMouseButtonUp) {
g_nancy->sound->playSound(0x18); // Hardcoded by original engine
g_nancy->_sound->playSound(0x18); // Hardcoded by original engine
_state = kWaitForSound;
}
}
void Help::waitForSound() {
if (!g_nancy->sound->isSoundPlaying(18)) {
g_nancy->sound->stopSound(_sound);
if (!g_nancy->_sound->isSoundPlaying(18)) {
g_nancy->_sound->stopSound(_sound);
g_nancy->setPreviousState();
}
}

View File

@ -61,7 +61,7 @@ void Logo::process() {
}
bool Logo::onStateExit() {
g_nancy->sound->stopSound(_msnd);
g_nancy->_sound->stopSound(_msnd);
destroy();
return true;
}
@ -78,15 +78,15 @@ void Logo::init() {
void Logo::startSound() {
_msnd.read(*g_nancy->getBootChunkStream("MSND"), SoundDescription::kMenu);
g_nancy->sound->loadSound(_msnd);
g_nancy->sound->playSound(_msnd);
g_nancy->_sound->loadSound(_msnd);
g_nancy->_sound->playSound(_msnd);
_startTicks = g_system->getMillis();
_state = kRun;
}
void Logo::run() {
if (g_system->getMillis() - _startTicks >= 7000 || (g_nancy->input->getInput().input & NancyInput::kLeftMouseButtonDown)) {
if (g_system->getMillis() - _startTicks >= 7000 || (g_nancy->_input->getInput().input & NancyInput::kLeftMouseButtonDown)) {
_state = kStop;
}
}
@ -96,7 +96,7 @@ void Logo::stop() {
// For the N+C key combo it looks for some kind of cheat file
// to initialize the game state with.
g_nancy->sound->stopSound(_msnd);
g_nancy->_sound->stopSound(_msnd);
g_nancy->setState(NancyEngine::kScene);
}

View File

@ -80,8 +80,8 @@ void Map::init() {
chunk->seek(0x18 + _mapID * 0x20, SEEK_SET);
SoundDescription sound;
sound.read(*chunk, SoundDescription::kMenu);
g_nancy->sound->loadSound(sound);
g_nancy->sound->playSound(0x14);
g_nancy->_sound->loadSound(sound);
g_nancy->_sound->playSound(0x14);
_locations.clear();
@ -116,17 +116,17 @@ void Map::init() {
}
registerGraphics();
g_nancy->cursorManager->setCursorItemID(-1);
g_nancy->_cursorManager->setCursorItemID(-1);
_state = kRun;
}
void Map::run() {
if (!g_nancy->sound->isSoundPlaying(0x14) && !g_nancy->sound->isSoundPlaying(0x13)) {
g_nancy->sound->playSound(0x13);
if (!g_nancy->_sound->isSoundPlaying(0x14) && !g_nancy->_sound->isSoundPlaying(0x13)) {
g_nancy->_sound->playSound(0x13);
}
NancyInput input = g_nancy->input->getInput();
NancyInput input = g_nancy->_input->getInput();
_label.setLabel(-1);
@ -140,7 +140,7 @@ void Map::run() {
for (uint i = 0; i < 4; ++i) {
auto &loc = _locations[i];
if (loc.isActive && _viewport.convertToScreen(loc.hotspot).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspotArrow);
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
_label.setLabel(i);
@ -159,7 +159,7 @@ bool Map::onStateExit() {
SoundDescription sound;
chunk->seek(0x18 + _mapID * 0x20, SEEK_SET);
sound.read(*chunk, SoundDescription::kMenu);
g_nancy->sound->stopSound(sound);
g_nancy->_sound->stopSound(sound);
g_nancy->setState(NancyEngine::kScene);
@ -168,11 +168,11 @@ bool Map::onStateExit() {
NancySceneState.changeScene(loc.scenes[_mapID].sceneID, loc.scenes[_mapID].frameID, loc.scenes[_mapID].verticalOffset, false);
_pickedLocationID = -1;
g_nancy->sound->playSound(0x18);
g_nancy->_sound->playSound(0x18);
}
// The two sounds play at the same time if a location was picked
g_nancy->sound->playSound(0x14);
g_nancy->_sound->playSound(0x14);
_mapButtonClicked = false;
@ -197,7 +197,7 @@ void Map::MapLabel::setLabel(int labelID) {
setVisible(false);
} else {
_screenPosition = _parent->_locations[labelID].labelDest;
_drawSurface.create(g_nancy->graphicsManager->object0, _parent->_locations[labelID].labelSrc);
_drawSurface.create(g_nancy->_graphicsManager->_object0, _parent->_locations[labelID].labelSrc);
setVisible(true);
}
}
@ -208,7 +208,7 @@ void Map::MapButton::init() {
map->seek(0x7A, SEEK_SET);
Common::Rect src;
readRect(*map, src);
_drawSurface.create(g_nancy->graphicsManager->object0, src);
_drawSurface.create(g_nancy->_graphicsManager->_object0, src);
readRect(*map, _screenPosition);
setVisible(true);

View File

@ -83,9 +83,9 @@ void Scene::SceneSummary::read(Common::SeekableReadStream &stream) {
ser.syncAsUint16LE((uint32 &)slowMoveTimeDelta);
ser.syncAsUint16LE((uint32 &)fastMoveTimeDelta);
if (g_nancy->overrideMovementTimeDeltas) {
slowMoveTimeDelta = g_nancy->slowMovementTimeDelta;
fastMoveTimeDelta = g_nancy->fastMovementTimeDelta;
if (g_nancy->_overrideMovementTimeDeltas) {
slowMoveTimeDelta = g_nancy->_slowMovementTimeDelta;
fastMoveTimeDelta = g_nancy->_fastMovementTimeDelta;
}
delete[] buf;
@ -106,10 +106,10 @@ void Scene::process() {
// fall through
case kStartSound:
_state = kRun;
if (!_sceneState._doNotStartSound) {
g_nancy->sound->stopAndUnloadSpecificSounds();
g_nancy->sound->loadSound(_sceneState.summary.sound);
g_nancy->sound->playSound(_sceneState.summary.sound);
if (!_sceneState.doNotStartSound) {
g_nancy->_sound->stopAndUnloadSpecificSounds();
g_nancy->_sound->loadSound(_sceneState.summary.sound);
g_nancy->_sound->playSound(_sceneState.summary.sound);
}
// fall through
case kRun:
@ -123,7 +123,7 @@ void Scene::onStateEnter() {
registerGraphics();
_actionManager.onPause(false);
g_nancy->graphicsManager->redrawAll();
g_nancy->_graphicsManager->redrawAll();
// Run once to clear out the previous scene when coming from Map
process();
@ -151,7 +151,7 @@ void Scene::changeScene(uint16 id, uint16 frame, uint16 verticalOffset, bool noS
_sceneState.nextScene.sceneID = id;
_sceneState.nextScene.frameID = frame;
_sceneState.nextScene.verticalOffset = verticalOffset;
_sceneState._doNotStartSound = noSound;
_sceneState.doNotStartSound = noSound;
_state = kLoad;
}
@ -173,13 +173,13 @@ void Scene::pauseSceneSpecificSounds() {
// TODO missing if, same condition as the one in SoundManager::stopAndUnloadSpecificSounds
for (uint i = 0; i < 10; ++i) {
g_nancy->sound->pauseSound(i, true);
g_nancy->_sound->pauseSound(i, true);
}
}
void Scene::unpauseSceneSpecificSounds() {
for (uint i = 0; i < 10; ++i) {
g_nancy->sound->pauseSound(i, false);
g_nancy->_sound->pauseSound(i, false);
}
}
@ -275,7 +275,7 @@ void Scene::synchronize(Common::Serializer &ser) {
ser.syncAsUint16LE(_sceneState.nextScene.sceneID);
ser.syncAsUint16LE(_sceneState.nextScene.frameID);
ser.syncAsUint16LE(_sceneState.nextScene.verticalOffset);
_sceneState._doNotStartSound = false;
_sceneState.doNotStartSound = false;
load();
}
@ -319,7 +319,7 @@ void Scene::synchronize(Common::Serializer &ser) {
// TODO hardcoded inventory size
ser.syncArray(_flags.items, 11, Common::Serializer::Byte);
ser.syncAsSint16LE(_flags.heldItem);
g_nancy->cursorManager->setCursorItemID(_flags.heldItem);
g_nancy->_cursorManager->setCursorItemID(_flags.heldItem);
ser.syncAsUint32LE((uint32 &)_timers.lastTotalTime);
ser.syncAsUint32LE((uint32 &)_timers.sceneTime);
@ -356,7 +356,7 @@ void Scene::init() {
}
_timers.lastTotalTime = 0;
_timers.playerTime = g_nancy->startTimeHours * 3600000;
_timers.playerTime = g_nancy->_startTimeHours * 3600000;
_timers.sceneTime = 0;
_timers.timerTime = 0;
_timers.timerIsActive = false;
@ -364,7 +364,7 @@ void Scene::init() {
_timers.pushedPlayTime = 0;
_timers.timeOfDay = Timers::kDay;
_sceneState.nextScene.sceneID = g_nancy->firstSceneID;
_sceneState.nextScene.sceneID = g_nancy->_firstSceneID;
Common::SeekableReadStream *chunk = g_nancy->getBootChunkStream("HINT");
@ -380,7 +380,7 @@ void Scene::init() {
_lastHint = -1;
}
Action::SliderPuzzle::playerHasTriedPuzzle = false;
Action::SliderPuzzle::_playerHasTriedPuzzle = false;
initStaticData();
@ -397,7 +397,7 @@ void Scene::init() {
}
registerGraphics();
g_nancy->graphicsManager->redrawAll();
g_nancy->_graphicsManager->redrawAll();
}
void Scene::load() {
@ -424,7 +424,7 @@ void Scene::load() {
_sceneState.summary.description.c_str(),
_sceneState.nextScene.frameID,
_sceneState.nextScene.verticalOffset,
_sceneState._doNotStartSound == true ? "true" : "false");
_sceneState.doNotStartSound == true ? "true" : "false");
// Search for Action Records, maximum for a scene is 30
Common::SeekableReadStream *actionRecordChunk = nullptr;
@ -504,7 +504,7 @@ void Scene::run() {
// Calculate the in-game time (playerTime)
if (currentPlayTime > _timers.playerTimeNextMinute) {
_timers.playerTime += 60000; // Add a minute
_timers.playerTimeNextMinute = currentPlayTime + g_nancy->playerTimeMinuteLength;
_timers.playerTimeNextMinute = currentPlayTime + g_nancy->_playerTimeMinuteLength;
}
// Set the time of day according to playerTime
@ -517,7 +517,7 @@ void Scene::run() {
}
// Update the UI elements and handle input
NancyInput input = g_nancy->input->getInput();
NancyInput input = g_nancy->_input->getInput();
_viewport.handleInput(input);
_menuButton.handleInput(input);
_helpButton.handleInput(input);
@ -532,7 +532,7 @@ void Scene::run() {
for (uint i = 0; i < _mapAccessSceneIDs.size(); ++i) {
if (_sceneState.currentScene.sceneID == _mapAccessSceneIDs[i]) {
if (_mapHotspot.contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspotArrow);
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
requestStateChange(NancyEngine::kMap);
@ -569,7 +569,7 @@ void Scene::initStaticData() {
_inventoryBox.init();
_menuButton.init();
_helpButton.init();
g_nancy->cursorManager->showCursor(true);
g_nancy->_cursorManager->showCursor(true);
_state = kLoad;
}

View File

@ -130,7 +130,7 @@ public:
void addItemToInventory(uint16 id);
void removeItemFromInventory(uint16 id, bool pickUp = true);
int16 getHeldItem() const { return _flags.heldItem; }
void setHeldItem(int16 id) { _flags.heldItem = id; g_nancy->cursorManager->setCursorItemID(id); }
void setHeldItem(int16 id) { _flags.heldItem = id; g_nancy->_cursorManager->setCursorItemID(id); }
NancyFlag hasItem(int16 id) const { return _flags.items[id]; }
void setEventFlag(int16 label, NancyFlag flag = kTrue);
@ -195,7 +195,7 @@ private:
SceneInfo pushedScene;
bool isScenePushed;
bool _doNotStartSound = false;
bool doNotStartSound = false;
};
struct Timers {

View File

@ -36,7 +36,7 @@ namespace UI {
void Button::handleInput(NancyInput &input) {
if (_screenPosition.contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspotArrow);
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
onClick();
@ -50,7 +50,7 @@ void MenuButton::init() {
bsum->seek(0x184, SEEK_SET);
Common::Rect src;
readRect(*bsum, src);
_drawSurface.create(g_nancy->graphicsManager->object0, src);
_drawSurface.create(g_nancy->_graphicsManager->_object0, src);
bsum->skip(16);
readRect(*bsum, _screenPosition);
setVisible(false);
@ -60,7 +60,7 @@ void MenuButton::init() {
void MenuButton::onClick() {
NancySceneState.requestStateChange(NancyEngine::kMainMenu);
g_nancy->sound->playSound(0x18);
g_nancy->_sound->playSound(0x18);
setVisible(true);
}
@ -70,7 +70,7 @@ void HelpButton::init() {
bsum->seek(0x194, SEEK_SET);
Common::Rect src;
readRect(*bsum, src);
_drawSurface.create(g_nancy->graphicsManager->object0, src);
_drawSurface.create(g_nancy->_graphicsManager->_object0, src);
bsum->skip(16);
readRect(*bsum, _screenPosition);
setVisible(false);
@ -80,7 +80,7 @@ void HelpButton::init() {
void HelpButton::onClick() {
NancySceneState.requestStateChange(NancyEngine::kHelp);
g_nancy->sound->playSound(0x18);
g_nancy->_sound->playSound(0x18);
setVisible(true);
}

View File

@ -30,7 +30,7 @@ namespace Nancy {
namespace UI {
void FullScreenImage::init(const Common::String &imageName) {
g_nancy->resource->loadImage(imageName, _drawSurface);
g_nancy->_resource->loadImage(imageName, _drawSurface);
Common::Rect srcBounds = Common::Rect(0,0, _drawSurface.w, _drawSurface.h);
_screenPosition = srcBounds;

View File

@ -72,10 +72,10 @@ void InventoryBox::init() {
readRect(stream, _itemDescriptions[i].sourceRect);
}
g_nancy->resource->loadImage(inventoryBoxIconsImageName, _iconsSurface);
g_nancy->_resource->loadImage(inventoryBoxIconsImageName, _iconsSurface);
uint numItems = 11; // TODO
_fullInventorySurface.create(_screenPosition.width(), _screenPosition.height() * ((numItems / 4) + 1), GraphicsManager::screenPixelFormat);
_fullInventorySurface.create(_screenPosition.width(), _screenPosition.height() * ((numItems / 4) + 1), GraphicsManager::_screenPixelFormat);
Common::Rect sourceRect = _screenPosition;
sourceRect.moveTo(0, 0);
_drawSurface.create(_fullInventorySurface, sourceRect);
@ -116,16 +116,16 @@ void InventoryBox::handleInput(NancyInput &input) {
for (uint i = 0; i < 4; ++i) {
if (_itemHotspots[i].hotspot.contains(input.mousePos)) {
if (NancySceneState.getHeldItem() != -1) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspotArrow);
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
NancySceneState.addItemToInventory(NancySceneState.getHeldItem());
g_nancy->sound->playSound(0x16);
g_nancy->_sound->playSound(0x16);
}
} else if (_itemHotspots[i].itemID != -1) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspotArrow);
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
NancySceneState.removeItemFromInventory(_itemHotspots[i].itemID);
g_nancy->sound->playSound(0x18);
g_nancy->_sound->playSound(0x18);
}
}
break;
@ -209,7 +209,7 @@ void InventoryBox::InventoryScrollbar::init() {
Common::Rect &srcBounds = _parent->_sliderSource;
Common::Point &topPosition = _parent->_sliderDefaultDest;
_drawSurface.create(g_nancy->graphicsManager->object0, srcBounds);
_drawSurface.create(g_nancy->_graphicsManager->_object0, srcBounds);
_startPosition = topPosition;
_startPosition.x -= srcBounds.width() / 2;
@ -224,7 +224,7 @@ void InventoryBox::InventoryScrollbar::init() {
void InventoryBox::Shades::init() {
Common::Rect bounds = _parent->getBounds();
_drawSurface.create(bounds.width(), bounds.height(), GraphicsManager::screenPixelFormat);
_drawSurface.create(bounds.width(), bounds.height(), GraphicsManager::_screenPixelFormat);
_screenPosition = _parent->getScreenPosition();
_nextFrameTime = 0;
setAnimationFrame(_curFrame);
@ -243,7 +243,7 @@ void InventoryBox::Shades::updateGraphics() {
if (!_soundTriggered) {
_soundTriggered = true;
g_nancy->sound->playSound(0x12);
g_nancy->_sound->playSound(0x12);
}
}
} else {
@ -253,7 +253,7 @@ void InventoryBox::Shades::updateGraphics() {
if (!_soundTriggered) {
_soundTriggered = true;
g_nancy->sound->playSound(0x12);
g_nancy->_sound->playSound(0x12);
}
}
}
@ -264,7 +264,7 @@ void InventoryBox::Shades::updateGraphics() {
}
void InventoryBox::Shades::setAnimationFrame(uint frame) {
Graphics::ManagedSurface &object0 = g_nancy->graphicsManager->object0;
Graphics::ManagedSurface &_object0 = g_nancy->_graphicsManager->_object0;
Common::Rect srcRect;
Common::Point destPoint;
@ -279,12 +279,12 @@ void InventoryBox::Shades::setAnimationFrame(uint frame) {
// Draw left shade
srcRect = _parent->_shadesSrc[frame * 2];
_drawSurface.blitFrom(object0, srcRect, destPoint);
_drawSurface.blitFrom(_object0, srcRect, destPoint);
// Draw right shade
srcRect = _parent->_shadesSrc[frame * 2 + 1];
destPoint.x = getBounds().width() - srcRect.width();
_drawSurface.blitFrom(object0, srcRect, destPoint);
_drawSurface.blitFrom(_object0, srcRect, destPoint);
_needsRedraw = true;
}

View File

@ -41,7 +41,7 @@ void Scrollbar::init() {
void Scrollbar::handleInput(NancyInput &input) {
if (_screenPosition.contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspotArrow);
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
if (input.input & NancyInput::kLeftMouseButtonDown && !_isClicked) {
// Begin click and hold

View File

@ -38,14 +38,14 @@
namespace Nancy {
namespace UI {
const char Textbox::CCBeginToken[] = "<i>";
const char Textbox::CCEndToken[] = "<o>";
const char Textbox::colorBeginToken[] = "<c1>";
const char Textbox::colorEndToken[] = "<c0>";
const char Textbox::hotspotToken[] = "<h>";
const char Textbox::newLineToken[] = "<n>";
const char Textbox::tabToken[] = "<t>";
const char Textbox::telephoneEndToken[] = "<e>";
const char Textbox::_CCBeginToken[] = "<i>";
const char Textbox::_CCEndToken[] = "<o>";
const char Textbox::_colorBeginToken[] = "<c1>";
const char Textbox::_colorEndToken[] = "<c0>";
const char Textbox::_hotspotToken[] = "<h>";
const char Textbox::_newLineToken[] = "<n>";
const char Textbox::_tabToken[] = "<t>";
const char Textbox::_telephoneEndToken[] = "<e>";
void Textbox::init() {
Common::SeekableReadStream *chunk = g_nancy->getBootChunkStream("TBOX");
@ -55,7 +55,7 @@ void Textbox::init() {
chunk->seek(0x20);
Common::Rect innerBoundingBox;
readRect(*chunk, innerBoundingBox);
_fullSurface.create(innerBoundingBox.width(), innerBoundingBox.height(), GraphicsManager::screenPixelFormat);
_fullSurface.create(innerBoundingBox.width(), innerBoundingBox.height(), GraphicsManager::_screenPixelFormat);
_scrollbarDefaultDest.x = chunk->readUint16LE();
_scrollbarDefaultDest.y = chunk->readUint16LE();
@ -108,7 +108,7 @@ void Textbox::handleInput(NancyInput &input) {
Common::Rect hotspot = _hotspots[i];
hotspot.translate(0, -_drawSurface.getOffsetFromOwner().y);
if (convertToScreen(hotspot).findIntersectingRect(_screenPosition).contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kHotspotArrow);
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
input.input &= ~NancyInput::kLeftMouseButtonUp;
@ -126,7 +126,7 @@ void Textbox::drawTextbox() {
_numLines = 0;
Font *font = g_nancy->graphicsManager->getFont(_fontID);
Font *font = g_nancy->_graphicsManager->getFont(_fontID);
uint maxWidth = _fullSurface.w - _borderWidth * 2;
uint lineDist = _lineHeight + _lineHeight / 4;
@ -140,40 +140,40 @@ void Textbox::drawTextbox() {
Rect hotspot;
// Trim the begin and end tokens from the line
if (currentLine.hasPrefix(CCBeginToken) && currentLine.hasSuffix(CCEndToken)) {
currentLine = currentLine.substr(ARRAYSIZE(CCBeginToken) - 1, currentLine.size() - ARRAYSIZE(CCBeginToken) - ARRAYSIZE(CCEndToken) + 2);
if (currentLine.hasPrefix(_CCBeginToken) && currentLine.hasSuffix(_CCEndToken)) {
currentLine = currentLine.substr(ARRAYSIZE(_CCBeginToken) - 1, currentLine.size() - ARRAYSIZE(_CCBeginToken) - ARRAYSIZE(_CCEndToken) + 2);
}
// Replace every newline token with \n
uint32 newLinePos;
while (newLinePos = currentLine.find(newLineToken), newLinePos != String::npos) {
currentLine.replace(newLinePos, ARRAYSIZE(newLineToken) - 1, "\n");
while (newLinePos = currentLine.find(_newLineToken), newLinePos != String::npos) {
currentLine.replace(newLinePos, ARRAYSIZE(_newLineToken) - 1, "\n");
}
// Simply remove telephone end token
if (currentLine.hasSuffix(telephoneEndToken)) {
currentLine = currentLine.substr(0, currentLine.size() - ARRAYSIZE(telephoneEndToken) + 1);
if (currentLine.hasSuffix(_telephoneEndToken)) {
currentLine = currentLine.substr(0, currentLine.size() - ARRAYSIZE(_telephoneEndToken) + 1);
}
// Remove hotspot token and mark that we need to calculate the bounds
// Assumes a single text line has a single hotspot
uint32 hotspotPos = currentLine.find(hotspotToken);
uint32 hotspotPos = currentLine.find(_hotspotToken);
if (hotspotPos != String::npos) {
currentLine.erase(hotspotPos, ARRAYSIZE(hotspotToken) - 1);
currentLine.erase(hotspotPos, ARRAYSIZE(_hotspotToken) - 1);
hasHotspot = true;
}
// Subdivide current line into sublines for proper handling of the tab and color tokens
// Assumes the tab token is on a new line
while (!currentLine.empty()) {
if (currentLine.hasPrefix(tabToken)) {
if (currentLine.hasPrefix(_tabToken)) {
horizontalOffset += font->getStringWidth(" "); // Replace tab with 4 spaces
currentLine = currentLine.substr(ARRAYSIZE(tabToken) - 1);
currentLine = currentLine.substr(ARRAYSIZE(_tabToken) - 1);
}
String currentSubLine;
uint32 nextTabPos = currentLine.find(tabToken);
uint32 nextTabPos = currentLine.find(_tabToken);
if (nextTabPos != String::npos) {
currentSubLine = currentLine.substr(0, nextTabPos);
currentLine = currentLine.substr(nextTabPos);
@ -183,12 +183,12 @@ void Textbox::drawTextbox() {
}
// Assumes color token will be at the beginning of the line, and color string will not need wrapping
if (currentSubLine.hasPrefix(colorBeginToken)) {
if (currentSubLine.hasPrefix(_colorBeginToken)) {
// Found color string, look for end token
uint32 colorEndPos = currentSubLine.find(colorEndToken);
uint32 colorEndPos = currentSubLine.find(_colorEndToken);
Common::String colorSubLine = currentSubLine.substr(ARRAYSIZE(colorBeginToken) - 1, colorEndPos - ARRAYSIZE(colorBeginToken) + 1);
currentSubLine = currentSubLine.substr(ARRAYSIZE(colorBeginToken) + ARRAYSIZE(colorEndToken) + colorSubLine.size() - 2);
Common::String colorSubLine = currentSubLine.substr(ARRAYSIZE(_colorBeginToken) - 1, colorEndPos - ARRAYSIZE(_colorBeginToken) + 1);
currentSubLine = currentSubLine.substr(ARRAYSIZE(_colorBeginToken) + ARRAYSIZE(_colorEndToken) + colorSubLine.size() - 2);
// Draw the color line
font->drawString(&_fullSurface, colorSubLine, _borderWidth + horizontalOffset, _firstLineOffset - font->getFontHeight() + _numLines * lineDist, maxWidth, 1);
@ -289,7 +289,7 @@ void Textbox::TextboxScrollbar::init() {
Common::Rect &srcBounds = _parent->_scrollbarSourceBounds;
Common::Point &topPosition = _parent->_scrollbarDefaultDest;
_drawSurface.create(g_nancy->graphicsManager->object0, srcBounds);
_drawSurface.create(g_nancy->_graphicsManager->_object0, srcBounds);
_startPosition = topPosition;
_startPosition.x -= srcBounds.width() / 2;

View File

@ -107,16 +107,14 @@ private:
bool _needsTextRedraw;
float _scrollbarPos;
static const char CCBeginToken[];
static const char CCEndToken[];
static const char colorBeginToken[];
static const char colorEndToken[];
static const char hotspotToken[];
static const char newLineToken[];
static const char tabToken[];
static const char telephoneEndToken[];
protected:
static const char _CCBeginToken[];
static const char _CCEndToken[];
static const char _colorBeginToken[];
static const char _colorEndToken[];
static const char _hotspotToken[];
static const char _newLineToken[];
static const char _tabToken[];
static const char _telephoneEndToken[];
};
} // End of namespace UI

View File

@ -63,7 +63,7 @@ void Viewport::handleInput(NancyInput &input) {
byte direction = 0;
if (_screenPosition.contains(input.mousePos)) {
g_nancy->cursorManager->setCursorType(CursorManager::kNormal);
g_nancy->_cursorManager->setCursorType(CursorManager::kNormal);
}
// Do not handle hotspots marked as incative and ignore diagonals if intersecting hotspots are not active
@ -120,7 +120,7 @@ void Viewport::handleInput(NancyInput &input) {
}
if (direction) {
g_nancy->cursorManager->setCursorType(CursorManager::kMove);
g_nancy->_cursorManager->setCursorType(CursorManager::kMove);
if (input.input & NancyInput::kRightMouseButton) {
direction |= kMoveFast;