diff --git a/Assets/Materials/UI/UIMat_Black.shmat b/Assets/Materials/UI/UIMat_Black.shmat new file mode 100644 index 00000000..183b5f26 --- /dev/null +++ b/Assets/Materials/UI/UIMat_Black.shmat @@ -0,0 +1,8 @@ +- VertexShader: 46580970 + FragmentShader: 50110174 + SubPass: UI + Properties: + data.color: {x: 0, y: 0, z: 0, w: 1} + data.textureIndex: 0 + data.alpha: 0 + data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UI/UIMat_Black.shmat.shmeta b/Assets/Materials/UI/UIMat_Black.shmat.shmeta new file mode 100644 index 00000000..caac5feb --- /dev/null +++ b/Assets/Materials/UI/UIMat_Black.shmat.shmeta @@ -0,0 +1,3 @@ +Name: UIMat_Black +ID: 120016136 +Type: 7 diff --git a/Assets/Scenes/Level1.shade b/Assets/Scenes/Level1.shade index e06548c0..3aca2ae6 100644 --- a/Assets/Scenes/Level1.shade +++ b/Assets/Scenes/Level1.shade @@ -5289,4 +5289,40 @@ Components: ~ Scripts: - Type: SHADE_Scripting.UI.TweenManager - Enabled: true \ No newline at end of file + Enabled: true +- EID: 461 + Name: TransitionCanvas + IsActive: true + NumberOfChildren: 1 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: true + Scripts: ~ +- EID: 459 + Name: Transition + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1920, y: 1080, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 120016136 + IsActive: true + UI Component: + Canvas ID: 461 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SceneFadeInOut + Enabled: true + alphaValue: 1 + fadeInTime: 0.5 + fadeOutTime: 0.5 \ No newline at end of file diff --git a/Assets/Scenes/Level2.shade b/Assets/Scenes/Level2.shade index 47b32e34..f0c33b5b 100644 --- a/Assets/Scenes/Level2.shade +++ b/Assets/Scenes/Level2.shade @@ -13297,4 +13297,40 @@ Mesh: 136373407 Material: 131956078 IsActive: true - Scripts: ~ \ No newline at end of file + Scripts: ~ +- EID: 174 + Name: TransitionCanvas + IsActive: true + NumberOfChildren: 1 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: true + Scripts: ~ +- EID: 173 + Name: Transition + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1920, y: 1080, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 120016136 + IsActive: true + UI Component: + Canvas ID: 174 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SceneFadeInOut + Enabled: true + alphaValue: 1 + fadeInTime: 0.5 + fadeOutTime: 0.5 \ No newline at end of file diff --git a/Assets/Scenes/LoseScene.shade b/Assets/Scenes/LoseScene.shade index 501c203f..bd9d45c3 100644 --- a/Assets/Scenes/LoseScene.shade +++ b/Assets/Scenes/LoseScene.shade @@ -20,6 +20,7 @@ Canvas Component: Canvas Width: 1920 Canvas Height: 1080 + Scale by canvas width: false IsActive: true Scripts: ~ - EID: 2 @@ -28,7 +29,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 0, z: 0} + Translate: {x: 0, y: 0, z: 0.5} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 1920, y: 1080, z: 1} IsActive: true @@ -38,6 +39,8 @@ IsActive: true UI Component: Canvas ID: 1 + Hovered: false + Clicked: false IsActive: true Scripts: ~ - EID: 5 @@ -46,7 +49,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 75, z: 0} + Translate: {x: 0, y: 75, z: 0.400000006} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 400, y: 200, z: 1} IsActive: true @@ -61,6 +64,8 @@ IsActive: true UI Component: Canvas ID: 1 + Hovered: false + Clicked: false IsActive: true Scripts: - Type: ChangeSceneButton @@ -72,7 +77,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: -200, z: 0} + Translate: {x: 0, y: -200, z: 0.400000006} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 400, y: 200, z: 1} IsActive: true @@ -87,6 +92,8 @@ IsActive: true UI Component: Canvas ID: 1 + Hovered: false + Clicked: false IsActive: true Scripts: - Type: QuitButton @@ -107,10 +114,10 @@ Yaw: 0 Roll: 0 Width: 1920 - Height: 1080 Near: 0.00999999978 Far: 10000 Perspective: true + FOV: 90 IsActive: true Scripts: ~ - EID: 4 @@ -122,4 +129,40 @@ - Type: EndScene Enabled: true mainGameScene: 86098106 - mainMainScene: 97158628 \ No newline at end of file + mainMainScene: 97158628 +- EID: 7 + Name: TransitionCanvas + IsActive: true + NumberOfChildren: 1 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: true + Scripts: ~ +- EID: 8 + Name: Transition + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1920, y: 1080, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 120016136 + IsActive: true + UI Component: + Canvas ID: 7 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SceneFadeInOut + Enabled: true + alphaValue: 1 + fadeInTime: 0.5 + fadeOutTime: 0.5 \ No newline at end of file diff --git a/Assets/Scenes/MainMenu.shade b/Assets/Scenes/MainMenu.shade index a2a5dd1c..946e7a8d 100644 --- a/Assets/Scenes/MainMenu.shade +++ b/Assets/Scenes/MainMenu.shade @@ -216,12 +216,12 @@ Components: Transform Component: Translate: {x: 0, y: 0, z: 0} - Rotate: {x: 0, y: 0, z: 3.14159274} - Scale: {x: 1920, y: 500, z: 1} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} IsActive: false Renderable Component: - Mesh: 141771688 - Material: 129138332 + Mesh: 0 + Material: 0 IsActive: false UI Component: Canvas ID: 0 @@ -1087,4 +1087,40 @@ Hovered: false Clicked: false IsActive: true - Scripts: ~ \ No newline at end of file + Scripts: ~ +- EID: 55 + Name: Transition Canvas + IsActive: true + NumberOfChildren: 1 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: true + Scripts: ~ +- EID: 56 + Name: Transition + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0.100000001} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1920, y: 1080, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 120016136 + IsActive: true + UI Component: + Canvas ID: 55 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SceneFadeInOut + Enabled: true + alphaValue: 1 + fadeInTime: 0.5 + fadeOutTime: 0.5 \ No newline at end of file diff --git a/Assets/Scenes/WinScene.shade b/Assets/Scenes/WinScene.shade index 0727860e..57096086 100644 --- a/Assets/Scenes/WinScene.shade +++ b/Assets/Scenes/WinScene.shade @@ -20,6 +20,7 @@ Canvas Component: Canvas Width: 1920 Canvas Height: 1080 + Scale by canvas width: false IsActive: true Scripts: ~ - EID: 2 @@ -28,7 +29,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 0, z: 0} + Translate: {x: 0, y: 0, z: 0.5} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 1920, y: 1080, z: 1} IsActive: true @@ -38,6 +39,8 @@ IsActive: true UI Component: Canvas ID: 1 + Hovered: false + Clicked: false IsActive: true Scripts: ~ - EID: 5 @@ -46,7 +49,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 75, z: 0} + Translate: {x: 0, y: 75, z: 0.400000006} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 400, y: 200, z: 1} IsActive: true @@ -61,6 +64,8 @@ IsActive: true UI Component: Canvas ID: 1 + Hovered: false + Clicked: false IsActive: true Scripts: - Type: ChangeSceneButton @@ -72,7 +77,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: -200, z: 0} + Translate: {x: 0, y: -200, z: 0.400000006} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 400, y: 200, z: 1} IsActive: true @@ -87,6 +92,8 @@ IsActive: true UI Component: Canvas ID: 1 + Hovered: false + Clicked: false IsActive: true Scripts: - Type: QuitButton @@ -107,7 +114,6 @@ Yaw: 0 Roll: 0 Width: 1920 - Height: 1080 Near: 0.00999999978 Far: 10000 Perspective: true @@ -123,4 +129,40 @@ - Type: EndScene Enabled: true mainGameScene: 86098106 - mainMainScene: 97158628 \ No newline at end of file + mainMainScene: 97158628 +- EID: 7 + Name: TransitionCanvas + IsActive: true + NumberOfChildren: 1 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: true + Scripts: ~ +- EID: 8 + Name: Transition + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0.100000001} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1920, y: 1080, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 120016136 + IsActive: true + UI Component: + Canvas ID: 7 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.SceneFadeInOut + Enabled: true + alphaValue: 1 + fadeInTime: 0.5 + fadeOutTime: 0.5 \ No newline at end of file diff --git a/Assets/Scripts/Audio/AudioHandler.cs b/Assets/Scripts/Audio/AudioHandler.cs index c6067819..4743b4c5 100644 --- a/Assets/Scripts/Audio/AudioHandler.cs +++ b/Assets/Scripts/Audio/AudioHandler.cs @@ -12,7 +12,7 @@ namespace SHADE_Scripting.Audio public static Dictionary audioClipHandlers = new Dictionary(); //Functions here, maybe - public static void stopAllSounds(bool fadeOut) + public static void StopAllSounds(bool fadeOut) { foreach (KeyValuePair h in audioClipHandlers) { @@ -20,7 +20,7 @@ namespace SHADE_Scripting.Audio } } - public static void pauseAllSounds(bool pause) + public static void PauseAllSounds(bool pause) { foreach (KeyValuePair h in audioClipHandlers) { diff --git a/Assets/Scripts/Gameplay/SC_GameManager.cs b/Assets/Scripts/Gameplay/SC_GameManager.cs index 1cebe002..3746ec0c 100644 --- a/Assets/Scripts/Gameplay/SC_GameManager.cs +++ b/Assets/Scripts/Gameplay/SC_GameManager.cs @@ -1,5 +1,6 @@ using SHADE; using SHADE_Scripting.Audio; +using SHADE_Scripting.UI; using System; using System.Collections.Generic; @@ -43,6 +44,10 @@ public class GameManager : Script public bool itemShatter { get; set; } + //For scene transitions + private bool goingToWin; + private bool goingToLose; + protected override void awake() { if (Instance != null && Instance != this) @@ -61,11 +66,13 @@ public class GameManager : Script AudioHandler.audioClipHandlers["BGMWin"] = Audio.CreateAudioClip("event:/Music/stingers/game_win"); AudioHandler.audioClipHandlers["BGMLose"] = Audio.CreateAudioClip("event:/Music/stingers/game_lose"); + + goingToWin = false; + goingToLose = false; } protected override void start() { - AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive"); AudioHandler.audioClipHandlers["BGMAdaptive"].Play(); @@ -113,21 +120,34 @@ public class GameManager : Script //multiplierText.GetComponent().LocalScale = Vector3.Zero; } - if ((timer > 0 && totalItemCount <= 0 && !itemShatter) || Input.GetKeyDown(Input.KeyCode.F1)) + if (!goingToLose && ((timer > 0 && totalItemCount <= 0 && !itemShatter) || Input.GetKeyDown(Input.KeyCode.F1))) { currGameState = GameState.WIN; - AudioHandler.stopAllSounds(false); + AudioHandler.StopAllSounds(false); AudioHandler.audioClipHandlers["BGMWin"].Play(); - SceneManager.ChangeScene(winScene); - + goingToWin = true; + SceneFadeInOut.Instance.CallFadeIn(); } - else if(timer < 0 || Input.GetKeyDown(Input.KeyCode.F2)) + else if(!goingToWin && (timer < 0 || Input.GetKeyDown(Input.KeyCode.F2))) { currGameState = GameState.LOSE; - AudioHandler.stopAllSounds(false); + AudioHandler.StopAllSounds(false); AudioHandler.audioClipHandlers["BGMLose"].Play(); + goingToLose = true; + SceneFadeInOut.Instance.CallFadeIn(); + } + } + + //Handling transitions + if (SceneFadeInOut.Instance.FadeInFinished()) + { + if (goingToWin) + { + SceneManager.ChangeScene(winScene); + } + if (goingToLose) + { SceneManager.ChangeScene(loseScene); - } } } diff --git a/Assets/Scripts/UI/SC_ChangeSceneButton.cs b/Assets/Scripts/UI/SC_ChangeSceneButton.cs index c0629d0a..6a51716b 100644 --- a/Assets/Scripts/UI/SC_ChangeSceneButton.cs +++ b/Assets/Scripts/UI/SC_ChangeSceneButton.cs @@ -1,10 +1,19 @@ using System; +using System.Reflection.Metadata.Ecma335; using SHADE; +using SHADE_Scripting.UI; public class ChangeSceneButton : Script { public uint sceneID = 0; - + + //Whether the scene changing button has been clicked + private bool clickedFlag; + + protected override void awake() + { + clickedFlag = false; + } protected override void start() { @@ -17,8 +26,11 @@ public class ChangeSceneButton : Script if (sceneID != 0) { Audio.PlaySFXOnce2D("event:/UI/success"); - SceneManager.ChangeScene(sceneID); + Audio.StopAllSounds(); + + SceneFadeInOut.Instance.CallFadeIn(); + clickedFlag = true; } }); } @@ -30,6 +42,9 @@ public class ChangeSceneButton : Script } protected override void update() { - + if (clickedFlag && sceneID != 0 && SceneFadeInOut.Instance.FadeInFinished()) + { + SceneManager.ChangeScene(sceneID); + } } } diff --git a/Assets/Scripts/UI/SC_EndScene.cs b/Assets/Scripts/UI/SC_EndScene.cs index b934e2bd..2117b24a 100644 --- a/Assets/Scripts/UI/SC_EndScene.cs +++ b/Assets/Scripts/UI/SC_EndScene.cs @@ -23,7 +23,7 @@ public class EndScene : Script { //Audio.PlaySFXOnce2D("event:/UI/success"); //Audio.StopAllSounds(); - AudioHandler.stopAllSounds(false); + AudioHandler.StopAllSounds(false); AudioHandler.audioClipHandlers["SFXUISuccess"].Play(); SceneManager.ChangeScene(mainGameScene); } @@ -37,7 +37,7 @@ public class EndScene : Script { //Audio.PlaySFXOnce2D("event:/UI/success"); //Audio.StopAllSounds(); - AudioHandler.stopAllSounds(false); + AudioHandler.StopAllSounds(false); AudioHandler.audioClipHandlers["SFXUISuccess"].Play(); SceneManager.ChangeScene(mainMainScene); } diff --git a/Assets/Scripts/UI/SC_PauseMenu.cs b/Assets/Scripts/UI/SC_PauseMenu.cs index 521b48ea..71e2b8c3 100644 --- a/Assets/Scripts/UI/SC_PauseMenu.cs +++ b/Assets/Scripts/UI/SC_PauseMenu.cs @@ -39,7 +39,7 @@ public class PauseMenu : Script if (GameManager.Instance.GamePause) { GameManager.Instance.GamePause = false; - AudioHandler.pauseAllSounds(false); + AudioHandler.PauseAllSounds(false); if (gamePauseText) gamePauseText.GetComponent().Enabled = false; if (canvas) @@ -89,7 +89,7 @@ public class PauseMenu : Script if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause) { GameManager.Instance.GamePause = true; - AudioHandler.pauseAllSounds(true); + AudioHandler.PauseAllSounds(true); if (gamePauseText) gamePauseText.GetComponent().Enabled = true; if (canvas) diff --git a/Assets/Scripts/UI/SC_SceneFadeInOut.cs b/Assets/Scripts/UI/SC_SceneFadeInOut.cs new file mode 100644 index 00000000..5c6ebb77 --- /dev/null +++ b/Assets/Scripts/UI/SC_SceneFadeInOut.cs @@ -0,0 +1,118 @@ +using SHADE; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SHADE_Scripting.UI +{ + public class SceneFadeInOut : Script + { + //[Tooltip("If true, the panel fadeUI fades in (increasing alpha). If false, no fading. Mutually exclusive with fadeIn")] + private bool fadeIn; + + //[Tooltip("If true, the panel fadeUI fades out (decreasing alpha). If false, no fading. Mutually exclusive with fadeIn")] + private bool fadeOut; + + [Tooltip("The initial alpha value of the UI that is faded. Between 0 and 1 inclusive.")] + public float alphaValue; + + [SerializeField] + private float fadeInTime; + + [SerializeField] + private float fadeOutTime; + + private Renderable fadeR; + + public static SceneFadeInOut Instance { get; private set; } + + protected override void awake() + { + if (Instance != null && Instance != this) + RemoveScript(); + else + Instance = this; + + fadeR = GameObject.GetComponent(); + fadeR.Material.SetProperty("data.alpha", alphaValue); + //alphaValue = fadeR.Material.GetProperty("data.alpha"); + } + + protected override void start() + { + CallFadeOut(); + } + + protected override void update() + { + if (fadeR != null) + { + if (fadeIn) //fading in + { + fadeOut = false; + if (fadeInTime == 0.0f) + { + alphaValue = 1.0f; + } + else + { + alphaValue += (1.0f / fadeInTime) * Time.DeltaTimeF; + } + if (alphaValue >= 1.0f) alphaValue = 1.0f; + } + + if (fadeOut) //fading out + { + fadeIn = false; + if (fadeOutTime == 0.0f) + { + alphaValue = 0.0f; + } + else + { + alphaValue -= (1.0f / fadeOutTime) * Time.DeltaTimeF; + } + if (alphaValue <= 0.0f) alphaValue = 0.0f; + } + + fadeR.Material.SetProperty("data.alpha", alphaValue); + } + } + + protected override void onDestroy() + { + if (Instance == this) + Instance = null; + } + + public void CallFadeIn() + { + fadeIn = true; + fadeOut = false; + } + + public void CallFadeOut() + { + fadeOut = true; + fadeIn = false; + } + + public void CallFadeStop() + { + fadeOut = false; + fadeIn = false; + } + + public bool FadeOutFinished() + { + return (alphaValue <= 0.0f); + } + + public bool FadeInFinished() + { + return (alphaValue >= 1.0f); + } + } +} diff --git a/Assets/Scripts/UI/SC_SceneFadeInOut.cs.shmeta b/Assets/Scripts/UI/SC_SceneFadeInOut.cs.shmeta new file mode 100644 index 00000000..ddebe65c --- /dev/null +++ b/Assets/Scripts/UI/SC_SceneFadeInOut.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_SceneFadeInOut +ID: 153328192 +Type: 9 diff --git a/Assets/Shaders/UI_Black_FS.glsl b/Assets/Shaders/UI_Black_FS.glsl new file mode 100644 index 00000000..84664ede --- /dev/null +++ b/Assets/Shaders/UI_Black_FS.glsl @@ -0,0 +1,49 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable +#extension GL_EXT_nonuniform_qualifier : require + +struct MatPropData +{ + vec4 color; + int textureIndex; + float alpha; +}; + +layout(location = 0) in struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + +} In; + +// material stuff +layout(location = 3) flat in struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; +} In2; + +layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials +{ + MatPropData data[]; +} MatProp; + +layout(location = 0) out vec4 fragColor; +layout(location = 1) out uint outEntityID; + +void main() +{ + fragColor = MatProp.data[In2.materialIndex].color; + if (fragColor.a < 0.01f) + { + discard; + } + fragColor.a = MatProp.data[In2.materialIndex].alpha; + + // fragColor.a = 1.0f; + outEntityID = In2.eid; +} \ No newline at end of file diff --git a/Assets/Shaders/UI_Black_FS.shshaderb b/Assets/Shaders/UI_Black_FS.shshaderb new file mode 100644 index 00000000..17a072c9 Binary files /dev/null and b/Assets/Shaders/UI_Black_FS.shshaderb differ diff --git a/Assets/Shaders/UI_Black_FS.shshaderb.shmeta b/Assets/Shaders/UI_Black_FS.shshaderb.shmeta new file mode 100644 index 00000000..b5429d75 --- /dev/null +++ b/Assets/Shaders/UI_Black_FS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: UI_Black_FS +ID: 50110174 +Type: 2 diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index 3ebcc904..5620e258 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -174,7 +174,6 @@ namespace Sandbox SHSceneManager::InitSceneManager(editorConfig.workingSceneID); #else SHSceneManager::InitSceneManager(appConfig.startingSceneID); - window.SetMouseVisible(false); #endif SHFrameRateController::UpdateFRC(); @@ -183,7 +182,6 @@ namespace Sandbox auto clip = SHResourceManager::LoadOrGet(77816045); auto rig = SHResourceManager::LoadOrGet(77816045); - int i = 0; } void SBApplication::Update(void) diff --git a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp index 8cc41d56..8f0a8193 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp @@ -31,6 +31,8 @@ #include "../AssetBrowser/SHAssetBrowser.h" #include "Assets/SHAssetManager.h" #include "Assets/Asset Types/SHPrefabAsset.h" +#include "Camera/SHCameraSystem.h" +#include "FRC/SHFramerateController.h" namespace SHADE @@ -442,7 +444,24 @@ namespace SHADE //Handle node selection 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()) + { + if(auto editorCam = camSystem->GetEditorCamera()) + { + if(auto entityTransform = SHComponentManager::GetComponent_s(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) { diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index ee853623..af03ffa6 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -387,14 +387,14 @@ namespace SHADE } 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" }, - [&collisionShape] + [collisionShape] { auto offset = collisionShape->GetRotationOffset(); return offset; }, - [&collisionShape](SHVec3 const& vec) + [collisionShape](SHVec3 const& vec) { collisionShape->SetRotationOffset(vec); }, true); diff --git a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp index d0c71265..6072c6a8 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp @@ -157,16 +157,16 @@ namespace SHADE if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags)) { auto camSystem = SHSystemManager::GetSystem(); - std::string editorCamPosText{}; + std::string editorCamPosText{}, editorRotText{}; auto editorCam = camSystem->GetEditorCamera(); if(editorCam) { auto editorCamPos = editorCam->GetPosition(); 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("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(editorCam) @@ -186,6 +186,20 @@ namespace SHADE auto editorCamPos = editorCam->GetPosition(); 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(); } diff --git a/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp b/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp index 13d9c143..078d9fc8 100644 --- a/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp +++ b/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp @@ -183,10 +183,22 @@ namespace SHADE 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) { - if (GetActiveWindow() == wndHWND) - ShowCursor(show); + ShowCursor(show); } void SHWindow::SetMousePosition(int x, int y) diff --git a/SHADE_Engine/src/Graphics/Windowing/SHWindow.h b/SHADE_Engine/src/Graphics/Windowing/SHWindow.h index 530f1778..9ad48f28 100644 --- a/SHADE_Engine/src/Graphics/Windowing/SHWindow.h +++ b/SHADE_Engine/src/Graphics/Windowing/SHWindow.h @@ -104,7 +104,8 @@ namespace SHADE //Get size of display the window is in (whichever window contains the window origin) WindowSize GetCurrentDisplaySize() const; - void SetMouseVisible(bool show); + static bool GetMouseVisible(); + static void SetMouseVisible(bool show); void SetMousePosition(int x = -1, int y = -1); diff --git a/SHADE_Managed/src/Engine/Application.cxx b/SHADE_Managed/src/Engine/Application.cxx index 5bde66d2..ba0cb592 100644 --- a/SHADE_Managed/src/Engine/Application.cxx +++ b/SHADE_Managed/src/Engine/Application.cxx @@ -71,7 +71,14 @@ namespace SHADE { return SHGraphicsSystemInterface::SetFullscreen(value); }*/ - + bool Application::IsCursorVisible::get() + { + return SHWindow::GetMouseVisible(); + } + void Application::IsCursorVisible::set(bool value) + { + SHWindow::SetMouseVisible(value); + } /*---------------------------------------------------------------------------------*/ /* Usage Functions */ /*---------------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Engine/Application.hxx b/SHADE_Managed/src/Engine/Application.hxx index 4467ec3b..6e04b725 100644 --- a/SHADE_Managed/src/Engine/Application.hxx +++ b/SHADE_Managed/src/Engine/Application.hxx @@ -73,6 +73,12 @@ namespace SHADE //void set(bool value); } + static property bool IsCursorVisible + { + bool get(); + void set(bool value); + } + /*-----------------------------------------------------------------------------*/ /* Usage Functions */ /*-----------------------------------------------------------------------------*/