internally switch input methods; closes #11
parent
0662c558e0
commit
5ef3229e93
|
@ -68,13 +68,23 @@ public abstract partial class PlayerState : CharacterState
|
|||
|
||||
if (!weapon.ShouldHideIdle || isAttack1On)
|
||||
{
|
||||
if (joystick.IsZeroApprox())
|
||||
var inputMethod = Utils.World.Instance.GlobalState
|
||||
.Settings.InputMethod;
|
||||
switch (inputMethod)
|
||||
{
|
||||
Character.Target = Character.Direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
Character.Target = joystick;
|
||||
case Global.InputMethod.Joystick:
|
||||
if (joystick.IsZeroApprox())
|
||||
{
|
||||
Character.Target = Character.Direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
Character.Target = joystick;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Character.Target = dirToMouse;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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