25 #include "macs2/events.h" 26 #include "macs2/macs2.h" 59 uint32 _startTime = 0;
62 bool _lerpIgnoresObstacles =
false;
72 uint16 _pickupFrameCounter = 0;
73 bool _pickupItemTransferred =
false;
74 bool _markedForDeletion =
false;
76 uint8 _previousOrientation = 0;
91 int16 _stepDeltaX = 0;
92 int16 _stepDeltaY = 0;
94 bool _stepDirectionSet =
false;
97 int16 _currentPathIndex = 0;
102 uint8 _pathBlockRaw[32] = {0};
108 bool canNodeConnectSourceToTarget(uint16 nodeIndex,
const Common::Point &charPos,
const Common::Point &target,
const bool *reachable,
int nodeCount);
109 void floodFillConnectedNodes(
int nodeIndex,
bool *visited,
int nodeCount);
111 bool walkAlongPath();
112 void startLerpTo(
const Common::Point &target, uint32 duration,
bool ignoreObstacles =
false);
119 uint16 getVerticalOffset()
const;
121 uint8 _animationIndex = 1;
122 uint16 _motionTargetVerticalOffset = 0;
123 uint16 _motionVerticalOffsetDelta = 0;
124 uint16 _motionDistanceUnits = 0;
125 uint16 _motionProgress = 0;
126 uint16 _motionStartVerticalOffset = 0;
127 bool _shouldMirrorCurrentAnimation =
false;
131 bool hasPendingVerticalMotion()
const;
132 bool shouldStepVerticalMotion()
const;
134 bool isAnimationMirrored()
const;
135 uint8 getMirroredAnimation(uint8 original)
const;
141 Macs2::AnimFrame *getCurrentPortrait(
bool onRightSide =
false, uint16 frameIndex = 2);
147 void resetCharacterWalkPath(
Character *character);
150 template<
typename T, T V>
153 template<
typename T, T V>
158 template<
typename T, T V, T W, T... Rest>
163 template<
typename T, T... ts>
164 constexpr
bool is_in_list(T
const &t) {
173 bool onRightSide =
false;
179 int16 mouthAnimCounter = 0;
180 bool mouthAnimActive =
false;
185 uint16 scalingFactor;
193 void drawSpriteTransparent(
int shadingTableOffset, uint8 depthThreshold, uint16 scalingFactor,
194 int16 drawX, int16 drawY, uint16 srcWidth, uint16 srcHeight,
197 void drawSpriteScaled(
int shadingTableOffset, uint8 depthThreshold, int16 drawX, int16 drawY,
198 uint16 srcWidth, uint16 srcHeight,
const byte *srcPixels,
202 bool _pendingMapOpen =
false;
207 byte _savedPalVanilla[256 * 3] = {0};
214 uint32 _bgAnimTickCounter = 0;
230 enum class SaveLoadSubMode {
235 SaveLoadSubMode _saveLoadSubMode = SaveLoadSubMode::None;
236 uint16 _saveLoadPageIndex = 0;
237 bool _saveConfirmArmed =
false;
238 bool _loadConfirmArmed =
false;
239 bool _helpButtonDisabled =
false;
240 uint16 _clickedButtonIndex = 0;
246 uint16 _saveLoadButtonWidth = 0;
247 uint16 _saveLoadButtonHeight = 0;
249 void openOriginalSaveLoadPanel();
252 void closeOriginalSaveLoadPanel();
254 int _currentFadeValue = -1;
255 FadeMode _fadeMode = FadeMode::None;
256 bool _cursorSuppressedForFade =
false;
257 bool _cursorWasVisibleBeforeFade =
false;
259 void drawDarkRectangle(uint16 x, uint16 y, uint16 width, uint16 height);
263 void beginFadeCursorSuppression();
264 void endFadeCursorSuppression(
const byte *palette);
270 void runInventoryPanelScriptIfPending(
bool excludeCloseButton);
313 void renderStringWithFont(uint16 x, uint16 y,
const Common::String &s,
const GlyphData *glyphs, uint16 numGlyphs);
323 uint16 _inventoryScrollOffset = 0;
325 void drawSprite(int16 x, int16 y, uint16 width, uint16 height, byte *data,
Graphics::ManagedSurface &s,
bool mirrored,
bool useDepth =
false, uint8 depth = 0,
bool clipToGameArea =
false);
326 void drawSprite(int16 x, int16 y,
const Sprite &sprite,
Graphics::ManagedSurface &s,
bool mirrored,
bool useDepth =
false, uint8 depth = 0,
bool clipToGameArea =
false);
327 void drawSprite(
const Common::Point &pos, uint16 width, uint16 height, byte *data,
Graphics::ManagedSurface &s,
bool mirrored,
bool useDepth =
false, uint8 depth = 0,
bool clipToGameArea =
false);
336 static const uint16 kMaxSceneObjects = 0x200;
337 void sortObjectListByY()
const;
338 void buildSortedObjectList(
int low,
int high)
const;
339 mutable uint16 _sortedObjectCount = 0;
340 mutable uint16 _sortedObjectIndices[kMaxSceneObjects + 1];
341 mutable Character *_characterByObjectIndex[kMaxSceneObjects + 1] = {};
346 int findInventoryItem(
const GameObject *item);
347 void setViewPaletteSafely(
const byte *colors);
348 void applyPaletteWithFade(
const byte *sourcePalette,
int fadeValue);
354 bool hasScummVerbUI()
const;
355 bool shouldShowScummVerbUI()
const;
356 void ensureScummVerbUI();
361 bool isHelpButtonDisabled()
const {
return _helpButtonDisabled; }
363 void restoreUiPaletteEntries();
365 void clearClickedButtonIndex() { _clickedButtonIndex = 0; }
369 ViewMode _currentMode = ViewMode::VM_GAME;
374 byte _pal[256 * 3] = {0};
375 bool _paletteDirty =
true;
383 static constexpr uint32 kGameFrameRate = 20;
386 bool _isShowingTextBox =
false;
388 bool _isShowingDialoguePanel =
false;
390 bool _continueScriptAfterUI =
false;
391 uint16 _dialogueChoiceCount = 0;
396 bool _started =
false;
398 bool _autoclickActive =
false;
402 void flushPendingCharacterDeletes();
404 void transferPickupTarget(
GameObject *targetObject);
419 enum UiPanelState : uint16 {
421 kUiPanelActionBar = 1,
422 kUiPanelInventory = 2,
423 kUiPanelContainerInventory = 3,
426 UiPanelState _uiPanelState = kUiPanelNone;
428 void finishPanelCloseAfterRelease(UiPanelState closedFromState);
431 bool _isDialogueChoiceInputActive =
false;
436 enum PendingPanelRequest : uint16 {
437 kPanelRequestNone = 0,
438 kPanelRequestInventory = 1,
439 kPanelRequestContainerInventory = 2,
440 kPanelRequestSaveLoad = 3,
441 kPanelRequestSaveLoadActive = 4
443 PendingPanelRequest _pendingPanelRequest = kPanelRequestNone;
446 bool _uiBackgroundRestorePending =
false;
449 Script::MouseMode _savedCursorMode = Script::MouseMode::Walk;
451 enum class InventoryButtonIndex {
464 enum class MainMenuButtonIndex {
477 uint16 _hoverAreaId = 0;
478 uint16 _hoverHotspotId = 0;
486 void setInventorySource(
GameObject *newInventorySource);
487 void refreshProtagonistInventoryAfterLoad(uint16 actorIndex);
488 void openInventory(
GameObject *newInventorySource);
490 void closeInventory();
492 bool isInventorySourceProtagonist()
const;
496 Character *getCharacterByIndex(uint16 index)
const;
497 void rebuildCharacterLookupTable()
const;
499 int getCharacterArrayIndex(
const Character *c)
const;
503 void updateCursor(
const byte *palette =
nullptr);
512 void draw()
override;
513 bool tick()
override;
522 void layoutActionBarButtons();
524 void drawSceneUpdate();
526 void handleTextBoxInput();
527 void dismissDialoguePanel();
528 bool handleDialogueChoiceClick(
int clickY,
int clickX);
530 void startFading(uint16 speed = 4);
531 void fadePaletteToBlack(uint16 speed,
const byte *sourcePalette);
532 void startFadeToBlack(uint16 speed = 4);
533 void startFadingWithSpeed(uint16 speed);
535 void instantSceneCut();
550 const BorderStyle &style,
bool fillCenter,
bool fillSides,
566 void triggerDialogueChoice(uint8 index);
575 void clearOverlayTextEntries();
576 void drawOverlayTextEntries();
Definition: managed_surface.h:51
Definition: messages.h:58
Definition: gameobjects.h:86
Definition: messages.h:75
Definition: messages.h:69
Definition: messages.h:63
Definition: messages.h:42
Definition: messages.h:33
Definition: debugtools.h:25