|
|
|
@ -149,9 +149,9 @@ namespace SHADE
|
|
|
|
|
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 topExtent{ topExtent4.x,topExtent4.y };
|
|
|
|
|
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
|
|
|
|
|
//SHLOG_INFO("TopExtent: {}, {}", topExtent.x, topExtent.y);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SHVec2 windowSize;
|
|
|
|
@ -160,23 +160,24 @@ namespace SHADE
|
|
|
|
|
|
|
|
|
|
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->windowSize;
|
|
|
|
|
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//SHLOG_INFO("MousePos: {}, {}", mousePos.x, mousePos.y);
|
|
|
|
|
//mousePos /= windowSize;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0).x , cameraSystem->GetCameraWidthHeight(0).y };
|
|
|
|
|
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0)};
|
|
|
|
|
|
|
|
|
|
topExtent += camSize * 0.5f;
|
|
|
|
|
btmExtent += camSize * 0.5f;
|
|
|
|
|
topExtent = CanvasToScreenPoint(topExtent);
|
|
|
|
|
btmExtent = CanvasToScreenPoint(btmExtent);
|
|
|
|
|
|
|
|
|
|
//SHLOG_INFO("TopExtent Screen Point: {}, {}, Cam size: {}, {}", topExtent.x, topExtent.y, camSize.x, camSize.y);
|
|
|
|
|
|
|
|
|
|
//Convert everything to using ratios
|
|
|
|
|
topExtent /= camSize;
|
|
|
|
|
btmExtent /= camSize;
|
|
|
|
|
//topExtent /= camSize;
|
|
|
|
|
//btmExtent /= camSize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mousePos /= windowSize;
|
|
|
|
|
|
|
|
|
|
//SHLOG_INFO("mousePos: {} , {}", mousePos.x, mousePos.y);
|
|
|
|
|
comp.isClicked = false;
|
|
|
|
@ -187,6 +188,7 @@ namespace SHADE
|
|
|
|
|
if (SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
|
|
|
|
|
{
|
|
|
|
|
comp.isClicked = true;
|
|
|
|
|
//SHLOG_INFO("BUTTON CLICKED");
|
|
|
|
|
}
|
|
|
|
|
//SHLOG_INFO("BUTTON HOVERED");
|
|
|
|
|
|
|
|
|
@ -202,11 +204,11 @@ namespace SHADE
|
|
|
|
|
|
|
|
|
|
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
|
|
|
|
|
{
|
|
|
|
|
//auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
|
|
|
|
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
|
|
|
|
|
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
|
|
|
|
auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
|
|
|
|
|
|
|
|
|
|
//auto material = renderable->GetModifiableMaterial();
|
|
|
|
|
//material->SetProperty("texture", comp.GetDefaultTexture());
|
|
|
|
|
auto material = renderable->GetModifiableMaterial();
|
|
|
|
|
material->SetProperty("texture", comp.GetDefaultTexture());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -221,4 +223,22 @@ namespace SHADE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SHVec2 SHUISystem::CanvasToScreenPoint(SHVec2& const canvasPoint) noexcept
|
|
|
|
|
{
|
|
|
|
|
SHVec2 result{canvasPoint};
|
|
|
|
|
|
|
|
|
|
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
|
|
|
|
|
|
|
|
|
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.y *= -1.0f;
|
|
|
|
|
result += camSize * 0.5f;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//end namespace
|
|
|
|
|