Implemented scanline and silhouette effect #363
|
@ -1,4 +1,4 @@
|
||||||
Start Maximized: true
|
Start Maximized: true
|
||||||
Working Scene ID: 86098106
|
Working Scene ID: 97158628
|
||||||
Window Size: {x: 1920, y: 1013}
|
Window Size: {x: 1920, y: 1013}
|
||||||
Style: 0
|
Style: 0
|
|
@ -9567,15 +9567,18 @@
|
||||||
maxMultiplierDuration: 5
|
maxMultiplierDuration: 5
|
||||||
maxMultiplierCombo: 10
|
maxMultiplierCombo: 10
|
||||||
multiplierFont: 60
|
multiplierFont: 60
|
||||||
|
- Type: PauseMenu
|
||||||
|
Enabled: true
|
||||||
|
resumeBtn: 8
|
||||||
|
retryBtn: 461
|
||||||
|
quitBtn: 0
|
||||||
|
gamePauseText: 11
|
||||||
|
canvas: 10
|
||||||
- EID: 199
|
- EID: 199
|
||||||
Name: =====Text====
|
Name: =====Text====
|
||||||
IsActive: true
|
IsActive: true
|
||||||
NumberOfChildren: 3
|
NumberOfChildren: 4
|
||||||
Components:
|
Components: ~
|
||||||
Canvas Component:
|
|
||||||
Canvas Width: 1920
|
|
||||||
Canvas Height: 1080
|
|
||||||
IsActive: true
|
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 237
|
- EID: 237
|
||||||
Name: Score
|
Name: Score
|
||||||
|
@ -9631,6 +9634,21 @@
|
||||||
Canvas ID: 199
|
Canvas ID: 199
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
|
- EID: 11
|
||||||
|
Name: GamePause
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: -250, y: 300, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 100, y: 100, z: 100}
|
||||||
|
IsActive: true
|
||||||
|
Text Renderer Component:
|
||||||
|
Text: Game Pause
|
||||||
|
Font: 176667660
|
||||||
|
IsActive: false
|
||||||
|
Scripts: ~
|
||||||
- EID: 198
|
- EID: 198
|
||||||
Name: ====Raccoon====
|
Name: ====Raccoon====
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -9689,18 +9707,21 @@
|
||||||
maxJumpHeight: 2
|
maxJumpHeight: 2
|
||||||
maxJumpTime: 0.75
|
maxJumpTime: 0.75
|
||||||
fallMultipler: 3
|
fallMultipler: 3
|
||||||
lightMultiper: 0.75
|
jumpPadMultiplayer: 1.20000005
|
||||||
mediumMultiper: 0.5
|
lightMultiper: 0.899999976
|
||||||
heavyMultiper: 0.25
|
mediumMultiper: 0.699999988
|
||||||
|
heavyMultiper: 0.5
|
||||||
- Type: PickAndThrow
|
- Type: PickAndThrow
|
||||||
Enabled: true
|
Enabled: true
|
||||||
throwForce: [10, 8, 10]
|
throwForce: [10, 8, 10]
|
||||||
cameraArmOffSet: [0, 0.25, 0]
|
cameraArmOffSet: [0.25, 0.600000024, 0.200000003]
|
||||||
delayTimer: 1
|
delayTimer: 1
|
||||||
aimingLength: 1
|
aimingLength: 1
|
||||||
throwItem: false
|
throwItem: false
|
||||||
rayDistance: 0.75
|
rayDistance: 0.75
|
||||||
rayHeight: 0.100000001
|
rayHeight: 0.100000001
|
||||||
|
aimingFOV: 50
|
||||||
|
defaultFOV: 45
|
||||||
- EID: 3
|
- EID: 3
|
||||||
Name: HoldingPoint
|
Name: HoldingPoint
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -9727,31 +9748,31 @@
|
||||||
Pitch: 0
|
Pitch: 0
|
||||||
Yaw: 360
|
Yaw: 360
|
||||||
Roll: 1.28065994e-06
|
Roll: 1.28065994e-06
|
||||||
Width: 1728
|
Width: 2560
|
||||||
Height: 832
|
Height: 1369
|
||||||
Near: 0.00999999978
|
Near: 0.00999999978
|
||||||
Far: 10000
|
Far: 10000
|
||||||
Perspective: true
|
Perspective: true
|
||||||
FOV: 90
|
FOV: 45
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Camera Arm Component:
|
Camera Arm Component:
|
||||||
Arm Pitch: 0
|
Arm Pitch: 0
|
||||||
Arm Yaw: 0
|
Arm Yaw: 0
|
||||||
Arm Length: 3
|
Arm Length: 3
|
||||||
Look At Camera Origin: true
|
Look At Camera Origin: true
|
||||||
Target Offset: {x: 0, y: 0, z: 0}
|
Target Offset: {x: 0, y: 0.75, z: 0}
|
||||||
Camera Collision: true
|
Camera Collision: true
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: SHADE_Scripting.ThirdPersonCamera
|
- Type: SHADE_Scripting.ThirdPersonCamera
|
||||||
Enabled: true
|
Enabled: true
|
||||||
armLength: 3
|
armLength: 3
|
||||||
turnSpeedPitch: 0.300000012
|
turnSpeedPitch: 0.200000003
|
||||||
turnSpeedYaw: 0.5
|
turnSpeedYaw: 0.400000006
|
||||||
pitchClamp: 45
|
|
||||||
inverseXControls: false
|
inverseXControls: false
|
||||||
inverseYControls: true
|
inverseYControls: false
|
||||||
lowerClamp: 5
|
pitchUpperClamp: 45
|
||||||
|
pitchLowerClamp: 5
|
||||||
- EID: 9
|
- EID: 9
|
||||||
Name: PlayerBag
|
Name: PlayerBag
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -10503,11 +10524,11 @@
|
||||||
Translate: {x: 2.70000005, y: 0.100000001, z: -2}
|
Translate: {x: 2.70000005, y: 0.100000001, z: -2}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: false
|
||||||
Renderable Component:
|
Renderable Component:
|
||||||
Mesh: 140697366
|
Mesh: 140697366
|
||||||
Material: 129495479
|
Material: 129495479
|
||||||
IsActive: true
|
IsActive: false
|
||||||
RigidBody Component:
|
RigidBody Component:
|
||||||
Type: Dynamic
|
Type: Dynamic
|
||||||
Drag: 0.00999999978
|
Drag: 0.00999999978
|
||||||
|
@ -10521,7 +10542,7 @@
|
||||||
Freeze Rotation X: true
|
Freeze Rotation X: true
|
||||||
Freeze Rotation Y: false
|
Freeze Rotation Y: false
|
||||||
Freeze Rotation Z: true
|
Freeze Rotation Z: true
|
||||||
IsActive: true
|
IsActive: false
|
||||||
Collider Component:
|
Collider Component:
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
|
@ -10533,7 +10554,7 @@
|
||||||
Density: 1
|
Density: 1
|
||||||
Position Offset: {x: 0, y: 0.899999976, z: 0}
|
Position Offset: {x: 0, y: 0.899999976, z: 0}
|
||||||
Rotation Offset: {x: 0, y: 0, z: 0}
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
IsActive: true
|
IsActive: false
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: Homeowner1
|
- Type: Homeowner1
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
@ -10545,4 +10566,155 @@
|
||||||
eyeOffset: [0, 1.64999998, 0]
|
eyeOffset: [0, 1.64999998, 0]
|
||||||
distanceToCapture: 0.5
|
distanceToCapture: 0.5
|
||||||
captureTime: 0.5
|
captureTime: 0.5
|
||||||
footstepSFXIntervalMultiplier: 0.5
|
footstepSFXIntervalMultiplier: 0.5
|
||||||
|
- EID: 12
|
||||||
|
Name: Mesh_Meat
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 2.30459714, y: 0.209537908, z: 6.371418}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 136892700
|
||||||
|
Material: 131956078
|
||||||
|
IsActive: true
|
||||||
|
RigidBody Component:
|
||||||
|
Type: Dynamic
|
||||||
|
Drag: 0.00999999978
|
||||||
|
Angular Drag: 0.100000001
|
||||||
|
Use Gravity: true
|
||||||
|
Interpolate: false
|
||||||
|
Sleeping Enabled: true
|
||||||
|
Freeze Position X: false
|
||||||
|
Freeze Position Y: false
|
||||||
|
Freeze Position Z: false
|
||||||
|
Freeze Rotation X: false
|
||||||
|
Freeze Rotation Y: false
|
||||||
|
Freeze Rotation Z: false
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Collision Tag: 2
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 0.300000012, y: 0.300000012, z: 0.300000012}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
IsActive: true
|
||||||
|
Scripts:
|
||||||
|
- Type: Item
|
||||||
|
Enabled: true
|
||||||
|
Score: 50
|
||||||
|
currCategory: 1
|
||||||
|
density: 1
|
||||||
|
dontReturn: false
|
||||||
|
- EID: 16
|
||||||
|
Name: JumpPad
|
||||||
|
IsActive: false
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 3.43332767, y: 0.149463654, z: 6.84711409}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: false
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Collision Tag: 1
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 0.25, z: 1}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
IsActive: false
|
||||||
|
Scripts:
|
||||||
|
- Type: JumpPad
|
||||||
|
Enabled: true
|
||||||
|
- EID: 10
|
||||||
|
Name: Canvas
|
||||||
|
IsActive: false
|
||||||
|
NumberOfChildren: 3
|
||||||
|
Components:
|
||||||
|
Canvas Component:
|
||||||
|
Canvas Width: 1920
|
||||||
|
Canvas Height: 1080
|
||||||
|
IsActive: false
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 8
|
||||||
|
Name: ResumeButton
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 100, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 300, y: 200, z: 500}
|
||||||
|
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: 10
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 0
|
||||||
|
Name: QuitButton
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: -300, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 300, y: 200, z: 500}
|
||||||
|
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: 10
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 461
|
||||||
|
Name: RetryButton
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: -100, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 300, y: 200, z: 500}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 141771688
|
||||||
|
Material: 129340704
|
||||||
|
IsActive: true
|
||||||
|
Button Component:
|
||||||
|
Default Texture: 55782622
|
||||||
|
Hovered Texture: 58972174
|
||||||
|
Clicked Texture: 55224464
|
||||||
|
IsActive: true
|
||||||
|
UI Component:
|
||||||
|
Canvas ID: 10
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
|
@ -6,6 +6,7 @@
|
||||||
Canvas Component:
|
Canvas Component:
|
||||||
Canvas Width: 1920
|
Canvas Width: 1920
|
||||||
Canvas Height: 1080
|
Canvas Height: 1080
|
||||||
|
Scale by canvas width: false
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 1
|
- EID: 1
|
||||||
|
@ -24,6 +25,8 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
UI Component:
|
UI Component:
|
||||||
Canvas ID: 0
|
Canvas ID: 0
|
||||||
|
Hovered: false
|
||||||
|
Clicked: false
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 5
|
- EID: 5
|
||||||
|
@ -47,6 +50,8 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
UI Component:
|
UI Component:
|
||||||
Canvas ID: 0
|
Canvas ID: 0
|
||||||
|
Hovered: false
|
||||||
|
Clicked: false
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: ChangeSceneButton
|
- Type: ChangeSceneButton
|
||||||
|
@ -73,6 +78,8 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
UI Component:
|
UI Component:
|
||||||
Canvas ID: 0
|
Canvas ID: 0
|
||||||
|
Hovered: false
|
||||||
|
Clicked: false
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: QuitButton
|
- Type: QuitButton
|
||||||
|
@ -106,11 +113,12 @@
|
||||||
Pitch: 0
|
Pitch: 0
|
||||||
Yaw: 0
|
Yaw: 0
|
||||||
Roll: 0
|
Roll: 0
|
||||||
Width: 1920
|
Width: 1319
|
||||||
Height: 1080
|
Height: 622
|
||||||
Near: 0.00999999978
|
Near: 0.00999999978
|
||||||
Far: 10000
|
Far: 10000
|
||||||
Perspective: true
|
Perspective: true
|
||||||
|
FOV: 90
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 4
|
- EID: 4
|
||||||
|
|
|
@ -19,5 +19,13 @@ namespace SHADE_Scripting.Audio
|
||||||
h.Value.Stop(fadeOut);
|
h.Value.Stop(fadeOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void pauseAllSounds(bool pause)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<string, AudioClipHandler> h in audioClipHandlers)
|
||||||
|
{
|
||||||
|
h.Value.SetPause(pause);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ using static Item;
|
||||||
|
|
||||||
public class PickAndThrow : Script
|
public class PickAndThrow : Script
|
||||||
{
|
{
|
||||||
public Vector3 throwForce = new Vector3(100.0f, 200.0f, 100.0f);
|
public Vector3 throwForce = new Vector3(10.0f, 8.0f, 10.0f);
|
||||||
public Vector3 cameraArmOffSet = new Vector3(0.0f, 0.25f, 0.0f);
|
public Vector3 cameraArmOffSet = new Vector3(0.0f, 0.25f, 0.0f);
|
||||||
public GameObject item { get; set; }
|
public GameObject item { get; set; }
|
||||||
public float delayTimer = 1.0f;
|
public float delayTimer = 1.0f;
|
||||||
|
@ -33,6 +33,9 @@ public class PickAndThrow : Script
|
||||||
[Tooltip("Height of ray")]
|
[Tooltip("Height of ray")]
|
||||||
public float rayHeight = 0.1f;
|
public float rayHeight = 0.1f;
|
||||||
|
|
||||||
|
public float aimingFOV = 50;
|
||||||
|
public float defaultFOV = 45;
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
pc = GetScript<PlayerController>();
|
pc = GetScript<PlayerController>();
|
||||||
|
@ -74,6 +77,7 @@ public class PickAndThrow : Script
|
||||||
pc.isAiming = true;
|
pc.isAiming = true;
|
||||||
pc.camArm.ArmLength = aimingLength;
|
pc.camArm.ArmLength = aimingLength;
|
||||||
pc.camArm.TargetOffset = cameraArmOffSet;
|
pc.camArm.TargetOffset = cameraArmOffSet;
|
||||||
|
pc.cam.FOV = aimingFOV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
|
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
|
||||||
|
@ -83,6 +87,7 @@ public class PickAndThrow : Script
|
||||||
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
||||||
pc.isAiming = false;
|
pc.isAiming = false;
|
||||||
pc.camArm.TargetOffset = Vector3.Zero;
|
pc.camArm.TargetOffset = Vector3.Zero;
|
||||||
|
pc.cam.FOV = defaultFOV;
|
||||||
if (tpc)
|
if (tpc)
|
||||||
pc.camArm.ArmLength = tpc.armLength;
|
pc.camArm.ArmLength = tpc.armLength;
|
||||||
pc.holdItem = false;
|
pc.holdItem = false;
|
||||||
|
@ -103,6 +108,7 @@ public class PickAndThrow : Script
|
||||||
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming)
|
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming)
|
||||||
{
|
{
|
||||||
pc.isAiming = false;
|
pc.isAiming = false;
|
||||||
|
pc.cam.FOV = defaultFOV;
|
||||||
pc.camArm.TargetOffset = Vector3.Zero;
|
pc.camArm.TargetOffset = Vector3.Zero;
|
||||||
if (tpc)
|
if (tpc)
|
||||||
pc.camArm.ArmLength = tpc.armLength;
|
pc.camArm.ArmLength = tpc.armLength;
|
||||||
|
@ -132,7 +138,7 @@ public class PickAndThrow : Script
|
||||||
{
|
{
|
||||||
if (itemScript)
|
if (itemScript)
|
||||||
{
|
{
|
||||||
Vector3 vec = new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir);
|
Vector3 vec = new Vector3(throwForce.x * lastXDir, throwForce.y + (throwForce.y * GetPitchRatioRange()), throwForce.z * lastZDir);
|
||||||
if (itemScript.currCategory == ItemCategory.LIGHT)
|
if (itemScript.currCategory == ItemCategory.LIGHT)
|
||||||
itemRidigBody.AddForce(vec * 0.2f);
|
itemRidigBody.AddForce(vec * 0.2f);
|
||||||
if (itemScript.currCategory == ItemCategory.MEDIUM)
|
if (itemScript.currCategory == ItemCategory.MEDIUM)
|
||||||
|
@ -254,5 +260,10 @@ public class PickAndThrow : Script
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float GetPitchRatioRange()
|
||||||
|
{
|
||||||
|
return (pc.camArm.Pitch - tpc.pitchUpperClamp) / (tpc.pitchLowerClamp - tpc.pitchUpperClamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -65,7 +65,7 @@ public class PlayerController : Script
|
||||||
//Jumping vars==================================================================
|
//Jumping vars==================================================================
|
||||||
[Tooltip("max height of the jump")]
|
[Tooltip("max height of the jump")]
|
||||||
public float maxJumpHeight = 1.0f;
|
public float maxJumpHeight = 1.0f;
|
||||||
[Tooltip("max amt of time it will take for the jump")]
|
[Tooltip("max amount of time it will take for the jump")]
|
||||||
public float maxJumpTime = 0.5f;
|
public float maxJumpTime = 0.5f;
|
||||||
[Tooltip("increase gravity when falling")]
|
[Tooltip("increase gravity when falling")]
|
||||||
public float fallMultipler = 3.0f;
|
public float fallMultipler = 3.0f;
|
||||||
|
@ -73,6 +73,9 @@ public class PlayerController : Script
|
||||||
private bool isGrounded = true;
|
private bool isGrounded = true;
|
||||||
private float gravity = -9.8f;
|
private float gravity = -9.8f;
|
||||||
private float groundGravity = -0.5f;
|
private float groundGravity = -0.5f;
|
||||||
|
public bool landedOnJumpPad { get; set; }
|
||||||
|
[Tooltip("multiply height on Jump Pad ")]
|
||||||
|
public float jumpPadMultiplayer = 2.0f;
|
||||||
|
|
||||||
//ItemMultipler==================================================================
|
//ItemMultipler==================================================================
|
||||||
[Tooltip("How light item will affect player jump")]
|
[Tooltip("How light item will affect player jump")]
|
||||||
|
@ -88,6 +91,7 @@ public class PlayerController : Script
|
||||||
isMoveKeyPress = false;
|
isMoveKeyPress = false;
|
||||||
holdItem = false;
|
holdItem = false;
|
||||||
isAiming = false;
|
isAiming = false;
|
||||||
|
landedOnJumpPad = false;
|
||||||
|
|
||||||
//Jump setup
|
//Jump setup
|
||||||
float timeToApex = maxJumpTime / 2;
|
float timeToApex = maxJumpTime / 2;
|
||||||
|
@ -287,7 +291,7 @@ public class PlayerController : Script
|
||||||
{
|
{
|
||||||
if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE)
|
if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE)
|
||||||
{
|
{
|
||||||
if (Input.GetKeyDown(Input.KeyCode.Space) && isGrounded && rb != null)
|
if ( (Input.GetKeyDown(Input.KeyCode.Space) || landedOnJumpPad ) && isGrounded && rb != null)
|
||||||
{
|
{
|
||||||
currentState = RaccoonStates.JUMP;
|
currentState = RaccoonStates.JUMP;
|
||||||
Vector3 v = rb.LinearVelocity;
|
Vector3 v = rb.LinearVelocity;
|
||||||
|
@ -302,6 +306,12 @@ public class PlayerController : Script
|
||||||
if (item != null && item.currCategory == ItemCategory.HEAVY)
|
if (item != null && item.currCategory == ItemCategory.HEAVY)
|
||||||
v.y *= heavyMultiper;
|
v.y *= heavyMultiper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (landedOnJumpPad)
|
||||||
|
{
|
||||||
|
v.y *= jumpPadMultiplayer;
|
||||||
|
landedOnJumpPad = false;
|
||||||
|
}
|
||||||
rb.LinearVelocity = v;
|
rb.LinearVelocity = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@ namespace SHADE_Scripting
|
||||||
public float armLength = 2.0f;
|
public float armLength = 2.0f;
|
||||||
public float turnSpeedPitch = 0.3f;
|
public float turnSpeedPitch = 0.3f;
|
||||||
public float turnSpeedYaw = 0.5f;
|
public float turnSpeedYaw = 0.5f;
|
||||||
public float pitchClamp = 45.0f;
|
|
||||||
public bool inverseXControls = false;
|
public bool inverseXControls = false;
|
||||||
public bool inverseYControls = false;
|
public bool inverseYControls = false;
|
||||||
public float lowerClamp = 5.0f;
|
public float pitchUpperClamp = 45.0f;
|
||||||
|
public float pitchLowerClamp = 5.0f;
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
|
@ -51,17 +51,17 @@ namespace SHADE_Scripting
|
||||||
arm.Pitch += vel.y * turnSpeedPitch * Time.DeltaTimeF;
|
arm.Pitch += vel.y * turnSpeedPitch * Time.DeltaTimeF;
|
||||||
|
|
||||||
if (inverseXControls)
|
if (inverseXControls)
|
||||||
arm.Yaw -= vel.x * turnSpeedYaw * Time.DeltaTimeF;
|
|
||||||
else
|
|
||||||
arm.Yaw += vel.x * turnSpeedYaw * Time.DeltaTimeF;
|
arm.Yaw += vel.x * turnSpeedYaw * Time.DeltaTimeF;
|
||||||
|
else
|
||||||
|
arm.Yaw -= vel.x * turnSpeedYaw * Time.DeltaTimeF;
|
||||||
|
|
||||||
if (arm.Pitch > pitchClamp)
|
if (arm.Pitch > pitchUpperClamp)
|
||||||
{
|
{
|
||||||
arm.Pitch = pitchClamp;
|
arm.Pitch = pitchUpperClamp;
|
||||||
}
|
}
|
||||||
else if (arm.Pitch < lowerClamp)
|
else if (arm.Pitch < pitchLowerClamp)
|
||||||
{
|
{
|
||||||
arm.Pitch = lowerClamp;
|
arm.Pitch = pitchLowerClamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ public class GameManager : Script
|
||||||
private Vector3 fontScalar;
|
private Vector3 fontScalar;
|
||||||
|
|
||||||
public static GameManager Instance { get; private set; }
|
public static GameManager Instance { get; private set; }
|
||||||
|
//public static int highScore { get; private set; } maybe need
|
||||||
|
|
||||||
|
public bool GamePause { get; set; }
|
||||||
|
|
||||||
protected override void start()
|
protected override void start()
|
||||||
{
|
{
|
||||||
|
@ -83,7 +86,11 @@ public class GameManager : Script
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
Cheats();
|
if (GamePause)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (currGameState == GameState.START)
|
if (currGameState == GameState.START)
|
||||||
{
|
{
|
||||||
timer -= Time.DeltaTimeF;
|
timer -= Time.DeltaTimeF;
|
||||||
|
@ -140,15 +147,6 @@ public class GameManager : Script
|
||||||
Instance = null;
|
Instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Cheats()
|
|
||||||
{
|
|
||||||
if (Input.GetKeyDown(Input.KeyCode.Escape))
|
|
||||||
{
|
|
||||||
Audio.StopAllSounds();
|
|
||||||
SceneManager.ChangeScene(97158628);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ItemScored()
|
public void ItemScored()
|
||||||
{
|
{
|
||||||
totalItemCount -= 1;
|
totalItemCount -= 1;
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
using SHADE;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class JumpPad : Script
|
||||||
|
{
|
||||||
|
protected override void awake()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onCollisionEnter(CollisionInfo info)
|
||||||
|
{
|
||||||
|
if (info.GameObject.GetScript<PlayerController>() && info.GameObject.GetScript<PlayerController>().currentState == PlayerController.RaccoonStates.FALLING)
|
||||||
|
{
|
||||||
|
info.GameObject.GetScript<PlayerController>().landedOnJumpPad = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: SC_JumpPad
|
||||||
|
ID: 167326885
|
||||||
|
Type: 9
|
|
@ -11,8 +11,9 @@ public class ChangeSceneButton : Script
|
||||||
UIElement ui = GetComponent<UIElement>();
|
UIElement ui = GetComponent<UIElement>();
|
||||||
if (ui != null)
|
if (ui != null)
|
||||||
{
|
{
|
||||||
ui.OnClick.RegisterAction(() =>
|
ui.OnRelease.RegisterAction(() =>
|
||||||
{
|
{
|
||||||
|
|
||||||
if (sceneID != 0)
|
if (sceneID != 0)
|
||||||
{
|
{
|
||||||
Audio.PlaySFXOnce2D("event:/UI/success");
|
Audio.PlaySFXOnce2D("event:/UI/success");
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
using System;
|
||||||
|
using SHADE;
|
||||||
|
using SHADE_Scripting.Audio;
|
||||||
|
|
||||||
|
public class PauseMenu : Script
|
||||||
|
{
|
||||||
|
public GameObject resumeBtn;
|
||||||
|
public GameObject retryBtn;
|
||||||
|
public GameObject quitBtn;
|
||||||
|
|
||||||
|
public GameObject gamePauseText;
|
||||||
|
public GameObject canvas;
|
||||||
|
|
||||||
|
protected override void awake()
|
||||||
|
{
|
||||||
|
GameManager.Instance.GamePause = false;
|
||||||
|
if (gamePauseText)
|
||||||
|
gamePauseText.GetComponent<TextRenderable>().Enabled = false;
|
||||||
|
if (canvas)
|
||||||
|
canvas.SetActive(false);
|
||||||
|
|
||||||
|
if (!resumeBtn)
|
||||||
|
Debug.LogError("Resume Btn missing");
|
||||||
|
|
||||||
|
if (!retryBtn)
|
||||||
|
Debug.LogError("Retry Btn missing");
|
||||||
|
|
||||||
|
if (!quitBtn)
|
||||||
|
Debug.LogError("Quit Btn missing");
|
||||||
|
}
|
||||||
|
protected override void start()
|
||||||
|
{
|
||||||
|
//resume
|
||||||
|
UIElement resume = resumeBtn.GetComponent<UIElement>();
|
||||||
|
if (resume != null)
|
||||||
|
{
|
||||||
|
resume.OnClick.RegisterAction(() =>
|
||||||
|
{
|
||||||
|
if (GameManager.Instance.GamePause)
|
||||||
|
{
|
||||||
|
GameManager.Instance.GamePause = false;
|
||||||
|
AudioHandler.pauseAllSounds(false);
|
||||||
|
if (gamePauseText)
|
||||||
|
gamePauseText.GetComponent<TextRenderable>().Enabled = false;
|
||||||
|
if (canvas)
|
||||||
|
canvas.SetActive(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Failed to register resume button.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//retry
|
||||||
|
UIElement retry = retryBtn.GetComponent<UIElement>();
|
||||||
|
if (retry != null)
|
||||||
|
{
|
||||||
|
retry.OnClick.RegisterAction(() =>
|
||||||
|
{
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
//get curr scene
|
||||||
|
//SceneManager.ChangeScene();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Failed to register retry button.");
|
||||||
|
}
|
||||||
|
|
||||||
|
UIElement quit = quitBtn.GetComponent<UIElement>();
|
||||||
|
if (quit != null)
|
||||||
|
{
|
||||||
|
quit.OnClick.RegisterAction(() =>
|
||||||
|
{
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
//go to main menu
|
||||||
|
SceneManager.ChangeScene(97158628);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Failed to register quit button.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void update()
|
||||||
|
{
|
||||||
|
if (GameManager.Instance.GamePause)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause)
|
||||||
|
{
|
||||||
|
GameManager.Instance.GamePause = true;
|
||||||
|
AudioHandler.pauseAllSounds(true);
|
||||||
|
if (gamePauseText)
|
||||||
|
gamePauseText.GetComponent<TextRenderable>().Enabled = true;
|
||||||
|
if (canvas)
|
||||||
|
canvas.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: SC_PauseMenu
|
||||||
|
ID: 151952680
|
||||||
|
Type: 9
|
|
@ -132,16 +132,19 @@ namespace Sandbox
|
||||||
SHSystemManager::RegisterRoutine<SHTransformSystem, SHTransformSystem::TransformPostPhysicsUpdate>();
|
SHSystemManager::RegisterRoutine<SHTransformSystem, SHTransformSystem::TransformPostPhysicsUpdate>();
|
||||||
SHSystemManager::RegisterRoutine<SHDebugDrawSystem, SHDebugDrawSystem::ProcessPointsRoutine>();
|
SHSystemManager::RegisterRoutine<SHDebugDrawSystem, SHDebugDrawSystem::ProcessPointsRoutine>();
|
||||||
|
|
||||||
SHSystemManager::RegisterRoutine<SHScriptEngine, SHScriptEngine::GizmosDrawRoutine>();
|
|
||||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::PrepareRenderRoutine>();
|
|
||||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BatcherDispatcherRoutine>();
|
|
||||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BeginRoutine>();
|
|
||||||
|
|
||||||
//SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::EditorCameraUpdate>();
|
//SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::EditorCameraUpdate>();
|
||||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::AddUIComponentRoutine>();
|
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::AddUIComponentRoutine>();
|
||||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateCanvasMatrixRoutine>();
|
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateCanvasMatrixRoutine>();
|
||||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateUIMatrixRoutine>();
|
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateUIMatrixRoutine>();
|
||||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateButtonsRoutine>();
|
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateButtonsRoutine>();
|
||||||
|
|
||||||
|
SHSystemManager::RegisterRoutine<SHScriptEngine, SHScriptEngine::GizmosDrawRoutine>();
|
||||||
|
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::PrepareRenderRoutine>();
|
||||||
|
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BatcherDispatcherRoutine>();
|
||||||
|
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BeginRoutine>();
|
||||||
|
|
||||||
|
|
||||||
SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::CameraSystemUpdate>();
|
SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::CameraSystemUpdate>();
|
||||||
|
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
|
|
@ -10,8 +10,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHCameraComponent::SHCameraComponent()
|
SHCameraComponent::SHCameraComponent()
|
||||||
:yaw(0.0f), pitch(0.0f), roll(0.0f)
|
:yaw(0.0f), pitch(0.0f), roll(0.0f)
|
||||||
, width(1920.0f), height(1080.0f), zNear(0.01f), zFar(10000.0f), fov(90.0f), movementSpeed(1.0f), turnSpeed(0.5f)
|
, width(1920.0f), zNear(0.01f), zFar(10000.0f), fov(90.0f), movementSpeed(1.0f), turnSpeed(0.5f)
|
||||||
, perspProj(true), dirtyView(true), dirtyProj(true)
|
, perspProj(true), dirtyView(true), dirtyProj(true), followScreenAR(true)
|
||||||
, viewMatrix(), perspProjMatrix(), orthoProjMatrix()
|
, viewMatrix(), perspProjMatrix(), orthoProjMatrix()
|
||||||
, position(), offset()
|
, position(), offset()
|
||||||
{
|
{
|
||||||
|
@ -122,11 +122,6 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHCameraComponent::SetHeight(float height) noexcept
|
|
||||||
{
|
|
||||||
this->height = height;
|
|
||||||
dirtyProj = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SHCameraComponent::SetNear(float znear) noexcept
|
void SHCameraComponent::SetNear(float znear) noexcept
|
||||||
{
|
{
|
||||||
|
@ -176,10 +171,7 @@ namespace SHADE
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SHCameraComponent::GetHeight() const noexcept
|
|
||||||
{
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
float SHCameraComponent::GetNear() const noexcept
|
float SHCameraComponent::GetNear() const noexcept
|
||||||
{
|
{
|
||||||
|
@ -191,10 +183,7 @@ namespace SHADE
|
||||||
return zFar;
|
return zFar;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SHCameraComponent::GetAspectRatio() const noexcept
|
|
||||||
{
|
|
||||||
return width/height;
|
|
||||||
}
|
|
||||||
|
|
||||||
float SHCameraComponent::GetFOV() const noexcept
|
float SHCameraComponent::GetFOV() const noexcept
|
||||||
{
|
{
|
||||||
|
@ -251,11 +240,11 @@ RTTR_REGISTRATION
|
||||||
.property("Yaw", &SHCameraComponent::GetYaw, &SHCameraComponent::SetYaw)
|
.property("Yaw", &SHCameraComponent::GetYaw, &SHCameraComponent::SetYaw)
|
||||||
.property("Roll", &SHCameraComponent::GetRoll, &SHCameraComponent::SetRoll)
|
.property("Roll", &SHCameraComponent::GetRoll, &SHCameraComponent::SetRoll)
|
||||||
.property("Width", &SHCameraComponent::GetWidth, &SHCameraComponent::SetWidth)
|
.property("Width", &SHCameraComponent::GetWidth, &SHCameraComponent::SetWidth)
|
||||||
.property("Height", &SHCameraComponent::GetHeight, &SHCameraComponent::SetHeight)
|
|
||||||
.property("Near", &SHCameraComponent::GetNear, &SHCameraComponent::SetNear)
|
.property("Near", &SHCameraComponent::GetNear, &SHCameraComponent::SetNear)
|
||||||
.property("Far", &SHCameraComponent::GetFar, &SHCameraComponent::SetFar)
|
.property("Far", &SHCameraComponent::GetFar, &SHCameraComponent::SetFar)
|
||||||
.property("Perspective", &SHCameraComponent::GetIsPerspective, &SHCameraComponent::SetIsPerspective)
|
.property("Perspective", &SHCameraComponent::GetIsPerspective, &SHCameraComponent::SetIsPerspective)
|
||||||
.property("FOV",&SHCameraComponent::GetFOV, &SHCameraComponent::SetFOV);
|
.property("FOV", &SHCameraComponent::GetFOV, &SHCameraComponent::SetFOV);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ namespace SHADE
|
||||||
float roll;
|
float roll;
|
||||||
|
|
||||||
float width;
|
float width;
|
||||||
float height;
|
|
||||||
float zNear;
|
float zNear;
|
||||||
float zFar;
|
float zFar;
|
||||||
float fov;
|
float fov;
|
||||||
|
@ -27,7 +26,6 @@ namespace SHADE
|
||||||
bool dirtyView;
|
bool dirtyView;
|
||||||
bool dirtyProj;
|
bool dirtyProj;
|
||||||
|
|
||||||
|
|
||||||
SHMatrix viewMatrix;
|
SHMatrix viewMatrix;
|
||||||
SHMatrix perspProjMatrix;
|
SHMatrix perspProjMatrix;
|
||||||
SHMatrix orthoProjMatrix;
|
SHMatrix orthoProjMatrix;
|
||||||
|
@ -45,6 +43,8 @@ namespace SHADE
|
||||||
SHCameraComponent();
|
SHCameraComponent();
|
||||||
virtual ~SHCameraComponent();
|
virtual ~SHCameraComponent();
|
||||||
|
|
||||||
|
bool followScreenAR;
|
||||||
|
|
||||||
|
|
||||||
//Getters and setters.
|
//Getters and setters.
|
||||||
void SetYaw(float yaw) noexcept;
|
void SetYaw(float yaw) noexcept;
|
||||||
|
@ -57,7 +57,6 @@ namespace SHADE
|
||||||
void SetPosition(SHVec3 pos) noexcept;
|
void SetPosition(SHVec3 pos) noexcept;
|
||||||
|
|
||||||
void SetWidth(float width) noexcept;
|
void SetWidth(float width) noexcept;
|
||||||
void SetHeight(float height) noexcept;
|
|
||||||
void SetNear(float znear) noexcept;
|
void SetNear(float znear) noexcept;
|
||||||
void SetFar(float zfar) noexcept;
|
void SetFar(float zfar) noexcept;
|
||||||
void SetFOV(float fov) noexcept;
|
void SetFOV(float fov) noexcept;
|
||||||
|
@ -70,11 +69,9 @@ namespace SHADE
|
||||||
float GetRoll() const noexcept;
|
float GetRoll() const noexcept;
|
||||||
|
|
||||||
float GetWidth() const noexcept;
|
float GetWidth() const noexcept;
|
||||||
float GetHeight() const noexcept;
|
|
||||||
float GetNear() const noexcept;
|
float GetNear() const noexcept;
|
||||||
float GetFar() const noexcept;
|
float GetFar() const noexcept;
|
||||||
|
|
||||||
float GetAspectRatio() const noexcept;
|
|
||||||
float GetFOV() const noexcept;
|
float GetFOV() const noexcept;
|
||||||
bool GetIsPerspective() const noexcept;
|
bool GetIsPerspective() const noexcept;
|
||||||
|
|
||||||
|
|
|
@ -99,13 +99,13 @@ namespace SHADE
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SHCameraDirector::GetHeight() noexcept
|
//float SHCameraDirector::GetHeight() noexcept
|
||||||
{
|
//{
|
||||||
SHCameraComponent* camComponent = GetMainCameraComponent();
|
// SHCameraComponent* camComponent = GetMainCameraComponent();
|
||||||
if (camComponent)
|
// if (camComponent)
|
||||||
return camComponent->GetHeight();
|
// return camComponent->GetHeight();
|
||||||
else
|
// else
|
||||||
return 0.0f;
|
// return 0.0f;
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace SHADE
|
||||||
SHMatrix const& GetOrthoMatrix() noexcept;
|
SHMatrix const& GetOrthoMatrix() noexcept;
|
||||||
SHMatrix const& GetPerspectiveMatrix() noexcept;
|
SHMatrix const& GetPerspectiveMatrix() noexcept;
|
||||||
float GetWidth() noexcept;
|
float GetWidth() noexcept;
|
||||||
float GetHeight() noexcept;
|
//float GetHeight() noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SHMatrix viewMatrix;
|
SHMatrix viewMatrix;
|
||||||
|
|
|
@ -116,7 +116,6 @@ namespace SHADE
|
||||||
editorCamera.SetYaw(0.0f);
|
editorCamera.SetYaw(0.0f);
|
||||||
editorCamera.SetRoll(0.0f);
|
editorCamera.SetRoll(0.0f);
|
||||||
editorCamera.SetWidth(1080.0f);
|
editorCamera.SetWidth(1080.0f);
|
||||||
editorCamera.SetHeight(720.0f);
|
|
||||||
editorCamera.SetFar(10000000.0f);
|
editorCamera.SetFar(10000000.0f);
|
||||||
editorCamera.movementSpeed = 2.0f;
|
editorCamera.movementSpeed = 2.0f;
|
||||||
editorCamera.perspProj = true;
|
editorCamera.perspProj = true;
|
||||||
|
@ -144,18 +143,7 @@ namespace SHADE
|
||||||
|
|
||||||
//std::cout << EVENT_DATA->resizeWidth << std::endl;
|
//std::cout << EVENT_DATA->resizeWidth << std::endl;
|
||||||
//std::cout << EVENT_DATA->resizeHeight << std::endl;
|
//std::cout << EVENT_DATA->resizeHeight << std::endl;
|
||||||
|
screenAspectRatio = (float)EVENT_DATA->resizeWidth / (float)EVENT_DATA->resizeHeight;
|
||||||
|
|
||||||
for (auto director : directorHandleList)
|
|
||||||
{
|
|
||||||
auto camera = SHComponentManager::GetComponent_s<SHCameraComponent>(director->mainCameraEID);
|
|
||||||
if (camera)
|
|
||||||
{
|
|
||||||
camera->SetWidth(EVENT_DATA->resizeWidth);
|
|
||||||
camera->SetHeight(EVENT_DATA->resizeHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return eventPtr->handle;
|
return eventPtr->handle;
|
||||||
|
@ -296,7 +284,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
camera.offset = arm->GetOffset();
|
camera.offset = arm->GetOffset();
|
||||||
if (arm->lookAtCameraOrigin)
|
if (arm->lookAtCameraOrigin)
|
||||||
CameraLookAt(camera, camera.position);
|
CameraLookAt(camera, camera.position + arm->GetTargetOffset());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +328,7 @@ namespace SHADE
|
||||||
if (camera.dirtyProj == true)
|
if (camera.dirtyProj == true)
|
||||||
{
|
{
|
||||||
//Perspective projection matrix.
|
//Perspective projection matrix.
|
||||||
const float ASPECT_RATIO = (camera.GetAspectRatio());
|
const float ASPECT_RATIO = (screenAspectRatio);
|
||||||
const float TAN_HALF_FOV = tan(SHMath::DegreesToRadians(camera.fov) * 0.5f);
|
const float TAN_HALF_FOV = tan(SHMath::DegreesToRadians(camera.fov) * 0.5f);
|
||||||
camera.perspProjMatrix = SHMatrix::Identity;
|
camera.perspProjMatrix = SHMatrix::Identity;
|
||||||
camera.perspProjMatrix(0, 0) = 1.0f / (ASPECT_RATIO * TAN_HALF_FOV);
|
camera.perspProjMatrix(0, 0) = 1.0f / (ASPECT_RATIO * TAN_HALF_FOV);
|
||||||
|
@ -357,7 +345,7 @@ namespace SHADE
|
||||||
|
|
||||||
const float right = camera.GetWidth() * 0.5f;
|
const float right = camera.GetWidth() * 0.5f;
|
||||||
const float left = -right;
|
const float left = -right;
|
||||||
const float top = camera.GetHeight() * 0.5f;
|
const float top = camera.GetWidth() / screenAspectRatio * 0.5f;
|
||||||
const float btm = -top;
|
const float btm = -top;
|
||||||
const float n = camera.GetNear();
|
const float n = camera.GetNear();
|
||||||
const float f = camera.GetFar();
|
const float f = camera.GetFar();
|
||||||
|
@ -574,11 +562,11 @@ namespace SHADE
|
||||||
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
if (editor->editorState != SHEditor::State::PLAY)
|
if (editor->editorState != SHEditor::State::PLAY)
|
||||||
{
|
{
|
||||||
return SHVec2{ GetEditorCamera()->GetWidth(), GetEditorCamera()->GetHeight() };
|
return SHVec2{ GetEditorCamera()->GetWidth(), GetEditorCamera()->GetWidth() / screenAspectRatio };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return SHVec2{ GetDirector(index)->GetWidth(),GetDirector(index)->GetHeight() };
|
return SHVec2{ GetDirector(index)->GetWidth(),GetDirector(index)->GetWidth() / screenAspectRatio };
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace SHADE
|
||||||
SHCameraComponent editorCamera;
|
SHCameraComponent editorCamera;
|
||||||
SHCameraArmComponent editorCameraArm;
|
SHCameraArmComponent editorCameraArm;
|
||||||
|
|
||||||
|
float screenAspectRatio{16.0f/9.0f};
|
||||||
|
|
||||||
SHResourceLibrary<SHCameraDirector> directorLibrary;
|
SHResourceLibrary<SHCameraDirector> directorLibrary;
|
||||||
std::vector<DirectorHandle> directorHandleList;
|
std::vector<DirectorHandle> directorHandleList;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace SHADE
|
||||||
if (SHEditorWindow::Begin())
|
if (SHEditorWindow::Begin())
|
||||||
{
|
{
|
||||||
//ImGui::ShowDemoWindow();
|
//ImGui::ShowDemoWindow();
|
||||||
|
if (bindingRenames.size() != SHInputManager::CountBindings())
|
||||||
|
resizeVectors(SHInputManager::CountBindings());
|
||||||
|
|
||||||
//Binding count
|
//Binding count
|
||||||
ImGui::Text("Binding Count: %d", SHInputManager::CountBindings());
|
ImGui::Text("Binding Count: %d", SHInputManager::CountBindings());
|
||||||
|
@ -127,6 +129,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHInputManager::RenameBinding(binding.first, bindingRenames[entryNumber]);
|
SHInputManager::RenameBinding(binding.first, bindingRenames[entryNumber]);
|
||||||
bindingRenames[entryNumber].clear();
|
bindingRenames[entryNumber].clear();
|
||||||
|
ImGui::End();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Button(labelConcat("Delete Binding##", entryNumber).c_str()))
|
if (ImGui::Button(labelConcat("Delete Binding##", entryNumber).c_str()))
|
||||||
|
|
|
@ -26,5 +26,8 @@ constexpr SHEventIdentifier SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT { 17 };
|
||||||
constexpr SHEventIdentifier SH_BUTTON_CLICK_EVENT { 18 };
|
constexpr SHEventIdentifier SH_BUTTON_CLICK_EVENT { 18 };
|
||||||
constexpr SHEventIdentifier SH_PHYSICS_COLLIDER_DRAW_EVENT { 19 };
|
constexpr SHEventIdentifier SH_PHYSICS_COLLIDER_DRAW_EVENT { 19 };
|
||||||
constexpr SHEventIdentifier SH_WINDOW_RESIZE_EVENT { 20 };
|
constexpr SHEventIdentifier SH_WINDOW_RESIZE_EVENT { 20 };
|
||||||
constexpr SHEventIdentifier SH_ASSET_COMPILE_EVENT { 21 };
|
constexpr SHEventIdentifier SH_BUTTON_RELEASE_EVENT { 21 };
|
||||||
|
constexpr SHEventIdentifier SH_BUTTON_HOVER_ENTER_EVENT { 22 };
|
||||||
|
constexpr SHEventIdentifier SH_BUTTON_HOVER_EXIT_EVENT { 23 };
|
||||||
|
constexpr SHEventIdentifier SH_ASSET_COMPILE_EVENT { 24 };
|
||||||
|
|
||||||
|
|
|
@ -1238,7 +1238,7 @@ namespace SHADE
|
||||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
cameraSystem->GetEditorCamera()->SetWidth(static_cast<float>(resizeWidth));
|
cameraSystem->GetEditorCamera()->SetWidth(static_cast<float>(resizeWidth));
|
||||||
cameraSystem->GetEditorCamera()->SetHeight(static_cast<float>(resizeHeight));
|
//cameraSystem->GetEditorCamera()->SetAspectRatio(static_cast<float>(resizeWidth) / static_cast<float>(resizeHeight));
|
||||||
|
|
||||||
// Create new event and broadcast it
|
// Create new event and broadcast it
|
||||||
SHWindowResizeEvent newEvent;
|
SHWindowResizeEvent newEvent;
|
||||||
|
@ -1249,7 +1249,12 @@ namespace SHADE
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
// Create new event and broadcast it
|
||||||
|
SHWindowResizeEvent newEvent;
|
||||||
|
newEvent.resizeWidth = resizeWidth;
|
||||||
|
newEvent.resizeHeight = resizeHeight;
|
||||||
|
|
||||||
|
SHEventManager::BroadcastEvent<SHWindowResizeEvent>(newEvent, SH_WINDOW_RESIZE_EVENT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "Math/Transform/SHTransformComponent.h"
|
#include "Math/Transform/SHTransformComponent.h"
|
||||||
#include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h"
|
#include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h"
|
||||||
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
||||||
|
#include "Scene/SHSceneManager.h"
|
||||||
#include "UI/SHUIComponent.h"
|
#include "UI/SHUIComponent.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
@ -185,6 +186,9 @@ namespace SHADE
|
||||||
|
|
||||||
for (auto& comp : textRendererComps)
|
for (auto& comp : textRendererComps)
|
||||||
{
|
{
|
||||||
|
if (!SHSceneManager::CheckNodeAndComponentsActive<SHTextRenderableComponent>(comp.GetEID()))
|
||||||
|
continue;
|
||||||
|
|
||||||
auto* transform = SHComponentManager::GetComponent<SHTransformComponent>(comp.GetEID());
|
auto* transform = SHComponentManager::GetComponent<SHTransformComponent>(comp.GetEID());
|
||||||
|
|
||||||
Handle<SHFont> fontHandle = comp.fontHandle;
|
Handle<SHFont> fontHandle = comp.fontHandle;
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "SHInputManager.h"
|
#include "SHInputManager.h"
|
||||||
#include "../Tools/SHException.h"
|
#include "../Tools/SHException.h"
|
||||||
|
#include <Graphics/Windowing/SHWindow.h>
|
||||||
|
#include <Graphics/MiddleEnd/Interface/SHGraphicsSystem.h>
|
||||||
|
#include <Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.h>
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -21,6 +24,7 @@ namespace SHADE
|
||||||
/* Static defines */
|
/* Static defines */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
bool SHInputManager::mouseCentering = false;
|
||||||
bool SHInputManager::controllerInUse = false;
|
bool SHInputManager::controllerInUse = false;
|
||||||
|
|
||||||
std::map<std::string, SHInputManager::SHLogicalBindingData> SHInputManager::bindings;
|
std::map<std::string, SHInputManager::SHLogicalBindingData> SHInputManager::bindings;
|
||||||
|
@ -751,6 +755,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
++keyCount;
|
++keyCount;
|
||||||
keys[i] = true;
|
keys[i] = true;
|
||||||
|
controllerInUse = false;
|
||||||
}
|
}
|
||||||
else keys[i] = false;
|
else keys[i] = false;
|
||||||
|
|
||||||
|
@ -801,6 +806,25 @@ namespace SHADE
|
||||||
mouseVelocityX = static_cast<double>(mouseScreenX - mouseScreenXLast) / dt;
|
mouseVelocityX = static_cast<double>(mouseScreenX - mouseScreenXLast) / dt;
|
||||||
mouseVelocityY = static_cast<double>(mouseScreenY - mouseScreenYLast) / dt;
|
mouseVelocityY = static_cast<double>(mouseScreenY - mouseScreenYLast) / dt;
|
||||||
|
|
||||||
|
|
||||||
|
//Mouse Centering
|
||||||
|
if (mouseCentering)
|
||||||
|
{
|
||||||
|
uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth();
|
||||||
|
uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight();
|
||||||
|
SetMouseWindowPosition(width / 2, height / 2);
|
||||||
|
|
||||||
|
//These four lines help a lot
|
||||||
|
POINT p;
|
||||||
|
GetCursorPos(&p);
|
||||||
|
mouseVelocityX -= static_cast<double>(p.x - mouseScreenX) / dt;
|
||||||
|
mouseVelocityY -= static_cast<double>(p.y - mouseScreenY) / dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mouseVelocityX != 0.0 || mouseVelocityY != 0.0)
|
||||||
|
controllerInUse = false;
|
||||||
|
|
||||||
|
|
||||||
//Mouse wheel vertical delta updating
|
//Mouse wheel vertical delta updating
|
||||||
mouseWheelVerticalDelta = 0;
|
mouseWheelVerticalDelta = 0;
|
||||||
mouseWheelVerticalDelta = mouseWheelVerticalDeltaPoll;
|
mouseWheelVerticalDelta = mouseWheelVerticalDeltaPoll;
|
||||||
|
|
|
@ -1074,6 +1074,18 @@ namespace SHADE
|
||||||
SetCursorPos(p.x, p.y);
|
SetCursorPos(p.x, p.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Call to set the flag to start mouse centering every frame
|
||||||
|
static inline void SetMouseCentering(bool state) noexcept
|
||||||
|
{
|
||||||
|
mouseCentering = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the flag whether mouse centering is on or not
|
||||||
|
static inline bool GetMouseCentering() noexcept
|
||||||
|
{
|
||||||
|
return mouseCentering;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Constants */
|
/* Constants */
|
||||||
|
@ -1097,6 +1109,9 @@ namespace SHADE
|
||||||
/* Data Members */
|
/* Data Members */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//Whether mouse centering will be called every frame or not
|
||||||
|
static bool mouseCentering;
|
||||||
|
|
||||||
//If the last input is from controller(s) or KB/M
|
//If the last input is from controller(s) or KB/M
|
||||||
//True if from controller(s), False if from KB/M
|
//True if from controller(s), False if from KB/M
|
||||||
//Useful for switching control hints between controllers and KB/M
|
//Useful for switching control hints between controllers and KB/M
|
||||||
|
|
|
@ -369,6 +369,27 @@ namespace SHADE
|
||||||
return eventData->handle;
|
return eventData->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHScriptEngine::onUIElementReleased(SHEventPtr eventPtr)
|
||||||
|
{
|
||||||
|
auto eventData = reinterpret_cast<const SHEventSpec<SHButtonClickEvent>*>(eventPtr.get());
|
||||||
|
csUIElementOnReleased(eventData->data->EID);
|
||||||
|
return eventData->handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHScriptEngine::onUIElementOnHoverEntered(SHEventPtr eventPtr)
|
||||||
|
{
|
||||||
|
auto eventData = reinterpret_cast<const SHEventSpec<SHButtonClickEvent>*>(eventPtr.get());
|
||||||
|
csUIElementOnHoverEntered(eventData->data->EID);
|
||||||
|
return eventData->handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHScriptEngine::onUIElementOnHoverExited(SHEventPtr eventPtr)
|
||||||
|
{
|
||||||
|
auto eventData = reinterpret_cast<const SHEventSpec<SHButtonClickEvent>*>(eventPtr.get());
|
||||||
|
csUIElementOnHoverExited(eventData->data->EID);
|
||||||
|
return eventData->handle;
|
||||||
|
}
|
||||||
|
|
||||||
SHEventHandle SHScriptEngine::onSceneNodeChildrenAdded(SHEventPtr eventPtr)
|
SHEventHandle SHScriptEngine::onSceneNodeChildrenAdded(SHEventPtr eventPtr)
|
||||||
{
|
{
|
||||||
auto eventData = reinterpret_cast<const SHEventSpec<SHSceneGraphAddChildEvent>*>(eventPtr.get());
|
auto eventData = reinterpret_cast<const SHEventSpec<SHSceneGraphAddChildEvent>*>(eventPtr.get());
|
||||||
|
@ -539,6 +560,24 @@ namespace SHADE
|
||||||
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
||||||
"OnClicked"
|
"OnClicked"
|
||||||
);
|
);
|
||||||
|
csUIElementOnReleased = dotNet.GetFunctionPtr<CsEventRelayFuncPtr>
|
||||||
|
(
|
||||||
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
|
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
||||||
|
"OnReleased"
|
||||||
|
);
|
||||||
|
csUIElementOnHoverEntered = dotNet.GetFunctionPtr<CsEventRelayFuncPtr>
|
||||||
|
(
|
||||||
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
|
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
||||||
|
"OnHoverEntered"
|
||||||
|
);
|
||||||
|
csUIElementOnHoverExited = dotNet.GetFunctionPtr<CsEventRelayFuncPtr>
|
||||||
|
(
|
||||||
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
|
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
||||||
|
"OnHoverExited"
|
||||||
|
);
|
||||||
csEditorRenderScripts = dotNet.GetFunctionPtr<CsScriptEditorFuncPtr>
|
csEditorRenderScripts = dotNet.GetFunctionPtr<CsScriptEditorFuncPtr>
|
||||||
(
|
(
|
||||||
DEFAULT_CSHARP_LIB_NAME,
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
|
@ -608,6 +647,21 @@ namespace SHADE
|
||||||
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementClicked)
|
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementClicked)
|
||||||
};
|
};
|
||||||
SHEventManager::SubscribeTo(SH_BUTTON_CLICK_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(clickedUIElementEventReceiver));
|
SHEventManager::SubscribeTo(SH_BUTTON_CLICK_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(clickedUIElementEventReceiver));
|
||||||
|
std::shared_ptr<SHEventReceiverSpec<SHScriptEngine>> releasedUIElementEventReceiver
|
||||||
|
{
|
||||||
|
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementReleased)
|
||||||
|
};
|
||||||
|
SHEventManager::SubscribeTo(SH_BUTTON_RELEASE_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(releasedUIElementEventReceiver));
|
||||||
|
std::shared_ptr<SHEventReceiverSpec<SHScriptEngine>> hoverEnterUIElementEventReceiver
|
||||||
|
{
|
||||||
|
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementOnHoverEntered)
|
||||||
|
};
|
||||||
|
SHEventManager::SubscribeTo(SH_BUTTON_HOVER_ENTER_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(hoverEnterUIElementEventReceiver));
|
||||||
|
std::shared_ptr<SHEventReceiverSpec<SHScriptEngine>> hoverExitedUIElementEventReceiver
|
||||||
|
{
|
||||||
|
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementOnHoverExited)
|
||||||
|
};
|
||||||
|
SHEventManager::SubscribeTo(SH_BUTTON_HOVER_EXIT_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(hoverExitedUIElementEventReceiver));
|
||||||
|
|
||||||
/* SceneGraph */
|
/* SceneGraph */
|
||||||
// Register for SceneNode child added event
|
// Register for SceneNode child added event
|
||||||
|
|
|
@ -292,6 +292,9 @@ namespace SHADE
|
||||||
CsEventRelayFuncPtr csSceneNodeChildrenChanged = nullptr;
|
CsEventRelayFuncPtr csSceneNodeChildrenChanged = nullptr;
|
||||||
CsEventRelayFuncPtr csUIElementOnRemoved = nullptr;
|
CsEventRelayFuncPtr csUIElementOnRemoved = nullptr;
|
||||||
CsEventRelayFuncPtr csUIElementOnClicked = nullptr;
|
CsEventRelayFuncPtr csUIElementOnClicked = nullptr;
|
||||||
|
CsEventRelayFuncPtr csUIElementOnReleased = nullptr;
|
||||||
|
CsEventRelayFuncPtr csUIElementOnHoverEntered = nullptr;
|
||||||
|
CsEventRelayFuncPtr csUIElementOnHoverExited = nullptr;
|
||||||
// - Editor
|
// - Editor
|
||||||
CsScriptEditorFuncPtr csEditorRenderScripts = nullptr;
|
CsScriptEditorFuncPtr csEditorRenderScripts = nullptr;
|
||||||
CsFuncPtr csEditorUndo = nullptr;
|
CsFuncPtr csEditorUndo = nullptr;
|
||||||
|
@ -306,6 +309,9 @@ namespace SHADE
|
||||||
SHEventHandle onColliderComponentRemoved(SHEventPtr eventPtr);
|
SHEventHandle onColliderComponentRemoved(SHEventPtr eventPtr);
|
||||||
SHEventHandle onUIElementRemoved(SHEventPtr eventPtr);
|
SHEventHandle onUIElementRemoved(SHEventPtr eventPtr);
|
||||||
SHEventHandle onUIElementClicked(SHEventPtr eventPtr);
|
SHEventHandle onUIElementClicked(SHEventPtr eventPtr);
|
||||||
|
SHEventHandle onUIElementReleased(SHEventPtr eventPtr);
|
||||||
|
SHEventHandle onUIElementOnHoverEntered(SHEventPtr eventPtr);
|
||||||
|
SHEventHandle onUIElementOnHoverExited(SHEventPtr eventPtr);
|
||||||
SHEventHandle onSceneNodeChildrenAdded(SHEventPtr eventPtr);
|
SHEventHandle onSceneNodeChildrenAdded(SHEventPtr eventPtr);
|
||||||
SHEventHandle onSceneNodeChildrenRemoved(SHEventPtr eventPtr);
|
SHEventHandle onSceneNodeChildrenRemoved(SHEventPtr eventPtr);
|
||||||
SHEventHandle onSceneDestroyed(SHEventPtr eventPtr);
|
SHEventHandle onSceneDestroyed(SHEventPtr eventPtr);
|
||||||
|
|
|
@ -70,6 +70,7 @@ namespace SHADE
|
||||||
//Compile component IDs
|
//Compile component IDs
|
||||||
const auto componentIDList = SHSerialization::GetComponentIDList(node[ComponentsNode]);
|
const auto componentIDList = SHSerialization::GetComponentIDList(node[ComponentsNode]);
|
||||||
eid = SHEntityManager::CreateEntity(componentIDList, eid, name, parentEID);
|
eid = SHEntityManager::CreateEntity(componentIDList, eid, name, parentEID);
|
||||||
|
|
||||||
createdEntities[oldEID] = eid;
|
createdEntities[oldEID] = eid;
|
||||||
//createdEntities.push_back(eid);
|
//createdEntities.push_back(eid);
|
||||||
if (node[NumberOfChildrenNode])
|
if (node[NumberOfChildrenNode])
|
||||||
|
@ -90,6 +91,12 @@ namespace SHADE
|
||||||
if (node[ScriptsNode])
|
if (node[ScriptsNode])
|
||||||
SHSystemManager::GetSystem<SHScriptEngine>()->DeserialiseScripts(eid, node[ScriptsNode]);
|
SHSystemManager::GetSystem<SHScriptEngine>()->DeserialiseScripts(eid, node[ScriptsNode]);
|
||||||
|
|
||||||
|
auto& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
|
||||||
|
if (node[IsActiveNode])
|
||||||
|
{
|
||||||
|
sceneGraph.SetActive(eid, node[IsActiveNode].as<bool>());
|
||||||
|
}
|
||||||
|
|
||||||
return eid;
|
return eid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
SHButtonComponent::SHButtonComponent()
|
SHButtonComponent::SHButtonComponent()
|
||||||
:size(1.0f), isHovered(false), isClicked(false),
|
: defaultTexture(0), hoveredTexture(0), clickedTexture(0), currentTexture(0)
|
||||||
defaultTexture(0), hoveredTexture(0), clickedTexture(0), currentTexture(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,18 +28,24 @@ namespace SHADE
|
||||||
void SHButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
void SHButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
defaultTexture = texture;
|
defaultTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHButtonComponent::SetHoveredTexture(AssetID texture) noexcept
|
void SHButtonComponent::SetHoveredTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
hoveredTexture = texture;
|
hoveredTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);\
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHButtonComponent::SetClickedTexture(AssetID texture) noexcept
|
void SHButtonComponent::SetClickedTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
clickedTexture = texture;
|
clickedTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,6 @@ namespace SHADE
|
||||||
SHButtonComponent();
|
SHButtonComponent();
|
||||||
virtual ~SHButtonComponent() = default;
|
virtual ~SHButtonComponent() = default;
|
||||||
|
|
||||||
SHVec2 size;
|
|
||||||
|
|
||||||
AssetID GetClickedTexture() const noexcept;
|
AssetID GetClickedTexture() const noexcept;
|
||||||
AssetID GetDefaultTexture() const noexcept;
|
AssetID GetDefaultTexture() const noexcept;
|
||||||
AssetID GetHoveredTexture() const noexcept;
|
AssetID GetHoveredTexture() const noexcept;
|
||||||
|
@ -32,11 +30,7 @@ namespace SHADE
|
||||||
|
|
||||||
friend class SHUISystem;
|
friend class SHUISystem;
|
||||||
private:
|
private:
|
||||||
//Set to true when mouse is hovering over the button.
|
|
||||||
bool isHovered;
|
|
||||||
//This is set to true when the mouse clicks down, and set back to false when mouse releases.
|
|
||||||
//The event for the button click will be broadcasted when mouse release.
|
|
||||||
bool isClicked;
|
|
||||||
AssetID defaultTexture;
|
AssetID defaultTexture;
|
||||||
AssetID hoveredTexture;
|
AssetID hoveredTexture;
|
||||||
AssetID clickedTexture;
|
AssetID clickedTexture;
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
SHCanvasComponent::SHCanvasComponent()
|
SHCanvasComponent::SHCanvasComponent()
|
||||||
:width(1),height(1), dirtyMatrix(false), canvasMatrix()
|
:width(1), height(1), dirtyMatrix(false), canvasMatrix(), scaleByCanvasWidth(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ namespace SHADE
|
||||||
height = val;
|
height = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SHCanvasComponent::CanvasSizeType SHCanvasComponent::GetCanvasWidth() const noexcept
|
SHCanvasComponent::CanvasSizeType SHCanvasComponent::GetCanvasWidth() const noexcept
|
||||||
{
|
{
|
||||||
|
@ -43,6 +45,8 @@ namespace SHADE
|
||||||
return canvasMatrix;
|
return canvasMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,6 +58,7 @@ RTTR_REGISTRATION
|
||||||
registration::class_<SHCanvasComponent>("Canvas Component")
|
registration::class_<SHCanvasComponent>("Canvas Component")
|
||||||
.property("Canvas Width", &SHCanvasComponent::GetCanvasWidth, &SHCanvasComponent::SetCanvasWidth)
|
.property("Canvas Width", &SHCanvasComponent::GetCanvasWidth, &SHCanvasComponent::SetCanvasWidth)
|
||||||
.property("Canvas Height", &SHCanvasComponent::GetCanvasHeight, &SHCanvasComponent::SetCanvasHeight)
|
.property("Canvas Height", &SHCanvasComponent::GetCanvasHeight, &SHCanvasComponent::SetCanvasHeight)
|
||||||
|
.property("Scale by canvas width", &SHCanvasComponent::scaleByCanvasWidth)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,21 +21,24 @@ namespace SHADE
|
||||||
|
|
||||||
SHCanvasComponent();
|
SHCanvasComponent();
|
||||||
~SHCanvasComponent() = default;
|
~SHCanvasComponent() = default;
|
||||||
|
bool scaleByCanvasWidth;
|
||||||
|
|
||||||
void SetCanvasSize(CanvasSizeType width, CanvasSizeType height) noexcept;
|
void SetCanvasSize(CanvasSizeType width, CanvasSizeType height) noexcept;
|
||||||
void SetCanvasWidth(CanvasSizeType width) noexcept;
|
void SetCanvasWidth(CanvasSizeType width) noexcept;
|
||||||
void SetCanvasHeight(CanvasSizeType height) noexcept;
|
void SetCanvasHeight(CanvasSizeType height) noexcept;
|
||||||
|
|
||||||
|
|
||||||
CanvasSizeType GetCanvasWidth() const noexcept;
|
CanvasSizeType GetCanvasWidth() const noexcept;
|
||||||
CanvasSizeType GetCanvasHeight() const noexcept;
|
CanvasSizeType GetCanvasHeight() const noexcept;
|
||||||
SHMatrix const& GetMatrix() const noexcept;
|
SHMatrix const& GetMatrix() const noexcept;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CanvasSizeType width;
|
CanvasSizeType width;
|
||||||
CanvasSizeType height;
|
CanvasSizeType height;
|
||||||
bool dirtyMatrix;
|
bool dirtyMatrix;
|
||||||
SHMatrix canvasMatrix;
|
SHMatrix canvasMatrix;
|
||||||
|
|
||||||
|
|
||||||
RTTR_ENABLE()
|
RTTR_ENABLE()
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
#include "SHToggleButtonComponent.h"
|
#include "SHToggleButtonComponent.h"
|
||||||
|
#include "Resource/SHResourceManager.h"
|
||||||
|
#include "Graphics/MiddleEnd/Textures/SHTextureLibrary.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
SHToggleButtonComponent::SHToggleButtonComponent()
|
SHToggleButtonComponent::SHToggleButtonComponent()
|
||||||
:size(1.0f), isHovered(false), isClicked(false), value(false),
|
:value(false), defaultTexture(0), toggledTexture(0), currentTexture(0)
|
||||||
defaultTexture(0), toggledTexture(0), currentTexture(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +29,13 @@ namespace SHADE
|
||||||
void SHToggleButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
void SHToggleButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
defaultTexture = texture;
|
defaultTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHToggleButtonComponent::SetToggledTexture(AssetID texture) noexcept
|
void SHToggleButtonComponent::SetToggledTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
toggledTexture = texture;
|
toggledTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHToggleButtonComponent::SetValue(bool value) noexcept
|
void SHToggleButtonComponent::SetValue(bool value) noexcept
|
||||||
|
|
|
@ -17,8 +17,6 @@ namespace SHADE
|
||||||
SHToggleButtonComponent();
|
SHToggleButtonComponent();
|
||||||
virtual ~SHToggleButtonComponent() = default;
|
virtual ~SHToggleButtonComponent() = default;
|
||||||
|
|
||||||
SHVec2 size;
|
|
||||||
|
|
||||||
AssetID GetToggledTexture() const noexcept;
|
AssetID GetToggledTexture() const noexcept;
|
||||||
AssetID GetDefaultTexture() const noexcept;
|
AssetID GetDefaultTexture() const noexcept;
|
||||||
bool GetValue() const noexcept;
|
bool GetValue() const noexcept;
|
||||||
|
@ -33,11 +31,7 @@ namespace SHADE
|
||||||
friend class SHUISystem;
|
friend class SHUISystem;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//Set to true when mouse is hovering over the button.
|
|
||||||
bool isHovered;
|
|
||||||
//This is set to true when the mouse clicks down, and set back to false when mouse releases.
|
|
||||||
//The event for the button click will be broadcasted when mouse release.
|
|
||||||
bool isClicked;
|
|
||||||
bool value;
|
bool value;
|
||||||
AssetID defaultTexture;
|
AssetID defaultTexture;
|
||||||
AssetID toggledTexture;
|
AssetID toggledTexture;
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
SHUIComponent::SHUIComponent()
|
SHUIComponent::SHUIComponent()
|
||||||
|
:size(1.0f), isHovered(false), isClicked(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +28,20 @@ namespace SHADE
|
||||||
(void)id;
|
(void)id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SHUIComponent::GetIsHovered() const noexcept
|
||||||
|
{
|
||||||
|
return isHovered;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHUIComponent::GetIsClicked() const noexcept
|
||||||
|
{
|
||||||
|
return isClicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHUIComponent::SetEmptyHoveredClick(bool value) noexcept
|
||||||
|
{
|
||||||
|
(void)value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,6 +52,8 @@ RTTR_REGISTRATION
|
||||||
|
|
||||||
registration::class_<SHUIComponent>("UI Component")
|
registration::class_<SHUIComponent>("UI Component")
|
||||||
.property("Canvas ID", &SHUIComponent::GetCanvasID, &SHUIComponent::SetCanvasID)
|
.property("Canvas ID", &SHUIComponent::GetCanvasID, &SHUIComponent::SetCanvasID)
|
||||||
|
.property("Hovered", &SHUIComponent::GetIsHovered, &SHUIComponent::SetEmptyHoveredClick)
|
||||||
|
.property("Clicked", &SHUIComponent::GetIsClicked, &SHUIComponent::SetEmptyHoveredClick)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "SH_API.h"
|
#include "SH_API.h"
|
||||||
#include "ECS_Base/Components/SHComponent.h"
|
#include "ECS_Base/Components/SHComponent.h"
|
||||||
#include "Math/SHMatrix.h"
|
#include "Math/SHMatrix.h"
|
||||||
|
#include "Math/Vector/SHVec2.h"
|
||||||
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
@ -17,14 +18,29 @@ namespace SHADE
|
||||||
SHUIComponent();
|
SHUIComponent();
|
||||||
~SHUIComponent() = default;
|
~SHUIComponent() = default;
|
||||||
|
|
||||||
|
|
||||||
|
SHVec2 size;
|
||||||
|
|
||||||
|
|
||||||
SHMatrix const& GetMatrix() const noexcept;
|
SHMatrix const& GetMatrix() const noexcept;
|
||||||
EntityID GetCanvasID() const noexcept;
|
EntityID GetCanvasID() const noexcept;
|
||||||
void SetCanvasID(EntityID id) noexcept;
|
void SetCanvasID(EntityID id) noexcept;
|
||||||
|
|
||||||
|
bool GetIsHovered() const noexcept;
|
||||||
|
bool GetIsClicked() const noexcept;
|
||||||
|
|
||||||
|
void SetEmptyHoveredClick(bool value)noexcept;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SHMatrix localToCanvasMatrix;
|
SHMatrix localToCanvasMatrix;
|
||||||
EntityID canvasID;
|
EntityID canvasID;
|
||||||
|
|
||||||
|
//Set to true when mouse is hovering over the button. Only set if there is a Button/Slider/ToggleButton comp.
|
||||||
|
bool isHovered;
|
||||||
|
//This is set to true when the mouse clicks down, and set back to false when mouse releases. Only set if there is a Button/Slider/ToggleButton comp.
|
||||||
|
bool isClicked;
|
||||||
|
|
||||||
|
|
||||||
RTTR_ENABLE()
|
RTTR_ENABLE()
|
||||||
};
|
};
|
||||||
|
|
|
@ -131,8 +131,17 @@ namespace SHADE
|
||||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
SHVec2 camSize = cameraSystem->GetCameraWidthHeight(0);
|
SHVec2 camSize = cameraSystem->GetCameraWidthHeight(0);
|
||||||
comp.canvasMatrix = SHMatrix::Identity;
|
comp.canvasMatrix = SHMatrix::Identity;
|
||||||
comp.canvasMatrix(0, 0) = camSize.x * 0.5f / (comp.GetCanvasWidth() * 0.5f);
|
float scale = camSize.y / comp.GetCanvasHeight();
|
||||||
comp.canvasMatrix(1, 1) = camSize.y * 0.5f / (comp.GetCanvasHeight() * 0.5f);
|
if (comp.scaleByCanvasWidth)
|
||||||
|
{
|
||||||
|
scale = camSize.x / comp.GetCanvasWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
comp.canvasMatrix(0, 0) = scale;
|
||||||
|
comp.canvasMatrix(1, 1) = scale;
|
||||||
|
|
||||||
|
//comp.canvasMatrix(0, 0) = camSize.x * 0.5f / (comp.GetCanvasWidth() * 0.5f);
|
||||||
|
//comp.canvasMatrix(1, 1) = camSize.y * 0.5f / (comp.GetCanvasHeight() * 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHUISystem::UpdateCanvasMatrixRoutine::Execute(double dt) noexcept
|
void SHUISystem::UpdateCanvasMatrixRoutine::Execute(double dt) noexcept
|
||||||
|
@ -146,156 +155,15 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SHUISystem::CheckButtonHoveredOrClicked(SHUIComponent& comp) noexcept
|
||||||
void SHUISystem::UpdateButtonComponent(SHButtonComponent& comp) noexcept
|
|
||||||
{
|
{
|
||||||
if (!SHComponentManager::HasComponent<SHUIComponent>(comp.GetEID()))
|
SHVec4 topExtent4 = SHMatrix::Translate(-comp.size.x * 0.5f, comp.size.y * 0.5f, 0.0f) * comp.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) * comp.GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
|
||||||
auto uiComp = SHComponentManager::GetComponent<SHUIComponent>(comp.GetEID());
|
|
||||||
//auto canvasComp = SHComponentManager::GetComponent_s<SHCanvasComponent>(uiComp->canvasID);
|
|
||||||
|
|
||||||
SHVec4 topExtent4 = SHMatrix::Translate(-comp.size.x * 0.5f, comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
SHVec4 btmExtent4 = SHMatrix::Translate(comp.size.x * 0.5f, -comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f,0.0f, 0.0f,1.0f);
|
|
||||||
|
|
||||||
|
|
||||||
SHVec2 topExtent{ topExtent4.x,topExtent4.y };
|
|
||||||
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
|
|
||||||
|
|
||||||
|
|
||||||
SHVec2 mousePos;
|
|
||||||
SHVec2 windowSize;
|
|
||||||
#ifdef SHEDITOR
|
|
||||||
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->beginContentRegionAvailable;
|
|
||||||
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
|
|
||||||
//mousePos.y = windowSize.y - mousePos.y;
|
|
||||||
//SHLOG_INFO("mouse pos: {}, {}", mousePos.x, mousePos.y)
|
|
||||||
mousePos /= windowSize;
|
|
||||||
//SHLOG_INFO("mouse pos normalized: {}, {}", mousePos.x, mousePos.y)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#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);
|
|
||||||
//SHLOG_INFO("TopExtent: {}, {} Btm Extent: {}, {}", topExtent.x, topExtent.y, btmExtent.x, btmExtent.y)
|
|
||||||
|
|
||||||
|
|
||||||
//comp.isClicked = false;
|
|
||||||
if (mousePos.x >= topExtent.x && mousePos.x <= btmExtent.x
|
|
||||||
&& mousePos.y >= topExtent.y && mousePos.y <= btmExtent.y)
|
|
||||||
{
|
|
||||||
comp.isHovered = true;
|
|
||||||
#ifdef SHEDITOR
|
|
||||||
//if (SHSystemManager::GetSystem<SHEditor>()->editorState == SHEditor::State::PLAY)
|
|
||||||
{
|
|
||||||
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB))
|
|
||||||
{
|
|
||||||
comp.isClicked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB))
|
|
||||||
{
|
|
||||||
comp.isClicked = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//SHLOG_INFO("HOVERED")
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
comp.isHovered = false;
|
|
||||||
//SHLOG_INFO("NOT HOVERED")
|
|
||||||
}
|
|
||||||
if (comp.isClicked && SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
|
|
||||||
{
|
|
||||||
comp.isClicked = false;
|
|
||||||
SHButtonClickEvent clickEvent;
|
|
||||||
clickEvent.EID = comp.GetEID();
|
|
||||||
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_CLICK_EVENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
|
|
||||||
{
|
|
||||||
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
|
||||||
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
|
|
||||||
|
|
||||||
|
|
||||||
AssetID textureID = 0;
|
|
||||||
if (!comp.isHovered && !comp.isClicked)
|
|
||||||
{
|
|
||||||
if (comp.GetDefaultTexture() != 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
|
|
||||||
{
|
|
||||||
textureID = comp.GetDefaultTexture();
|
|
||||||
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
|
|
||||||
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (comp.isClicked)
|
|
||||||
{
|
|
||||||
if (comp.GetClickedTexture() != 0 && SHAssetManager::GetType(comp.GetClickedTexture()) == AssetType::TEXTURE)
|
|
||||||
{
|
|
||||||
textureID = comp.GetClickedTexture();
|
|
||||||
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetClickedTexture()));
|
|
||||||
//SHLOG_INFO("SETTING CLICKED TEXTURE")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (comp.GetHoveredTexture() != 0 && SHAssetManager::GetType(comp.GetHoveredTexture()) == AssetType::TEXTURE)
|
|
||||||
{
|
|
||||||
textureID = comp.GetHoveredTexture();
|
|
||||||
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>( comp.GetHoveredTexture()));
|
|
||||||
//SHLOG_INFO("SETTING HOVERED TEXTURE")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (textureID != 0 && textureID != comp.currentTexture)
|
|
||||||
{
|
|
||||||
auto material = renderable->GetModifiableMaterial();
|
|
||||||
comp.currentTexture = textureID;
|
|
||||||
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SHUISystem::UpdateToggleButtonComponent(SHToggleButtonComponent& 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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
SHVec2 topExtent{ topExtent4.x,topExtent4.y };
|
SHVec2 topExtent{ topExtent4.x,topExtent4.y };
|
||||||
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
|
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
|
||||||
|
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
|
|
||||||
SHVec2 mousePos;
|
SHVec2 mousePos;
|
||||||
SHVec2 windowSize;
|
SHVec2 windowSize;
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
@ -331,38 +199,145 @@ namespace SHADE
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
if (comp.isHovered == false)
|
||||||
|
{
|
||||||
|
SHButtonClickEvent clickEvent;
|
||||||
|
clickEvent.EID = comp.GetEID();
|
||||||
|
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_HOVER_ENTER_EVENT);
|
||||||
|
//SHLOG_INFO("C++ BROADCASTED HOVER ENTER EVENT EID: {}", clickEvent.EID);
|
||||||
|
}
|
||||||
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))
|
||||||
{
|
{
|
||||||
comp.isClicked = true;
|
comp.isClicked = true;
|
||||||
|
SHButtonClickEvent clickEvent;
|
||||||
|
clickEvent.EID = comp.GetEID();
|
||||||
|
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_CLICK_EVENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB))
|
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB))
|
||||||
{
|
{
|
||||||
comp.isClicked = true;
|
comp.isClicked = true;
|
||||||
}
|
SHButtonClickEvent clickEvent;
|
||||||
|
clickEvent.EID = comp.GetEID();
|
||||||
|
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_CLICK_EVENT);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//SHLOG_INFO("HOVERED")
|
//SHLOG_INFO("HOVERED")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (comp.isHovered == true)
|
||||||
|
{
|
||||||
|
SHButtonClickEvent clickEvent;
|
||||||
|
clickEvent.EID = comp.GetEID();
|
||||||
|
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_HOVER_EXIT_EVENT);
|
||||||
|
}
|
||||||
|
|
||||||
comp.isHovered = false;
|
comp.isHovered = false;
|
||||||
//SHLOG_INFO("NOT HOVERED")
|
//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;
|
|
||||||
SHButtonClickEvent clickEvent;
|
SHButtonClickEvent clickEvent;
|
||||||
clickEvent.EID = comp.GetEID();
|
clickEvent.EID = comp.GetEID();
|
||||||
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_CLICK_EVENT);
|
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_RELEASE_EVENT);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHUISystem::UpdateButtonComponent(SHButtonComponent& 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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CheckButtonHoveredOrClicked(*uiComp);
|
||||||
|
|
||||||
|
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
|
||||||
|
{
|
||||||
|
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
||||||
|
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
|
||||||
|
|
||||||
|
|
||||||
|
AssetID textureID = 0;
|
||||||
|
if (!uiComp->isHovered && !uiComp->isClicked)
|
||||||
|
{
|
||||||
|
if (comp.GetDefaultTexture() != 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
|
||||||
|
{
|
||||||
|
textureID = comp.GetDefaultTexture();
|
||||||
|
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
|
||||||
|
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (uiComp->isClicked)
|
||||||
|
{
|
||||||
|
if (comp.GetClickedTexture() != 0 && SHAssetManager::GetType(comp.GetClickedTexture()) == AssetType::TEXTURE)
|
||||||
|
{
|
||||||
|
textureID = comp.GetClickedTexture();
|
||||||
|
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetClickedTexture()));
|
||||||
|
//SHLOG_INFO("SETTING CLICKED TEXTURE")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (comp.GetHoveredTexture() != 0 && SHAssetManager::GetType(comp.GetHoveredTexture()) == AssetType::TEXTURE)
|
||||||
|
{
|
||||||
|
textureID = comp.GetHoveredTexture();
|
||||||
|
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>( comp.GetHoveredTexture()));
|
||||||
|
//SHLOG_INFO("SETTING HOVERED TEXTURE")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (textureID != 0 && textureID != comp.currentTexture)
|
||||||
|
{
|
||||||
|
auto material = renderable->GetModifiableMaterial();
|
||||||
|
comp.currentTexture = textureID;
|
||||||
|
material->SetProperty("data.textureIndex", SHResourceManager::Get<SHTexture>(textureID)->TextureArrayIndex);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHUISystem::UpdateToggleButtonComponent(SHToggleButtonComponent& 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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (CheckButtonHoveredOrClicked(*uiComp))
|
||||||
|
comp.value = !comp.value;
|
||||||
|
|
||||||
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
|
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
|
||||||
{
|
{
|
||||||
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
|
||||||
|
@ -393,7 +368,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
auto material = renderable->GetModifiableMaterial();
|
auto material = renderable->GetModifiableMaterial();
|
||||||
comp.currentTexture = textureID;
|
comp.currentTexture = textureID;
|
||||||
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
|
material->SetProperty("data.textureIndex", SHResourceManager::Get<SHTexture>(textureID)->TextureArrayIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -405,6 +381,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHUISystem* system = (SHUISystem*)GetSystem();
|
SHUISystem* system = (SHUISystem*)GetSystem();
|
||||||
auto& dense = SHComponentManager::GetDense<SHButtonComponent>();
|
auto& dense = SHComponentManager::GetDense<SHButtonComponent>();
|
||||||
|
//We ensure that the textures are loaded before we do the update.
|
||||||
|
SHResourceManager::FinaliseChanges();
|
||||||
for (auto& comp : dense)
|
for (auto& comp : dense)
|
||||||
{
|
{
|
||||||
if (SHSceneManager::CheckNodeAndComponentsActive<SHButtonComponent>(comp.GetEID()))
|
if (SHSceneManager::CheckNodeAndComponentsActive<SHButtonComponent>(comp.GetEID()))
|
||||||
|
|
|
@ -68,10 +68,17 @@ namespace SHADE
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool loadTexture{false};
|
||||||
|
|
||||||
void UpdateUIComponent(SHUIComponent& comp) noexcept;
|
void UpdateUIComponent(SHUIComponent& comp) noexcept;
|
||||||
void UpdateButtonComponent(SHButtonComponent& comp) noexcept;
|
void UpdateButtonComponent(SHButtonComponent& comp) noexcept;
|
||||||
void UpdateToggleButtonComponent(SHToggleButtonComponent& comp) noexcept;
|
void UpdateToggleButtonComponent(SHToggleButtonComponent& comp) noexcept;
|
||||||
void UpdateCanvasComponent(SHCanvasComponent& comp) noexcept;
|
void UpdateCanvasComponent(SHCanvasComponent& comp) noexcept;
|
||||||
|
|
||||||
|
//returns true on button release.
|
||||||
|
bool CheckButtonHoveredOrClicked(SHUIComponent& comp) noexcept;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SHVec2 CanvasToScreenPoint(SHVec2& const canvasPoint, bool normalized) noexcept;
|
SHVec2 CanvasToScreenPoint(SHVec2& const canvasPoint, bool normalized) noexcept;
|
||||||
|
|
||||||
|
|
|
@ -50,15 +50,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetWidth(val);
|
GetNativeComponent()->SetWidth(val);
|
||||||
}
|
}
|
||||||
float Camera::Height::get()
|
|
||||||
{
|
|
||||||
return (GetNativeComponent()->GetHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Camera::Height::set(float val)
|
|
||||||
{
|
|
||||||
GetNativeComponent()->SetHeight(val);
|
|
||||||
}
|
|
||||||
float Camera::Near::get()
|
float Camera::Near::get()
|
||||||
{
|
{
|
||||||
return (GetNativeComponent()->GetNear());
|
return (GetNativeComponent()->GetNear());
|
||||||
|
|
|
@ -35,11 +35,7 @@ namespace SHADE
|
||||||
float get();
|
float get();
|
||||||
void set(float val);
|
void set(float val);
|
||||||
}
|
}
|
||||||
property float Height
|
|
||||||
{
|
|
||||||
float get();
|
|
||||||
void set(float val);
|
|
||||||
}
|
|
||||||
property float Near
|
property float Near
|
||||||
{
|
{
|
||||||
float get();
|
float get();
|
||||||
|
@ -60,6 +56,7 @@ namespace SHADE
|
||||||
Vector3 get();
|
Vector3 get();
|
||||||
void set(Vector3 val);
|
void set(Vector3 val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SetMainCamera(size_t directorIndex);
|
void SetMainCamera(size_t directorIndex);
|
||||||
|
|
|
@ -47,11 +47,16 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SHADE::Material Renderable::Material::get()
|
SHADE::Material Renderable::Material::get()
|
||||||
|
{
|
||||||
|
auto mat = GetNativeComponent()->GetModifiableMaterial();
|
||||||
|
return mat ? SHADE::Material(mat) : SHADE::Material();
|
||||||
|
}
|
||||||
|
SHADE::Material Renderable::SharedMaterial::get()
|
||||||
{
|
{
|
||||||
auto mat = GetNativeComponent()->GetMaterial();
|
auto mat = GetNativeComponent()->GetMaterial();
|
||||||
return mat ? SHADE::Material(mat) : SHADE::Material();
|
return mat ? SHADE::Material(mat) : SHADE::Material();
|
||||||
}
|
}
|
||||||
void Renderable::Material::set(SHADE::Material value)
|
void Renderable::SharedMaterial::set(SHADE::Material value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,9 +55,19 @@ namespace SHADE
|
||||||
void set(MeshAsset value);
|
void set(MeshAsset value);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Material used to render this Renderable.
|
/// Special instance of the shared Material for this Renderable. When accessing
|
||||||
|
/// this property, a new instance of the shared Material is created and assigned
|
||||||
|
/// to this Renderable. Hence, changes will only affect this Renderable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property SHADE::Material Material
|
property SHADE::Material Material
|
||||||
|
{
|
||||||
|
SHADE::Material get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The shared Material used to render this Renderable and other Renderables
|
||||||
|
/// using the same base Material.
|
||||||
|
/// </summary>
|
||||||
|
property SHADE::Material SharedMaterial
|
||||||
{
|
{
|
||||||
SHADE::Material get();
|
SHADE::Material get();
|
||||||
void set(SHADE::Material value);
|
void set(SHADE::Material value);
|
||||||
|
|
|
@ -28,6 +28,18 @@ namespace SHADE
|
||||||
: Component(entity)
|
: Component(entity)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void UIElement::ClearStaticEventData()
|
||||||
|
{
|
||||||
|
if (onClickEventMap != nullptr)
|
||||||
|
onClickEventMap->Clear();
|
||||||
|
if (onReleasedEventMap != nullptr)
|
||||||
|
onReleasedEventMap->Clear();
|
||||||
|
if (onHoverEnterEventMap != nullptr)
|
||||||
|
onHoverEnterEventMap->Clear();
|
||||||
|
if (onHoverExitEventMap != nullptr)
|
||||||
|
onHoverExitEventMap->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Properties */
|
/* Properties */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -37,7 +49,7 @@ namespace SHADE
|
||||||
if (onClickEventMap == nullptr)
|
if (onClickEventMap == nullptr)
|
||||||
{
|
{
|
||||||
onClickEventMap = gcnew System::Collections::Generic::Dictionary<Entity, CallbackEvent ^>();
|
onClickEventMap = gcnew System::Collections::Generic::Dictionary<Entity, CallbackEvent ^>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create event if it wasn't before
|
// Create event if it wasn't before
|
||||||
if (!onClickEventMap->ContainsKey(owner.EntityId))
|
if (!onClickEventMap->ContainsKey(owner.EntityId))
|
||||||
|
@ -48,6 +60,57 @@ namespace SHADE
|
||||||
// Return the event
|
// Return the event
|
||||||
return onClickEventMap[owner.EntityId];
|
return onClickEventMap[owner.EntityId];
|
||||||
}
|
}
|
||||||
|
CallbackEvent^ UIElement::OnRelease::get()
|
||||||
|
{
|
||||||
|
// Create map if it wasn't before
|
||||||
|
if (onReleasedEventMap == nullptr)
|
||||||
|
{
|
||||||
|
onReleasedEventMap = gcnew System::Collections::Generic::Dictionary<Entity, CallbackEvent ^>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create event if it wasn't before
|
||||||
|
if (!onReleasedEventMap->ContainsKey(owner.EntityId))
|
||||||
|
{
|
||||||
|
onReleasedEventMap->Add(owner.EntityId, gcnew CallbackEvent());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the event
|
||||||
|
return onReleasedEventMap[owner.EntityId];
|
||||||
|
}
|
||||||
|
CallbackEvent^ UIElement::OnHoverEnter::get()
|
||||||
|
{
|
||||||
|
// Create map if it wasn't before
|
||||||
|
if (onHoverEnterEventMap == nullptr)
|
||||||
|
{
|
||||||
|
onHoverEnterEventMap = gcnew System::Collections::Generic::Dictionary<Entity, CallbackEvent ^>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create event if it wasn't before
|
||||||
|
if (!onHoverEnterEventMap->ContainsKey(owner.EntityId))
|
||||||
|
{
|
||||||
|
onHoverEnterEventMap->Add(owner.EntityId, gcnew CallbackEvent());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the event
|
||||||
|
return onHoverEnterEventMap[owner.EntityId];
|
||||||
|
}
|
||||||
|
CallbackEvent^ UIElement::OnHoverExit::get()
|
||||||
|
{
|
||||||
|
// Create map if it wasn't before
|
||||||
|
if (onHoverExitEventMap == nullptr)
|
||||||
|
{
|
||||||
|
onHoverExitEventMap = gcnew System::Collections::Generic::Dictionary<Entity, CallbackEvent ^>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create event if it wasn't before
|
||||||
|
if (!onHoverExitEventMap->ContainsKey(owner.EntityId))
|
||||||
|
{
|
||||||
|
onHoverExitEventMap->Add(owner.EntityId, gcnew CallbackEvent());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the event
|
||||||
|
return onHoverExitEventMap[owner.EntityId];
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Event Handling Functions */
|
/* Event Handling Functions */
|
||||||
|
@ -60,6 +123,18 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
onClickEventMap->Remove(entity);
|
onClickEventMap->Remove(entity);
|
||||||
}
|
}
|
||||||
|
if (onReleasedEventMap != nullptr && onReleasedEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onReleasedEventMap->Remove(entity);
|
||||||
|
}
|
||||||
|
if (onHoverEnterEventMap != nullptr && onHoverEnterEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onHoverEnterEventMap->Remove(entity);
|
||||||
|
}
|
||||||
|
if (onHoverExitEventMap != nullptr && onHoverExitEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onHoverExitEventMap->Remove(entity);
|
||||||
|
}
|
||||||
SAFE_NATIVE_CALL_END("UIElement.OnComponentRemoved")
|
SAFE_NATIVE_CALL_END("UIElement.OnComponentRemoved")
|
||||||
}
|
}
|
||||||
void UIElement::OnClicked(EntityID entity)
|
void UIElement::OnClicked(EntityID entity)
|
||||||
|
@ -72,4 +147,34 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
SAFE_NATIVE_CALL_END("UIElement.OnClicked")
|
SAFE_NATIVE_CALL_END("UIElement.OnClicked")
|
||||||
}
|
}
|
||||||
|
void UIElement::OnReleased(EntityID entity)
|
||||||
|
{
|
||||||
|
SAFE_NATIVE_CALL_BEGIN
|
||||||
|
// Remove the event if it contained an event
|
||||||
|
if (onReleasedEventMap != nullptr && onReleasedEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onReleasedEventMap[entity]->Invoke();
|
||||||
|
}
|
||||||
|
SAFE_NATIVE_CALL_END("UIElement.OnReleased")
|
||||||
|
}
|
||||||
|
void UIElement::OnHoverEntered(EntityID entity)
|
||||||
|
{
|
||||||
|
SAFE_NATIVE_CALL_BEGIN
|
||||||
|
// Remove the event if it contained an event
|
||||||
|
if (onHoverEnterEventMap != nullptr && onHoverEnterEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onHoverEnterEventMap[entity]->Invoke();
|
||||||
|
}
|
||||||
|
SAFE_NATIVE_CALL_END("UIElement.OnHoverEntered")
|
||||||
|
}
|
||||||
|
void UIElement::OnHoverExited(EntityID entity)
|
||||||
|
{
|
||||||
|
SAFE_NATIVE_CALL_BEGIN
|
||||||
|
// Remove the event if it contained an event
|
||||||
|
if (onHoverExitEventMap != nullptr && onHoverExitEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onHoverExitEventMap[entity]->Invoke();
|
||||||
|
}
|
||||||
|
SAFE_NATIVE_CALL_END("UIElement.OnHoverExited")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,37 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
CallbackEvent^ get();
|
CallbackEvent^ get();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is raised when this UIElement is released.
|
||||||
|
/// </summary>
|
||||||
|
property CallbackEvent^ OnRelease
|
||||||
|
{
|
||||||
|
CallbackEvent^ get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is raised on the first frame when this UIElement is hovered over.
|
||||||
|
/// </summary>
|
||||||
|
property CallbackEvent^ OnHoverEnter
|
||||||
|
{
|
||||||
|
CallbackEvent^ get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is raised on the first frame when this UIElement is no longer
|
||||||
|
/// hovered over.
|
||||||
|
/// </summary>
|
||||||
|
property CallbackEvent^ OnHoverExit
|
||||||
|
{
|
||||||
|
CallbackEvent^ get();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Static Clear Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes static event data which may contains data from SHADE_Scripting.
|
||||||
|
/// </summary>
|
||||||
|
static void ClearStaticEventData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -65,11 +96,32 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">The entity which was clicked.</param>
|
/// <param name="entity">The entity which was clicked.</param>
|
||||||
static void OnClicked(EntityID entity);
|
static void OnClicked(EntityID entity);
|
||||||
|
/// <summary>
|
||||||
|
/// To be called from native code when this component is released from clicking.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity which was clicked.</param>
|
||||||
|
static void OnReleased(EntityID entity);
|
||||||
|
/// <summary>
|
||||||
|
/// To be called from native code on the first frame that this component is
|
||||||
|
/// hovered on.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity which was clicked.</param>
|
||||||
|
static void OnHoverEntered(EntityID entity);
|
||||||
|
/// <summary>
|
||||||
|
/// To be called from native code on the first frame that this component is
|
||||||
|
/// no longer hovered on.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity which was clicked.</param>
|
||||||
|
static void OnHoverExited(EntityID entity);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Static Data Members */
|
/* Static Data Members */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
// As these hold references to code in SHADE_Scripting, we must remember to dispose of them when changing scenes
|
||||||
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onClickEventMap;
|
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onClickEventMap;
|
||||||
|
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onReleasedEventMap;
|
||||||
|
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onHoverEnterEventMap;
|
||||||
|
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onHoverExitEventMap;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace SHADE
|
||||||
/// specified Component.
|
/// specified Component.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
generic<typename T> where T : BaseComponent
|
generic<typename T> where T : BaseComponent
|
||||||
static T GetComponent(EntityID entity);
|
static T GetComponent(EntityID entity);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the first Component from the specified GameObject's children that
|
/// Retrieves the first Component from the specified GameObject's children that
|
||||||
/// matches the specified type.
|
/// matches the specified type.
|
||||||
|
|
|
@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Utility/Convert.hxx"
|
#include "Utility/Convert.hxx"
|
||||||
#include "Utility/Debug.hxx"
|
#include "Utility/Debug.hxx"
|
||||||
#include "Scripts/ScriptStore.hxx"
|
#include "Scripts/ScriptStore.hxx"
|
||||||
|
#include "Components/UIElement.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -43,6 +44,9 @@ namespace SHADE
|
||||||
oss << "[EngineInterface] Unloading " << Convert::ToNative(ManagedLibraryName) << ".dll";
|
oss << "[EngineInterface] Unloading " << Convert::ToNative(ManagedLibraryName) << ".dll";
|
||||||
ScriptStore::Exit();
|
ScriptStore::Exit();
|
||||||
|
|
||||||
|
// Unload static data of components that have access to the assembly
|
||||||
|
UIElement::ClearStaticEventData();
|
||||||
|
|
||||||
// Unload the script
|
// Unload the script
|
||||||
scriptContext->Unload();
|
scriptContext->Unload();
|
||||||
scriptContext = nullptr;
|
scriptContext = nullptr;
|
||||||
|
|
|
@ -30,10 +30,29 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
return SHInputManager::GetMouseWheelVerticalDelta();
|
return SHInputManager::GetMouseWheelVerticalDelta();
|
||||||
}
|
}
|
||||||
|
bool Input::ControllerInUse::get()
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInUse();
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
bool Input::AnyKey()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::AnyKeyDown()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyKeyDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::AnyKeyUp()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyKeyUp();
|
||||||
|
}
|
||||||
|
|
||||||
bool Input::GetKey(KeyCode key)
|
bool Input::GetKey(KeyCode key)
|
||||||
{
|
{
|
||||||
return SHInputManager::GetKey(static_cast<SHInputManager::SH_KEYCODE>(key));
|
return SHInputManager::GetKey(static_cast<SHInputManager::SH_KEYCODE>(key));
|
||||||
|
@ -64,6 +83,50 @@ namespace SHADE
|
||||||
return SHInputManager::GetKeyUp(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
|
return SHInputManager::GetKeyUp(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Input::AnyControllerInput()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerInput();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerInputDown()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerInputDown();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerInputUp()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerInputUp();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerButton()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerButton();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerButtonDown()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerButtonDown();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerButtonUp()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerButtonUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::GetControllerInput(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInput(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
double Input::GetControllerInputNormalisedValue(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
double toReturn = 0.0;
|
||||||
|
SHInputManager::GetControllerInput(static_cast<SHInputManager::SH_CONTROLLERCODE>(code), &toReturn);
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
bool Input::GetControllerInputDown(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInputDown(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
bool Input::GetControllerInputUp(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInputUp(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Cursor Functions */
|
/* Cursor Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -76,6 +139,24 @@ namespace SHADE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 Input::GetMousePosition()
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
SHInputManager::GetMouseWindowPosition(&x, &y);
|
||||||
|
return Convert::ToCLI(SHVec2{ (float)x,(float)y });
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::SetMouseCentering(bool state)
|
||||||
|
{
|
||||||
|
SHInputManager::SetMouseCentering(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::GetMouseCentering()
|
||||||
|
{
|
||||||
|
return SHInputManager::GetMouseCentering();
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Time Functions */
|
/* Time Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -106,4 +187,220 @@ namespace SHADE
|
||||||
|
|
||||||
return Convert::ToCLI(SHVec2{ (float)velX,(float)velY });
|
return Convert::ToCLI(SHVec2{ (float)velX,(float)velY });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Input::GetControllerInputHeldTime(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInputHeldTime(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
double Input::GetControllerInputReleasedTime(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInputReleasedTime(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Binding Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
void Input::SaveBindings()
|
||||||
|
{
|
||||||
|
SHInputManager::SaveBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::SaveBindings(System::String^ targetFile)
|
||||||
|
{
|
||||||
|
SHInputManager::SaveBindings(Convert::ToNative(targetFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::LoadBindings()
|
||||||
|
{
|
||||||
|
SHInputManager::LoadBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::LoadBindings(System::String^ sourceFile)
|
||||||
|
{
|
||||||
|
SHInputManager::LoadBindings(Convert::ToNative(sourceFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::GetBindingInverted(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingInverted(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingInverted(System::String^ bindingName, bool newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingInverted(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
double Input::GetBindingGravity(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingGravity(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingGravity(System::String^ bindingName, double newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingGravity(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
double Input::GetBindingDead(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingDead(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingDead(System::String^ bindingName, double newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingDead(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
double Input::GetBindingSensitivity(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingSensitivity(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingSensitivity(System::String^ bindingName, double newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingSensitivity(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
bool Input::GetBindingSnap(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingSnap(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingSnap(System::String^ bindingName, bool newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingSnap(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System::Collections::Generic::HashSet<Input::KeyCode>^ Input::GetBindingPositiveKeyCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
System::Collections::Generic::HashSet<Input::KeyCode>^ toReturn = gcnew System::Collections::Generic::HashSet<Input::KeyCode>();
|
||||||
|
std::set<SHInputManager::SH_KEYCODE> list = SHInputManager::GetBindingPositiveKeyCodes(Convert::ToNative(bindingName));
|
||||||
|
for (auto kc : list)
|
||||||
|
{
|
||||||
|
toReturn->Add(static_cast<Input::KeyCode>(kc));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
void Input::AddBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toAdd)
|
||||||
|
{
|
||||||
|
SHInputManager::AddBindingPositiveKeyCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_KEYCODE>(toAdd));
|
||||||
|
}
|
||||||
|
void Input::RemoveBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toRemove)
|
||||||
|
{
|
||||||
|
SHInputManager::RemoveBindingPositiveKeyCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_KEYCODE>(toRemove));
|
||||||
|
}
|
||||||
|
void Input::ClearBindingPositiveKeyCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
SHInputManager::ClearBindingPositiveKeyCodes(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
System::Collections::Generic::HashSet<Input::KeyCode>^ Input::GetBindingNegativeKeyCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
System::Collections::Generic::HashSet<Input::KeyCode>^ toReturn = gcnew System::Collections::Generic::HashSet<Input::KeyCode>();
|
||||||
|
std::set<SHInputManager::SH_KEYCODE> list = SHInputManager::GetBindingNegativeKeyCodes(Convert::ToNative(bindingName));
|
||||||
|
for (auto kc : list)
|
||||||
|
{
|
||||||
|
toReturn->Add(static_cast<Input::KeyCode>(kc));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
void Input::AddBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toAdd)
|
||||||
|
{
|
||||||
|
SHInputManager::AddBindingNegativeKeyCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_KEYCODE>(toAdd));
|
||||||
|
}
|
||||||
|
void Input::RemoveBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toRemove)
|
||||||
|
{
|
||||||
|
SHInputManager::RemoveBindingNegativeKeyCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_KEYCODE>(toRemove));
|
||||||
|
}
|
||||||
|
void Input::ClearBindingNegativeKeyCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
SHInputManager::ClearBindingNegativeKeyCodes(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
System::Collections::Generic::HashSet<Input::ControllerCode>^ Input::GetBindingPositiveControllerCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
System::Collections::Generic::HashSet<Input::ControllerCode>^ toReturn = gcnew System::Collections::Generic::HashSet<Input::ControllerCode>();
|
||||||
|
std::set<SHInputManager::SH_CONTROLLERCODE> list = SHInputManager::GetBindingPositiveControllerCodes(Convert::ToNative(bindingName));
|
||||||
|
for (auto kc : list)
|
||||||
|
{
|
||||||
|
toReturn->Add(static_cast<Input::ControllerCode>(kc));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
void Input::AddBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toAdd)
|
||||||
|
{
|
||||||
|
SHInputManager::AddBindingPositiveControllerCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_CONTROLLERCODE>(toAdd));
|
||||||
|
}
|
||||||
|
void Input::RemoveBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toRemove)
|
||||||
|
{
|
||||||
|
SHInputManager::RemoveBindingPositiveControllerCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_CONTROLLERCODE>(toRemove));
|
||||||
|
}
|
||||||
|
void Input::ClearBindingPositiveControllerCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
SHInputManager::ClearBindingPositiveControllerCodes(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
System::Collections::Generic::HashSet<Input::ControllerCode>^ Input::GetBindingNegativeControllerCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
System::Collections::Generic::HashSet<Input::ControllerCode>^ toReturn = gcnew System::Collections::Generic::HashSet<Input::ControllerCode>();
|
||||||
|
std::set<SHInputManager::SH_CONTROLLERCODE> list = SHInputManager::GetBindingNegativeControllerCodes(Convert::ToNative(bindingName));
|
||||||
|
for (auto kc : list)
|
||||||
|
{
|
||||||
|
toReturn->Add(static_cast<Input::ControllerCode>(kc));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
void Input::AddBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toAdd)
|
||||||
|
{
|
||||||
|
SHInputManager::AddBindingNegativeControllerCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_CONTROLLERCODE>(toAdd));
|
||||||
|
}
|
||||||
|
void Input::RemoveBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toRemove)
|
||||||
|
{
|
||||||
|
SHInputManager::RemoveBindingNegativeControllerCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_CONTROLLERCODE>(toRemove));
|
||||||
|
}
|
||||||
|
void Input::ClearBindingNegativeControllerCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
SHInputManager::ClearBindingNegativeControllerCodes(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
double Input::GetBindingAxis(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingAxis(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
double Input::GetBindingAxisRaw(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingAxisRaw(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingPositiveButton(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveButton(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingNegativeButton(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeButton(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingPositiveButtonDown(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveButtonDown(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingNegativeButtonDown(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeButtonDown(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingPositiveButtonUp(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveButtonUp(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingNegativeButtonUp(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeButtonUp(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
double Input::GetBindingPositiveHeldTime(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveHeldTime(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
double Input::GetBindingNegativeHeldTime(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeHeldTime(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
double Input::GetBindingPositiveReleasedTime(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveReleasedTime(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
double Input::GetBindingNegativeReleasedTime(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeReleasedTime(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -181,7 +181,6 @@ namespace SHADE
|
||||||
//Break
|
//Break
|
||||||
//Menu
|
//Menu
|
||||||
//Mouse buttons use mouse codes, which are enums declared later
|
//Mouse buttons use mouse codes, which are enums declared later
|
||||||
//TODO Controller input
|
|
||||||
#if 0
|
#if 0
|
||||||
Space = static_cast<int>(SHInputManager::SH_KEYCODE::SPACE),
|
Space = static_cast<int>(SHInputManager::SH_KEYCODE::SPACE),
|
||||||
//Apostrophe = static_cast<int>(SHInputManager::SH_KEYCODE::APOSTROPHE),
|
//Apostrophe = static_cast<int>(SHInputManager::SH_KEYCODE::APOSTROPHE),
|
||||||
|
@ -355,6 +354,35 @@ namespace SHADE
|
||||||
Button3 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB1),
|
Button3 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB1),
|
||||||
Button4 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB2)
|
Button4 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB2)
|
||||||
};
|
};
|
||||||
|
enum class ControllerCode : int
|
||||||
|
{
|
||||||
|
DpadUp = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::DPAD_UP),
|
||||||
|
DpadDown = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::DPAD_DOWN),
|
||||||
|
DpadLeft = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::DPAD_LEFT),
|
||||||
|
DpadRight = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::DPAD_RIGHT),
|
||||||
|
Start = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::START),
|
||||||
|
Back = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::BACK),
|
||||||
|
LeftThumbstickButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK),
|
||||||
|
RightThumbstickButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::RIGHT_THUMBSTICK),
|
||||||
|
LeftShoulder = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_SHOULDER),
|
||||||
|
RightShoulder = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::RIGHT_SHOULDER),
|
||||||
|
AButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::A),
|
||||||
|
BButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::B),
|
||||||
|
XButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::X),
|
||||||
|
YButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::Y),
|
||||||
|
LeftTrigger = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_TRIGGER),
|
||||||
|
RightTrigger = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::RIGHT_TRIGGER),
|
||||||
|
LeftThumbStickX = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK_X),
|
||||||
|
LeftThumbStickY = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK_Y)
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class BindingType : int
|
||||||
|
{
|
||||||
|
KbMbController = static_cast<int>(SHInputManager::SH_BINDINGTYPE::KB_MB_CONTROLLER),
|
||||||
|
mouseX = static_cast<int>(SHInputManager::SH_BINDINGTYPE::MOUSE_X),
|
||||||
|
mouseY = static_cast<int>(SHInputManager::SH_BINDINGTYPE::MOUSE_Y),
|
||||||
|
mouseScroll = static_cast<int>(SHInputManager::SH_BINDINGTYPE::MOUSE_SCROLL)
|
||||||
|
};
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Properites */
|
/* Properites */
|
||||||
|
@ -376,9 +404,25 @@ namespace SHADE
|
||||||
int get();
|
int get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static property bool ControllerInUse
|
||||||
|
{
|
||||||
|
bool get();
|
||||||
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if any key is being held down.
|
||||||
|
/// This will also be true if GetKeyDown() is true.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="firstKey">KeyCode of the first key that was detected to be pressed.</param>
|
||||||
|
/// <returns>True while the user holds down the key specified.</returns>
|
||||||
|
static bool AnyKey();
|
||||||
|
static bool AnyKeyDown();
|
||||||
|
static bool AnyKeyUp();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if a specified key is being held down.
|
/// Checks if a specified key is being held down.
|
||||||
/// This will also be true if GetKeyDown() is true.
|
/// This will also be true if GetKeyDown() is true.
|
||||||
|
@ -427,6 +471,20 @@ namespace SHADE
|
||||||
/// True during the frame the user releases the given mouse button.
|
/// True during the frame the user releases the given mouse button.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
static bool GetMouseButtonUp(MouseCode mouseButton);
|
static bool GetMouseButtonUp(MouseCode mouseButton);
|
||||||
|
|
||||||
|
//For controller
|
||||||
|
|
||||||
|
static bool AnyControllerInput();
|
||||||
|
static bool AnyControllerInputDown();
|
||||||
|
static bool AnyControllerInputUp();
|
||||||
|
static bool AnyControllerButton();
|
||||||
|
static bool AnyControllerButtonDown();
|
||||||
|
static bool AnyControllerButtonUp();
|
||||||
|
|
||||||
|
static bool GetControllerInput(ControllerCode code);
|
||||||
|
static double GetControllerInputNormalisedValue(ControllerCode code);
|
||||||
|
static bool GetControllerInputDown(ControllerCode code);
|
||||||
|
static bool GetControllerInputUp(ControllerCode code);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Cursor Functions */
|
/* Cursor Functions */
|
||||||
|
@ -440,6 +498,11 @@ namespace SHADE
|
||||||
/// </param>
|
/// </param>
|
||||||
static void SetMousePosition(Vector2 pos);
|
static void SetMousePosition(Vector2 pos);
|
||||||
|
|
||||||
|
static Vector2 GetMousePosition();
|
||||||
|
|
||||||
|
static void SetMouseCentering(bool state);
|
||||||
|
static bool GetMouseCentering();
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Timing Functions */
|
/* Timing Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -472,6 +535,66 @@ namespace SHADE
|
||||||
/// <returns>Time in seconds that the key was held.</returns>
|
/// <returns>Time in seconds that the key was held.</returns>
|
||||||
static double GetMouseReleasedTime(MouseCode mouseButton);
|
static double GetMouseReleasedTime(MouseCode mouseButton);
|
||||||
|
|
||||||
|
static double GetControllerInputHeldTime(ControllerCode code);
|
||||||
|
static double GetControllerInputReleasedTime(ControllerCode code);
|
||||||
|
|
||||||
static Vector2 GetMouseVelocity();
|
static Vector2 GetMouseVelocity();
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Binding Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
static void SaveBindings(); //To default file
|
||||||
|
static void SaveBindings(System::String^ targetFile);
|
||||||
|
static void LoadBindings(); //From default file
|
||||||
|
static void LoadBindings(System::String^ sourceFile);
|
||||||
|
|
||||||
|
static bool GetBindingInverted(System::String^ bindingName);
|
||||||
|
static void SetBindingInverted(System::String^ bindingName, bool newValue);
|
||||||
|
static double GetBindingGravity(System::String^ bindingName);
|
||||||
|
static void SetBindingGravity(System::String^ bindingName, double newValue);
|
||||||
|
static double GetBindingDead(System::String^ bindingName);
|
||||||
|
static void SetBindingDead(System::String^ bindingName, double newValue);
|
||||||
|
static double GetBindingSensitivity(System::String^ bindingName);
|
||||||
|
static void SetBindingSensitivity(System::String^ bindingName, double newValue);
|
||||||
|
static bool GetBindingSnap(System::String^ bindingName);
|
||||||
|
static void SetBindingSnap(System::String^ bindingName, bool newValue);
|
||||||
|
|
||||||
|
static System::Collections::Generic::HashSet<KeyCode>^ GetBindingPositiveKeyCodes(System::String^ bindingName);
|
||||||
|
static void AddBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toAdd);
|
||||||
|
static void RemoveBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toRemove);
|
||||||
|
static void ClearBindingPositiveKeyCodes(System::String^ bindingName);
|
||||||
|
|
||||||
|
static System::Collections::Generic::HashSet<KeyCode>^ GetBindingNegativeKeyCodes(System::String^ bindingName);
|
||||||
|
static void AddBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toAdd);
|
||||||
|
static void RemoveBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toRemove);
|
||||||
|
static void ClearBindingNegativeKeyCodes(System::String^ bindingName);
|
||||||
|
|
||||||
|
static System::Collections::Generic::HashSet<ControllerCode>^ GetBindingPositiveControllerCodes(System::String^ bindingName);
|
||||||
|
static void AddBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toAdd);
|
||||||
|
static void RemoveBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toRemove);
|
||||||
|
static void ClearBindingPositiveControllerCodes(System::String^ bindingName);
|
||||||
|
|
||||||
|
static System::Collections::Generic::HashSet<ControllerCode>^ GetBindingNegativeControllerCodes(System::String^ bindingName);
|
||||||
|
static void AddBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toAdd);
|
||||||
|
static void RemoveBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toRemove);
|
||||||
|
static void ClearBindingNegativeControllerCodes(System::String^ bindingName);
|
||||||
|
|
||||||
|
//Binding states
|
||||||
|
|
||||||
|
static double GetBindingAxis(System::String^ bindingName);
|
||||||
|
static double GetBindingAxisRaw(System::String^ bindingName);
|
||||||
|
static bool GetBindingPositiveButton(System::String^ bindingName);
|
||||||
|
static bool GetBindingNegativeButton(System::String^ bindingName);
|
||||||
|
static bool GetBindingPositiveButtonDown(System::String^ bindingName);
|
||||||
|
static bool GetBindingNegativeButtonDown(System::String^ bindingName);
|
||||||
|
static bool GetBindingPositiveButtonUp(System::String^ bindingName);
|
||||||
|
static bool GetBindingNegativeButtonUp(System::String^ bindingName);
|
||||||
|
|
||||||
|
//Binding times
|
||||||
|
|
||||||
|
static double GetBindingPositiveHeldTime(System::String^ bindingName);
|
||||||
|
static double GetBindingNegativeHeldTime(System::String^ bindingName);
|
||||||
|
static double GetBindingPositiveReleasedTime(System::String^ bindingName);
|
||||||
|
static double GetBindingNegativeReleasedTime(System::String^ bindingName);
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue