cleaned main code
This commit is contained in:
36
src/main.cs
36
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user