From 0d2d261a2eceaf6bcda961d69db5781ad9fb41e6 Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Sat, 26 Nov 2022 15:30:18 +0000 Subject: [PATCH] code cleanup --- fggl/scenes/menu.cpp | 17 ++++++++--------- include/fggl/data/assimp/module.hpp | 2 +- include/fggl/scenes/menu.hpp | 6 +++--- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/fggl/scenes/menu.cpp b/fggl/scenes/menu.cpp index a497298..b7330a7 100644 --- a/fggl/scenes/menu.cpp +++ b/fggl/scenes/menu.cpp @@ -61,24 +61,23 @@ namespace fggl::scenes { } - void BasicMenu::add(const std::string &name, callback cb) { - m_items[name] = cb; + void BasicMenu::add(const std::string &name, const Callback& callback) { + m_items[name] = callback; - const math::vec2 btnSize{150.0f, 30.0f}; + const math::vec2 btnSize{150.0F, 30.0F}; const float spacing = 5; - const float padX = 50.0f; - const float padY = 50.0f; + const float padX = 50.0F; + const float padY = 50.0F; // figure out the position based off the old logic // FIXME should be the container's job - math::vec2 pos{1920.0f - (padX + btnSize.x), padY}; - auto btnIdx = m_items.size() - 1; - pos.y += (btnIdx * (btnSize.y + spacing)); + math::vec2 pos{1920.0F - (padX + btnSize.x), padY}; + pos.y += ( (m_items.size()-1.0F) * (btnSize.y + spacing)); // build the button auto btn = std::make_unique<gui::Button>(pos, btnSize); btn->label(name); - btn->addCallback(cb); + btn->addCallback(callback); m_canvas.add(std::move(btn)); } diff --git a/include/fggl/data/assimp/module.hpp b/include/fggl/data/assimp/module.hpp index 0a4001d..a10e114 100644 --- a/include/fggl/data/assimp/module.hpp +++ b/include/fggl/data/assimp/module.hpp @@ -43,7 +43,7 @@ namespace fggl::data::models { // new style loaders (textures) bool load_tex_stb(const std::filesystem::path& filePath, assets::MemoryBlock& block); - static assets::AssetTypeID is_tex_stb(const std::filesystem::path& filePath); + assets::AssetTypeID is_tex_stb(const std::filesystem::path& filePath); // new style loaders (models) assets::AssetTypeID is_model_assimp(const std::filesystem::path& filePath); diff --git a/include/fggl/scenes/menu.hpp b/include/fggl/scenes/menu.hpp index 70c0b15..740d655 100644 --- a/include/fggl/scenes/menu.hpp +++ b/include/fggl/scenes/menu.hpp @@ -26,7 +26,7 @@ namespace fggl::scenes { - using callback = std::function<void(void)>; + using Callback = std::function<void(void)>; class BasicMenu : public AppState { public: @@ -38,11 +38,11 @@ namespace fggl::scenes { void activate() override; void deactivate() override; - void add(const std::string &label, callback cb); + void add(const std::string &label, const Callback& /*cb*/); private: input::Input *m_inputs; - std::map<const std::string, callback> m_items; + std::map<const std::string, Callback> m_items; // menu state std::string m_active; -- GitLab