Added Buttons, Added Canvas Scaling matrix, Added Serialization of buttons and camera arm #250
|
@ -13,6 +13,7 @@
|
|||
Near: 0.00999999978
|
||||
Far: 10000
|
||||
Perspective: true
|
||||
IsActive: true
|
||||
Light Component:
|
||||
Position: {x: 0, y: 0, z: 0}
|
||||
Type: Directional
|
||||
|
@ -20,6 +21,7 @@
|
|||
Color: {x: 0.951541841, y: 0.921719015, z: 0.553319454, w: 1}
|
||||
Layer: 4294967295
|
||||
Strength: 0
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 7
|
||||
Name: BigBoi
|
||||
|
@ -30,9 +32,11 @@
|
|||
Translate: {x: 0, y: -16.8647861, z: -14.039052}
|
||||
Rotate: {x: -0, y: 0, z: -0}
|
||||
Scale: {x: 28.1434975, y: 28.1434975, z: 28.1434975}
|
||||
IsActive: true
|
||||
Renderable Component:
|
||||
Mesh: 149697411
|
||||
Material: 126974645
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 8
|
||||
Name: AmbientLight
|
||||
|
@ -46,4 +50,35 @@
|
|||
Color: {x: 1, y: 1, z: 1, w: 1}
|
||||
Layer: 4294967295
|
||||
Strength: 0.25
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 6
|
||||
Name: Default
|
||||
IsActive: true
|
||||
NumberOfChildren: 1
|
||||
Components:
|
||||
Canvas Component:
|
||||
Canvas Width: 10
|
||||
Canvas Height: 10
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 5
|
||||
Name: Default
|
||||
IsActive: true
|
||||
NumberOfChildren: 0
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: 0, 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
|
||||
Button Component:
|
||||
Default Texture: 0
|
||||
Hovered Texture: 0
|
||||
Clicked Texture: 0
|
||||
IsActive: true
|
||||
Scripts: ~
|
|
@ -126,7 +126,9 @@ namespace Sandbox
|
|||
|
||||
//SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::EditorCameraUpdate>();
|
||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::AddUIComponentRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateCanvasMatrixRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateUIMatrixRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateButtonsRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::CameraSystemUpdate>();
|
||||
|
||||
#ifdef SHEDITOR
|
||||
|
|
|
@ -89,5 +89,22 @@ namespace SHADE
|
|||
return SHMatrix::Identity;
|
||||
}
|
||||
|
||||
float SHCameraDirector::GetWidth() noexcept
|
||||
{
|
||||
SHCameraComponent* camComponent = GetMainCameraComponent();
|
||||
if (camComponent)
|
||||
return camComponent->GetWidth();
|
||||
else
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float SHCameraDirector::GetHeight() noexcept
|
||||
{
|
||||
SHCameraComponent* camComponent = GetMainCameraComponent();
|
||||
if (camComponent)
|
||||
return camComponent->GetHeight();
|
||||
else
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ namespace SHADE
|
|||
void SetMainCamera(SHCameraComponent& cam) noexcept;
|
||||
SHMatrix const& GetOrthoMatrix() noexcept;
|
||||
SHMatrix const& GetPerspectiveMatrix() noexcept;
|
||||
float GetWidth() noexcept;
|
||||
float GetHeight() noexcept;
|
||||
|
||||
private:
|
||||
SHMatrix viewMatrix;
|
||||
|
|
|
@ -57,6 +57,8 @@ namespace SHADE
|
|||
|
||||
//std::cout << camera.yaw << std::endl;
|
||||
|
||||
|
||||
|
||||
camera.pitch -= mouseY * dt * camera.turnSpeed.x;
|
||||
camera.yaw -= mouseX * dt * camera.turnSpeed.y;
|
||||
camera.dirtyView = true;
|
||||
|
@ -150,6 +152,8 @@ namespace SHADE
|
|||
|
||||
void SHCameraSystem::UpdateCameraComponent(SHCameraComponent& camera) noexcept
|
||||
{
|
||||
|
||||
|
||||
if (camera.isActive == false)
|
||||
return;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "Camera/SHCameraArmComponent.h"
|
||||
#include "UI/SHUIComponent.h"
|
||||
#include "UI/SHCanvasComponent.h"
|
||||
#include "UI/SHButtonComponent.h"
|
||||
#include "SHEditorComponentView.h"
|
||||
#include "AudioSystem/SHAudioListenerComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||
|
@ -149,6 +150,10 @@ namespace SHADE
|
|||
{
|
||||
DrawComponent(textRendererComponent);
|
||||
}
|
||||
if (auto buttonComponent = SHComponentManager::GetComponent_s<SHButtonComponent>(eid))
|
||||
{
|
||||
DrawComponent(buttonComponent);
|
||||
}
|
||||
ImGui::Separator();
|
||||
// Render Scripts
|
||||
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
||||
|
@ -161,6 +166,7 @@ namespace SHADE
|
|||
DrawAddComponentButton<SHCameraArmComponent>(eid);
|
||||
DrawAddComponentButton<SHLightComponent>(eid);
|
||||
DrawAddComponentButton<SHCanvasComponent>(eid);
|
||||
DrawAddComponentButton<SHButtonComponent>(eid);
|
||||
|
||||
// Components that require Transforms
|
||||
|
||||
|
|
|
@ -454,12 +454,12 @@ namespace SHADE
|
|||
ImGui::BeginGroup();
|
||||
ImGui::PushID(label.data());
|
||||
TextLabel(label);
|
||||
const bool hasChange = ImGui::DragScalar("##dragScalar", data_type, &value, speed, &p_min, &p_max, displayFormat, flags);
|
||||
const bool hasChange = ImGui::InputScalar("##dragScalar", data_type, &value);
|
||||
static bool startRecording = false;
|
||||
if (hasChange)
|
||||
{
|
||||
SHCommandManager::PerformCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCommand<T>>(get(), value, set)), startRecording);
|
||||
if (!startRecording)
|
||||
if (!startRecording && ImGui::IsMouseDown(ImGuiMouseButton_Left))
|
||||
startRecording = true;
|
||||
}
|
||||
if (startRecording && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||
|
@ -477,7 +477,7 @@ namespace SHADE
|
|||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
return hasChange;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool DragFloat(const std::string_view& label, std::function<float(void)> get, std::function<void(float const&)> set, std::string_view const& tooltip = {},
|
||||
|
|
|
@ -313,7 +313,8 @@ namespace SHADE
|
|||
auto uiComp = SHComponentManager::GetComponent_s<SHUIComponent>(rendId);
|
||||
if (uiComp)
|
||||
{
|
||||
transformData.emplace_back(uiComp->GetMatrix());
|
||||
if(uiComp->isActive)
|
||||
transformData.emplace_back(uiComp->GetMatrix());
|
||||
}
|
||||
else
|
||||
transformData.emplace_back(transform->GetTRS());
|
||||
|
|
|
@ -55,7 +55,11 @@ namespace SHADE
|
|||
|
||||
void SHSuperBatch::Remove(const SHRenderable* renderable) noexcept
|
||||
{
|
||||
Handle<SHMaterial> baseMat = (renderable->HasMaterialChanged() ? renderable->GetPrevMaterial() : renderable->GetMaterial())->GetBaseMaterial();
|
||||
Handle<SHMaterialInstance> matInst = renderable->HasMaterialChanged() ? renderable->GetPrevMaterial() : renderable->GetMaterial();
|
||||
if (!matInst)
|
||||
return;
|
||||
|
||||
Handle<SHMaterial> baseMat = matInst->GetBaseMaterial();
|
||||
const Handle<SHVkPipeline> PIPELINE = baseMat->HasPipelineChanged() ? baseMat->GetPrevPipeline() : baseMat->GetPipeline();
|
||||
|
||||
// Check if we have a Batch with the same pipeline yet
|
||||
|
|
|
@ -968,7 +968,7 @@ namespace SHADE
|
|||
for (auto& renderable : renderables)
|
||||
{
|
||||
// Check if the material instance is now unused
|
||||
renderable.CleanUpMaterials();
|
||||
renderable.CleanUpMaterials();
|
||||
|
||||
if (!renderable.HasChanged())
|
||||
continue;
|
||||
|
|
|
@ -34,9 +34,10 @@ namespace SHADE
|
|||
void SHRenderable::OnDestroy()
|
||||
{
|
||||
// Remove from SuperBatch
|
||||
if (sharedMaterial)
|
||||
auto currMat = GetMaterial();
|
||||
if (currMat)
|
||||
{
|
||||
Handle<SHSuperBatch> superBatch = sharedMaterial->GetBaseMaterial()->GetPipeline()->GetPipelineState().GetSubpass()->GetSuperBatch();
|
||||
Handle<SHSuperBatch> superBatch = currMat->GetBaseMaterial()->GetPipeline()->GetPipelineState().GetSubpass()->GetSuperBatch();
|
||||
superBatch->Remove(this);
|
||||
}
|
||||
|
||||
|
@ -64,7 +65,6 @@ namespace SHADE
|
|||
if (material)
|
||||
{
|
||||
oldMaterial = material;
|
||||
material.Free();
|
||||
material = {};
|
||||
}
|
||||
else if (sharedMaterial)
|
||||
|
@ -144,6 +144,8 @@ namespace SHADE
|
|||
{
|
||||
matChanged = false;
|
||||
meshChanged = false;
|
||||
if (oldMaterial)
|
||||
oldMaterial.Free();
|
||||
oldMaterial = {};
|
||||
oldMesh = {};
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@
|
|||
|
||||
#include "Assets/Asset Types/SHSceneAsset.h"
|
||||
#include "Camera/SHCameraComponent.h"
|
||||
#include "Camera/SHCameraArmComponent.h"
|
||||
#include "Math/Transform/SHTransformComponent.h"
|
||||
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
||||
#include "Physics/Interface/SHRigidBodyComponent.h"
|
||||
#include "UI/SHCanvasComponent.h"
|
||||
#include "UI/SHButtonComponent.h"
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
||||
#include "Scripting/SHScriptEngine.h"
|
||||
|
@ -208,12 +210,14 @@ namespace SHADE
|
|||
|
||||
AddComponentToComponentNode<SHTransformComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHCameraComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHCameraArmComponent>(components, eid);
|
||||
AddConvComponentToComponentNode<SHRenderable>(components, eid);
|
||||
AddComponentToComponentNode<SHLightComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHRigidBodyComponent>(components, eid);
|
||||
AddConvComponentToComponentNode<SHColliderComponent>(components, eid);
|
||||
|
||||
AddComponentToComponentNode<SHCanvasComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHButtonComponent>(components, eid);
|
||||
|
||||
AddConvComponentToComponentNode<SHTextRenderableComponent>(components, eid);
|
||||
|
||||
|
@ -263,12 +267,14 @@ namespace SHADE
|
|||
|
||||
AddComponentID<SHTransformComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHCameraComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHCameraArmComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHRenderable>(componentIDList, componentsNode);
|
||||
AddComponentID<SHRigidBodyComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHLightComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHColliderComponent>(componentIDList, componentsNode);
|
||||
|
||||
AddComponentID<SHCanvasComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHButtonComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHTextRenderableComponent>(componentIDList, componentsNode);
|
||||
|
||||
return componentIDList;
|
||||
|
@ -343,11 +349,13 @@ namespace SHADE
|
|||
return;
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHTransformComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHCameraComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHCameraArmComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHRigidBodyComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::ConvertNodeToComponent<SHRenderable>(componentsNode, eid);
|
||||
SHSerializationHelper::ConvertNodeToComponent<SHColliderComponent>(componentsNode, eid);
|
||||
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHCanvasComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHButtonComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::ConvertNodeToComponent<SHTextRenderableComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHLightComponent>(componentsNode, eid);
|
||||
}
|
||||
|
|
|
@ -5,11 +5,54 @@
|
|||
namespace SHADE
|
||||
{
|
||||
SHButtonComponent::SHButtonComponent()
|
||||
:size(0.0f), offset(0.0f), isHovered(false)
|
||||
:size(1.0f), offset(0.0f), isHovered(false), isClicked(false),
|
||||
defaultTexture(0), hoveredTexture(0), clickedTexture(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AssetID SHButtonComponent::GetDefaultTexture() const noexcept
|
||||
{
|
||||
return defaultTexture;
|
||||
}
|
||||
|
||||
AssetID SHButtonComponent::GetHoveredTexture() const noexcept
|
||||
{
|
||||
return hoveredTexture;
|
||||
}
|
||||
|
||||
AssetID SHButtonComponent::GetClickedTexture() const noexcept
|
||||
{
|
||||
return clickedTexture;
|
||||
}
|
||||
|
||||
void SHButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
||||
{
|
||||
defaultTexture = texture;
|
||||
}
|
||||
|
||||
void SHButtonComponent::SetHoveredTexture(AssetID texture) noexcept
|
||||
{
|
||||
hoveredTexture = texture;
|
||||
}
|
||||
|
||||
void SHButtonComponent::SetClickedTexture(AssetID texture) noexcept
|
||||
{
|
||||
clickedTexture = texture;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
RTTR_REGISTRATION
|
||||
{
|
||||
using namespace SHADE;
|
||||
using namespace rttr;
|
||||
|
||||
registration::class_<SHButtonComponent>("Button Component")
|
||||
.property("Default Texture", &SHButtonComponent::GetDefaultTexture, &SHButtonComponent::SetDefaultTexture)
|
||||
.property("Hovered Texture", &SHButtonComponent::GetHoveredTexture, &SHButtonComponent::SetHoveredTexture)
|
||||
.property("Clicked Texture", &SHButtonComponent::GetClickedTexture, &SHButtonComponent::SetClickedTexture)
|
||||
;
|
||||
|
||||
|
||||
}
|
|
@ -1,30 +1,47 @@
|
|||
#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 SHButtonComponent final: public SHComponent
|
||||
{
|
||||
public:
|
||||
SHButtonComponent();
|
||||
~SHButtonComponent() = default;
|
||||
virtual ~SHButtonComponent() = default;
|
||||
|
||||
SHVec2 size;
|
||||
SHVec2 offset;
|
||||
|
||||
AssetID GetClickedTexture() const noexcept;
|
||||
AssetID GetDefaultTexture() const noexcept;
|
||||
AssetID GetHoveredTexture() const noexcept;
|
||||
|
||||
|
||||
void SetDefaultTexture(AssetID texture) noexcept;
|
||||
void SetHoveredTexture(AssetID texture) noexcept;
|
||||
void SetClickedTexture(AssetID texture) noexcept;
|
||||
|
||||
|
||||
|
||||
friend class SHUISystem;
|
||||
private:
|
||||
|
||||
bool isHovered;
|
||||
bool isClicked;
|
||||
AssetID defaultTexture;
|
||||
AssetID hoveredTexture;
|
||||
AssetID clickedTexture;
|
||||
|
||||
|
||||
|
||||
RTTR_ENABLE()
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include "Math/Transform/SHTransformComponent.h"
|
||||
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
||||
#include "Camera/SHCameraSystem.h"
|
||||
#include "Editor/EditorWindow/SHEditorWindowManager.h"
|
||||
#include "Editor/EditorWindow/ViewportWindow/SHEditorViewport.h"
|
||||
#include "Resource/SHResourceManager.h"
|
||||
#include "Input/SHInputManager.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -12,6 +18,7 @@ namespace SHADE
|
|||
SystemFamily::GetID<SHUISystem>();
|
||||
SHComponentManager::CreateComponentSparseSet<SHCanvasComponent>();
|
||||
SHComponentManager::CreateComponentSparseSet<SHUIComponent>();
|
||||
SHComponentManager::CreateComponentSparseSet<SHButtonComponent>();
|
||||
}
|
||||
|
||||
void SHUISystem::Exit()
|
||||
|
@ -95,7 +102,7 @@ namespace SHADE
|
|||
{
|
||||
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(comp.GetEID());
|
||||
if (canvasComp != nullptr)
|
||||
comp.localToCanvasMatrix = canvasComp->GetMatrix() * transform->GetTRS();
|
||||
comp.localToCanvasMatrix = canvasComp->GetMatrix()* transform->GetTRS();
|
||||
else
|
||||
comp.localToCanvasMatrix = transform->GetTRS();
|
||||
}
|
||||
|
@ -108,10 +115,109 @@ namespace SHADE
|
|||
}
|
||||
}
|
||||
|
||||
void SHUISystem::UpdateButtonComponent(SHButtonComponent& comp) noexcept
|
||||
void SHUISystem::UpdateCanvasComponent(SHCanvasComponent& comp) noexcept
|
||||
{
|
||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
|
||||
comp.canvasMatrix = SHMatrix::Identity;
|
||||
comp.canvasMatrix(0, 0) = cameraSystem->GetDirector(0)->GetWidth() * 0.5f / (comp.GetCanvasWidth() * 0.5f );
|
||||
comp.canvasMatrix(1, 1) = cameraSystem->GetDirector(0)->GetHeight() * 0.5f / (comp.GetCanvasHeight() * 0.5f );
|
||||
}
|
||||
|
||||
void SHUISystem::UpdateCanvasMatrixRoutine::Execute(double dt) noexcept
|
||||
{
|
||||
SHUISystem* system = (SHUISystem*)GetSystem();
|
||||
auto& dense = SHComponentManager::GetDense<SHCanvasComponent>();
|
||||
for (auto& comp : dense)
|
||||
{
|
||||
if(SHSceneManager::CheckNodeAndComponentsActive<SHCanvasComponent>(comp.GetEID()))
|
||||
system->UpdateCanvasComponent(comp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SHUISystem::UpdateButtonComponent(SHButtonComponent& comp) noexcept
|
||||
{
|
||||
if (!SHComponentManager::HasComponent<SHTransformComponent>(comp.GetEID()) || !SHComponentManager::HasComponent<SHUIComponent>(comp.GetEID()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
auto uiComp = SHComponentManager::GetComponent<SHUIComponent>(comp.GetEID());
|
||||
|
||||
SHVec4 topExtent4 = uiComp->GetMatrix() * SHVec4(-comp.size.x * 0.5f, comp.size.y * 0.5f , 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 windowSize;
|
||||
SHVec2 mousePos;
|
||||
#ifdef SHEDITOR
|
||||
|
||||
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->windowSize;
|
||||
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
SHVec2 camSize{ cameraSystem->GetDirector(0)->GetWidth() , cameraSystem->GetDirector(0)->GetHeight() };
|
||||
|
||||
topExtent += camSize * 0.5f;
|
||||
btmExtent += camSize * 0.5f;
|
||||
|
||||
//Convert everything to using ratios
|
||||
topExtent /= camSize;
|
||||
btmExtent /= camSize;
|
||||
|
||||
mousePos /= windowSize;
|
||||
|
||||
//SHLOG_INFO("mousePos: {} , {}", mousePos.x, mousePos.y);
|
||||
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("BUTTON HOVERED");
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
comp.isHovered = false;
|
||||
|
||||
//SHLOG_INFO("BUTTON 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::UpdateButtonsRoutine::Execute(double dt) noexcept
|
||||
{
|
||||
SHUISystem* system = (SHUISystem*)GetSystem();
|
||||
auto& dense = SHComponentManager::GetDense<SHButtonComponent>();
|
||||
for (auto& comp : dense)
|
||||
{
|
||||
if (SHSceneManager::CheckNodeAndComponentsActive<SHButtonComponent>(comp.GetEID()))
|
||||
system->UpdateButtonComponent(comp);
|
||||
}
|
||||
}
|
||||
|
||||
}//end namespace
|
||||
|
|
|
@ -39,6 +39,14 @@ namespace SHADE
|
|||
};
|
||||
friend class UpdateUIMatrixRoutine;
|
||||
|
||||
class SH_API UpdateCanvasMatrixRoutine final: public SHSystemRoutine
|
||||
{
|
||||
public:
|
||||
UpdateCanvasMatrixRoutine() :SHSystemRoutine("Update Canvas Matrix Routine", true) {};
|
||||
virtual void Execute(double dt) noexcept override final;
|
||||
};
|
||||
friend class UpdateCanvasMatrixRoutine;
|
||||
|
||||
|
||||
class SH_API UpdateButtonsRoutine final: public SHSystemRoutine
|
||||
{
|
||||
|
@ -56,7 +64,7 @@ namespace SHADE
|
|||
private:
|
||||
void UpdateUIComponent(SHUIComponent& comp) noexcept;
|
||||
void UpdateButtonComponent(SHButtonComponent& comp) noexcept;
|
||||
|
||||
void UpdateCanvasComponent(SHCanvasComponent& comp) noexcept;
|
||||
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue