Merge branch 'main' into SP3-141-Camera-System

This commit is contained in:
maverickdgg 2023-02-04 00:43:41 +08:00
commit 81d63f9776
84 changed files with 418 additions and 81 deletions

1
.gitignore vendored
View File

@ -366,3 +366,4 @@ MigrationBackup/
JSON/Schemas/Catalog/
Assets/Editor/Editor.SHConfig
Assets/Editor/Layouts/UserLayout.ini

View File

@ -1,4 +1,4 @@
Start Maximized: true
Working Scene ID: 87244611
Working Scene ID: 91685359
Window Size: {x: 1920, y: 1013}
Style: 0

View File

@ -3,6 +3,6 @@
SubPass: UI
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 54429632
data.textureIndex: 51995224
data.alpha: 0
data.beta: {x: 1, y: 1, z: 1}

View File

@ -15,7 +15,7 @@
- EID: 1
Name: Canvas
IsActive: true
NumberOfChildren: 1
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
@ -23,7 +23,7 @@
IsActive: true
Scripts: ~
- EID: 2
Name: Default
Name: Back Ground
IsActive: true
NumberOfChildren: 0
Components:
@ -36,7 +36,61 @@
Mesh: 141771688
Material: 123313564
IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts: ~
- EID: 5
Name: Main Menu Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 65788519
Hovered Texture: 55999018
Clicked Texture: 66382894
IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 97158628
- EID: 6
Name: Quit Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts:
- Type: QuitButton
Enabled: true
- EID: 3
Name: Camera
IsActive: true

View File

@ -1,7 +1,7 @@
- EID: 0
Name: Canvas
IsActive: true
NumberOfChildren: 1
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
@ -9,7 +9,7 @@
IsActive: true
Scripts: ~
- EID: 1
Name: Default
Name: Background
IsActive: true
NumberOfChildren: 0
Components:
@ -22,7 +22,61 @@
Mesh: 141771688
Material: 121834459
IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts: ~
- EID: 5
Name: Start Game Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 52901020
Hovered Texture: 62235279
Clicked Texture: 64722619
IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 96668835
- EID: 6
Name: Quit Game Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts:
- Type: QuitButton
Enabled: true
- EID: 2
Name: Light
IsActive: true

View File

@ -15,7 +15,7 @@
- EID: 1
Name: Canvas
IsActive: true
NumberOfChildren: 1
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
@ -23,7 +23,7 @@
IsActive: true
Scripts: ~
- EID: 2
Name: Default
Name: Background
IsActive: true
NumberOfChildren: 0
Components:
@ -37,6 +37,51 @@
Material: 129138332
IsActive: true
Scripts: ~
- EID: 5
Name: Main Menu Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 65788519
Hovered Texture: 55999018
Clicked Texture: 66382894
IsActive: true
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 97158628
- EID: 6
Name: Quit Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
Scripts:
- Type: QuitButton
Enabled: true
- EID: 3
Name: Camera
IsActive: true

View File

@ -0,0 +1,33 @@
using System;
using SHADE;
public class ChangeSceneButton : Script
{
public uint sceneID = 0;
protected override void start()
{
UIElement ui = GetComponent<UIElement>();
if (ui != null)
{
ui.OnClick.RegisterAction(() =>
{
if (sceneID != 0)
{
Audio.PlaySFXOnce2D("event:/UI/success");
SceneManager.ChangeScene(sceneID);
Audio.StopAllSounds();
}
});
}
else
{
Debug.LogError("Failed to register button action for ChangeSceneButton.");
}
}
protected override void update()
{
}
}

View File

@ -0,0 +1,3 @@
Name: SC_ChangeSceneButton
ID: 155329160
Type: 9

View File

@ -0,0 +1,31 @@
using System;
using SHADE;
public class QuitButton : Script
{
protected override void start()
{
UIElement ui = GetComponent<UIElement>();
if (ui != null)
{
ui.OnClick.RegisterAction(() =>
{
ui.OnClick.RegisterAction(() =>
{
Audio.StopAllSounds();
Application.Quit();
});
});
}
else
{
Debug.LogError("Failed to register button action for QuitButton.");
}
}
protected override void update()
{
}
}

View File

@ -0,0 +1,3 @@
Name: SC_QuitButton
ID: 163136401
Type: 9

View File

@ -39,5 +39,10 @@ layout(location = 1) out uint outEntityID;
void main()
{
fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
if (fragColor.a < 0.01f)
{
discard;
}
outEntityID = In2.eid;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: howToPlay_default
ID: 65084899
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: howToPlay_hover
ID: 58647112
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: howToPlay_pressed
ID: 55758383
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: mainMenu_default
ID: 65788519
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: mainMenu_hover
ID: 55999018
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: mainMenu_pressed
ID: 66382894
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: quit_default
ID: 66477839
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: quit_hover
ID: 65045286
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: quit_pressed
ID: 58607560
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: retry_default
ID: 55782622
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: retry_hover
ID: 58972174
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: retry_pressed
ID: 55224464
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: settings_default
ID: 58593104
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: settings_hover
ID: 64495732
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: settings_pressed
ID: 63138015
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: startGame_default
ID: 52901020
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: startGame_hover
ID: 62235279
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: startGame_pressed
ID: 64722619
Type: 3

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -117,10 +117,11 @@ namespace SHADE
/// </summary>
public void Invoke()
{
foreach (CallbackAction action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction;
action.Invoke();
}
catch (Exception e)
@ -203,10 +204,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1)
{
foreach (CallbackAction<T1> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1>;
action.Invoke(t1);
}
catch (Exception e)
@ -289,10 +291,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2)
{
foreach (CallbackAction<T1, T2> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2>;
action.Invoke(t1, t2);
}
catch (Exception e)
@ -375,10 +378,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3)
{
foreach (CallbackAction<T1, T2, T3> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3>;
action.Invoke(t1, t2, t3);
}
catch (Exception e)
@ -461,10 +465,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4)
{
foreach (CallbackAction<T1, T2, T3, T4> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4>;
action.Invoke(t1, t2, t3, t4);
}
catch (Exception e)
@ -547,10 +552,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
{
foreach (CallbackAction<T1, T2, T3, T4, T5> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5>;
action.Invoke(t1, t2, t3, t4, t5);
}
catch (Exception e)
@ -633,10 +639,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6>;
action.Invoke(t1, t2, t3, t4, t5, t6);
}
catch (Exception e)
@ -719,10 +726,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6, T7> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6, T7>;
action.Invoke(t1, t2, t3, t4, t5, t6, t7);
}
catch (Exception e)
@ -805,10 +813,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8>;
action.Invoke(t1, t2, t3, t4, t5, t6, t7, t8);
}
catch (Exception e)
@ -891,10 +900,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9>;
action.Invoke(t1, t2, t3, t4, t5, t6, t7, t8, t9);
}
catch (Exception e)
@ -977,10 +987,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>;
action.Invoke(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
}
catch (Exception e)

View File

@ -134,10 +134,11 @@ namespace SHADE
/// </summary>
public void Invoke(<# if (i != 0) { for (int t = 1; t < i + 1; ++t) { #>T<#=t#> t<#=t#><# if (t != i) { #>, <# } #><# } } #>)
{
foreach (CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #>;
action.Invoke(<# for (int t = 1; t < i + 1; ++t) { #>t<#=t#><# if (t != i) { #>, <# } #><# } #>);
}
catch (Exception e)

View File

@ -199,7 +199,7 @@ namespace SHADE
// Check material usage
for (const auto& rendId : sb.Renderables)
{
auto rend = SHComponentManager::GetComponent<SHRenderable>(rendId);
auto rend = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (rend)
{
if (rend->GetMaterial() == matToCheck)
@ -210,7 +210,7 @@ namespace SHADE
}
else
{
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!");
SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
}
}
}
@ -290,20 +290,20 @@ namespace SHADE
// Build CPU Buffer
char* propsCurrPtr = matPropsData.get();
for (auto& subBatch : subBatches)
for (auto rendId : subBatch.Renderables)
for (auto rendId : subBatch.Renderables)
{
const SHRenderable* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable)
{
const SHRenderable* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId);
if (renderable)
{
renderable->GetMaterial()->ExportProperties(propsCurrPtr);
}
else
{
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!");
}
//propsCurrPtr += singleMatPropAlignedSize;
propsCurrPtr += singleMatPropSize;
renderable->GetMaterial()->ExportProperties(propsCurrPtr);
}
else
{
SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
}
//propsCurrPtr += singleMatPropAlignedSize;
propsCurrPtr += singleMatPropSize;
}
// Transfer to GPU
rebuildDescriptorSetBuffers(frameIndex, descPool);
@ -328,7 +328,7 @@ namespace SHADE
for (auto rendId : subBatch.Renderables)
{
// Transform
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(rendId);
auto transform = SHComponentManager::GetComponent_s<SHTransformComponent>(rendId);
if (transform)
{
if (SHSceneManager::CheckNodeAndComponentsActive<SHRenderable>(rendId))
@ -357,7 +357,7 @@ namespace SHADE
}
else
{
SHLOG_WARNING("[SHBatch] Entity contianing a SHRenderable with no SHTransformComponent found!");
SHLOG_WARNING("[SHBatch] Entity #{} containing a SHRenderable with no SHTransformComponent found!", rendId);
transformData.emplace_back();
}
}
@ -382,12 +382,15 @@ namespace SHADE
for (auto& subBatch : subBatches)
for (auto rendId : subBatch.Renderables)
{
auto* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId);
instancedIntegerData.emplace_back(SHInstancedIntegerData
auto* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable)
{
rendId,
renderable->GetLightLayer()
});
instancedIntegerData.emplace_back(SHInstancedIntegerData
{
rendId,
renderable->GetLightLayer()
});
}
}
// Transfer to GPU
@ -575,17 +578,21 @@ namespace SHADE
}
else
{
SHLOG_WARNING("[SHBatch] Entity contianing a SHRenderable with no SHTransformComponent found!");
SHLOG_WARNING("[SHBatch] Entity #{} contianing a SHRenderable with no SHTransformComponent found!", rendId);
transformData.emplace_back();
}
const SHRenderable* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId);
instancedIntegerData.emplace_back(SHInstancedIntegerData
{
rendId,
renderable->GetLightLayer()
}
);
const SHRenderable* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable)
{
instancedIntegerData.emplace_back(SHInstancedIntegerData
{
rendId,
renderable->GetLightLayer()
}
);
}
// Material Properties
if (!EMPTY_MAT_PROPS)
@ -596,7 +603,7 @@ namespace SHADE
}
else
{
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!");
SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
}
propsCurrPtr += singleMatPropSize;
}

View File

@ -1065,7 +1065,7 @@ namespace SHADE
for (auto& renderable : renderables)
{
// Check if the material instance is now unused
renderable.CleanUpMaterials();
renderable.CleanUpMaterials();
if (!renderable.HasChanged())
continue;

View File

@ -99,6 +99,8 @@ namespace SHADE
{
SHGraphicsSystem* gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
material = gfxSystem->AddMaterialInstanceCopy(sharedMaterial);
oldMaterial = sharedMaterial;
oldMatIsShared = true;
matChanged = true;
}

View File

@ -205,6 +205,7 @@ namespace SHADE
AddComponentToComponentNode<SHTextRenderableComponent>(components, eid);
AddComponentToComponentNode<SHAnimatorComponent>(components, eid);
AddComponentToComponentNode<SHUIComponent>(components, eid);
node[ComponentsNode] = components;
@ -263,6 +264,7 @@ namespace SHADE
AddComponentID<SHToggleButtonComponent>(componentIDList, componentsNode);
AddComponentID<SHTextRenderableComponent>(componentIDList, componentsNode);
AddComponentID<SHAnimatorComponent>(componentIDList, componentsNode);
AddComponentID<SHUIComponent>(componentIDList, componentsNode);
return componentIDList;
}
@ -347,5 +349,6 @@ namespace SHADE
SHSerializationHelper::InitializeComponentFromNode<SHTextRenderableComponent>(componentsNode, eid);
SHSerializationHelper::InitializeComponentFromNode<SHLightComponent>(componentsNode, eid);
SHSerializationHelper::InitializeComponentFromNode<SHAnimatorComponent>(componentsNode, eid);
SHSerializationHelper::InitializeComponentFromNode<SHUIComponent>(componentsNode, eid);
}
}

View File

@ -1,12 +1,13 @@
#include "SHpch.h"
#include "SHButtonComponent.h"
#include "Resource/SHResourceManager.h"
#include "Graphics/MiddleEnd/Textures/SHTextureLibrary.h"
namespace SHADE
{
SHButtonComponent::SHButtonComponent()
:size(1.0f), isHovered(false), isClicked(false),
defaultTexture(0), hoveredTexture(0), clickedTexture(0)
defaultTexture(0), hoveredTexture(0), clickedTexture(0), currentTexture(0)
{
}

View File

@ -41,6 +41,8 @@ namespace SHADE
AssetID hoveredTexture;
AssetID clickedTexture;
AssetID currentTexture;
RTTR_ENABLE()
};

View File

@ -6,7 +6,7 @@ namespace SHADE
{
SHToggleButtonComponent::SHToggleButtonComponent()
:size(1.0f), isHovered(false), isClicked(false), value(false),
defaultTexture(0), toggledTexture(0)
defaultTexture(0), toggledTexture(0), currentTexture(0)
{
}

View File

@ -42,6 +42,8 @@ namespace SHADE
AssetID defaultTexture;
AssetID toggledTexture;
AssetID currentTexture;
RTTR_ENABLE()

View File

@ -28,6 +28,8 @@ namespace SHADE
SHComponentManager::CreateComponentSparseSet<SHCanvasComponent>();
SHComponentManager::CreateComponentSparseSet<SHUIComponent>();
SHComponentManager::CreateComponentSparseSet<SHButtonComponent>();
SHComponentManager::CreateComponentSparseSet<SHToggleButtonComponent>();
SHComponentManager::CreateComponentSparseSet<SHSliderComponent>();
}
void SHUISystem::Exit()
@ -234,18 +236,23 @@ namespace SHADE
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
if(!comp.isHovered && !comp.isClicked)
if (comp.GetDefaultTexture() != 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
AssetID textureID = 0;
if (!comp.isHovered && !comp.isClicked)
{
material->SetProperty("data.textureIndex", comp.GetDefaultTexture());
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
if (comp.GetDefaultTexture() != 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
{
textureID = comp.GetDefaultTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
}
else if (comp.isClicked)
{
if (comp.GetClickedTexture() != 0 && SHAssetManager::GetType(comp.GetClickedTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetClickedTexture());
textureID = comp.GetClickedTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetClickedTexture()));
//SHLOG_INFO("SETTING CLICKED TEXTURE")
}
}
@ -253,10 +260,17 @@ namespace SHADE
{
if (comp.GetHoveredTexture() != 0 && SHAssetManager::GetType(comp.GetHoveredTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetHoveredTexture());
textureID = comp.GetHoveredTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>( comp.GetHoveredTexture()));
//SHLOG_INFO("SETTING HOVERED TEXTURE")
}
}
if (textureID != 0 && textureID != comp.currentTexture)
{
auto material = renderable->GetModifiableMaterial();
comp.currentTexture = textureID;
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
}
@ -272,6 +286,7 @@ namespace SHADE
}
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
auto uiComp = SHComponentManager::GetComponent<SHUIComponent>(comp.GetEID());
//auto canvasComp = SHComponentManager::GetComponent_s<SHCanvasComponent>(uiComp->canvasID);
SHVec4 topExtent4 = SHMatrix::Translate(-comp.size.x * 0.5f, comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f);
SHVec4 btmExtent4 = SHMatrix::Translate(comp.size.x * 0.5f, -comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f);
@ -280,15 +295,15 @@ namespace SHADE
SHVec2 topExtent{ topExtent4.x,topExtent4.y };
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
SHVec2 mousePos;
SHVec2 windowSize;
#ifdef SHEDITOR
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->beginContentRegionAvailable;
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
//mousePos.y = windowSize.y - mousePos.y;
//SHLOG_INFO("mouse pos: {}, {}", mousePos.x, mousePos.y)
mousePos /= windowSize;
mousePos /= windowSize;
//SHLOG_INFO("mouse pos normalized: {}, {}", mousePos.x, mousePos.y)
@ -305,21 +320,20 @@ namespace SHADE
#endif
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) };
//SHLOG_INFO("TopExtent: {}, {}", topExtent.x, topExtent.y)
topExtent = CanvasToScreenPoint(topExtent,true);
topExtent = CanvasToScreenPoint(topExtent, true);
btmExtent = CanvasToScreenPoint(btmExtent, true);
//SHLOG_INFO("TopExtent: {}, {} Btm Extent: {}, {}", topExtent.x, topExtent.y, btmExtent.x, btmExtent.y)
comp.isClicked = false;
//comp.isClicked = false;
if (mousePos.x >= topExtent.x && mousePos.x <= btmExtent.x
&& mousePos.y >= topExtent.y && mousePos.y <= btmExtent.y)
{
comp.isHovered = true;
#ifdef SHEDITOR
if (SHSystemManager::GetSystem<SHEditor>()->editorState == SHEditor::State::PLAY)
//if (SHSystemManager::GetSystem<SHEditor>()->editorState == SHEditor::State::PLAY)
{
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB))
{
@ -330,22 +344,22 @@ namespace SHADE
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB))
{
comp.isClicked = true;
}
}
#endif
}
//SHLOG_INFO("HOVERED")
}
else
{
comp.isHovered = false;
//SHLOG_INFO("NOT HOVERED")
}
if (comp.isClicked && SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
{
comp.isClicked = false;
comp.value = !comp.value;
SHButtonClickEvent clickEvent;
clickEvent.EID = comp.GetEID();
clickEvent.value = comp.value;
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_CLICK_EVENT);
}
@ -354,12 +368,14 @@ namespace SHADE
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
//auto material = renderable->GetModifiableMaterial();
AssetID textureID = 0;
if (comp.GetValue() == false)
{
if (comp.GetDefaultTexture()!= 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetDefaultTexture());
textureID = comp.GetDefaultTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
}
@ -367,11 +383,20 @@ namespace SHADE
{
if (comp.GetToggledTexture() != 0 && SHAssetManager::GetType(comp.GetToggledTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetToggledTexture());
textureID = comp.GetToggledTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetToggledTexture()));
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
}
if (textureID != 0 && textureID != comp.currentTexture)
{
auto material = renderable->GetModifiableMaterial();
comp.currentTexture = textureID;
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
}
}
}

View File

@ -103,19 +103,19 @@ project "SHADE_Managed"
filter "configurations:Debug"
symbols "On"
defines {"_DEBUG"}
defines {"_DEBUG", "SHEDITOR"}
links{"librttr_core_d.lib"}
links{"fmodstudioL_vc.lib", "fmodL_vc.lib"}
filter "configurations:Release"
optimize "On"
defines{"_RELEASE"}
defines{"_RELEASE", "SHEDITOR"}
links{"librttr_core.lib"}
links{"fmodstudio_vc.lib", "fmod_vc.lib"}
filter "configurations:Publish"
optimize "On"
defines{"_RELEASE"}
defines{"_RELEASE", "_PUBLISH"}
links{"librttr_core.lib"}
links{"fmodstudio_vc.lib", "fmod_vc.lib"}