Added scripting interface for cursor visible. #377
|
@ -174,7 +174,6 @@ namespace Sandbox
|
||||||
SHSceneManager::InitSceneManager<SBMainScene>(editorConfig.workingSceneID);
|
SHSceneManager::InitSceneManager<SBMainScene>(editorConfig.workingSceneID);
|
||||||
#else
|
#else
|
||||||
SHSceneManager::InitSceneManager<SBMainScene>(appConfig.startingSceneID);
|
SHSceneManager::InitSceneManager<SBMainScene>(appConfig.startingSceneID);
|
||||||
window.SetMouseVisible(false);
|
|
||||||
#endif
|
#endif
|
||||||
SHFrameRateController::UpdateFRC();
|
SHFrameRateController::UpdateFRC();
|
||||||
|
|
||||||
|
@ -183,7 +182,6 @@ namespace Sandbox
|
||||||
|
|
||||||
auto clip = SHResourceManager::LoadOrGet<SHAnimationClip>(77816045);
|
auto clip = SHResourceManager::LoadOrGet<SHAnimationClip>(77816045);
|
||||||
auto rig = SHResourceManager::LoadOrGet<SHRig>(77816045);
|
auto rig = SHResourceManager::LoadOrGet<SHRig>(77816045);
|
||||||
int i = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBApplication::Update(void)
|
void SBApplication::Update(void)
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include "../AssetBrowser/SHAssetBrowser.h"
|
#include "../AssetBrowser/SHAssetBrowser.h"
|
||||||
#include "Assets/SHAssetManager.h"
|
#include "Assets/SHAssetManager.h"
|
||||||
#include "Assets/Asset Types/SHPrefabAsset.h"
|
#include "Assets/Asset Types/SHPrefabAsset.h"
|
||||||
|
#include "Camera/SHCameraSystem.h"
|
||||||
|
#include "FRC/SHFramerateController.h"
|
||||||
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
@ -442,7 +444,24 @@ namespace SHADE
|
||||||
//Handle node selection
|
//Handle node selection
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
{
|
{
|
||||||
if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||||
|
{
|
||||||
|
editor->selectedEntities.clear();
|
||||||
|
editor->selectedEntities.push_back(eid);
|
||||||
|
if(auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>())
|
||||||
|
{
|
||||||
|
if(auto editorCam = camSystem->GetEditorCamera())
|
||||||
|
{
|
||||||
|
if(auto entityTransform = SHComponentManager::GetComponent_s<SHTransformComponent>(eid))
|
||||||
|
{
|
||||||
|
editorCam->SetPosition(entityTransform->GetWorldPosition() + SHVec3(0.5f));
|
||||||
|
camSystem->CameraLookAt(*editorCam, entityTransform->GetWorldPosition());
|
||||||
|
camSystem->UpdateEditorCamera(SHFrameRateController::GetRawDeltaTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||||
{
|
{
|
||||||
if (!isSelected)
|
if (!isSelected)
|
||||||
{
|
{
|
||||||
|
|
|
@ -387,14 +387,14 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
SHEditorWidgets::BeginPanel("Offsets",{ ImGui::GetContentRegionAvail().x, 30.0f });
|
SHEditorWidgets::BeginPanel("Offsets",{ ImGui::GetContentRegionAvail().x, 30.0f });
|
||||||
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [&collisionShape] {return collisionShape->GetPositionOffset(); }, [&collisionShape](SHVec3 const& vec) {collisionShape->SetPositionOffset(vec); });
|
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [collisionShape] {return collisionShape->GetPositionOffset(); }, [collisionShape](SHVec3 const& vec) {collisionShape->SetPositionOffset(vec); });
|
||||||
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" },
|
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" },
|
||||||
[&collisionShape]
|
[collisionShape]
|
||||||
{
|
{
|
||||||
auto offset = collisionShape->GetRotationOffset();
|
auto offset = collisionShape->GetRotationOffset();
|
||||||
return offset;
|
return offset;
|
||||||
},
|
},
|
||||||
[&collisionShape](SHVec3 const& vec)
|
[collisionShape](SHVec3 const& vec)
|
||||||
{
|
{
|
||||||
collisionShape->SetRotationOffset(vec);
|
collisionShape->SetRotationOffset(vec);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
|
@ -157,16 +157,16 @@ namespace SHADE
|
||||||
if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags))
|
if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags))
|
||||||
{
|
{
|
||||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
std::string editorCamPosText{};
|
std::string editorCamPosText{}, editorRotText{};
|
||||||
auto editorCam = camSystem->GetEditorCamera();
|
auto editorCam = camSystem->GetEditorCamera();
|
||||||
if(editorCam)
|
if(editorCam)
|
||||||
{
|
{
|
||||||
auto editorCamPos = editorCam->GetPosition();
|
auto editorCamPos = editorCam->GetPosition();
|
||||||
editorCamPosText = std::format("Editor Cam [X: {:.3f}, Y: {:.3f}, Z: {:.3f}]", editorCamPos.x, editorCamPos.y, editorCamPos.z);
|
editorCamPosText = std::format("Editor Cam [X: {:.3f}, Y: {:.3f}, Z: {:.3f}]", editorCamPos.x, editorCamPos.y, editorCamPos.z);
|
||||||
|
editorRotText = std::format("[Pitch: {:.3f}, Yaw: {:.3f}, Roll: {:.3f}]", editorCam->GetPitch(), editorCam->GetYaw(), editorCam->GetRoll());
|
||||||
//ImGui::Text(editorCamPosText.data());
|
//ImGui::Text(editorCamPosText.data());
|
||||||
}
|
}
|
||||||
ImGui::Text("Entity count: %zu %s", SHEntityManager::GetEntityCount(), editorCamPosText.data());
|
ImGui::Text("Entity count: %zu | %s | %s", SHEntityManager::GetEntityCount(), editorCamPosText.data(), editorRotText.data());
|
||||||
if(ImGui::BeginPopupContextItem("EditorCamPosContext"))
|
if(ImGui::BeginPopupContextItem("EditorCamPosContext"))
|
||||||
{
|
{
|
||||||
if(editorCam)
|
if(editorCam)
|
||||||
|
@ -186,6 +186,20 @@ namespace SHADE
|
||||||
auto editorCamPos = editorCam->GetPosition();
|
auto editorCamPos = editorCam->GetPosition();
|
||||||
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.z));
|
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.z));
|
||||||
}
|
}
|
||||||
|
if (ImGui::Selectable("Copy Editor Cam Pitch"))
|
||||||
|
{
|
||||||
|
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCam->GetPitch()));
|
||||||
|
}
|
||||||
|
if (ImGui::Selectable("Copy Editor Cam Yaw"))
|
||||||
|
{
|
||||||
|
auto editorCamPos = editorCam->GetPosition();
|
||||||
|
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}",editorCam->GetYaw()));
|
||||||
|
}
|
||||||
|
if (ImGui::Selectable("Copy Editor Cam Roll"))
|
||||||
|
{
|
||||||
|
auto editorCamPos = editorCam->GetPosition();
|
||||||
|
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}",editorCam->GetRoll()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,10 +183,22 @@ namespace SHADE
|
||||||
return WindowSize(screenWidth, screenHeight);
|
return WindowSize(screenWidth, screenHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SHWindow::GetMouseVisible()
|
||||||
|
{
|
||||||
|
CURSORINFO cursorInfo{};
|
||||||
|
cursorInfo.cbSize = sizeof(cursorInfo);
|
||||||
|
BOOL result = GetCursorInfo(&cursorInfo);
|
||||||
|
if(!result)
|
||||||
|
{
|
||||||
|
auto error = GetLastError();
|
||||||
|
SHLOG_ERROR("SHWindow: Failed to get cursor info")
|
||||||
|
}
|
||||||
|
return cursorInfo.flags != 0;
|
||||||
|
}
|
||||||
|
|
||||||
void SHWindow::SetMouseVisible(bool show)
|
void SHWindow::SetMouseVisible(bool show)
|
||||||
{
|
{
|
||||||
if (GetActiveWindow() == wndHWND)
|
ShowCursor(show);
|
||||||
ShowCursor(show);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHWindow::SetMousePosition(int x, int y)
|
void SHWindow::SetMousePosition(int x, int y)
|
||||||
|
|
|
@ -104,7 +104,8 @@ namespace SHADE
|
||||||
//Get size of display the window is in (whichever window contains the window origin)
|
//Get size of display the window is in (whichever window contains the window origin)
|
||||||
WindowSize GetCurrentDisplaySize() const;
|
WindowSize GetCurrentDisplaySize() const;
|
||||||
|
|
||||||
void SetMouseVisible(bool show);
|
static bool GetMouseVisible();
|
||||||
|
static void SetMouseVisible(bool show);
|
||||||
|
|
||||||
void SetMousePosition(int x = -1, int y = -1);
|
void SetMousePosition(int x = -1, int y = -1);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,14 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
return SHGraphicsSystemInterface::SetFullscreen(value);
|
return SHGraphicsSystemInterface::SetFullscreen(value);
|
||||||
}*/
|
}*/
|
||||||
|
bool Application::IsCursorVisible::get()
|
||||||
|
{
|
||||||
|
return SHWindow::GetMouseVisible();
|
||||||
|
}
|
||||||
|
void Application::IsCursorVisible::set(bool value)
|
||||||
|
{
|
||||||
|
SHWindow::SetMouseVisible(value);
|
||||||
|
}
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -73,6 +73,12 @@ namespace SHADE
|
||||||
//void set(bool value);
|
//void set(bool value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static property bool IsCursorVisible
|
||||||
|
{
|
||||||
|
bool get();
|
||||||
|
void set(bool value);
|
||||||
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
|
Loading…
Reference in New Issue