Added Toggle Button, Fixed canvas Scalar
This commit is contained in:
parent
b293b28a56
commit
5f11a931c7
|
@ -1,7 +1,7 @@
|
||||||
- EID: 0
|
- EID: 0
|
||||||
Name: Canvas
|
Name: Canvas
|
||||||
IsActive: true
|
IsActive: true
|
||||||
NumberOfChildren: 1
|
NumberOfChildren: 2
|
||||||
Components:
|
Components:
|
||||||
Canvas Component:
|
Canvas Component:
|
||||||
Canvas Width: 10
|
Canvas Width: 10
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 0, y: 0, z: 0}
|
Translate: {x: -3.5999999, y: 3.0999999, z: 0}
|
||||||
Rotate: {x: 0, y: 0, z: 0}
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -28,6 +28,26 @@
|
||||||
Clicked Texture: 0
|
Clicked Texture: 0
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
|
- EID: 5
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 153.399994, y: 0, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 141771688
|
||||||
|
Material: 129340704
|
||||||
|
IsActive: true
|
||||||
|
Toggle Button Component:
|
||||||
|
Non Toggled Texture: 0
|
||||||
|
Toggled Texture: 0
|
||||||
|
Value: false
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
- EID: 1
|
- EID: 1
|
||||||
Name: Camera
|
Name: Camera
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Name: UI Test
|
Name: UI Test
|
||||||
ID: 92351881
|
ID: 94041256
|
||||||
Type: 5
|
Type: 5
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "UI/SHUIComponent.h"
|
#include "UI/SHUIComponent.h"
|
||||||
#include "UI/SHCanvasComponent.h"
|
#include "UI/SHCanvasComponent.h"
|
||||||
#include "UI/SHButtonComponent.h"
|
#include "UI/SHButtonComponent.h"
|
||||||
|
#include "UI/SHToggleButtonComponent.h"
|
||||||
#include "SHEditorComponentView.h"
|
#include "SHEditorComponentView.h"
|
||||||
#include "AudioSystem/SHAudioListenerComponent.h"
|
#include "AudioSystem/SHAudioListenerComponent.h"
|
||||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||||
|
@ -154,6 +155,10 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
DrawComponent(buttonComponent);
|
DrawComponent(buttonComponent);
|
||||||
}
|
}
|
||||||
|
if (auto toggleButton = SHComponentManager::GetComponent_s<SHToggleButtonComponent>(eid))
|
||||||
|
{
|
||||||
|
DrawComponent(toggleButton);
|
||||||
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
// Render Scripts
|
// Render Scripts
|
||||||
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
||||||
|
@ -167,6 +172,7 @@ namespace SHADE
|
||||||
DrawAddComponentButton<SHLightComponent>(eid);
|
DrawAddComponentButton<SHLightComponent>(eid);
|
||||||
DrawAddComponentButton<SHCanvasComponent>(eid);
|
DrawAddComponentButton<SHCanvasComponent>(eid);
|
||||||
DrawAddComponentButton<SHButtonComponent>(eid);
|
DrawAddComponentButton<SHButtonComponent>(eid);
|
||||||
|
DrawAddComponentButton<SHToggleButtonComponent>(eid);
|
||||||
|
|
||||||
// Components that require Transforms
|
// Components that require Transforms
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "Physics/Interface/SHRigidBodyComponent.h"
|
#include "Physics/Interface/SHRigidBodyComponent.h"
|
||||||
#include "UI/SHCanvasComponent.h"
|
#include "UI/SHCanvasComponent.h"
|
||||||
#include "UI/SHButtonComponent.h"
|
#include "UI/SHButtonComponent.h"
|
||||||
|
#include "UI/SHToggleButtonComponent.h"
|
||||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
||||||
#include "Scripting/SHScriptEngine.h"
|
#include "Scripting/SHScriptEngine.h"
|
||||||
|
@ -218,6 +219,7 @@ namespace SHADE
|
||||||
|
|
||||||
AddComponentToComponentNode<SHCanvasComponent>(components, eid);
|
AddComponentToComponentNode<SHCanvasComponent>(components, eid);
|
||||||
AddComponentToComponentNode<SHButtonComponent>(components, eid);
|
AddComponentToComponentNode<SHButtonComponent>(components, eid);
|
||||||
|
AddComponentToComponentNode<SHToggleButtonComponent>(components, eid);
|
||||||
|
|
||||||
AddConvComponentToComponentNode<SHTextRenderableComponent>(components, eid);
|
AddConvComponentToComponentNode<SHTextRenderableComponent>(components, eid);
|
||||||
|
|
||||||
|
@ -275,6 +277,7 @@ namespace SHADE
|
||||||
|
|
||||||
AddComponentID<SHCanvasComponent>(componentIDList, componentsNode);
|
AddComponentID<SHCanvasComponent>(componentIDList, componentsNode);
|
||||||
AddComponentID<SHButtonComponent>(componentIDList, componentsNode);
|
AddComponentID<SHButtonComponent>(componentIDList, componentsNode);
|
||||||
|
AddComponentID<SHToggleButtonComponent>(componentIDList, componentsNode);
|
||||||
AddComponentID<SHTextRenderableComponent>(componentIDList, componentsNode);
|
AddComponentID<SHTextRenderableComponent>(componentIDList, componentsNode);
|
||||||
|
|
||||||
return componentIDList;
|
return componentIDList;
|
||||||
|
@ -356,6 +359,7 @@ namespace SHADE
|
||||||
|
|
||||||
SHSerializationHelper::InitializeComponentFromNode<SHCanvasComponent>(componentsNode, eid);
|
SHSerializationHelper::InitializeComponentFromNode<SHCanvasComponent>(componentsNode, eid);
|
||||||
SHSerializationHelper::InitializeComponentFromNode<SHButtonComponent>(componentsNode, eid);
|
SHSerializationHelper::InitializeComponentFromNode<SHButtonComponent>(componentsNode, eid);
|
||||||
|
SHSerializationHelper::InitializeComponentFromNode<SHToggleButtonComponent>(componentsNode, eid);
|
||||||
SHSerializationHelper::ConvertNodeToComponent<SHTextRenderableComponent>(componentsNode, eid);
|
SHSerializationHelper::ConvertNodeToComponent<SHTextRenderableComponent>(componentsNode, eid);
|
||||||
SHSerializationHelper::InitializeComponentFromNode<SHLightComponent>(componentsNode, eid);
|
SHSerializationHelper::InitializeComponentFromNode<SHLightComponent>(componentsNode, eid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
SHButtonComponent::SHButtonComponent()
|
SHButtonComponent::SHButtonComponent()
|
||||||
:size(1.0f), offset(0.0f), isHovered(false), isClicked(false),
|
:size(1.0f), isHovered(false), isClicked(false),
|
||||||
defaultTexture(0), hoveredTexture(0), clickedTexture(0)
|
defaultTexture(0), hoveredTexture(0), clickedTexture(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ namespace SHADE
|
||||||
virtual ~SHButtonComponent() = default;
|
virtual ~SHButtonComponent() = default;
|
||||||
|
|
||||||
SHVec2 size;
|
SHVec2 size;
|
||||||
SHVec2 offset;
|
|
||||||
|
|
||||||
AssetID GetClickedTexture() const noexcept;
|
AssetID GetClickedTexture() const noexcept;
|
||||||
AssetID GetDefaultTexture() const noexcept;
|
AssetID GetDefaultTexture() const noexcept;
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
#include "SHpch.h"
|
||||||
|
#include "SHToggleButtonComponent.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
SHToggleButtonComponent::SHToggleButtonComponent()
|
||||||
|
:size(1.0f), isHovered(false), isClicked(false), value(false),
|
||||||
|
defaultTexture(0), toggledTexture(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetID SHToggleButtonComponent::GetDefaultTexture() const noexcept
|
||||||
|
{
|
||||||
|
return defaultTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetID SHToggleButtonComponent::GetToggledTexture() const noexcept
|
||||||
|
{
|
||||||
|
return toggledTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHToggleButtonComponent::GetValue() const noexcept
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHToggleButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
||||||
|
{
|
||||||
|
defaultTexture = texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHToggleButtonComponent::SetToggledTexture(AssetID texture) noexcept
|
||||||
|
{
|
||||||
|
toggledTexture = texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHToggleButtonComponent::SetValue(bool value) noexcept
|
||||||
|
{
|
||||||
|
this->value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RTTR_REGISTRATION
|
||||||
|
{
|
||||||
|
using namespace SHADE;
|
||||||
|
using namespace rttr;
|
||||||
|
|
||||||
|
registration::class_<SHToggleButtonComponent>("Toggle Button Component")
|
||||||
|
.property("Non Toggled Texture", &SHToggleButtonComponent::GetDefaultTexture, &SHToggleButtonComponent::SetDefaultTexture)
|
||||||
|
.property("Toggled Texture", &SHToggleButtonComponent::GetToggledTexture, &SHToggleButtonComponent::SetToggledTexture)
|
||||||
|
.property("Value", &SHToggleButtonComponent::GetValue, &SHToggleButtonComponent::SetValue)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <rttr/registration>
|
||||||
|
|
||||||
|
#include "SH_API.h"
|
||||||
|
#include "ECS_Base/Components/SHComponent.h"
|
||||||
|
#include "Math/Vector/SHVec3.h"
|
||||||
|
#include "Math/Vector/SHVec2.h"
|
||||||
|
#include "Assets/SHAssetMacros.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
|
||||||
|
class SH_API SHToggleButtonComponent final: public SHComponent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SHToggleButtonComponent();
|
||||||
|
virtual ~SHToggleButtonComponent() = default;
|
||||||
|
|
||||||
|
SHVec2 size;
|
||||||
|
|
||||||
|
AssetID GetToggledTexture() const noexcept;
|
||||||
|
AssetID GetDefaultTexture() const noexcept;
|
||||||
|
bool GetValue() const noexcept;
|
||||||
|
|
||||||
|
|
||||||
|
void SetDefaultTexture(AssetID texture) noexcept;
|
||||||
|
void SetToggledTexture(AssetID texture) noexcept;
|
||||||
|
void SetValue(bool value) noexcept;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
friend class SHUISystem;
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool isHovered;
|
||||||
|
bool isClicked;
|
||||||
|
bool value;
|
||||||
|
AssetID defaultTexture;
|
||||||
|
AssetID toggledTexture;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
RTTR_ENABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -103,7 +103,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(comp.GetEID());
|
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(comp.GetEID());
|
||||||
if (canvasComp != nullptr)
|
if (canvasComp != nullptr)
|
||||||
comp.localToCanvasMatrix = canvasComp->GetMatrix()* transform->GetTRS();
|
comp.localToCanvasMatrix = transform->GetTRS() * canvasComp->GetMatrix();
|
||||||
else
|
else
|
||||||
comp.localToCanvasMatrix = transform->GetTRS();
|
comp.localToCanvasMatrix = transform->GetTRS();
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,70 @@ namespace SHADE
|
||||||
|
|
||||||
void SHUISystem::UpdateButtonComponent(SHButtonComponent& comp) noexcept
|
void SHUISystem::UpdateButtonComponent(SHButtonComponent& comp) noexcept
|
||||||
{
|
{
|
||||||
if (!SHComponentManager::HasComponent<SHTransformComponent>(comp.GetEID()) || !SHComponentManager::HasComponent<SHUIComponent>(comp.GetEID()))
|
if (!SHComponentManager::HasComponent<SHUIComponent>(comp.GetEID()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
|
auto uiComp = SHComponentManager::GetComponent<SHUIComponent>(comp.GetEID());
|
||||||
|
|
||||||
|
SHVec4 topExtent4 = SHMatrix::Translate(-comp.size.x * 0.5f, comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f,0.0f, 0.0f,1.0f);
|
||||||
|
SHVec4 btmExtent4 = SHMatrix::Translate(comp.size.x * 0.5f, -comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f,0.0f, 0.0f,1.0f);
|
||||||
|
//SHVec4 btmExtent4 = uiComp->GetMatrix() * SHVec4(comp.size.x * 0.5f , -comp.size.y * 0.5f , 0.0f, 1.0f);
|
||||||
|
|
||||||
|
SHVec2 topExtent{ topExtent4.x,topExtent4.y };
|
||||||
|
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
|
||||||
|
|
||||||
|
|
||||||
|
SHVec2 mousePos;
|
||||||
|
SHVec2 windowSize;
|
||||||
|
#ifdef SHEDITOR
|
||||||
|
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->windowSize;
|
||||||
|
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
|
||||||
|
//mousePos.y = windowSize.y - mousePos.y;
|
||||||
|
mousePos /= windowSize;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0)};
|
||||||
|
//SHLOG_INFO("TopExtent: {}, {}", topExtent.x, topExtent.y)
|
||||||
|
|
||||||
|
topExtent = CanvasToScreenPoint(topExtent);
|
||||||
|
btmExtent = CanvasToScreenPoint(btmExtent);
|
||||||
|
topExtent /= camSize;
|
||||||
|
btmExtent /= camSize;
|
||||||
|
|
||||||
|
comp.isClicked = false;
|
||||||
|
if (mousePos.x >= topExtent.x && mousePos.x <= btmExtent.x
|
||||||
|
&& mousePos.y >= topExtent.y && mousePos.y <= btmExtent.y)
|
||||||
|
{
|
||||||
|
comp.isHovered = true;
|
||||||
|
if (SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
|
||||||
|
{
|
||||||
|
comp.isClicked = true;
|
||||||
|
}
|
||||||
|
SHLOG_INFO("HOVERED")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
comp.isHovered = false;
|
||||||
|
SHLOG_INFO("NOT HOVERED")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
|
||||||
|
{
|
||||||
|
/*auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
||||||
|
auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
|
||||||
|
|
||||||
|
auto material = renderable->GetModifiableMaterial();
|
||||||
|
material->SetProperty("texture", comp.GetDefaultTexture());*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHUISystem::UpdateToggleButtonComponent(SHToggleButtonComponent& comp) noexcept
|
||||||
|
{
|
||||||
|
if (!SHComponentManager::HasComponent<SHUIComponent>(comp.GetEID()))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -151,35 +214,25 @@ namespace SHADE
|
||||||
|
|
||||||
SHVec2 topExtent{ topExtent4.x,topExtent4.y };
|
SHVec2 topExtent{ topExtent4.x,topExtent4.y };
|
||||||
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
|
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
|
||||||
//SHLOG_INFO("TopExtent: {}, {}", topExtent.x, topExtent.y);
|
|
||||||
|
|
||||||
|
|
||||||
SHVec2 windowSize;
|
|
||||||
SHVec2 mousePos;
|
SHVec2 mousePos;
|
||||||
|
SHVec2 windowSize;
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
|
||||||
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->windowSize;
|
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->windowSize;
|
||||||
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
|
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
|
||||||
//SHLOG_INFO("MousePos: {}, {}", mousePos.x, mousePos.y);
|
mousePos /= windowSize;
|
||||||
//mousePos /= windowSize;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) };
|
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
topExtent = CanvasToScreenPoint(topExtent);
|
topExtent = CanvasToScreenPoint(topExtent);
|
||||||
btmExtent = CanvasToScreenPoint(btmExtent);
|
btmExtent = CanvasToScreenPoint(btmExtent);
|
||||||
|
topExtent /= camSize;
|
||||||
//SHLOG_INFO("TopExtent Screen Point: {}, {}, Cam size: {}, {}", topExtent.x, topExtent.y, camSize.x, camSize.y);
|
btmExtent /= camSize;
|
||||||
|
|
||||||
//Convert everything to using ratios
|
|
||||||
//topExtent /= camSize;
|
|
||||||
//btmExtent /= camSize;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//SHLOG_INFO("mousePos: {} , {}", mousePos.x, mousePos.y);
|
|
||||||
comp.isClicked = false;
|
comp.isClicked = false;
|
||||||
if (mousePos.x >= topExtent.x && mousePos.x <= btmExtent.x
|
if (mousePos.x >= topExtent.x && mousePos.x <= btmExtent.x
|
||||||
&& mousePos.y >= topExtent.y && mousePos.y <= btmExtent.y)
|
&& mousePos.y >= topExtent.y && mousePos.y <= btmExtent.y)
|
||||||
|
@ -188,30 +241,26 @@ namespace SHADE
|
||||||
if (SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
|
if (SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
|
||||||
{
|
{
|
||||||
comp.isClicked = true;
|
comp.isClicked = true;
|
||||||
//SHLOG_INFO("BUTTON CLICKED");
|
comp.value = !comp.value;
|
||||||
}
|
}
|
||||||
//SHLOG_INFO("BUTTON HOVERED");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
comp.isHovered = false;
|
comp.isHovered = false;
|
||||||
|
|
||||||
//SHLOG_INFO("BUTTON NOT HOVERED")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
|
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
|
||||||
{
|
{
|
||||||
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
/*auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
||||||
auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
|
auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
|
||||||
|
|
||||||
auto material = renderable->GetModifiableMaterial();
|
auto material = renderable->GetModifiableMaterial();
|
||||||
material->SetProperty("texture", comp.GetDefaultTexture());
|
material->SetProperty("texture", comp.GetDefaultTexture());*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHUISystem::UpdateButtonsRoutine::Execute(double dt) noexcept
|
void SHUISystem::UpdateButtonsRoutine::Execute(double dt) noexcept
|
||||||
{
|
{
|
||||||
SHUISystem* system = (SHUISystem*)GetSystem();
|
SHUISystem* system = (SHUISystem*)GetSystem();
|
||||||
|
@ -221,6 +270,13 @@ namespace SHADE
|
||||||
if (SHSceneManager::CheckNodeAndComponentsActive<SHButtonComponent>(comp.GetEID()))
|
if (SHSceneManager::CheckNodeAndComponentsActive<SHButtonComponent>(comp.GetEID()))
|
||||||
system->UpdateButtonComponent(comp);
|
system->UpdateButtonComponent(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& toggleButtonDense = SHComponentManager::GetDense<SHToggleButtonComponent>();
|
||||||
|
for (auto& comp : toggleButtonDense)
|
||||||
|
{
|
||||||
|
if (SHSceneManager::CheckNodeAndComponentsActive<SHToggleButtonComponent>(comp.GetEID()))
|
||||||
|
system->UpdateToggleButtonComponent(comp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SHVec2 SHUISystem::CanvasToScreenPoint(SHVec2& const canvasPoint) noexcept
|
SHVec2 SHUISystem::CanvasToScreenPoint(SHVec2& const canvasPoint) noexcept
|
||||||
|
@ -230,7 +286,7 @@ namespace SHADE
|
||||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
|
|
||||||
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) };
|
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) };
|
||||||
|
//camSize.y *= -1.0f;
|
||||||
|
|
||||||
result.y *= -1.0f;
|
result.y *= -1.0f;
|
||||||
result += camSize * 0.5f;
|
result += camSize * 0.5f;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "ECS_Base/System/SHSystemRoutine.h"
|
#include "ECS_Base/System/SHSystemRoutine.h"
|
||||||
#include "SHUIComponent.h"
|
#include "SHUIComponent.h"
|
||||||
#include "SHButtonComponent.h"
|
#include "SHButtonComponent.h"
|
||||||
|
#include "SHToggleButtonComponent.h"
|
||||||
#include "SHCanvasComponent.h"
|
#include "SHCanvasComponent.h"
|
||||||
#include "Scene/SHSceneGraph.h"
|
#include "Scene/SHSceneGraph.h"
|
||||||
#include "Scene/SHSceneManager.h"
|
#include "Scene/SHSceneManager.h"
|
||||||
|
@ -64,6 +65,7 @@ namespace SHADE
|
||||||
private:
|
private:
|
||||||
void UpdateUIComponent(SHUIComponent& comp) noexcept;
|
void UpdateUIComponent(SHUIComponent& comp) noexcept;
|
||||||
void UpdateButtonComponent(SHButtonComponent& comp) noexcept;
|
void UpdateButtonComponent(SHButtonComponent& comp) noexcept;
|
||||||
|
void UpdateToggleButtonComponent(SHToggleButtonComponent& comp) noexcept;
|
||||||
void UpdateCanvasComponent(SHCanvasComponent& comp) noexcept;
|
void UpdateCanvasComponent(SHCanvasComponent& comp) noexcept;
|
||||||
SHVec2 CanvasToScreenPoint(SHVec2& const canvasPoint) noexcept;
|
SHVec2 CanvasToScreenPoint(SHVec2& const canvasPoint) noexcept;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue