diff --git a/CMakeLists.txt b/CMakeLists.txt index aa4aef40..1e72f753 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,6 +244,7 @@ set(Impacto_Src src/ui/widgets/cc/titlebutton.cpp src/ui/widgets/cclcc/titlebutton.cpp src/ui/widgets/cclcc/optionsbinarybutton.cpp + src/ui/widgets/cclcc/optionsslider.cpp src/ui/widgets/cclcc/saveentrybutton.cpp src/ui/widgets/cclcc/sysmenubutton.cpp src/ui/widgets/cclcc/tipsentrybutton.cpp @@ -556,6 +557,7 @@ set(Impacto_Header src/ui/widgets/cc/titlebutton.h src/ui/widgets/cclcc/titlebutton.h src/ui/widgets/cclcc/optionsbinarybutton.h + src/ui/widgets/cclcc/optionsslider.h src/renderer/3d/camera.h src/renderer/3d/model.h diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 7388db6e..d0252bae 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -5,6 +5,7 @@ #include "../../profile/scriptinput.h" #include "../../vm/interface/input.h" #include "../../ui/widgets/cclcc/optionsbinarybutton.h" +#include "../../ui/widgets/cclcc/optionsslider.h" namespace Impacto { namespace UI { @@ -26,40 +27,45 @@ OptionsMenu::OptionsMenu() { PoleAnimation = Profile::CCLCC::OptionsMenu::PoleAnimation.Instantiate(); Pages.reserve(4); + glm::vec2 pos = EntriesStartPosition; BasicPage = new Group(this); BasicPage->FocusLock = false; for (int i = 0; i < 4; i++) { - glm::vec2 pos = EntriesStartPosition; - pos.y += EntriesVerticalOffset * i; - BasicPage->Add(new OptionsBinaryButton(BinaryBoxSprite, OnSprite, OffSprite, LabelSprites[i], pos), FDIR_DOWN); + + pos.y += EntriesVerticalOffset; } Pages.push_back(BasicPage); + pos = EntriesStartPosition; TextPage = new Group(this); TextPage->FocusLock = false; - for (int i = 4; i < 7; i++) { - glm::vec2 pos = EntriesStartPosition; - pos.y += EntriesVerticalOffset * (i - 4); - - TextPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, - LabelSprites[i], pos), + for (int i = 4; i < 6; i++) { + TextPage->Add(new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos), FDIR_DOWN); + + pos.y += EntriesVerticalOffset; } + TextPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, + LabelSprites[6], pos), + FDIR_DOWN); Pages.push_back(TextPage); + pos = SoundEntriesStartPosition; SoundPage = new Group(this); SoundPage->FocusLock = false; for (int i = 7; i < 15; i++) { - glm::vec2 pos = SoundEntriesStartPosition; - pos.y += SoundEntriesVerticalOffset * (i - 7); - - SoundPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, - LabelSprites[i], pos), - FDIR_DOWN); + Widget* widget = + (i < 11 || i == 14) + ? new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos) + : widget = new OptionsBinaryButton(BinaryBoxSprite, YesSprite, + NoSprite, LabelSprites[i], pos); + SoundPage->Add(widget, FDIR_DOWN); + + pos.y += SoundEntriesVerticalOffset; } Pages.push_back(SoundPage); diff --git a/src/ui/widgets/cclcc/optionsslider.cpp b/src/ui/widgets/cclcc/optionsslider.cpp new file mode 100644 index 00000000..7dabe416 --- /dev/null +++ b/src/ui/widgets/cclcc/optionsslider.cpp @@ -0,0 +1,39 @@ +#include "optionsslider.h" + +#include "../../../profile/games/cclcc/optionsmenu.h" +#include "../../../renderer/renderer.h" + +using namespace Impacto::Profile::CCLCC::OptionsMenu; + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +OptionsSlider::OptionsSlider(const Sprite& box, const Sprite& label, + glm::vec2 pos) + : BoxSprite(box), LabelSprite(label) { + Bounds = RectF(pos.x, pos.y, SliderTrackOffset.x + box.ScaledWidth(), + LabelSprite.ScaledHeight()); +} + +void OptionsSlider::Render() { + HighlightTint.a = Tint.a; + glm::vec4 black = glm::vec4(0.0f, 0.0f, 0.0f, Tint.a); + + Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), black); + + RectF highlightBounds( + Bounds.X + SliderTrackOffset.x, Bounds.Y + SliderTrackOffset.y, + Progress * BoxSprite.ScaledWidth(), BoxSprite.ScaledHeight()); + Renderer->DrawRect(highlightBounds, HighlightTint); + + Renderer->DrawSprite(BoxSprite, Bounds.GetPos() + SliderTrackOffset, Tint); +} + +void OptionsSlider::UpdateInput() {} + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file diff --git a/src/ui/widgets/cclcc/optionsslider.h b/src/ui/widgets/cclcc/optionsslider.h new file mode 100644 index 00000000..a00ee00d --- /dev/null +++ b/src/ui/widgets/cclcc/optionsslider.h @@ -0,0 +1,30 @@ +#pragma once + +#include "../../widget.h" +#include "../../../spritesheet.h" + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +class OptionsSlider : public Widget { + public: + OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos); + + void Render() override; + void UpdateInput() override; + + private: + const Sprite& BoxSprite; + const Sprite& LabelSprite; + + glm::vec4 HighlightTint = glm::vec4(0.94f, 0.49f, 0.59f, 1.0f); + + float Progress = 0.0f; +}; + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file