From 1f8fe0fd81053821f26787e9809cd1a13f747819 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 9 Dec 2017 11:49:18 +0100 Subject: [PATCH] track top ten for each record --- src/app/states.cpp | 13 +++- src/ui/CreaturePanel.hpp | 2 + src/ui/RecordsPanel.hpp | 9 ++- src/ui/TimePanel.hpp | 3 + src/ui/ui.cpp | 119 +++++++++++++++++--------------- src/world/Record.hpp | 26 +++++-- src/world/Simulation.hpp | 2 +- src/world/sim.cpp | 145 +++++++++++++++++++++++---------------- 8 files changed, 196 insertions(+), 123 deletions(-) diff --git a/src/app/states.cpp b/src/app/states.cpp index eff36da..bec6da1 100644 --- a/src/app/states.cpp +++ b/src/app/states.cpp @@ -30,6 +30,9 @@ MasterState::MasterState(Assets &assets, world::Simulation &sim) noexcept , remain(0) , thirds(0) , paused(false) { + cp.ZIndex(10.0f); + rp.ZIndex(20.0f); + tp.ZIndex(30.0f); } MasterState::~MasterState() noexcept { @@ -89,11 +92,13 @@ int MasterState::FrameMS() const noexcept { void MasterState::OnKeyDown(const SDL_KeyboardEvent &e) { if (e.keysym.sym == SDLK_p) { paused = !paused; + } else if (e.keysym.sym == SDLK_F1) { + rp.Toggle(); } } void MasterState::OnMouseDown(const SDL_MouseButtonEvent &e) { - if (e.button == SDL_BUTTON_RIGHT && cp.Shown()) { + if (e.button == SDL_BUTTON_RIGHT) { SDL_SetRelativeMouseMode(SDL_TRUE); cam_dragging = true; } @@ -139,7 +144,11 @@ void MasterState::OnMouseWheel(const SDL_MouseWheelEvent &e) { constexpr double zoom_scale = -1.0; constexpr double zoom_base = 1.125; cam_orient.z = glm::clamp(cam_orient.z + double(e.x) * roll_scale, PI * -0.5, PI * 0.5); - cam_tgt_dist = std::max(cp.GetCreature().Size() * 2.0, cam_tgt_dist * std::pow(zoom_base, double(e.y) * zoom_scale)); + if (cp.Shown()) { + cam_tgt_dist = std::max(cp.GetCreature().Size() * 2.0, cam_tgt_dist * std::pow(zoom_base, double(e.y) * zoom_scale)); + } else { + cam_tgt_dist = std::max(1.0, cam_tgt_dist * std::pow(zoom_base, double(e.y) * zoom_scale)); + } } void MasterState::OnRender(graphics::Viewport &viewport) { diff --git a/src/ui/CreaturePanel.hpp b/src/ui/CreaturePanel.hpp index 719af40..be12348 100644 --- a/src/ui/CreaturePanel.hpp +++ b/src/ui/CreaturePanel.hpp @@ -40,6 +40,8 @@ public: bool Shown() const noexcept { return c; } const creature::Creature &GetCreature() const noexcept { return *c; } + void ZIndex(float z) noexcept { panel.ZIndex(z); } + void Draw(graphics::Viewport &) noexcept; private: diff --git a/src/ui/RecordsPanel.hpp b/src/ui/RecordsPanel.hpp index 032ad56..150a7a0 100644 --- a/src/ui/RecordsPanel.hpp +++ b/src/ui/RecordsPanel.hpp @@ -24,12 +24,19 @@ public: public: void Draw(graphics::Viewport &) noexcept; + void Show() noexcept { shown = true; } + void Hide() noexcept { shown = false; } + void Toggle() noexcept { shown = !shown; } + bool Shown() const noexcept { return shown; } + + void ZIndex(float z) noexcept { panel.ZIndex(z); } + private: world::Simulation ∼ - Label *live; std::vector