refactor: format project
This commit is contained in:
@@ -14,7 +14,7 @@ bool Mob::isImmuneTo(EffectType type) {
|
||||
return std::find(getEffectImmunities().begin(), getEffectImmunities().end(), type) != getEffectImmunities().end();
|
||||
}
|
||||
|
||||
EffectDuration& Mob::getEffect(EffectType effectType){
|
||||
EffectDuration& Mob::getEffect(EffectType effectType) {
|
||||
return *std::find_if(m_Effects.begin(), m_Effects.end(), [&effectType](EffectDuration effect) { return effect.type == effectType;});
|
||||
}
|
||||
|
||||
@@ -39,40 +39,40 @@ void Mob::updateEffects(std::uint64_t delta) {
|
||||
for (std::size_t i = 0; i < m_Effects.size(); i++) {
|
||||
EffectDuration& effect = m_Effects[i];
|
||||
effect.duration -= deltaSec;
|
||||
if (effect.duration < 0){ // effect has gone
|
||||
if (effect.duration < 0) { // effect has gone
|
||||
m_Effects.erase(m_Effects.begin() + i);
|
||||
switch(effect.type){
|
||||
case EffectType::Fire:{
|
||||
m_EffectFireTimer.reset();
|
||||
break;
|
||||
}
|
||||
switch (effect.type) {
|
||||
case EffectType::Fire: {
|
||||
m_EffectFireTimer.reset();
|
||||
break;
|
||||
}
|
||||
|
||||
case EffectType::Poison:{
|
||||
m_EffectPoisonTimer.reset();
|
||||
break;
|
||||
}
|
||||
case EffectType::Poison: {
|
||||
m_EffectPoisonTimer.reset();
|
||||
break;
|
||||
}
|
||||
|
||||
case EffectType::Heal:{
|
||||
m_EffectHealTimer.reset();
|
||||
}
|
||||
case EffectType::Heal: {
|
||||
m_EffectHealTimer.reset();
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hasEffect(EffectType::Fire)){
|
||||
if(m_EffectFireTimer.update(delta)){
|
||||
if (hasEffect(EffectType::Fire)) {
|
||||
if (m_EffectFireTimer.update(delta)) {
|
||||
damage(3, getEffect(EffectType::Fire).tower);
|
||||
}
|
||||
}
|
||||
if(hasEffect(EffectType::Poison)){
|
||||
if(m_EffectPoisonTimer.update(delta)){
|
||||
if (hasEffect(EffectType::Poison)) {
|
||||
if (m_EffectPoisonTimer.update(delta)) {
|
||||
damage(1, getEffect(EffectType::Poison).tower);
|
||||
}
|
||||
}
|
||||
if(hasEffect(EffectType::Heal)){
|
||||
if(m_EffectFireTimer.update(delta)){
|
||||
if (hasEffect(EffectType::Heal)) {
|
||||
if (m_EffectFireTimer.update(delta)) {
|
||||
heal(10);
|
||||
}
|
||||
}
|
||||
@@ -305,30 +305,30 @@ MobPtr MobFactory::createMob(MobID id, MobType type, std::uint8_t level, PlayerI
|
||||
return mobFactory[type](id, level, sender);
|
||||
}
|
||||
|
||||
std::string MobFactory::getMobName(MobType type){
|
||||
switch(type){
|
||||
case MobType::Zombie:
|
||||
return "Zombie";
|
||||
case MobType::Spider:
|
||||
return "Spider";
|
||||
case MobType::Skeleton:
|
||||
return "Skeleton";
|
||||
case MobType::Pigman:
|
||||
return "Pigman";
|
||||
case MobType::Creeper:
|
||||
return "Creeper";
|
||||
case MobType::Silverfish:
|
||||
return "Silverfish";
|
||||
case MobType::Blaze:
|
||||
return "Blaze";
|
||||
case MobType::Witch:
|
||||
return "Witch";
|
||||
case MobType::Slime:
|
||||
return "Slime";
|
||||
case MobType::Giant:
|
||||
return "Giant";
|
||||
default:
|
||||
return "Unknow";
|
||||
std::string MobFactory::getMobName(MobType type) {
|
||||
switch (type) {
|
||||
case MobType::Zombie:
|
||||
return "Zombie";
|
||||
case MobType::Spider:
|
||||
return "Spider";
|
||||
case MobType::Skeleton:
|
||||
return "Skeleton";
|
||||
case MobType::Pigman:
|
||||
return "Pigman";
|
||||
case MobType::Creeper:
|
||||
return "Creeper";
|
||||
case MobType::Silverfish:
|
||||
return "Silverfish";
|
||||
case MobType::Blaze:
|
||||
return "Blaze";
|
||||
case MobType::Witch:
|
||||
return "Witch";
|
||||
case MobType::Slime:
|
||||
return "Slime";
|
||||
case MobType::Giant:
|
||||
return "Giant";
|
||||
default:
|
||||
return "Unknow";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,8 +116,8 @@ const std::map<std::pair<TowerType, TowerLevel>, TowerStats> TowerConstants = {
|
||||
};
|
||||
|
||||
const TowerStats* getTowerStats(TowerType type, TowerLevel level) {
|
||||
auto it = TowerConstants.find({type, level});
|
||||
if(it == TowerConstants.end()) return nullptr;
|
||||
auto it = TowerConstants.find({ type, level });
|
||||
if (it == TowerConstants.end()) return nullptr;
|
||||
return &it->second;
|
||||
}
|
||||
|
||||
@@ -251,30 +251,30 @@ void PoisonTower::tick(std::uint64_t delta, World* world) {
|
||||
if (m_Timer.update(delta)) {
|
||||
for (MobPtr mob : world->getMobList()) {
|
||||
if (isMobInRange(mob)) {
|
||||
if(getLevel().getPath() == TowerPath::Bottom){
|
||||
if (getLevel().getPath() == TowerPath::Bottom) {
|
||||
mob->damage(getStats()->getDamage(), this);
|
||||
}else{
|
||||
} else {
|
||||
float durationSec;
|
||||
switch(getLevel().getLevel()){
|
||||
case 1:
|
||||
durationSec = 5;
|
||||
break;
|
||||
switch (getLevel().getLevel()) {
|
||||
case 1:
|
||||
durationSec = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
durationSec = 15;
|
||||
break;
|
||||
case 2:
|
||||
durationSec = 15;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
durationSec = 30;
|
||||
break;
|
||||
case 3:
|
||||
durationSec = 30;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
durationSec = 1e10; // about 3 million hours. It should be enough
|
||||
break;
|
||||
case 4:
|
||||
durationSec = 1e10; // about 3 million hours. It should be enough
|
||||
break;
|
||||
|
||||
default:
|
||||
durationSec = 0; // how did we get there ?
|
||||
break;
|
||||
default:
|
||||
durationSec = 0; // how did we get there ?
|
||||
break;
|
||||
}
|
||||
mob->addEffect(EffectType::Poison, durationSec, this);
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ TowerPtr World::getTower(const glm::vec2& position) const {
|
||||
|
||||
TowerPtr World::getTowerById(TowerID towerID) {
|
||||
auto it = std::find_if(m_Towers.begin(), m_Towers.end(), [towerID](TowerPtr tower) { return tower->getID() == towerID;});
|
||||
if(it == m_Towers.end()) return nullptr;
|
||||
if (it == m_Towers.end()) return nullptr;
|
||||
return *it;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ void Client::render() {
|
||||
m_Game.renderWorld();
|
||||
}
|
||||
|
||||
void Client::sendMobs(const std::vector<protocol::MobSend>& mobSends){
|
||||
void Client::sendMobs(const std::vector<protocol::MobSend>& mobSends) {
|
||||
protocol::SendMobsPacket packet(mobSends);
|
||||
m_Connexion.sendPacket(&packet);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ void Client::placeTower(game::TowerType type, const glm::vec2& position) {
|
||||
m_Connexion.sendPacket(&packet);
|
||||
}
|
||||
|
||||
void Client::upgradeTower(game::TowerID tower, game::TowerLevel level){
|
||||
void Client::upgradeTower(game::TowerID tower, game::TowerLevel level) {
|
||||
protocol::UpgradeTowerPacket packet(tower, level);
|
||||
m_Connexion.sendPacket(&packet);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ void WorldClient::HandlePacket(const protocol::SpawnMobPacket* packet) {
|
||||
|
||||
void WorldClient::HandlePacket(const protocol::UpgradeTowerPacket* packet) {
|
||||
game::TowerPtr tower = getTowerById(packet->getTowerID());
|
||||
if(tower == nullptr) return; // this should not happen but who knows ?
|
||||
if (tower == nullptr) return; // this should not happen but who knows ?
|
||||
tower->upgrade(packet->getTowerLevel().getLevel(), packet->getTowerLevel().getPath());
|
||||
}
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ void Server::startThread() {
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void Server::stopThread(){
|
||||
void Server::stopThread() {
|
||||
m_ServerRunning = false;
|
||||
if(m_Thread.joinable())
|
||||
if (m_Thread.joinable())
|
||||
m_Thread.join();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ bool Server::start(std::uint16_t port) {
|
||||
}
|
||||
|
||||
void Server::stop() {
|
||||
if(!m_ServerRunning)
|
||||
if (!m_ServerRunning)
|
||||
return;
|
||||
stopThread();
|
||||
|
||||
|
||||
@@ -168,12 +168,12 @@ void ServerConnexion::HandlePacket(const protocol::SendMobsPacket* packet) {
|
||||
|
||||
//TODO: verify the packet
|
||||
|
||||
for(protocol::MobSend mobSend : mobSent){
|
||||
for (protocol::MobSend mobSend : mobSent) {
|
||||
m_Server->getGame().getServerWorld()->spawnMobs(mobSend.mobType, mobSend.mobLevel, m_ID, mobSend.mobCount);
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConnexion::HandlePacket(const protocol::UpgradeTowerPacket* packet){
|
||||
void ServerConnexion::HandlePacket(const protocol::UpgradeTowerPacket* packet) {
|
||||
//TODO: verify the packet
|
||||
|
||||
m_Server->broadcastPacket(packet);
|
||||
|
||||
@@ -9,7 +9,7 @@ ServerGame::ServerGame(server::Server* server) : game::Game(&m_ServerWorld), m_S
|
||||
}
|
||||
|
||||
void ServerGame::tick(std::uint64_t delta) {
|
||||
if(m_GameState == game::GameState::Game){
|
||||
if (m_GameState == game::GameState::Game) {
|
||||
Game::tick(delta);
|
||||
updatePlayerStats();
|
||||
}
|
||||
@@ -27,16 +27,16 @@ void ServerGame::startGame() {
|
||||
m_GameState = game::GameState::Game;
|
||||
}
|
||||
|
||||
void ServerGame::updatePlayerStats(){
|
||||
void ServerGame::updatePlayerStats() {
|
||||
m_GoldMineTimer.update();
|
||||
for (auto& pair : m_Server->getPlayers()) {
|
||||
game::Player& player = pair.second;
|
||||
if(player.hasGoldChanged()){
|
||||
if (player.hasGoldChanged()) {
|
||||
protocol::UpdateMoneyPacket packet(player.getGold());
|
||||
m_Server->getConnexions()[player.getID()].sendPacket(&packet);
|
||||
player.updateGold();
|
||||
}
|
||||
if(player.hasExpChanged()){
|
||||
if (player.hasExpChanged()) {
|
||||
protocol::UpdateExpPacket packet(player.getExp());
|
||||
m_Server->getConnexions()[player.getID()].sendPacket(&packet);
|
||||
player.updateExp();
|
||||
|
||||
@@ -55,7 +55,7 @@ void CooldownTimer::reset() {
|
||||
m_Cooldown = 0; // let the timer active once at the beginning
|
||||
}
|
||||
|
||||
void CooldownTimer::applyCooldown(){
|
||||
void CooldownTimer::applyCooldown() {
|
||||
m_Cooldown = m_CooldownTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ bool Updater::checkUpdate() {
|
||||
m_LastVersion = m_LastVersion.substr(0, m_LastVersion.find('\n'));
|
||||
|
||||
std::cout << "Current version : [" << getCurrentVersion() << "]\n";
|
||||
std::cout << "Last version : [" << m_LastVersion << "]\n";
|
||||
std::cout << "Last version : [" << m_LastVersion << "]\n";
|
||||
|
||||
if (currentVersion != m_LastVersion) {
|
||||
return true;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace td {
|
||||
namespace protocol {
|
||||
namespace PacketFactory {
|
||||
|
||||
using PacketCreator = std::function<PacketPtr ()>;
|
||||
using PacketCreator = std::function<PacketPtr()>;
|
||||
|
||||
static std::map<PacketType, PacketCreator> packets = {
|
||||
{PacketType::PlayerLogin, []() -> PacketPtr {return std::make_unique<PlayerLoginPacket>();} },
|
||||
|
||||
@@ -498,7 +498,7 @@ void WorldRemoveTowerPacket::Deserialize(DataBuffer& data) {
|
||||
DataBuffer SendMobsPacket::Serialize() const {
|
||||
DataBuffer data;
|
||||
data << getID() << static_cast<std::uint8_t>(m_MobSends.size());
|
||||
for(const MobSend& mobSend : m_MobSends){
|
||||
for (const MobSend& mobSend : m_MobSends) {
|
||||
data << mobSend;
|
||||
}
|
||||
return data;
|
||||
@@ -508,7 +508,7 @@ void SendMobsPacket::Deserialize(DataBuffer& data) {
|
||||
std::uint8_t mobSendCount;
|
||||
data >> mobSendCount;
|
||||
protocol::MobSend mobSend;
|
||||
for(int i = 0; i < mobSendCount; i++){
|
||||
for (int i = 0; i < mobSendCount; i++) {
|
||||
data >> mobSend;
|
||||
m_MobSends.push_back(mobSend);
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ void Renderer::initShader() {
|
||||
}
|
||||
|
||||
bool Renderer::init() {
|
||||
#ifndef ANDROID
|
||||
#ifndef ANDROID
|
||||
glbinding::Binding::initialize();
|
||||
#endif
|
||||
#endif
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
@@ -85,7 +85,7 @@ void WorldRenderer::renderTowers() const {
|
||||
}
|
||||
|
||||
void WorldRenderer::renderTileSelect() const {
|
||||
if(ImGui::IsAnyItemHovered()) return;
|
||||
if (ImGui::IsAnyItemHovered()) return;
|
||||
|
||||
Renderer::Model tileSelectModel;
|
||||
tileSelectModel.vao = m_SelectTileVao.get();
|
||||
@@ -180,8 +180,8 @@ void WorldRenderer::renderTowerUpgradePopup() {
|
||||
bool alreadyUpgraded = currentLevel <= towerLevel;
|
||||
bool canUpgrade = (towerLevel + 1) == currentLevel;
|
||||
|
||||
if(canUpgrade && towerPath != game::TowerPath::Base){
|
||||
if(currentPath != towerPath){
|
||||
if (canUpgrade && towerPath != game::TowerPath::Base) {
|
||||
if (currentPath != towerPath) {
|
||||
canUpgrade = false;
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ void WorldRenderer::renderTowerUpgradePopup() {
|
||||
ImGui::EndDisabled();
|
||||
} else if (canUpgrade) {
|
||||
if (ImGui::Button("Upgrade", ImVec2(100, 100))) {
|
||||
m_Client->getClient()->upgradeTower(tower->getID(), {currentLevel, currentPath});
|
||||
m_Client->getClient()->upgradeTower(tower->getID(), { currentLevel, currentPath });
|
||||
}
|
||||
} else {
|
||||
ImGui::BeginDisabled();
|
||||
@@ -226,8 +226,8 @@ void WorldRenderer::detectClick() {
|
||||
}
|
||||
|
||||
void WorldRenderer::renderMobTooltip() const {
|
||||
if(ImGui::IsAnyItemHovered()) return;
|
||||
|
||||
if (ImGui::IsAnyItemHovered()) return;
|
||||
|
||||
detectMobHovering();
|
||||
m_MobTooltip->render();
|
||||
}
|
||||
@@ -240,7 +240,7 @@ void WorldRenderer::detectMobHovering() const {
|
||||
float mobCenterY = mob->getY();
|
||||
if (cursorWorldPos.x > mobCenterX - 0.5f && cursorWorldPos.x < mobCenterX + 0.5f
|
||||
&& cursorWorldPos.y > mobCenterY - 0.5f && cursorWorldPos.y < mobCenterY + 0.5f) {
|
||||
m_MobTooltip->setMob(mob.get());
|
||||
m_MobTooltip->setMob(mob.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "render/shaders/EntityShader.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
static const char vertexSource[] =
|
||||
static const char vertexSource[] =
|
||||
R"(#version 300 es
|
||||
|
||||
precision mediump float;
|
||||
@@ -34,7 +34,7 @@ void main(void){
|
||||
}
|
||||
)";
|
||||
|
||||
static const char fragmentSource[] =
|
||||
static const char fragmentSource[] =
|
||||
R"(#version 300 es
|
||||
|
||||
precision mediump float;
|
||||
|
||||
@@ -116,9 +116,9 @@ int ShaderProgram::loadShader(const std::string& source, GLenum type) {
|
||||
char error[size];
|
||||
glGetShaderInfoLog(shaderID, size, &size, error);
|
||||
std::cout << error << std::endl;
|
||||
#ifdef __ANDROID__
|
||||
#ifdef __ANDROID__
|
||||
__android_log_print(ANDROID_LOG_ERROR, "TRACKERS", "Could not compile shader !\n %s", error);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return shaderID;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "render/shaders/WorldShader.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
static const char vertexSource[] =
|
||||
static const char vertexSource[] =
|
||||
R"(#version 300 es
|
||||
|
||||
precision mediump float;
|
||||
@@ -31,7 +31,7 @@ void main(void){
|
||||
}
|
||||
)";
|
||||
|
||||
static const char fragmentSource[] =
|
||||
static const char fragmentSource[] =
|
||||
R"(#version 300 es
|
||||
|
||||
precision mediump float;
|
||||
|
||||
Reference in New Issue
Block a user