simplified health bar display
This commit is contained in:
9
include/render/gui/LifeProgress.h
Normal file
9
include/render/gui/LifeProgress.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
namespace gui {
|
||||||
|
|
||||||
|
extern void RenderLifeProgress(float progress);
|
||||||
|
|
||||||
|
} // namespace gui
|
||||||
|
} // namespace td
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "render/gui/CastleTooltip.h"
|
#include "render/gui/CastleTooltip.h"
|
||||||
#include "render/gui/imgui/imgui.h"
|
#include "render/gui/imgui/imgui.h"
|
||||||
|
#include "render/gui/LifeProgress.h"
|
||||||
|
|
||||||
#include "render/WorldRenderer.h"
|
#include "render/WorldRenderer.h"
|
||||||
|
|
||||||
@@ -15,12 +16,18 @@ CastleTooltip::CastleTooltip(client::Client* client) : GuiWidget(client) {
|
|||||||
void CastleTooltip::Render() {
|
void CastleTooltip::Render() {
|
||||||
if (m_Castle == nullptr) return;
|
if (m_Castle == nullptr) return;
|
||||||
|
|
||||||
ImGui::BeginTooltip();
|
if (ImGui::GetIO().KeyShift) {
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, render::WorldRenderer::GetImGuiTeamColor(m_Castle->GetTeam()->GetColor()));
|
ImGui::BeginTooltip();
|
||||||
ImGui::Text("Castle : ");
|
ImGui::PushStyleColor(ImGuiCol_Text, render::WorldRenderer::GetImGuiTeamColor(m_Castle->GetTeam()->GetColor()));
|
||||||
ImGui::PopStyleColor();
|
ImGui::Text("Castle : ");
|
||||||
ImGui::Text("\tCastle HP : %i/%i", static_cast<int>(m_Castle->GetLife()), game::TeamCastle::CastleMaxLife);
|
ImGui::PopStyleColor();
|
||||||
ImGui::EndTooltip();
|
ImGui::Text("\tCastle HP : %i/%i", static_cast<int>(m_Castle->GetLife()), game::TeamCastle::CastleMaxLife);
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
} else {
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
RenderLifeProgress(m_Castle->GetLife() / static_cast<float>(game::TeamCastle::CastleMaxLife));
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gui
|
} // namespace gui
|
||||||
|
|||||||
15
src/render/gui/LifeProgress.cpp
Normal file
15
src/render/gui/LifeProgress.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "render/gui/LifeProgress.h"
|
||||||
|
|
||||||
|
#include "render/gui/imgui/imgui.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
namespace gui {
|
||||||
|
|
||||||
|
void RenderLifeProgress(float progress) {
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, { 1 - progress, progress, 0, 1 });
|
||||||
|
ImGui::ProgressBar(progress, { 100, 25 }, "");
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace gui
|
||||||
|
} // namespace td
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "render/gui/MobTooltip.h"
|
#include "render/gui/MobTooltip.h"
|
||||||
#include "render/gui/imgui/imgui.h"
|
#include "render/gui/imgui/imgui.h"
|
||||||
|
#include "render/gui/LifeProgress.h"
|
||||||
|
|
||||||
#include "render/WorldRenderer.h"
|
#include "render/WorldRenderer.h"
|
||||||
|
|
||||||
@@ -19,25 +20,31 @@ void MobTooltip::Render() {
|
|||||||
|
|
||||||
// TODO: add sender null check
|
// TODO: add sender null check
|
||||||
|
|
||||||
const game::Player* sender = GetClient()->GetGame().GetPlayerById(m_Mob->GetSender());
|
if (ImGui::GetIO().KeyShift) {
|
||||||
ImGui::BeginTooltip();
|
const game::Player* sender = GetClient()->GetGame().GetPlayerById(m_Mob->GetSender());
|
||||||
ImGui::Text("Sender :");
|
ImGui::BeginTooltip();
|
||||||
ImGui::SameLine();
|
ImGui::Text("Sender :");
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, render::WorldRenderer::GetImGuiTeamColor(sender->GetTeamColor()));
|
ImGui::SameLine();
|
||||||
ImGui::Text("%s", sender->GetName().c_str());
|
ImGui::PushStyleColor(ImGuiCol_Text, render::WorldRenderer::GetImGuiTeamColor(sender->GetTeamColor()));
|
||||||
ImGui::PopStyleColor();
|
ImGui::Text("%s", sender->GetName().c_str());
|
||||||
ImGui::Text("Mob HP : %.1f/%i", m_Mob->GetHealth(), m_Mob->GetStats()->GetMaxLife());
|
ImGui::PopStyleColor();
|
||||||
ImGui::Text("Mob Type : %s", game::MobFactory::GetMobName(m_Mob->GetType()).c_str());
|
ImGui::Text("Mob HP : %.1f/%i", m_Mob->GetHealth(), m_Mob->GetStats()->GetMaxLife());
|
||||||
ImGui::Text("Mob Level : %i", m_Mob->GetLevel());
|
ImGui::Text("Mob Type : %s", game::MobFactory::GetMobName(m_Mob->GetType()).c_str());
|
||||||
ImGui::NewLine();
|
ImGui::Text("Mob Level : %i", m_Mob->GetLevel());
|
||||||
ImGui::Text("Mob Stats :");
|
ImGui::NewLine();
|
||||||
ImGui::Text("\tMax health : %i", m_Mob->GetStats()->GetMaxLife());
|
ImGui::Text("Mob Stats :");
|
||||||
ImGui::Text("\tSpeed : %.1f", m_Mob->GetStats()->GetMovementSpeed());
|
ImGui::Text("\tMax health : %i", m_Mob->GetStats()->GetMaxLife());
|
||||||
ImGui::Text("\tDamage : %.1f", m_Mob->GetStats()->GetDamage());
|
ImGui::Text("\tSpeed : %.1f", m_Mob->GetStats()->GetMovementSpeed());
|
||||||
ImGui::Text("\tMoney cost : %i", m_Mob->GetStats()->GetMoneyCost());
|
ImGui::Text("\tDamage : %.1f", m_Mob->GetStats()->GetDamage());
|
||||||
ImGui::Text("\tEXP cost : %i", m_Mob->GetStats()->GetExpCost());
|
ImGui::Text("\tMoney cost : %i", m_Mob->GetStats()->GetMoneyCost());
|
||||||
ImGui::Text("\tEXP reward : %i", m_Mob->GetStats()->GetExpReward());
|
ImGui::Text("\tEXP cost : %i", m_Mob->GetStats()->GetExpCost());
|
||||||
ImGui::EndTooltip();
|
ImGui::Text("\tEXP reward : %i", m_Mob->GetStats()->GetExpReward());
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
} else {
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
RenderLifeProgress(m_Mob->GetHealth() / m_Mob->GetStats()->GetMaxLife());
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gui
|
} // namespace gui
|
||||||
|
|||||||
Reference in New Issue
Block a user