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/ JSON/Schemas/Catalog/
Assets/Editor/Editor.SHConfig Assets/Editor/Editor.SHConfig
Assets/Editor/Layouts/UserLayout.ini

View File

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

View File

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

View File

@ -15,7 +15,7 @@
- EID: 1 - EID: 1
Name: Canvas Name: Canvas
IsActive: true IsActive: true
NumberOfChildren: 1 NumberOfChildren: 3
Components: Components:
Canvas Component: Canvas Component:
Canvas Width: 1920 Canvas Width: 1920
@ -23,7 +23,7 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 2 - EID: 2
Name: Default Name: Back Ground
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -36,7 +36,61 @@
Mesh: 141771688 Mesh: 141771688
Material: 123313564 Material: 123313564
IsActive: true IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts: ~ 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 - EID: 3
Name: Camera Name: Camera
IsActive: true IsActive: true

View File

@ -1,7 +1,7 @@
- EID: 0 - EID: 0
Name: Canvas Name: Canvas
IsActive: true IsActive: true
NumberOfChildren: 1 NumberOfChildren: 3
Components: Components:
Canvas Component: Canvas Component:
Canvas Width: 1920 Canvas Width: 1920
@ -9,7 +9,7 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 1 - EID: 1
Name: Default Name: Background
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -22,7 +22,61 @@
Mesh: 141771688 Mesh: 141771688
Material: 121834459 Material: 121834459
IsActive: true IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts: ~ 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 - EID: 2
Name: Light Name: Light
IsActive: true IsActive: true

View File

@ -15,7 +15,7 @@
- EID: 1 - EID: 1
Name: Canvas Name: Canvas
IsActive: true IsActive: true
NumberOfChildren: 1 NumberOfChildren: 3
Components: Components:
Canvas Component: Canvas Component:
Canvas Width: 1920 Canvas Width: 1920
@ -23,7 +23,7 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 2 - EID: 2
Name: Default Name: Background
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -37,6 +37,51 @@
Material: 129138332 Material: 129138332
IsActive: true IsActive: true
Scripts: ~ 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 - EID: 3
Name: Camera Name: Camera
IsActive: true 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() void main()
{ {
fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
if (fragColor.a < 0.01f)
{
discard;
}
outEntityID = In2.eid; 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> /// </summary>
public void Invoke() public void Invoke()
{ {
foreach (CallbackAction action in actions) for (int i = 0; i < actions.Count; ++i)
{ {
try try
{ {
var action = actions[i] as CallbackAction;
action.Invoke(); action.Invoke();
} }
catch (Exception e) catch (Exception e)
@ -203,10 +204,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1) public void Invoke(T1 t1)
{ {
foreach (CallbackAction<T1> action in actions) for (int i = 0; i < actions.Count; ++i)
{ {
try try
{ {
var action = actions[i] as CallbackAction<T1>;
action.Invoke(t1); action.Invoke(t1);
} }
catch (Exception e) catch (Exception e)
@ -289,10 +291,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1, T2 t2) public void Invoke(T1 t1, T2 t2)
{ {
foreach (CallbackAction<T1, T2> action in actions) for (int i = 0; i < actions.Count; ++i)
{ {
try try
{ {
var action = actions[i] as CallbackAction<T1, T2>;
action.Invoke(t1, t2); action.Invoke(t1, t2);
} }
catch (Exception e) catch (Exception e)
@ -375,10 +378,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3) 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 try
{ {
var action = actions[i] as CallbackAction<T1, T2, T3>;
action.Invoke(t1, t2, t3); action.Invoke(t1, t2, t3);
} }
catch (Exception e) catch (Exception e)
@ -461,10 +465,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4) 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 try
{ {
var action = actions[i] as CallbackAction<T1, T2, T3, T4>;
action.Invoke(t1, t2, t3, t4); action.Invoke(t1, t2, t3, t4);
} }
catch (Exception e) catch (Exception e)
@ -547,10 +552,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) 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 try
{ {
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5>;
action.Invoke(t1, t2, t3, t4, t5); action.Invoke(t1, t2, t3, t4, t5);
} }
catch (Exception e) catch (Exception e)
@ -633,10 +639,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) 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 try
{ {
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6>;
action.Invoke(t1, t2, t3, t4, t5, t6); action.Invoke(t1, t2, t3, t4, t5, t6);
} }
catch (Exception e) catch (Exception e)
@ -719,10 +726,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) 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 try
{ {
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6, T7>;
action.Invoke(t1, t2, t3, t4, t5, t6, t7); action.Invoke(t1, t2, t3, t4, t5, t6, t7);
} }
catch (Exception e) catch (Exception e)
@ -805,10 +813,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) 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 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); action.Invoke(t1, t2, t3, t4, t5, t6, t7, t8);
} }
catch (Exception e) catch (Exception e)
@ -891,10 +900,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9) 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 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); action.Invoke(t1, t2, t3, t4, t5, t6, t7, t8, t9);
} }
catch (Exception e) catch (Exception e)
@ -977,10 +987,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10) 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 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); action.Invoke(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
} }
catch (Exception e) catch (Exception e)

View File

@ -134,10 +134,11 @@ namespace SHADE
/// </summary> /// </summary>
public void Invoke(<# if (i != 0) { for (int t = 1; t < i + 1; ++t) { #>T<#=t#> t<#=t#><# if (t != i) { #>, <# } #><# } } #>) 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 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) { #>, <# } #><# } #>); action.Invoke(<# for (int t = 1; t < i + 1; ++t) { #>t<#=t#><# if (t != i) { #>, <# } #><# } #>);
} }
catch (Exception e) catch (Exception e)

View File

@ -199,7 +199,7 @@ namespace SHADE
// Check material usage // Check material usage
for (const auto& rendId : sb.Renderables) for (const auto& rendId : sb.Renderables)
{ {
auto rend = SHComponentManager::GetComponent<SHRenderable>(rendId); auto rend = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (rend) if (rend)
{ {
if (rend->GetMaterial() == matToCheck) if (rend->GetMaterial() == matToCheck)
@ -210,7 +210,7 @@ namespace SHADE
} }
else else
{ {
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!"); SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
} }
} }
} }
@ -292,14 +292,14 @@ namespace SHADE
for (auto& subBatch : subBatches) for (auto& subBatch : subBatches)
for (auto rendId : subBatch.Renderables) for (auto rendId : subBatch.Renderables)
{ {
const SHRenderable* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId); const SHRenderable* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable) if (renderable)
{ {
renderable->GetMaterial()->ExportProperties(propsCurrPtr); renderable->GetMaterial()->ExportProperties(propsCurrPtr);
} }
else else
{ {
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!"); SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
} }
//propsCurrPtr += singleMatPropAlignedSize; //propsCurrPtr += singleMatPropAlignedSize;
propsCurrPtr += singleMatPropSize; propsCurrPtr += singleMatPropSize;
@ -328,7 +328,7 @@ namespace SHADE
for (auto rendId : subBatch.Renderables) for (auto rendId : subBatch.Renderables)
{ {
// Transform // Transform
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(rendId); auto transform = SHComponentManager::GetComponent_s<SHTransformComponent>(rendId);
if (transform) if (transform)
{ {
if (SHSceneManager::CheckNodeAndComponentsActive<SHRenderable>(rendId)) if (SHSceneManager::CheckNodeAndComponentsActive<SHRenderable>(rendId))
@ -357,7 +357,7 @@ namespace SHADE
} }
else 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(); transformData.emplace_back();
} }
} }
@ -382,13 +382,16 @@ namespace SHADE
for (auto& subBatch : subBatches) for (auto& subBatch : subBatches)
for (auto rendId : subBatch.Renderables) for (auto rendId : subBatch.Renderables)
{ {
auto* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId); auto* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable)
{
instancedIntegerData.emplace_back(SHInstancedIntegerData instancedIntegerData.emplace_back(SHInstancedIntegerData
{ {
rendId, rendId,
renderable->GetLightLayer() renderable->GetLightLayer()
}); });
} }
}
// Transfer to GPU // Transfer to GPU
if (instancedIntegerBuffer[frameIndex] && !drawData.empty()) if (instancedIntegerBuffer[frameIndex] && !drawData.empty())
@ -575,17 +578,21 @@ namespace SHADE
} }
else 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(); transformData.emplace_back();
} }
const SHRenderable* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId); const SHRenderable* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable)
{
instancedIntegerData.emplace_back(SHInstancedIntegerData instancedIntegerData.emplace_back(SHInstancedIntegerData
{ {
rendId, rendId,
renderable->GetLightLayer() renderable->GetLightLayer()
} }
); );
}
// Material Properties // Material Properties
if (!EMPTY_MAT_PROPS) if (!EMPTY_MAT_PROPS)
@ -596,7 +603,7 @@ namespace SHADE
} }
else else
{ {
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!"); SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
} }
propsCurrPtr += singleMatPropSize; propsCurrPtr += singleMatPropSize;
} }

View File

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

View File

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

View File

@ -1,12 +1,13 @@
#include "SHpch.h" #include "SHpch.h"
#include "SHButtonComponent.h" #include "SHButtonComponent.h"
#include "Resource/SHResourceManager.h"
#include "Graphics/MiddleEnd/Textures/SHTextureLibrary.h"
namespace SHADE namespace SHADE
{ {
SHButtonComponent::SHButtonComponent() SHButtonComponent::SHButtonComponent()
:size(1.0f), isHovered(false), isClicked(false), :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 hoveredTexture;
AssetID clickedTexture; AssetID clickedTexture;
AssetID currentTexture;
RTTR_ENABLE() RTTR_ENABLE()
}; };

View File

@ -6,7 +6,7 @@ namespace SHADE
{ {
SHToggleButtonComponent::SHToggleButtonComponent() SHToggleButtonComponent::SHToggleButtonComponent()
:size(1.0f), isHovered(false), isClicked(false), value(false), :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 defaultTexture;
AssetID toggledTexture; AssetID toggledTexture;
AssetID currentTexture;
RTTR_ENABLE() RTTR_ENABLE()

View File

@ -28,6 +28,8 @@ namespace SHADE
SHComponentManager::CreateComponentSparseSet<SHCanvasComponent>(); SHComponentManager::CreateComponentSparseSet<SHCanvasComponent>();
SHComponentManager::CreateComponentSparseSet<SHUIComponent>(); SHComponentManager::CreateComponentSparseSet<SHUIComponent>();
SHComponentManager::CreateComponentSparseSet<SHButtonComponent>(); SHComponentManager::CreateComponentSparseSet<SHButtonComponent>();
SHComponentManager::CreateComponentSparseSet<SHToggleButtonComponent>();
SHComponentManager::CreateComponentSparseSet<SHSliderComponent>();
} }
void SHUISystem::Exit() void SHUISystem::Exit()
@ -234,18 +236,23 @@ namespace SHADE
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID()); auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture()); //auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
if(!comp.isHovered && !comp.isClicked) AssetID textureID = 0;
if (!comp.isHovered && !comp.isClicked)
{
if (comp.GetDefaultTexture() != 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE) 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") //SHLOG_INFO("SETTING DEFAULT TEXTURE")
} }
}
else if (comp.isClicked) else if (comp.isClicked)
{ {
if (comp.GetClickedTexture() != 0 && SHAssetManager::GetType(comp.GetClickedTexture()) == AssetType::TEXTURE) 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") //SHLOG_INFO("SETTING CLICKED TEXTURE")
} }
} }
@ -253,10 +260,17 @@ namespace SHADE
{ {
if (comp.GetHoveredTexture() != 0 && SHAssetManager::GetType(comp.GetHoveredTexture()) == AssetType::TEXTURE) 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") //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 cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
auto uiComp = SHComponentManager::GetComponent<SHUIComponent>(comp.GetEID()); 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 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); 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,9 +295,9 @@ namespace SHADE
SHVec2 topExtent{ topExtent4.x,topExtent4.y }; SHVec2 topExtent{ topExtent4.x,topExtent4.y };
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y }; SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
SHVec2 mousePos; SHVec2 mousePos;
SHVec2 windowSize; SHVec2 windowSize;
#ifdef SHEDITOR #ifdef SHEDITOR
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->beginContentRegionAvailable; windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->beginContentRegionAvailable;
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos; mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
@ -305,21 +320,20 @@ namespace SHADE
#endif #endif
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) }; SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) };
//SHLOG_INFO("TopExtent: {}, {}", topExtent.x, topExtent.y)
topExtent = CanvasToScreenPoint(topExtent, true);
topExtent = CanvasToScreenPoint(topExtent,true);
btmExtent = CanvasToScreenPoint(btmExtent, 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 if (mousePos.x >= topExtent.x && mousePos.x <= btmExtent.x
&& mousePos.y >= topExtent.y && mousePos.y <= btmExtent.y) && mousePos.y >= topExtent.y && mousePos.y <= btmExtent.y)
{ {
comp.isHovered = true; comp.isHovered = true;
#ifdef SHEDITOR #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)) if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB))
{ {
@ -332,20 +346,20 @@ namespace SHADE
comp.isClicked = true; comp.isClicked = true;
} }
#endif #endif
//SHLOG_INFO("HOVERED")
} }
else else
{ {
comp.isHovered = false; comp.isHovered = false;
//SHLOG_INFO("NOT HOVERED")
} }
if (comp.isClicked && SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB)) if (comp.isClicked && SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
{ {
comp.isClicked = false; comp.isClicked = false;
comp.value = !comp.value; comp.value = !comp.value;
SHButtonClickEvent clickEvent; SHButtonClickEvent clickEvent;
clickEvent.EID = comp.GetEID(); clickEvent.EID = comp.GetEID();
clickEvent.value = comp.value;
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_CLICK_EVENT); SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_CLICK_EVENT);
} }
@ -354,12 +368,14 @@ namespace SHADE
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID()); auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture()); //auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial(); //auto material = renderable->GetModifiableMaterial();
AssetID textureID = 0;
if (comp.GetValue() == false) if (comp.GetValue() == false)
{ {
if (comp.GetDefaultTexture()!= 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE) 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") //SHLOG_INFO("SETTING DEFAULT TEXTURE")
} }
} }
@ -367,11 +383,20 @@ namespace SHADE
{ {
if (comp.GetToggledTexture() != 0 && SHAssetManager::GetType(comp.GetToggledTexture()) == AssetType::TEXTURE) 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") //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" filter "configurations:Debug"
symbols "On" symbols "On"
defines {"_DEBUG"} defines {"_DEBUG", "SHEDITOR"}
links{"librttr_core_d.lib"} links{"librttr_core_d.lib"}
links{"fmodstudioL_vc.lib", "fmodL_vc.lib"} links{"fmodstudioL_vc.lib", "fmodL_vc.lib"}
filter "configurations:Release" filter "configurations:Release"
optimize "On" optimize "On"
defines{"_RELEASE"} defines{"_RELEASE", "SHEDITOR"}
links{"librttr_core.lib"} links{"librttr_core.lib"}
links{"fmodstudio_vc.lib", "fmod_vc.lib"} links{"fmodstudio_vc.lib", "fmod_vc.lib"}
filter "configurations:Publish" filter "configurations:Publish"
optimize "On" optimize "On"
defines{"_RELEASE"} defines{"_RELEASE", "_PUBLISH"}
links{"librttr_core.lib"} links{"librttr_core.lib"}
links{"fmodstudio_vc.lib", "fmod_vc.lib"} links{"fmodstudio_vc.lib", "fmod_vc.lib"}