feat: add summon menu

This commit is contained in:
2021-11-04 10:03:37 +01:00
parent f2f79781db
commit 129544d127
15 changed files with 307 additions and 51 deletions

View File

@@ -0,0 +1,27 @@
#pragma once
#include "GuiWidget.h"
#include <vector>
#include <memory>
namespace td {
namespace gui {
class GuiManager {
private:
std::vector<std::shared_ptr<GuiWidget>> m_Widgets;
public:
void renderWidgets(){
for(auto widget : m_Widgets){
widget->render();
}
}
void addWidgets(const std::shared_ptr<GuiWidget>& widget){
m_Widgets.push_back(std::move(widget));
}
};
} // namespace gui
} // namespace td

View File

@@ -0,0 +1,25 @@
#pragma once
namespace td {
namespace client {
class Client;
} // namespace client
namespace gui {
class GuiWidget {
protected:
client::Client* m_Client;
public:
GuiWidget(client::Client* client) {
m_Client = client;
}
client::Client* getClient() { return m_Client; }
virtual void render() = 0;
};
} // namespace gui
} // namespace td

View File

@@ -0,0 +1,26 @@
#pragma once
#include "GuiWidget.h"
#include <array>
#include "game/Mobs.h"
namespace td {
namespace gui {
class SummonMenu : public GuiWidget{
private:
bool m_MenuOpened;
int m_ImageWidth = 100;
static constexpr int m_MobTypeCount = static_cast<std::size_t>(td::game::MobType::MOB_COUNT);
std::array<int, static_cast<std::size_t>(m_MobTypeCount)> m_Values;
public:
SummonMenu(client::Client* client);
virtual void render();
private:
void setSummonMax(int valueIndex);
};
} // namespace gui
} // namespace td