Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmake/compiler-flags-gl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ src/OpenSHC/IO/ResourceManager/swapMapDataWithNextMap.cpp
src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp
src/OpenSHC/IO/ResourceManager/readFirstPartOfCurrentResourceIntoMemory.cpp
src/OpenSHC/IO/ResourceManager/readNextPartOfCurrentResourceIntoMemory.cpp
src/OpenSHC/Map/Navigation/DirectionAlgorithmState/getMouseVectorLengthBasedOnDirection.cpp
src/OpenSHC/Input/MouseState/updateRightDragCameraControl.cpp
22 changes: 22 additions & 0 deletions src/OpenSHC/Input/MouseState/Constructor_MouseState.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "../MouseState.func.hpp"

namespace OpenSHC {
namespace Input {

// FUNCTION: STRONGHOLDCRUSADER 0x004709B0
MouseState* MouseState::Constructor_MouseState()
{
this->time0 = timeGetTime();
MACRO_CALL_MEMBER(MouseState_Func::storeXYAndResetMouseState, this)();
this->previewEnabled = 0;
this->flag = 0;
this->resetPending = 0;
this->waitCursorToggle = 0;
this->cursorType = 0;
this->field70_0x1e4 = 0;
this->field68_0x1dc = -1;
return this;
}

}
}
42 changes: 42 additions & 0 deletions src/OpenSHC/Input/MouseState/beginPointSelectionBox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "../MouseState.func.hpp"

#include "OpenSHC/Globals/DAT_MouseState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"

namespace OpenSHC {
namespace Input {

// FUNCTION: STRONGHOLDCRUSADER 0x00468420
void MouseState::beginPointSelectionBox()
{
this->previousSelectionBox.left
= this->screenSpaceX + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX - 1;
this->previousSelectionBox.top
= this->screenSpaceY + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY - 1;
this->previousSelectionBox.right
= this->screenSpaceX + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX + 1;
this->previousSelectionBox.bottom
= this->screenSpaceY + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + 1;

if (DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk) {
this->selectionBox.left
= (this->screenSpaceX + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX) * 2 - 2;
this->selectionBox.top
= (this->screenSpaceY + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY) * 2 - 2;
this->selectionBox.right
= (this->screenSpaceX + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX) * 2 + 2;
this->selectionBox.bottom
= (this->screenSpaceY + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY) * 2 + 2;
} else {
this->selectionBox.left = this->previousSelectionBox.left;
this->selectionBox.top = this->previousSelectionBox.top;
this->selectionBox.right = this->previousSelectionBox.right;
this->selectionBox.bottom = this->previousSelectionBox.bottom;
}

DAT_MouseState::instance.field31_0x94 = 0;
DAT_MouseState::instance.selectionBoxMode = 1;
}

}
}
39 changes: 39 additions & 0 deletions src/OpenSHC/Input/MouseState/drawMouseBasedBox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "../MouseState.func.hpp"

#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp"

#include "OpenSHC/Globals/COL_BLACK.hpp"
#include "OpenSHC/Globals/COL_WHITE.hpp"
#include "OpenSHC/Globals/DAT_MouseState.hpp"
#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp"

namespace OpenSHC {
namespace Input {

// FUNCTION: STRONGHOLDCRUSADER 0x00472A90
void MouseState::drawMouseBasedBox()
{
if (!DAT_MouseState::instance.field31_0x94) {
return;
}
if (!DAT_MouseState::instance.leftClickState && !DAT_MouseState::instance.draggingStopped) {
MACRO_CALL_MEMBER(MouseState_Func::resetMouseCursorState, this)();
return;
}
int left = this->previousSelectionBox.left;
int right = this->previousSelectionBox.right;
int top = this->previousSelectionBox.top;
int bottom = this->previousSelectionBox.bottom;

DAT_PencilRenderCore::instance.surfaceTarget = Rendering::Enums::RT_MAP_GAME;
MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)(
left, top, right, bottom, COL_BLACK::instance.shortValue);

MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)(
left + 1, top + 1, right + -1, bottom + -1, COL_WHITE::instance.shortValue);

DAT_PencilRenderCore::instance.surfaceTarget = Rendering::Enums::RT_SCREEN_MENU;
}

}
}
42 changes: 42 additions & 0 deletions src/OpenSHC/Input/MouseState/extendSelectionBoxToMouse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "../MouseState.func.hpp"

#include "OpenSHC/Map/Navigation/DirectionAlgorithmState.func.hpp"

#include "OpenSHC/Globals/DAT_DirectionAlgorithmState.hpp"
#include "OpenSHC/Globals/DAT_MouseState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"

namespace OpenSHC {
namespace Input {

// FUNCTION: STRONGHOLDCRUSADER 0x00470B30
void MouseState::extendSelectionBoxToMouse()
{
this->previousSelectionBox.right
= this->screenSpaceX + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX;
this->previousSelectionBox.bottom
= this->screenSpaceY + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY;

if (DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk) {
this->selectionBox.right
= (DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX + this->screenSpaceX) * 2 + 2;
this->selectionBox.bottom
= (DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + this->screenSpaceY) * 2 + 2;
} else {
this->selectionBox.right = this->previousSelectionBox.right;
this->selectionBox.bottom = this->previousSelectionBox.bottom;
}

DAT_MouseState::instance.selectionBoxMode = 2;

MACRO_CALL_MEMBER(Map::Navigation::DirectionAlgorithmState_Func::setAxisBasedDistanceResult,
DAT_DirectionAlgorithmState::ptr)(
this->selectionBox.left, this->selectionBox.top, this->selectionBox.right, this->selectionBox.bottom);

if (16 < DAT_DirectionAlgorithmState::instance.distanceHigh) {
DAT_MouseState::instance.field31_0x94 = 1;
}
}

}
}
25 changes: 25 additions & 0 deletions src/OpenSHC/Input/MouseState/isMouseInsideBox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "../MouseState.func.hpp"

namespace OpenSHC {
namespace Input {

// FUNCTION: STRONGHOLDCRUSADER 0x004680C0
BOOLEnum MouseState::isMouseInsideBox(int xPos, int yPos, int width, int heigth)
{
if (xPos > this->screenSpaceX) {
return FALSE;
}
if ((xPos + width) <= this->screenSpaceX) {
return FALSE;
}
if (yPos > this->screenSpaceY) {
return FALSE;
}
if ((yPos + heigth) <= this->screenSpaceY) {
return FALSE;
}
return TRUE;
}

}
}
60 changes: 60 additions & 0 deletions src/OpenSHC/Input/MouseState/loadAndSetCursor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "../MouseState.func.hpp"

#include "OpenSHC/string-literals.hpp"

#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp"

namespace OpenSHC {
namespace Input {

// TODO: We later also need to add the proper resources.

// FUNCTION: STRONGHOLDCRUSADER 0x00470A00
void MouseState::loadAndSetCursor(int notAniDefaultCursorRef, int notAniDeleteCursorRef,
int notAniDeleteNotCursorRef, int unused1, int unused2, int unused3, int unused4, int notAniUnknownCursorRef)
{
this->notAniDefaultCursor_0x24c
= LoadCursorA(DAT_WindowAndDirectDraw::instance.hInstanceUnk_0xa8, MAKEINTRESOURCE(notAniDefaultCursorRef));

this->notAniDeleteCursor_0x250
= LoadCursorA(DAT_WindowAndDirectDraw::instance.hInstanceUnk_0xa8, MAKEINTRESOURCE(notAniDeleteCursorRef));

this->notAniWaitCursor_0x258 = LoadCursorA(NULL, IDC_WAIT);

this->notAniHandCursor_0x25c
= LoadCursorA(DAT_WindowAndDirectDraw::instance.hInstanceUnk_0xa8, MAKEINTRESOURCE(notAniDefaultCursorRef));

this->notAniDeleteNotCursor_0x260 = LoadCursorA(
DAT_WindowAndDirectDraw::instance.hInstanceUnk_0xa8, MAKEINTRESOURCE(notAniDeleteNotCursorRef));

this->notAniDefaultArabCursor_0x264
= LoadCursorA(DAT_WindowAndDirectDraw::instance.hInstanceUnk_0xa8, MAKEINTRESOURCE(notAniDefaultCursorRef));

this->swordCursor_0x224 = LoadCursorFromFileA(s_sword_ani_005a625c);
this->deleteCursor_0x228 = LoadCursorFromFileA(s_delete_ani_005a6250);
this->jesterCursor_0x230 = LoadCursorFromFileA(s_jester_ani_005a6244);
this->handCursor_0x234 = LoadCursorFromFileA(s_hand_ani_005a6238);
this->deleteNotCursor_0x238 = LoadCursorFromFileA(s_delete_not_ani_005a6228);
this->scimitarCursor_0x23c = LoadCursorFromFileA(s_scimitar_ani_005a6218);

if (!this->cursorType) {
if (DAT_WindowAndDirectDraw::instance.not_DDCAPS2_CANBOBHARDWARE_0xe0) {
this->cursorType = 2;
} else {
this->cursorType = 1;
}
}
MACRO_CALL_MEMBER(MouseState_Func::makeSelectedCursorTypeCurrent, this)();

if (notAniDeleteNotCursorRef) {
this->unknownNotAniDeleteNotCursor_0x204 = LoadCursorA(
DAT_WindowAndDirectDraw::instance.hInstanceUnk_0xa8, MAKEINTRESOURCE(notAniDeleteNotCursorRef));
}
if (notAniUnknownCursorRef) {
this->unknownNotAniCursor_0x218 = LoadCursorA(
DAT_WindowAndDirectDraw::instance.hInstanceUnk_0xa8, MAKEINTRESOURCE(notAniUnknownCursorRef));
}
}

}
}
30 changes: 30 additions & 0 deletions src/OpenSHC/Input/MouseState/makeSelectedCursorTypeCurrent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "../MouseState.func.hpp"

namespace OpenSHC {
namespace Input {

// FUNCTION: STRONGHOLDCRUSADER 0x00467F80
void MouseState::makeSelectedCursorTypeCurrent()
{
if (this->cursorType == 1) {
this->currentDefaultCursor = this->swordCursor_0x224;
this->currentDeleteCursor_0x200 = this->deleteCursor_0x228;
this->currentWaitCursor_0x208 = this->jesterCursor_0x230;
this->currentHandCursor_0x20c = this->handCursor_0x234;
this->currentDeleteNotCursor_0x210 = this->deleteNotCursor_0x238;
this->currentDefaultArabCursor_0x214 = this->scimitarCursor_0x23c;
return;
}

if (this->cursorType == 2) {
this->currentDefaultCursor = this->notAniDefaultCursor_0x24c;
this->currentDeleteCursor_0x200 = this->notAniDeleteCursor_0x250;
this->currentWaitCursor_0x208 = this->notAniWaitCursor_0x258;
this->currentHandCursor_0x20c = this->notAniHandCursor_0x25c;
this->currentDeleteNotCursor_0x210 = this->notAniDeleteNotCursor_0x260;
this->currentDefaultArabCursor_0x214 = this->notAniDefaultArabCursor_0x264;
}
}

}
}
90 changes: 90 additions & 0 deletions src/OpenSHC/Input/MouseState/renderPreviewAtMouseLocation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#include "../MouseState.func.hpp"

#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp"

#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp"
#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"
#include "OpenSHC/Globals/DAT_TileMapState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"
#include "OpenSHC/Globals/GMTotalPicturesProcessed.hpp"

namespace OpenSHC {
namespace Input {

// FUNCTION: STRONGHOLDCRUSADER 0x004685C0
void MouseState::renderPreviewAtMouseLocation()
{
int iVar1 = 0;
if (!this->previewEnabled || !this->rightClickState
|| !DAT_ViewportRenderState::instance.viewportState.field0_0x0
|| (DAT_GameCore::instance.currentMenuViewType != UI::Enums::MVT_BUILD_MENU
&& DAT_GameCore::instance.currentMenuViewType != UI::Enums::MVT_MAP_EDITOR_LANDSCAPING)) {
return;
}

if (DAT_TileMapState::instance.mapOrientation == 0) {
iVar1 = 0;
} else if (DAT_TileMapState::instance.mapOrientation == 2) {
iVar1 = 3;
} else if (DAT_TileMapState::instance.mapOrientation == 4) {
iVar1 = 2;
} else if (DAT_TileMapState::instance.mapOrientation == 6) {
iVar1 = 1;
}

if (!this->field60_0x1bc) {
int imageIndex = GMTotalPicturesProcessed::instance[16] + 37 + iVar1;
MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
DE::SHCDE::GM_FLOATS, 38 + iVar1,
(this->storedScreenSpaceX - DAT_GMImageHeaders::instance.imh[imageIndex].width / 2)
+ DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX,
(this->storedScreenSpaceY - DAT_GMImageHeaders::instance.imh[imageIndex].height / 2)
+ DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY - 50);
}

if (!this->field61_0x1c0) {
int uVar2 = this->mouseBasedEvent == 1;

int imageIndex = GMTotalPicturesProcessed::instance[16] + 35 + uVar2;
MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
DE::SHCDE::GM_FLOATS, 36 + uVar2,
(this->storedScreenSpaceX - DAT_GMImageHeaders::instance.imh[imageIndex].width / 2)
+ DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX,
(this->storedScreenSpaceY - DAT_GMImageHeaders::instance.imh[imageIndex].height / 2)
+ DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + 50);
}

if (!this->field63_0x1c8) {
int uVar2 = !DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk;
if (this->field59_0x1b8 == 3) {
uVar2 += 2;
}

int imageIndex = GMTotalPicturesProcessed::instance[16] + 45 + uVar2;
MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
DE::SHCDE::GM_FLOATS, 46 + uVar2,
(this->storedScreenSpaceX - DAT_GMImageHeaders::instance.imh[imageIndex].width / 2)
+ DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX + 80,
(this->storedScreenSpaceY - DAT_GMImageHeaders::instance.imh[imageIndex].height / 2)
+ DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY);
}

if (!this->field62_0x1c4) {
int uVar2 = !!DAT_TileMapState::instance.flatViewToggleValue1;
if (this->field59_0x1b8 == 4) {
uVar2 += 2;
}

int imageIndex = GMTotalPicturesProcessed::instance[16] + 124 + uVar2;
MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
DE::SHCDE::GM_FLOATS, 125 + uVar2,
(this->storedScreenSpaceX - DAT_GMImageHeaders::instance.imh[imageIndex].width / 2)
+ DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX - 80,
(this->storedScreenSpaceY - DAT_GMImageHeaders::instance.imh[imageIndex].height / 2)
+ DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY);
}
}

}
}
26 changes: 26 additions & 0 deletions src/OpenSHC/Input/MouseState/resetMouseCursorState.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "../MouseState.func.hpp"

#include "OpenSHC/Globals/DAT_MouseState.hpp"

namespace OpenSHC {
namespace Input {

// FUNCTION: STRONGHOLDCRUSADER 0x00468590
void MouseState::resetMouseCursorState()
{
this->selectionBox.left = 0;
this->selectionBox.top = 0;
this->selectionBox.right = 0;
this->selectionBox.bottom = 0;

this->previousSelectionBox.left = 0;
this->previousSelectionBox.top = 0;
this->previousSelectionBox.right = 0;
this->previousSelectionBox.bottom = 0;

DAT_MouseState::instance.selectionBoxMode = 0;
DAT_MouseState::instance.field31_0x94 = 0;
}

}
}
Loading
Loading