From fee50ba3b6e0b025c6f0ae4ec17be5153ca1b306 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 11 Feb 2016 21:16:10 +0100 Subject: [PATCH 1/5] Crash fix --- src/Game/Systems/CapturePointHUDSystem.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Game/Systems/CapturePointHUDSystem.cpp b/src/Game/Systems/CapturePointHUDSystem.cpp index 784c7e16..5369b830 100644 --- a/src/Game/Systems/CapturePointHUDSystem.cpp +++ b/src/Game/Systems/CapturePointHUDSystem.cpp @@ -17,6 +17,10 @@ void CapturePointHUDSystem::Update(double dt) auto CapturePointHUDElements = m_World->GetComponents("CapturePointHUD"); auto CapturePoints = m_World->GetComponents("CapturePoint"); + if(!CapturePointHUDElements) { + return; + } + for (auto& cCapturePointHUD : *CapturePointHUDElements) { int HUD_ID = cCapturePointHUD["CapturePointNumber"]; EntityWrapper entityHUD = EntityWrapper(m_World, cCapturePointHUD.EntityID); From c1860ae383faacdce63f2b374f5c9c645bdbde8b Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 11 Feb 2016 23:38:25 +0100 Subject: [PATCH 2/5] AmmunitionHUD now working --- include/Game/Systems/HealthHUDSystem - Copy.h | 17 ++ .../{PlayerHUDSystem.h => HealthHUDSystem.h} | 6 +- resources/Schema/Components.xsd | 1 + resources/Schema/Components/AmmunitionHUD.xml | 3 + resources/Schema/Components/AmmunitionHUD.xsd | 10 + ...PointHUDGroup => CapturePointHUDGroup.xml} | 0 resources/Schema/Entities/Player.xml | 235 ++++++++++++++++-- resources/Schema/Types/Entity.xsd | 1 + src/Game/Game.cpp | 7 +- ...layerHUDSystem.cpp => HealthHUDSystem.cpp} | 8 +- 10 files changed, 263 insertions(+), 25 deletions(-) create mode 100644 include/Game/Systems/HealthHUDSystem - Copy.h rename include/Game/Systems/{PlayerHUDSystem.h => HealthHUDSystem.h} (57%) create mode 100644 resources/Schema/Components/AmmunitionHUD.xml create mode 100644 resources/Schema/Components/AmmunitionHUD.xsd rename resources/Schema/Entities/{CapturePointHUDGroup => CapturePointHUDGroup.xml} (100%) rename src/Game/Systems/{PlayerHUDSystem.cpp => HealthHUDSystem.cpp} (85%) diff --git a/include/Game/Systems/HealthHUDSystem - Copy.h b/include/Game/Systems/HealthHUDSystem - Copy.h new file mode 100644 index 00000000..b22a85b5 --- /dev/null +++ b/include/Game/Systems/HealthHUDSystem - Copy.h @@ -0,0 +1,17 @@ +#ifndef AmmunitionHUDSystem_h__ +#define AmmunitionHUDSystem_h__ + +#include "../../Engine/Core/System.h" +#include "../../Engine/GLM.h" + +class AmmunitionHUDSystem : public ImpureSystem +{ +public: + AmmunitionHUDSystem(SystemParams params) + : System(params) + { } + + virtual void Update(double dt) override; +}; + +#endif \ No newline at end of file diff --git a/include/Game/Systems/PlayerHUDSystem.h b/include/Game/Systems/HealthHUDSystem.h similarity index 57% rename from include/Game/Systems/PlayerHUDSystem.h rename to include/Game/Systems/HealthHUDSystem.h index 50b6a258..49a40041 100644 --- a/include/Game/Systems/PlayerHUDSystem.h +++ b/include/Game/Systems/HealthHUDSystem.h @@ -3,13 +3,11 @@ #include "../../Engine/Core/System.h" #include "../../Engine/GLM.h" -#include "../../Engine/Rendering/ESetCamera.h" -#include -class PlayerHUDSystem : public ImpureSystem +class HealthHUDSystem : public ImpureSystem { public: - PlayerHUDSystem(SystemParams params) + HealthHUDSystem(SystemParams params) : System(params) { } diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index f950e8c8..2a1b67e0 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -39,4 +39,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/AmmunitionHUD.xml b/resources/Schema/Components/AmmunitionHUD.xml new file mode 100644 index 00000000..63b86150 --- /dev/null +++ b/resources/Schema/Components/AmmunitionHUD.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/resources/Schema/Components/AmmunitionHUD.xsd b/resources/Schema/Components/AmmunitionHUD.xsd new file mode 100644 index 00000000..1a48d8d1 --- /dev/null +++ b/resources/Schema/Components/AmmunitionHUD.xsd @@ -0,0 +1,10 @@ + + + + + + + Hud element for tracking ammunition from parent with AssaultWeapon component. Child with the name "MagazineAmmo" tracks clip ammunition. Child with the name "Ammo" tracks ammo. + + + \ No newline at end of file diff --git a/resources/Schema/Entities/CapturePointHUDGroup b/resources/Schema/Entities/CapturePointHUDGroup.xml similarity index 100% rename from resources/Schema/Entities/CapturePointHUDGroup rename to resources/Schema/Entities/CapturePointHUDGroup.xml diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 4ba23a0d..8a5a4d24 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -12,9 +12,7 @@ - - - + 5 @@ -73,17 +71,17 @@ 1 - + + + Textures/Core/UnitHexagon.png + + - - Models/Core/UnitHexagon.mesh - - - + @@ -101,13 +99,182 @@ + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 3 + + + 0.80222018197612788 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 1 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + Idle - 0.52743271827223559 + 0.14471987707210765 1 @@ -126,8 +293,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -142,6 +309,44 @@ + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + @@ -166,7 +371,7 @@ Idle - 0.69666320633760392 + 1.7139414005989018 1 @@ -190,8 +395,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index ffe3421a..3e521007 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -43,6 +43,7 @@ + diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 8ee6dbed..cd8abb87 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -17,12 +17,14 @@ #include "Game/Systems/DamageIndicatorSystem.h" #include "Game/Systems/WeaponSystem.h" #include "Rendering/AnimationSystem.h" -#include "Game/Systems/PlayerHUDSystem.h" +#include "Game/Systems/HealthHUDSystem.h" #include "Rendering/BoneAttachmentSystem.h" #include "Game/Systems/LifetimeSystem.h" #include "../Engine/Core/UniformScaleSystem.h" #include "Rendering/AnimationSystem.h" #include "Network/MultiplayerSnapshotFilter.h" +#include "Game/Systems/AmmunitionHUDSystem.h" + Game::Game(int argc, char* argv[]) { @@ -125,6 +127,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); // Populate Octree with collidables ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision, "Collidable"); @@ -132,7 +135,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeFrustrumCulling); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); // Collision and TriggerSystem should update after player. ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel); diff --git a/src/Game/Systems/PlayerHUDSystem.cpp b/src/Game/Systems/HealthHUDSystem.cpp similarity index 85% rename from src/Game/Systems/PlayerHUDSystem.cpp rename to src/Game/Systems/HealthHUDSystem.cpp index 898d8bea..49b2d0c1 100644 --- a/src/Game/Systems/PlayerHUDSystem.cpp +++ b/src/Game/Systems/HealthHUDSystem.cpp @@ -1,6 +1,6 @@ -#include "Game/Systems/PlayerHUDSystem.h" +#include "Game/Systems/HealthHUDSystem.h" -void PlayerHUDSystem::Update(double dt) +void HealthHUDSystem::Update(double dt) { auto healthHUDs = m_World->GetComponents("HealthHUD"); if (healthHUDs == nullptr) { @@ -27,13 +27,13 @@ void PlayerHUDSystem::Update(double dt) s = s + "/"; s = s + std::to_string((int)(double)entityIDParent["Health"]["MaxHealth"]); float healthPercentage = (double)entityIDParent["Health"]["Health"]/(double)entityIDParent["Health"]["MaxHealth"]; - (glm::vec4&)entity["Text"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, 1.f); + (glm::vec4&)entity["Text"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, glm::vec4(entity["Fill"]["Color"]).a); entity["Text"]["Content"] = s; } if(entity.HasComponent("Fill")) { float healthPercentage = (double)entityIDParent["Health"]["Health"]/(double)entityIDParent["Health"]["MaxHealth"]; - (glm::vec4&)entity["Fill"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, 0.f); + (glm::vec4&)entity["Fill"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, glm::vec4(entity["Fill"]["Color"]).a); (double&)entity["Fill"]["Percentage"] = healthPercentage; } From a36ed76a4e42bf0a4ad116b86b4b8f603fcf3021 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 12 Feb 2016 00:26:59 +0100 Subject: [PATCH 3/5] AmmunitionHUDSystem now really working --- assets | 2 +- ...DSystem - Copy.h => AmmunitionHUDSystem.h} | 0 resources/Schema/Entities/Player.xml | 17 ++++----- src/Game/Systems/AmmunitionHUDSystem.cpp | 36 +++++++++++++++++++ 4 files changed, 46 insertions(+), 9 deletions(-) rename include/Game/Systems/{HealthHUDSystem - Copy.h => AmmunitionHUDSystem.h} (100%) create mode 100644 src/Game/Systems/AmmunitionHUDSystem.cpp diff --git a/assets b/assets index dfa0fc61..4d36fdce 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit dfa0fc61ab88456f3461779bd7c6ac97d15f6493 +Subproject commit 4d36fdced7007a594a56b7371bb26861876889aa diff --git a/include/Game/Systems/HealthHUDSystem - Copy.h b/include/Game/Systems/AmmunitionHUDSystem.h similarity index 100% rename from include/Game/Systems/HealthHUDSystem - Copy.h rename to include/Game/Systems/AmmunitionHUDSystem.h diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 8a5a4d24..910e440f 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -274,7 +274,7 @@ Idle - 0.14471987707210765 + 1.9901368826444736 1 @@ -293,8 +293,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -313,8 +313,9 @@ - - + + + @@ -371,7 +372,7 @@ Idle - 1.7139414005989018 + 0.22602443705505681 1 @@ -395,8 +396,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + diff --git a/src/Game/Systems/AmmunitionHUDSystem.cpp b/src/Game/Systems/AmmunitionHUDSystem.cpp new file mode 100644 index 00000000..c9d87072 --- /dev/null +++ b/src/Game/Systems/AmmunitionHUDSystem.cpp @@ -0,0 +1,36 @@ +#include "Game/Systems/AmmunitionHUDSystem.h" + +void AmmunitionHUDSystem::Update(double dt) +{ + //Hud element for tracking ammunition from parent with AssaultWeapon component.Child with the name "MagazineAmmo" tracks clip ammunition.Child with the name "Ammo" tracks ammo. + + auto ammunitionHUDs = m_World->GetComponents("AmmunitionHUD"); + if (ammunitionHUDs == nullptr) { + return; + } + + for (auto& ammunitionHUDComponent : *ammunitionHUDs) { + EntityWrapper entity = EntityWrapper(m_World, ammunitionHUDComponent.EntityID); + + EntityWrapper playerEntity = entity.FirstParentWithComponent("AssaultWeapon"); + + if (!playerEntity.Valid()) { + return; + } + + + EntityWrapper magazineAmmo = entity.FirstChildByName("MagazineAmmo"); + if(magazineAmmo.Valid()) { + if(magazineAmmo.HasComponent("Text")) { + (std::string&)magazineAmmo["Text"]["Content"] = std::to_string((int)playerEntity["AssaultWeapon"]["MagazineAmmo"]); + } + } + + EntityWrapper ammo = entity.FirstChildByName("Ammo"); + if (ammo.Valid()) { + if (ammo.HasComponent("Text")) { + (std::string&)ammo["Text"]["Content"] = std::to_string((int)playerEntity["AssaultWeapon"]["Ammo"]); + } + } + } +} From fb5164221f8ec45b191c6395dfcfcc35a48e863c Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 12 Feb 2016 01:57:53 +0100 Subject: [PATCH 4/5] HealthHUD redesigned --- assets | 2 +- resources/Schema/Entities/AmmoHUD | 98 +++++++++++++++++++++++++++ resources/Schema/Entities/Player.xml | 99 +++++++++++++++++++--------- resources/Schema/Entities/temp | 38 +++++++++++ src/Engine/Rendering/Renderer.cpp | 1 + src/Game/Systems/HealthHUDSystem.cpp | 2 +- 6 files changed, 208 insertions(+), 32 deletions(-) create mode 100644 resources/Schema/Entities/AmmoHUD create mode 100644 resources/Schema/Entities/temp diff --git a/assets b/assets index 4d36fdce..0fd6b66b 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4d36fdced7007a594a56b7371bb26861876889aa +Subproject commit 0fd6b66b599ab98a441f91d5cc53c603009f488c diff --git a/resources/Schema/Entities/AmmoHUD b/resources/Schema/Entities/AmmoHUD new file mode 100644 index 00000000..6cdb6568 --- /dev/null +++ b/resources/Schema/Entities/AmmoHUD @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + 0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + 0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 39e7331f..30ae942e 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -76,14 +76,14 @@ - Textures/Core/UnitHexagon.png - + Textures/HealthHUD3.png + - - - + + + @@ -279,13 +279,33 @@ + + + + 1 + + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + Idle - 0.1719161089749548 + 1.1017089512865343 1 @@ -305,8 +325,8 @@ true - - + + @@ -327,36 +347,55 @@ - - + - - 32 - Fonts/DroidSans.ttf,64 - - + + Textures/Core/UnitHexagon.png + + - + + - + - - 360 - Fonts/DroidSans.ttf,64 - - - - - - + - + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + @@ -393,7 +432,7 @@ Idle - 1.8038469763698401 + 1.5336333336960681 1 @@ -418,8 +457,8 @@ false - - + + diff --git a/resources/Schema/Entities/temp b/resources/Schema/Entities/temp new file mode 100644 index 00000000..baf4ce61 --- /dev/null +++ b/resources/Schema/Entities/temp @@ -0,0 +1,38 @@ + + + + + + + + + + + + 0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 173ddb2b..be84160c 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -168,6 +168,7 @@ void Renderer::SortRenderJobsByDepth(RenderScene &scene) //Sort all forward jobs so transparency is good. scene.Jobs.TransparentObjects.sort(Renderer::DepthSort); scene.Jobs.SpriteJob.sort(Renderer::DepthSort); + scene.Jobs.Text.sort(Renderer::DepthSort); } void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) diff --git a/src/Game/Systems/HealthHUDSystem.cpp b/src/Game/Systems/HealthHUDSystem.cpp index 49b2d0c1..b35bce12 100644 --- a/src/Game/Systems/HealthHUDSystem.cpp +++ b/src/Game/Systems/HealthHUDSystem.cpp @@ -27,7 +27,7 @@ void HealthHUDSystem::Update(double dt) s = s + "/"; s = s + std::to_string((int)(double)entityIDParent["Health"]["MaxHealth"]); float healthPercentage = (double)entityIDParent["Health"]["Health"]/(double)entityIDParent["Health"]["MaxHealth"]; - (glm::vec4&)entity["Text"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, glm::vec4(entity["Fill"]["Color"]).a); + (glm::vec4&)entity["Text"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, glm::vec4(entity["Text"]["Color"]).a); entity["Text"]["Content"] = s; } From 021c4e36d75567a8cf36a860767bea666ad6ad03 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 12 Feb 2016 02:08:24 +0100 Subject: [PATCH 5/5] New HUD XML files --- resources/Schema/Entities/AmmunitionHUD.xml | 62 +++++++++++++ .../Schema/Entities/CapturePointHUDGroup.xml | 5 +- resources/Schema/Entities/HealthHUD.xml | 50 ++++++++++ resources/Schema/Entities/Player.xml | 93 ++++++++++--------- 4 files changed, 165 insertions(+), 45 deletions(-) create mode 100644 resources/Schema/Entities/AmmunitionHUD.xml create mode 100644 resources/Schema/Entities/HealthHUD.xml diff --git a/resources/Schema/Entities/AmmunitionHUD.xml b/resources/Schema/Entities/AmmunitionHUD.xml new file mode 100644 index 00000000..2eaf2753 --- /dev/null +++ b/resources/Schema/Entities/AmmunitionHUD.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/CapturePointHUDGroup.xml b/resources/Schema/Entities/CapturePointHUDGroup.xml index 9dce0ffb..d35e1bde 100644 --- a/resources/Schema/Entities/CapturePointHUDGroup.xml +++ b/resources/Schema/Entities/CapturePointHUDGroup.xml @@ -1,9 +1,10 @@ - + - + + diff --git a/resources/Schema/Entities/HealthHUD.xml b/resources/Schema/Entities/HealthHUD.xml new file mode 100644 index 00000000..ec781d8f --- /dev/null +++ b/resources/Schema/Entities/HealthHUD.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + 1 + + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1 + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 30ae942e..b34669ca 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -69,25 +69,6 @@ - - - - 1 - - - - Textures/HealthHUD3.png - - - - - - - - - - - @@ -279,25 +260,51 @@ - + - - 1 - - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - + - + + + + + 1 + + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1 + + + + Textures/HealthHUD3.png + + + + + + + + + + + + @@ -305,7 +312,7 @@ Idle - 1.1017089512865343 + 0.24990652025910975 1 @@ -325,8 +332,8 @@ true - - + + @@ -363,7 +370,7 @@ - + @@ -432,7 +439,7 @@ Idle - 1.5336333336960681 + 1.6484966474501377 1 @@ -457,8 +464,8 @@ false - - + +