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());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://rfvnddfqufho"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://rfvnddfqufho"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://14b7o2c6cgry" path="res://src/menu/MainMenu.cs" id="1_y6722"]
|
||||
[ext_resource type="Shortcut" uid="uid://dumkrjur22k2a" path="res://src/ui/ButtonShortcut.tres" id="2_7fwjx"]
|
||||
|
||||
[node name="MainMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -27,7 +28,6 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 0
|
||||
theme_override_constants/margin_left = 100
|
||||
theme_override_constants/margin_top = 100
|
||||
theme_override_constants/margin_right = 100
|
||||
@@ -37,41 +37,56 @@ theme_override_constants/margin_bottom = 100
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
mouse_filter = 0
|
||||
|
||||
[node name="StartGameButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_neighbor_bottom = NodePath("../EnemyViewerButton")
|
||||
focus_next = NodePath("../EnemyViewerButton")
|
||||
theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1)
|
||||
shortcut = ExtResource("2_7fwjx")
|
||||
text = "Start Game"
|
||||
|
||||
[node name="EnemyViewerButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_neighbor_bottom = NodePath("../GalleryButton")
|
||||
focus_next = NodePath("../GalleryButton")
|
||||
focus_previous = NodePath("../StartGameButton")
|
||||
theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1)
|
||||
shortcut = ExtResource("2_7fwjx")
|
||||
text = "Enemy Viewer"
|
||||
|
||||
[node name="GalleryButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_neighbor_top = NodePath("../EnemyViewerButton")
|
||||
focus_neighbor_bottom = NodePath("../QuitButton")
|
||||
focus_neighbor_bottom = NodePath("../OptionsButton")
|
||||
focus_next = NodePath("../OptionsButton")
|
||||
focus_previous = NodePath("../EnemyViewerButton")
|
||||
theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1)
|
||||
shortcut = ExtResource("2_7fwjx")
|
||||
text = "Gallery"
|
||||
|
||||
[node name="OptionsButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_neighbor_top = NodePath("../EnemyViewerButton")
|
||||
focus_neighbor_top = NodePath("../GalleryButton")
|
||||
focus_neighbor_bottom = NodePath("../QuitButton")
|
||||
focus_next = NodePath("../QuitButton")
|
||||
focus_previous = NodePath("../GalleryButton")
|
||||
theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1)
|
||||
shortcut = ExtResource("2_7fwjx")
|
||||
text = "Options"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_neighbor_top = NodePath("../GalleryButton")
|
||||
focus_neighbor_top = NodePath("../OptionsButton")
|
||||
focus_neighbor_bottom = NodePath(".")
|
||||
focus_next = NodePath(".")
|
||||
focus_previous = NodePath("../OptionsButton")
|
||||
theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1)
|
||||
shortcut = ExtResource("2_7fwjx")
|
||||
text = "Quit
|
||||
"
|
||||
|
||||
19
Zennysoft.Game.Ma/src/options/InputMapButton.cs
Normal file
19
Zennysoft.Game.Ma/src/options/InputMapButton.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Godot;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public abstract partial class InputMapButton : Button
|
||||
{
|
||||
[Signal] public delegate void RemapEventHandler(InputMapButton buttonBeingRemapped);
|
||||
|
||||
public string Action { get; set; }
|
||||
|
||||
public InputEvent InputEvent { get; set; }
|
||||
|
||||
public InputMapButton()
|
||||
{
|
||||
Pressed += RemapButton_Pressed;
|
||||
}
|
||||
|
||||
private void RemapButton_Pressed() => EmitSignal(SignalName.Remap, this);
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/options/InputMapButton.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/options/InputMapButton.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bhfrdlnv7xyf6
|
||||
191
Zennysoft.Game.Ma/src/options/InputMapper.cs
Normal file
191
Zennysoft.Game.Ma/src/options/InputMapper.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using NathanHoad;
|
||||
using SimpleInjector.Lifestyles;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Game.Implementation;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class InputMapper : PanelContainer
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public VBoxContainer ActionList { get; set; }
|
||||
|
||||
[Node] public KeyboardRemapButton MoveForwardKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton MoveForwardController { get; set; }
|
||||
[Node] public KeyboardRemapButton MoveLeftKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton MoveLeftController { get; set; }
|
||||
[Node] public KeyboardRemapButton MoveRightKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton MoveRightController { get; set; }
|
||||
[Node] public KeyboardRemapButton MoveBackwardKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton MoveBackwardController { get; set; }
|
||||
[Node] public KeyboardRemapButton StrafeLeftKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton StrafeLeftController { get; set; }
|
||||
[Node] public KeyboardRemapButton StrafeRightKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton StrafeRightController { get; set; }
|
||||
[Node] public KeyboardRemapButton AttackKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton AttackController { get; set; }
|
||||
[Node] public KeyboardRemapButton InteractKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton InteractController { get; set; }
|
||||
[Node] public KeyboardRemapButton InventoryKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton InventoryController { get; set; }
|
||||
[Node] public KeyboardRemapButton SortKeyboard { get; set; }
|
||||
[Node] public JoypadRemapButton SortController { get; set; }
|
||||
|
||||
private Button _remappingButton = null;
|
||||
private InputEvent _remappingAction = null;
|
||||
|
||||
private List<JoypadRemapButton> _actionJoyMap = [];
|
||||
private List<KeyboardRemapButton> _actionKeyMap = [];
|
||||
|
||||
private SimpleInjector.Container _container;
|
||||
private ISaveFileManager _saveFileManager;
|
||||
|
||||
[Signal] public delegate void SaveControllerInputEventHandler();
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
_container = new SimpleInjector.Container();
|
||||
_container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
|
||||
_container.RegisterSingleton<IFileSystem, FileSystem>();
|
||||
_container.RegisterSingleton<ISaveFileManager, SaveFileManager>();
|
||||
_saveFileManager = _container.GetInstance<ISaveFileManager>();
|
||||
|
||||
MoveForwardController.Action = GameInputs.MoveUp;
|
||||
MoveForwardKeyboard.Action = GameInputs.MoveUp;
|
||||
MoveLeftController.Action = GameInputs.MoveLeft;
|
||||
MoveLeftKeyboard.Action = GameInputs.MoveLeft;
|
||||
MoveRightController.Action = GameInputs.MoveRight;
|
||||
MoveRightKeyboard.Action = GameInputs.MoveRight;
|
||||
MoveBackwardController.Action = GameInputs.MoveDown;
|
||||
MoveBackwardKeyboard.Action = GameInputs.MoveDown;
|
||||
StrafeLeftController.Action = GameInputs.StrafeLeft;
|
||||
StrafeLeftKeyboard.Action = GameInputs.StrafeLeft;
|
||||
StrafeRightController.Action = GameInputs.StrafeRight;
|
||||
StrafeRightKeyboard.Action = GameInputs.StrafeRight;
|
||||
AttackController.Action = GameInputs.Attack;
|
||||
AttackKeyboard.Action = GameInputs.Attack;
|
||||
InteractController.Action = GameInputs.Interact;
|
||||
InteractKeyboard.Action = GameInputs.Interact;
|
||||
InventoryController.Action = GameInputs.Inventory;
|
||||
InventoryKeyboard.Action = GameInputs.Inventory;
|
||||
SortController.Action = GameInputs.InventorySort;
|
||||
SortKeyboard.Action = GameInputs.InventorySort;
|
||||
|
||||
_actionJoyMap.Add(MoveForwardController);
|
||||
_actionJoyMap.Add(MoveLeftController);
|
||||
_actionJoyMap.Add(MoveRightController);
|
||||
_actionJoyMap.Add(MoveBackwardController);
|
||||
_actionJoyMap.Add(StrafeLeftController);
|
||||
_actionJoyMap.Add(StrafeRightController);
|
||||
_actionJoyMap.Add(AttackController);
|
||||
_actionJoyMap.Add(InteractController);
|
||||
_actionJoyMap.Add(InventoryController);
|
||||
_actionJoyMap.Add(SortController);
|
||||
|
||||
_actionKeyMap.Add(MoveForwardKeyboard);
|
||||
_actionKeyMap.Add(MoveLeftKeyboard);
|
||||
_actionKeyMap.Add(MoveRightKeyboard);
|
||||
_actionKeyMap.Add(MoveBackwardKeyboard);
|
||||
_actionKeyMap.Add(StrafeLeftKeyboard);
|
||||
_actionKeyMap.Add(StrafeRightKeyboard);
|
||||
_actionKeyMap.Add(AttackKeyboard);
|
||||
_actionKeyMap.Add(InteractKeyboard);
|
||||
_actionKeyMap.Add(InventoryKeyboard);
|
||||
_actionKeyMap.Add(SortKeyboard);
|
||||
|
||||
MoveForwardKeyboard.Remap += OnRemap;
|
||||
MoveForwardController.Remap += OnRemap;
|
||||
MoveLeftKeyboard.Remap += OnRemap;
|
||||
MoveLeftController.Remap += OnRemap;
|
||||
MoveRightKeyboard.Remap += OnRemap;
|
||||
MoveRightController.Remap += OnRemap;
|
||||
MoveBackwardKeyboard.Remap += OnRemap;
|
||||
MoveBackwardController.Remap += OnRemap;
|
||||
StrafeLeftKeyboard.Remap += OnRemap;
|
||||
StrafeLeftController.Remap += OnRemap;
|
||||
StrafeRightKeyboard.Remap += OnRemap;
|
||||
StrafeRightController.Remap += OnRemap;
|
||||
AttackKeyboard.Remap += OnRemap;
|
||||
AttackController.Remap += OnRemap;
|
||||
InteractKeyboard.Remap += OnRemap;
|
||||
InteractController.Remap += OnRemap;
|
||||
InventoryKeyboard.Remap += OnRemap;
|
||||
InventoryController.Remap += OnRemap;
|
||||
SortKeyboard.Remap += OnRemap;
|
||||
SortController.Remap += OnRemap;
|
||||
|
||||
InputHelper.JoypadInputChanged += (string action, InputEvent input) =>
|
||||
{
|
||||
var buttonChanged = _actionJoyMap.SingleOrDefault(x => x.Action == action);
|
||||
if (buttonChanged != null)
|
||||
{
|
||||
buttonChanged.SetProcessInput(false);
|
||||
buttonChanged.Text = InputHelper.GetLabelForInput(input);
|
||||
}
|
||||
var allButtons = _actionKeyMap.Concat<InputMapButton>(_actionJoyMap);
|
||||
foreach (var button in allButtons)
|
||||
button.Disabled = false;
|
||||
};
|
||||
|
||||
InputHelper.KeyboardInputChanged += (string action, InputEvent input) =>
|
||||
{
|
||||
var buttonChanged = _actionKeyMap.SingleOrDefault(x => x.Action == action);
|
||||
if (buttonChanged != null)
|
||||
{
|
||||
buttonChanged.SetProcessInput(false);
|
||||
buttonChanged.Text = InputHelper.GetLabelForInput(input);
|
||||
}
|
||||
var allButtons = _actionKeyMap.Concat<InputMapButton>(_actionJoyMap);
|
||||
foreach (var button in allButtons)
|
||||
button.Disabled = false;
|
||||
};
|
||||
}
|
||||
|
||||
public void LoadControllerInput(string jsonData)
|
||||
{
|
||||
InputHelper.DeserializeInputsForActions(jsonData);
|
||||
InitializeButtonText();
|
||||
}
|
||||
|
||||
public void InitializeButtonText()
|
||||
{
|
||||
MoveForwardKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.MoveUp));
|
||||
MoveForwardController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.MoveUp));
|
||||
MoveLeftKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.MoveLeft));
|
||||
MoveLeftController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.MoveLeft));
|
||||
MoveRightKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.MoveRight));
|
||||
MoveRightController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.MoveRight));
|
||||
MoveBackwardKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.MoveDown));
|
||||
MoveBackwardController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.MoveDown));
|
||||
StrafeLeftKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.StrafeLeft));
|
||||
StrafeLeftController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.StrafeLeft));
|
||||
StrafeRightKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.StrafeRight));
|
||||
StrafeRightController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.StrafeRight));
|
||||
AttackKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.Attack));
|
||||
AttackController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.Attack));
|
||||
InteractKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.Interact));
|
||||
InteractController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.Interact));
|
||||
InventoryKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.Inventory));
|
||||
InventoryController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.Inventory));
|
||||
SortKeyboard.Text = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.InventorySort));
|
||||
SortController.Text = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.InventorySort));
|
||||
}
|
||||
|
||||
private void OnRemap(InputMapButton inputButton)
|
||||
{
|
||||
inputButton.Text = "...";
|
||||
inputButton.SetProcessInput(true);
|
||||
var allButtons = _actionKeyMap.Concat<InputMapButton>(_actionJoyMap);
|
||||
foreach (var button in allButtons)
|
||||
button.Disabled = true;
|
||||
ReleaseFocus();
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/options/InputMapper.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/options/InputMapper.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c6lw5yp8p0wb5
|
||||
361
Zennysoft.Game.Ma/src/options/InputMapper.tscn
Normal file
361
Zennysoft.Game.Ma/src/options/InputMapper.tscn
Normal file
@@ -0,0 +1,361 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dk5esf6mm6kte"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c6lw5yp8p0wb5" path="res://src/options/InputMapper.cs" id="1_rwvs3"]
|
||||
[ext_resource type="Script" uid="uid://b70br20xue678" path="res://src/options/KeyboardRemapButton.cs" id="2_fmxfy"]
|
||||
[ext_resource type="Script" uid="uid://bo7vk56h1lr07" path="res://src/options/JoypadRemapButton.cs" id="3_yis0i"]
|
||||
|
||||
[node name="InputMapper" type="PanelContainer"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -451.0
|
||||
offset_top = -451.0
|
||||
offset_right = 449.0
|
||||
offset_bottom = 449.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_rwvs3")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
mouse_filter = 0
|
||||
theme_override_constants/margin_left = 25
|
||||
theme_override_constants/margin_top = 25
|
||||
theme_override_constants/margin_right = 25
|
||||
theme_override_constants/margin_bottom = 25
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 3
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ActionList" type="VBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="Header" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Header"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Actions"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Header"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label2" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Header"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Keyboard"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Header"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label3" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Header"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Controller"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Move Forward" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Forward"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Move Forward"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Forward"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="MoveForwardKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Forward"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 35)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Forward"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="MoveForwardController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Forward"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
|
||||
[node name="Move Left" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Left"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Move Left"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Left"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="MoveLeftKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Left"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 35)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Left"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="MoveLeftController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Left"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
|
||||
[node name="Move Right" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Right"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Move Right"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Right"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="MoveRightKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Right"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 35)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Right"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="MoveRightController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Right"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
|
||||
[node name="Move Backward" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Backward"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Move Backward"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Backward"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="MoveBackwardKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Backward"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Backward"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="MoveBackwardController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Move Backward"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
|
||||
[node name="Strafe Left" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Left"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Strafe Left"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Left"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="StrafeLeftKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Left"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Left"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="StrafeLeftController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Left"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
|
||||
[node name="Strafe Right" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Right"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Strafe Right"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Right"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="StrafeRightKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Right"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Right"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="StrafeRightController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Strafe Right"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
|
||||
[node name="Attack" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Attack"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Attack"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Attack"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="AttackKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Attack"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 35)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Attack"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="AttackController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Attack"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
|
||||
[node name="Interact" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Interact"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Interact"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Interact"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="InteractKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Interact"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 35)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Interact"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="InteractController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Interact"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
|
||||
[node name="Open Inventory" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Open Inventory"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Open Inventory"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Open Inventory"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="InventoryKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Open Inventory"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 35)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Open Inventory"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="InventoryController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Open Inventory"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
|
||||
[node name="Sort Inventory" type="HBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Sort Inventory"]
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
text = "Sort Inventory"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Sort Inventory"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="SortKeyboard" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Sort Inventory"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 35)
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_fmxfy")
|
||||
|
||||
[node name="Control2" type="Control" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Sort Inventory"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="SortController" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/ActionList/Sort Inventory"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_yis0i")
|
||||
1
Zennysoft.Game.Ma/src/options/InputToString.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/options/InputToString.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bwd066xv65pbi
|
||||
41
Zennysoft.Game.Ma/src/options/JoypadRemapButton.cs
Normal file
41
Zennysoft.Game.Ma/src/options/JoypadRemapButton.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Godot;
|
||||
using NathanHoad;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public partial class JoypadRemapButton : InputMapButton
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
SetProcessInput(false);
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event.IsActionType() && InputHelper.GetDeviceFromEvent(@event) != "keyboard")
|
||||
{
|
||||
if (InputHelper.GetJoypadInputForAction(GameInputs.Pause).IsMatch(@event))
|
||||
{
|
||||
InputHelper.SetJoypadInputForAction(Action, InputEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
InputHelper.ReplaceJoypadInputForAction(Action, InputEvent, @event, true);
|
||||
if (Action == GameInputs.MoveUp)
|
||||
InputHelper.ReplaceJoypadInputForAction(GameInputs.UiUp, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.MoveLeft)
|
||||
InputHelper.ReplaceJoypadInputForAction(GameInputs.UiLeft, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.MoveRight)
|
||||
InputHelper.ReplaceJoypadInputForAction(GameInputs.UiRight, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.MoveDown)
|
||||
InputHelper.ReplaceJoypadInputForAction(GameInputs.UiDown, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.Attack)
|
||||
InputHelper.ReplaceJoypadInputForAction(GameInputs.UiAccept, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.Interact)
|
||||
InputHelper.ReplaceJoypadInputForAction(GameInputs.UiCancel, InputEvent, @event, true);
|
||||
InputEvent = @event;
|
||||
}
|
||||
}
|
||||
AcceptEvent();
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/options/JoypadRemapButton.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/options/JoypadRemapButton.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bo7vk56h1lr07
|
||||
42
Zennysoft.Game.Ma/src/options/KeyboardRemapButton.cs
Normal file
42
Zennysoft.Game.Ma/src/options/KeyboardRemapButton.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Godot;
|
||||
using NathanHoad;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public partial class KeyboardRemapButton : InputMapButton
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
SetProcessInput(false);
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
AcceptEvent();
|
||||
if (@event.IsActionType() && InputHelper.GetDeviceFromEvent(@event) == "keyboard")
|
||||
{
|
||||
if (InputHelper.GetKeyboardInputForAction(GameInputs.Pause).IsMatch(@event))
|
||||
{
|
||||
InputHelper.SetKeyboardInputForAction(Action, InputEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
InputHelper.ReplaceKeyboardInputForAction(Action, InputEvent, @event, true);
|
||||
if (Action == GameInputs.MoveUp)
|
||||
InputHelper.ReplaceKeyboardInputForAction(GameInputs.UiUp, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.MoveLeft)
|
||||
InputHelper.ReplaceKeyboardInputForAction(GameInputs.UiLeft, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.MoveRight)
|
||||
InputHelper.ReplaceKeyboardInputForAction(GameInputs.UiRight, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.MoveDown)
|
||||
InputHelper.ReplaceKeyboardInputForAction(GameInputs.UiDown, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.Attack)
|
||||
InputHelper.ReplaceKeyboardInputForAction(GameInputs.UiAccept, InputEvent, @event, true);
|
||||
else if (Action == GameInputs.Interact)
|
||||
InputHelper.ReplaceKeyboardInputForAction(GameInputs.UiCancel, InputEvent, @event, true);
|
||||
InputEvent = @event;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
Zennysoft.Game.Ma/src/options/KeyboardRemapButton.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/options/KeyboardRemapButton.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b70br20xue678
|
||||
21
Zennysoft.Game.Ma/src/options/OptionsData.cs
Normal file
21
Zennysoft.Game.Ma/src/options/OptionsData.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
[Meta, Id("options_data")]
|
||||
public partial class OptionsData : Node
|
||||
{
|
||||
[Save("MasterVolume")]
|
||||
public required double MasterVolumeLevel { get; set; }
|
||||
|
||||
[Save("MusicVolume")]
|
||||
public required double MusicVolumeLevel { get; set; }
|
||||
|
||||
[Save("SFXVolume")]
|
||||
public required double SFXVolumeLevel { get; set; }
|
||||
|
||||
[Save("ScreenResolution")]
|
||||
public required int ScreenResolution { get; set; }
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/options/OptionsData.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/options/OptionsData.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://jrl2hyudv6jn
|
||||
@@ -1,7 +1,8 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using NathanHoad;
|
||||
using System.Linq;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -15,7 +16,12 @@ public partial class OptionsMenu : Control
|
||||
[Node] public HSlider MasterVolumeSlider { get; set; }
|
||||
[Node] public HSlider MusicVolumeSlider { get; set; }
|
||||
[Node] public HSlider SFXVolumeSlider { get; set; }
|
||||
[Node] public Button SaveAndExitButton { get; set; }
|
||||
|
||||
[Node] public InputMapper Controller { get; set; }
|
||||
[Node] public TabContainer TabContainer { get; set; }
|
||||
[Node] public Label PressToGoBackLabel { get; set; }
|
||||
|
||||
[Node] public CanvasLayer CanvasLayer { get; set; }
|
||||
|
||||
public OptionsData OptionsData;
|
||||
|
||||
@@ -48,11 +54,65 @@ public partial class OptionsMenu : Control
|
||||
|
||||
ResolutionOptions.ItemSelected += ResolutionOptions_ItemSelected;
|
||||
|
||||
SaveAndExitButton.ButtonUp += SaveAndExitButton_ButtonUp;
|
||||
TabContainer.TabChanged += TabContainer_TabChanged;
|
||||
|
||||
_masterBusIndex = AudioServer.GetBusIndex("Master");
|
||||
_musicBusIndex = AudioServer.GetBusIndex("MUSIC");
|
||||
_sfxBusIndex = AudioServer.GetBusIndex("SFX");
|
||||
|
||||
VisibilityChanged += OptionsMenu_VisibilityChanged;
|
||||
|
||||
InputHelper.JoypadInputChanged += (string action, InputEvent input) =>
|
||||
{
|
||||
if (GameInputs.Interact == action)
|
||||
{
|
||||
var interactInputs = InputHelper.GetLabelForInput(InputHelper.GetJoypadInputForAction(GameInputs.Interact));
|
||||
PressToGoBackLabel.Text = $"Press {interactInputs} to save and exit.";
|
||||
}
|
||||
};
|
||||
|
||||
InputHelper.KeyboardInputChanged += (string action, InputEvent input) =>
|
||||
{
|
||||
if (GameInputs.Interact == action)
|
||||
{
|
||||
var interactInputs = InputHelper.GetLabelForInput(InputHelper.GetKeyboardInputForAction(GameInputs.Interact));
|
||||
PressToGoBackLabel.Text = $"Press {interactInputs} to save and exit.";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void TabContainer_TabChanged(long tab)
|
||||
{
|
||||
if (tab == 0)
|
||||
MasterVolumeSlider.GrabFocus();
|
||||
if (tab == 1)
|
||||
Controller.MoveForwardKeyboard.GrabFocus();
|
||||
}
|
||||
|
||||
private void OptionsMenu_VisibilityChanged() => CanvasLayer.Visible = !CanvasLayer.Visible;
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
var interactInputs = InputHelper.GetKeyboardOrJoypadInputsForAction(GameInputs.Interact);
|
||||
if (interactInputs.Any(x => x.IsMatch(@event)))
|
||||
{
|
||||
AcceptEvent();
|
||||
SaveAndExitMenu();
|
||||
}
|
||||
|
||||
var leftTab = InputHelper.GetKeyboardOrJoypadInputsForAction(GameInputs.StrafeLeft);
|
||||
if (leftTab.Any(x => x.IsMatch(@event)))
|
||||
{
|
||||
AcceptEvent();
|
||||
TabContainer.CurrentTab = Mathf.Max(0, TabContainer.CurrentTab - 1);
|
||||
}
|
||||
|
||||
var rightTab = InputHelper.GetKeyboardOrJoypadInputsForAction(GameInputs.StrafeRight);
|
||||
if (rightTab.Any(x => x.IsMatch(@event)))
|
||||
{
|
||||
AcceptEvent();
|
||||
TabContainer.CurrentTab = Mathf.Min(TabContainer.GetTabCount() - 1, TabContainer.CurrentTab + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResolutionOptions_ItemSelected(long index)
|
||||
@@ -71,7 +131,7 @@ public partial class OptionsMenu : Control
|
||||
DisplayServer.WindowSetMode(_windowModes[optionsData.ScreenResolution]);
|
||||
}
|
||||
|
||||
private void SaveAndExitButton_ButtonUp() => EmitSignal(SignalName.OptionsMenuExited);
|
||||
private void SaveAndExitMenu() => EmitSignal(SignalName.OptionsMenuExited);
|
||||
|
||||
private void MasterVolumeSlider_Changed(double valueChanged)
|
||||
{
|
||||
@@ -90,20 +150,4 @@ public partial class OptionsMenu : Control
|
||||
OptionsData.SFXVolumeLevel = valueChanged;
|
||||
AudioServer.SetBusVolumeDb(_sfxBusIndex, Mathf.LinearToDb((float)valueChanged));
|
||||
}
|
||||
}
|
||||
|
||||
[Meta, Id("options_data")]
|
||||
public partial class OptionsData : Node
|
||||
{
|
||||
[Save("MasterVolume")]
|
||||
public required double MasterVolumeLevel { get; set; }
|
||||
|
||||
[Save("MusicVolume")]
|
||||
public required double MusicVolumeLevel { get; set; }
|
||||
|
||||
[Save("SFXVolume")]
|
||||
public required double SFXVolumeLevel { get; set; }
|
||||
|
||||
[Save("ScreenResolution")]
|
||||
public required int ScreenResolution { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://drkl3btdy6uxj"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://drkl3btdy6uxj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cjxmdvhixcj6e" path="res://src/options/OptionsMenu.cs" id="1_jli36"]
|
||||
[ext_resource type="Shortcut" uid="uid://dumkrjur22k2a" path="res://src/ui/ButtonShortcut.tres" id="2_1egkf"]
|
||||
[ext_resource type="PackedScene" uid="uid://dk5esf6mm6kte" path="res://src/options/InputMapper.tscn" id="2_utd4g"]
|
||||
|
||||
[sub_resource type="StyleBoxLine" id="StyleBoxLine_jli36"]
|
||||
|
||||
@@ -18,43 +20,50 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_jli36")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.137255, 0.121569, 0.12549, 1)
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
[node name="CenterContainer" type="AspectRatioContainer" parent="CanvasLayer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/CenterContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="CanvasLayer/CenterContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(1280, 960)
|
||||
layout_mode = 2
|
||||
current_tab = 0
|
||||
|
||||
[node name="Audio" type="MarginContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 100
|
||||
theme_override_constants/margin_top = 100
|
||||
theme_override_constants/margin_right = 100
|
||||
theme_override_constants/margin_bottom = 100
|
||||
metadata/_tab_index = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
mouse_filter = 0
|
||||
|
||||
[node name="MasterVolume" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
[node name="MasterVolume" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VolumeLabel" type="Label" parent="MarginContainer/VBoxContainer/MasterVolume"]
|
||||
[node name="VolumeLabel" type="Label" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer/MasterVolume"]
|
||||
custom_minimum_size = Vector2(125, 0)
|
||||
layout_mode = 2
|
||||
text = "Master Volume"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="MasterVolumeSlider" type="HSlider" parent="MarginContainer/VBoxContainer/MasterVolume"]
|
||||
[node name="MasterVolumeSlider" type="HSlider" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer/MasterVolume"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(300, 0)
|
||||
layout_mode = 2
|
||||
@@ -66,16 +75,16 @@ max_value = 1.0
|
||||
step = 0.001
|
||||
value = 1.0
|
||||
|
||||
[node name="MusicVolume" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
[node name="MusicVolume" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VolumeLabel" type="Label" parent="MarginContainer/VBoxContainer/MusicVolume"]
|
||||
[node name="VolumeLabel" type="Label" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer/MusicVolume"]
|
||||
custom_minimum_size = Vector2(125, 0)
|
||||
layout_mode = 2
|
||||
text = "Music Volume"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="MusicVolumeSlider" type="HSlider" parent="MarginContainer/VBoxContainer/MusicVolume"]
|
||||
[node name="MusicVolumeSlider" type="HSlider" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer/MusicVolume"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(300, 0)
|
||||
layout_mode = 2
|
||||
@@ -87,16 +96,16 @@ max_value = 1.0
|
||||
step = 0.001
|
||||
value = 1.0
|
||||
|
||||
[node name="SFXVolume" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
[node name="SFXVolume" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VolumeLabel" type="Label" parent="MarginContainer/VBoxContainer/SFXVolume"]
|
||||
[node name="VolumeLabel" type="Label" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer/SFXVolume"]
|
||||
custom_minimum_size = Vector2(125, 0)
|
||||
layout_mode = 2
|
||||
text = "SFX Volume"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="SFXVolumeSlider" type="HSlider" parent="MarginContainer/VBoxContainer/SFXVolume"]
|
||||
[node name="SFXVolumeSlider" type="HSlider" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer/SFXVolume"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(300, 0)
|
||||
layout_mode = 2
|
||||
@@ -108,27 +117,33 @@ max_value = 1.0
|
||||
step = 0.001
|
||||
value = 1.0
|
||||
|
||||
[node name="Resolution" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
[node name="Resolution" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ResolutionLabel" type="Label" parent="MarginContainer/VBoxContainer/Resolution"]
|
||||
[node name="ResolutionLabel" type="Label" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer/Resolution"]
|
||||
custom_minimum_size = Vector2(125, 0)
|
||||
layout_mode = 2
|
||||
text = "Resolution: "
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="ResolutionOptions" type="OptionButton" parent="MarginContainer/VBoxContainer/Resolution"]
|
||||
[node name="ResolutionOptions" type="OptionButton" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer/Resolution"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
layout_mode = 2
|
||||
shortcut = ExtResource("2_1egkf")
|
||||
flat = true
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer/Audio/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
|
||||
[node name="SaveAndExitButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
[node name="Controller" parent="CanvasLayer/CenterContainer/VBoxContainer/TabContainer" instance=ExtResource("2_utd4g")]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(150, 75)
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "Save and Exit"
|
||||
metadata/_tab_index = 1
|
||||
|
||||
[node name="PressToGoBackLabel" type="Label" parent="CanvasLayer/CenterContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Press "
|
||||
|
||||
3
Zennysoft.Game.Ma/src/ui/ButtonShortcut.tres
Normal file
3
Zennysoft.Game.Ma/src/ui/ButtonShortcut.tres
Normal file
@@ -0,0 +1,3 @@
|
||||
[gd_resource type="Shortcut" format=3 uid="uid://dumkrjur22k2a"]
|
||||
|
||||
[resource]
|
||||
@@ -5,8 +5,8 @@ using Godot.Collections;
|
||||
namespace Zennysoft.Game.Ma;
|
||||
public partial class DialogueBalloon : CanvasLayer
|
||||
{
|
||||
[Export] public string NextAction = "ui_accept";
|
||||
[Export] public string SkipAction = "ui_cancel";
|
||||
[Export] public string NextAction = GameInputs.Interact;
|
||||
[Export] public string SkipAction = GameInputs.Attack;
|
||||
|
||||
|
||||
Control balloon;
|
||||
|
||||
@@ -60,7 +60,7 @@ public partial class InGameUI : Control, IInGameUI
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (@event.IsActionPressed(GameInputs.Inventory))
|
||||
if (@event.IsActionPressed(GameInputs.Inventory) && !InventoryMenu.Visible)
|
||||
{
|
||||
GD.Print("Inventory button pressed");
|
||||
InGameUILogic.Input(new InGameUILogic.Input.ShowInventory());
|
||||
|
||||
@@ -124,7 +124,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (Visible && @event.IsActionPressed(GameInputs.UiCancel))
|
||||
if (Visible && @event.IsActionPressed(GameInputs.Inventory))
|
||||
{
|
||||
if (UseButton.HasFocus() || DropButton.HasFocus() || ThrowButton.HasFocus())
|
||||
{
|
||||
@@ -134,6 +134,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
}
|
||||
else
|
||||
{
|
||||
AcceptEvent();
|
||||
Autoload.AudioManager.Play(SoundEffect.Cancel);
|
||||
_gameRepo.CloseInventory();
|
||||
}
|
||||
@@ -142,17 +143,17 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
if (ItemSlots.Length == 0 || UseButton.HasFocus() || DropButton.HasFocus() || ThrowButton.HasFocus())
|
||||
return;
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.UiRight) && _currentPageNumber == InventoryPageNumber.FirstPage)
|
||||
if (@event.IsActionPressed(GameInputs.MoveRight) && _currentPageNumber == InventoryPageNumber.FirstPage)
|
||||
{
|
||||
var inventory = Player.Inventory;
|
||||
if (inventory.Items.Count > _itemsPerPage)
|
||||
ChangeInventoryPage(InventoryPageNumber.SecondPage);
|
||||
}
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.UiLeft) && _currentPageNumber == InventoryPageNumber.SecondPage)
|
||||
if (@event.IsActionPressed(GameInputs.MoveLeft) && _currentPageNumber == InventoryPageNumber.SecondPage)
|
||||
ChangeInventoryPage(InventoryPageNumber.FirstPage);
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.UiDown))
|
||||
if (@event.IsActionPressed(GameInputs.MoveDown))
|
||||
{
|
||||
var oldIndex = _currentIndex;
|
||||
var newIndex = new[] { _currentIndex + 1, _itemsPerPage - 1, ItemSlots.Length - 1 }.Min();
|
||||
@@ -165,7 +166,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
_currentIndex = newIndex;
|
||||
}
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.UiUp))
|
||||
if (@event.IsActionPressed(GameInputs.MoveUp))
|
||||
{
|
||||
var oldIndex = _currentIndex;
|
||||
var newIndex = new[] { _currentIndex - 1, 0 }.Max();
|
||||
@@ -179,7 +180,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
_currentIndex = newIndex;
|
||||
}
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.UiAccept))
|
||||
if (@event.IsActionPressed(GameInputs.Attack))
|
||||
{
|
||||
DisplayUserActionPrompt();
|
||||
Autoload.AudioManager.Play(SoundEffect.Select);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=29 format=3 uid="uid://dlj8qdg1c5048"]
|
||||
[gd_scene load_steps=30 format=3 uid="uid://dlj8qdg1c5048"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cmtet15hi5oiy" path="res://src/ui/inventory_menu/InventoryMenu.cs" id="1_l64wl"]
|
||||
[ext_resource type="Shader" uid="uid://cnphwvmr05hp1" path="res://src/ui/inventory_menu/InventoryMenu.gdshader" id="2_0fvsh"]
|
||||
@@ -8,6 +8,7 @@
|
||||
[ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="6_tmdno"]
|
||||
[ext_resource type="LabelSettings" uid="uid://cuuo43x72xcsc" path="res://src/ui/label_settings/MainTextBold.tres" id="7_vyrxm"]
|
||||
[ext_resource type="Theme" uid="uid://daxuhpmyxwxck" path="res://src/ui/inventory_menu/InventoryDialogueSelectionStyle.tres" id="8_khyvo"]
|
||||
[ext_resource type="Shortcut" uid="uid://dumkrjur22k2a" path="res://src/ui/ButtonShortcut.tres" id="9_b6rkr"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_i55tv"]
|
||||
shader = ExtResource("2_0fvsh")
|
||||
@@ -381,6 +382,7 @@ theme_override_styles/disabled = SubResource("StyleBoxEmpty_fu7o2")
|
||||
theme_override_styles/pressed = SubResource("StyleBoxEmpty_nkvce")
|
||||
theme_override_styles/normal = SubResource("StyleBoxEmpty_545ij")
|
||||
button_mask = 0
|
||||
shortcut = ExtResource("9_b6rkr")
|
||||
text = "Use"
|
||||
alignment = 0
|
||||
|
||||
@@ -405,6 +407,7 @@ theme_override_styles/disabled = SubResource("StyleBoxEmpty_ascpt")
|
||||
theme_override_styles/pressed = SubResource("StyleBoxEmpty_abpb1")
|
||||
theme_override_styles/normal = SubResource("StyleBoxEmpty_545ij")
|
||||
button_mask = 0
|
||||
shortcut = ExtResource("9_b6rkr")
|
||||
text = "Throw"
|
||||
alignment = 0
|
||||
|
||||
@@ -429,6 +432,7 @@ theme_override_styles/disabled = SubResource("StyleBoxEmpty_uerb4")
|
||||
theme_override_styles/pressed = SubResource("StyleBoxEmpty_lvcf8")
|
||||
theme_override_styles/normal = SubResource("StyleBoxEmpty_ct6ql")
|
||||
button_mask = 0
|
||||
shortcut = ExtResource("9_b6rkr")
|
||||
text = "Drop"
|
||||
alignment = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user