Skip to content

Commit

Permalink
update mulligan message with options menu hint
Browse files Browse the repository at this point in the history
  • Loading branch information
fallahn committed Sep 10, 2024
1 parent 289f1fc commit 4e68f3a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
3 changes: 1 addition & 2 deletions libsocial/include/Input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ namespace Progress
{
file2.file->read(file2.file, values.data(), sizeof(values), 1);
SDL_RWclose(file2.file);
file2.file = nullptr;
}

values[leagueID] = std::min(1, mulliganCount);
Expand Down Expand Up @@ -205,8 +206,6 @@ namespace Progress
if (file2.file)
{
file2.file->read(file2.file, values.data(), sizeof(values), 1);
SDL_RWclose(file2.file);

mulliganCount = std::min(1, values[leagueID]);
}

Expand Down
31 changes: 27 additions & 4 deletions samples/golf/src/golf/GolfStateUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,18 @@ void GolfState::buildUI()
mRoot.getComponent<cro::Transform>().addChild(entity.getComponent<cro::Transform>());
auto tEnt = entity;

entity = m_uiScene.createEntity();
entity.addComponent<cro::Transform>().setPosition({ 0.f, -3.f });
entity.addComponent<cro::Drawable2D>().setFacing(cro::Drawable2D::Facing::Back);
entity.addComponent<cro::Text>(smallFont).setCharacterSize(InfoTextSize);
entity.getComponent<cro::Text>().setFillColour(TextGoldColour);
entity.getComponent<cro::Text>().setAlignment(cro::Text::Alignment::Centre);
entity.getComponent<cro::Text>().setString("Options Menu");
entity.getComponent<cro::Text>().setShadowOffset({ 1.f, -1.f });
entity.getComponent<cro::Text>().setShadowColour(LeaderboardTextDark);
mRoot.getComponent<cro::Transform>().addChild(entity.getComponent<cro::Transform>());
auto oEnt = entity;

struct MulliganData final
{
enum
Expand All @@ -1433,18 +1445,18 @@ void GolfState::buildUI()
Hold
};
std::int32_t state = 0;
std::int32_t idx = 0;
float progress = 0.f;
float currTime = 5.f;

};
static constexpr float SpinTime = 6.f; //Time between spins

mRoot.addComponent<cro::Callback>().active = true;
mRoot.getComponent<cro::Callback>().setUserData<MulliganData>();
mRoot.getComponent<cro::Callback>().function =
[&, mEnt, tEnt](cro::Entity e, float dt) mutable
[&, mEnt, tEnt, oEnt](cro::Entity e, float dt) mutable
{
auto& [state, progress, currTime] = e.getComponent<cro::Callback>().getUserData<MulliganData>();
auto& [state, idx, progress, currTime] = e.getComponent<cro::Callback>().getUserData<MulliganData>();
const float Speed = dt * 4.f;

switch (state)
Expand Down Expand Up @@ -1503,12 +1515,23 @@ void GolfState::buildUI()
if (mEnt.getComponent<cro::Drawable2D>().getFacing() == cro::Drawable2D::Facing::Front)
{
mEnt.getComponent<cro::Drawable2D>().setFacing(cro::Drawable2D::Facing::Back);
tEnt.getComponent<cro::Drawable2D>().setFacing(cro::Drawable2D::Facing::Front);

if (idx == 0)
{
tEnt.getComponent<cro::Drawable2D>().setFacing(cro::Drawable2D::Facing::Front);
idx = 1;
}
else
{
oEnt.getComponent<cro::Drawable2D>().setFacing(cro::Drawable2D::Facing::Front);
idx = 0;
}
}
else
{
mEnt.getComponent<cro::Drawable2D>().setFacing(cro::Drawable2D::Facing::Front);
tEnt.getComponent<cro::Drawable2D>().setFacing(cro::Drawable2D::Facing::Back);
oEnt.getComponent<cro::Drawable2D>().setFacing(cro::Drawable2D::Facing::Back);
}
}
}
Expand Down

0 comments on commit 4e68f3a

Please sign in to comment.