Skip to content
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

[Customized] Change the scrolling action of the sidebar #1522

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ This page lists all the individual contributions to the project by their author.
- Fix for sidebar not updating queued unit numbers when on hold
- New Parabola trajectory
- Enhanced Bombard trajectory
- Change the scrolling action of the sidebar and trigger hook of mouse wheel scroll
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
Expand Down
16 changes: 16 additions & 0 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,3 +637,19 @@ In `RA2MD.ini`:
[Phobos]
SaveGameOnScenarioStart=true ; boolean
```

### Change the scrolling action of the sidebar

- Allow players to decide for themselves:
- Whether can use mouse wheel to scroll sidebar strip when the mouse is not on it by `ScrollSidebarStripInTactical` .
- Whether can use mouse wheel to scroll sidebar strip when pressing Ctrl by `ScrollSidebarStripWhenHoldCtrl`, Alt by `ScrollSidebarStripWhenHoldAlt`, or Shift by `ScrollSidebarStripWhenHoldShift`.

In `RA2MD.ini`:

```ini
[Phobos]
ScrollSidebarStripInTactical=true ; boolean
ScrollSidebarStripWhenHoldAlt=true ; boolean
ScrollSidebarStripWhenHoldCtrl=true ; boolean
ScrollSidebarStripWhenHoldShift=true ; boolean
```
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ New:
- Enhanced Bombard trajectory (by CrimRecya & Ollerus, based on knowledge of NaotoYuuki)
- Toggle waypoint for building (by TaranDahl)
- Bunkerable checks dehardcode (by TaranDahl)
- Change the scrolling action of the sidebar and trigger hook of mouse wheel scroll (by CrimRecya)

Vanilla fixes:
- Aircraft will now behave as expected according to it's `MovementZone` and `SpeedType` when moving onto different surfaces. In particular, this fixes erratic behavior when vanilla aircraft is ordered to move onto water surface and instead the movement order changes to a shore nearby (by CrimRecya)
Expand Down
48 changes: 47 additions & 1 deletion src/Commands/Commands.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <CCINIClass.h>
#include "Commands.h"

#include "ObjectInfo.h"
Expand All @@ -11,6 +10,13 @@
#include "ToggleDesignatorRange.h"
#include "SaveVariablesToFile.h"

#include <CCINIClass.h>
#include <InputManagerClass.h>
#include <MouseClass.h>
#include <WWMouseClass.h>

#include <Utilities/Macro.h>

DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
{
// Load it after Ares'
Expand All @@ -36,3 +42,43 @@ DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)

return 0;
}

static void MouseWheelDownCommand()
{
// Debug::LogAndMessage("[Frame: %d] Mouse Wheel Down", Unsorted::CurrentFrame());

// SomeCommand->Execute(WWKey);
}

static void MouseWheelUpCommand()
{
// Debug::LogAndMessage("[Frame: %d] Mouse Wheel Up", Unsorted::CurrentFrame());

// SomeCommand->Execute(WWKey);
}

DEFINE_HOOK(0x777998, Game_WndProc_ScrollMouseWheel, 0x6)
{
GET(const WPARAM, WParam, ECX);

if (WParam & 0x80000000u)
MouseWheelDownCommand();
else
MouseWheelUpCommand();

return 0;
}

static inline bool CheckSkipScrollSidebar()
{
return !Phobos::Config::ScrollSidebarStripWhenHoldAlt && InputManagerClass::Instance->IsForceMoveKeyPressed()
|| !Phobos::Config::ScrollSidebarStripWhenHoldCtrl && InputManagerClass::Instance->IsForceFireKeyPressed()
|| !Phobos::Config::ScrollSidebarStripWhenHoldShift && InputManagerClass::Instance->IsForceSelectKeyPressed()
|| !Phobos::Config::ScrollSidebarStripInTactical && WWMouseClass::Instance->XY1.X < Make_Global<int>(0xB0CE30); // TacticalClass::view_bound.Width
}

DEFINE_HOOK(0x533F50, Game_ScrollSidebar_Skip, 0x5)
{
enum { SkipScrollSidebar = 0x533FC3 };
return CheckSkipScrollSidebar() ? SkipScrollSidebar : 0;
}
8 changes: 8 additions & 0 deletions src/Phobos.INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ bool Phobos::Config::ShowWeedsCounter = false;
bool Phobos::Config::HideLightFlashEffects = true;
bool Phobos::Config::ShowFlashOnSelecting = false;
bool Phobos::Config::UnitPowerDrain = false;
bool Phobos::Config::ScrollSidebarStripInTactical = true;
bool Phobos::Config::ScrollSidebarStripWhenHoldAlt = true;
bool Phobos::Config::ScrollSidebarStripWhenHoldCtrl = true;
bool Phobos::Config::ScrollSidebarStripWhenHoldShift = true;

bool Phobos::Misc::CustomGS = false;
int Phobos::Misc::CustomGS_ChangeInterval[7] = { -1, -1, -1, -1, -1, -1, -1 };
Expand All @@ -79,6 +83,10 @@ DEFINE_HOOK(0x5FACDF, OptionsClass_LoadSettings_LoadPhobosSettings, 0x5)
Phobos::Config::ShowWeedsCounter = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ShowWeedsCounter", true);
Phobos::Config::HideLightFlashEffects = CCINIClass::INI_RA2MD->ReadBool("Phobos", "HideLightFlashEffects", false);
Phobos::Config::ShowFlashOnSelecting = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ShowFlashOnSelecting", false);
Phobos::Config::ScrollSidebarStripInTactical = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ScrollSidebarStripInTactical", true);
Phobos::Config::ScrollSidebarStripWhenHoldAlt = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ScrollSidebarStripWhenHoldAlt", true);
Phobos::Config::ScrollSidebarStripWhenHoldCtrl = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ScrollSidebarStripWhenHoldCtrl", true);
Phobos::Config::ScrollSidebarStripWhenHoldShift = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ScrollSidebarStripWhenHoldShift", true);

// Custom game speeds, 6 - i so that GS6 is index 0, just like in the engine
Phobos::Config::CampaignDefaultGameSpeed = 6 - CCINIClass::INI_RA2MD->ReadInteger("Phobos", "CampaignDefaultGameSpeed", 4);
Expand Down
4 changes: 4 additions & 0 deletions src/Phobos.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class Phobos
static bool HideLightFlashEffects;
static bool ShowFlashOnSelecting;
static bool UnitPowerDrain;
static bool ScrollSidebarStripInTactical;
static bool ScrollSidebarStripWhenHoldAlt;
static bool ScrollSidebarStripWhenHoldCtrl;
static bool ScrollSidebarStripWhenHoldShift;
};

class Misc
Expand Down