Skip to content

Commit

Permalink
tweak stats layout
Browse files Browse the repository at this point in the history
  • Loading branch information
fallahn committed Jul 18, 2023
1 parent 1d8af91 commit 1e5938a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions samples/golf/buildnumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef BUILD_NUMBER_H_
#define BUILD_NUMBER_H_

#define BUILDNUMBER 812
#define BUILDNUMBER_STR "812"
#define BUILDNUMBER 820
#define BUILDNUMBER_STR "820"

#endif /* BUILD_NUMBER_H_ */
1 change: 1 addition & 0 deletions samples/golf/src/golf/GolfStateUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,7 @@ void GolfState::showCountdown(std::uint8_t seconds)
m_achievementDebug.awardStatus = "Did not award Course Complete: there were only " + std::to_string(m_holeData.size()) + " holes.";
}

//this increments all the aggregated stats
Social::courseComplete(m_sharedData.mapDirectory, m_sharedData.holeCount);
}

Expand Down
11 changes: 10 additions & 1 deletion samples/golf/src/golf/StatsState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ void StatsState::createClubStatsTab(cro::Entity parent, const cro::SpriteSheet&
label += Clubs[clubID].getDistanceLabel(false, 0) + "\n";
label += Clubs[clubID].getDistanceLabel(false, 1) + "\n";
label += Clubs[clubID].getDistanceLabel(false, 2) + "\n";
label += "Top/Side";

const float labelScale = m_sharedData.imperialMeasurements ? 0.f : 1.f;

auto labelEnt = m_scene.createEntity();
Expand All @@ -545,6 +547,7 @@ void StatsState::createClubStatsTab(cro::Entity parent, const cro::SpriteSheet&
label += Clubs[clubID].getDistanceLabel(true, 0) + "\n";
label += Clubs[clubID].getDistanceLabel(true, 1) + "\n";
label += Clubs[clubID].getDistanceLabel(true, 2) + "\n";
label += "Top/Side";

labelEnt = m_scene.createEntity();
labelEnt.addComponent<cro::Transform>().setScale(glm::vec2(1.f - labelScale));
Expand Down Expand Up @@ -725,6 +728,12 @@ void StatsState::createHistoryTab(cro::Entity parent)
m_pieCharts[1].addValue(Achievements::getGlobalStat(StatStrings[i])->value);
}

//TODO find out why this always returns zero (also f/b9 hole stats are probably empty)
/*for (const auto& [course, _] : m_courseStrings)
{
m_pieCharts[0].addValue(Social::getCompletionCount(course));
}*/

const auto& font = m_sharedData.sharedResources->fonts.get(FontID::Info);
const auto& labelFont = m_sharedData.sharedResources->fonts.get(FontID::Label);

Expand Down Expand Up @@ -972,7 +981,7 @@ void StatsState::activateTab(std::int32_t tabID)

void StatsState::quitState()
{
m_scene.setSystemActive<cro::AudioPlayerSystem>(false);
//m_scene.setSystemActive<cro::AudioPlayerSystem>(false);
m_rootNode.getComponent<cro::Callback>().active = true;
m_audioEnts[AudioID::Back].getComponent<cro::AudioEmitter>().play();
}
Expand Down
2 changes: 1 addition & 1 deletion samples/golf/src/golf/StatsState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PieChart final

float getPercentage(std::uint32_t) const;
float getTotal() const { return m_total; }
float getValue(std::uint32_t i) { return m_values[i]; }
float getValue(std::uint32_t i) { return i < m_values.size() ? m_values[i] : 0.f; }

private:
float m_total;
Expand Down

0 comments on commit 1e5938a

Please sign in to comment.