ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

state.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef VARIABLES_H_
00024 #define VARIABLES_H_
00025 
00026 #include "common/hashmap.h"
00027 #include "common/hash-str.h"
00028 #include "common/savefile.h"
00029 #include "common/serializer.h"
00030 
00031 #include "engines/myst3/myst3.h"
00032 
00033 namespace Myst3 {
00034 
00035 class Database;
00036 
00037 // View type
00038 enum ViewType {
00039     kCube = 1,
00040     kFrame = 2,
00041     kMenu = 3
00042 };
00043 
00044 #define DECLARE_VAR(name) \
00045     void set##name(int32 value) { engineSet(#name, value); } \
00046     int32 get##name() { return engineGet(#name); } \
00047     bool hasVar##name() { return _varDescriptions.contains(#name); }
00048 
00049 class GameState {
00050 public:
00051     GameState(const Common::Platform platform, Database *database);
00052     virtual ~GameState();
00053 
00054     void newGame();
00055     bool load(Common::InSaveFile *saveFile);
00056     bool save(Common::OutSaveFile *saveFile, const Common::String &description, const Graphics::Surface *thumbnail);
00057 
00058     int32 getVar(uint16 var);
00059     void setVar(uint16 var, int32 value);
00060     bool evaluate(int16 condition);
00061     int32 valueOrVarValue(int16 value);
00062 
00063     const Common::String describeVar(uint16 var);
00064     const Common::String describeCondition(int16 condition);
00065 
00066     DECLARE_VAR(CursorTransparency)
00067 
00068     DECLARE_VAR(ProjectorAngleX)
00069     DECLARE_VAR(ProjectorAngleY)
00070     DECLARE_VAR(ProjectorAngleZoom)
00071     DECLARE_VAR(ProjectorAngleBlur)
00072     DECLARE_VAR(DraggedWeight)
00073 
00074     DECLARE_VAR(DragEnded)
00075     DECLARE_VAR(DragLeverSpeed)
00076     DECLARE_VAR(DragPositionFound)
00077     DECLARE_VAR(DragLeverPositionChanged)
00078 
00079     DECLARE_VAR(LocationAge)
00080     DECLARE_VAR(LocationRoom)
00081     DECLARE_VAR(LocationNode)
00082     DECLARE_VAR(BookSavedAge)
00083     DECLARE_VAR(BookSavedRoom)
00084     DECLARE_VAR(BookSavedNode)
00085     DECLARE_VAR(MenuSavedAge)
00086     DECLARE_VAR(MenuSavedRoom)
00087     DECLARE_VAR(MenuSavedNode)
00088 
00089     DECLARE_VAR(SecondsCountdown)
00090     DECLARE_VAR(TickCountdown)
00091 
00092     DECLARE_VAR(SweepEnabled)
00093     DECLARE_VAR(SweepValue)
00094     DECLARE_VAR(SweepStep)
00095     DECLARE_VAR(SweepMin)
00096     DECLARE_VAR(SweepMax)
00097 
00098     DECLARE_VAR(InputMousePressed)
00099     DECLARE_VAR(InputEscapePressed)
00100     DECLARE_VAR(InputTildePressed)
00101     DECLARE_VAR(InputSpacePressed)
00102 
00103     DECLARE_VAR(HotspotActiveRect)
00104 
00105     DECLARE_VAR(WaterEffectRunning)
00106     DECLARE_VAR(WaterEffectActive)
00107     DECLARE_VAR(WaterEffectSpeed)
00108     DECLARE_VAR(WaterEffectAttenuation)
00109     DECLARE_VAR(WaterEffectFrequency)
00110     DECLARE_VAR(WaterEffectAmpl)
00111     DECLARE_VAR(WaterEffectMaxStep)
00112     DECLARE_VAR(WaterEffectAmplOffset)
00113 
00114     DECLARE_VAR(LavaEffectActive)
00115     DECLARE_VAR(LavaEffectSpeed)
00116     DECLARE_VAR(LavaEffectAmpl)
00117     DECLARE_VAR(LavaEffectStepSize)
00118 
00119     DECLARE_VAR(MagnetEffectActive)
00120     DECLARE_VAR(MagnetEffectSpeed)
00121     DECLARE_VAR(MagnetEffectUnk1)
00122     DECLARE_VAR(MagnetEffectUnk2)
00123     DECLARE_VAR(MagnetEffectSound)
00124     DECLARE_VAR(MagnetEffectNode)
00125     DECLARE_VAR(MagnetEffectUnk3)
00126 
00127     DECLARE_VAR(ShakeEffectAmpl)
00128     DECLARE_VAR(ShakeEffectTickPeriod)
00129     DECLARE_VAR(RotationEffectSpeed)
00130     DECLARE_VAR(SunspotIntensity)
00131     DECLARE_VAR(SunspotColor)
00132     DECLARE_VAR(SunspotRadius)
00133 
00134     DECLARE_VAR(AmbiantFadeOutDelay)
00135     DECLARE_VAR(AmbiantPreviousFadeOutDelay)
00136     DECLARE_VAR(AmbientOverrideFadeOutDelay)
00137     DECLARE_VAR(SoundScriptsSuspended)
00138 
00139     DECLARE_VAR(SoundNextMultipleSounds)
00140     DECLARE_VAR(SoundNextIsChoosen)
00141     DECLARE_VAR(SoundNextId)
00142     DECLARE_VAR(SoundNextIsLast)
00143     DECLARE_VAR(SoundScriptsTimer)
00144     DECLARE_VAR(SoundScriptsPaused)
00145     DECLARE_VAR(SoundScriptFadeOutDelay)
00146 
00147     DECLARE_VAR(CursorLocked)
00148     DECLARE_VAR(CursorHidden)
00149 
00150     DECLARE_VAR(CameraPitch)
00151     DECLARE_VAR(CameraHeading)
00152     DECLARE_VAR(CameraMinPitch)
00153     DECLARE_VAR(CameraMaxPitch)
00154 
00155     DECLARE_VAR(MovieStartFrame)
00156     DECLARE_VAR(MovieEndFrame)
00157     DECLARE_VAR(MovieVolume1)
00158     DECLARE_VAR(MovieVolume2)
00159     DECLARE_VAR(MovieOverrideSubtitles)
00160     DECLARE_VAR(MovieConditionBit)
00161     DECLARE_VAR(MoviePreloadToMemory)
00162     DECLARE_VAR(MovieScriptDriven)
00163     DECLARE_VAR(MovieNextFrameSetVar)
00164     DECLARE_VAR(MovieNextFrameGetVar)
00165     DECLARE_VAR(MovieStartFrameVar)
00166     DECLARE_VAR(MovieEndFrameVar)
00167     DECLARE_VAR(MovieForce2d)
00168     DECLARE_VAR(MovieVolumeVar)
00169     DECLARE_VAR(MovieSoundHeading)
00170     DECLARE_VAR(MoviePanningStrenght)
00171     DECLARE_VAR(MovieSynchronized)
00172     DECLARE_VAR(MovieOverrideCondition)
00173     DECLARE_VAR(MovieUVar)
00174     DECLARE_VAR(MovieVVar)
00175     DECLARE_VAR(MovieOverridePosition)
00176     DECLARE_VAR(MovieOverridePosU)
00177     DECLARE_VAR(MovieOverridePosV)
00178     DECLARE_VAR(MovieAdditiveBlending)
00179     DECLARE_VAR(MovieTransparency)
00180     DECLARE_VAR(MovieTransparencyVar)
00181     DECLARE_VAR(MoviePlayingVar)
00182     DECLARE_VAR(MovieStartSoundId)
00183     DECLARE_VAR(MovieStartSoundVolume)
00184     DECLARE_VAR(MovieStartSoundHeading)
00185     DECLARE_VAR(MovieStartSoundAttenuation)
00186 
00187     DECLARE_VAR(MovieUseBackground)
00188     DECLARE_VAR(CameraSkipAnimation)
00189     DECLARE_VAR(MovieAmbiantScriptStartFrame)
00190     DECLARE_VAR(MovieAmbiantScript)
00191     DECLARE_VAR(MovieScriptStartFrame)
00192     DECLARE_VAR(MovieScript)
00193 
00194     DECLARE_VAR(CameraMoveSpeed)
00195 
00196     DECLARE_VAR(TransitionSound)
00197     DECLARE_VAR(TransitionSoundVolume)
00198 
00199     DECLARE_VAR(LocationNextNode)
00200     DECLARE_VAR(LocationNextRoom)
00201     DECLARE_VAR(LocationNextAge)
00202 
00203     DECLARE_VAR(BallPosition)
00204     DECLARE_VAR(BallFrame)
00205     DECLARE_VAR(BallLeverLeft)
00206     DECLARE_VAR(BallLeverRight)
00207 
00208     DECLARE_VAR(BallDoorOpen)
00209 
00210     DECLARE_VAR(ProjectorX)
00211     DECLARE_VAR(ProjectorY)
00212     DECLARE_VAR(ProjectorZoom)
00213     DECLARE_VAR(ProjectorBlur)
00214     DECLARE_VAR(ProjectorAngleXOffset)
00215     DECLARE_VAR(ProjectorAngleYOffset)
00216     DECLARE_VAR(ProjectorAngleZoomOffset)
00217     DECLARE_VAR(ProjectorAngleBlurOffset)
00218 
00219     DECLARE_VAR(JournalAtrusState)
00220     DECLARE_VAR(JournalSaavedroState)
00221     DECLARE_VAR(JournalSaavedroClosed)
00222     DECLARE_VAR(JournalSaavedroOpen)
00223     DECLARE_VAR(JournalSaavedroLastPage)
00224     DECLARE_VAR(JournalSaavedroChapter)
00225     DECLARE_VAR(JournalSaavedroPageInChapter)
00226 
00227     DECLARE_VAR(TeslaAllAligned)
00228     DECLARE_VAR(TeslaTopAligned)
00229     DECLARE_VAR(TeslaMiddleAligned)
00230     DECLARE_VAR(TeslaBottomAligned)
00231     DECLARE_VAR(TeslaMovieStart)
00232 
00233     DECLARE_VAR(AmateriaSecondsCounter)
00234     DECLARE_VAR(AmateriaTicksCounter)
00235 
00236     DECLARE_VAR(ResonanceRingsSolved)
00237 
00238     DECLARE_VAR(PinballRemainingPegs)
00239 
00240     DECLARE_VAR(OuterShieldUp)
00241     DECLARE_VAR(InnerShieldUp)
00242     DECLARE_VAR(SaavedroStatus)
00243 
00244     DECLARE_VAR(BookStateTomahna)
00245     DECLARE_VAR(BookStateReleeshahn)
00246 
00247     DECLARE_VAR(SymbolCode2Solved)
00248     DECLARE_VAR(SymbolCode1AllSolved)
00249     DECLARE_VAR(SymbolCode1CurrentSolved)
00250     DECLARE_VAR(SymbolCode1TopSolved)
00251     DECLARE_VAR(SymbolCode1LeftSolved)
00252     DECLARE_VAR(SymbolCode1RightSolved)
00253 
00254     DECLARE_VAR(SoundVoltaicUnk540)
00255     DECLARE_VAR(SoundEdannaUnk587)
00256     DECLARE_VAR(SoundAmateriaUnk627)
00257     DECLARE_VAR(SoundAmateriaUnk930)
00258     DECLARE_VAR(SoundEdannaUnk1031)
00259     DECLARE_VAR(SoundVoltaicUnk1146)
00260 
00261     DECLARE_VAR(ZipModeEnabled)
00262     DECLARE_VAR(SubtitlesEnabled)
00263     DECLARE_VAR(WaterEffects)
00264     DECLARE_VAR(TransitionSpeed)
00265     DECLARE_VAR(MouseSpeed)
00266     DECLARE_VAR(DialogResult)
00267 
00268     DECLARE_VAR(MenuEscapePressed)
00269     DECLARE_VAR(MenuNextAction)
00270     DECLARE_VAR(MenuLoadBack)
00271     DECLARE_VAR(MenuSaveBack)
00272     DECLARE_VAR(MenuSaveAction)
00273     DECLARE_VAR(MenuOptionsBack)
00274 
00275     DECLARE_VAR(MenuSaveLoadPageLeft)
00276     DECLARE_VAR(MenuSaveLoadPageRight)
00277     DECLARE_VAR(MenuSaveLoadSelectedItem)
00278     DECLARE_VAR(MenuSaveLoadCurrentPage)
00279 
00280     DECLARE_VAR(OverallVolume)
00281     DECLARE_VAR(MusicVolume)
00282     DECLARE_VAR(MusicFrequency)
00283     DECLARE_VAR(LanguageAudio)
00284     DECLARE_VAR(LanguageText)
00285     DECLARE_VAR(HotspotIgnoreClick)
00286     DECLARE_VAR(HotspotHovered)
00287     DECLARE_VAR(SpotSubtitle)
00288 
00289     DECLARE_VAR(DragLeverLimited)
00290     DECLARE_VAR(DragLeverLimitMin)
00291     DECLARE_VAR(DragLeverLimitMax)
00292 
00293     DECLARE_VAR(ShieldEffectActive)
00294 
00295     // Xbox specific variables
00296     DECLARE_VAR(GamePadActionPressed)
00297     DECLARE_VAR(GamePadDownPressed)
00298     DECLARE_VAR(GamePadUpPressed)
00299     DECLARE_VAR(GamePadLeftPressed)
00300     DECLARE_VAR(GamePadRightPressed)
00301     DECLARE_VAR(GamePadCancelPressed)
00302 
00303     DECLARE_VAR(DragWithDirectionKeys)
00304     DECLARE_VAR(MenuSavesAvailable)
00305     DECLARE_VAR(MenuSelectedSave)
00306     DECLARE_VAR(MenuAttractCountDown)
00307     DECLARE_VAR(MovieOptional)
00308     DECLARE_VAR(VibrationEnabled)
00309     DECLARE_VAR(StateCanSave)
00310 
00311     void updateFrameCounters();
00312     uint getTickCount() const;
00313 
00315     void pauseEngine(bool pause);
00316 
00317     ViewType getViewType() { return static_cast<ViewType>(_data.currentNodeType); }
00318     void setViewType(ViewType t) { _data.currentNodeType = t; }
00319 
00320     float getLookAtFOV() { return _data.lookatFOV; }
00321     void setLookAtFOV(float fov) { _data.lookatFOV = fov; }
00322     float getLookAtPitch() { return _data.lookatPitch; }
00323     float getLookAtHeading() { return _data.lookatHeading; }
00324     void lookAt(float pitch, float heading) { _data.lookatPitch = pitch; _data.lookatHeading = heading; }
00325 
00326     void limitCubeCamera(float minPitch, float maxPitch, float minHeading, float maxHeading);
00327     void freeCubeCamera() { _data.limitCubeCamera = false; }
00328     bool isCameraLimited() { return _data.limitCubeCamera != 0; }
00329     float getMinPitch() { return _data.minPitch; }
00330     float getMaxPitch() { return _data.maxPitch; }
00331     float getMinHeading() { return _data.minHeading; }
00332     float getMaxHeading() { return _data.maxHeading; }
00333 
00334     void markNodeAsVisited(uint16 node, uint16 room, uint32 age);
00335     bool isZipDestinationAvailable(uint16 node, uint16 room, uint32 age);
00336 
00337     Common::String formatSaveTime();
00338 
00339     Common::Array<uint16> getInventory();
00340     void updateInventory(const Common::Array<uint16> &items);
00341 
00342     struct StateData {
00343         uint32 version;
00344         uint32 gameRunning;
00345         uint32 tickCount;
00346         uint32 nextSecondsUpdate;
00347         uint32 secondsPlayed;
00348         uint32 dword_4C2C44;
00349         uint32 dword_4C2C48;
00350         uint32 dword_4C2C4C;
00351         uint32 dword_4C2C50;
00352         uint32 dword_4C2C54;
00353         uint32 dword_4C2C58;
00354         uint32 dword_4C2C5C;
00355         uint32 dword_4C2C60;
00356         uint32 currentNodeType;
00357         float lookatPitch;
00358         float lookatHeading;
00359         float lookatFOV;
00360         float pitchOffset;
00361         float headingOffset;
00362         uint32 limitCubeCamera;
00363         float minPitch;
00364         float maxPitch;
00365         float minHeading;
00366         float maxHeading;
00367         uint32  dword_4C2C90;
00368         int32 vars[2048];
00369         uint32 inventoryCount;
00370         uint32 inventoryList[7];
00371         uint32 zipDestinations[64];
00372 
00373         uint8 saveDay;
00374         uint8 saveMonth;
00375         uint16 saveYear;
00376 
00377         uint8 saveHour;
00378         uint8 saveMinute;
00379 
00380         Common::String saveDescription;
00381 
00382         StateData();
00383         void syncWithSaveGame(Common::Serializer &s);
00384     };
00385 
00386     static const Graphics::PixelFormat getThumbnailSavePixelFormat();
00387     static Graphics::Surface *readThumbnail(Common::ReadStream *inStream);
00388     static void writeThumbnail(Common::WriteStream *outStream, const Graphics::Surface *thumbnail);
00389     static Graphics::Surface *resizeThumbnail(Graphics::Surface *big, uint width, uint height);
00390 
00391     static const uint kThumbnailWidth = 240;
00392     static const uint kThumbnailHeight = 135;
00393 
00394 private:
00395     const Common::Platform _platform;
00396     Database *_db;
00397 
00398     static const uint32 kSaveVersion = 149;
00399 
00400     StateData _data;
00401 
00402     static const uint32 kTickDuration = 1000 / 30;
00403     uint32 _lastTickStartTime;
00404 
00405     struct VarDescription {
00406         VarDescription() : var(0), name(0), unknown(0) {}
00407         VarDescription(uint16 v, const char *n, bool u) : var(v), name(n), unknown(u) {}
00408 
00409         uint16 var;
00410         const char *name;
00411         bool unknown;
00412     };
00413 
00414     typedef Common::HashMap<Common::String, VarDescription> VarMap;
00415 
00416     VarMap _varDescriptions;
00417 
00418     void checkRange(uint16 var);
00419     const VarDescription findDescription(uint16 var);
00420     void shiftVariables(uint16 base, int32 value);
00421 
00422     int32 engineGet(const Common::String &varName);
00423     void engineSet(const Common::String &varName, int32 value);
00424 
00425     static void syncFloat(Common::Serializer &s, float &val,
00426             Common::Serializer::Version minVersion = 0,
00427             Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion);
00428 
00429     void updateTickCounters();
00430 };
00431 
00435 struct Saves {
00437     static Common::String buildName(const char *name, Common::Platform platform);
00438 
00440     static Common::StringArray list(Common::SaveFileManager *saveFileManager, Common::Platform platform);
00441 };
00442 
00443 } // End of namespace Myst3
00444 
00445 #endif // VARIABLES_H_


Generated on Sat Feb 16 2019 05:01:05 for ResidualVM by doxygen 1.7.1
curved edge   curved edge