Added 3 button event. Changed hovered and clicked boolean to be stored in UIComponent instead. Fixed Canvas Scaling matrix. #356
|
@ -6,6 +6,7 @@
|
|||
Canvas Component:
|
||||
Canvas Width: 1920
|
||||
Canvas Height: 1080
|
||||
Scale by canvas width: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 1
|
||||
|
@ -24,6 +25,8 @@
|
|||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 0
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 5
|
||||
|
@ -47,6 +50,8 @@
|
|||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 0
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts:
|
||||
- Type: ChangeSceneButton
|
||||
|
@ -73,6 +78,8 @@
|
|||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 0
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts:
|
||||
- Type: QuitButton
|
||||
|
@ -106,11 +113,12 @@
|
|||
Pitch: 0
|
||||
Yaw: 0
|
||||
Roll: 0
|
||||
Width: 1920
|
||||
Height: 1080
|
||||
Width: 1319
|
||||
Height: 622
|
||||
Near: 0.00999999978
|
||||
Far: 10000
|
||||
Perspective: true
|
||||
FOV: 90
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 4
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace SHADE
|
|||
{
|
||||
|
||||
SHCanvasComponent::SHCanvasComponent()
|
||||
:width(1),height(1), dirtyMatrix(false), canvasMatrix()
|
||||
:width(1), height(1), dirtyMatrix(false), canvasMatrix(), scaleByCanvasWidth(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ namespace SHADE
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SHCanvasComponent::CanvasSizeType SHCanvasComponent::GetCanvasWidth() const noexcept
|
||||
{
|
||||
return width;
|
||||
|
@ -43,6 +45,8 @@ namespace SHADE
|
|||
return canvasMatrix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,6 +58,7 @@ RTTR_REGISTRATION
|
|||
registration::class_<SHCanvasComponent>("Canvas Component")
|
||||
.property("Canvas Width", &SHCanvasComponent::GetCanvasWidth, &SHCanvasComponent::SetCanvasWidth)
|
||||
.property("Canvas Height", &SHCanvasComponent::GetCanvasHeight, &SHCanvasComponent::SetCanvasHeight)
|
||||
.property("Scale by canvas width", &SHCanvasComponent::scaleByCanvasWidth)
|
||||
;
|
||||
|
||||
|
||||
|
|
|
@ -21,15 +21,18 @@ namespace SHADE
|
|||
|
||||
SHCanvasComponent();
|
||||
~SHCanvasComponent() = default;
|
||||
bool scaleByCanvasWidth;
|
||||
|
||||
void SetCanvasSize(CanvasSizeType width, CanvasSizeType height) noexcept;
|
||||
void SetCanvasWidth(CanvasSizeType width) noexcept;
|
||||
void SetCanvasHeight(CanvasSizeType height) noexcept;
|
||||
|
||||
|
||||
CanvasSizeType GetCanvasWidth() const noexcept;
|
||||
CanvasSizeType GetCanvasHeight() const noexcept;
|
||||
SHMatrix const& GetMatrix() const noexcept;
|
||||
|
||||
|
||||
private:
|
||||
CanvasSizeType width;
|
||||
CanvasSizeType height;
|
||||
|
|
|
@ -131,8 +131,17 @@ namespace SHADE
|
|||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
SHVec2 camSize = cameraSystem->GetCameraWidthHeight(0);
|
||||
comp.canvasMatrix = SHMatrix::Identity;
|
||||
comp.canvasMatrix(0, 0) = camSize.x * 0.5f / (comp.GetCanvasWidth() * 0.5f);
|
||||
comp.canvasMatrix(1, 1) = camSize.y * 0.5f / (comp.GetCanvasHeight() * 0.5f);
|
||||
float scale = camSize.y / comp.GetCanvasHeight();
|
||||
if (comp.scaleByCanvasWidth)
|
||||
{
|
||||
scale = camSize.x / comp.GetCanvasWidth();
|
||||
}
|
||||
|
||||
comp.canvasMatrix(0, 0) = scale;
|
||||
comp.canvasMatrix(1, 1) = scale;
|
||||
|
||||
//comp.canvasMatrix(0, 0) = camSize.x * 0.5f / (comp.GetCanvasWidth() * 0.5f);
|
||||
//comp.canvasMatrix(1, 1) = camSize.y * 0.5f / (comp.GetCanvasHeight() * 0.5f);
|
||||
}
|
||||
|
||||
void SHUISystem::UpdateCanvasMatrixRoutine::Execute(double dt) noexcept
|
||||
|
|
Loading…
Reference in New Issue