Public Member Functions | |
StarTrekEngine (OSystem *syst, const StarTrekGameDescription *gamedesc) | |
Common::Error | run () override |
Common::Error | runGameMode (int mode, bool resume) |
void | runTransportSequence (const Common::String &name) |
void | initBridge (bool b) |
void | loadBridge () |
void | loadBridgeActors () |
void | cleanupBridge () |
void | runBridge () |
void | setBridgeMouseCursor () |
void | playBridgeSequence (int sequenceId) |
void | handleBridgeEvents () |
void | handleBridgeComputer () |
void | showMissionPerformance (int score, int missionScoreTextId, int missionId) |
void | playMovie (Common::String filename) |
void | playMovieMac (Common::String filename) |
uint16 | getRandomWord () |
void | initAwayMission () |
void | runAwayMission () |
void | cleanupAwayMission () |
void | loadRoom (const Common::String &missionName, int roomIndex) |
void | initAwayCrewPositions (int warpEntryIndex) |
void | handleAwayMissionEvents () |
void | awayMissionLeftClick () |
void | awayMissionSelectAction (bool openActionMenu) |
void | awayMissionUseObject (int16 clickedObject) |
void | awayMissionGetLookOrTalk (int16 clickedObject) |
void | unloadRoom () |
int | loadActorAnimWithRoomScaling (int actorIndex, const Common::String &animName, int16 x, int16 y) |
Fixed8 | getActorScaleAtPosition (int16 y) |
void | addAction (const Action &action) |
void | addAction (int8 type, byte b1, byte b2, byte b3) |
void | handleAwayMissionAction () |
void | checkTouchedLoadingZone (int16 x, int16 y) |
void | updateAwayMissionTimers () |
bool | isPositionSolid (int16 x, int16 y) |
void | loadRoomIndex (int roomIndex, int spawnIndex) |
Room * | getRoom () |
void | initActors () |
int | loadActorAnim (int actorIndex, const Common::String &animName, int16 x, int16 y, Fixed8 scale) |
void | loadBanFile (const Common::String &name) |
bool | actorWalkToPosition (int actorIndex, const Common::String &animFile, int16 srcX, int16 srcY, int16 destX, int16 destY) |
void | updateActorAnimations () |
void | renderBanBelowSprites () |
void | renderBan (byte *screenPixels, byte *bgPixels, int banFileIndex) |
void | renderBanAboveSprites () |
void | removeActorFromScreen (int actorIndex) |
void | removeDrawnActorsFromScreen () |
void | drawActorToScreen (Actor *actor, const Common::String &animName, int16 x, int16 y, Fixed8 scale, bool addSprite) |
void | releaseAnim (Actor *actor) |
void | initStandAnim (int actorIndex) |
void | updateActorPositionWhileWalking (Actor *actor, int16 x, int16 y) |
void | chooseActorDirectionForWalking (Actor *actor, int16 srcX, int16 srcY, int16 destX, int16 destY) |
bool | directPathExists (int16 srcX, int16 srcY, int16 destX, int16 destY) |
int | findObjectAt (int x, int y) |
int | findObjectAt (Common::Point p) |
Bitmap * | loadAnimationFrame (const Common::String &filename, Fixed8 scale) |
int | selectObjectForUseAction () |
Common::String | getCrewmanAnimFilename (int actorIndex, const Common::String &basename) |
void | updateMouseBitmap () |
bool | walkActiveObjectToHotspot () |
bool | isObjectUnusable (int objectIndex, int action) |
void | updateCrewmanGetupTimers () |
void | showInventoryIcons (bool showItem) |
void | hideInventoryIcons () |
int | showInventoryMenu (int x, int y, bool restoreMouse) |
void | initStarfieldSprite (Sprite *sprite, Bitmap *bitmap, const Common::Rect &rect) |
Bitmap * | scaleBitmap (Bitmap *bitmap, Fixed8 scale) |
void | scaleBitmapRow (byte *src, byte *dest, uint16 origWidth, uint16 scaledWidth) |
void | pollEvents (bool queueEvents=true) |
void | waitForNextTick (bool queueEvents=true) |
void | initializeEventsAndMouse () |
bool | getNextEvent (TrekEvent *e, bool poll=true) |
void | removeNextEvent () |
bool | popNextEvent (TrekEvent *e, bool poll=true) |
void | addEventToQueue (const TrekEvent &e) |
Common::EventManager * | getEventMan () |
const char * | getNextTextLine (const char *text, char *line, int lineWidth) |
void | drawTextLineToBitmap (const char *text, int textLen, int x, int y, Bitmap *bitmap) |
Common::String | centerTextboxHeader (Common::String headerText) |
void | getTextboxHeader (Common::String *headerTextOutput, Common::String speakerText, int choiceIndex) |
Common::String | readTextFromRdf (int choiceIndex, uintptr data, Common::String *headerTextOutput) |
void | showTextbox (Common::String headerText, const Common::String &mainText, int xoffset, int yoffset, byte textColor, int maxTextLines) |
Common::String | skipTextAudioPrompt (const Common::String &str) |
Common::String | playTextAudio (const Common::String &str) |
int | showText (TextGetterFunc textGetter, uintptr var, int xoffset, int yoffset, int textColor, bool loopChoices, int maxTextLines, bool rclickCancelsChoice) |
int | getNumTextboxLines (const Common::String &str) |
Common::String | putTextIntoLines (const Common::String &text) |
TextBitmap * | initTextSprite (int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite) |
void | drawMainText (TextBitmap *bitmap, int numTextLines, int numTextboxLines, const Common::String &text, bool withHeader) |
Common::String | readLineFormattedText (TextGetterFunc textGetter, uintptr var, int choiceIndex, TextBitmap *textBitmap, int numTextboxLines, int *numLines) |
Common::String | readTextFromArray (int choiceIndex, uintptr data, Common::String *headerTextOutput) |
String | readTextFromArrayWithChoices (int choiceIndex, uintptr data, Common::String *headerTextOutput) |
Common::String | readTextFromFoundComputerTopics (int choiceIndex, uintptr data, Common::String *headerTextOutput) |
Common::String | showCodeInputBox () |
Common::String | showComputerInputBox () |
void | redrawTextInput () |
void | addCharToTextInputBuffer (char c) |
Common::String | showTextInputBox (int16 arg0, int16 arg2, const Common::String &headerText) |
void | initTextInputSprite (int16 arg0, int16 arg2, const Common::String &headerText) |
void | cleanupTextInputSprite () |
int | getMenuButtonAt (Sprite *sprites, int numSprites, int x, int y) |
void | chooseMousePositionFromSprites (Sprite *sprites, int numSprites, int spriteIndex, int mode) |
void | drawMenuButtonOutline (Bitmap *bitmap, byte color) |
void | showOptionsMenu (int x, int y) |
void | showBridgeMenu (Common::String menu, int x, int y) |
void | handleBridgeMenu (int menuEvent) |
void | showStarMap () |
void | orbitPlanet () |
void | captainsLog () |
int | showActionMenu () |
void | loadMenuButtons (String mnuFilename, int xpos, int ypos) |
void | setVisibleMenuButtons (uint32 bits) |
void | disableMenuButtons (uint32 bits) |
void | enableMenuButtons (uint32 bits) |
int | handleMenuEvents (uint32 ticksUntilClickingEnabled, bool inTextbox) |
void | unloadMenuButtons () |
void | chooseMouseBitmapForAction (int action, bool withRedOutline) |
void | showQuitGamePrompt (int x, int y) |
void | showGameOverMenu () |
void | showTextConfigurationMenu (bool fromOptionMenu) |
int | loadTextDisplayMode () |
void | saveTextDisplayMode (int value) |
void | showRepublicMap (int16 arg0, int16 turbolift) |
int | getRepublicMapAreaAtMouse () |
int | getRepublicMapAreaOrFailure (int16 turbolift) |
bool | showSaveMenu () |
bool | showLoadMenu () |
bool | saveGame (int slot, Common::String desc) |
bool | loadGame (int slot) |
bool | saveOrLoadGameData (Common::SeekableReadStream *in, Common::WriteStream *out, SavegameMetadata *meta) |
Common::String | getSavegameFilename (int slotId) const |
uint32 | getFeatures () const |
Common::Platform | getPlatform () const |
uint8 | getGameType () const |
Common::Language | getLanguage () const |
Common::String | getScreenName () const |
Public Member Functions inherited from Engine | |
MetaEngine * | getMetaEngine () const |
void | setMetaEngine (MetaEngine *metaEngine) |
PauseToken | pauseEngine () |
bool | isPaused () const |
void | openMainMenuDialog () |
uint32 | getTotalPlayTime () const |
void | setTotalPlayTime (uint32 time=0) |
Common::TimerManager * | getTimerManager () |
Common::EventManager * | getEventManager () |
Common::SaveFileManager * | getSaveFileManager () |
bool | existExtractedCDAudioFiles (uint track=1) |
bool | isDataAndCDAudioReadFromSameCD () |
void | warnMissingExtractedCDAudio () |
void | handleAutoSave () |
void | saveAutosaveIfEnabled () |
virtual bool | canSaveAutosaveCurrently () |
virtual int | getAutosaveSlot () 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::Debugger * | getDebugger () final |
void | setDebugger (GUI::Debugger *debugger) |
GUI::Debugger * | getOrCreateDebugger () |
virtual bool | hasFeature (EngineFeature f) const |
bool | enhancementEnabled (int32 cls) |
virtual void | syncSoundSettings () |
virtual void | applyGameSettings () |
virtual void | flipMute () |
virtual Common::String | getSaveStateName (int slot) const |
virtual Common::Error | loadGameState (int slot) |
virtual Common::Error | loadGameStream (Common::SeekableReadStream *stream) |
void | setGameToLoadSlot (int slot) |
virtual bool | canLoadGameStateCurrently (Common::U32String *msg=nullptr) |
virtual Common::Error | saveGameState (int slot, const Common::String &desc, bool isAutosave=false) |
virtual Common::Error | saveGameStream (Common::WriteStream *stream, bool isAutosave=false) |
virtual bool | canSaveGameStateCurrently (Common::U32String *msg=nullptr) |
bool | saveGameDialog () |
bool | loadGameDialog () |
Public Attributes | |
int | _bridgeSequenceToLoad |
const StarTrekGameDescription * | _gameDescription |
int | _gameMode |
int | _lastGameMode |
bool | _resetGameMode |
Common::String | _missionToLoad |
int | _roomIndexToLoad |
int | _spawnIndexToLoad |
Common::String | _missionName |
int | _roomIndex |
Common::MemoryReadStreamEndian * | _mapFile |
Fixed16 | _playerActorScale |
Common::Queue< Action > | _actionQueue |
AwayMission | _awayMission |
bool | _warpHotspotsActive |
int16 | _activeWarpHotspot |
int16 | _activeDoorWarpHotspot |
int16 | _lookActionBitmapIndex |
Item | _itemList [NUM_OBJECTS] |
Actor | _actorList [NUM_ACTORS] |
Actor *const | _kirkActor |
Actor *const | _spockActor |
Actor *const | _mccoyActor |
Actor *const | _redshirtActor |
Common::MemoryReadStreamEndian * | _banFiles [MAX_BAN_FILES] |
uint16 | _banFileOffsets [MAX_BAN_FILES] |
Sprite | _inventoryIconSprite |
Sprite | _itemIconSprite |
bool | _objectHasWalkPosition |
Common::Point | _objectWalkPosition |
Action | _actionOnWalkCompletion [MAX_BUFFERED_WALK_ACTIONS] |
bool | _actionOnWalkCompletionInUse [MAX_BUFFERED_WALK_ACTIONS] |
uint32 | _clockTicks |
uint32 | _frameIndex |
uint32 | _roomFrameCounter |
bool | _musicEnabled |
bool | _sfxEnabled |
uint16 | _word_467a6 |
uint16 | _musicWorking |
bool | _sfxWorking |
bool | _finishedPlayingSpeech |
bool | _mouseControllingShip |
bool | _keyboardControlsMouse |
bool | _inQuitGameMenu |
bool | _showSubtitles |
byte | _byte_45b3c |
Sprite | _starfieldSprite |
Star | _starList [NUM_STARS] |
Point3 | _starfieldPosition |
int32 | _starfieldPointDivisor |
int16 | _starfieldXVar1 |
int16 | _starfieldYVar1 |
int16 | _starfieldXVar2 |
int16 | _starfieldYVar2 |
Common::Rect | _starfieldRect |
R3 | _enterpriseR3 |
R3 * | _r3List [NUM_SPACE_OBJECTS] |
R3 * | _orderedR3List [NUM_SPACE_OBJECTS] |
Matrix | _starPositionMatrix |
Matrix | _someMatrix |
float | _flt_50898 |
Graphics * | _gfx |
Sound * | _sound |
IWFile * | _iwFile |
Resource * | _resource |
EnterpriseState | _enterpriseState |
Public Attributes inherited from Engine | |
OSystem * | _system |
Audio::Mixer * | _mixer |
Additional Inherited Members | |
Public Types inherited from Engine | |
enum | EngineFeature { kSupportsSubtitleOptions, kSupportsReturnToLauncher, kSupportsLoadingDuringRuntime, kSupportsSavingDuringRuntime, kSupportsChangingOptionsDuringRuntime, kSupportsArbitraryResolutions, kSupportsHelp, kSupportsQuitDialogOverride } |
Static Public Member Functions inherited from Engine | |
static void | quitGame () |
static bool | shouldQuit () |
static bool | warnUserAboutUnsupportedGame (Common::String msg=Common::String()) |
static void | errorUnsupportedGame (Common::String extraMsg) |
Protected Member Functions inherited from Engine | |
virtual int | runDialog (GUI::Dialog &dialog) |
void | defaultSyncSoundSettings () |
virtual void | pauseEngineIntern (bool pause) |
Protected Attributes inherited from Engine | |
Common::TimerManager * | _timer |
Common::EventManager * | _eventMan |
Common::SaveFileManager * | _saveFileMan |
GUI::Dialog * | _mainMenuDialog |
const Common::String | _targetName |
int32 | _activeEnhancements = kEnhGameBreakingBugFixes |
|
overridevirtual |
Initialize the engine and start its main loop.
Implements Engine.
void StarTrek::StarTrekEngine::awayMissionSelectAction | ( | bool | openActionMenu | ) |
Called on right-click (select action), or when certain actions are otherwise selected (checks whether to show inventory icon, etc)
int StarTrek::StarTrekEngine::loadActorAnimWithRoomScaling | ( | int | actorIndex, |
const Common::String & | animName, | ||
int16 | x, | ||
int16 | y | ||
) |
Similar to loadActorAnim, but scale is determined by the y-position in the room. The further up (away) the object is, the smaller it is.
void StarTrek::StarTrekEngine::updateAwayMissionTimers | ( | ) |
Updates any nonzero away mission timers, and invokes ACTION_TIMER_EXPIRED when any one reaches 0.
bool StarTrek::StarTrekEngine::isPositionSolid | ( | int16 | x, |
int16 | y | ||
) |
Returns true if the given position in the room is solid (not walkable). Reads from a ".map" file which has a bit for each position in the room, which is true when that position is solid.
int StarTrek::StarTrekEngine::loadActorAnim | ( | int | actorIndex, |
const Common::String & | animName, | ||
int16 | x, | ||
int16 | y, | ||
Fixed8 | scale | ||
) |
Set an actor's animation, position, and scale.
bool StarTrek::StarTrekEngine::actorWalkToPosition | ( | int | actorIndex, |
const Common::String & | animFile, | ||
int16 | srcX, | ||
int16 | srcY, | ||
int16 | destX, | ||
int16 | destY | ||
) |
Tries to make an actor walk to a position. Returns true if successful in initiating the walk.
void StarTrek::StarTrekEngine::renderBanBelowSprites | ( | ) |
".BAN" files relate to drawing background animations, ie. flashing computer lights. "renderBanBelowSprites()" does the work of drawing it, while "renderBanAboveSprites()" redraws sprites above them if necessary.
void StarTrek::StarTrekEngine::chooseActorDirectionForWalking | ( | Actor * | actor, |
int16 | srcX, | ||
int16 | srcY, | ||
int16 | destX, | ||
int16 | destY | ||
) |
Chooses a value for the actor's speed and direction, based on a source position and a destination position it's walking to.
bool StarTrek::StarTrekEngine::directPathExists | ( | int16 | srcX, |
int16 | srcY, | ||
int16 | destX, | ||
int16 | destY | ||
) |
Returns true if an actor can walk directly from a source position to a destination position without running into unwalkable terrain.
Bitmap* StarTrek::StarTrekEngine::loadAnimationFrame | ( | const Common::String & | filename, |
Fixed8 | scale | ||
) |
Loads a bitmap for the animation frame with the given scale.
int StarTrek::StarTrekEngine::selectObjectForUseAction | ( | ) |
Called when the "get" action is first selected. Returns a selected object. This behaves like other menus in that it holds game execution, but no actual menu pops up; it just waits for the player to select something on the screen.
void StarTrek::StarTrekEngine::updateMouseBitmap | ( | ) |
Checks whether to change the mouse bitmap to have the red outline.
bool StarTrek::StarTrekEngine::walkActiveObjectToHotspot | ( | ) |
Checks whether to walk a crewman to a hotspot (the last one obtained from a "findObjectAt" call).
bool StarTrek::StarTrekEngine::isObjectUnusable | ( | int | objectIndex, |
int | action | ||
) |
Return true if an object is unselectable with the given action?
void StarTrek::StarTrekEngine::updateCrewmanGetupTimers | ( | ) |
When a crewman is collapsed, they get once a timer reaches 0.
void StarTrek::StarTrekEngine::scaleBitmapRow | ( | byte * | src, |
byte * | dest, | ||
uint16 | origWidth, | ||
uint16 | scaledWidth | ||
) |
This takes a row of an unscaled bitmap, and copies it to a row of a scaled bitmap. This was heavily optimized in the original game (manually constructed an unrolled loop).
void StarTrek::StarTrekEngine::pollEvents | ( | bool | queueEvents = true | ) |
Checks for all events, and updates Star Trek's event queue if queueEvents is set. This does not account for "tick" events (getNextEvent/popNextEvent handle that).
bool StarTrek::StarTrekEngine::getNextEvent | ( | TrekEvent * | e, |
bool | poll = true |
||
) |
Returns false if there is no event waiting. If "poll" is true, this always returns something (waits until an event occurs if necessary).
const char* StarTrek::StarTrekEngine::getNextTextLine | ( | const char * | text, |
char * | line, | ||
int | lineWidth | ||
) |
Gets one line of text (does not include words that won't fit). Returns position of text to continue from, or nullptr if done.
void StarTrek::StarTrekEngine::drawTextLineToBitmap | ( | const char * | text, |
int | textLen, | ||
int | x, | ||
int | y, | ||
Bitmap * | bitmap | ||
) |
Draw a line of text to a standard bitmap (NOT a "TextBitmap", whose pixel array is an array of characters, but an actual standard bitmap).
Common::String StarTrek::StarTrekEngine::readTextFromRdf | ( | int | choiceIndex, |
uintptr | data, | ||
Common::String * | headerTextOutput | ||
) |
Text getter for showText which reads from an rdf file. Not really used, since it would require hardcoding text locations in RDF files. "readTextFromArrayWithChoices" replaces this.
void StarTrek::StarTrekEngine::showTextbox | ( | Common::String | headerText, |
const Common::String & | mainText, | ||
int | xoffset, | ||
int | yoffset, | ||
byte | textColor, | ||
int | maxTextLines | ||
) |
Shows text with the given header and main text.
Common::String StarTrek::StarTrekEngine::playTextAudio | ( | const Common::String & | str | ) |
Plays an audio prompt, if it exists, and returns the string starting at the end of the prompt.
int StarTrek::StarTrekEngine::showText | ( | TextGetterFunc | textGetter, |
uintptr | var, | ||
int | xoffset, | ||
int | yoffset, | ||
int | textColor, | ||
bool | loopChoices, | ||
int | maxTextLines, | ||
bool | rclickCancelsChoice | ||
) |
rclickCancelsChoice | If true, right-clicks return "-1" as choice instead of whatever was selected. |
int StarTrek::StarTrekEngine::getNumTextboxLines | ( | const Common::String & | str | ) |
Returns the number of lines this string will take up in a textbox.
TextBitmap* StarTrek::StarTrekEngine::initTextSprite | ( | int * | xoffsetPtr, |
int * | yoffsetPtr, | ||
byte | textColor, | ||
int | numTextLines, | ||
bool | withHeader, | ||
Sprite * | sprite | ||
) |
Creates a blank textbox in a TextBitmap, and initializes a sprite to use it.
void StarTrek::StarTrekEngine::drawMainText | ( | TextBitmap * | bitmap, |
int | numTextLines, | ||
int | numTextboxLines, | ||
const Common::String & | text, | ||
bool | withHeader | ||
) |
Draws the "main" text (everything but the header at the top) to a TextBitmap.
Common::String StarTrek::StarTrekEngine::readTextFromArray | ( | int | choiceIndex, |
uintptr | data, | ||
Common::String * | headerTextOutput | ||
) |
Text getter for showText which reads choices from an array of pointers. Last element in the array must be an empty string.
String StarTrek::StarTrekEngine::readTextFromArrayWithChoices | ( | int | choiceIndex, |
uintptr | data, | ||
Common::String * | headerTextOutput | ||
) |
Similar to above, but shows the choice index when multiple choices are present. Effectively replaces the "readTextFromRdf" function.
Common::String StarTrek::StarTrekEngine::showTextInputBox | ( | int16 | arg0, |
int16 | arg2, | ||
const Common::String & | headerText | ||
) |
Shows a textbox that the player can type a string into.
int StarTrek::StarTrekEngine::getMenuButtonAt | ( | Sprite * | sprites, |
int | numSprites, | ||
int | x, | ||
int | y | ||
) |
Returns the index of the button at the given position, or -1 if none.
void StarTrek::StarTrekEngine::chooseMousePositionFromSprites | ( | Sprite * | sprites, |
int | numSprites, | ||
int | spriteIndex, | ||
int | mode | ||
) |
This chooses a sprite from the list to place the mouse cursor at. The sprite it chooses may be, for example, the top-leftmost one in the list. Exact behaviour is determined by the "mode" parameter.
If "containMouseSprite" is a valid index, it's ensured that the mouse is contained within it. "mode" should be -1 in this case.
void StarTrek::StarTrekEngine::drawMenuButtonOutline | ( | Bitmap * | bitmap, |
byte | color | ||
) |
Draws or removes the outline on menu buttons when the cursor hovers on them, or leaves them.
int StarTrek::StarTrekEngine::showActionMenu | ( | ) |
Show the "action selection" menu, ie. look, talk, etc.
void StarTrek::StarTrekEngine::loadMenuButtons | ( | String | mnuFilename, |
int | xpos, | ||
int | ypos | ||
) |
Loads a .MNU file, which is a list of buttons to display.
void StarTrek::StarTrekEngine::setVisibleMenuButtons | ( | uint32 | bits | ) |
Sets which buttons are visible based on the given bitmask.
void StarTrek::StarTrekEngine::disableMenuButtons | ( | uint32 | bits | ) |
Disables the given bitmask of buttons.
int StarTrek::StarTrekEngine::handleMenuEvents | ( | uint32 | ticksUntilClickingEnabled, |
bool | inTextbox | ||
) |
This returns either a special menu event (negative number) or the retval of the button clicked (usually an index, always positive).
void StarTrek::StarTrekEngine::chooseMouseBitmapForAction | ( | int | action, |
bool | withRedOutline | ||
) |
Sets the mouse bitmap based on which action is selected.
void StarTrek::StarTrekEngine::showTextConfigurationMenu | ( | bool | fromOptionMenu | ) |
This can be called from startup or from the options menu. On startup, this tries to load the setting without user input.
void StarTrek::StarTrekEngine::showRepublicMap | ( | int16 | arg0, |
int16 | turbolift | ||
) |
Show the republic map, only used in mission 7.
int StarTrek::StarTrekEngine::getRepublicMapAreaAtMouse | ( | ) |
Checks the mouse position to return and index for the area selected.
int StarTrek::StarTrekEngine::getRepublicMapAreaOrFailure | ( | int16 | turbolift | ) |
Same as above, but returns 6 or 7 as error conditions (can't reach due to radiation or wrong turbolift).
bool StarTrek::StarTrekEngine::saveOrLoadGameData | ( | Common::SeekableReadStream * | in, |
Common::WriteStream * | out, | ||
SavegameMetadata * | meta | ||
) |
Call this after loading "saveOrLoadMetadata" to load all the data pertaining to game execution.