25 #include "common/events.h" 26 #include "common/list.h" 27 #include "common/ptr.h" 28 #include "common/random.h" 29 #include "common/rect.h" 30 #include "common/scummsys.h" 31 #include "common/serializer.h" 32 #include "common/str.h" 33 #include "common/stream.h" 34 #include "common/system.h" 35 #include "common/util.h" 37 #include "gui/saveload-dialog.h" 39 #include "engines/engine.h" 41 #include "math/cosinetables.h" 42 #include "math/sinetables.h" 44 #include "startrek/action.h" 45 #include "startrek/awaymission.h" 46 #include "startrek/graphics.h" 47 #include "startrek/items.h" 48 #include "startrek/object.h" 49 #include "startrek/sound.h" 50 #include "startrek/space.h" 51 #include "startrek/detection.h" 68 typedef String(StarTrekEngine::*TextGetterFunc)(int, uintptr,
String *);
70 const int SAVEGAME_DESCRIPTION_LEN = 30;
74 char description[SAVEGAME_DESCRIPTION_LEN + 1];
83 void setSaveTimeAndDate(
TimeDate time) {
84 saveDate = ((time.
tm_mday & 0xFF) << 24) | (((time.
tm_mon + 1) & 0xFF) << 16) | ((time.
tm_year + 1900) & 0xFFFF);
85 saveTime = ((time.
tm_hour & 0xFF) << 8) | ((time.
tm_min) & 0xFF);
86 saveTimeSecs = time.
tm_sec & 0xFF;
90 return (saveDate >> 24) & 0xFF;
93 return (saveDate >> 16) & 0xFF;
96 return saveDate & 0xFFFF;
99 return (saveTime >> 8) & 0xFF;
102 return saveTime & 0xFF;
107 const int MAX_MENUBUTTONS = 32;
108 const int TEXTBOX_WIDTH = 26;
109 const int TEXT_CHARS_PER_LINE = TEXTBOX_WIDTH - 2;
110 const int MAX_TEXTBOX_LINES = 12;
112 const int TEXT_INPUT_BUFFER_SIZE = 134;
113 const int MAX_TEXT_INPUT_LEN = 20;
115 const int MAX_BUFFERED_WALK_ACTIONS = 32;
117 const int MAX_BAN_FILES = 16;
123 kDebugSound = 1 << 0,
124 kDebugGraphics = 1 << 1,
125 kDebugSavegame = 1 << 2,
126 kDebugSpace = 1 << 3,
127 kDebugGeneral = 1 << 4
133 GAMEMODE_AWAYMISSION,
138 enum TextDisplayMode {
139 TEXTDISPLAY_WAIT = 0,
140 TEXTDISPLAY_SUBTITLES,
145 TEXTCOLOR_GREY = 0x88,
146 TEXTCOLOR_RED = 0xa1,
147 TEXTCOLOR_YELLOW = 0xb0,
148 TEXTCOLOR_BLUE = 0xc0
153 Sprite sprites[MAX_MENUBUTTONS];
154 uint16 retvals[MAX_MENUBUTTONS];
155 uint32 disabledButtons;
157 int16 selectedButton;
164 MENUEVENT_RCLICK_OFFBUTTON = -4,
165 MENUEVENT_ENABLEINPUT,
166 MENUEVENT_RCLICK_ONBUTTON,
167 MENUEVENT_LCLICK_OFFBUTTON
172 TEXTBUTTON_CONFIRM = 0,
174 TEXTBUTTON_SCROLLDOWN,
175 TEXTBUTTON_PREVCHOICE,
176 TEXTBUTTON_NEXTCHOICE,
177 TEXTBUTTON_SCROLLUP_ONELINE,
178 TEXTBUTTON_SCROLLDOWN_ONELINE,
180 TEXTBUTTON_GOTO_BOTTOM,
181 TEXTBUTTON_SPEECH_DONE
186 enum OptionMenuButtons {
190 OPTIONBUTTON_ENABLEMUSIC,
191 OPTIONBUTTON_DISABLEMUSIC,
192 OPTIONBUTTON_ENABLESFX,
193 OPTIONBUTTON_DISABLESFX,
199 TREKEVENT_LBUTTONDOWN = 1,
200 TREKEVENT_MOUSEMOVE = 2,
201 TREKEVENT_LBUTTONUP = 3,
202 TREKEVENT_RBUTTONDOWN = 4,
203 TREKEVENT_RBUTTONUP = 5,
204 TREKEVENT_KEYDOWN = 6
231 targetAnalysis =
false;
255 void initBridge(
bool b);
257 void loadBridgeActors();
258 void cleanupBridge();
260 void setBridgeMouseCursor();
261 void playBridgeSequence(
int sequenceId);
262 void handleBridgeEvents();
263 void handleBridgeComputer();
264 void showMissionPerformance(
int score,
int missionScoreTextId,
int missionId);
266 int _bridgeSequenceToLoad;
270 void showTextboxBridge(
int talker,
int textId);
276 void wrongDestinationRandomEncounter();
277 void bridgeCrewAction(
int crewId);
278 void contactTargetAction();
279 void orbitPlanetSequence(
int sequenceId);
280 void negotiateWithElasiCereth();
281 void hailTheMasada();
284 int16 _currentPlanet;
285 int _currentScreenTalker;
288 int _deadMasadaPrisoners;
289 bool _beamDownAllowed;
291 int16 _randomEncounterType;
292 int16 _lastMissionId;
293 int16 _missionPoints[7];
299 uint16 getRandomWord();
302 void initAwayMission();
303 void runAwayMission();
304 void cleanupAwayMission();
306 void initAwayCrewPositions(
int warpEntryIndex);
307 void handleAwayMissionEvents();
308 void awayMissionLeftClick();
313 void awayMissionSelectAction(
bool openActionMenu);
314 void awayMissionUseObject(int16 clickedObject);
315 void awayMissionGetLookOrTalk(int16 clickedObject);
321 int loadActorAnimWithRoomScaling(
int actorIndex,
const Common::String &animName, int16 x, int16 y);
322 Fixed8 getActorScaleAtPosition(int16 y);
323 void addAction(
const Action &action);
324 void addAction(int8 type, byte b1, byte b2, byte b3);
325 void handleAwayMissionAction();
327 void checkTouchedLoadingZone(int16 x, int16 y);
332 void updateAwayMissionTimers();
338 bool isPositionSolid(int16 x, int16 y);
339 void loadRoomIndex(
int roomIndex,
int spawnIndex);
346 void showCreditsScreen(
R3 *creditsBuffer,
int index,
bool deletePrevious =
true);
351 void initIntroR3ObjectToMove(
R3 *r3, int16 srcAngle, int16 srcDepth, int16 destAngle, int16 destDepth, int16 ticks);
352 void loadSubtitleSprite(
int index,
Sprite *sprite);
355 void initStarfieldPosition();
356 void initStarfield(int16 x, int16 y, int16 width, int16 height, int16 arg8);
359 void clearStarfieldPixels();
360 void drawStarfield();
361 void updateStarfieldAndShips(
bool arg0);
362 R3 *sub_19f24(
R3 *r3);
363 void drawR3Shape(
R3 *r3);
364 bool sub_1c022(
R3 *r3);
366 Point3 constructPoint3ForStarfield(int16 x, int16 y, int16 z);
369 int32 scaleSpacePosition(int32 x, int32 z);
390 bool actorWalkToPosition(
int actorIndex,
const Common::String &animFile, int16 srcX, int16 srcY, int16 destX, int16 destY);
391 void updateActorAnimations();
398 void renderBanBelowSprites();
399 void renderBan(byte *screenPixels, byte *bgPixels,
int banFileIndex);
400 void renderBanAboveSprites();
401 void removeActorFromScreen(
int actorIndex);
402 void removeDrawnActorsFromScreen();
404 void releaseAnim(
Actor *actor);
405 void initStandAnim(
int actorIndex);
406 void updateActorPositionWhileWalking(
Actor *actor, int16 x, int16 y);
411 void chooseActorDirectionForWalking(
Actor *actor, int16 srcX, int16 srcY, int16 destX, int16 destY);
416 bool directPathExists(int16 srcX, int16 srcY, int16 destX, int16 destY);
418 int findObjectAt(
int x,
int y);
420 return findObjectAt(p.
x, p.
y);
432 int selectObjectForUseAction();
437 void updateMouseBitmap();
442 bool walkActiveObjectToHotspot();
446 bool isObjectUnusable(
int objectIndex,
int action);
450 void updateCrewmanGetupTimers();
451 void showInventoryIcons(
bool showItem);
452 void hideInventoryIcons();
453 int showInventoryMenu(
int x,
int y,
bool restoreMouse);
461 void scaleBitmapRow(byte *src, byte *dest, uint16 origWidth, uint16 scaledWidth);
469 void pollEvents(
bool queueEvents =
true);
470 void waitForNextTick(
bool queueEvents =
true);
471 void initializeEventsAndMouse();
476 bool getNextEvent(
TrekEvent *e,
bool poll =
true);
477 void removeNextEvent();
478 bool popNextEvent(
TrekEvent *e,
bool poll =
true);
479 void addEventToQueue(
const TrekEvent &e);
487 bool _mouseMoveEventInQueue;
488 bool _tickEventInQueue;
489 uint32 _frameStartMillis;
498 const char *getNextTextLine(
const char *text,
char *line,
int lineWidth);
503 void drawTextLineToBitmap(
const char *text,
int textLen,
int x,
int y,
Bitmap *bitmap);
517 void showTextbox(
Common::String headerText,
const Common::String &mainText,
int xoffset,
int yoffset, byte textColor,
int maxTextLines);
530 int showText(TextGetterFunc textGetter, uintptr var,
int xoffset,
int yoffset,
int textColor,
bool loopChoices,
int maxTextLines,
bool rclickCancelsChoice);
541 TextBitmap *initTextSprite(
int *xoffsetPtr,
int *yoffsetPtr, byte textColor,
int numTextLines,
bool withHeader,
Sprite *sprite);
545 void drawMainText(
TextBitmap *bitmap,
int numTextLines,
int numTextboxLines,
const Common::String &text,
bool withHeader);
547 Common::String readLineFormattedText(TextGetterFunc textGetter, uintptr var,
int choiceIndex,
TextBitmap *textBitmap,
int numTextboxLines,
int *numLines);
558 String readTextFromArrayWithChoices(
int choiceIndex, uintptr data,
Common::String *headerTextOutput);
563 void redrawTextInput();
564 void addCharToTextInputBuffer(
char c);
569 void initTextInputSprite(int16 arg0, int16 arg2,
const Common::String &headerText);
570 void cleanupTextInputSprite();
573 char _textInputBuffer[TEXT_INPUT_BUFFER_SIZE];
574 int16 _textInputCursorPos;
575 char _textInputCursorChar;
583 int getMenuButtonAt(
Sprite *sprites,
int numSprites,
int x,
int y);
592 void chooseMousePositionFromSprites(
Sprite *sprites,
int numSprites,
int spriteIndex,
int mode);
597 void drawMenuButtonOutline(
Bitmap *bitmap, byte color);
598 void showOptionsMenu(
int x,
int y);
600 void handleBridgeMenu(
int menuEvent);
608 int showActionMenu();
612 void loadMenuButtons(
String mnuFilename,
int xpos,
int ypos);
616 void setVisibleMenuButtons(uint32 bits);
620 void disableMenuButtons(uint32 bits);
621 void enableMenuButtons(uint32 bits);
626 int handleMenuEvents(uint32 ticksUntilClickingEnabled,
bool inTextbox);
627 void unloadMenuButtons();
632 void chooseMouseBitmapForAction(
int action,
bool withRedOutline);
633 void showQuitGamePrompt(
int x,
int y);
634 void showGameOverMenu();
639 void showTextConfigurationMenu(
bool fromOptionMenu);
641 int loadTextDisplayMode();
642 void saveTextDisplayMode(
int value);
647 void showRepublicMap(int16 arg0, int16 turbolift);
651 int getRepublicMapAreaAtMouse();
656 int getRepublicMapAreaOrFailure(int16 turbolift);
660 int16 _textDisplayMode;
663 bool _textboxHasMultipleChoices;
666 bool _keyboardControlsMouseOutsideMenu;
674 bool loadGame(
int slot);
687 uint32 getFeatures()
const;
689 uint8 getGameType()
const;
694 return _missionName + (char)(_roomIndex +
'0');
707 int _roomIndexToLoad;
708 int _spawnIndexToLoad;
719 bool _warpHotspotsActive;
720 int16 _activeWarpHotspot;
721 int16 _activeDoorWarpHotspot;
722 int16 _lookActionBitmapIndex;
724 Item _itemList[NUM_OBJECTS];
726 Actor _actorList[NUM_ACTORS];
727 Actor *
const _kirkActor;
728 Actor *
const _spockActor;
729 Actor *
const _mccoyActor;
730 Actor *
const _redshirtActor;
735 uint16 _banFileOffsets[MAX_BAN_FILES];
737 Sprite _inventoryIconSprite;
742 bool _objectHasWalkPosition;
748 Action _actionOnWalkCompletion[MAX_BUFFERED_WALK_ACTIONS];
749 bool _actionOnWalkCompletionInUse[MAX_BUFFERED_WALK_ACTIONS];
755 uint32 _roomFrameCounter;
760 uint16 _musicWorking;
762 bool _finishedPlayingSpeech;
764 bool _mouseControllingShip;
769 bool _keyboardControlsMouse;
771 bool _inQuitGameMenu;
778 Star _starList[NUM_STARS];
779 Point3 _starfieldPosition;
780 int32 _starfieldPointDivisor;
781 int16 _starfieldXVar1, _starfieldYVar1;
782 int16 _starfieldXVar2, _starfieldYVar2;
785 R3 *_r3List[NUM_SPACE_OBJECTS];
786 R3 *_orderedR3List[NUM_SPACE_OBJECTS];
787 Matrix _starPositionMatrix;
799 int leftClickEvent();
800 int rightClickEvent();
801 int mouseMoveEvent();
802 int lookupNextAction(
const int *lookupArray,
int action);
803 void loadBridgeComputerTopics();
804 void bridgeLeftClick();
807 Math::SineTable _sineTable;
808 Math::CosineTable _cosineTable;
int tm_hour
Definition: system.h:109
int tm_mday
Definition: system.h:110
int tm_min
Definition: system.h:108
Definition: startrek.h:219
Definition: memstream.h:103
Definition: resource.h:54
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: startrek.h:214
int tm_sec
Definition: system.h:107
Definition: detection.h:39
Definition: algorithm.h:29
Definition: formatinfo.h:28
int tm_year
Definition: system.h:112
Definition: awaymission.h:27
int16 x
Definition: rect.h:46
int tm_mon
Definition: system.h:111
int16 y
Definition: rect.h:47
Definition: keyboard.h:294
Definition: startrek.h:239
Definition: startrek.h:207
Language
Definition: language.h:45