Skip to content

Commit

Permalink
[Virtual Gamepad] Set primary action button graphic to apply in char …
Browse files Browse the repository at this point in the history
…panel when applying stat points for level up
  • Loading branch information
StephenCWills authored and AJenbo committed Oct 28, 2021
1 parent 4d5a517 commit e2408bc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Source/controls/touch/renderers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,24 @@ void LoadPotionArt(Art *potionArt, SDL_Renderer *renderer)
}
}

bool InteractsWithCharButton(Point point)
{
auto &myPlayer = Players[MyPlayerId];
if (myPlayer._pStatPts == 0)
return false;
for (auto attribute : enum_values<CharacterAttribute>()) {
if (myPlayer.GetBaseAttributeValue(attribute) >= myPlayer.GetMaximumAttributeValue(attribute))
continue;
auto buttonId = static_cast<size_t>(attribute);
Rectangle button = ChrBtnsRect[buttonId];
button.position = GetPanelPosition(UiPanels::Character, button.position);
if (button.Contains(point)) {
return true;
}
}
return false;
}

} // namespace

void RenderVirtualGamepad(SDL_Renderer *renderer)
Expand Down Expand Up @@ -381,6 +399,8 @@ VirtualGamepadButtonType PrimaryActionButtonRenderer::GetButtonType()
// NEED: Confirm surface
if (qtextflag)
return GetTalkButtonType(virtualPadButton->isHeld);
if (chrflag && InteractsWithCharButton(MousePosition))
return GetApplyButtonType(virtualPadButton->isHeld);
if (invflag)
return GetInventoryButtonType();
if (leveltype == DTYPE_TOWN)
Expand Down

0 comments on commit e2408bc

Please sign in to comment.