internally switch input methods; closes #11
parent
0662c558e0
commit
5ef3229e93
|
@ -68,6 +68,11 @@ public abstract partial class PlayerState : CharacterState
|
|||
|
||||
if (!weapon.ShouldHideIdle || isAttack1On)
|
||||
{
|
||||
var inputMethod = Utils.World.Instance.GlobalState
|
||||
.Settings.InputMethod;
|
||||
switch (inputMethod)
|
||||
{
|
||||
case Global.InputMethod.Joystick:
|
||||
if (joystick.IsZeroApprox())
|
||||
{
|
||||
Character.Target = Character.Direction;
|
||||
|
@ -76,6 +81,11 @@ public abstract partial class PlayerState : CharacterState
|
|||
{
|
||||
Character.Target = joystick;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Character.Target = dirToMouse;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAttack1On)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
using Godot;
|
||||
|
||||
namespace SupaLidlGame.State.Global;
|
||||
|
||||
public enum InputMethod
|
||||
{
|
||||
Mouse,
|
||||
Joystick,
|
||||
MouseCentered,
|
||||
}
|
||||
|
||||
public partial class GameSettings : Resource
|
||||
{
|
||||
[Export]
|
||||
public InputMethod InputMethod { get; set; }
|
||||
}
|
|
@ -14,12 +14,44 @@ public partial class GlobalState : Node
|
|||
[Export]
|
||||
public Stats Stats { get; set; } = new();
|
||||
|
||||
[Export]
|
||||
public GameSettings Settings { get; set; } = new();
|
||||
|
||||
[Signal]
|
||||
public delegate void SummonBossEventHandler(string bossName);
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
ProcessMode = ProcessModeEnum.Always;
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
public override void _Notification(int what)
|
||||
{
|
||||
if (what == NotificationWMCloseRequest)
|
||||
{
|
||||
// TODO: quit prompt
|
||||
GetTree().Root
|
||||
.PropagateNotification((int)NotificationWMCloseRequest);
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
if (ResourceLoader.Exists("user://settings.tres"))
|
||||
{
|
||||
Settings = ResourceLoader.Load<GameSettings>("user://settings.tres");
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings = new GameSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
{
|
||||
ResourceSaver.Save(Settings, "user://settings.tres");
|
||||
}
|
||||
|
||||
public void ImportFromSave(Save save)
|
||||
|
|
Loading…
Reference in New Issue