From dd1a2b65e9a79b4d643c5b8fe3a8a35dd03c80c0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Sep 2016 14:16:11 -0400 Subject: TITANIC: Extra loading logic and translation code for German version --- engines/titanic/core/saveable_object.cpp | 4 +- engines/titanic/game/arboretum_gate.cpp | 63 ++++++++++++++++++++ engines/titanic/game/arboretum_gate.h | 25 ++++++++ engines/titanic/game/code_wheel.cpp | 12 +++- engines/titanic/game/code_wheel.h | 3 + .../titanic/pet_control/pet_show_translation.cpp | 68 +++++++++++++++++++--- engines/titanic/pet_control/pet_show_translation.h | 4 +- engines/titanic/support/files_manager.cpp | 11 +++- engines/titanic/support/files_manager.h | 4 +- engines/titanic/titanic.cpp | 2 +- 10 files changed, 180 insertions(+), 16 deletions(-) diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index f84ca23c5f..630404a6ee 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -740,7 +740,7 @@ DEFFN(CPetModePanel); DEFFN(CPetPannel1); DEFFN(CPetPannel2); DEFFN(CPetPannel3); -DEFFN(CPetShowTranslation); +DEFFN(CPETShowTranslation); DEFFN(CSendToSucc); DEFFN(CSGTSelector); DEFFN(CSliderButton); @@ -1331,7 +1331,7 @@ void CSaveableObject::initClassList() { ADDFN(CPetPannel1, CPetGraphic); ADDFN(CPetPannel2, CPetGraphic); ADDFN(CPetPannel3, CPetGraphic); - ADDFN(CPetShowTranslation, CGameObject); + ADDFN(CPETShowTranslation, CGameObject); ADDFN(CSendToSucc, CToggleSwitch); ADDFN(CSGTSelector, CPetGraphic); ADDFN(CSliderButton, CSTButton); diff --git a/engines/titanic/game/arboretum_gate.cpp b/engines/titanic/game/arboretum_gate.cpp index 1435e3e204..1f684fdcc0 100644 --- a/engines/titanic/game/arboretum_gate.cpp +++ b/engines/titanic/game/arboretum_gate.cpp @@ -21,6 +21,7 @@ */ #include "titanic/game/arboretum_gate.h" +#include "titanic/titanic.h" namespace Titanic { @@ -68,6 +69,14 @@ CArboretumGate::CArboretumGate() : CBackground() { _endFrameWinterOn1 = 364; _startFrameWinterOn2 = 365; _endFrameWinterOn2 = 424; + + // German specific fields + _field160 = _field164 = _field168 = _field16C = 0; + _field170 = _field174 = _field178 = _field17C = 0; + _field180 = _field184 = _field188 = _field18C = 0; + _field190 = _field194 = _field198 = _field19C = 0; + _field1A0 = _field1A4 = _field1A8 = _field1AC = 0; + _field1B0 = _field1B4 = _field1B8 = _field1BC = 0; } void CArboretumGate::save(SimpleFile *file, int indent) { @@ -104,6 +113,33 @@ void CArboretumGate::save(SimpleFile *file, int indent) { file->writeNumberLine(_endFrameWinterOn2, indent); file->writeQuotedLine(_viewName2, indent); + if (g_vm->getLanguage() == Common::DE_DEU) { + file->writeNumberLine(_field160, indent); + file->writeNumberLine(_field164, indent); + file->writeNumberLine(_field168, indent); + file->writeNumberLine(_field16C, indent); + file->writeNumberLine(_field170, indent); + file->writeNumberLine(_field174, indent); + file->writeNumberLine(_field178, indent); + file->writeNumberLine(_field17C, indent); + file->writeNumberLine(_field180, indent); + file->writeNumberLine(_field184, indent); + file->writeNumberLine(_field188, indent); + file->writeNumberLine(_field18C, indent); + file->writeNumberLine(_field190, indent); + file->writeNumberLine(_field194, indent); + file->writeNumberLine(_field198, indent); + file->writeNumberLine(_field19C, indent); + file->writeNumberLine(_field1A0, indent); + file->writeNumberLine(_field1A4, indent); + file->writeNumberLine(_field1A8, indent); + file->writeNumberLine(_field1AC, indent); + file->writeNumberLine(_field1B0, indent); + file->writeNumberLine(_field1B4, indent); + file->writeNumberLine(_field1B8, indent); + file->writeNumberLine(_field1BC, indent); + } + CBackground::save(file, indent); } @@ -141,6 +177,33 @@ void CArboretumGate::load(SimpleFile *file) { _endFrameWinterOn2 = file->readNumber(); _viewName2 = file->readString(); + if (g_vm->getLanguage() == Common::DE_DEU) { + _field160 = file->readNumber(); + _field164 = file->readNumber(); + _field168 = file->readNumber(); + _field16C = file->readNumber(); + _field170 = file->readNumber(); + _field174 = file->readNumber(); + _field178 = file->readNumber(); + _field17C = file->readNumber(); + _field180 = file->readNumber(); + _field184 = file->readNumber(); + _field188 = file->readNumber(); + _field18C = file->readNumber(); + _field190 = file->readNumber(); + _field194 = file->readNumber(); + _field198 = file->readNumber(); + _field19C = file->readNumber(); + _field1A0 = file->readNumber(); + _field1A4 = file->readNumber(); + _field1A8 = file->readNumber(); + _field1AC = file->readNumber(); + _field1B0 = file->readNumber(); + _field1B4 = file->readNumber(); + _field1B8 = file->readNumber(); + _field1BC = file->readNumber(); + } + CBackground::load(file); } diff --git a/engines/titanic/game/arboretum_gate.h b/engines/titanic/game/arboretum_gate.h index b1c06cf773..efb4e81ae9 100644 --- a/engines/titanic/game/arboretum_gate.h +++ b/engines/titanic/game/arboretum_gate.h @@ -72,6 +72,31 @@ private: int _startFrameWinterOn2; int _endFrameWinterOn2; CString _viewName2; + // German specific fields + int _field160; + int _field164; + int _field168; + int _field16C; + int _field170; + int _field174; + int _field178; + int _field17C; + int _field180; + int _field184; + int _field188; + int _field18C; + int _field190; + int _field194; + int _field198; + int _field19C; + int _field1A0; + int _field1A4; + int _field1A8; + int _field1AC; + int _field1B0; + int _field1B4; + int _field1B8; + int _field1BC; public: CLASSDEF; CArboretumGate(); diff --git a/engines/titanic/game/code_wheel.cpp b/engines/titanic/game/code_wheel.cpp index 94ee25435a..cd492ec856 100644 --- a/engines/titanic/game/code_wheel.cpp +++ b/engines/titanic/game/code_wheel.cpp @@ -21,6 +21,7 @@ */ #include "titanic/game/code_wheel.h" +#include "titanic/titanic.h" namespace Titanic { @@ -31,7 +32,8 @@ BEGIN_MESSAGE_MAP(CodeWheel, CBomb) ON_MESSAGE(MovieEndMsg) END_MESSAGE_MAP() -CodeWheel::CodeWheel() : CBomb(), _field108(0), _state(4), _field110(0) { +CodeWheel::CodeWheel() : CBomb(), _field108(0), _state(4), + _field110(0), _field114(0), _field118(0) { } void CodeWheel::save(SimpleFile *file, int indent) { @@ -39,6 +41,10 @@ void CodeWheel::save(SimpleFile *file, int indent) { file->writeNumberLine(_field108, indent); file->writeNumberLine(_state, indent); file->writeNumberLine(_field110, indent); + if (g_vm->getLanguage() == Common::DE_DEU) { + file->writeNumberLine(_field114, indent); + file->writeNumberLine(_field118, indent); + } CBomb::save(file, indent); } @@ -48,6 +54,10 @@ void CodeWheel::load(SimpleFile *file) { _field108 = file->readNumber(); _state = file->readNumber(); _field110 = file->readNumber(); + if (g_vm->getLanguage() == Common::DE_DEU) { + _field114 = file->readNumber(); + _field118 = file->readNumber(); + } CBomb::load(file); } diff --git a/engines/titanic/game/code_wheel.h b/engines/titanic/game/code_wheel.h index e38a45b631..de246f56c4 100644 --- a/engines/titanic/game/code_wheel.h +++ b/engines/titanic/game/code_wheel.h @@ -37,6 +37,9 @@ private: int _field108; int _state; int _field110; + // German specific fields + int _field114; + int _field118; public: CLASSDEF; CodeWheel(); diff --git a/engines/titanic/pet_control/pet_show_translation.cpp b/engines/titanic/pet_control/pet_show_translation.cpp index 2a3b024324..cf52916b3b 100644 --- a/engines/titanic/pet_control/pet_show_translation.cpp +++ b/engines/titanic/pet_control/pet_show_translation.cpp @@ -25,7 +25,7 @@ namespace Titanic { -BEGIN_MESSAGE_MAP(CPetShowTranslation, CGameObject) +BEGIN_MESSAGE_MAP(CPETShowTranslation, CGameObject) ON_MESSAGE(EnterViewMsg) ON_MESSAGE(LeaveViewMsg) ON_MESSAGE(ChangeSeasonMsg) @@ -33,17 +33,17 @@ BEGIN_MESSAGE_MAP(CPetShowTranslation, CGameObject) END_MESSAGE_MAP() -void CPetShowTranslation::save(SimpleFile *file, int indent) { +void CPETShowTranslation::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); } -void CPetShowTranslation::load(SimpleFile *file) { +void CPETShowTranslation::load(SimpleFile *file) { file->readNumber(); CGameObject::load(file); } -bool CPetShowTranslation::EnterViewMsg(CEnterViewMsg *msg) { +bool CPETShowTranslation::EnterViewMsg(CEnterViewMsg *msg) { CPetControl *pet = getPetControl(); if (!pet) return true; @@ -113,15 +113,69 @@ bool CPetShowTranslation::EnterViewMsg(CEnterViewMsg *msg) { return true; } -bool CPetShowTranslation::LeaveViewMsg(CLeaveViewMsg *msg) { +bool CPETShowTranslation::LeaveViewMsg(CLeaveViewMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet) + pet->clearTranslation(); + return true; } -bool CPetShowTranslation::ChangeSeasonMsg(CChangeSeasonMsg *msg) { +bool CPETShowTranslation::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet) { + pet->clearTranslation(); + + CString viewName = getFullViewName(); + if (viewName == "Arboretum.Node 2.N" || viewName == "FrozenArboretum.Node 2.N") { + if (msg->_season == "Summer") + pet->addTranslation(DE_SUMMER_ARBORETUM, DE_SUMMER); + else if (msg->_season == "Autumn") + pet->addTranslation(DE_AUTUMN_ARBORETUM, DE_AUTUMN); + else if (msg->_season == "Winter") + pet->addTranslation(DE_WINTER_ARBORETUM, DE_WINTER); + else if (msg->_season == "Spring") + pet->addTranslation(DE_SPRING_ARBORETUM, DE_SPRING); + + pet->addTranslation(DE_ARBORETUM_MSG1, DE_ARBORETUM_MSG2); + } + } + return true; } -bool CPetShowTranslation::ArboretumGateMsg(CArboretumGateMsg *msg) { +bool CPETShowTranslation::ArboretumGateMsg(CArboretumGateMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet) { + pet->clearTranslation(); + + CString viewName = getFullViewName(); + if (viewName == "Arboretum.Node 2.N" || viewName == "FrozenArboretum.Node 2.N") { + switch (stateGetSeason()) { + case SEASON_SUMMER: + pet->addTranslation(DE_SUMMER_ARBORETUM, DE_SUMMER); + break; + + case SEASON_AUTUMN: + pet->addTranslation(DE_AUTUMN_ARBORETUM, DE_AUTUMN); + break; + + case SEASON_WINTER: + pet->addTranslation(DE_WINTER_ARBORETUM, DE_WINTER); + break; + + case SEASON_SPRING: + pet->addTranslation(DE_SPRING_ARBORETUM, DE_SPRING); + break; + + default: + break; + } + + pet->addTranslation(DE_ARBORETUM_MSG1, DE_ARBORETUM_MSG2); + } + } + return true; } diff --git a/engines/titanic/pet_control/pet_show_translation.h b/engines/titanic/pet_control/pet_show_translation.h index cef9708616..a0feae8504 100644 --- a/engines/titanic/pet_control/pet_show_translation.h +++ b/engines/titanic/pet_control/pet_show_translation.h @@ -31,7 +31,7 @@ namespace Titanic { * Used by the German version to show contextual translation of * English background text throughout the game */ -class CPetShowTranslation: public CGameObject { +class CPETShowTranslation: public CGameObject { DECLARE_MESSAGE_MAP; bool EnterViewMsg(CEnterViewMsg *msg); bool LeaveViewMsg(CLeaveViewMsg *msg); @@ -39,7 +39,7 @@ class CPetShowTranslation: public CGameObject { bool ArboretumGateMsg(CArboretumGateMsg *msg); public: CLASSDEF; - CPetShowTranslation() : CGameObject() {} + CPETShowTranslation() : CGameObject() {} /** * Save the data for the class to file diff --git a/engines/titanic/support/files_manager.cpp b/engines/titanic/support/files_manager.cpp index ee3a3e1cde..836d35b717 100644 --- a/engines/titanic/support/files_manager.cpp +++ b/engines/titanic/support/files_manager.cpp @@ -24,11 +24,12 @@ #include "common/memstream.h" #include "titanic/support/files_manager.h" #include "titanic/game_manager.h" +#include "titanic/titanic.h" namespace Titanic { -CFilesManager::CFilesManager() : _gameManager(nullptr), _assetsPath("Assets"), - _drive(-1) { +CFilesManager::CFilesManager(TitanicEngine *vm) : _vm(vm), _gameManager(nullptr), + _assetsPath("Assets"), _drive(-1) { loadResourceIndex(); } @@ -122,6 +123,12 @@ void CFilesManager::preload(const CString &name) { Common::SeekableReadStream *CFilesManager::getResource(const CString &str) { ResourceEntry resEntry = _resources[str]; + + // If we're running the German version, check for the existance of + // a German specific version of the given resource + if (_vm->getLanguage() == Common::DE_DEU && _resources.contains(str + "/DE")) + resEntry = _resources[str + "/DE"]; + _datFile.seek(resEntry._offset); return (resEntry._size > 0) ? _datFile.readStream(resEntry._size) : diff --git a/engines/titanic/support/files_manager.h b/engines/titanic/support/files_manager.h index 6f56327968..a980ef1b25 100644 --- a/engines/titanic/support/files_manager.h +++ b/engines/titanic/support/files_manager.h @@ -29,6 +29,7 @@ namespace Titanic { +class TitanicEngine; class CGameManager; class CFilesManagerList : public List { @@ -44,6 +45,7 @@ class CFilesManager { }; typedef Common::HashMap ResourceHash; private: + TitanicEngine *_vm; CGameManager *_gameManager; Common::File _datFile; ResourceHash _resources; @@ -53,7 +55,7 @@ private: private: void loadResourceIndex(); public: - CFilesManager(); + CFilesManager(TitanicEngine *vm); ~CFilesManager(); /** diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp index 3a721b6095..375908a814 100644 --- a/engines/titanic/titanic.cpp +++ b/engines/titanic/titanic.cpp @@ -85,7 +85,7 @@ void TitanicEngine::initialize() { DebugMan.addDebugChannel(kDebugSound, "sound", "Sound and Music handling"); _debugger = new Debugger(this); - _filesManager = new CFilesManager(); + _filesManager = new CFilesManager(this); CSaveableObject::initClassList(); CEnterExitFirstClassState::init(); -- cgit v1.2.3