-
Notifications
You must be signed in to change notification settings - Fork 4
reimplement OpenSHC::Input::MouseState 100% #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
TheRedDaemon
wants to merge
18
commits into
main
Choose a base branch
from
reimpl/mouse-state
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
64f1b61
reimplement: SHC_3BB0A8C1_0x004709B0 100%
TheRedDaemon 972f7e2
reimplement: SHC_3BB0A8C1_0x00467F80 100%
TheRedDaemon 3418dd3
reimplement: SHC_3BB0A8C1_0x00468030 100%
TheRedDaemon 28c3ef9
reimplement: SHC_3BB0A8C1_0x004680B0 100%
TheRedDaemon 1a5dc06
reimplement: SHC_3BB0A8C1_0x004680C0 100%
TheRedDaemon c8a717d
reimplement: SHC_3BB0A8C1_0x00468100 100%
TheRedDaemon 6376eda
reimplement: SHC_3BB0A8C1_0x00468370 100%
TheRedDaemon 0bd8e96
reimplement: SHC_3BB0A8C1_0x00468420 100%
TheRedDaemon c4d33e9
reimplement: SHC_3BB0A8C1_0x004684D0 100%
TheRedDaemon 51c80b1
reimplement: SHC_3BB0A8C1_0x00468590 100%
TheRedDaemon 4dc2ff6
reimplement: SHC_3BB0A8C1_0x004685C0 100%
TheRedDaemon 33c34bd
reimplement: SHC_3BB0A8C1_0x004687F0 100%
TheRedDaemon e91300d
reimplement: SHC_3BB0A8C1_0x004689D0 100%
TheRedDaemon 6ca4358
reimplement: SHC_3BB0A8C1_0x00470A00 100%
TheRedDaemon 64675fb
reimplement: SHC_3BB0A8C1_0x00470B30 100%
TheRedDaemon 09788e8
reimplement: SHC_3BB0A8C1_0x00470BC0 and SHC_3BB0A8C1_0x0046CCD0 100%
TheRedDaemon b845f0b
reimplement: SHC_3BB0A8C1_0x00472A90 100%
TheRedDaemon cc4a338
reimplement: OpenSHC::Input::MouseState revert type change
TheRedDaemon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
42
src/OpenSHC/Input/MouseState/extendSelectionBoxToMouse.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } | ||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
30
src/OpenSHC/Input/MouseState/makeSelectedCursorTypeCurrent.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You sure? Changing this would mean changing all enum bytes to enum chars, which is fine I guess, since original enum is also usually int (not uint). Just want to be sure before I implement such a large change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. While a while, I clearly remember that I was hesitant and tested around, but it is a
char.