Merge branch 'main' into SP3-8-serialization
This commit is contained in:
commit
49ef701994
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: Dangrek-Regular
|
||||
ID: 174412429
|
||||
Type: 10
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
- VertexShader: 46580970
|
||||
FragmentShader: 35983630
|
||||
SubPass: UI
|
||||
Properties:
|
||||
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||
data.textureIndex: 51158984
|
||||
data.alpha: 1
|
||||
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
|||
Name: GameIcon
|
||||
ID: 126117259
|
||||
Type: 7
|
|
@ -0,0 +1,8 @@
|
|||
- VertexShader: 46580970
|
||||
FragmentShader: 35983630
|
||||
SubPass: UI
|
||||
Properties:
|
||||
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||
data.textureIndex: 62200943
|
||||
data.alpha: 1
|
||||
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
|||
Name: Instruction_01
|
||||
ID: 124926341
|
||||
Type: 7
|
|
@ -0,0 +1,8 @@
|
|||
- VertexShader: 46580970
|
||||
FragmentShader: 35983630
|
||||
SubPass: UI
|
||||
Properties:
|
||||
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||
data.textureIndex: 53303669
|
||||
data.alpha: 1
|
||||
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
|||
Name: Instruction_02
|
||||
ID: 128721520
|
||||
Type: 7
|
|
@ -0,0 +1,8 @@
|
|||
- VertexShader: 46580970
|
||||
FragmentShader: 35983630
|
||||
SubPass: UI
|
||||
Properties:
|
||||
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||
data.textureIndex: 61780097
|
||||
data.alpha: 1
|
||||
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
|||
Name: Instruction_03
|
||||
ID: 124482180
|
||||
Type: 7
|
|
@ -0,0 +1,8 @@
|
|||
- VertexShader: 46580970
|
||||
FragmentShader: 35983630
|
||||
SubPass: UI
|
||||
Properties:
|
||||
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||
data.textureIndex: 59178524
|
||||
data.alpha: 1
|
||||
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
|||
Name: Instruction_04
|
||||
ID: 129768803
|
||||
Type: 7
|
|
@ -0,0 +1,12 @@
|
|||
- VertexShader: 46580970
|
||||
FragmentShader: 48832081
|
||||
SubPass: UI
|
||||
Properties:
|
||||
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||
data.textureIndex: 64651793
|
||||
data.alpha: 1
|
||||
data.beta: {x: 1, y: 1, z: 1}
|
||||
data.sliderThreshold: 1
|
||||
data.sliderStartColor: {x: 0, y: 1, z: 0, w: 1}
|
||||
data.sliderEndColor: {x: 1, y: 0, z: 0, w: 1}
|
||||
data.sliderBarColor: {x: 1, y: 1, z: 1, w: 1}
|
|
@ -0,0 +1,3 @@
|
|||
Name: UIMat_Slider
|
||||
ID: 128676209
|
||||
Type: 7
|
|
@ -4,5 +4,5 @@
|
|||
Properties:
|
||||
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||
data.textureIndex: 57302694
|
||||
data.alpha: 0
|
||||
data.alpha: 1
|
||||
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,9 @@
|
|||
- VertexShader: 46580970
|
||||
FragmentShader: 43211183
|
||||
SubPass: UI
|
||||
Properties:
|
||||
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||
data.textureIndex: 51995224
|
||||
data.alpha: 1
|
||||
data.beta: {x: 1, y: 1, z: 1}
|
||||
data.sliderThreshold: 1
|
|
@ -0,0 +1,3 @@
|
|||
Name: UIMat_Slider_Textured
|
||||
ID: 127128823
|
||||
Type: 7
|
|
@ -9591,27 +9591,14 @@
|
|||
gamePauseText: 11
|
||||
canvas: 10
|
||||
- EID: 199
|
||||
Name: =====Text====
|
||||
Name: Gameplay UI Canvas
|
||||
IsActive: true
|
||||
NumberOfChildren: 4
|
||||
Components: ~
|
||||
Scripts: ~
|
||||
- EID: 237
|
||||
Name: Score
|
||||
IsActive: true
|
||||
NumberOfChildren: 0
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: -800, y: 400, z: 0}
|
||||
Rotate: {x: 0, y: 0, z: 0}
|
||||
Scale: {x: 60, y: 60, z: 60}
|
||||
IsActive: true
|
||||
Text Renderer Component:
|
||||
Text: My name is Brandon.
|
||||
Font: 176667660
|
||||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 199
|
||||
Canvas Component:
|
||||
Canvas Width: 1920
|
||||
Canvas Height: 1080
|
||||
Scale by canvas width: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 206
|
||||
|
@ -9630,24 +9617,8 @@
|
|||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 199
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 139
|
||||
Name: Multiplier
|
||||
IsActive: true
|
||||
NumberOfChildren: 0
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: -800, y: 300, z: 0}
|
||||
Rotate: {x: 0, y: 0, z: 0}
|
||||
Scale: {x: 60, y: 60, z: 60}
|
||||
IsActive: true
|
||||
Text Renderer Component:
|
||||
Text: TEST
|
||||
Font: 176667660
|
||||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 199
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 11
|
||||
|
@ -9664,6 +9635,91 @@
|
|||
Text: Game Pause
|
||||
Font: 176667660
|
||||
IsActive: false
|
||||
UI Component:
|
||||
Canvas ID: 199
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 139
|
||||
Name: Multiplier Text
|
||||
IsActive: true
|
||||
NumberOfChildren: 1
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: -800, y: 300, z: 0}
|
||||
Rotate: {x: 0, y: 0, z: 0}
|
||||
Scale: {x: 60, y: 60.0000038, z: 60}
|
||||
IsActive: true
|
||||
Text Renderer Component:
|
||||
Text: TEST
|
||||
Font: 176667660
|
||||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 199
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 463
|
||||
Name: Multiplier BG
|
||||
IsActive: true
|
||||
NumberOfChildren: 0
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: 0.833334029, y: 0.416666061, z: 0}
|
||||
Rotate: {x: 0, y: 0, z: 0}
|
||||
Scale: {x: 5, y: 1.66666651, z: 0.0166666675}
|
||||
IsActive: true
|
||||
Renderable Component:
|
||||
Mesh: 141771688
|
||||
Material: 129340704
|
||||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 199
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 237
|
||||
Name: Score Text
|
||||
IsActive: true
|
||||
NumberOfChildren: 1
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: -770.099915, y: 419.999969, z: 0}
|
||||
Rotate: {x: 0, y: 0, z: 0}
|
||||
Scale: {x: 60.0000038, y: 60.0000038, z: 60}
|
||||
IsActive: true
|
||||
Text Renderer Component:
|
||||
Text: My name is Brandon.
|
||||
Font: 176667660
|
||||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 199
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 462
|
||||
Name: Score BG
|
||||
IsActive: true
|
||||
NumberOfChildren: 0
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: 0.334998131, y: 0.500000477, z: 0}
|
||||
Rotate: {x: 0, y: 0, z: 0}
|
||||
Scale: {x: 6.66666603, y: 1.66666651, z: 0.0166666675}
|
||||
IsActive: true
|
||||
Renderable Component:
|
||||
Mesh: 141771688
|
||||
Material: 129340704
|
||||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 199
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 198
|
||||
Name: ====Raccoon====
|
||||
|
@ -9765,7 +9821,6 @@
|
|||
Yaw: 360
|
||||
Roll: 1.28065994e-06
|
||||
Width: 1055
|
||||
Height: 604
|
||||
Near: 0.00999999978
|
||||
Far: 10000
|
||||
Perspective: true
|
||||
|
@ -10664,6 +10719,7 @@
|
|||
Canvas Component:
|
||||
Canvas Width: 1920
|
||||
Canvas Height: 1080
|
||||
Scale by canvas width: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 8
|
||||
|
@ -10687,6 +10743,8 @@
|
|||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 10
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 0
|
||||
|
@ -10710,6 +10768,8 @@
|
|||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 10
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 461
|
||||
|
@ -10733,5 +10793,7 @@
|
|||
IsActive: true
|
||||
UI Component:
|
||||
Canvas ID: 10
|
||||
Hovered: false
|
||||
Clicked: false
|
||||
IsActive: true
|
||||
Scripts: ~
|
File diff suppressed because it is too large
Load Diff
|
@ -100,7 +100,7 @@ public class GameManager : Script
|
|||
if (itemScored)
|
||||
{
|
||||
multiplierText.GetComponent<TextRenderable>().Text = $"X {currMultiplierCombo}";
|
||||
multiplierText.GetComponent<Transform>().LocalScale -= fontScalar * Time.DeltaTimeF;
|
||||
//multiplierText.GetComponent<Transform>().LocalScale -= fontScalar * Time.DeltaTimeF;
|
||||
currMultiplierDuration += Time.DeltaTimeF;
|
||||
|
||||
if (currMultiplierDuration >= maxMultiplierDuration)
|
||||
|
@ -113,7 +113,7 @@ public class GameManager : Script
|
|||
}
|
||||
else
|
||||
{
|
||||
multiplierText.GetComponent<Transform>().LocalScale = Vector3.Zero;
|
||||
//multiplierText.GetComponent<Transform>().LocalScale = Vector3.Zero;
|
||||
}
|
||||
|
||||
if ((timer > 0 && totalItemCount <= 0) || Input.GetKeyDown(Input.KeyCode.F1))
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SHADE_Scripting.UI
|
||||
{
|
||||
|
||||
public enum EASING_METHOD
|
||||
{
|
||||
EASE_IN_SINE,
|
||||
EASE_OUT_SINE,
|
||||
EASE_OUT_BOUNCE,
|
||||
EASE_IN_BOUNCE,
|
||||
EASE_INOUT_BOUNCE
|
||||
}
|
||||
|
||||
public static class EasingHelper
|
||||
{
|
||||
|
||||
public static float EaseHelp(float value, EASING_METHOD method)
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
case EASING_METHOD.EASE_IN_SINE:
|
||||
{
|
||||
return EaseInSine(value);
|
||||
}break;
|
||||
case EASING_METHOD.EASE_OUT_SINE:
|
||||
{
|
||||
return EaseOutSine(value);
|
||||
}break;
|
||||
case EASING_METHOD.EASE_OUT_BOUNCE:
|
||||
{
|
||||
return EaseOutBounce(value);
|
||||
}break;
|
||||
case EASING_METHOD.EASE_IN_BOUNCE:
|
||||
{
|
||||
return EaseInBounce(value);
|
||||
}
|
||||
break;
|
||||
case EASING_METHOD.EASE_INOUT_BOUNCE:
|
||||
{
|
||||
return EaseInOutBounce(value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
private static float EaseInSine(float value)
|
||||
{
|
||||
return (float)(1.0f - Math.Cos((value * Math.PI) / 2.0f));
|
||||
}
|
||||
|
||||
private static float EaseOutSine(float value)
|
||||
{
|
||||
return (float)(1.0f - Math.Sin(value * Math.PI) / 2.0f);
|
||||
}
|
||||
|
||||
|
||||
private static float EaseOutBounce(float value)
|
||||
{
|
||||
const float n1 = 7.5625f;
|
||||
const float d1 = 2.75f;
|
||||
if (value < 1.0f / d1)
|
||||
{
|
||||
return n1 * value * value;
|
||||
} else if (value < 2.0f / d1)
|
||||
{
|
||||
return n1 * (value -= 2.25f / d1) * value + 0.9375f;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n1 * (value -= 2.625f / d1) * value + 0.984375f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static float EaseInBounce(float value)
|
||||
{
|
||||
return 1 - EaseOutBounce(1 - value);
|
||||
}
|
||||
|
||||
|
||||
private static float EaseInOutBounce(float value)
|
||||
{
|
||||
return (value < 0.5f)
|
||||
?(1.0f - EaseOutBounce(1.0f - 2.0f * value)) / 2.0f
|
||||
: (1.0f + EaseOutBounce(2.0f * value - 1.0f)) / 2.0f;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Name: EasingHelper
|
||||
ID: 161000975
|
||||
Type: 9
|
|
@ -0,0 +1,123 @@
|
|||
using SHADE;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SHADE_Scripting.UI
|
||||
{
|
||||
public class ButtonFX:Script
|
||||
{
|
||||
public string onHoverEnterSound = "event:/Music/player_undetected";
|
||||
public string onHoverExitSound = "event:/Music/player_undetected";
|
||||
public string onClickSound = "event:/Music/player_undetected";
|
||||
public string onReleaseSound = "event:/Music/player_undetected";
|
||||
|
||||
[NonSerialized]
|
||||
private AudioClipHandler onHoverEnterACHandler;
|
||||
[NonSerialized]
|
||||
private AudioClipHandler onHoverExitACHandler;
|
||||
[NonSerialized]
|
||||
private AudioClipHandler onClickACHandler;
|
||||
[NonSerialized]
|
||||
private AudioClipHandler onReleaseACHandler;
|
||||
|
||||
[NonSerialized]
|
||||
private Vector3 defaultScale;
|
||||
|
||||
public float hoverScale = 1.1f;
|
||||
public float clickScale = 0.9f;
|
||||
|
||||
|
||||
[NonSerialized]
|
||||
private TweenThread thread;
|
||||
|
||||
[NonSerialized]
|
||||
private bool tweening = false;
|
||||
[NonSerialized]
|
||||
private float currentScale = 1.0f;
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
onHoverEnterACHandler = SHADE.Audio.CreateAudioClip(onHoverEnterSound);
|
||||
onHoverExitACHandler = SHADE.Audio.CreateAudioClip(onHoverExitSound);
|
||||
onClickACHandler = SHADE.Audio.CreateAudioClip(onClickSound);
|
||||
onReleaseACHandler = SHADE.Audio.CreateAudioClip(onReleaseSound);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void start()
|
||||
{
|
||||
thread = TweenManager.CreateTweenThread(0.1f, 0.9f, 1.0f, EASING_METHOD.EASE_IN_SINE);
|
||||
|
||||
|
||||
Transform transform = GetComponent<Transform>();
|
||||
if (transform == null)
|
||||
return;
|
||||
defaultScale = transform.LocalScale;
|
||||
|
||||
|
||||
UIElement ui = GetComponent<UIElement>();
|
||||
if (ui == null)
|
||||
return;
|
||||
|
||||
|
||||
ui.OnClick.RegisterAction(() =>
|
||||
{
|
||||
if (onClickSound != "")
|
||||
onClickACHandler.Play();
|
||||
tweening = true;
|
||||
if(thread != null)
|
||||
thread.Reset(currentScale,clickScale);
|
||||
});
|
||||
|
||||
ui.OnRelease.RegisterAction(() =>
|
||||
{
|
||||
if (onReleaseSound != "")
|
||||
onReleaseACHandler.Play();
|
||||
tweening = true;
|
||||
if (thread != null)
|
||||
thread.Reset(currentScale, 1.0f);
|
||||
});
|
||||
|
||||
ui.OnHoverEnter.RegisterAction(() =>
|
||||
{
|
||||
if (onHoverEnterSound != "")
|
||||
onHoverEnterACHandler.Play();
|
||||
tweening = true;
|
||||
if (thread != null)
|
||||
thread.Reset(currentScale, hoverScale);
|
||||
});
|
||||
|
||||
ui.OnHoverExit.RegisterAction(() =>
|
||||
{
|
||||
if (onHoverExitSound != "")
|
||||
onHoverExitACHandler.Play();
|
||||
tweening = true;
|
||||
if (thread != null)
|
||||
thread.Reset(currentScale, 1.0f);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected override void update()
|
||||
{
|
||||
Transform transform = GetComponent<Transform>();
|
||||
if (transform == null)
|
||||
return;
|
||||
if (tweening == true && thread != null)
|
||||
{
|
||||
Debug.Log("Tweening value " + thread.GetValue());
|
||||
transform.LocalScale = defaultScale * thread.GetValue();
|
||||
currentScale = thread.GetValue();
|
||||
if (thread.IsCompleted())
|
||||
tweening = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Name: SC_ButtonFX
|
||||
ID: 163796084
|
||||
Type: 9
|
|
@ -0,0 +1,42 @@
|
|||
using SHADE;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SHADE_Scripting.UI
|
||||
{
|
||||
public class ChangeCanvasButton:Script
|
||||
{
|
||||
|
||||
public GameObject canvasToActivate;
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
//if (canvasToActivate.GetComponent<Canvas>() == null)
|
||||
// return;
|
||||
UIElement ui = GetComponent<UIElement>();
|
||||
ui.OnRelease.RegisterAction(() =>
|
||||
{
|
||||
Canvas.DeactivateAllCanvas();
|
||||
|
||||
canvasToActivate.SetActive(true);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
protected override void start()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Name: SC_ChangeCanvasButton
|
||||
ID: 154633292
|
||||
Type: 9
|
|
@ -25,6 +25,7 @@ public class ChangeSceneButton : Script
|
|||
else
|
||||
{
|
||||
Debug.LogError("Failed to register button action for ChangeSceneButton.");
|
||||
|
||||
}
|
||||
}
|
||||
protected override void update()
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
using SHADE;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SHADE_Scripting.UI
|
||||
{
|
||||
public class MultiImageList:Script
|
||||
{
|
||||
public List<MaterialAsset> imageAssetList = new List<MaterialAsset>();
|
||||
[NonSerialized]
|
||||
private int index = 0;
|
||||
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void NextImage()
|
||||
{
|
||||
++index;
|
||||
if(index >= imageAssetList.Count())
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
Renderable rend = GetComponent<Renderable>();
|
||||
rend.SetMaterial(imageAssetList[index]);
|
||||
|
||||
}
|
||||
|
||||
public void PrevImage()
|
||||
{
|
||||
if (index == 0)
|
||||
index = imageAssetList.Count();
|
||||
--index;
|
||||
|
||||
Renderable rend = GetComponent<Renderable>();
|
||||
rend.SetMaterial(imageAssetList[index]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Name: SC_MultiImageList
|
||||
ID: 166320642
|
||||
Type: 9
|
|
@ -0,0 +1,40 @@
|
|||
using SHADE;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SHADE_Scripting.UI
|
||||
{
|
||||
public class MultiImageListControlButton: Script
|
||||
{
|
||||
public bool isNext = true;
|
||||
public GameObject multiImageList;
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
|
||||
UIElement ui = GetComponent<UIElement>();
|
||||
if (ui != null)
|
||||
{
|
||||
ui.OnRelease.RegisterAction(() =>
|
||||
{
|
||||
|
||||
MultiImageList imageList = multiImageList.GetScript<MultiImageList>();
|
||||
if(imageList != null)
|
||||
{
|
||||
|
||||
if (isNext)
|
||||
imageList.NextImage();
|
||||
else
|
||||
imageList.PrevImage();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Name: SC_MultiImageListControlButton
|
||||
ID: 164209885
|
||||
Type: 9
|
|
@ -0,0 +1,47 @@
|
|||
using SHADE;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SHADE_Scripting.UI
|
||||
{
|
||||
public class ScaleBounce:Script
|
||||
{
|
||||
[NonSerialized]
|
||||
private TweenThread thread;
|
||||
|
||||
public float minScale = 1.0f;
|
||||
public float maxScale = 1.2f;
|
||||
public float duration = 1.0f;
|
||||
|
||||
private Vector3 defaultScale;
|
||||
|
||||
|
||||
protected override void start()
|
||||
{
|
||||
thread = TweenManager.CreateTweenThread(duration, minScale, maxScale, EASING_METHOD.EASE_IN_SINE);
|
||||
Transform trans = GetComponent<Transform>();
|
||||
if(trans != null)
|
||||
{
|
||||
defaultScale = trans.LocalScale;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void update()
|
||||
{
|
||||
Transform trans = GetComponent<Transform>();
|
||||
if(trans != null)
|
||||
{
|
||||
trans.LocalScale = defaultScale * thread.GetValue();
|
||||
}
|
||||
if(thread.IsCompleted())
|
||||
{
|
||||
thread.ResetInvert();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Name: SC_ScaleBounce
|
||||
ID: 152015842
|
||||
Type: 9
|
|
@ -0,0 +1,41 @@
|
|||
using SHADE;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SHADE_Scripting.UI
|
||||
{
|
||||
public class SliderText:Script
|
||||
{
|
||||
public GameObject sliderObj;
|
||||
|
||||
public int minValue = 0;
|
||||
public int maxValue = 0;
|
||||
|
||||
protected override void start()
|
||||
{
|
||||
Slider slider = sliderObj.GetComponent<Slider>();
|
||||
TextRenderable text = GetComponent<TextRenderable>();
|
||||
|
||||
if (slider != null && text != null)
|
||||
{
|
||||
|
||||
text.Text = ((int)(slider.GetValue() * (maxValue - minValue) + minValue)).ToString();
|
||||
}
|
||||
}
|
||||
protected override void update()
|
||||
{
|
||||
Slider slider = sliderObj.GetComponent<Slider>();
|
||||
TextRenderable text = GetComponent<TextRenderable>();
|
||||
if(slider != null && text != null)
|
||||
{
|
||||
|
||||
text.Text = ((int)(slider.GetValue() * (maxValue - minValue) + minValue)).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Name: SC_SliderText
|
||||
ID: 158412308
|
||||
Type: 9
|
|
@ -0,0 +1,120 @@
|
|||
using SHADE;
|
||||
using SHADE_Scripting.Audio;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
namespace SHADE_Scripting.UI
|
||||
{
|
||||
|
||||
public class TweenThread
|
||||
{
|
||||
private float timer = 0.0f;
|
||||
public float duration = 1.0f;
|
||||
public EASING_METHOD method;
|
||||
private float value = 0.0f;
|
||||
public float startValue = 0.0f;
|
||||
public float endValue = 1.0f;
|
||||
|
||||
|
||||
public TweenThread(float duration, float startValue, float endValue, EASING_METHOD method)
|
||||
{
|
||||
this.duration = duration;
|
||||
this.method = method;
|
||||
this.startValue = startValue;
|
||||
this.endValue = endValue;
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
if (timer > duration)
|
||||
return;
|
||||
timer += deltaTime;
|
||||
if (timer > duration)
|
||||
timer = duration;
|
||||
|
||||
value = EasingHelper.EaseHelp(timer/duration, method) * (endValue - startValue) + startValue ;
|
||||
}
|
||||
|
||||
public bool IsCompleted()
|
||||
{
|
||||
return timer >= duration;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
timer = 0.0f;
|
||||
value = startValue;
|
||||
}
|
||||
public void Reset(float startValue, float endValue)
|
||||
{
|
||||
Reset();
|
||||
this.startValue = startValue;
|
||||
this.endValue = endValue;
|
||||
}
|
||||
public void ResetInvert()
|
||||
{
|
||||
Reset();
|
||||
float temp = startValue;
|
||||
startValue = endValue;
|
||||
endValue = temp;
|
||||
}
|
||||
|
||||
|
||||
public float GetValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TweenManager : Script
|
||||
{
|
||||
public static TweenManager Instance { get; private set; }
|
||||
|
||||
[NonSerialized]
|
||||
private List<TweenThread> threadList;
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
RemoveScript<TweenManager>();
|
||||
else
|
||||
Instance = this;
|
||||
|
||||
threadList = new List<TweenThread>();
|
||||
|
||||
}
|
||||
|
||||
protected override void onDestroy()
|
||||
{
|
||||
if (Instance == this)
|
||||
Instance = null;
|
||||
|
||||
}
|
||||
|
||||
protected override void update()
|
||||
{
|
||||
|
||||
foreach (TweenThread thread in threadList)
|
||||
{
|
||||
thread.Update(Time.DeltaTimeF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static TweenThread CreateTweenThread(float duration, float startValue, float endValue, EASING_METHOD method)
|
||||
{
|
||||
if (Instance == null)
|
||||
return null;
|
||||
|
||||
|
||||
TweenThread thread = new TweenThread(duration, startValue, endValue, method);
|
||||
Instance.threadList.Add(thread);
|
||||
thread.Reset();
|
||||
return thread;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Name: SC_TweenManager
|
||||
ID: 164072799
|
||||
Type: 9
|
|
@ -0,0 +1,60 @@
|
|||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
#extension GL_EXT_nonuniform_qualifier : require
|
||||
|
||||
struct MatPropData
|
||||
{
|
||||
int textureIndex;
|
||||
float alpha;
|
||||
float sliderThreshold;
|
||||
vec4 sliderStartColor;
|
||||
vec4 sliderEndColor;
|
||||
vec4 sliderBarColor;
|
||||
};
|
||||
|
||||
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 = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
|
||||
|
||||
if (In.uv.x > MatProp.data[In2.materialIndex].sliderThreshold)
|
||||
fragColor = MatProp.data[In2.materialIndex].sliderBarColor;
|
||||
else
|
||||
fragColor = (1.0f - In.uv.x) * MatProp.data[In2.materialIndex].sliderStartColor + In.uv.x * MatProp.data[In2.materialIndex].sliderEndColor;
|
||||
//fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
|
||||
if (fragColor.a < 0.01f)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
fragColor.a = MatProp.data[In2.materialIndex].alpha;
|
||||
|
||||
// fragColor.a = 1.0f;
|
||||
outEntityID = In2.eid;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: UI_Slider_FS
|
||||
ID: 48832081
|
||||
Type: 2
|
|
@ -0,0 +1,62 @@
|
|||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
#extension GL_EXT_nonuniform_qualifier : require
|
||||
|
||||
struct MatPropData
|
||||
{
|
||||
int textureIndex;
|
||||
float alpha;
|
||||
float sliderThreshold;
|
||||
vec4 sliderStartColor;
|
||||
vec4 sliderEndColor;
|
||||
vec4 sliderBarColor;
|
||||
};
|
||||
|
||||
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 = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
|
||||
|
||||
if (In.uv.x > MatProp.data[In2.materialIndex].sliderThreshold)
|
||||
fragColor = MatProp.data[In2.materialIndex].sliderBarColor;
|
||||
else
|
||||
//fragColor = (1.0f - In.uv.x) * MatProp.data[In2.materialIndex].sliderStartColor + In.uv.x * MatProp.data[In2.materialIndex].sliderEndColor;
|
||||
fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
|
||||
|
||||
|
||||
if (fragColor.a < 0.01f)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
fragColor.a = MatProp.data[In2.materialIndex].alpha;
|
||||
|
||||
// fragColor.a = 1.0f;
|
||||
outEntityID = In2.eid;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: UI_Slider_Textured_FS
|
||||
ID: 43211183
|
||||
Type: 2
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: RaccoonTransparent
|
||||
ID: 51158984
|
||||
Type: 3
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: TX_WK10_HowToPlay_01
|
||||
ID: 62200943
|
||||
Type: 3
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: TX_WK10_HowToPlay_02
|
||||
ID: 53303669
|
||||
Type: 3
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: TX_WK10_HowToPlay_03
|
||||
ID: 61780097
|
||||
Type: 3
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: TX_WK10_HowToPlay_04
|
||||
ID: 59178524
|
||||
Type: 3
|
|
@ -16,6 +16,7 @@
|
|||
#include <FMOD/fmod.hpp>
|
||||
#include <FMOD/fmod_studio.hpp>
|
||||
#include <SDL_keyboard.h>
|
||||
#include "Camera/SHCameraSystem.h"
|
||||
|
||||
const std::string AUDIO_FOLDER_PATH{ std::string(ASSET_ROOT)+ "/Audio/" };
|
||||
|
||||
|
@ -53,8 +54,9 @@ namespace SHADE
|
|||
|
||||
denseListener = &SHComponentManager::GetDense<SHAudioListenerComponent>();
|
||||
fmodStudioSystem->getCoreSystem(&fmodSystem);
|
||||
|
||||
result = fmodStudioSystem->initialize(AUDIO_SYS_MAX_CHANNELS, AUDIO_SYS_MAX_CHANNELS, FMOD_STUDIO_INIT_NORMAL, extraDriverData);
|
||||
fmodSystem->setSoftwareFormat(0, FMOD_SPEAKERMODE_5POINT1, 0);
|
||||
result = fmodStudioSystem->initialize(AUDIO_SYS_MAX_CHANNELS, AUDIO_SYS_MAX_CHANNELS, FMOD_STUDIO_INIT_NORMAL | FMOD_INIT_NORMAL, extraDriverData);
|
||||
|
||||
ErrorCheck();
|
||||
|
||||
fmodSystem->setSoftwareFormat(0, speakerMode, 0);
|
||||
|
@ -83,17 +85,10 @@ namespace SHADE
|
|||
|
||||
LoadBank((AUDIO_FOLDER_PATH + "Master.bank").data());
|
||||
LoadBank((AUDIO_FOLDER_PATH + "Master.strings.bank").data());
|
||||
//LoadBank((AUDIO_FOLDER_PATH + "Music.bank").data());
|
||||
//LoadBank((AUDIO_FOLDER_PATH + "footsteps.bank").data());
|
||||
LoadBank((AUDIO_FOLDER_PATH + "Music.bank").data());
|
||||
LoadBank((AUDIO_FOLDER_PATH + "SFX.bank").data());
|
||||
LoadBank((AUDIO_FOLDER_PATH + "UI.bank").data());
|
||||
|
||||
//auto clip = CreateAudioClip("event:/Characters/sfx_footsteps_human");
|
||||
//clip->Play();
|
||||
//PlayEventOnce("event:/Characters/sfx_footsteps_raccoon");
|
||||
//PlayEventOnce("event:/SFX/Dawn/Dawn_Attack");
|
||||
|
||||
#ifdef SHEDITOR
|
||||
|
||||
// Subscribe to Editor State Change Events
|
||||
|
@ -115,35 +110,65 @@ namespace SHADE
|
|||
void SHADE::SHAudioSystem::Run(double dt)
|
||||
{
|
||||
static_cast<void>(dt);
|
||||
//if (GetKeyState(VK_SPACE) & 0x8000)
|
||||
// PlayEventOnce("event:/Characters/sfx_footsteps_raccoon");
|
||||
|
||||
fmodStudioSystem->update();
|
||||
if (!denseListener->empty())
|
||||
//int listenerID = 0;
|
||||
//for(auto& listener : *denseListener)
|
||||
//{
|
||||
// if(!listener.isActive)
|
||||
// continue;
|
||||
// //SHAudioListenerComponent& listener = denseListener->at(0); //Loop through dense
|
||||
// SHTransformComponent* listenerTransform = SHComponentManager::GetComponent_s<SHTransformComponent>(listener.GetEID());
|
||||
// if (listenerTransform)
|
||||
// {
|
||||
// listener.SetPos(listenerTransform->GetWorldPosition());
|
||||
// SHQuaternion worldOrientation = listenerTransform->GetWorldOrientation();
|
||||
// SHVec3 orientatedFoward = (worldOrientation * SHQuaternion::FromEuler(SHVec3::Forward) * SHQuaternion::Conjugate(worldOrientation)).ToEuler();
|
||||
// SHVec3 orientatedUp = (worldOrientation * SHQuaternion::FromEuler(SHVec3::Up) * SHQuaternion::Conjugate(worldOrientation)).ToEuler();
|
||||
// listener.SetForward(orientatedFoward);
|
||||
// listener.SetUp(orientatedUp);
|
||||
|
||||
// FMOD_3D_ATTRIBUTES attribs{ { 0 } };
|
||||
// attribs.position = { listener.pos.x, listener.pos.y, listener.pos.z };
|
||||
// attribs.forward = { orientatedFoward.x, orientatedFoward.y, orientatedFoward.z };
|
||||
// attribs.up = { orientatedUp.x, orientatedUp.y, orientatedUp.z };
|
||||
//
|
||||
// fmodStudioSystem->setListenerAttributes(listenerID++, &attribs);
|
||||
// }
|
||||
//}
|
||||
|
||||
if(auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>())
|
||||
{
|
||||
SHAudioListenerComponent& listener = denseListener->at(0);
|
||||
SHTransformComponent* listenerTransform = SHComponentManager::GetComponent_s<SHTransformComponent>(listener.GetEID());
|
||||
if (listenerTransform)
|
||||
auto mainCamEID = camSystem->GetMainCameraEID();
|
||||
if(auto camComponent = SHComponentManager::GetComponent_s<SHCameraComponent>(mainCamEID))
|
||||
{
|
||||
listener.SetPos(listenerTransform->GetWorldPosition()); // TODO: Clean up listener
|
||||
listener.SetForward({ (listenerTransform->GetLocalScale()[0] > 0.f) ? 1.f : -1.f, 0.f, 0.f }); //TODO: USE CORRECT FORWARD
|
||||
FMOD_VECTOR pos = { listener.pos[0] ,listener.pos[1] ,0.f };
|
||||
FMOD_VECTOR forward = { listener.forward[0] ,listener.forward[1] ,listener.forward[2] };
|
||||
FMOD_VECTOR up = { listener.up[0] ,listener.up[1] ,listener.up[2] };
|
||||
fmodSystem->set3DListenerAttributes(0, &pos, nullptr, &forward, &up);
|
||||
FMOD_3D_ATTRIBUTES attribs{ { 0 } };
|
||||
SHVec3 pos = camComponent->GetPosition();
|
||||
SHVec3 forward, up, right;
|
||||
camSystem->GetCameraAxis(*camComponent, forward, right, up);
|
||||
attribs.position = { pos.x, pos.y, pos.z };
|
||||
attribs.forward = { forward.x, forward.y, forward.z };
|
||||
attribs.up = { up.x, up.y, up.z };
|
||||
fmodStudioSystem->setListenerAttributes(0, &attribs);
|
||||
}
|
||||
}
|
||||
|
||||
auto [begin, end] = audioClipLibrary.GetDenseAccess();
|
||||
for(auto it = begin; it != end; ++it)
|
||||
for (auto& it = begin; it != end; ++it)
|
||||
{
|
||||
if(it->instance && (it->transformRef != MAX_EID))
|
||||
{
|
||||
if(SHTransformComponent* transformComponent = SHComponentManager::GetComponent_s<SHTransformComponent>(it->transformRef))
|
||||
{
|
||||
FMOD_3D_ATTRIBUTES attribs{}; //TODO: Set other attribs
|
||||
FMOD_3D_ATTRIBUTES attribs{ { 0 } };
|
||||
auto pos = transformComponent->GetWorldPosition();
|
||||
SHQuaternion worldOrientation = transformComponent->GetWorldOrientation();
|
||||
SHVec3 orientatedFoward = (worldOrientation * SHQuaternion::FromEuler(SHVec3::Forward) * SHQuaternion::Conjugate(worldOrientation)).ToEuler();
|
||||
SHVec3 orientatedUp = (worldOrientation * SHQuaternion::FromEuler(SHVec3::Up) * SHQuaternion::Conjugate(worldOrientation)).ToEuler();
|
||||
|
||||
attribs.position = {pos.x, pos.y, pos.z};
|
||||
attribs.forward = {orientatedFoward.x, orientatedFoward.y, orientatedFoward.z};
|
||||
attribs.up = {orientatedUp.x, orientatedUp.y, orientatedUp.z};
|
||||
it->instance->set3DAttributes(&attribs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace SHADE
|
|||
typedef FMOD::Studio::Bank* SHBank;
|
||||
|
||||
class SHAudioListenerComponent;
|
||||
|
||||
|
||||
class SH_API AudioClip
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -12,4 +12,5 @@
|
|||
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
||||
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
||||
#include "Physics/Interface/SHColliderComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||
#include "AudioSystem/SHAudioListenerComponent.h"
|
|
@ -254,7 +254,7 @@ namespace SHADE
|
|||
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
||||
}
|
||||
|
||||
ImRect SHAssetBrowser::DrawAsset(SHAsset const* const asset, FileExt const& ext /*= ""*/) noexcept
|
||||
ImRect SHAssetBrowser::DrawAsset(SHAsset const* const asset, FileExt const& ext /*= ""*/, bool isSubAsset /*= false*/) noexcept
|
||||
{
|
||||
if (asset == nullptr)
|
||||
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
||||
|
@ -267,10 +267,20 @@ namespace SHADE
|
|||
bool highlighted = false;
|
||||
if(!filter.empty())
|
||||
{
|
||||
ImGui::SetNextItemOpen(true);
|
||||
//ImGui::SetNextItemOpen(true);
|
||||
if(SHStringUtilities::StringFindInsensitive(asset->name.data(), filter) == std::string::npos)
|
||||
{
|
||||
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
||||
bool subAssetFiltered = false;
|
||||
for (auto const& subAsset : asset->subAssets)
|
||||
{
|
||||
subAssetFiltered |= (SHStringUtilities::StringFindInsensitive(subAsset->name.data(), filter) != std::string::npos);
|
||||
}
|
||||
if(!subAssetFiltered)
|
||||
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
||||
else if(!asset->subAssets.empty())
|
||||
{
|
||||
ImGui::SetNextItemOpen(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -350,7 +360,12 @@ namespace SHADE
|
|||
case AssetType::TEXTURE: break;
|
||||
case AssetType::MESH: break;
|
||||
case AssetType::SCENE:
|
||||
editor->LoadScene(asset->id);
|
||||
{
|
||||
if(editor->LoadScene(asset->id))
|
||||
{
|
||||
editor->editorConfig->workingSceneID = asset->id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AssetType::PREFAB: break;
|
||||
case AssetType::MATERIAL:
|
||||
|
@ -418,7 +433,7 @@ namespace SHADE
|
|||
for(auto const& subAsset : asset->subAssets)
|
||||
{
|
||||
const float horizontalLineSize = 25.0f;
|
||||
const ImRect childRect = DrawAsset(subAsset);
|
||||
const ImRect childRect = DrawAsset(subAsset, "", true);
|
||||
const float midPoint = (childRect.Min.y + childRect.Max.y) * 0.5f;
|
||||
drawList->AddLine(ImVec2(vertLineStart.x, midPoint), ImVec2(vertLineStart.x + horizontalLineSize, midPoint), treeLineColor, 1);
|
||||
vertLineEnd.y = midPoint;
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace SHADE
|
|||
ImRect RecursivelyDrawTree(FolderPointer folder);
|
||||
void DrawCurrentFolder();
|
||||
ImRect DrawFile(SHFile& file) noexcept;
|
||||
ImRect DrawAsset(SHAsset const* const asset, FileExt const& ext = "") noexcept;
|
||||
ImRect DrawAsset(SHAsset const* const asset, FileExt const& ext = "", bool isSubAsset = false) noexcept;
|
||||
void DrawAssetBeingCreated() noexcept;
|
||||
void DrawAssetBrowserFilter();
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "Serialization/Prefab/SHPrefabManager.h"
|
||||
#include "../SHEditorWindowManager.h"
|
||||
#include "../AssetBrowser/SHAssetBrowser.h"
|
||||
#include "Assets/SHAssetManager.h"
|
||||
#include "Assets/Asset Types/SHPrefabAsset.h"
|
||||
|
||||
|
||||
namespace SHADE
|
||||
|
@ -99,30 +101,32 @@ namespace SHADE
|
|||
}
|
||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);
|
||||
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_A))
|
||||
if (!ImGui::IsAnyItemActive())
|
||||
{
|
||||
SelectAllEntities();
|
||||
}
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_C))
|
||||
{
|
||||
CopySelectedEntities();
|
||||
}
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && !ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V))
|
||||
{
|
||||
PasteEntities();
|
||||
}
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V))
|
||||
{
|
||||
if (editor->selectedEntities.size() == 1)
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_A))
|
||||
{
|
||||
PasteEntities(editor->selectedEntities.back());
|
||||
SelectAllEntities();
|
||||
}
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_C))
|
||||
{
|
||||
CopySelectedEntities();
|
||||
}
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && !ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V))
|
||||
{
|
||||
PasteEntities();
|
||||
}
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V))
|
||||
{
|
||||
if (editor->selectedEntities.size() == 1)
|
||||
{
|
||||
PasteEntities(editor->selectedEntities.back());
|
||||
}
|
||||
}
|
||||
if (ImGui::IsKeyReleased(ImGuiKey_Delete))
|
||||
{
|
||||
DeleteSelectedEntities();
|
||||
}
|
||||
}
|
||||
if (ImGui::IsKeyReleased(ImGuiKey_Delete))
|
||||
{
|
||||
DeleteSelectedEntities();
|
||||
}
|
||||
|
||||
}
|
||||
if(ImGui::IsWindowHovered() && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||
{
|
||||
|
@ -134,6 +138,23 @@ namespace SHADE
|
|||
draggingEntities.clear();
|
||||
ImGui::ClearDragDrop();
|
||||
}
|
||||
//else if(SHDragDrop::currentDragDropTag == SHDragDrop::DRAG_RESOURCE)
|
||||
//{
|
||||
// if (const AssetID* assetPayload = SHDragDrop::AcceptPayload<AssetID>(SHDragDrop::DRAG_RESOURCE)) //If payload is valid
|
||||
// {
|
||||
// auto assetId = *assetPayload;
|
||||
// auto createdEntitiesList = SHSerialization::DeserializeEntitiesFromString(SHAssetManager::GetData<SHPrefabAsset>(assetId)->data);
|
||||
// if (!createdEntitiesList.empty())
|
||||
// {
|
||||
// std::vector<EntityID> eidList;
|
||||
// std::ranges::transform(createdEntitiesList, std::back_inserter(eidList), [](std::pair<EntityID, EntityID> pair) {return pair.second; });
|
||||
// ParentSelectedEntities(eid, eidList);
|
||||
// SetScrollTo(createdEntitiesList.begin()->second);
|
||||
// SHPrefabManager::AddEntity(assetId, createdEntitiesList.begin()->second);
|
||||
// skipFrame = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
@ -357,6 +378,20 @@ namespace SHADE
|
|||
draggingEntities.clear();
|
||||
//ImGui::ClearDragDrop();
|
||||
}
|
||||
if (const AssetID* assetPayload = SHDragDrop::AcceptPayload<AssetID>(SHDragDrop::DRAG_RESOURCE)) //If payload is valid
|
||||
{
|
||||
auto assetId = *assetPayload;
|
||||
auto createdEntitiesList = SHSerialization::DeserializeEntitiesFromString(SHAssetManager::GetData<SHPrefabAsset>(assetId)->data);
|
||||
if(!createdEntitiesList.empty())
|
||||
{
|
||||
std::vector<EntityID> eidList;
|
||||
std::ranges::transform(createdEntitiesList, std::back_inserter(eidList), [](std::pair<EntityID, EntityID> pair){return pair.second;} );
|
||||
ParentSelectedEntities(eid, eidList);
|
||||
SetScrollTo(createdEntitiesList.begin()->second);
|
||||
SHPrefabManager::AddEntity(assetId, createdEntitiesList.begin()->second);
|
||||
skipFrame = true;
|
||||
}
|
||||
}
|
||||
SHDragDrop::EndTarget();
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,8 @@ namespace SHADE
|
|||
data.createdEntities.clear();
|
||||
data.createdEntities = SHSerialization::DeserializeEntitiesFromString(data.entityData, data.parentEID);
|
||||
data.entityData = SHSerialization::ResolveSerializedEntityIndices(data.entityData, data.createdEntities);
|
||||
SHEditorWindowManager::GetEditorWindow<SHHierarchyPanel>()->SetScrollTo(data.createdEntities.begin()->second);
|
||||
if(!data.createdEntities.empty())
|
||||
SHEditorWindowManager::GetEditorWindow<SHHierarchyPanel>()->SetScrollTo(data.createdEntities.begin()->second);
|
||||
}
|
||||
|
||||
void SHPasteEntitiesCommand::Undo()
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "UI/SHCanvasComponent.h"
|
||||
#include "UI/SHButtonComponent.h"
|
||||
#include "UI/SHToggleButtonComponent.h"
|
||||
#include "UI/SHSliderComponent.h"
|
||||
#include "SHEditorComponentView.h"
|
||||
#include "AudioSystem/SHAudioListenerComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||
|
@ -171,6 +172,14 @@ namespace SHADE
|
|||
{
|
||||
DrawComponent(toggleButton);
|
||||
}
|
||||
if (auto slider = SHComponentManager::GetComponent_s<SHSliderComponent>(eid))
|
||||
{
|
||||
DrawComponent(slider);
|
||||
}
|
||||
if(auto listenerComponent = SHComponentManager::GetComponent_s<SHAudioListenerComponent>(eid))
|
||||
{
|
||||
DrawComponent(listenerComponent);
|
||||
}
|
||||
ImGui::Separator();
|
||||
// Render Scripts
|
||||
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
||||
|
@ -185,6 +194,7 @@ namespace SHADE
|
|||
DrawAddComponentButton<SHCanvasComponent>(eid);
|
||||
DrawAddComponentButton<SHButtonComponent>(eid);
|
||||
DrawAddComponentButton<SHToggleButtonComponent>(eid);
|
||||
DrawAddComponentButton<SHSliderComponent>(eid);
|
||||
|
||||
// Components that require Transforms
|
||||
|
||||
|
@ -193,7 +203,7 @@ namespace SHADE
|
|||
DrawAddComponentWithEnforcedComponentButton<SHColliderComponent, SHTransformComponent>(eid);
|
||||
DrawAddComponentWithEnforcedComponentButton<SHTextRenderableComponent, SHTransformComponent>(eid);
|
||||
DrawAddComponentWithEnforcedComponentButton<SHAnimatorComponent, SHTransformComponent, SHRenderable>(eid);
|
||||
|
||||
DrawAddComponentWithEnforcedComponentButton<SHAudioListenerComponent, SHTransformComponent>(eid);
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "Serialization/Configurations/SHConfigurationManager.h"
|
||||
#include "Editor/EditorWindow/SHEditorWindowManager.h"
|
||||
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
|
||||
#include "Camera/SHCameraSystem.h"
|
||||
#include "Tools/Utilities/SHClipboardUtilities.h"
|
||||
|
||||
const std::string LAYOUT_FOLDER_PATH{ std::string(ASSET_ROOT) + "/Editor/Layouts" };
|
||||
|
||||
|
@ -154,7 +156,39 @@ namespace SHADE
|
|||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg]);
|
||||
if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags))
|
||||
{
|
||||
ImGui::Text("Entity count: %zu", SHEntityManager::GetEntityCount());
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
std::string editorCamPosText{};
|
||||
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);
|
||||
|
||||
//ImGui::Text(editorCamPosText.data());
|
||||
}
|
||||
ImGui::Text("Entity count: %zu %s", SHEntityManager::GetEntityCount(), editorCamPosText.data());
|
||||
if(ImGui::BeginPopupContextItem("EditorCamPosContext"))
|
||||
{
|
||||
if(editorCam)
|
||||
{
|
||||
if(ImGui::Selectable("Copy Editor Cam Pos X"))
|
||||
{
|
||||
auto editorCamPos = editorCam->GetPosition();
|
||||
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.x));
|
||||
}
|
||||
if (ImGui::Selectable("Copy Editor Cam Pos Y"))
|
||||
{
|
||||
auto editorCamPos = editorCam->GetPosition();
|
||||
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.y));
|
||||
}
|
||||
if (ImGui::Selectable("Copy Editor Cam Pos Z"))
|
||||
{
|
||||
auto editorCamPos = editorCam->GetPosition();
|
||||
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.z));
|
||||
}
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleColor();
|
||||
|
|
|
@ -70,7 +70,8 @@ namespace SHADE
|
|||
beginCursorPos = ImGui::GetCursorScreenPos();
|
||||
viewportMousePos = { mousePos.x - beginCursorPos.x, mousePos.y - beginCursorPos.y };
|
||||
gfxSystem->GetMousePickSystem()->SetViewportMousePos(viewportMousePos);
|
||||
ImGui::Image((ImTextureID)descriptorSet, { beginContentRegionAvailable.x, beginContentRegionAvailable.y });
|
||||
SHVec2 viewportSize = CalculateWindowSize(beginContentRegionAvailable);
|
||||
ImGui::Image((ImTextureID)descriptorSet, { viewportSize.x, viewportSize.y });
|
||||
|
||||
if (ImGui::IsWindowHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Right))
|
||||
{
|
||||
|
@ -122,12 +123,22 @@ namespace SHADE
|
|||
|
||||
//auto pos = ImGui::GetCursorPos();
|
||||
//windowCursorPos = {}
|
||||
|
||||
if (beginContentRegionAvailable.x == 0 || beginContentRegionAvailable.y == 0)
|
||||
{
|
||||
beginContentRegionAvailable = windowSize;
|
||||
}
|
||||
gfxSystem->PrepareResize(static_cast<uint32_t>(beginContentRegionAvailable.x), static_cast<uint32_t>(beginContentRegionAvailable.y));
|
||||
|
||||
//beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||
SHVec2 viewportSize = CalculateWindowSize(beginContentRegionAvailable);
|
||||
gfxSystem->PrepareResize(static_cast<uint32_t>(viewportSize.x), static_cast<uint32_t>(viewportSize.y));
|
||||
shouldUpdateCamera = true;
|
||||
//if (aspectRatio != AspectRatio::FREE && (ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseReleased(ImGuiMouseButton_Left)))
|
||||
//{
|
||||
// windowSize = CalculateWindowSize(windowSize);
|
||||
// beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||
// ImGui::SetWindowSize(windowName.data(), CalculateWindowSize(windowSize));
|
||||
//}
|
||||
}
|
||||
|
||||
void SHEditorViewport::OnPosChange()
|
||||
|
@ -195,13 +206,73 @@ namespace SHADE
|
|||
ImGui::PopStyleColor();
|
||||
ImGui::EndDisabled();
|
||||
|
||||
//TODO: Shift to constructor
|
||||
auto arRTTRtype = rttr::type::get<SHEditorViewport::AspectRatio>();
|
||||
auto enumAlign = arRTTRtype.get_enumeration();
|
||||
auto names = enumAlign.get_names();
|
||||
std::vector<const char*> arNames;
|
||||
for (auto const& name : names)
|
||||
{
|
||||
arNames.push_back(name.data());
|
||||
}
|
||||
int currentAR = static_cast<int>(aspectRatio);
|
||||
ImGui::SetNextItemWidth(80.0f);
|
||||
if (ImGui::Combo("Aspect Ratio", ¤tAR, arNames.data(), arNames.size()))
|
||||
{
|
||||
aspectRatio = static_cast<AspectRatio>(currentAR);
|
||||
windowSize = CalculateWindowSize(windowSize);
|
||||
ImGui::SetWindowSize(windowSize);
|
||||
//beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||
//OnResize();
|
||||
}
|
||||
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
auto editorCamera = camSystem->GetEditorCamera();
|
||||
//ImGui::SetNextItemWidth(10.0f);
|
||||
SHEditorWidgets::SliderFloat("CamSpeed", 0.0f, 5.0f, [editorCamera] {return editorCamera->movementSpeed; }, [editorCamera](float const& value) {editorCamera->movementSpeed = value; });
|
||||
SHEditorWidgets::DragVec3("TurnSpeed", { "X", "Y", "Z" }, [editorCamera] {return editorCamera->turnSpeed; }, [editorCamera](SHVec3 const& value) {editorCamera->turnSpeed = value; });
|
||||
|
||||
//if(ImGui::BeginCombo("Aspect Ratio", arNames[(uint8_t)aspectRatio].data()))
|
||||
//{
|
||||
// auto nameIt = names.begin();
|
||||
// auto valueIt = values.end();
|
||||
// while(nameIt != names.end() && valueIt != values.end())
|
||||
// {
|
||||
// if ImGui::Beg
|
||||
// }
|
||||
//}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
SHVec2 SHEditorViewport::CalculateWindowSize(SHVec2 const& rhs) noexcept
|
||||
{
|
||||
switch (aspectRatio)
|
||||
{
|
||||
case SHADE::SHEditorViewport::AspectRatio::FREE:
|
||||
return rhs;
|
||||
case SHADE::SHEditorViewport::AspectRatio::AR16_9:
|
||||
return SHVec2(rhs.x, rhs.x * 0.5625f);
|
||||
case SHADE::SHEditorViewport::AspectRatio::AR21_9:
|
||||
return SHVec2(rhs.x, rhs.x * 0.42857f);
|
||||
case SHADE::SHEditorViewport::AspectRatio::AR21_10:
|
||||
return SHVec2(rhs.x, rhs.x * 0.47619f);
|
||||
default:
|
||||
return rhs;
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace SHADE
|
||||
|
||||
RTTR_REGISTRATION
|
||||
{
|
||||
using namespace rttr;
|
||||
using namespace SHADE;
|
||||
registration::enumeration<SHEditorViewport::AspectRatio>("AspectRatio")(
|
||||
value("FREE", SHEditorViewport::AspectRatio::FREE),
|
||||
value("16:9", SHEditorViewport::AspectRatio::AR16_9),
|
||||
value("21:9", SHEditorViewport::AspectRatio::AR21_9),
|
||||
value("21:10", SHEditorViewport::AspectRatio::AR21_10)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,15 @@ namespace SHADE
|
|||
{
|
||||
class SHEditorViewport final : public SHEditorWindow
|
||||
{
|
||||
|
||||
public:
|
||||
enum class AspectRatio : uint8_t
|
||||
{
|
||||
FREE,
|
||||
AR16_9,
|
||||
AR21_9,
|
||||
AR21_10
|
||||
};
|
||||
SHEditorViewport();
|
||||
void Init() override;
|
||||
void Update() override;
|
||||
|
@ -27,9 +35,12 @@ namespace SHADE
|
|||
void OnPosChange() override;
|
||||
private:
|
||||
void DrawMenuBar() noexcept;
|
||||
SHVec2 beginCursorPos;
|
||||
SHVec2 CalculateWindowSize(SHVec2 const& rhs) noexcept;
|
||||
|
||||
bool shouldUpdateCamera = false;
|
||||
bool shouldUpdateCamArm = false;
|
||||
AspectRatio aspectRatio {AspectRatio::FREE};
|
||||
SHVec2 beginCursorPos;
|
||||
SHVec3 targetPos;
|
||||
};//class SHEditorViewport
|
||||
}//namespace SHADE
|
||||
|
|
|
@ -579,19 +579,23 @@ namespace SHADE
|
|||
return false;
|
||||
}
|
||||
|
||||
void SHEditor::LoadScene(AssetID const& assetID) noexcept
|
||||
bool SHEditor::LoadScene(AssetID const& assetID) noexcept
|
||||
{
|
||||
if(shWindow->IsUnsavedChanges())
|
||||
{
|
||||
//Unsaved changes prompt
|
||||
isUnsavedChangesPromptOpen = true;
|
||||
sceneToLoad = assetID;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Load the scene
|
||||
sceneToLoad = 0;
|
||||
editorConfig->workingSceneID = assetID;
|
||||
SHConfigurationManager::SaveEditorConfig();
|
||||
SHSceneManager::RestartScene(assetID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace SHADE
|
|||
|
||||
bool SaveScene(std::string const& newSceneName = {});
|
||||
|
||||
void LoadScene(AssetID const& assetID) noexcept;
|
||||
bool LoadScene(AssetID const& assetID) noexcept;
|
||||
|
||||
void Play();
|
||||
void Pause();
|
||||
|
|
|
@ -278,10 +278,12 @@ namespace SHADE
|
|||
AddComponentToComponentNode<SHCanvasComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHButtonComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHToggleButtonComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHSliderComponent>(components, eid);
|
||||
|
||||
AddComponentToComponentNode<SHTextRenderableComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHAnimatorComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHUIComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHAudioListenerComponent>(components, eid);
|
||||
|
||||
node[ComponentsNode] = components;
|
||||
|
||||
|
@ -342,9 +344,11 @@ namespace SHADE
|
|||
AddComponentID<SHCanvasComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHButtonComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHToggleButtonComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHSliderComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHTextRenderableComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHAnimatorComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHUIComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHAudioListenerComponent>(componentIDList, componentsNode);
|
||||
|
||||
return componentIDList;
|
||||
}
|
||||
|
@ -427,12 +431,12 @@ namespace SHADE
|
|||
SHSerializationHelper::InitializeComponentFromNode<SHCanvasComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHButtonComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHToggleButtonComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHSliderComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHTextRenderableComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHLightComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHAnimatorComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHUIComponent>(componentsNode, eid);
|
||||
|
||||
// Deserialise scripts
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHAudioListenerComponent>(componentsNode, eid);
|
||||
if (entityNode[ScriptsNode].IsDefined())
|
||||
SHSystemManager::GetSystem<SHScriptEngine>()->DeserialiseScripts(eid, entityNode[ScriptsNode]);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
namespace SHADE
|
||||
{
|
||||
SHSliderComponent::SHSliderComponent()
|
||||
:size(1.0f), isHovered(false), isClicked(false), value(0.0f)
|
||||
:value(0.0f)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ namespace SHADE
|
|||
SHSliderComponent();
|
||||
virtual ~SHSliderComponent() = default;
|
||||
|
||||
SHVec2 size;
|
||||
|
||||
|
||||
float GetValue() const noexcept;
|
||||
|
||||
|
@ -29,8 +27,7 @@ namespace SHADE
|
|||
friend class SHUISystem;
|
||||
private:
|
||||
|
||||
bool isHovered;
|
||||
bool isClicked;
|
||||
|
||||
|
||||
float value;
|
||||
|
||||
|
|
|
@ -377,6 +377,86 @@ namespace SHADE
|
|||
}
|
||||
|
||||
|
||||
void SHUISystem::UpdateSliderComponent(SHSliderComponent& comp) noexcept
|
||||
{
|
||||
|
||||
|
||||
if (!SHComponentManager::HasComponent<SHUIComponent>(comp.GetEID()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
auto uiComp = SHComponentManager::GetComponent<SHUIComponent>(comp.GetEID());
|
||||
//auto canvasComp = SHComponentManager::GetComponent_s<SHCanvasComponent>(uiComp->canvasID);
|
||||
|
||||
float tempValue = comp.GetValue();
|
||||
|
||||
CheckButtonHoveredOrClicked(*uiComp);
|
||||
|
||||
if (uiComp->GetIsClicked() == true)
|
||||
{
|
||||
SHVec4 topExtent4 = SHMatrix::Translate(-uiComp->size.x * 0.5f, uiComp->size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
SHVec4 btmExtent4 = SHMatrix::Translate(uiComp->size.x * 0.5f, -uiComp->size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
|
||||
SHVec2 topExtent{ topExtent4.x,topExtent4.y };
|
||||
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
|
||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
SHVec2 mousePos;
|
||||
SHVec2 windowSize;
|
||||
#ifdef SHEDITOR
|
||||
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->beginContentRegionAvailable;
|
||||
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
|
||||
mousePos /= windowSize;
|
||||
#else
|
||||
int x, y;
|
||||
SHInputManager::GetMouseScreenPosition(&x, &y);
|
||||
mousePos.x = x;
|
||||
mousePos.y = y;
|
||||
auto ws = SHSystemManager::GetSystem<SHGraphicsSystem>()->GetWindow()->GetWindowSize();
|
||||
windowSize = { static_cast<float>(ws.first), static_cast<float>(ws.second) };
|
||||
mousePos /= windowSize;
|
||||
#endif
|
||||
|
||||
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) };
|
||||
//SHLOG_INFO("TopExtent: {}, {}", topExtent.x, topExtent.y)
|
||||
|
||||
topExtent = CanvasToScreenPoint(topExtent, true);
|
||||
btmExtent = CanvasToScreenPoint(btmExtent, true);
|
||||
|
||||
|
||||
comp.value = (mousePos.x - topExtent.x) / (btmExtent.x - topExtent.x);
|
||||
|
||||
if (comp.GetValue() > 1.0f)
|
||||
comp.value = 1.0f;
|
||||
if (comp.GetValue() < 0.0f)
|
||||
comp.value = 0.0f;
|
||||
}
|
||||
try
|
||||
{
|
||||
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
||||
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
|
||||
auto material = renderable->GetModifiableMaterial();
|
||||
if (renderable)
|
||||
{
|
||||
if (comp.GetValue() != material->GetProperty<float>("data.sliderThreshold"))
|
||||
{
|
||||
//Set shader value.
|
||||
|
||||
material->SetProperty("data.sliderThreshold", comp.GetValue());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SHUISystem::UpdateButtonsRoutine::Execute(double dt) noexcept
|
||||
{
|
||||
SHUISystem* system = (SHUISystem*)GetSystem();
|
||||
|
@ -395,6 +475,13 @@ namespace SHADE
|
|||
if (SHSceneManager::CheckNodeAndComponentsActive<SHToggleButtonComponent>(comp.GetEID()))
|
||||
system->UpdateToggleButtonComponent(comp);
|
||||
}
|
||||
|
||||
auto& sliderDense = SHComponentManager::GetDense<SHSliderComponent>();
|
||||
for (auto& comp : sliderDense)
|
||||
{
|
||||
if (SHSceneManager::CheckNodeAndComponentsActive<SHSliderComponent>(comp.GetEID()))
|
||||
system->UpdateSliderComponent(comp);
|
||||
}
|
||||
}
|
||||
|
||||
SHVec2 SHUISystem::CanvasToScreenPoint(SHVec2& const canvasPoint, bool normalized) noexcept
|
||||
|
@ -415,6 +502,17 @@ namespace SHADE
|
|||
return result;
|
||||
}
|
||||
|
||||
void SHUISystem::HideActiveCanvas() noexcept
|
||||
{
|
||||
auto& dense = SHComponentManager::GetDense<SHCanvasComponent>();
|
||||
for (auto& canvas : dense)
|
||||
{
|
||||
if (SHSceneManager::CheckNodeAndComponentsActive<SHCanvasComponent>(canvas.GetEID()))
|
||||
{
|
||||
SHSceneManager::GetCurrentSceneGraph().SetActive(canvas.GetEID(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@ namespace SHADE
|
|||
void Init();
|
||||
void Exit();
|
||||
|
||||
void HideActiveCanvas() noexcept;
|
||||
|
||||
|
||||
private:
|
||||
bool loadTexture{false};
|
||||
|
@ -74,7 +76,7 @@ namespace SHADE
|
|||
void UpdateButtonComponent(SHButtonComponent& comp) noexcept;
|
||||
void UpdateToggleButtonComponent(SHToggleButtonComponent& comp) noexcept;
|
||||
void UpdateCanvasComponent(SHCanvasComponent& comp) noexcept;
|
||||
|
||||
void UpdateSliderComponent(SHSliderComponent& comp) noexcept;
|
||||
//returns true on button release.
|
||||
bool CheckButtonHoveredOrClicked(SHUIComponent& comp) noexcept;
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
// Precompiled Headers
|
||||
#include "SHpch.h"
|
||||
// Primary Header
|
||||
#include "Canvas.hxx"
|
||||
#include "Assets/NativeAsset.hxx"
|
||||
#include "Utility/Convert.hxx"
|
||||
#include "Utility/Debug.hxx"
|
||||
|
||||
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include "UI/SHUISystem.h"
|
||||
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
Canvas::Canvas(Entity entity)
|
||||
: Component(entity)
|
||||
{}
|
||||
|
||||
void Canvas::DeactivateAllCanvas()
|
||||
{
|
||||
auto system = SHSystemManager::GetSystem<SHUISystem>();
|
||||
system->HideActiveCanvas();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/************************************************************************************//*!
|
||||
\file Canvas.hxx
|
||||
\author Daniel Chua, 2001877
|
||||
\par email: yeechendaniel/@digipen.edu
|
||||
\date Feb 26, 2023
|
||||
\brief Contains the definition of the managed Canvas class with the
|
||||
declaration of functions for working with it.
|
||||
|
||||
Note: This file is written in C++17/CLI.
|
||||
|
||||
Copyright (C) 2023 DigiPen Institute of Technology.
|
||||
Reproduction or disclosure of this file or its contents without the prior written consent
|
||||
of DigiPen Institute of Technology is prohibited.
|
||||
*//*************************************************************************************/
|
||||
#pragma once
|
||||
|
||||
// Project Includes
|
||||
#include "Components/Component.hxx"
|
||||
#include "Math/Vector3.hxx"
|
||||
#include "Math/Quaternion.hxx"
|
||||
// External Dependencies
|
||||
#include "UI/SHCanvasComponent.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/// <summary>
|
||||
/// CLR version of the SHADE Engine's SHCanvasComponent.
|
||||
/// </summary>
|
||||
public ref class Canvas : public Component<SHCanvasComponent>
|
||||
{
|
||||
internal:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Constructors */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Constructs a Canvas Component that represents a native SHCanvasComponent
|
||||
/// tied to the specified Entity.
|
||||
/// </summary>
|
||||
/// <param name="entity">Entity that this Component will be tied to.</param>
|
||||
Canvas(Entity entity);
|
||||
|
||||
public:
|
||||
|
||||
static void DeactivateAllCanvas();
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// Precompiled Headers
|
||||
#include "SHpch.h"
|
||||
// Primary Header
|
||||
#include "Slider.hxx"
|
||||
#include "Assets/NativeAsset.hxx"
|
||||
#include "Utility/Convert.hxx"
|
||||
#include "Utility/Debug.hxx"
|
||||
|
||||
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include "UI/SHUISystem.h"
|
||||
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
Slider::Slider(Entity entity)
|
||||
: Component(entity)
|
||||
{}
|
||||
|
||||
float Slider::GetValue()
|
||||
{
|
||||
return GetNativeComponent()->GetValue();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/************************************************************************************//*!
|
||||
\file Slider.hxx
|
||||
\author Daniel Chua, 2001877
|
||||
\par email: yeechendaniel/@digipen.edu
|
||||
\date Feb 26, 2023
|
||||
\brief Contains the definition of the managed Slider class with the
|
||||
declaration of functions for working with it.
|
||||
|
||||
Note: This file is written in C++17/CLI.
|
||||
|
||||
Copyright (C) 2023 DigiPen Institute of Technology.
|
||||
Reproduction or disclosure of this file or its contents without the prior written consent
|
||||
of DigiPen Institute of Technology is prohibited.
|
||||
*//*************************************************************************************/
|
||||
#pragma once
|
||||
|
||||
// Project Includes
|
||||
#include "Components/Component.hxx"
|
||||
#include "Math/Vector3.hxx"
|
||||
#include "Math/Quaternion.hxx"
|
||||
// External Dependencies
|
||||
#include "UI/SHSliderComponent.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/// <summary>
|
||||
/// CLR version of the SHADE Engine's SHSliderComponent.
|
||||
/// </summary>
|
||||
public ref class Slider : public Component<SHSliderComponent>
|
||||
{
|
||||
internal:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Constructors */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Constructs a Slider Component that represents a native SHSliderComponent
|
||||
/// tied to the specified Entity.
|
||||
/// </summary>
|
||||
/// <param name="entity">Entity that this Component will be tied to.</param>
|
||||
Slider(Entity entity);
|
||||
|
||||
public:
|
||||
|
||||
float GetValue();
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -73,6 +73,8 @@ namespace SHADE
|
|||
CallbackEvent^ get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Static Clear Functions */
|
||||
|
|
|
@ -30,18 +30,24 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "Graphics\MiddleEnd\Interface\SHRenderable.h"
|
||||
#include "Graphics\MiddleEnd\TextRendering\SHTextRenderableComponent.h"
|
||||
#include "UI\SHUIComponent.h"
|
||||
#include "UI\SHSliderComponent.h"
|
||||
#include "UI\SHCanvasComponent.h"
|
||||
// Project Headers
|
||||
#include "Utility/Convert.hxx"
|
||||
#include "Utility/Debug.hxx"
|
||||
#include "Components/Transform.hxx"
|
||||
#include "Components/RigidBody.hxx"
|
||||
#include "Components/Collider.hxx"
|
||||
#include "Components/Camera.hxx"
|
||||
#include "Components/CameraArm.hxx"
|
||||
#include "Components/Light.hxx"
|
||||
#include "Components\Transform.hxx"
|
||||
#include "Components\RigidBody.hxx"
|
||||
#include "Components\Collider.hxx"
|
||||
#include "Components\Camera.hxx"
|
||||
#include "Components\CameraArm.hxx"
|
||||
#include "Components\Light.hxx"
|
||||
#include "Components\Renderable.hxx"
|
||||
#include "Components\TextRenderable.hxx"
|
||||
#include "Components\UIElement.hxx"
|
||||
#include "Components\Canvas.hxx"
|
||||
#include "Components\Slider.hxx"
|
||||
|
||||
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -327,6 +333,8 @@ namespace SHADE
|
|||
componentMap.Add(createComponentSet<SHLightComponent, Light>());
|
||||
componentMap.Add(createComponentSet<SHTextRenderableComponent, TextRenderable>());
|
||||
componentMap.Add(createComponentSet<SHUIComponent, UIElement>());
|
||||
componentMap.Add(createComponentSet<SHCanvasComponent, Canvas>());
|
||||
componentMap.Add(createComponentSet<SHSliderComponent, Slider>());
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -482,11 +482,20 @@ namespace SHADE
|
|||
{
|
||||
SAFE_NATIVE_CALL_BEGIN
|
||||
// Clear the awake queue
|
||||
for each (Script^ script in awakeList)
|
||||
for each (Script ^ script in awakeList)
|
||||
{
|
||||
script->Awake();
|
||||
if (script->Owner.IsActiveInHierarchy)
|
||||
{
|
||||
script->Awake();
|
||||
}
|
||||
else
|
||||
{
|
||||
inactiveAwakeList.Add(script);
|
||||
}
|
||||
}
|
||||
awakeList.Clear();
|
||||
awakeList.UnionWith(%inactiveAwakeList);
|
||||
inactiveAwakeList.Clear();
|
||||
|
||||
// Clear the start queue
|
||||
for each (Script^ script in startList)
|
||||
|
@ -501,10 +510,7 @@ namespace SHADE
|
|||
}
|
||||
}
|
||||
startList.Clear();
|
||||
for each (Script ^ script in startList)
|
||||
{
|
||||
startList.Add(script);
|
||||
}
|
||||
startList.UnionWith(%inactiveStartList);
|
||||
inactiveStartList.Clear();
|
||||
|
||||
SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore")
|
||||
|
@ -897,6 +903,12 @@ namespace SHADE
|
|||
{
|
||||
return pair->type;
|
||||
}
|
||||
|
||||
/* Sort */
|
||||
System::String^ sortKeyAccessor(System::Type^ type)
|
||||
{
|
||||
return type->Name;
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptStore::refreshScriptTypeList()
|
||||
|
@ -920,6 +932,10 @@ namespace SHADE
|
|||
Func<Pair^, Type^>^ selector = gcnew Func<Pair^, Type^>(selectorFunc);
|
||||
scriptTypeList = Enumerable::Select(whereResult, selector);
|
||||
|
||||
/* Sort: By Alphabetical Order */
|
||||
Func<Type^, String^>^ sorter = gcnew Func<Type^, String^>(sortKeyAccessor);
|
||||
scriptTypeList = Enumerable::OrderBy(scriptTypeList, sorter);
|
||||
|
||||
// Log
|
||||
std::ostringstream oss;
|
||||
oss << "[ScriptStore] Successfully retrieved references to " << Enumerable::Count(scriptTypeList)
|
||||
|
|
|
@ -353,6 +353,7 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------------*/
|
||||
static ScriptDictionary scripts;
|
||||
static ScriptSet awakeList;
|
||||
static ScriptSet inactiveAwakeList;
|
||||
static ScriptSet startList;
|
||||
static ScriptSet inactiveStartList;
|
||||
static ScriptSet disposalQueue;
|
||||
|
|
Loading…
Reference in New Issue