Button remapping work
This commit is contained in:
@@ -4,8 +4,8 @@ using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using NathanHoad;
|
||||
using SimpleInjector.Lifestyles;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -47,11 +47,11 @@ public partial class App : Node, IApp
|
||||
private bool _loadingGame = false;
|
||||
private bool _loadingEnemyViewer = false;
|
||||
private string _optionsSavePath = string.Empty;
|
||||
private string _controllerSavePath = string.Empty;
|
||||
private ISaveFileManager _saveFileManager;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
MainMenu.Hide();
|
||||
_container = new SimpleInjector.Container();
|
||||
_container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
|
||||
_container.RegisterSingleton<IAppRepo, AppRepo>();
|
||||
@@ -61,6 +61,7 @@ public partial class App : Node, IApp
|
||||
|
||||
_saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
_optionsSavePath = $"{OS.GetUserDataDir()}/options.json";
|
||||
_controllerSavePath = $"{OS.GetUserDataDir()}/controls.json";
|
||||
|
||||
Task.Run(() => _saveFileManager.ReadFromFile<OptionsData>(_optionsSavePath).ContinueWith((data) =>
|
||||
{
|
||||
@@ -68,6 +69,12 @@ public partial class App : Node, IApp
|
||||
OptionsMenu.CallDeferred("Load", data.Result);
|
||||
}));
|
||||
|
||||
Task.Run(() => _saveFileManager.ReadFromFile<string>(_controllerSavePath).ContinueWith((data) =>
|
||||
{
|
||||
if (data.IsCompletedSuccessfully)
|
||||
OptionsMenu.Controller.CallDeferred(nameof(OptionsMenu.Controller.LoadControllerInput), data.Result);
|
||||
}));
|
||||
|
||||
MainMenu.StartGame += OnStartGame;
|
||||
MainMenu.EnemyViewer += OnEnemyViewer;
|
||||
MainMenu.Options += OnOptions;
|
||||
@@ -91,8 +98,10 @@ public partial class App : Node, IApp
|
||||
{
|
||||
var saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
await saveFileManager.WriteToFile(OptionsMenu.OptionsData, _optionsSavePath);
|
||||
MainMenu.Show();
|
||||
var controllerOutput = InputHelper.SerializeInputsForActions();
|
||||
await saveFileManager.WriteToFile(controllerOutput, _controllerSavePath);
|
||||
OptionsMenu.Hide();
|
||||
MainMenu.OptionsButton.GrabFocus();
|
||||
}
|
||||
|
||||
private void OnGameLoaded(string sceneName)
|
||||
@@ -141,7 +150,6 @@ public partial class App : Node, IApp
|
||||
});
|
||||
|
||||
AppLogic.Start();
|
||||
MainMenu.Show();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
@@ -170,7 +178,7 @@ public partial class App : Node, IApp
|
||||
private async void OnOptions()
|
||||
{
|
||||
OptionsMenu.Show();
|
||||
MainMenu.Hide();
|
||||
OptionsMenu.MasterVolumeSlider.GrabFocus();
|
||||
}
|
||||
|
||||
public void OnQuit() => AppLogic.Input(new AppLogic.Input.QuitGame());
|
||||
|
||||
Reference in New Issue
Block a user