Skip to content

Commit

Permalink
Added highlight color to profile
Browse files Browse the repository at this point in the history
  • Loading branch information
PringlesGang committed Oct 20, 2024
1 parent b7a9c3d commit 178457c
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 16 deletions.
2 changes: 2 additions & 0 deletions profiles/cclcc/hud/optionsmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ root.OptionsMenu = {
FadeInDuration = 0.2,
FadeOutDuration = 0.2,

HighlightColor = { X = 0.94, Y = 0.49, Z = 0.59 },

BackgroundSprite = "OptionsBackground",
BackgroundPosition = { X = 179, Y = 0 },

Expand Down
19 changes: 11 additions & 8 deletions src/games/cclcc/optionsmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ OptionsMenu::OptionsMenu() {

Pages.reserve(4);
glm::vec2 pos = EntriesStartPosition;
glm::vec4 highlightTint(HighlightColor, 1.0f);

BasicPage = new Group(this);
BasicPage->FocusLock = false;
for (int i = 0; i < 4; i++) {
BasicPage->Add(new OptionsBinaryButton(BinaryBoxSprite, OnSprite, OffSprite,
LabelSprites[i], pos),
LabelSprites[i], pos, highlightTint),
FDIR_DOWN);

pos.y += EntriesVerticalOffset;
Expand All @@ -44,25 +45,27 @@ OptionsMenu::OptionsMenu() {
TextPage = new Group(this);
TextPage->FocusLock = false;
for (int i = 4; i < 6; i++) {
TextPage->Add(new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos),
TextPage->Add(new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos,
highlightTint),
FDIR_DOWN);

pos.y += EntriesVerticalOffset;
}
TextPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite,
LabelSprites[6], pos),
LabelSprites[6], pos, highlightTint),
FDIR_DOWN);
Pages.push_back(TextPage);

pos = SoundEntriesStartPosition;
SoundPage = new Group(this);
SoundPage->FocusLock = false;
for (int i = 7; i < 15; i++) {
Widget* widget =
(i < 11 || i == 14)
? new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos)
: widget = new OptionsBinaryButton(BinaryBoxSprite, YesSprite,
NoSprite, LabelSprites[i], pos);
Widget* widget = (i < 11 || i == 14)
? new OptionsSlider(SliderTrackSprite, LabelSprites[i],
pos, highlightTint)
: widget = new OptionsBinaryButton(
BinaryBoxSprite, YesSprite, NoSprite,
LabelSprites[i], pos, highlightTint);
SoundPage->Add(widget, FDIR_DOWN);

pos.y += SoundEntriesVerticalOffset;
Expand Down
2 changes: 2 additions & 0 deletions src/profile/games/cclcc/optionsmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace OptionsMenu {
void Configure() {
BackgroundPosition = EnsureGetMemberVec2("BackgroundPosition");

HighlightColor = EnsureGetMemberVec3("HighlightColor");

PointerSprite = EnsureGetMemberSprite("PointerSprite");
PointerOffset = EnsureGetMemberVec2("PointerOffset");

Expand Down
2 changes: 2 additions & 0 deletions src/profile/games/cclcc/optionsmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ int constexpr PortraitSpriteCount = 26;

inline glm::vec2 BackgroundPosition;

inline glm::vec3 HighlightColor;

inline Sprite PointerSprite;
inline glm::vec2 PointerOffset;

Expand Down
6 changes: 4 additions & 2 deletions src/ui/widgets/cclcc/optionsbinarybutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ namespace CCLCC {
OptionsBinaryButton::OptionsBinaryButton(const Sprite& box,
const Sprite& trueLabel,
const Sprite& falseLabel,
const Sprite& label, glm::vec2 pos)
const Sprite& label, glm::vec2 pos,
glm::vec4 highlightTint)
: BoxSprite(box),
TrueSprite(trueLabel),
FalseSprite(falseLabel),
LabelSprite(label) {
LabelSprite(label),
HighlightTint(highlightTint) {
Bounds = RectF(pos.x, pos.y, BinaryBoxOffset.x + BoxSprite.ScaledWidth(),
LabelSprite.ScaledHeight());
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/widgets/cclcc/optionsbinarybutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class OptionsBinaryButton : public Widget {
public:
OptionsBinaryButton(const Sprite& box, const Sprite& trueLabel,
const Sprite& falseLabel, const Sprite& label,
glm::vec2 pos);
glm::vec2 pos, glm::vec4 highlightTint);

void Render() override;
void UpdateInput() override;
Expand All @@ -26,7 +26,7 @@ class OptionsBinaryButton : public Widget {
const Sprite& FalseSprite;
const Sprite& LabelSprite;

glm::vec4 HighlightTint = glm::vec4(0.94f, 0.49f, 0.59f, 1.0f);
glm::vec4 HighlightTint;

bool State = true;
};
Expand Down
4 changes: 2 additions & 2 deletions src/ui/widgets/cclcc/optionsslider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace Widgets {
namespace CCLCC {

OptionsSlider::OptionsSlider(const Sprite& box, const Sprite& label,
glm::vec2 pos)
: BoxSprite(box), LabelSprite(label) {
glm::vec2 pos, glm::vec4 highlightTint)
: BoxSprite(box), LabelSprite(label), HighlightTint(highlightTint) {
Bounds = RectF(pos.x, pos.y, SliderTrackOffset.x + box.ScaledWidth(),
LabelSprite.ScaledHeight());
}
Expand Down
5 changes: 3 additions & 2 deletions src/ui/widgets/cclcc/optionsslider.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace CCLCC {

class OptionsSlider : public Widget {
public:
OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos);
OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos,
glm::vec4 highlightTint);

void Render() override;
void UpdateInput() override;
Expand All @@ -19,7 +20,7 @@ class OptionsSlider : public Widget {
const Sprite& BoxSprite;
const Sprite& LabelSprite;

glm::vec4 HighlightTint = glm::vec4(0.94f, 0.49f, 0.59f, 1.0f);
glm::vec4 HighlightTint;

float Progress = 0.0f;
};
Expand Down

0 comments on commit 178457c

Please sign in to comment.