ScummVM API documentation
Macs2::Macs2Engine Class Reference
Inheritance diagram for Macs2::Macs2Engine:
Engine Macs2::Events Macs2::UIElement

Classes

struct  HotspotSnapshot
 
struct  TranslationEntry
 

Public Types

enum  InputMode { None, Record, Playback }
 
- Public Types inherited from Engine
enum  EngineFeature {
  kSupportsSubtitleOptions, kSupportsReturnToLauncher, kSupportsLoadingDuringRuntime, kSupportsSavingDuringRuntime,
  kSupportsChangingOptionsDuringRuntime, kSupportsArbitraryResolutions, kSupportsHelp, kSupportsQuitDialogOverride
}
 

Public Member Functions

Graphics::ManagedSurface readRLEImage (int64 offs, Common::MemoryReadStream *stream)
 
void readResourceFile ()
 
void readExecutable ()
 
void readBackgroundAnimations (Common::MemoryReadStream *stream)
 
void readImageResources (Common::MemoryReadStream *stream)
 
 Macs2Engine (OSystem *osystem, const ADGameDescription *gameDesc)
 
void changeScene (uint32 newSceneIndex, bool executeScript=true)
 
bool getPathfindingOverride (uint16 index, uint16 &result)
 
void setPathfindingOverride (uint16 index, uint16 overrideValue)
 
uint16 getPathfindingOverride2 (uint16 index)
 
void removePathfindingOverride (uint16 index)
 
uint16 getWalkabilityAt (int16 y, int16 x)
 
bool isPathWalkable (int16 y1, int16 x1, int16 y2, int16 x2)
 
void snapToWalkablePosition (int16 *pTargetY, int16 *pTargetX, int16 charY, int16 charX)
 
int getPathfindingNodeCount () const
 
int euclideanDistance (const Common::Point &a, const Common::Point &b)
 
int walkableDistance (int nodeA, int nodeB)
 
int computeMinCostToReachable (int nodeIndex, int prevNode, uint16 actorIndex, const bool *reachable, int nodeCount, const Common::Point &finalDest)
 
bool loadOverlayFont (uint8 resourceIndex, uint16 executingObjectID)
 
bool findGlyph (char c, GlyphData &out) const
 
void setCursorMode (Script::MouseMode newMode)
 
void nextCursorMode ()
 
void applyPaletteDarkening ()
 
void applyScenePaletteEffect ()
 
void updateBackgroundAnimationPalette ()
 
bool loadAnimationFromSceneData (uint16 objectIndex, uint16 slotIndex, uint8 arrayIndex, bool shouldMirror=false, uint16 executingScriptObjectId=0)
 
bool loadObjectData (GameObject *obj)
 
void clearObjectRuntime (GameObject *obj)
 
void sortObjectsByDepth (uint16 objectIndex)
 
void loadSongFromSceneData (uint8 dataIndex)
 
MusicgetAdlib () const
 
uint16 scaledMusicVolume (uint16 gameAttenuation) const
 
void setCurrentSoundData (const Common::Array< uint8 > &data)
 
void clearCurrentSoundData ()
 
void playCurrentSound ()
 
void stopCurrentSound ()
 
bool hasCurrentSound () const
 
bool isCurrentSoundPlaying () const
 
uint16 getHotspotAtPoint (const Common::Point &p)
 
void runScriptExecutor (bool firstRun=false)
 
void setGameSpeedMode (uint16 mode)
 
void startInputRecording (const Common::Path &filename)
 
void startInputPlayback (const Common::Path &filename)
 
void stopInputRecording ()
 
void recordInputFrame (uint16 mouseX, uint16 mouseY, uint16 buttons)
 
bool readInputFrame (uint16 &mouseX, uint16 &mouseY, uint16 &buttons)
 
void scheduleRun (bool initScene=false)
 
uint16 getWalkabilityAt (const Common::Point &p)
 
int measureString (const Common::String &s)
 
int measureStrings (const Common::StringArray &sa)
 
int measureStringsVertically (const Common::StringArray &sa)
 
Common::StringArray decodeStrings (Common::MemoryReadStream *stream, int offset, int numStrings, int sceneId=0, int objectId=0)
 
void loadTranslation ()
 
Common::String translateHotspotLabel (const Common::String &cp850Name) const
 
int computeStringIndex (Common::MemoryReadStream *stream, int targetOffset)
 
uint32 getFeatures () const
 
bool isDemo () const
 
Common::String getGameId () const
 
bool hasFeature (EngineFeature f) const override
 
void syncSoundSettings () override
 
bool canLoadGameStateCurrently (Common::U32String *msg=nullptr) override
 
bool canSaveGameStateCurrently (Common::U32String *msg=nullptr) override
 
Common::Error loadGameState (int slot) override
 
Common::Error syncGame (Common::Serializer &s)
 
Common::Error saveGameStream (Common::WriteStream *stream, bool isAutosave=false) override
 
Common::Error loadGameStream (Common::SeekableReadStream *stream) override
 
Common::Error saveOriginalGameState (int dosSlot)
 
bool tick () override
 
void sayText (const Common::String &text, Common::TextToSpeechManager::Action action=Common::TextToSpeechManager::INTERRUPT_NO_REPEAT) const
 
void getHotspotPositions (Common::Array< Graphics::HotspotInfo > &hotspots) override
 
bool hotspotDirty () const override
 
void rebuildHotspotSnapshot () const
 
- Public Member Functions inherited from Engine
virtual void showHotspots (bool show)
 
MetaEnginegetMetaEngine () const
 
void setMetaEngine (MetaEngine *metaEngine)
 
PauseToken pauseEngine ()
 
bool isPaused () const
 
void openMainMenuDialog ()
 
uint32 getTotalPlayTime () const
 
void setTotalPlayTime (uint32 time=0)
 
Common::TimerManagergetTimerManager ()
 
Common::EventManagergetEventManager ()
 
Common::SaveFileManagergetSaveFileManager ()
 
bool existExtractedCDAudioFiles (uint track=1)
 
bool isDataAndCDAudioReadFromSameCD ()
 
void warnMissingExtractedCDAudio ()
 
void handleAutoSave ()
 
void saveAutosaveIfEnabled ()
 
virtual bool canSaveAutosaveCurrently ()
 
virtual int getAutosaveSlot () const
 
virtual bool gameTypeHasAddOns () const
 
virtual bool dirCanBeGameAddOn (const Common::FSDirectory &dir) const
 
virtual bool dirMustBeGameAddOn (const Common::FSDirectory &dir) const
 
Common::ErrorCode updateAddOns (const MetaEngine *metaEngine) const
 
 Engine (OSystem *syst)
 
virtual ~Engine ()
 
virtual void initializePath (const Common::FSNode &gamePath)
 
virtual void errorString (const char *buf_input, char *buf_output, int buf_output_size)
 
virtual GUI::DebuggergetDebugger () final
 
void setDebugger (GUI::Debugger *debugger)
 
GUI::DebuggergetOrCreateDebugger ()
 
bool enhancementEnabled (int32 cls)
 
virtual void applyGameSettings ()
 
virtual void flipMute ()
 
virtual Common::String getSaveStateName (int slot) const
 
void setGameToLoadSlot (int slot)
 
virtual Common::Error saveGameState (int slot, const Common::String &desc, bool isAutosave=false)
 
bool saveGameDialog ()
 
bool loadGameDialog ()
 
- Public Member Functions inherited from Macs2::Events
void runGame ()
 
void addView (UIElement *ui)
 
UIElementfocusedView () const
 
Graphics::ScreengetScreen () const
 
void drawElements ()
 
void draw () override
 
- Public Member Functions inherited from Macs2::UIElement
 UIElement (const Common::String &name, UIElement *uiParent)
 
 UIElement (const Common::String &name)
 
void redraw ()
 
Graphics::ManagedSurface getSurface () const
 
virtual UIElementfindView (const Common::String &name)
 

Static Public Member Functions

static bool isWalkabilityBlocking (uint16 value)
 
static bool isWalkabilityWalkable (uint16 value)
 
- Static Public Member Functions inherited from Engine
static void quitGame ()
 
static bool shouldQuit ()
 
static bool warnUserAboutUnsupportedGame (Common::String msg=Common::String())
 
static bool warnUserAboutUnsupportedAddOn (Common::String addOnName)
 
static void warnUserAboutTestingMode ()
 
static void errorAddingAddOnWithoutBaseGame (Common::String addOnName, Common::String gameId)
 
static void errorUnsupportedGame (Common::String extraMsg)
 

Public Attributes

Script::ScriptExecutor_scriptExecutor = nullptr
 
Graphics::ManagedSurface _sceneBackground
 
Graphics::ManagedSurface _hotspotMap
 
uint32 _mapImageFileOffset = 0
 
int64 _mapSubSceneTableFilePos = 0
 
Graphics::ManagedSurface _depthMap
 
Graphics::ManagedSurface _shadowMap
 
byte _pal [256 *3] = {0}
 
byte _palVanilla [256 *3] = {0}
 
Common::Array< Common::String_debugOutput
 
Common::Array< Common::String_textLog
 
Graphics::ManagedSurface _pathfindingMap
 
Common::Array< PathfindingAreaOverride_pathfindingOverrides
 
uint16 _areaOverrides [(239 - 200+1)] = {0}
 
uint16 _pathfindingPoints [32]
 
Common::Array< PathfindingPointpathfindingPoints
 
Common::Array< Common::Point_path
 
Common::Array< uint16 > _hotspotOverrides
 
Common::Array< Macs2::AnimFrame_imageResources
 
GlyphData _glyphs [256]
 
GlyphData _panelGlyphs [256]
 
GlyphData _overlayGlyphs [256]
 
uint16 numOverlayGlyphs = 0
 
uint16 maxOverlayGlyphHeight = 0
 
uint16 numPanelGlyphs = 0
 
uint16 maxPanelGlyphHeight = 0
 
uint16 numGlyphs = 79
 
uint16 maxGlyphHeight
 
AnimFrame _animFrames [6]
 
Common::Array< byte > _shadingTable
 
Common::Array< byte > _panelRemapTable
 
uint32 _mapSceneOffsets [256] = {0}
 
Common::Array< BackgroundAnimation_backgroundAnimations
 
Common::Array< BackgroundAnimationBlob_backgroundAnimationsBlobs
 
Common::MemoryReadStream_fileStream
 
Common::Array< uint16 > _hotspotColorTable
 
uint16 _numPathfindingPoints
 
uint16 _walkDepthThresholdY
 
uint16 _walkDepthScaleFactor
 
uint16 _walkBaseSpeedPct
 
uint16 _scenePaletteMode
 
uint16 _paletteDarkenPercent
 
bool _movementFinishedFlag = false
 
Common::Array< uint32 > _sceneResourceOffsets
 
uint16 _numHotspots
 
uint32 _sceneTimerParams [4] = {0}
 
bool _clipRectDirty = false
 
Common::Array< uint16 > inventoryIconIndices
 
Common::Array< uint16 > containerInventoryIconIndices
 
bool _runScheduled = false
 
bool _scheduledRunIsInitScene = false
 
uint16 _gameSpeedMode = 0
 
InputMode _inputMode = InputMode::None
 
Common::WriteStream_inputRecordStream = nullptr
 
Common::SeekableReadStream_inputPlaybackStream = nullptr
 
uint32 _inputFrameCounter = 0
 
uint32 _inputPlaybackEndFrame = 0
 
Common::Array< uint8 > _currentSoundData
 
Audio::SoundHandle _currentSoundHandle
 
Common::HashMap< uint32, TranslationEntry_sceneTranslations
 
Common::HashMap< uint32, TranslationEntry_objectTranslations
 
Common::HashMap< Common::String, Common::String_hotspotLabelTranslations
 
HotspotSnapshot _hotspotSnapshot
 
- Public Attributes inherited from Engine
OSystem_system
 
Audio::Mixer_mixer
 
- Public Attributes inherited from Macs2::Events
uint32 currentMillis = 0
 

Protected Member Functions

Common::Error run () override
 
bool shouldQuit () const override
 
- Protected Member Functions inherited from Engine
virtual int runDialog (GUI::Dialog &dialog)
 
void defaultSyncSoundSettings ()
 
virtual void pauseEngineIntern (bool pause)
 
virtual void drawHotspots ()
 
- Protected Member Functions inherited from Macs2::Events
void processEvent (Common::Event &ev)
 
bool msgAction (const ActionMessage &e) override
 
bool msgFocus (const FocusMessage &e) override
 
bool msgUnfocus (const UnfocusMessage &e) override
 
bool msgKeypress (const KeypressMessage &e) override
 
bool msgMouseDown (const MouseDownMessage &e) override
 
bool msgMouseUp (const MouseUpMessage &e) override
 
- Protected Member Functions inherited from Macs2::UIElement
virtual bool msgMouseMove (const MouseMoveMessage &e)
 

Additional Inherited Members

- Protected Attributes inherited from Engine
Common::TimerManager_timer
 
Common::EventManager_eventMan
 
Common::SaveFileManager_saveFileMan
 
GUI::Dialog_mainMenuDialog
 
const Common::String _targetName
 
int32 _activeEnhancements = kEnhGameBreakingBugFixes
 
bool _showHotspots
 
bool _hotspotForceRedraw
 
bool _hotspotPrevCursorVisible
 
- Protected Attributes inherited from Macs2::UIElement
Common::Array< UIElement * > _children
 
Common::Rect _innerBounds
 
Bounds _bounds
 
bool _needsRedraw = true
 
Common::String _name
 

Member Function Documentation

◆ run()

Common::Error Macs2::Macs2Engine::run ( )
overrideprotectedvirtual

Initialize the engine and start its main loop.

Returns
kNoError on success, otherwise an error code.

Implements Engine.

◆ shouldQuit()

bool Macs2::Macs2Engine::shouldQuit ( ) const
inlineoverrideprotectedvirtual

Returns true if the game should quit

Implements Macs2::Events.

◆ getGameId()

Common::String Macs2::Macs2Engine::getGameId ( ) const

Returns the game Id

◆ hasFeature()

bool Macs2::Macs2Engine::hasFeature ( EngineFeature  f) const
inlineoverridevirtual

Determine whether the engine supports the specified feature.

Reimplemented from Engine.

◆ syncSoundSettings()

void Macs2::Macs2Engine::syncSoundSettings ( )
overridevirtual

Notify the engine that the sound settings in the config manager might have changed and that it should adjust any internal volume (and other) values accordingly.

The default implementation sets the volume levels of all mixer sound types according to the config entries of the active domain. When overwriting, call the default implementation first, then adjust the volumes further (if required).

Note
When setting volume levels, respect the "mute" config entry.
The volume for the plain sound type is reset to the maximum volume. If the engine can associate its own value for this type, it needs to overwrite this member and set it accordingly.

Reimplemented from Engine.

◆ canLoadGameStateCurrently()

bool Macs2::Macs2Engine::canLoadGameStateCurrently ( Common::U32String msg = nullptr)
inlineoverridevirtual

Indicate whether a game state can be loaded.

Parameters
msgOptional pointer to message explaining why it is disabled

Reimplemented from Engine.

◆ canSaveGameStateCurrently()

bool Macs2::Macs2Engine::canSaveGameStateCurrently ( Common::U32String msg = nullptr)
inlineoverridevirtual

Indicate whether a game state can be saved.

Parameters
msgOptional pointer to message explaining why it is disabled

Reimplemented from Engine.

◆ loadGameState()

Common::Error Macs2::Macs2Engine::loadGameState ( int  slot)
overridevirtual

Load a game state.

Parameters
slotThe slot from which a save state should be loaded.
Returns
kNoError on success, otherwise an error code.

Reimplemented from Engine.

◆ syncGame()

Common::Error Macs2::Macs2Engine::syncGame ( Common::Serializer s)

Uses a serializer to allow implementing savegame loading and saving using a single method. Produces binary-compatible saves with the original DOS game.

◆ saveGameStream()

Common::Error Macs2::Macs2Engine::saveGameStream ( Common::WriteStream stream,
bool  isAutosave = false 
)
inlineoverridevirtual

Save a game state.

Parameters
streamThe write stream to save the savegame data to.
isAutosaveExpected to be true if an autosave is being created.
Returns
kNoError on success, otherwise an error code.

Reimplemented from Engine.

◆ loadGameStream()

Common::Error Macs2::Macs2Engine::loadGameStream ( Common::SeekableReadStream stream)
inlineoverridevirtual

Load a game state.

Parameters
streamThe stream to load the save state from.
Returns
kNoError on success, otherwise an error code.

Reimplemented from Engine.

◆ tick()

bool Macs2::Macs2Engine::tick ( )
overridevirtual

Called once every game frame

Reimplemented from Macs2::Events.

◆ getHotspotPositions()

void Macs2::Macs2Engine::getHotspotPositions ( Common::Array< Graphics::HotspotInfo > &  hotspots)
overridevirtual

Get information about all hotspots that should be displayed.

Engines should override this method to populate the hotspots array with hotspot information in game screen coordinates.

Parameters
hotspotsArray to be filled with hotspot information

Reimplemented from Engine.

◆ hotspotDirty()

bool Macs2::Macs2Engine::hotspotDirty ( ) const
overridevirtual

Returns whether hotspot markers need to be re-rendered this frame.

The default implementation always returns true. Engines may override this to return false when hotspot positions have not changed (e.g. no object state change, no screen pan), avoiding an unnecessary overlay redraw.

Returns
true if hotspots should be re-rendered, false to skip

Reimplemented from Engine.


The documentation for this class was generated from the following file: