mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-08 13:15:55 +00:00
Input remapping
This commit is contained in:
parent
1a1a191923
commit
82edd196b0
5 changed files with 104 additions and 10 deletions
|
|
@ -11,7 +11,9 @@
|
|||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADisposablesTracker_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FDecompilerCache_003Fdecompiler_003F4fd22cd129a84c16b5d8004b467c426f518800_003Fb8_003Fee061233_003FDisposablesTracker_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEnemy_005FScriptProperties_002Egenerated_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Fd6739058209280d46591ab296d6b49dfcf7ecd2_003FEnemy_005FScriptProperties_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGameManager_005FScriptMethods_002Egenerated_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F642294f86639b2f8d4cb4d14e791d697e55369_003FGameManager_005FScriptMethods_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInputEvent_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F10e1ba49df151bbaf6853f9834601cecebdeade8465a9adb366b4a7b7c9524b0_003FInputEvent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInput_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F3e43a674e8a96aa8b4abdf97a31f18732060401d8285a17ee7109827a69cd18b_003FInput_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANativeCalls_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F4178b6f96a2e273c05bd023e0a7f4ff5c747b218af487b1ac979f58bafb30d_003FNativeCalls_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode2D_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe37dc1faf08a4d5ea030ad59bdf77522523400_003F49_003F8f2ede17_003FNode2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Fbb1b701f3c7411227a9d2e09f965d857ff3e771557650c4f513e427d77c_003FNode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Ff1d69ec2da76ccf9bc8a75c8e0fdca9a7ba1adf8c8c9d5047e2fa5991c02eca_003FNode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="Theme" load_steps=12 format=3 uid="uid://dnsadvmunm76k"]
|
||||
[gd_resource type="Theme" load_steps=21 format=3 uid="uid://dnsadvmunm76k"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://coek1e2q257pq" path="res://fonts/at01.ttf" id="1_dp7be"]
|
||||
[ext_resource type="StyleBox" uid="uid://ctw2hju32l3rg" path="res://Resources/Styles/PixelStyleBoxRed.tres" id="2_wf67a"]
|
||||
|
|
@ -6,8 +6,13 @@
|
|||
[ext_resource type="StyleBox" uid="uid://6ydsirgc5xi5" path="res://Resources/Styles/HealthBarFill.tres" id="4_j5bu4"]
|
||||
[ext_resource type="Texture2D" uid="uid://d2m6srimy07bq" path="res://Sprites/UI/SliderSelector.png" id="4_joeh7"]
|
||||
[ext_resource type="StyleBox" uid="uid://24hh6h4juk3r" path="res://Resources/Styles/PixelStyleBoxRed_SquareBackground.tres" id="4_jpso0"]
|
||||
[ext_resource type="StyleBox" uid="uid://cpa8himkyhn61" path="res://Resources/Styles/HorizontalGrabberBox.tres" id="4_uwwh5"]
|
||||
[ext_resource type="Texture2D" uid="uid://d4wo6kxffwo5" path="res://Sprites/UI/ScrollGrabberHorizontal.png" id="5_ercuu"]
|
||||
[ext_resource type="StyleBox" uid="uid://dnb4ogn847dyp" path="res://Resources/Styles/HealthBarBackground.tres" id="5_ogh8g"]
|
||||
[ext_resource type="Texture2D" uid="uid://c4bj6flx8lp68" path="res://Sprites/UI/SliderSelector_Focused.png" id="5_xp2bu"]
|
||||
[ext_resource type="StyleBox" uid="uid://dj8x7ss2wee7k" path="res://Resources/Styles/VerticalGrabberBox.tres" id="9_0lulh"]
|
||||
[ext_resource type="Texture2D" uid="uid://d22shrdi1kf7" path="res://Sprites/UI/ScrollGrabber.png" id="10_uwwh5"]
|
||||
[ext_resource type="StyleBox" uid="uid://5ceac1vp2b47" path="res://Resources/Styles/VerticalScrollStyleBox.tres" id="10_yplb8"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jpso0"]
|
||||
atlas = ExtResource("3_xfr2l")
|
||||
|
|
@ -21,6 +26,42 @@ region = Rect2(0, 0, 8, 8)
|
|||
atlas = ExtResource("3_xfr2l")
|
||||
region = Rect2(16, 0, 8, 8)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_t5cti"]
|
||||
texture = ExtResource("5_ercuu")
|
||||
texture_margin_left = 3.0
|
||||
texture_margin_top = 3.0
|
||||
texture_margin_right = 3.0
|
||||
texture_margin_bottom = 3.0
|
||||
axis_stretch_horizontal = 2
|
||||
modulate_color = Color(0.706778, 0.706778, 0.706778, 1)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_d1bcy"]
|
||||
texture = ExtResource("5_ercuu")
|
||||
texture_margin_left = 3.0
|
||||
texture_margin_top = 3.0
|
||||
texture_margin_right = 3.0
|
||||
texture_margin_bottom = 3.0
|
||||
axis_stretch_horizontal = 2
|
||||
modulate_color = Color(0.603538, 0.603537, 0.603537, 1)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_ercuu"]
|
||||
texture = ExtResource("10_uwwh5")
|
||||
texture_margin_left = 3.0
|
||||
texture_margin_top = 3.0
|
||||
texture_margin_right = 3.0
|
||||
texture_margin_bottom = 3.0
|
||||
axis_stretch_vertical = 2
|
||||
modulate_color = Color(0.713915, 0.713915, 0.713915, 1)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_e1y5d"]
|
||||
texture = ExtResource("10_uwwh5")
|
||||
texture_margin_left = 3.0
|
||||
texture_margin_top = 3.0
|
||||
texture_margin_right = 3.0
|
||||
texture_margin_bottom = 3.0
|
||||
axis_stretch_vertical = 2
|
||||
modulate_color = Color(0.692541, 0.692541, 0.692541, 1)
|
||||
|
||||
[resource]
|
||||
default_font = ExtResource("1_dp7be")
|
||||
default_font_size = 16
|
||||
|
|
@ -51,6 +92,17 @@ Button/styles/pressed = ExtResource("2_wf67a")
|
|||
CheckBox/icons/checked = SubResource("AtlasTexture_jpso0")
|
||||
CheckBox/icons/unchecked = SubResource("AtlasTexture_0p6en")
|
||||
CheckBox/icons/unchecked_disabled = SubResource("AtlasTexture_xfr2l")
|
||||
HScrollBar/icons/decrement = null
|
||||
HScrollBar/icons/decrement_highlight = null
|
||||
HScrollBar/icons/decrement_pressed = null
|
||||
HScrollBar/icons/increment = null
|
||||
HScrollBar/icons/increment_highlight = null
|
||||
HScrollBar/icons/increment_pressed = null
|
||||
HScrollBar/styles/grabber = ExtResource("4_uwwh5")
|
||||
HScrollBar/styles/grabber_highlight = SubResource("StyleBoxTexture_t5cti")
|
||||
HScrollBar/styles/grabber_pressed = SubResource("StyleBoxTexture_d1bcy")
|
||||
HScrollBar/styles/scroll = ExtResource("5_ogh8g")
|
||||
HScrollBar/styles/scroll_focus = ExtResource("5_ogh8g")
|
||||
HSlider/icons/grabber = ExtResource("4_joeh7")
|
||||
HSlider/icons/grabber_disabled = null
|
||||
HSlider/icons/grabber_highlight = ExtResource("5_xp2bu")
|
||||
|
|
@ -71,6 +123,23 @@ TabContainer/styles/tab_hovered = ExtResource("4_jpso0")
|
|||
TabContainer/styles/tab_selected = ExtResource("4_jpso0")
|
||||
TabContainer/styles/tab_unselected = ExtResource("4_jpso0")
|
||||
TabContainer/styles/tabbar_background = null
|
||||
VScrollBar/icons/decrement = null
|
||||
VScrollBar/icons/decrement_highlight = null
|
||||
VScrollBar/icons/decrement_pressed = null
|
||||
VScrollBar/icons/increment = null
|
||||
VScrollBar/icons/increment_highlight = null
|
||||
VScrollBar/icons/increment_pressed = null
|
||||
VScrollBar/styles/grabber = ExtResource("9_0lulh")
|
||||
VScrollBar/styles/grabber_highlight = SubResource("StyleBoxTexture_ercuu")
|
||||
VScrollBar/styles/grabber_pressed = SubResource("StyleBoxTexture_e1y5d")
|
||||
VScrollBar/styles/scroll = ExtResource("10_yplb8")
|
||||
VScrollBar/styles/scroll_focus = ExtResource("10_yplb8")
|
||||
VSlider/constants/center_grabber = 0
|
||||
VSlider/constants/grabber_offset = 0
|
||||
VSlider/icons/grabber = null
|
||||
VSlider/icons/grabber_disabled = null
|
||||
VSlider/icons/grabber_highlight = null
|
||||
VSlider/icons/tick = null
|
||||
VSlider/styles/grabber_area = null
|
||||
VSlider/styles/grabber_area_highlight = null
|
||||
VSlider/styles/slider = null
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_il8fq")
|
||||
script = ExtResource("1_mpohc")
|
||||
ResolutionsList = NodePath("ScrollContainer/VBoxContainer/GeneralSettings/HFlowContainer/Resolution/ResolutionsList")
|
||||
VSyncToggle = NodePath("ScrollContainer/VBoxContainer/GeneralSettings/HFlowContainer/VsyncCheckbox")
|
||||
|
|
|
|||
|
|
@ -16,12 +16,11 @@ label_settings = ExtResource("2_b0qgl")
|
|||
|
||||
[node name="Key" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
text = "A"
|
||||
label_settings = ExtResource("2_b0qgl")
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("3_b0qgl")
|
||||
text = "Remap"
|
||||
text = "Add"
|
||||
|
||||
[connection signal="pressed" from="Button" to="." method="StartRemap"]
|
||||
|
|
|
|||
|
|
@ -12,18 +12,40 @@ public partial class KeyRemappingItem : HBoxContainer
|
|||
[Export] public Label InputLabel { get; private set; }
|
||||
|
||||
private bool _active = false;
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
NameLabel.Text = KeyName;
|
||||
var actions = InputMap.GetActions();
|
||||
|
||||
|
||||
var action = actions.FirstOrDefault(x => x == KeyId);
|
||||
var events = InputMap.ActionGetEvents(action);
|
||||
|
||||
InputLabel.Text = string.Join(",", events.Select(x => x.AsText()));
|
||||
|
||||
foreach (var e in events)
|
||||
{
|
||||
var button = new Button();
|
||||
|
||||
button.Text = e switch
|
||||
{
|
||||
InputEventKey key => key.PhysicalKeycode.ToString(),
|
||||
InputEventJoypadButton jButton => $"Joypad {jButton.ButtonIndex}",
|
||||
InputEventMouseButton mouseButton => $"Mouse {mouseButton.ButtonIndex}",
|
||||
_ => e.AsText()
|
||||
};
|
||||
button.Pressed += () => { BeginRemap(button, action, e); };
|
||||
this.AddChild(button);
|
||||
}
|
||||
|
||||
|
||||
//InputLabel.Text = string.Join(",", events.Select(x => x.AsText()));
|
||||
}
|
||||
|
||||
|
||||
private void BeginRemap(Button button, StringName action, InputEvent e)
|
||||
{
|
||||
button.Text = "Remapping...";
|
||||
_active = true;
|
||||
}
|
||||
|
||||
public void StartRemap()
|
||||
{
|
||||
_active = true;
|
||||
|
|
@ -32,11 +54,12 @@ public partial class KeyRemappingItem : HBoxContainer
|
|||
public override void _Input(InputEvent e)
|
||||
{
|
||||
if (!_active) return;
|
||||
|
||||
|
||||
if (e is InputEventKey keyEvent && keyEvent.Pressed)
|
||||
{
|
||||
GD.Print(keyEvent.Keycode);
|
||||
InputLabel.Text = keyEvent.Keycode.ToString();
|
||||
//InputLabel.Text = keyEvent.Keycode.ToString();
|
||||
|
||||
_active = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue