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/*
*/.vscode/launch.json
# File specific ignores
savefile.tres

View File

@ -14,6 +14,36 @@ _global_script_classes=[ {
"language": "GDScript",
"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",
"class": "Enemy",
"language": "GDScript",
@ -46,6 +76,12 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
"Actor": "",
"ControllerButton": "",
"ControllerMapper": "",
"ControllerSettings": "",
"ControllerSprite": "",
"ControllerSprite3D": "",
"ControllerTextureRect": "",
"Enemy": "",
"GlobalStateResource": "",
"LevelTemplate": "",
@ -64,6 +100,7 @@ config/icon="res://icon.png"
GlobalState="*res://src/Autoload/GlobalState.tscn"
SaveManager="*res://src/Autoload/SaveManager.gd"
ControllerIcons="*res://addons/controller_icons/ControllerIcons.gd"
[debug]
@ -80,7 +117,7 @@ window/stretch/aspect="expand"
[editor_plugins]
enabled=PoolStringArray( "res://addons/AsepriteWizard/plugin.cfg" )
enabled=PoolStringArray( "res://addons/AsepriteWizard/plugin.cfg", "res://addons/controller_icons/plugin.cfg" )
[global]
@ -122,24 +159,49 @@ ogg_vorbis={
ui_accept={
"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(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)
]
}
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={
"deadzone": 0.5,
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"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":65,"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":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(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={
"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)
, 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(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={
@ -164,9 +226,7 @@ boost_move={
duck={
"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)
, 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":16777234,"unicode":0,"echo":false,"script":null)
]
}
click={
@ -177,15 +237,12 @@ click={
interact={
"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)
, 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)
]
}
up={
"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)
, 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)
]
}

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]
@ -11,142 +11,96 @@ button_index = 1
[sub_resource type="InputEventMouseButton" id=3]
button_index = 1
[sub_resource type="InputEventKey" id=5]
physical_scancode = 83
[sub_resource type="InputEventJoypadButton" id=4]
button_index = 13
[sub_resource type="InputEventJoypadMotion" id=5]
axis = 1
axis_value = 1.0
[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
[sub_resource type="InputEventKey" id=9]
physical_scancode = 16777221
[sub_resource type="InputEventJoypadButton" id=10]
[sub_resource type="InputEventJoypadButton" id=7]
button_index = 2
[sub_resource type="InputEventKey" id=11]
[sub_resource type="InputEventKey" id=8]
scancode = 32
[sub_resource type="InputEventJoypadButton" id=12]
[sub_resource type="InputEventKey" id=13]
[sub_resource type="InputEventKey" id=10]
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]
shift = true
scancode = 16777218
pressed = true
scancode = 87
physical_scancode = 87
unicode = 119
[sub_resource type="InputEventKey" id=34]
scancode = 16777229
[sub_resource type="InputEventJoypadButton" id=9]
[sub_resource type="InputEventKey" id=35]
scancode = 16777231
[sub_resource type="InputEventKey" id=11]
scancode = 65
[sub_resource type="InputEventJoypadButton" id=36]
[sub_resource type="InputEventJoypadButton" id=12]
device = -1
button_index = 14
[sub_resource type="InputEventKey" id=37]
scancode = 16777236
[sub_resource type="InputEventKey" id=13]
scancode = 68
[sub_resource type="InputEventKey" id=38]
scancode = 16777235
[sub_resource type="InputEventKey" id=39]
scancode = 16777233
[sub_resource type="InputEventJoypadButton" id=40]
[sub_resource type="InputEventJoypadButton" id=14]
device = -1
button_index = 15
[sub_resource type="InputEventKey" id=41]
scancode = 32
[sub_resource type="InputEventKey" id=15]
scancode = 16777217
[sub_resource type="InputEventJoypadButton" id=42]
button_index = 3
[sub_resource type="InputEventJoypadButton" id=16]
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
[sub_resource type="InputEventJoypadButton" id=44]
[sub_resource type="InputEventJoypadButton" id=30]
button_index = 12
[sub_resource type="InputEventKey" id=45]
[sub_resource type="InputEventKey" id=31]
physical_scancode = 87
[sub_resource type="InputEventKey" id=46]
physical_scancode = 16777232
[sub_resource type="InputEventJoypadMotion" id=47]
axis = 1
axis_value = -1.0
[sub_resource type="InputEventJoypadButton" id=48]
[sub_resource type="InputEventJoypadButton" id=32]
button_index = 12
[resource]
@ -157,31 +111,44 @@ progress_dict = {
"deaths": 0,
"frees": 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 = {
"boost_move": [ SubResource( 1 ), SubResource( 2 ) ],
"click": [ SubResource( 3 ) ],
"duck": [ SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ],
"interact": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ],
"jump": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ],
"move_left": [ SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ) ],
"move_right": [ SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ) ],
"pause": [ SubResource( 22 ), SubResource( 23 ) ],
"ui_accept": [ SubResource( 24 ), SubResource( 25 ), SubResource( 26 ) ],
"ui_cancel": [ SubResource( 27 ), SubResource( 28 ) ],
"ui_down": [ SubResource( 29 ), SubResource( 30 ) ],
"ui_end": [ SubResource( 31 ) ],
"ui_focus_next": [ SubResource( 32 ) ],
"ui_focus_prev": [ SubResource( 33 ) ],
"ui_home": [ SubResource( 34 ) ],
"ui_left": [ SubResource( 35 ), SubResource( 36 ) ],
"ui_page_down": [ SubResource( 37 ) ],
"ui_page_up": [ SubResource( 38 ) ],
"ui_right": [ SubResource( 39 ), SubResource( 40 ) ],
"ui_select": [ SubResource( 41 ), SubResource( 42 ) ],
"ui_up": [ SubResource( 43 ), SubResource( 44 ) ],
"up": [ SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ) ]
"duck": [ SubResource( 5 ), SubResource( 4 ) ],
"interact": [ SubResource( 6 ), SubResource( 7 ) ],
"jump": [ SubResource( 8 ), SubResource( 10 ), SubResource( 33 ), SubResource( 9 ) ],
"move_left": [ SubResource( 11 ), SubResource( 12 ) ],
"move_right": [ SubResource( 13 ), SubResource( 14 ) ],
"pause": [ SubResource( 15 ), SubResource( 16 ) ],
"ui_accept": [ SubResource( 17 ), SubResource( 18 ) ],
"ui_cancel": [ SubResource( 19 ), SubResource( 20 ) ],
"ui_down": [ SubResource( 21 ), SubResource( 22 ) ],
"ui_end": [ ],
"ui_focus_next": [ ],
"ui_focus_prev": [ ],
"ui_home": [ ],
"ui_left": [ SubResource( 23 ), SubResource( 24 ) ],
"ui_page_down": [ ],
"ui_page_up": [ ],
"ui_right": [ SubResource( 25 ), SubResource( 26 ) ],
"ui_select": [ SubResource( 27 ), SubResource( 28 ) ],
"ui_up": [ SubResource( 29 ), SubResource( 30 ) ],
"up": [ SubResource( 31 ), SubResource( 32 ) ]
}
show_tutorial = false

View File

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

View File

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

View File

@ -1,7 +1,7 @@
extends Node
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:
load_initial_save()

View File

@ -1,6 +1,6 @@
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:
if(GlobalState.get_savepoint(levelState.levelName) == global_position + Vector2(0,18)):

View File

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

View File

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

View File

@ -4,7 +4,7 @@ onready var buttonPlayer = $"%ButtonPlayer"
onready var activatorArea = $"%ActivatorArea"
onready var indicatorPlayer = $"%IndicatorPlayer"
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 get_back_timer := $GetBackTimer

View File

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

View File

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

View File

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

View File

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

View File

@ -51,6 +51,7 @@ theme = ExtResource( 5 )
script = ExtResource( 12 )
[node name="InputMapper" type="Node" parent="."]
unique_name_in_owner = true
script = ExtResource( 4 )
[node name="background" type="TextureRect" parent="."]
@ -252,6 +253,32 @@ text = "Press a key (ESC to cancel)"
align = 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="Reset" to="Reset" 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
func initialize(action_name, key, can_change):
func initialize(action_name, event):
$Action.text = action_name.capitalize()
$Key.text = OS.get_scancode_string(key)
$ChangeButton.disabled = !can_change
$Key.texture = ControllerIcons.parse_event(event)
func update_key(scancode):
$Key.text = OS.get_scancode_string(scancode)
func update_key(event):
$Key.texture = ControllerIcons.parse_event(event)
func _on_ChangeButton_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://addons/controller_icons/objects/TextureRect.gd" type="Script" id=2]
[node name="InputLine" type="HBoxContainer"]
anchor_top = 0.5
@ -8,38 +9,42 @@ anchor_right = 1.0
anchor_bottom = 0.5
margin_top = -10.0
margin_bottom = 10.0
size_flags_horizontal = 13
size_flags_vertical = 13
script = ExtResource( 1 )
[node name="Action" type="Label" parent="."]
margin_right = 287.0
margin_right = 306.0
margin_bottom = 20.0
size_flags_horizontal = 3
size_flags_vertical = 3
size_flags_vertical = 1
text = "Up"
valign = 1
[node name="Key" type="Label" parent="."]
margin_left = 291.0
margin_right = 578.0
[node name="Key" type="TextureRect" parent="."]
margin_left = 310.0
margin_right = 330.0
margin_bottom = 20.0
grow_horizontal = 0
grow_vertical = 0
size_flags_horizontal = 3
size_flags_vertical = 1
text = "W Key"
valign = 1
rect_min_size = Vector2( 20, 20 )
size_flags_horizontal = 0
size_flags_vertical = 0
expand = true
stretch_mode = 1
script = ExtResource( 2 )
max_width = 30
[node name="ChangeButton" type="Button" parent="."]
margin_left = 582.0
margin_right = 640.0
margin_bottom = 20.0
grow_horizontal = 0
grow_vertical = 0
grow_vertical = 2
rect_min_size = Vector2( 40, 20 )
input_pass_on_modal_close_click = false
size_flags_horizontal = 0
size_flags_vertical = 0
size_flags_horizontal = 10
text = "Change"
icon_align = 1
align = 2
icon_align = 2
[connection signal="pressed" from="ChangeButton" to="." method="_on_ChangeButton_pressed"]

View File

@ -1,55 +1,56 @@
extends Node
signal profile_changed(new_profile, is_customizable)
signal profile_changed(new_profile)
var current_profile_id = 0
var profiles = {
0: 'keyboard',
1: 'controller',
2: 'keyboard_default',
3: 'controller_default',
1: 'controller'
}
var keyboard_default = {
'move_up': KEY_UP,
'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
var keyboard = {}
var controller = {}
func change_profile(id):
current_profile_id = id
var profile = get(profiles[id])
var is_customizable = true if id < 2 else false
for action_name in profile.keys():
change_action_key(action_name, profile[action_name])
emit_signal('profile_changed', profile, is_customizable)
change_action_key(action_name, profile[action_name], profile[action_name])
emit_signal('profile_changed', profile)
return profile
func change_action_key(action_name, key_scancode):
erase_action_events(action_name)
func commit_to_changes():
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()
new_event.set_scancode(key_scancode)
InputMap.action_add_event(action_name, new_event)
get_selected_profile()[action_name] = key_scancode
func change_action_key(action_name, old_event, event):
#erase_action_events(action_name, old_event)
get_selected_profile()[action_name] = event
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)
for event in input_events:
InputMap.action_erase_event(action_name, event)
for e in input_events:
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():
return get(profiles[current_profile_id])

View File

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

View File

@ -1,7 +1,9 @@
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:
InputMap.load_from_globals()
mapper.initialize_profiles()
SaveManager.save_default()

View File

@ -1,6 +1,8 @@
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:
mapper.commit_to_changes()
SaveManager.save_default()

View File

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

View File

@ -1,6 +1,6 @@
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()
#TODO Easteregg pls