From 7db764c4593704bf48e429e572d6042a81709faf Mon Sep 17 00:00:00 2001 From: vaporvee Date: Sun, 27 Nov 2022 18:57:12 +0100 Subject: [PATCH] cleaned main code --- src/main.cs | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/src/main.cs b/src/main.cs index 3484858..ef281ab 100644 --- a/src/main.cs +++ b/src/main.cs @@ -15,49 +15,33 @@ public partial class main : Node2D //Checks if using Keyboard or controller and giving out current controller //this is a terrible way of doing this and will be reworked if (Input.IsMouseButtonPressed(MouseButton.Left) || currentController == "" || currentController == null) - { currentController = "PC"; - } if (Input.IsJoyButtonPressed(0, JoyButton.A) || Input.IsJoyButtonPressed(0, JoyButton.B)) - { currentController = Input.GetJoyName(0); - } //CHANGE INPUT FOR NINTENDO CONTROLLER if (currentController.StartsWith("Nintendo")) { - InputMap.ActionAddEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.B}); InputMap.ActionEraseEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.A }); - InputMap.ActionAddEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.A }); InputMap.ActionEraseEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.B }); - } - else + InputMap.ActionAddEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.B }); + InputMap.ActionAddEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.A }); + } else { - InputMap.ActionAddEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.A }); InputMap.ActionEraseEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.B }); - InputMap.ActionAddEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.B }); InputMap.ActionEraseEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.A }); + InputMap.ActionAddEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.A }); + InputMap.ActionAddEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.B }); } - if (Input.IsActionJustPressed("ui_accept")) - { - GD.Print(currentController + " accept"); - } - if (Input.IsActionJustPressed("ui_cancel")) - { - GD.Print(currentController + " cancel"); - } + + if (Input.IsActionJustPressed("ui_accept")) GD.Print(currentController + " accept"); + if (Input.IsActionJustPressed("ui_cancel")) GD.Print(currentController + " cancel"); //FULLSCREEN HOTKEY if (Input.IsActionJustPressed("hotkey_fullscreen")) { - if (DisplayServer.WindowGetMode() == DisplayServer.WindowMode.Fullscreen) - { - DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed); - } - else - { - DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen); - } + if (DisplayServer.WindowGetMode() == DisplayServer.WindowMode.Fullscreen) DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed); + else DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen); } } }