Skip to content

Commit

Permalink
Implemented muting voice with mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
PringlesGang committed Dec 27, 2024
1 parent 9385e16 commit 0d94b82
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/ui/widgets/cclcc/optionsvoiceslider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ OptionsVoiceSlider::OptionsVoiceSlider(
Bounds =
RectF(Bounds.X, Bounds.Y, VoiceEntryDimensions.x, VoiceEntryDimensions.y);
EntryButton.Bounds = Bounds;

std::function<void(ClickButton*)> onClick = std::bind(
&OptionsVoiceSlider::MuteButtonOnClick, this, std::placeholders::_1);
const RectF muteButtonBounds(Bounds.GetPos().x + PortraitOffset.x,
Bounds.GetPos().y + PortraitOffset.y,
portrait.ScaledWidth(), portrait.ScaledHeight());
MuteButton = ClickButton(0, muteButtonBounds, onClick);
}

void OptionsVoiceSlider::Render() {
Expand Down Expand Up @@ -53,10 +60,25 @@ void OptionsVoiceSlider::Render() {

void OptionsVoiceSlider::UpdateInput() {
OptionsSlider::UpdateInput();
MuteButton.UpdateInput();

if (HasFocus) Muted ^= (bool)(PADinputButtonWentDown & PAD1Y);
}

void OptionsVoiceSlider::Show() {
OptionsSlider::Show();
MuteButton.Show();
}

void OptionsVoiceSlider::Hide() {
OptionsSlider::Hide();
MuteButton.Hide();
}

void OptionsVoiceSlider::MuteButtonOnClick(ClickButton* target) {
Muted = !Muted;
}

} // namespace CCLCC
} // namespace Widgets
} // namespace UI
Expand Down
5 changes: 5 additions & 0 deletions src/ui/widgets/cclcc/optionsvoiceslider.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ class OptionsVoiceSlider : public OptionsSlider {
void Render() override;
void UpdateInput() override;

void Show() override;
void Hide() override;

private:
const Sprite& Portrait;
const Sprite& MutedPortrait;

bool Muted = false;
ClickButton MuteButton;
void MuteButtonOnClick(ClickButton* target);
};

} // namespace CCLCC
Expand Down

0 comments on commit 0d94b82

Please sign in to comment.