feat: upgraded tower place popop
This commit is contained in:
@@ -16,6 +16,12 @@ public:
|
|||||||
virtual void render();
|
virtual void render();
|
||||||
|
|
||||||
void setClickPos(const glm::vec2& worldPos);
|
void setClickPos(const glm::vec2& worldPos);
|
||||||
|
private:
|
||||||
|
static constexpr float m_TowerPopupTileWidth = 250.0f;
|
||||||
|
static constexpr float m_TowerPopupTileHeight = 250.0f;
|
||||||
|
|
||||||
|
static constexpr float m_PlaceTowerButtonWidth = 200.0f;
|
||||||
|
static constexpr float m_PlaceTowerButtonHeight = 45.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gui
|
} // namespace gui
|
||||||
|
|||||||
@@ -13,28 +13,48 @@ TowerPlacePopup::TowerPlacePopup(client::Client* client) : GuiWidget(client) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TowerPlacePopup::render(){
|
void TowerPlacePopup::render() {
|
||||||
if (ImGui::BeginPopup("TowerPlace")) {
|
if (ImGui::BeginPopup("TowerPlace")) {
|
||||||
ImGui::BeginChild("SubWindow", ImVec2(800, 270), false, ImGuiWindowFlags_HorizontalScrollbar);
|
ImGui::BeginChild("SubWindow", ImVec2(800, m_TowerPopupTileHeight + 20), false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
for (int i = 0; i < (int)game::TowerType::TowerCount; i++) {
|
for (int i = 0; i < (int)game::TowerType::TowerCount; i++) {
|
||||||
if(i > 0) ImGui::SameLine();
|
if (i > 0) ImGui::SameLine();
|
||||||
|
|
||||||
ImGui::BeginChild(std::to_string(i).c_str(), ImVec2(250, 250), true);
|
game::TowerType towerType = game::TowerType(i);
|
||||||
|
const game::TowerInfo& towerInfo = game::getTowerInfo(towerType);
|
||||||
|
|
||||||
ImGui::Text(game::getTowerInfo(game::TowerType(i)).getName().c_str());
|
if (!towerInfo.isBigTower() || (towerInfo.isBigTower() &&
|
||||||
|
getClient()->getGame().getWorld().CanPlaceBigTower(m_ClickWorldPos, getClient()->getGame().getPlayer()->getID()))) {
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::BeginChild(std::to_string(i).c_str(), ImVec2(m_TowerPopupTileWidth, m_TowerPopupTileHeight), true);
|
||||||
ImGui::SetCursorPosX(250 - 10 - ImGui::CalcTextSize("(?)").x);
|
|
||||||
ImGui::TextDisabled("(?)");
|
|
||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::Text(towerInfo.getName().c_str());
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SetCursorPosX(m_TowerPopupTileWidth - 10 - ImGui::CalcTextSize("(?)").x);
|
||||||
|
ImGui::TextDisabled("(?)");
|
||||||
|
|
||||||
|
if (ImGui::IsItemHovered()) {
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
ImGui::Text("%s", towerInfo.getDescription().c_str());
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string buyText = std::to_string(100) + " golds";
|
||||||
|
|
||||||
|
ImGui::SetCursorPosY(m_TowerPopupTileHeight - m_PlaceTowerButtonHeight - 10);
|
||||||
|
ImGui::SetCursorPosX(m_TowerPopupTileWidth / 2.0f - m_PlaceTowerButtonWidth / 2.0f);
|
||||||
|
|
||||||
|
ImGui::Button(buyText.c_str(), ImVec2(m_PlaceTowerButtonWidth, m_PlaceTowerButtonHeight));
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TowerPlacePopup::setClickPos(const glm::vec2& worldPos){
|
void TowerPlacePopup::setClickPos(const glm::vec2& worldPos) {
|
||||||
m_ClickWorldPos = worldPos;
|
m_ClickWorldPos = worldPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user