Skip to content
Snippets Groups Projects
Commit 0d2d261a authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

code cleanup

parent 287cc28e
No related branches found
No related tags found
No related merge requests found
......@@ -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));
}
......
......@@ -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);
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment