-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented pages and binary buttons
- Loading branch information
1 parent
4382d70
commit 7aa1e26
Showing
7 changed files
with
215 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "optionsbinarybutton.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 { | ||
|
||
OptionsBinaryButton::OptionsBinaryButton(const Sprite& box, | ||
const Sprite& trueLabel, | ||
const Sprite& falseLabel, | ||
const Sprite& label, glm::vec2 pos) | ||
: BoxSprite(box), | ||
TrueSprite(trueLabel), | ||
FalseSprite(falseLabel), | ||
LabelSprite(label) { | ||
Bounds = RectF(pos.x, pos.y, BinaryBoxOffset.x + BoxSprite.ScaledWidth(), | ||
LabelSprite.ScaledHeight()); | ||
} | ||
|
||
inline glm::vec2 OptionsBinaryButton::GetTruePos() const { | ||
return Bounds.GetPos() + BinaryBoxOffset; | ||
} | ||
|
||
inline glm::vec2 OptionsBinaryButton::GetFalsePos() const { | ||
return Bounds.GetPos() + BinaryBoxOffset + | ||
glm::vec2(BoxSprite.ScaledWidth() / 2, 0.0f); | ||
} | ||
|
||
void OptionsBinaryButton::Render() { | ||
HighlightTint.a = Tint.a; | ||
glm::vec4 black = glm::vec4(0.0f, 0.0f, 0.0f, Tint.a); | ||
|
||
glm::vec4 trueTint; | ||
glm::vec4 falseTint; | ||
glm::vec2 highlightPos; | ||
RectF highlightBounds(0.0f, 0.0f, BoxSprite.ScaledWidth() / 2, | ||
BoxSprite.ScaledHeight()); | ||
if (State) { | ||
trueTint = Tint; | ||
falseTint = black; | ||
highlightPos = GetTruePos(); | ||
} else { | ||
trueTint = black; | ||
falseTint = Tint; | ||
highlightPos = GetFalsePos(); | ||
} | ||
highlightBounds.X = highlightPos.x; | ||
highlightBounds.Y = highlightPos.y; | ||
|
||
Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), black); | ||
|
||
Renderer->DrawRect(highlightBounds, HighlightTint); | ||
Renderer->DrawSprite(BoxSprite, GetTruePos(), Tint); | ||
|
||
Renderer->DrawSprite(TrueSprite, GetTruePos(), trueTint); | ||
Renderer->DrawSprite(FalseSprite, GetFalsePos(), falseTint); | ||
} | ||
|
||
void OptionsBinaryButton::UpdateInput() {} | ||
|
||
} // namespace CCLCC | ||
} // namespace Widgets | ||
} // namespace UI | ||
} // namespace Impacto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include "../../widget.h" | ||
#include "../../../spritesheet.h" | ||
|
||
namespace Impacto { | ||
namespace UI { | ||
namespace Widgets { | ||
namespace CCLCC { | ||
|
||
class OptionsBinaryButton : public Widget { | ||
public: | ||
OptionsBinaryButton(const Sprite& box, const Sprite& trueLabel, | ||
const Sprite& falseLabel, const Sprite& label, | ||
glm::vec2 pos); | ||
|
||
void Render() override; | ||
void UpdateInput() override; | ||
|
||
private: | ||
inline glm::vec2 GetTruePos() const; | ||
inline glm::vec2 GetFalsePos() const; | ||
|
||
const Sprite& BoxSprite; | ||
const Sprite& TrueSprite; | ||
const Sprite& FalseSprite; | ||
const Sprite& LabelSprite; | ||
|
||
glm::vec4 HighlightTint = glm::vec4(0.94f, 0.49f, 0.59f, 1.0f); | ||
|
||
bool State = true; | ||
}; | ||
|
||
} // namespace CCLCC | ||
} // namespace Widgets | ||
} // namespace UI | ||
} // namespace Impacto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters