refactor: format project

This commit is contained in:
2021-11-21 17:02:42 +01:00
parent 0f328e6f81
commit f48af51dc7
36 changed files with 162 additions and 162 deletions

View File

@@ -8,7 +8,7 @@
namespace td {
namespace gui {
FrameMenu::FrameMenu(client::Client* client) : GuiWidget(client), m_VSync(true), m_IsometricView(true), m_ShowDemoWindow(false){
FrameMenu::FrameMenu(client::Client* client) : GuiWidget(client), m_VSync(true), m_IsometricView(true), m_ShowDemoWindow(false) {
}
@@ -24,7 +24,7 @@ void FrameMenu::render() {
ImGui::Checkbox("Demo Window", &m_ShowDemoWindow);
ImGui::End();
if(m_ShowDemoWindow)
if (m_ShowDemoWindow)
ImGui::ShowDemoWindow(&m_ShowDemoWindow);
}

View File

@@ -13,7 +13,7 @@ GameMenu::GameMenu(client::Client* client) : GuiWidget(client), m_SummonMenu(std
}
void GameMenu::render(){
void GameMenu::render() {
if (getClient()->getGame().getGameState() == td::game::GameState::Lobby) {
ImGui::Begin("Lobby");

View File

@@ -12,8 +12,8 @@ MainMenu::MainMenu(client::Client* client) : GuiWidget(client), m_ConnectPort(25
m_ConnectAddress.reserve(256);
}
MainMenu::~MainMenu(){
if(m_Server != nullptr)
MainMenu::~MainMenu() {
if (m_Server != nullptr)
m_Server->stop();
}
@@ -28,7 +28,7 @@ void MainMenu::render() {
if (ImGui::Button("Options")) {
// TODO: add settings
}
if (ImGui::BeginPopup("Rejoindre une partie##join_popup")) {
ImGui::InputText("Server Adress", &m_ConnectAddress.front(), m_ConnectAddress.capacity());
ImGui::InputInt("Port", &m_ConnectPort, -1);
@@ -71,7 +71,7 @@ void MainMenu::render() {
ImGui::End();
}
bool MainMenu::startServer(){
bool MainMenu::startServer() {
if (m_WorldFilePath.empty())
return false;
m_Server = std::make_unique<td::server::Server>(m_WorldFilePath);

View File

@@ -19,22 +19,22 @@ void MobTooltip::render() {
const game::Player& sender = getClient()->getGame().getPlayerById(m_Mob->getSender());
ImGui::BeginTooltip();
ImGui::Text("Sender :");
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, render::WorldRenderer::getImGuiTeamColor(sender.getTeamColor()));
ImGui::Text("%s", sender.getName().c_str());
ImGui::PopStyleColor();
ImGui::Text("Mob HP : %.1f/%i", m_Mob->getHealth(), m_Mob->getStats()->getMaxLife());
ImGui::Text("Mob Type : %s", game::MobFactory::getMobName(m_Mob->getType()).c_str());
ImGui::Text("Mob Level : %i", m_Mob->getLevel());
ImGui::NewLine();
ImGui::Text("Mob Stats :");
ImGui::Text("\tMax health : %i", m_Mob->getStats()->getMaxLife());
ImGui::Text("\tSpeed : %.1f", m_Mob->getStats()->getMovementSpeed());
ImGui::Text("\tDamage : %.1f", m_Mob->getStats()->getDamage());
ImGui::Text("\tMoney cost : %i", m_Mob->getStats()->getMoneyCost());
ImGui::Text("\tEXP cost : %i", m_Mob->getStats()->getExpCost());
ImGui::Text("\tEXP reward : %i", m_Mob->getStats()->getExpReward());
ImGui::Text("Sender :");
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, render::WorldRenderer::getImGuiTeamColor(sender.getTeamColor()));
ImGui::Text("%s", sender.getName().c_str());
ImGui::PopStyleColor();
ImGui::Text("Mob HP : %.1f/%i", m_Mob->getHealth(), m_Mob->getStats()->getMaxLife());
ImGui::Text("Mob Type : %s", game::MobFactory::getMobName(m_Mob->getType()).c_str());
ImGui::Text("Mob Level : %i", m_Mob->getLevel());
ImGui::NewLine();
ImGui::Text("Mob Stats :");
ImGui::Text("\tMax health : %i", m_Mob->getStats()->getMaxLife());
ImGui::Text("\tSpeed : %.1f", m_Mob->getStats()->getMovementSpeed());
ImGui::Text("\tDamage : %.1f", m_Mob->getStats()->getDamage());
ImGui::Text("\tMoney cost : %i", m_Mob->getStats()->getMoneyCost());
ImGui::Text("\tEXP cost : %i", m_Mob->getStats()->getExpCost());
ImGui::Text("\tEXP reward : %i", m_Mob->getStats()->getExpReward());
ImGui::EndTooltip();
}

View File

@@ -5,11 +5,11 @@
namespace td {
namespace gui {
SummonMenu::SummonMenu(client::Client* client) : GuiWidget(client), m_MenuOpened(true){
SummonMenu::SummonMenu(client::Client* client) : GuiWidget(client), m_MenuOpened(true) {
m_Values.fill(0);
}
void SummonMenu::render(){
void SummonMenu::render() {
if (m_MenuOpened) {
ImGui::Begin("Summon", &m_MenuOpened);
ImTextureID my_tex_id = ImGui::GetIO().Fonts->TexID;
@@ -51,8 +51,8 @@ void SummonMenu::render(){
if (ImGui::Button("Send")) {
std::vector<protocol::MobSend> mobSent;
protocol::MobSend mobSend;
for(int i = 0; i < m_MobTypeCount; i++){
if(m_Values[i] != 0){
for (int i = 0; i < m_MobTypeCount; i++) {
if (m_Values[i] != 0) {
mobSend.mobCount = m_Values[i];
mobSend.mobLevel = 1; // TODO: add mob levels
mobSend.mobType = td::game::MobType(i);
@@ -66,7 +66,7 @@ void SummonMenu::render(){
}
}
void SummonMenu::setSummonMax(int valueIndex){
void SummonMenu::setSummonMax(int valueIndex) {
int& value = m_Values[valueIndex];
value = std::max(0, value);
value = std::min(12, value);

View File

@@ -28,8 +28,8 @@ void TowerGui::initWidgets() {
m_UpdateMenu = std::make_unique<td::gui::UpdateMenu>(m_Client.get());
}
TowerGui::TowerGui(SDL_Window* sdl_window, SDL_GLContext glContext, td::render::Renderer* renderer) : m_Window(sdl_window),
m_GlContext(glContext), m_Renderer(renderer), m_Client(std::make_unique<client::Client>(m_Renderer)) {
TowerGui::TowerGui(SDL_Window* sdl_window, SDL_GLContext glContext, td::render::Renderer* renderer) : m_Window(sdl_window),
m_GlContext(glContext), m_Renderer(renderer), m_Client(std::make_unique<client::Client>(m_Renderer)) {
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui::StyleColorsDark();

View File

@@ -44,7 +44,7 @@ void TowerPlacePopup::render() {
ImGui::SetCursorPosY(m_TowerPopupTileHeight - m_PlaceTowerButtonHeight - 10);
ImGui::SetCursorPosX(m_TowerPopupTileWidth / 2.0f - m_PlaceTowerButtonWidth / 2.0f);
if(ImGui::Button(buyText.c_str(), ImVec2(m_PlaceTowerButtonWidth, m_PlaceTowerButtonHeight))){
if (ImGui::Button(buyText.c_str(), ImVec2(m_PlaceTowerButtonWidth, m_PlaceTowerButtonHeight))) {
getClient()->placeTower(towerType, m_ClickWorldPos);
ImGui::CloseCurrentPopup();
}

View File

@@ -20,18 +20,18 @@ void UpdateMenu::render() {
bool updateAvailable = m_UpdateAvailable.get();
if (updateAvailable) {
if(m_Updater.isFileWrited()){
if (m_Updater.isFileWrited()) {
ImGui::Text("The update is now installed");
ImGui::Text("The game needs to be restarted");
}else if (m_Updater.isDownloadComplete()) {
} else if (m_Updater.isDownloadComplete()) {
ImGui::Text("Download done!");
if(ImGui::Button("Install")){
if(!m_Updater.writeFile()){
if (ImGui::Button("Install")) {
if (!m_Updater.writeFile()) {
m_Error = "Failed to write file !\n";
ImGui::OpenPopup("UpdateError");
}
}
if(ImGui::Button("Cancel")){
if (ImGui::Button("Cancel")) {
m_Updater.cancelDownload();
m_Updater.clearCache();
}
@@ -50,13 +50,13 @@ void UpdateMenu::render() {
bool canDownloadFile = m_Updater.canUpdate();
if(!canDownloadFile) ImGui::BeginDisabled();
if (!canDownloadFile) ImGui::BeginDisabled();
if (ImGui::Button("Download")) {
m_Updater.downloadUpdate();
}
if(!canDownloadFile) ImGui::EndDisabled();
if (!canDownloadFile) ImGui::EndDisabled();
ImGui::SameLine();
if (ImGui::Button("Cancel")) {
@@ -77,8 +77,8 @@ void UpdateMenu::render() {
}
}
void UpdateMenu::renderErrorPopup(){
if(ImGui::BeginPopup("UpdateError")){
void UpdateMenu::renderErrorPopup() {
if (ImGui::BeginPopup("UpdateError")) {
ImGui::Text("Error : %s", m_Error.c_str());
ImGui::EndPopup();
}