Skip to content

Commit

Permalink
Added option to pass activation keybind to game if released before de…
Browse files Browse the repository at this point in the history
…lay.
  • Loading branch information
Friendly0Fire committed Aug 29, 2022
1 parent ea8979a commit 3a179a0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion GW2Radial/common
9 changes: 5 additions & 4 deletions GW2Radial/include/Wheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ class Wheel : public SettingsMenu::Implementer

enum class BehaviorBeforeDelay : int
{
NOTHING = 0,
PREVIOUS = 1,
FAVORITE = 2,
DIRECTION = 3
NOTHING = 0,
PREVIOUS = 1,
FAVORITE = 2,
DIRECTION = 3,
PASS_TO_GAME = 4
};

Wheel(std::shared_ptr<Texture2D> bgTexture, std::string nickname, std::string displayName);
Expand Down
8 changes: 4 additions & 4 deletions GW2Radial/include/WheelElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ inline bool IsUsable(ConditionalState cs, ConditionalProperties cp)
{
if (isNone(cs) && isNone(cp & ConditionalProperties::USABLE_DEFAULT))
return false;
if (notNone(cs & ConditionalState::IN_WVW) && isNone(cp & ConditionalProperties::USABLE_WVW))
return false;

if (notNone(cs & ConditionalState::IN_COMBAT) && isNone(cp & ConditionalProperties::USABLE_IN_COMBAT))
return false;
if (notNone(cs & ConditionalState::IN_WVW) && isNone(cp & ConditionalProperties::USABLE_WVW))
return false;
if (notNone(cs & ConditionalState::UNDERWATER) && isNone(cp & ConditionalProperties::USABLE_UNDERWATER))
return false;
if (notNone(cs & ConditionalState::ON_WATER) && isNone(cp & ConditionalProperties::USABLE_ON_WATER))
Expand All @@ -66,11 +66,11 @@ inline bool IsVisible(ConditionalState cs, ConditionalProperties cp)
{
if (isNone(cs) && isNone(cp & ConditionalProperties::VISIBLE_DEFAULT))
return false;
if (notNone(cs & ConditionalState::IN_WVW) && isNone(cp & ConditionalProperties::VISIBLE_WVW))
return false;

if (notNone(cs & ConditionalState::IN_COMBAT) && isNone(cp & ConditionalProperties::VISIBLE_IN_COMBAT))
return false;
if (notNone(cs & ConditionalState::IN_WVW) && isNone(cp & ConditionalProperties::VISIBLE_WVW))
return false;
if (notNone(cs & ConditionalState::UNDERWATER) && isNone(cp & ConditionalProperties::VISIBLE_UNDERWATER))
return false;
if (notNone(cs & ConditionalState::ON_WATER) && isNone(cp & ConditionalProperties::VISIBLE_ON_WATER))
Expand Down
11 changes: 9 additions & 2 deletions GW2Radial/src/Wheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,12 @@ void Wheel::DrawMenu(Keybind** currentEditedKeybind)
ImGuiConfigurationWrapper(rb, "Favorite##ReleaseBeforeDelay", behaviorOnReleaseBeforeDelay_, int(BehaviorBeforeDelay::FAVORITE));
ImGui::SameLine();
ImGuiConfigurationWrapper(rb, "As if opened##ReleaseBeforeDelay", behaviorOnReleaseBeforeDelay_, int(BehaviorBeforeDelay::DIRECTION));
ImGui::SameLine();
ImGuiConfigurationWrapper(rb, "Pass to game##ReleaseBeforeDelay", behaviorOnReleaseBeforeDelay_, int(BehaviorBeforeDelay::PASS_TO_GAME));
ImGuiHelpTooltip(
"Determines the behavior of the menu if it is dismissed before it becomes visible. By default, it does nothing, but it can also (1) trigger the last selected item; "
"(2) trigger a fixed \"favorite\" option; (3) function exactly as if the menu was opened, making it possible to select an item with the mouse without seeing them.");
"(2) trigger a fixed \"favorite\" option; (3) function exactly as if the menu was opened, making it possible to select an item with the mouse without seeing them; "
"(4) forward the input to the game.");

if (BehaviorBeforeDelay(behaviorOnReleaseBeforeDelay_.value()) == BehaviorBeforeDelay::FAVORITE)
{
Expand Down Expand Up @@ -989,7 +992,6 @@ void Wheel::DeactivateWheel()
ResetConditionallyDelayed(true);
return;
}

// If keybind release was done before the wheel is visible, check our behavior
if (currentTriggerTime_ + displayDelayOption_.value() > TimeInMilliseconds())
{
Expand All @@ -1008,6 +1010,11 @@ void Wheel::DeactivateWheel()
if (!currentHovered_)
currentHovered_ = GetCenterHoveredElement();
break;
case BehaviorBeforeDelay::PASS_TO_GAME:
bool centerKeybind = currentPosition_.x == 0.5f && currentPosition_.y == 0.5f;
Input::i().SendKeybind((centerKeybind ? centralKeybind_ : keybind_).keyCombo());
currentHovered_ = nullptr;
break;
}
}
else if (!currentHovered_)
Expand Down

0 comments on commit 3a179a0

Please sign in to comment.