feat: vorläufig funktionierendes Controlls menu

This commit is contained in:
Jakob Feldmann 2023-05-29 19:41:37 +02:00
parent ec5c67930c
commit 25845bfc99
23 changed files with 295 additions and 228 deletions

3
.gitignore vendored
View File

@ -30,3 +30,6 @@ data_*/
/.vscode/launch.json /.vscode/launch.json
*/.vscode/* */.vscode/*
*/.vscode/launch.json */.vscode/launch.json
# File specific ignores
savefile.tres

View File

@ -14,6 +14,36 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://src/Actors/Actor.gd" "path": "res://src/Actors/Actor.gd"
}, { }, {
"base": "Button",
"class": "ControllerButton",
"language": "GDScript",
"path": "res://addons/controller_icons/objects/Button.gd"
}, {
"base": "Node",
"class": "ControllerMapper",
"language": "GDScript",
"path": "res://addons/controller_icons/Mapper.gd"
}, {
"base": "Resource",
"class": "ControllerSettings",
"language": "GDScript",
"path": "res://addons/controller_icons/Settings.gd"
}, {
"base": "Sprite",
"class": "ControllerSprite",
"language": "GDScript",
"path": "res://addons/controller_icons/objects/Sprite.gd"
}, {
"base": "Sprite3D",
"class": "ControllerSprite3D",
"language": "GDScript",
"path": "res://addons/controller_icons/objects/Sprite3D.gd"
}, {
"base": "TextureRect",
"class": "ControllerTextureRect",
"language": "GDScript",
"path": "res://addons/controller_icons/objects/TextureRect.gd"
}, {
"base": "Actor", "base": "Actor",
"class": "Enemy", "class": "Enemy",
"language": "GDScript", "language": "GDScript",
@ -46,6 +76,12 @@ _global_script_classes=[ {
} ] } ]
_global_script_class_icons={ _global_script_class_icons={
"Actor": "", "Actor": "",
"ControllerButton": "",
"ControllerMapper": "",
"ControllerSettings": "",
"ControllerSprite": "",
"ControllerSprite3D": "",
"ControllerTextureRect": "",
"Enemy": "", "Enemy": "",
"GlobalStateResource": "", "GlobalStateResource": "",
"LevelTemplate": "", "LevelTemplate": "",
@ -64,6 +100,7 @@ config/icon="res://icon.png"
GlobalState="*res://src/Autoload/GlobalState.tscn" GlobalState="*res://src/Autoload/GlobalState.tscn"
SaveManager="*res://src/Autoload/SaveManager.gd" SaveManager="*res://src/Autoload/SaveManager.gd"
ControllerIcons="*res://addons/controller_icons/ControllerIcons.gd"
[debug] [debug]
@ -80,7 +117,7 @@ window/stretch/aspect="expand"
[editor_plugins] [editor_plugins]
enabled=PoolStringArray( "res://addons/AsepriteWizard/plugin.cfg" ) enabled=PoolStringArray( "res://addons/AsepriteWizard/plugin.cfg", "res://addons/controller_icons/plugin.cfg" )
[global] [global]
@ -122,24 +159,49 @@ ogg_vorbis={
ui_accept={ ui_accept={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
ui_select={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_focus_next={
"deadzone": 0.5,
"events": [ ]
}
ui_focus_prev={
"deadzone": 0.5,
"events": [ ]
}
ui_page_up={
"deadzone": 0.5,
"events": [ ]
}
ui_page_down={
"deadzone": 0.5,
"events": [ ]
}
ui_home={
"deadzone": 0.5,
"events": [ ]
}
ui_end={
"deadzone": 0.5,
"events": [ ]
}
move_left={ move_left={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777231,"unicode":0,"echo":false,"script":null)
] ]
} }
move_right={ move_right={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":15,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777233,"unicode":0,"echo":false,"script":null)
] ]
} }
jump={ jump={
@ -164,9 +226,7 @@ boost_move={
duck={ duck={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) "events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":83,"unicode":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":83,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777234,"unicode":0,"echo":false,"script":null)
] ]
} }
click={ click={
@ -177,15 +237,12 @@ click={
interact={ interact={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":69,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":69,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777221,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
up={ up={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":87,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":87,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777232,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
] ]
} }

View File

@ -1,4 +1,4 @@
[gd_resource type="Resource" load_steps=50 format=2] [gd_resource type="Resource" load_steps=35 format=2]
[ext_resource path="res://src/Utilities/GlobalStateResource.gd" type="Script" id=1] [ext_resource path="res://src/Utilities/GlobalStateResource.gd" type="Script" id=1]
@ -11,142 +11,96 @@ button_index = 1
[sub_resource type="InputEventMouseButton" id=3] [sub_resource type="InputEventMouseButton" id=3]
button_index = 1 button_index = 1
[sub_resource type="InputEventKey" id=5]
physical_scancode = 83
[sub_resource type="InputEventJoypadButton" id=4] [sub_resource type="InputEventJoypadButton" id=4]
button_index = 13 button_index = 13
[sub_resource type="InputEventJoypadMotion" id=5]
axis = 1
axis_value = 1.0
[sub_resource type="InputEventKey" id=6] [sub_resource type="InputEventKey" id=6]
physical_scancode = 83
[sub_resource type="InputEventKey" id=7]
physical_scancode = 16777234
[sub_resource type="InputEventKey" id=8]
physical_scancode = 69 physical_scancode = 69
[sub_resource type="InputEventKey" id=9] [sub_resource type="InputEventJoypadButton" id=7]
physical_scancode = 16777221
[sub_resource type="InputEventJoypadButton" id=10]
button_index = 2 button_index = 2
[sub_resource type="InputEventKey" id=11] [sub_resource type="InputEventKey" id=8]
scancode = 32 scancode = 32
[sub_resource type="InputEventJoypadButton" id=12] [sub_resource type="InputEventKey" id=10]
[sub_resource type="InputEventKey" id=13]
physical_scancode = 16777232 physical_scancode = 16777232
[sub_resource type="InputEventJoypadMotion" id=14]
axis_value = -1.0
[sub_resource type="InputEventKey" id=15]
scancode = 65
[sub_resource type="InputEventJoypadButton" id=16]
device = -1
button_index = 14
[sub_resource type="InputEventKey" id=17]
physical_scancode = 16777231
[sub_resource type="InputEventKey" id=18]
scancode = 68
[sub_resource type="InputEventJoypadMotion" id=19]
axis_value = 1.0
[sub_resource type="InputEventJoypadButton" id=20]
device = -1
button_index = 15
[sub_resource type="InputEventKey" id=21]
physical_scancode = 16777233
[sub_resource type="InputEventKey" id=22]
scancode = 16777217
[sub_resource type="InputEventJoypadButton" id=23]
button_index = 11
[sub_resource type="InputEventKey" id=24]
scancode = 16777221
[sub_resource type="InputEventKey" id=25]
scancode = 32
[sub_resource type="InputEventJoypadButton" id=26]
[sub_resource type="InputEventKey" id=27]
scancode = 16777217
[sub_resource type="InputEventJoypadButton" id=28]
button_index = 1
[sub_resource type="InputEventKey" id=29]
scancode = 16777234
[sub_resource type="InputEventJoypadButton" id=30]
button_index = 13
[sub_resource type="InputEventKey" id=31]
scancode = 16777230
[sub_resource type="InputEventKey" id=32]
scancode = 16777218
[sub_resource type="InputEventKey" id=33] [sub_resource type="InputEventKey" id=33]
shift = true pressed = true
scancode = 16777218 scancode = 87
physical_scancode = 87
unicode = 119
[sub_resource type="InputEventKey" id=34] [sub_resource type="InputEventJoypadButton" id=9]
scancode = 16777229
[sub_resource type="InputEventKey" id=35] [sub_resource type="InputEventKey" id=11]
scancode = 16777231 scancode = 65
[sub_resource type="InputEventJoypadButton" id=36] [sub_resource type="InputEventJoypadButton" id=12]
device = -1
button_index = 14 button_index = 14
[sub_resource type="InputEventKey" id=37] [sub_resource type="InputEventKey" id=13]
scancode = 16777236 scancode = 68
[sub_resource type="InputEventKey" id=38] [sub_resource type="InputEventJoypadButton" id=14]
scancode = 16777235 device = -1
[sub_resource type="InputEventKey" id=39]
scancode = 16777233
[sub_resource type="InputEventJoypadButton" id=40]
button_index = 15 button_index = 15
[sub_resource type="InputEventKey" id=41] [sub_resource type="InputEventKey" id=15]
scancode = 32 scancode = 16777217
[sub_resource type="InputEventJoypadButton" id=42] [sub_resource type="InputEventJoypadButton" id=16]
button_index = 3 button_index = 11
[sub_resource type="InputEventKey" id=43] [sub_resource type="InputEventKey" id=17]
scancode = 16777221
[sub_resource type="InputEventJoypadButton" id=18]
[sub_resource type="InputEventKey" id=19]
scancode = 16777217
[sub_resource type="InputEventJoypadButton" id=20]
button_index = 1
[sub_resource type="InputEventKey" id=21]
scancode = 16777234
[sub_resource type="InputEventJoypadButton" id=22]
button_index = 13
[sub_resource type="InputEventKey" id=23]
scancode = 16777231
[sub_resource type="InputEventJoypadButton" id=24]
button_index = 14
[sub_resource type="InputEventKey" id=25]
scancode = 16777233
[sub_resource type="InputEventJoypadButton" id=26]
button_index = 15
[sub_resource type="InputEventKey" id=27]
scancode = 16777221
[sub_resource type="InputEventJoypadButton" id=28]
[sub_resource type="InputEventKey" id=29]
scancode = 16777232 scancode = 16777232
[sub_resource type="InputEventJoypadButton" id=44] [sub_resource type="InputEventJoypadButton" id=30]
button_index = 12 button_index = 12
[sub_resource type="InputEventKey" id=45] [sub_resource type="InputEventKey" id=31]
physical_scancode = 87 physical_scancode = 87
[sub_resource type="InputEventKey" id=46] [sub_resource type="InputEventJoypadButton" id=32]
physical_scancode = 16777232
[sub_resource type="InputEventJoypadMotion" id=47]
axis = 1
axis_value = -1.0
[sub_resource type="InputEventJoypadButton" id=48]
button_index = 12 button_index = 12
[resource] [resource]
@ -157,31 +111,44 @@ progress_dict = {
"deaths": 0, "deaths": 0,
"frees": 0, "frees": 0,
"kills": 0 "kills": 0
},
"Level 2": {
"currency": 0,
"deaths": 1,
"frees": 0,
"kills": 0,
"savepoint": Vector2( 1542, -222 )
},
"Level 3": {
"currency": 3,
"deaths": 0,
"frees": 0,
"kills": 0
} }
} }
wallet = 0 wallet = 3
input_map = { input_map = {
"boost_move": [ SubResource( 1 ), SubResource( 2 ) ], "boost_move": [ SubResource( 1 ), SubResource( 2 ) ],
"click": [ SubResource( 3 ) ], "click": [ SubResource( 3 ) ],
"duck": [ SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ], "duck": [ SubResource( 5 ), SubResource( 4 ) ],
"interact": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ], "interact": [ SubResource( 6 ), SubResource( 7 ) ],
"jump": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ], "jump": [ SubResource( 8 ), SubResource( 10 ), SubResource( 33 ), SubResource( 9 ) ],
"move_left": [ SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ) ], "move_left": [ SubResource( 11 ), SubResource( 12 ) ],
"move_right": [ SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ) ], "move_right": [ SubResource( 13 ), SubResource( 14 ) ],
"pause": [ SubResource( 22 ), SubResource( 23 ) ], "pause": [ SubResource( 15 ), SubResource( 16 ) ],
"ui_accept": [ SubResource( 24 ), SubResource( 25 ), SubResource( 26 ) ], "ui_accept": [ SubResource( 17 ), SubResource( 18 ) ],
"ui_cancel": [ SubResource( 27 ), SubResource( 28 ) ], "ui_cancel": [ SubResource( 19 ), SubResource( 20 ) ],
"ui_down": [ SubResource( 29 ), SubResource( 30 ) ], "ui_down": [ SubResource( 21 ), SubResource( 22 ) ],
"ui_end": [ SubResource( 31 ) ], "ui_end": [ ],
"ui_focus_next": [ SubResource( 32 ) ], "ui_focus_next": [ ],
"ui_focus_prev": [ SubResource( 33 ) ], "ui_focus_prev": [ ],
"ui_home": [ SubResource( 34 ) ], "ui_home": [ ],
"ui_left": [ SubResource( 35 ), SubResource( 36 ) ], "ui_left": [ SubResource( 23 ), SubResource( 24 ) ],
"ui_page_down": [ SubResource( 37 ) ], "ui_page_down": [ ],
"ui_page_up": [ SubResource( 38 ) ], "ui_page_up": [ ],
"ui_right": [ SubResource( 39 ), SubResource( 40 ) ], "ui_right": [ SubResource( 25 ), SubResource( 26 ) ],
"ui_select": [ SubResource( 41 ), SubResource( 42 ) ], "ui_select": [ SubResource( 27 ), SubResource( 28 ) ],
"ui_up": [ SubResource( 43 ), SubResource( 44 ) ], "ui_up": [ SubResource( 29 ), SubResource( 30 ) ],
"up": [ SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ) ] "up": [ SubResource( 31 ), SubResource( 32 ) ]
} }
show_tutorial = false show_tutorial = false

View File

@ -3,8 +3,8 @@ class_name Actor
#TODO Split the blobby specific parts up from this #TODO Split the blobby specific parts up from this
onready var levelState := get_tree().root.get_child(2).get_node("%LevelState") onready var levelState := get_tree().root.get_child(3).get_node("%LevelState")
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd") const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd")

View File

@ -3,8 +3,8 @@ extends Node2D
# Is given in blocks # Is given in blocks
export var movement_radius = 6 export var movement_radius = 6
onready var tilemap: TileMap = $"%TileMap" onready var tilemap: TileMap = $"%TileMap"
onready var levelState := get_tree().root.get_child(2).get_node("%LevelState") onready var levelState := get_tree().root.get_child(3).get_node("%LevelState")
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
var Rope = preload("res://src/Contraptions/Rope/Rope.tscn") var Rope = preload("res://src/Contraptions/Rope/Rope.tscn")
var RopeAnchor = preload("res://src/Contraptions/Rope/RopeAnchor.tscn") var RopeAnchor = preload("res://src/Contraptions/Rope/RopeAnchor.tscn")

View File

@ -1,7 +1,7 @@
extends Node extends Node
export var save_location: String = "res://savefile.tres" export var save_location: String = "res://savefile.tres"
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
func _ready() -> void: func _ready() -> void:
load_initial_save() load_initial_save()

View File

@ -1,6 +1,6 @@
extends Node2D extends Node2D
onready var levelState := get_tree().root.get_child(2).get_node("%LevelState") onready var levelState := get_tree().root.get_child(3).get_node("%LevelState")
func _ready() -> void: func _ready() -> void:
if(GlobalState.get_savepoint(levelState.levelName) == global_position + Vector2(0,18)): if(GlobalState.get_savepoint(levelState.levelName) == global_position + Vector2(0,18)):

View File

@ -1,7 +1,7 @@
extends StaticBody2D extends StaticBody2D
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
onready var levelState := get_tree().root.get_child(2).get_node("%LevelState") onready var levelState := get_tree().root.get_child(3).get_node("%LevelState")
export var locked := true export var locked := true

View File

@ -2,8 +2,8 @@ tool
extends Area2D extends Area2D
onready var anim_player: AnimationPlayer = $AnimationPlayer onready var anim_player: AnimationPlayer = $AnimationPlayer
onready var levelState := get_tree().root.get_child(2).get_node("%LevelState") onready var levelState := get_tree().root.get_child(3).get_node("%LevelState")
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
onready var levelName := get_tree().get_current_scene().get_name() onready var levelName := get_tree().get_current_scene().get_name()
export(String, FILE, "*.tscn") var next_scene export(String, FILE, "*.tscn") var next_scene

View File

@ -4,7 +4,7 @@ onready var buttonPlayer = $"%ButtonPlayer"
onready var activatorArea = $"%ActivatorArea" onready var activatorArea = $"%ActivatorArea"
onready var indicatorPlayer = $"%IndicatorPlayer" onready var indicatorPlayer = $"%IndicatorPlayer"
onready var elevator = get_node("./Portal") onready var elevator = get_node("./Portal")
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
onready var unactivatable_timer := $Timer onready var unactivatable_timer := $Timer
onready var get_back_timer := $GetBackTimer onready var get_back_timer := $GetBackTimer

View File

@ -1,8 +1,8 @@
extends Node2D extends Node2D
onready var activatorArea = $"%ActivatorArea" onready var activatorArea = $"%ActivatorArea"
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
onready var levelState := get_tree().root.get_child(2).get_node("%LevelState") onready var levelState := get_tree().root.get_child(3).get_node("%LevelState")
onready var blobby := $"../%Blobby" onready var blobby := $"../%Blobby"
onready var unactivatable_timer := $Timer onready var unactivatable_timer := $Timer
export var cost := 3 export var cost := 3

View File

@ -11,8 +11,8 @@ var states = {}
onready var parent = get_parent() onready var parent = get_parent()
# Scene Singletons # Scene Singletons
onready var levelState := get_tree().root.get_child(2).get_node("%LevelState") onready var levelState := get_tree().root.get_child(3).get_node("%LevelState")
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
# Basic process flow for every SM # Basic process flow for every SM

View File

@ -6,8 +6,8 @@ func clear():
for child in get_children(): for child in get_children():
child.free() child.free()
func add_input_line(action_name, key, is_customizable=false): func add_input_line(action_name, event):
var line = InputLine.instance() var line = InputLine.instance()
line.initialize(action_name, key, is_customizable)
add_child(line) add_child(line)
line.initialize(action_name, event)
return line return line

View File

@ -1,28 +1,31 @@
extends Control extends Control
onready var _action_list = $"%ActionKeyList" onready var _action_list = $"%ActionKeyList"
onready var changes_made := false
func _ready(): func _ready():
$InputMapper.connect('profile_changed', self, 'rebuild') $InputMapper.connect('profile_changed', self, 'rebuild')
$InputMapper.initialize_profiles()
$ProfilesMenu.initialize($InputMapper) $ProfilesMenu.initialize($InputMapper)
$InputMapper.change_profile($ProfilesMenu.selected) $InputMapper.change_profile($ProfilesMenu.selected)
func rebuild(input_profile, is_customizable=false): func rebuild(input_profile):
_action_list.clear() _action_list.clear()
for input_action in input_profile.keys(): for input_action in input_profile.keys():
var line = _action_list.add_input_line(input_action, \ if(input_action.ends_with("_old")):
input_profile[input_action], is_customizable) continue
if is_customizable: var line = _action_list.add_input_line(input_action, input_profile[input_action])
line.connect('change_button_pressed', self, \ line.connect('change_button_pressed', self, '_on_InputLine_change_button_pressed', [input_action, line])
'_on_InputLine_change_button_pressed', [input_action, line])
func _on_InputLine_change_button_pressed(action_name, line): func _on_InputLine_change_button_pressed(action_name, line):
set_process_input(false) set_process_input(false)
var old_event = $InputMapper.get_selected_profile()[action_name]
$KeySelectMenu.open() $KeySelectMenu.open()
var key_scancode = yield($KeySelectMenu, "key_selected") var event = yield($KeySelectMenu, "key_selected")
$InputMapper.change_action_key(action_name, key_scancode) if event == null:
line.update_key(key_scancode) return
changes_made = true
$InputMapper.change_action_key(action_name, old_event, event)
line.update_key(event)
set_process_input(true) set_process_input(true)

View File

@ -51,6 +51,7 @@ theme = ExtResource( 5 )
script = ExtResource( 12 ) script = ExtResource( 12 )
[node name="InputMapper" type="Node" parent="."] [node name="InputMapper" type="Node" parent="."]
unique_name_in_owner = true
script = ExtResource( 4 ) script = ExtResource( 4 )
[node name="background" type="TextureRect" parent="."] [node name="background" type="TextureRect" parent="."]
@ -252,6 +253,32 @@ text = "Press a key (ESC to cancel)"
align = 1 align = 1
valign = 1 valign = 1
[node name="ReallyQuitMenu" type="Panel" parent="."]
visible = false
material = SubResource( 8 )
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 13 )
[node name="Prompt" type="Label" parent="ReallyQuitMenu"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -334.0
margin_top = -26.0
margin_right = 335.0
margin_bottom = 26.0
grow_horizontal = 2
size_flags_horizontal = 0
size_flags_vertical = 0
custom_fonts/font = SubResource( 7 )
text = "Unsaved changes were made.
Go back anyway? Enter -> Leave, ESC -> Stay
Smile -> Save changes and leave"
align = 1
valign = 1
[connection signal="button_up" from="Back" to="Back" method="_on_button_up"] [connection signal="button_up" from="Back" to="Back" method="_on_button_up"]
[connection signal="button_up" from="Reset" to="Reset" method="_on_button_up"] [connection signal="button_up" from="Reset" to="Reset" method="_on_button_up"]
[connection signal="button_up" from="Save" to="Save" method="_on_button_up"] [connection signal="button_up" from="Save" to="Save" method="_on_button_up"]

View File

@ -2,13 +2,12 @@ extends HBoxContainer
signal change_button_pressed signal change_button_pressed
func initialize(action_name, key, can_change): func initialize(action_name, event):
$Action.text = action_name.capitalize() $Action.text = action_name.capitalize()
$Key.text = OS.get_scancode_string(key) $Key.texture = ControllerIcons.parse_event(event)
$ChangeButton.disabled = !can_change
func update_key(scancode): func update_key(event):
$Key.text = OS.get_scancode_string(scancode) $Key.texture = ControllerIcons.parse_event(event)
func _on_ChangeButton_pressed(): func _on_ChangeButton_pressed():
emit_signal('change_button_pressed') emit_signal('change_button_pressed')

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://src/UserInterface/Screens/ControlsMenu/InputLine.gd" type="Script" id=1] [ext_resource path="res://src/UserInterface/Screens/ControlsMenu/InputLine.gd" type="Script" id=1]
[ext_resource path="res://addons/controller_icons/objects/TextureRect.gd" type="Script" id=2]
[node name="InputLine" type="HBoxContainer"] [node name="InputLine" type="HBoxContainer"]
anchor_top = 0.5 anchor_top = 0.5
@ -8,38 +9,42 @@ anchor_right = 1.0
anchor_bottom = 0.5 anchor_bottom = 0.5
margin_top = -10.0 margin_top = -10.0
margin_bottom = 10.0 margin_bottom = 10.0
size_flags_horizontal = 13
size_flags_vertical = 13
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Action" type="Label" parent="."] [node name="Action" type="Label" parent="."]
margin_right = 287.0 margin_right = 306.0
margin_bottom = 20.0 margin_bottom = 20.0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 1
text = "Up" text = "Up"
valign = 1 valign = 1
[node name="Key" type="Label" parent="."] [node name="Key" type="TextureRect" parent="."]
margin_left = 291.0 margin_left = 310.0
margin_right = 578.0 margin_right = 330.0
margin_bottom = 20.0 margin_bottom = 20.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 0 grow_vertical = 0
size_flags_horizontal = 3 rect_min_size = Vector2( 20, 20 )
size_flags_vertical = 1 size_flags_horizontal = 0
text = "W Key" size_flags_vertical = 0
valign = 1 expand = true
stretch_mode = 1
script = ExtResource( 2 )
max_width = 30
[node name="ChangeButton" type="Button" parent="."] [node name="ChangeButton" type="Button" parent="."]
margin_left = 582.0 margin_left = 582.0
margin_right = 640.0 margin_right = 640.0
margin_bottom = 20.0 margin_bottom = 20.0
grow_horizontal = 0 grow_vertical = 2
grow_vertical = 0
rect_min_size = Vector2( 40, 20 ) rect_min_size = Vector2( 40, 20 )
input_pass_on_modal_close_click = false input_pass_on_modal_close_click = false
size_flags_horizontal = 0 size_flags_horizontal = 10
size_flags_vertical = 0
text = "Change" text = "Change"
icon_align = 1 align = 2
icon_align = 2
[connection signal="pressed" from="ChangeButton" to="." method="_on_ChangeButton_pressed"] [connection signal="pressed" from="ChangeButton" to="." method="_on_ChangeButton_pressed"]

View File

@ -1,55 +1,56 @@
extends Node extends Node
signal profile_changed(new_profile, is_customizable) signal profile_changed(new_profile)
var current_profile_id = 0 var current_profile_id = 0
var profiles = { var profiles = {
0: 'keyboard', 0: 'keyboard',
1: 'controller', 1: 'controller'
2: 'keyboard_default',
3: 'controller_default',
} }
var keyboard_default = { var keyboard = {}
'move_up': KEY_UP, var controller = {}
'move_down': KEY_DOWN,
'move_left': KEY_LEFT,
'move_right': KEY_RIGHT
}
var controller_default = {
'move_up': KEY_W,
'move_down': KEY_S,
'move_left': KEY_A,
'move_right': KEY_D
}
var keyboard = keyboard_default
var controller = controller_default
func change_profile(id): func change_profile(id):
current_profile_id = id current_profile_id = id
var profile = get(profiles[id]) var profile = get(profiles[id])
var is_customizable = true if id < 2 else false
for action_name in profile.keys(): for action_name in profile.keys():
change_action_key(action_name, profile[action_name]) change_action_key(action_name, profile[action_name], profile[action_name])
emit_signal('profile_changed', profile, is_customizable) emit_signal('profile_changed', profile)
return profile return profile
func change_action_key(action_name, key_scancode): func commit_to_changes():
erase_action_events(action_name) for profile_name in profiles.values():
var profile = get(profile_name)
for action_name in profile.keys():
erase_action_events(action_name, profile[action_name])
InputMap.action_add_event(action_name, profile[action_name])
var new_event = InputEventKey.new() func change_action_key(action_name, old_event, event):
new_event.set_scancode(key_scancode) #erase_action_events(action_name, old_event)
InputMap.action_add_event(action_name, new_event) get_selected_profile()[action_name] = event
get_selected_profile()[action_name] = key_scancode get_selected_profile()[action_name+"_old"] = old_event
func erase_action_events(action_name): func erase_action_events(action_name, event):
var input_events = InputMap.get_action_list(action_name) var input_events = InputMap.get_action_list(action_name)
for event in input_events: for e in input_events:
InputMap.action_erase_event(action_name, event) if(e == event):
InputMap.action_erase_event(action_name, event)
func initialize_profiles() -> void:
var actions: Array = InputMap.get_actions()
for action in actions:
var input_events = InputMap.get_action_list(action)
for event in input_events:
if event.as_text().match("*Joy*"):
controller[action] = event
controller[action+"_old"] = event
else:
keyboard[action] = event
keyboard[action+"_old"] = event
change_profile(current_profile_id)
func get_selected_profile(): func get_selected_profile():
return get(profiles[current_profile_id]) return get(profiles[current_profile_id])

View File

@ -8,8 +8,9 @@ func _ready():
func _input(event): func _input(event):
if !event.is_pressed(): if !event.is_pressed():
return return
if event.scancode != 16777217: if "scancode" in event && event.scancode == 16777217:
emit_signal("key_selected", event.scancode) return
emit_signal("key_selected", event)
close() close()
func open(): func open():

View File

@ -1,7 +1,9 @@
extends Button extends Button
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
onready var mapper := $"%InputMapper"
func _on_button_up() -> void: func _on_button_up() -> void:
InputMap.load_from_globals() InputMap.load_from_globals()
mapper.initialize_profiles()
SaveManager.save_default() SaveManager.save_default()

View File

@ -1,6 +1,8 @@
extends Button extends Button
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
onready var mapper := $"%InputMapper"
func _on_button_up() -> void: func _on_button_up() -> void:
mapper.commit_to_changes()
SaveManager.save_default() SaveManager.save_default()

View File

@ -7,8 +7,8 @@ onready var timer: Label = $HUDOverlay/GetBackTimer
onready var currency: Label = $HUDOverlay/Currency onready var currency: Label = $HUDOverlay/Currency
onready var kills: Label = $HUDOverlay/Kills onready var kills: Label = $HUDOverlay/Kills
onready var frees: Label = $HUDOverlay/Frees onready var frees: Label = $HUDOverlay/Frees
onready var levelState := get_tree().root.get_child(2).get_node("%LevelState") onready var levelState := get_tree().root.get_child(3).get_node("%LevelState")
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
func _ready(): func _ready():

View File

@ -1,6 +1,6 @@
extends Node extends Node
onready var signalManager := get_tree().root.get_child(2).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
onready var levelName := get_tree().get_current_scene().get_name() onready var levelName := get_tree().get_current_scene().get_name()
#TODO Easteregg pls #TODO Easteregg pls