indent with tabs
This commit is contained in:
@@ -13,17 +13,17 @@
|
||||
#if defined(__has_include)
|
||||
|
||||
#if __has_include(<GL/glew.h>)
|
||||
#define TD_IMPL_OPENGL_LOADER_GLEW
|
||||
#define TD_IMPL_OPENGL_LOADER_GLEW
|
||||
#elif __has_include(<glad/glad.h>)
|
||||
#define TD_IMPL_OPENGL_LOADER_GLAD
|
||||
#define TD_IMPL_OPENGL_LOADER_GLAD
|
||||
#elif __has_include(<GL/gl3w.h>)
|
||||
#define TD_IMPL_OPENGL_LOADER_GL3W
|
||||
#define TD_IMPL_OPENGL_LOADER_GL3W
|
||||
#elif __has_include(<glbinding/glbinding.h>)
|
||||
#define TD_IMPL_OPENGL_LOADER_GLBINDING3
|
||||
#define TD_IMPL_OPENGL_LOADER_GLBINDING3
|
||||
#elif __has_include(<glbinding/Binding.h>)
|
||||
#define TD_IMPL_OPENGL_LOADER_GLBINDING2
|
||||
#define TD_IMPL_OPENGL_LOADER_GLBINDING2
|
||||
#else
|
||||
#error "Cannot detect OpenGL loader!"
|
||||
#error "Cannot detect OpenGL loader!"
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
@@ -11,45 +11,45 @@ namespace render {
|
||||
|
||||
class Renderer {
|
||||
public:
|
||||
static constexpr float m_AnimationSpeed = 2.0f;
|
||||
static constexpr float m_AnimationSpeed = 2.0f;
|
||||
|
||||
struct Model {
|
||||
GL::VertexArray* vao;
|
||||
Vec2f positon;
|
||||
};
|
||||
struct Model {
|
||||
GL::VertexArray* vao;
|
||||
Vec2f positon;
|
||||
};
|
||||
private:
|
||||
std::unique_ptr<shader::WorldShader> m_WorldShader;
|
||||
std::unique_ptr<shader::EntityShader> m_EntityShader;
|
||||
std::unique_ptr<shader::WorldShader> m_WorldShader;
|
||||
std::unique_ptr<shader::EntityShader> m_EntityShader;
|
||||
|
||||
Vec3f m_BackgroundColor;
|
||||
Vec3f m_BackgroundColor;
|
||||
|
||||
bool m_IsometricView = true;
|
||||
float m_IsometricShade = m_IsometricView;
|
||||
Vec2f m_CamPos{};
|
||||
bool m_IsometricView = true;
|
||||
float m_IsometricShade = m_IsometricView;
|
||||
Vec2f m_CamPos{};
|
||||
public:
|
||||
Renderer();
|
||||
~Renderer();
|
||||
Renderer();
|
||||
~Renderer();
|
||||
|
||||
bool Init();
|
||||
bool Init();
|
||||
|
||||
void Prepare();
|
||||
void Resize(const int width, const int height);
|
||||
void Prepare();
|
||||
void Resize(const int width, const int height);
|
||||
|
||||
void RenderVAO(const GL::VertexArray& vao);
|
||||
void RenderModel(const Model& model);
|
||||
void RenderVAO(const GL::VertexArray& vao);
|
||||
void RenderModel(const Model& model);
|
||||
|
||||
void SetZoom(float zoom);
|
||||
void SetCamMovement(const Vec2f& mov);
|
||||
void SetCamPos(const Vec2f& newPos);
|
||||
void SetIsometricView(bool isometric); // false = 2D true = Isometric
|
||||
void SetZoom(float zoom);
|
||||
void SetCamMovement(const Vec2f& mov);
|
||||
void SetCamPos(const Vec2f& newPos);
|
||||
void SetIsometricView(bool isometric); // false = 2D true = Isometric
|
||||
|
||||
void SetBackgroundColor(const Vec3f& color) { m_BackgroundColor = color; }
|
||||
void SetBackgroundColor(const Vec3f& color) { m_BackgroundColor = color; }
|
||||
|
||||
Vec2f GetCursorWorldPos(const Vec2f& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight);
|
||||
Vec2f GetCursorWorldPos(const Vec2f& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight);
|
||||
private:
|
||||
void UpdateIsometricView();
|
||||
void UpdateIsometricFade();
|
||||
void InitShaders();
|
||||
void UpdateIsometricView();
|
||||
void UpdateIsometricFade();
|
||||
void InitShaders();
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -11,27 +11,27 @@ namespace render {
|
||||
|
||||
class VertexCache {
|
||||
|
||||
typedef std::vector<float> Vector;
|
||||
typedef std::vector<float> Vector;
|
||||
|
||||
struct DataIndex {
|
||||
Vector position;
|
||||
Vector color;
|
||||
};
|
||||
struct DataIndex {
|
||||
Vector position;
|
||||
Vector color;
|
||||
};
|
||||
|
||||
private:
|
||||
std::size_t m_VertexCount;
|
||||
std::unordered_map<std::uint64_t, DataIndex> m_Indexes;
|
||||
std::unique_ptr<GL::VertexArray> m_VertexArray;
|
||||
std::size_t m_VertexCount;
|
||||
std::unordered_map<std::uint64_t, DataIndex> m_Indexes;
|
||||
std::unique_ptr<GL::VertexArray> m_VertexArray;
|
||||
public:
|
||||
VertexCache() : m_VertexCount(0) {}
|
||||
VertexCache() : m_VertexCount(0) {}
|
||||
|
||||
void AddData(std::uint64_t index, std::vector<float> positions, std::vector<float> colors);
|
||||
void RemoveData(std::uint64_t index);
|
||||
void Clear();
|
||||
void UpdateVertexArray();
|
||||
void AddData(std::uint64_t index, std::vector<float> positions, std::vector<float> colors);
|
||||
void RemoveData(std::uint64_t index);
|
||||
void Clear();
|
||||
void UpdateVertexArray();
|
||||
|
||||
const GL::VertexArray& GetVertexArray() const { return *m_VertexArray; }
|
||||
bool IsEmpty() const { return m_VertexArray == nullptr; }
|
||||
const GL::VertexArray& GetVertexArray() const { return *m_VertexArray; }
|
||||
bool IsEmpty() const { return m_VertexArray == nullptr; }
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -24,61 +24,61 @@ namespace render {
|
||||
|
||||
class WorldRenderer : public game::WorldListener {
|
||||
private:
|
||||
client::ClientGame* m_Client;
|
||||
Renderer* m_Renderer;
|
||||
game::World* m_World;
|
||||
std::unique_ptr<GL::VertexArray> m_WorldVao, m_MobVao, m_SelectTileVao;
|
||||
Vec2f m_CamPos;
|
||||
Vec2f m_CursorPos;
|
||||
Vec2f m_HoldCursorPos;
|
||||
Vec2f m_LastClicked;
|
||||
float m_Zoom;
|
||||
float m_CamSensibility = 1;
|
||||
bool m_PopupOpened = false;
|
||||
VertexCache m_TowersCache;
|
||||
client::ClientGame* m_Client;
|
||||
Renderer* m_Renderer;
|
||||
game::World* m_World;
|
||||
std::unique_ptr<GL::VertexArray> m_WorldVao, m_MobVao, m_SelectTileVao;
|
||||
Vec2f m_CamPos;
|
||||
Vec2f m_CursorPos;
|
||||
Vec2f m_HoldCursorPos;
|
||||
Vec2f m_LastClicked;
|
||||
float m_Zoom;
|
||||
float m_CamSensibility = 1;
|
||||
bool m_PopupOpened = false;
|
||||
VertexCache m_TowersCache;
|
||||
|
||||
std::unique_ptr<gui::TowerPlacePopup> m_TowerPlacePopup;
|
||||
std::unique_ptr<gui::MobTooltip> m_MobTooltip;
|
||||
std::unique_ptr<gui::CastleTooltip> m_CastleTooltip;
|
||||
std::unique_ptr<gui::TowerPlacePopup> m_TowerPlacePopup;
|
||||
std::unique_ptr<gui::MobTooltip> m_MobTooltip;
|
||||
std::unique_ptr<gui::CastleTooltip> m_CastleTooltip;
|
||||
public:
|
||||
WorldRenderer(game::World* world, client::ClientGame* client);
|
||||
~WorldRenderer();
|
||||
WorldRenderer(game::World* world, client::ClientGame* client);
|
||||
~WorldRenderer();
|
||||
|
||||
void LoadModels();
|
||||
void LoadModels();
|
||||
|
||||
static ImVec4 GetImGuiTeamColor(game::TeamColor color);
|
||||
static ImVec4 GetImGuiTeamColor(game::TeamColor color);
|
||||
|
||||
void Update();
|
||||
void Render();
|
||||
void Update();
|
||||
void Render();
|
||||
|
||||
void SetCamPos(float camX, float camY);
|
||||
void SetCamPos(float camX, float camY);
|
||||
|
||||
void MoveCam(float relativeX, float relativeY, float aspectRatio);
|
||||
void ChangeZoom(float zoom);
|
||||
void MoveCam(float relativeX, float relativeY, float aspectRatio);
|
||||
void ChangeZoom(float zoom);
|
||||
|
||||
// WorldListener
|
||||
// WorldListener
|
||||
|
||||
virtual void OnTowerAdd(game::TowerPtr tower);
|
||||
virtual void OnTowerRemove(game::TowerPtr tower);
|
||||
virtual void OnTowerAdd(game::TowerPtr tower);
|
||||
virtual void OnTowerRemove(game::TowerPtr tower);
|
||||
private:
|
||||
void Click();
|
||||
void RenderWorld() const;
|
||||
void RenderTowers() const;
|
||||
void RenderMobs() const;
|
||||
void RenderTileSelect() const;
|
||||
void RenderPopups();
|
||||
void RenderTowerUpgradePopup();
|
||||
void RenderMobTooltip() const;
|
||||
void RenderCastleTooltip() const;
|
||||
void DetectClick();
|
||||
void DetectMobHovering() const;
|
||||
void DetectCastleHovering() const;
|
||||
void RenderTooltips() const;
|
||||
void RemoveTower();
|
||||
Vec2f GetCursorWorldPos() const;
|
||||
Vec2f GetClickWorldPos() const;
|
||||
void Click();
|
||||
void RenderWorld() const;
|
||||
void RenderTowers() const;
|
||||
void RenderMobs() const;
|
||||
void RenderTileSelect() const;
|
||||
void RenderPopups();
|
||||
void RenderTowerUpgradePopup();
|
||||
void RenderMobTooltip() const;
|
||||
void RenderCastleTooltip() const;
|
||||
void DetectClick();
|
||||
void DetectMobHovering() const;
|
||||
void DetectCastleHovering() const;
|
||||
void RenderTooltips() const;
|
||||
void RemoveTower();
|
||||
Vec2f GetCursorWorldPos() const;
|
||||
Vec2f GetClickWorldPos() const;
|
||||
|
||||
void UpdateCursorPos();
|
||||
void UpdateCursorPos();
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -14,14 +14,14 @@ namespace gui {
|
||||
|
||||
class CastleTooltip : public GuiWidget {
|
||||
private:
|
||||
const game::TeamCastle* m_Castle;
|
||||
const game::TeamCastle* m_Castle;
|
||||
public:
|
||||
CastleTooltip(client::Client* client);
|
||||
CastleTooltip(client::Client* client);
|
||||
|
||||
virtual void Render();
|
||||
virtual void Render();
|
||||
|
||||
void SetCastle(const game::TeamCastle* castle) { m_Castle = castle; }
|
||||
bool IsShown() { return m_Castle != nullptr; }
|
||||
void SetCastle(const game::TeamCastle* castle) { m_Castle = castle; }
|
||||
bool IsShown() { return m_Castle != nullptr; }
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -7,13 +7,13 @@ namespace gui {
|
||||
|
||||
class FrameMenu : public GuiWidget {
|
||||
private:
|
||||
bool m_VSync;
|
||||
bool m_IsometricView;
|
||||
bool m_ShowDemoWindow;
|
||||
bool m_VSync;
|
||||
bool m_IsometricView;
|
||||
bool m_ShowDemoWindow;
|
||||
public:
|
||||
FrameMenu(client::Client* client);
|
||||
FrameMenu(client::Client* client);
|
||||
|
||||
virtual void Render();
|
||||
virtual void Render();
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -7,17 +7,17 @@ namespace gui {
|
||||
|
||||
class GameMenu : public GuiWidget {
|
||||
private:
|
||||
std::unique_ptr<SummonMenu> m_SummonMenu;
|
||||
std::unique_ptr<SummonMenu> m_SummonMenu;
|
||||
public:
|
||||
GameMenu(client::Client* client);
|
||||
GameMenu(client::Client* client);
|
||||
|
||||
virtual void Render();
|
||||
virtual void Render();
|
||||
private:
|
||||
void ShowTPS();
|
||||
void ShowStats();
|
||||
void ShowPlayers();
|
||||
void ShowLobbyProgress();
|
||||
void ShowTeamSelection();
|
||||
void ShowTPS();
|
||||
void ShowStats();
|
||||
void ShowPlayers();
|
||||
void ShowLobbyProgress();
|
||||
void ShowTeamSelection();
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -10,19 +10,19 @@ namespace gui {
|
||||
|
||||
class GuiManager {
|
||||
private:
|
||||
std::vector<std::unique_ptr<GuiWidget>> m_Widgets;
|
||||
std::vector<std::unique_ptr<GuiWidget>> m_Widgets;
|
||||
public:
|
||||
GuiManager() {}
|
||||
GuiManager() {}
|
||||
|
||||
void RenderWidgets() {
|
||||
for (auto& widget : m_Widgets) {
|
||||
widget->Render();
|
||||
}
|
||||
}
|
||||
void RenderWidgets() {
|
||||
for (auto& widget : m_Widgets) {
|
||||
widget->Render();
|
||||
}
|
||||
}
|
||||
|
||||
void AddWidget(std::unique_ptr<GuiWidget>&& widget) {
|
||||
m_Widgets.push_back(std::move(widget));
|
||||
}
|
||||
void AddWidget(std::unique_ptr<GuiWidget>&& widget) {
|
||||
m_Widgets.push_back(std::move(widget));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -10,13 +10,13 @@ namespace gui {
|
||||
|
||||
class GuiWidget {
|
||||
protected:
|
||||
client::Client* m_Client;
|
||||
client::Client* m_Client;
|
||||
public:
|
||||
GuiWidget(client::Client* client) : m_Client(client) {}
|
||||
GuiWidget(client::Client* client) : m_Client(client) {}
|
||||
|
||||
client::Client* GetClient() { return m_Client; }
|
||||
client::Client* GetClient() { return m_Client; }
|
||||
|
||||
virtual void Render() = 0;
|
||||
virtual void Render() = 0;
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -13,24 +13,24 @@ namespace gui {
|
||||
|
||||
class MainMenu : public GuiWidget {
|
||||
private:
|
||||
bool m_TriedToConnect = false;
|
||||
bool m_TriedToCreate = false;
|
||||
std::string m_ConnectAddress;
|
||||
int m_ConnectPort;
|
||||
int m_ServerPort = 25565;
|
||||
std::string m_WorldFilePath;
|
||||
imgui_addons::ImGuiFileBrowser m_FileDialog;
|
||||
bool m_TriedToConnect = false;
|
||||
bool m_TriedToCreate = false;
|
||||
std::string m_ConnectAddress;
|
||||
int m_ConnectPort;
|
||||
int m_ServerPort = 25565;
|
||||
std::string m_WorldFilePath;
|
||||
imgui_addons::ImGuiFileBrowser m_FileDialog;
|
||||
|
||||
std::unique_ptr<server::Server> m_Server;
|
||||
std::unique_ptr<server::Server> m_Server;
|
||||
public:
|
||||
MainMenu(client::Client* client);
|
||||
~MainMenu();
|
||||
MainMenu(client::Client* client);
|
||||
~MainMenu();
|
||||
|
||||
virtual void Render();
|
||||
virtual void Render();
|
||||
|
||||
const server::Server* GetServer() const { return m_Server.get(); }
|
||||
const server::Server* GetServer() const { return m_Server.get(); }
|
||||
private:
|
||||
bool StartServer();
|
||||
bool StartServer();
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -14,14 +14,14 @@ namespace gui {
|
||||
|
||||
class MobTooltip : public GuiWidget {
|
||||
private:
|
||||
const game::Mob* m_Mob;
|
||||
const game::Mob* m_Mob;
|
||||
public:
|
||||
MobTooltip(client::Client* client);
|
||||
MobTooltip(client::Client* client);
|
||||
|
||||
virtual void Render();
|
||||
virtual void Render();
|
||||
|
||||
void SetMob(const game::Mob* mob) { m_Mob = mob; }
|
||||
bool IsShown() { return m_Mob != nullptr; }
|
||||
void SetMob(const game::Mob* mob) { m_Mob = mob; }
|
||||
bool IsShown() { return m_Mob != nullptr; }
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -10,16 +10,16 @@ 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;
|
||||
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);
|
||||
SummonMenu(client::Client* client);
|
||||
|
||||
virtual void Render();
|
||||
virtual void Render();
|
||||
private:
|
||||
void SetSummonMax(int valueIndex);
|
||||
void SetSummonMax(int valueIndex);
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -28,21 +28,21 @@ class Renderer;
|
||||
|
||||
class TowerGui {
|
||||
private:
|
||||
SDL_Window* m_Window;
|
||||
SDL_GLContext m_GlContext;
|
||||
td::render::Renderer* m_Renderer;
|
||||
td::gui::GuiManager m_GuiManager;
|
||||
std::unique_ptr<td::client::Client> m_Client;
|
||||
SDL_Window* m_Window;
|
||||
SDL_GLContext m_GlContext;
|
||||
td::render::Renderer* m_Renderer;
|
||||
td::gui::GuiManager m_GuiManager;
|
||||
std::unique_ptr<td::client::Client> m_Client;
|
||||
public:
|
||||
TowerGui(SDL_Window* wndow, SDL_GLContext glContext, td::render::Renderer* renderer);
|
||||
~TowerGui();
|
||||
TowerGui(SDL_Window* wndow, SDL_GLContext glContext, td::render::Renderer* renderer);
|
||||
~TowerGui();
|
||||
|
||||
void Render();
|
||||
void Render();
|
||||
private:
|
||||
void InitWidgets();
|
||||
void Tick();
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
void InitWidgets();
|
||||
void Tick();
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -9,19 +9,19 @@ namespace gui {
|
||||
|
||||
class TowerPlacePopup : public GuiWidget {
|
||||
private:
|
||||
Vec2f m_ClickWorldPos;
|
||||
Vec2f m_ClickWorldPos;
|
||||
public:
|
||||
TowerPlacePopup(client::Client* client);
|
||||
TowerPlacePopup(client::Client* client);
|
||||
|
||||
virtual void Render();
|
||||
virtual void Render();
|
||||
|
||||
void SetClickPos(const Vec2f& worldPos);
|
||||
void SetClickPos(const Vec2f& worldPos);
|
||||
private:
|
||||
static constexpr float m_TowerPopupTileWidth = 200.0f;
|
||||
static constexpr float m_TowerPopupTileHeight = 200.0f;
|
||||
static constexpr float m_TowerPopupTileWidth = 200.0f;
|
||||
static constexpr float m_TowerPopupTileHeight = 200.0f;
|
||||
|
||||
static constexpr float m_PlaceTowerButtonWidth = 150.0f;
|
||||
static constexpr float m_PlaceTowerButtonHeight = 35.0f;
|
||||
static constexpr float m_PlaceTowerButtonWidth = 150.0f;
|
||||
static constexpr float m_PlaceTowerButtonHeight = 35.0f;
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -17,19 +17,19 @@ namespace gui {
|
||||
|
||||
class UpdateMenu : public GuiWidget {
|
||||
private:
|
||||
bool m_Opened;
|
||||
std::string m_Error;
|
||||
std::unique_ptr<utils::Updater> m_Updater;
|
||||
std::shared_future<bool> m_UpdateAvailable;
|
||||
bool m_Opened;
|
||||
std::string m_Error;
|
||||
std::unique_ptr<utils::Updater> m_Updater;
|
||||
std::shared_future<bool> m_UpdateAvailable;
|
||||
public:
|
||||
UpdateMenu(client::Client* client);
|
||||
virtual ~UpdateMenu();
|
||||
UpdateMenu(client::Client* client);
|
||||
virtual ~UpdateMenu();
|
||||
|
||||
virtual void Render();
|
||||
virtual void Render();
|
||||
private:
|
||||
void CheckUpdates();
|
||||
bool IsUpdateChecked();
|
||||
void RenderErrorPopup();
|
||||
void CheckUpdates();
|
||||
bool IsUpdateChecked();
|
||||
void RenderErrorPopup();
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace render {
|
||||
namespace WorldLoader {
|
||||
|
||||
struct RenderData {
|
||||
std::vector<float> positions;
|
||||
std::vector<float> colors;
|
||||
std::vector<float> positions;
|
||||
std::vector<float> colors;
|
||||
};
|
||||
|
||||
GL::VertexArray LoadMobModel();
|
||||
|
||||
Reference in New Issue
Block a user