Compare commits

..

3 Commits

Author SHA1 Message Date
8cf677677f feat: Option for frog to jump in narrow pits
If this is enabled the frog will jump into pits in which he will slide
along the wall when he falls.
This causes the frog to always jump directly against a wall before
it considers jumping ontop of it. So it's slightly dumber.
2023-10-11 17:07:13 +02:00
499928b096 fix: Level Select Improvment Highlights 2023-10-11 17:04:58 +02:00
72fc3e7e39 feat: Controls Menu Overhaul, alternative buttons and swaps 2023-10-11 17:04:04 +02:00
28 changed files with 774 additions and 215 deletions

View File

@ -75,7 +75,14 @@ region = Rect2( 100, 20, 7, 8 )
[sub_resource type="StyleBoxEmpty" id=10] [sub_resource type="StyleBoxEmpty" id=10]
[sub_resource type="StyleBoxEmpty" id=11] [sub_resource type="StyleBoxFlat" id=96]
bg_color = Color( 0.423529, 0.898039, 0.756863, 0.4 )
border_width_left = 31
border_width_top = 1
border_width_right = 22
border_width_bottom = 1
border_color = Color( 0.0901961, 0.14902, 0.270588, 0.345098 )
border_blend = true
[sub_resource type="StyleBoxEmpty" id=12] [sub_resource type="StyleBoxEmpty" id=12]
@ -329,9 +336,7 @@ margin_right = 2.0
margin_top = 2.0 margin_top = 2.0
margin_bottom = 2.0 margin_bottom = 2.0
[sub_resource type="StyleBoxEmpty" id=52] [sub_resource type="StyleBoxTexture" id=97]
[sub_resource type="StyleBoxTexture" id=53]
texture = ExtResource( 2 ) texture = ExtResource( 2 )
region_rect = Rect2( 17, 97, 14, 14 ) region_rect = Rect2( 17, 97, 14, 14 )
margin_left = 2.0 margin_left = 2.0
@ -347,6 +352,14 @@ margin_right = 2.0
margin_top = 2.0 margin_top = 2.0
margin_bottom = 2.0 margin_bottom = 2.0
[sub_resource type="StyleBoxTexture" id=53]
texture = ExtResource( 2 )
region_rect = Rect2( 17, 97, 14, 14 )
margin_left = 2.0
margin_right = 2.0
margin_top = 2.0
margin_bottom = 2.0
[sub_resource type="StyleBoxTexture" id=55] [sub_resource type="StyleBoxTexture" id=55]
content_margin_left = 15.0 content_margin_left = 15.0
content_margin_right = 16.0 content_margin_right = 16.0
@ -655,7 +668,7 @@ CheckBox/icons/radio_checked = SubResource( 7 )
CheckBox/icons/radio_unchecked = SubResource( 8 ) CheckBox/icons/radio_unchecked = SubResource( 8 )
CheckBox/icons/unchecked = SubResource( 9 ) CheckBox/icons/unchecked = SubResource( 9 )
CheckBox/styles/disabled = SubResource( 10 ) CheckBox/styles/disabled = SubResource( 10 )
CheckBox/styles/focus = SubResource( 11 ) CheckBox/styles/focus = SubResource( 96 )
CheckBox/styles/hover = SubResource( 12 ) CheckBox/styles/hover = SubResource( 12 )
CheckBox/styles/hover_pressed = SubResource( 13 ) CheckBox/styles/hover_pressed = SubResource( 13 )
CheckBox/styles/normal = SubResource( 14 ) CheckBox/styles/normal = SubResource( 14 )
@ -741,8 +754,9 @@ MenuButton/styles/focus = SubResource( 46 )
MenuButton/styles/hover = SubResource( 47 ) MenuButton/styles/hover = SubResource( 47 )
MenuButton/styles/normal = SubResource( 48 ) MenuButton/styles/normal = SubResource( 48 )
MenuButton/styles/pressed = SubResource( 49 ) MenuButton/styles/pressed = SubResource( 49 )
OptionButton/colors/font_color = Color( 0.88, 0.88, 0.88, 1 ) OptionButton/colors/font_color = Color( 1, 1, 1, 1 )
OptionButton/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 ) OptionButton/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
OptionButton/colors/font_color_focus = Color( 0.376471, 0.909804, 0.768627, 1 )
OptionButton/colors/font_color_hover = Color( 0.376471, 0.909804, 0.768627, 1 ) OptionButton/colors/font_color_hover = Color( 0.376471, 0.909804, 0.768627, 1 )
OptionButton/colors/font_color_pressed = Color( 1, 1, 1, 1 ) OptionButton/colors/font_color_pressed = Color( 1, 1, 1, 1 )
OptionButton/constants/arrow_margin = 2 OptionButton/constants/arrow_margin = 2
@ -750,8 +764,8 @@ OptionButton/constants/hseparation = 2
OptionButton/fonts/font = ExtResource( 3 ) OptionButton/fonts/font = ExtResource( 3 )
OptionButton/icons/arrow = SubResource( 50 ) OptionButton/icons/arrow = SubResource( 50 )
OptionButton/styles/disabled = SubResource( 51 ) OptionButton/styles/disabled = SubResource( 51 )
OptionButton/styles/focus = SubResource( 52 ) OptionButton/styles/focus = SubResource( 97 )
OptionButton/styles/hover = SubResource( 53 ) OptionButton/styles/hover = SubResource( 97 )
OptionButton/styles/normal = SubResource( 54 ) OptionButton/styles/normal = SubResource( 54 )
OptionButton/styles/pressed = SubResource( 53 ) OptionButton/styles/pressed = SubResource( 53 )
Panel/styles/panel = SubResource( 55 ) Panel/styles/panel = SubResource( 55 )

View File

@ -59,11 +59,6 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://addons/controller_icons/objects/TextureRect.gd" "path": "res://addons/controller_icons/objects/TextureRect.gd"
}, { }, {
"base": "SceneTree",
"class": "CreateIcon",
"language": "GDScript",
"path": "res://Neuer Ordner/CreateIcon.gd"
}, {
"base": "Actor", "base": "Actor",
"class": "Enemy", "class": "Enemy",
"language": "GDScript", "language": "GDScript",
@ -89,11 +84,6 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://src/RayCasters/RayCaster.gd" "path": "res://src/RayCasters/RayCaster.gd"
}, { }, {
"base": "Reference",
"class": "ReplaceIcon",
"language": "GDScript",
"path": "res://Neuer Ordner/ReplaceIcon.gd"
}, {
"base": "Button", "base": "Button",
"class": "SoundButton", "class": "SoundButton",
"language": "GDScript", "language": "GDScript",
@ -115,13 +105,11 @@ _global_script_class_icons={
"ControllerSprite": "", "ControllerSprite": "",
"ControllerSprite3D": "", "ControllerSprite3D": "",
"ControllerTextureRect": "", "ControllerTextureRect": "",
"CreateIcon": "",
"Enemy": "", "Enemy": "",
"GlobalStateResource": "", "GlobalStateResource": "",
"LevelTemplate": "", "LevelTemplate": "",
"RayCastDebugLines": "", "RayCastDebugLines": "",
"RayCaster": "", "RayCaster": "",
"ReplaceIcon": "",
"SoundButton": "", "SoundButton": "",
"StateMachine": "" "StateMachine": ""
} }
@ -251,34 +239,34 @@ ui_end={
} }
up={ up={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":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":16777232,"physical_scancode":0,"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(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"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":87,"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":16777232,"physical_scancode":0,"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)
}
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":83,"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":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
] ]
} }
move_left={ move_left={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":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":16777231,"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(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(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"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":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
move_right={ move_right={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":15,"pressure":0.0,"pressed":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":16777233,"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(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(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(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"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":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
]
}
duck={
"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":16777234,"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":83,"physical_scancode":0,"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":13,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
jump={ jump={
@ -340,7 +328,6 @@ quality/intended_usage/framebuffer_allocation.mobile=0
threads/thread_model=2 threads/thread_model=2
2d/options/use_software_skinning=false 2d/options/use_software_skinning=false
gles3/shaders/shader_compilation_mode=2 gles3/shaders/shader_compilation_mode=2
gles3/shaders/shader_compilation_mode.web=2
2d/options/culling_mode=0 2d/options/culling_mode=0
quality/depth/hdr=false quality/depth/hdr=false
environment/default_environment="res://default_env.tres" environment/default_environment="res://default_env.tres"

View File

@ -19,6 +19,7 @@ export var vision_distance := 6.0
export var vision_angle := 180.0 export var vision_angle := 180.0
export var attack_jump_range := 6.0 export var attack_jump_range := 6.0
export var aggressive_to_player := false export var aggressive_to_player := false
export var jump_into_narrow_pit := false
export var loose_target_seconds := 3.0 export var loose_target_seconds := 3.0
# Jump distance in blocks # Jump distance in blocks
export var default_jump_distance := 4.0 export var default_jump_distance := 4.0
@ -344,6 +345,8 @@ func jump():
# TODO fix that you could call jump from jumping on top # TODO fix that you could call jump from jumping on top
# and let it fail if the top is dangerous for jump height or not safe # and let it fail if the top is dangerous for jump height or not safe
v = consider_jumping_on_top() v = consider_jumping_on_top()
if v == zero_vector && jump_into_narrow_pit:
v = consider_jump_landing_space(v, jump_into_narrow_pit)
if v == zero_vector && can_reverse_facing_direction(): if v == zero_vector && can_reverse_facing_direction():
reverse_facing_direction() reverse_facing_direction()
@ -398,7 +401,7 @@ func consider_jump_headspace(v: Vector2, recursive_check_count = 0, max_checks =
# Check the block in jump distance for danger or height # Check the block in jump distance for danger or height
# If danger check neighboring blocks: if still danger, then jump closer (or jump over) # If danger check neighboring blocks: if still danger, then jump closer (or jump over)
# If height move to distance which allows 1 block high jump # If height move to distance which allows 1 block high jump
func consider_jump_landing_space(v: Vector2) -> Vector2: func consider_jump_landing_space(v: Vector2, jump_into_narrow_pit = false) -> Vector2:
var jump_distance = calculate_jump_distance(v) var jump_distance = calculate_jump_distance(v)
var jump_height = calculate_jump_height(v) var jump_height = calculate_jump_height(v)
var collider = check_feeler(Vector2(jump_distance * get_facing_direction(), -jump_height / 2)) var collider = check_feeler(Vector2(jump_distance * get_facing_direction(), -jump_height / 2))
@ -417,7 +420,7 @@ func consider_jump_landing_space(v: Vector2) -> Vector2:
v = correct_jump_direction(v) v = correct_jump_direction(v)
collider = check_feeler(Vector2(jump_distance * get_facing_direction(), -jump_height / 2)) collider = check_feeler(Vector2(jump_distance * get_facing_direction(), -jump_height / 2))
if ( if (
(!is_jump_path_safe(v, global_position) || collider != null) (!is_jump_path_safe(v, global_position) || (collider != null && !jump_into_narrow_pit))
&& can_reverse_facing_direction() && can_reverse_facing_direction()
): ):
# Can be printed when frog would jump into a wall too # Can be printed when frog would jump into a wall too

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=50 format=2] [gd_scene load_steps=52 format=2]
[ext_resource path="res://assets/enemy/froshler.png" type="Texture" id=1] [ext_resource path="res://assets/enemy/froshler.png" type="Texture" id=1]
[ext_resource path="res://src/Actors/Friendlies/WhatAreFrog.gd" type="Script" id=2] [ext_resource path="res://src/Actors/Friendlies/WhatAreFrog.gd" type="Script" id=2]
@ -8,6 +8,38 @@
[ext_resource path="res://assets/enemy/leash-hook.png" type="Texture" id=6] [ext_resource path="res://assets/enemy/leash-hook.png" type="Texture" id=6]
[ext_resource path="res://src/Utilities/SceneAudio.tscn" type="PackedScene" id=7] [ext_resource path="res://src/Utilities/SceneAudio.tscn" type="PackedScene" id=7]
[sub_resource type="Shader" id=61]
code = "shader_type canvas_item;
uniform float wavelength = 10.0;
uniform float wavespeed = 1.0;
uniform float alpha = 0.25;
uniform float displacement = 0.0;
uniform float displacement_speed = 1.0;
uniform sampler2D noise_texture;
uniform sampler2D noise_displacement_texture;
uniform sampler2D gradiant;
void vertex()
{
vec3 perlin = texture(noise_displacement_texture, UV + (TIME * displacement_speed)).rgb;
VERTEX = VERTEX + (perlin * displacement);
}
void fragment()
{
vec3 perlin = texture(noise_texture, UV).rgb;
float ndotp = dot(VIEW, perlin) * wavelength;
float waves = (1.0 + sin(ndotp + TIME * wavespeed)) / 2.0;
vec4 color = texture(gradiant, vec2(waves, 0.5));
ALBEDO = color.rgb;
ALPHA = min(color.a, alpha);
}"
[sub_resource type="ShaderMaterial" id=62]
shader = SubResource( 61 )
[sub_resource type="Animation" id=5] [sub_resource type="Animation" id=5]
length = 0.001 length = 0.001
tracks/0/type = "value" tracks/0/type = "value"
@ -479,6 +511,7 @@ texture = ExtResource( 6 )
[node name="FrogSprite" type="Sprite" parent="."] [node name="FrogSprite" type="Sprite" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
material = SubResource( 62 )
position = Vector2( 0, -7 ) position = Vector2( 0, -7 )
texture = ExtResource( 1 ) texture = ExtResource( 1 )
hframes = 2 hframes = 2

View File

@ -1146,6 +1146,9 @@ initial_wait_time = 2.0
[node name="Button" parent="Tutorials/RightTut" index="0"] [node name="Button" parent="Tutorials/RightTut" index="0"]
material = SubResource( 13 ) material = SubResource( 13 )
[node name="Label" parent="Tutorials/RightTut/TextureRect" index="0"]
autowrap = false
[node name="AnimationPlayer" parent="Tutorials/RightTut" index="4"] [node name="AnimationPlayer" parent="Tutorials/RightTut" index="4"]
anims/RESET = SubResource( 9 ) anims/RESET = SubResource( 9 )
anims/cease_4_exist = SubResource( 10 ) anims/cease_4_exist = SubResource( 10 )
@ -1326,7 +1329,7 @@ position = Vector2( -70, 1 )
scale = Vector2( 0.878906, 0.936025 ) scale = Vector2( 0.878906, 0.936025 )
[node name="BlobbySprite" parent="Blobby" index="5"] [node name="BlobbySprite" parent="Blobby" index="5"]
frame = 7 frame = 8
[node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"] [node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"]
parameters/playback = SubResource( 33 ) parameters/playback = SubResource( 33 )

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -41,12 +41,12 @@ resource_name = "LowPassFilter"
cutoff_hz = 3000.0 cutoff_hz = 3000.0
[resource] [resource]
bus/0/volume_db = -6.93575 bus/0/volume_db = inf_neg
bus/1/name = "Music" bus/1/name = "Music"
bus/1/solo = false bus/1/solo = false
bus/1/mute = false bus/1/mute = false
bus/1/bypass_fx = false bus/1/bypass_fx = false
bus/1/volume_db = -6.0206 bus/1/volume_db = 0.0
bus/1/send = "Master" bus/1/send = "Master"
bus/1/effect/0/effect = SubResource( 1 ) bus/1/effect/0/effect = SubResource( 1 )
bus/1/effect/0/enabled = false bus/1/effect/0/enabled = false
@ -68,7 +68,7 @@ bus/3/name = "UI"
bus/3/solo = false bus/3/solo = false
bus/3/mute = false bus/3/mute = false
bus/3/bypass_fx = false bus/3/bypass_fx = false
bus/3/volume_db = -6.0206 bus/3/volume_db = 0.0
bus/3/send = "Master" bus/3/send = "Master"
bus/3/effect/0/effect = SubResource( 6 ) bus/3/effect/0/effect = SubResource( 6 )
bus/3/effect/0/enabled = true bus/3/effect/0/enabled = true

View File

@ -1,32 +1,32 @@
extends StateMachine extends StateMachine
func _ready() -> void: func _ready() -> void:
add_state("robbing") add_state("robbing")
state = states.robbing state = states.robbing
set_state(states.robbing) set_state(states.robbing)
for state in states: for state in states:
if state_matching_method_exists(state): if state_matching_method_exists(state):
continue continue
else: else:
printerr("StateMachine -> State: " + state + " has no matching method in parent.") printerr("StateMachine -> State: " + state + " has no matching method in parent.")
push_error("StateMachine -> State: " + state + " has no matching method in parent.") push_error("StateMachine -> State: " + state + " has no matching method in parent.")
# _animation_logic() # _animation_logic()
# Game logic consequences of state # Game logic consequences of state
func _state_logic(delta): func _state_logic(delta):
#var state_action_ref = funcref(parent, self.state) #var state_action_ref = funcref(parent, self.state)
#parent.velocity = state_action_ref.call_func() #parent.velocity = state_action_ref.call_func()
parent.execute_movement(delta) parent.execute_movement(delta)
func _get_transition(_delta): func _get_transition(_delta):
return null return null
func _enter_state(_new_state, _previous_state): func _enter_state(_new_state, _previous_state):
pass pass
func _exit_state(_previous_state, _new_state): func _exit_state(_previous_state, _new_state):
pass pass

View File

@ -12,7 +12,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3 )
far = 150.0 far = 150.0
[node name="MeshInstance" type="MeshInstance" parent="."] [node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1.0, -0.00767937, 0, 0.00767937, 1.0, 0, 0, 0, 1, 0, 0, 0 ) transform = Transform( 1, -0.00767937, 0, 0.00767937, 1, 0, 0, 0, 1, 0, 0, 0 )
mesh = SubResource( 1 ) mesh = SubResource( 1 )
material/0 = ExtResource( 2 ) material/0 = ExtResource( 2 )
script = ExtResource( 1 ) script = ExtResource( 1 )

View File

@ -7,28 +7,28 @@ var focus_player
var press_player var press_player
func _ready() -> void: func _ready() -> void:
focus_player = AudioStreamPlayer.new() focus_player = AudioStreamPlayer.new()
focus_player.bus = "UI" focus_player.bus = "UI"
var asrp = AudioStreamRandomPitch.new() var asrp = AudioStreamRandomPitch.new()
asrp.audio_stream = GlobalState.sound_library[focus_sound] asrp.audio_stream = GlobalState.sound_library[focus_sound]
focus_player.stream = asrp focus_player.stream = asrp
#focus_player.volume_db = 5 #focus_player.volume_db = 5
add_child(focus_player) add_child(focus_player)
connect("focus_exited", self, "focus_play") connect("focus_exited", self, "focus_play")
press_player = AudioStreamPlayer.new() press_player = AudioStreamPlayer.new()
press_player.bus = "UI" press_player.bus = "UI"
var asrp2 = AudioStreamRandomPitch.new() var asrp2 = AudioStreamRandomPitch.new()
asrp2.audio_stream = GlobalState.sound_library[press_sound] asrp2.audio_stream = GlobalState.sound_library[press_sound]
press_player.stream = asrp2 press_player.stream = asrp2
#press_player.volume_db = 5 #press_player.volume_db = 5
add_child(press_player) add_child(press_player)
connect("button_down", self, "press_play") connect("button_down", self, "press_play")
func focus_play(): func focus_play():
if visible: if visible:
focus_player.play() focus_player.play()
func press_play(): func press_play():
if visible: if visible:
press_player.play() press_player.play()

View File

@ -26,7 +26,17 @@ func rebuild(input_profile):
_action_list.clear() _action_list.clear()
var first = true var first = true
var prev_line var prev_line
for input_action in input_profile.keys(): for order_action in $InputMapper.profile_order:
var input_action := ""
for action in input_profile.keys():
if action == order_action:
input_action = action
if input_action == "":
continue
if(input_action.ends_with("_old") || input_action.begins_with(("ui_"))): if(input_action.ends_with("_old") || input_action.begins_with(("ui_"))):
continue continue
var line = _action_list.add_input_line(input_action, input_profile[input_action]) var line = _action_list.add_input_line(input_action, input_profile[input_action])
@ -55,7 +65,62 @@ func _on_InputLine_change_button_pressed(action_name, line):
var event = yield($"%KeySelectMenu", "key_selected") var event = yield($"%KeySelectMenu", "key_selected")
if event == null: if event == null:
return return
if($InputMapper.change_action_key(action_name, event, old_event)):
#Check if events are basically the same
#TODO Problem with different physical locations of the same key
if "scancode" in old_event && "scancode" in event:
if event.scancode == old_event.scancode:
return
elif event == old_event:
return
var action_with_same_event: String = check_doubled_event(event)
# Routine to swap buttons
# TODO put into function
if action_with_same_event != "":
# Check doubled reads from the InputMap and alternative actions are only virtual
if action_with_same_event == action_name:
action_with_same_event = "alt " + action_name
$"%SwapKeysMenu".open(action_name, action_with_same_event, old_event, event)
var swap = yield($"SwapKeysMenu", "selection_made")
if swap:
swap_buttons(action_name, action_with_same_event, old_event, event)
print("bakayaroo!")
return
if $InputMapper.change_action_key(action_name, event, old_event):
changes_made = true changes_made = true
changes_saved = false changes_saved = false
line.update_key(event) line.update_key(event)
func check_doubled_event(event: InputEvent) -> String:
for action in $InputMapper.get_selected_profile().keys():
if action.begins_with("ui_") || action.ends_with("_old"):
continue
var assigned_event: InputEvent = $InputMapper.get_selected_profile()[action]
if "scancode" in assigned_event && "scancode" in event:
if event.scancode == assigned_event.scancode:
return action
else:
if event == assigned_event:
return action
return ""
func swap_buttons(action1, action2, old_event, new_event) -> void:
var input_line1 = $"%ActionKeyList".get_input_line(action1)
var input_line2 = $"%ActionKeyList".get_input_line(action2)
if $InputMapper.change_action_key(action1, new_event, old_event):
changes_made = true
changes_saved = false
input_line1.update_key(new_event)
else:
return
# Avoid erasing the just assigned "old" event from the input map,
# when swapping alternative button assignments in place
if action1.trim_prefix("alt ") == action2.trim_prefix("alt "):
new_event = old_event
if $InputMapper.change_action_key(action2, old_event, new_event):
input_line2.update_key(old_event)

View File

@ -4,65 +4,68 @@ extends Control
onready var signal_manager := get_tree().root.get_child(4).get_node("%SignalManager") onready var signal_manager := get_tree().root.get_child(4).get_node("%SignalManager")
onready var level_state := get_tree().root.get_child(4).get_node("%LevelState") onready var level_state := get_tree().root.get_child(4).get_node("%LevelState")
onready var current_scene := get_tree().get_current_scene() onready var current_scene := get_tree().get_current_scene()
onready var pause_overlay: = get_node("PauseOverlay") onready var pause_overlay := get_node("PauseOverlay")
onready var pause_title: Label = get_node("PauseOverlay/Title") onready var pause_title: Label = get_node("PauseOverlay/Title")
var paused := false setget set_paused var paused := false setget set_paused
var block_ui_cancel = false var block_ui_cancel = false
func _ready(): func _ready():
#signal_manager.connect("player_died", self, "_on_GlobalState_player_died") #signal_manager.connect("player_died", self, "_on_GlobalState_player_died")
$ControlsMenu.visible = false $ControlsMenu.visible = false
$ControlsMenu.set_process_input(false) $ControlsMenu.set_process_input(false)
$AudioMenu.set_process_input(false) $AudioMenu.set_process_input(false)
signal_manager.connect("game_paused", self, "set_paused") signal_manager.connect("game_paused", self, "set_paused")
pass pass
func open_audio_menu(): func open_audio_menu():
block_ui_cancel = true block_ui_cancel = true
pause_overlay.visible = false pause_overlay.visible = false
$AudioMenu.visible = true $AudioMenu.visible = true
$AudioMenu.set_process_input(true) $AudioMenu.set_process_input(true)
$"%MasterSlider".grab_focus() $"%MasterSlider".grab_focus()
func close_audio_menu(): func close_audio_menu():
$AudioMenu.visible = false $AudioMenu.visible = false
pause_overlay.visible = true pause_overlay.visible = true
$AudioMenu.set_process_input(false) $AudioMenu.set_process_input(false)
$"%Continue".grab_focus() $"%Continue".grab_focus()
get_tree().set_input_as_handled() get_tree().set_input_as_handled()
func _on_GlobalState_player_died() -> void: func _on_GlobalState_player_died() -> void:
self.paused = true self.paused = true
pause_title.text = "You lost" pause_title.text = "You lost"
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if !event.is_action("pause"): if !event.is_action("pause"):
return return
if block_ui_cancel || $"%ControlsMenu".visible: if block_ui_cancel || $"%ControlsMenu".visible:
block_ui_cancel = false block_ui_cancel = false
get_tree().set_input_as_handled() get_tree().set_input_as_handled()
return return
#not oder ! schaltet einen boolean um #not oder ! schaltet einen boolean um
#Ist self hier notwendig? #Ist self hier notwendig?
self.paused = not paused self.paused = not paused
block_ui_cancel = true block_ui_cancel = true
func set_paused(value: bool) -> void: func set_paused(value: bool) -> void:
paused = value paused = value
get_tree().paused = value get_tree().paused = value
pause_overlay.visible = value pause_overlay.visible = value
if value == true: if value == true:
$"%Continue".grab_focus() $"%Continue".grab_focus()
func _on_Controls_button_up() -> void: func _on_Controls_button_up() -> void:
$ControlsMenu.visible = true $ControlsMenu.visible = true
$ControlsMenu.set_process_input(true) $ControlsMenu.set_process_input(true)
block_ui_cancel = true block_ui_cancel = true
pause_overlay.visible = false pause_overlay.visible = false
$"%ProfilesMenu".grab_focus() $"%ProfilesMenu".grab_focus()

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=39 format=2] [gd_scene load_steps=44 format=2]
[ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=1] [ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=1]
[ext_resource path="res://assets/ui/sci-fi-godot-theme/sci-fi-theme.tres" type="Theme" id=2] [ext_resource path="res://assets/ui/sci-fi-godot-theme/sci-fi-theme.tres" type="Theme" id=2]
@ -19,11 +19,14 @@
[ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/ProfilesMenu.gd" type="Script" id=17] [ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/ProfilesMenu.gd" type="Script" id=17]
[ext_resource path="res://assets/ui/fonts/Kenney Thick.ttf" type="DynamicFontData" id=18] [ext_resource path="res://assets/ui/fonts/Kenney Thick.ttf" type="DynamicFontData" id=18]
[ext_resource path="res://assets/ui/fonts/kenny_thick.tres" type="DynamicFont" id=19] [ext_resource path="res://assets/ui/fonts/kenny_thick.tres" type="DynamicFont" id=19]
[ext_resource path="res://addons/controller_icons/objects/Button.gd" type="Script" id=20]
[ext_resource path="res://assets/ui/Screenshot 2023-05-23 160521.png" type="Texture" id=21] [ext_resource path="res://assets/ui/Screenshot 2023-05-23 160521.png" type="Texture" id=21]
[ext_resource path="res://assets/meta/montserrat_extrabold.otf" type="DynamicFontData" id=22] [ext_resource path="res://assets/meta/montserrat_extrabold.otf" type="DynamicFontData" id=22]
[ext_resource path="res://src/UserInterface/Buttons/AudibleButton.gd" type="Script" id=23] [ext_resource path="res://src/UserInterface/Buttons/AudibleButton.gd" type="Script" id=23]
[ext_resource path="res://assets/music/Shopping For The Future (LOOP).wav" type="AudioStream" id=24] [ext_resource path="res://assets/music/Shopping For The Future (LOOP).wav" type="AudioStream" id=24]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/SwapKeysMenu.gd" type="Script" id=25]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/AudioMenu.gd" type="Script" id=26] [ext_resource path="res://src/UserInterface/Screens/MainMenu/AudioMenu.gd" type="Script" id=26]
[ext_resource path="res://addons/controller_icons/assets/key/arrow_down.png" type="Texture" id=27]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/AudioSlider.gd" type="Script" id=28] [ext_resource path="res://src/UserInterface/Screens/MainMenu/AudioSlider.gd" type="Script" id=28]
[ext_resource path="res://src/UserInterface/Buttons/MenuNavigationButton.gd" type="Script" id=29] [ext_resource path="res://src/UserInterface/Buttons/MenuNavigationButton.gd" type="Script" id=29]
@ -71,6 +74,14 @@ shader_param/transparency = 0.778
size = 20 size = 20
font_data = ExtResource( 22 ) font_data = ExtResource( 22 )
[sub_resource type="ShaderMaterial" id=18]
shader = ExtResource( 7 )
shader_param/transparency = 0.778
[sub_resource type="DynamicFont" id=19]
size = 8
font_data = ExtResource( 18 )
[sub_resource type="DynamicFont" id=16] [sub_resource type="DynamicFont" id=16]
size = 42 size = 42
font_data = ExtResource( 22 ) font_data = ExtResource( 22 )
@ -448,6 +459,140 @@ custom_fonts/font = ExtResource( 19 )
text = "Quit Don't Save" text = "Quit Don't Save"
script = ExtResource( 23 ) script = ExtResource( 23 )
[node name="SwapKeysMenu" type="Panel" parent="ControlsMenu"]
unique_name_in_owner = true
visible = false
material = SubResource( 18 )
anchor_right = 1.0
anchor_bottom = 1.0
focus_mode = 2
input_pass_on_modal_close_click = false
script = ExtResource( 25 )
[node name="VBoxContainer2" type="VBoxContainer" parent="ControlsMenu/SwapKeysMenu"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -139.0
margin_top = -123.0
margin_right = 139.0
margin_bottom = 123.0
focus_mode = 2
custom_constants/separation = 30
[node name="Prompt" type="Label" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2"]
margin_right = 278.0
margin_bottom = 21.0
grow_horizontal = 2
mouse_filter = 0
size_flags_horizontal = 3
size_flags_vertical = 0
custom_fonts/font = SubResource( 19 )
text = "selected button already assigned
swap Button actions?"
align = 1
valign = 1
[node name="HBoxContainer" type="HBoxContainer" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2"]
margin_top = 51.0
margin_right = 278.0
margin_bottom = 174.0
custom_constants/separation = 20
alignment = 1
[node name="VBoxContainer" type="VBoxContainer" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2/HBoxContainer"]
margin_left = 15.0
margin_right = 129.0
margin_bottom = 123.0
size_flags_horizontal = 0
size_flags_vertical = 0
[node name="Action1" type="Label" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2/HBoxContainer/VBoxContainer"]
unique_name_in_owner = true
margin_right = 114.0
margin_bottom = 9.0
text = "Action 1"
align = 1
[node name="ControllerButton1" type="Button" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2/HBoxContainer/VBoxContainer"]
unique_name_in_owner = true
margin_top = 13.0
margin_right = 114.0
margin_bottom = 123.0
focus_mode = 0
size_flags_horizontal = 0
size_flags_vertical = 0
shortcut_in_tooltip = false
button_mask = 0
enabled_focus_mode = 0
icon = ExtResource( 27 )
icon_align = 1
script = ExtResource( 20 )
path = "duck"
[node name="VBoxContainer2" type="VBoxContainer" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2/HBoxContainer"]
margin_left = 149.0
margin_right = 263.0
margin_bottom = 123.0
size_flags_horizontal = 0
size_flags_vertical = 0
[node name="Action2" type="Label" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
margin_right = 114.0
margin_bottom = 9.0
text = "Action 2"
align = 1
[node name="ControllerButton2" type="Button" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
margin_top = 13.0
margin_right = 114.0
margin_bottom = 123.0
focus_mode = 0
size_flags_horizontal = 0
size_flags_vertical = 0
shortcut_in_tooltip = false
button_mask = 0
enabled_focus_mode = 0
icon = ExtResource( 27 )
icon_align = 1
script = ExtResource( 20 )
path = "duck"
[node name="VBoxContainer" type="VBoxContainer" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2"]
margin_top = 204.0
margin_right = 278.0
margin_bottom = 246.0
grow_horizontal = 2
grow_vertical = 2
focus_mode = 2
mouse_filter = 0
input_pass_on_modal_close_click = false
size_flags_horizontal = 3
size_flags_vertical = 0
alignment = 1
[node name="Yes" type="Button" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2/VBoxContainer"]
unique_name_in_owner = true
margin_right = 278.0
margin_bottom = 19.0
focus_neighbour_top = NodePath("../No")
focus_neighbour_bottom = NodePath("../No")
text = "Yes"
script = ExtResource( 23 )
[node name="No" type="Button" parent="ControlsMenu/SwapKeysMenu/VBoxContainer2/VBoxContainer"]
unique_name_in_owner = true
margin_top = 23.0
margin_right = 278.0
margin_bottom = 42.0
focus_neighbour_top = NodePath("../Yes")
focus_neighbour_bottom = NodePath("../Yes")
text = "NO"
script = ExtResource( 23 )
[node name="AudioMenu" type="Control" parent="."] [node name="AudioMenu" type="Control" parent="."]
visible = false visible = false
anchor_right = 1.0 anchor_right = 1.0
@ -789,6 +934,8 @@ volume_db = -10.0
[connection signal="button_up" from="ControlsMenu/ReallyQuitMenu/VBoxContainer/SaveNQuit" to="ControlsMenu/ReallyQuitMenu/VBoxContainer/SaveNQuit" method="_on_button_up"] [connection signal="button_up" from="ControlsMenu/ReallyQuitMenu/VBoxContainer/SaveNQuit" to="ControlsMenu/ReallyQuitMenu/VBoxContainer/SaveNQuit" method="_on_button_up"]
[connection signal="button_up" from="ControlsMenu/ReallyQuitMenu/VBoxContainer/ContinueEdit" to="ControlsMenu/ReallyQuitMenu" method="close"] [connection signal="button_up" from="ControlsMenu/ReallyQuitMenu/VBoxContainer/ContinueEdit" to="ControlsMenu/ReallyQuitMenu" method="close"]
[connection signal="button_up" from="ControlsMenu/ReallyQuitMenu/VBoxContainer/QuitDontSave" to="ControlsMenu" method="close"] [connection signal="button_up" from="ControlsMenu/ReallyQuitMenu/VBoxContainer/QuitDontSave" to="ControlsMenu" method="close"]
[connection signal="pressed" from="ControlsMenu/SwapKeysMenu/VBoxContainer2/VBoxContainer/Yes" to="ControlsMenu/SwapKeysMenu" method="swap"]
[connection signal="pressed" from="ControlsMenu/SwapKeysMenu/VBoxContainer2/VBoxContainer/No" to="ControlsMenu/SwapKeysMenu" method="do_not_swap"]
[connection signal="button_up" from="AudioMenu/Panel/Back" to="." method="close_audio_menu"] [connection signal="button_up" from="AudioMenu/Panel/Back" to="." method="close_audio_menu"]
[connection signal="button_up" from="AudioMenu/Panel/Back" to="AudioMenu" method="save"] [connection signal="button_up" from="AudioMenu/Panel/Back" to="AudioMenu" method="save"]
[connection signal="button_up" from="PauseOverlay/Panel/VBoxContainer/Continue" to="PauseOverlay/Panel/VBoxContainer/Continue" method="_on_button_up"] [connection signal="button_up" from="PauseOverlay/Panel/VBoxContainer/Continue" to="PauseOverlay/Panel/VBoxContainer/Continue" method="_on_button_up"]

View File

@ -7,6 +7,12 @@ func clear():
for child in get_children(): for child in get_children():
child.free() child.free()
func get_input_line(action_name) -> Control:
for child in get_children():
if child.action == action_name:
return child
return null
func add_input_line(action_name, event) -> Control: func add_input_line(action_name, event) -> Control:
var line = InputLine.instance() var line = InputLine.instance()
add_child(line) add_child(line)

View File

@ -6,13 +6,15 @@ onready var changes_saved := false
var block_ui_cancel = false var block_ui_cancel = false
func _ready() -> void: func _ready() -> void:
$InputMapper.connect('profile_changed', self, 'rebuild') $InputMapper.connect("profile_changed", self, "rebuild")
$InputMapper.initialize_profiles() $InputMapper.initialize_profiles()
$ProfilesMenu.initialize($InputMapper) $ProfilesMenu.initialize($InputMapper)
$ProfilesMenu.grab_focus() $ProfilesMenu.grab_focus()
$InputMapper.change_profile($ProfilesMenu.selected) $InputMapper.change_profile($ProfilesMenu.selected)
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
# TODO Static quit button esc # TODO Static quit button esc
if !event.is_action("ui_cancel") || !visible: if !event.is_action("ui_cancel") || !visible:
@ -22,15 +24,23 @@ func _input(event: InputEvent) -> void:
get_tree().set_input_as_handled() get_tree().set_input_as_handled()
return return
$"%Back"._on_button_up() $"%Back"._on_button_up()
func rebuild(input_profile) -> void: func rebuild(input_profile) -> void:
_action_list.clear() _action_list.clear()
var first = true var first = true
var prev_line var prev_line
for input_action in input_profile.keys(): for order_action in $InputMapper.profile_order:
if(input_action.ends_with("_old") || input_action.begins_with(("ui_"))):
var input_action := ""
for action in input_profile.keys():
if action == order_action:
input_action = action
if input_action == "":
continue continue
var line = _action_list.add_input_line(input_action, input_profile[input_action]) var line = _action_list.add_input_line(input_action, input_profile[input_action])
# child(2) is the actual button inside the inputline # child(2) is the actual button inside the inputline
if first: if first:
@ -45,7 +55,13 @@ func rebuild(input_profile) -> void:
line.get_child(2).focus_neighbour_left = $"%Back".get_path() line.get_child(2).focus_neighbour_left = $"%Back".get_path()
line.get_child(2).focus_neighbour_right = $"%Save".get_path() line.get_child(2).focus_neighbour_right = $"%Save".get_path()
prev_line = line.get_child(2) prev_line = line.get_child(2)
line.connect('change_button_pressed', self, '_on_InputLine_change_button_pressed', [input_action, line]) line.connect(
"change_button_pressed",
self,
"_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):
var old_event = $InputMapper.get_selected_profile()[action_name] var old_event = $InputMapper.get_selected_profile()[action_name]
@ -53,7 +69,62 @@ func _on_InputLine_change_button_pressed(action_name, line):
var event = yield($"%KeySelectMenu", "key_selected") var event = yield($"%KeySelectMenu", "key_selected")
if event == null: if event == null:
return return
if($InputMapper.change_action_key(action_name, event, old_event)):
#Check if events are basically the same
#TODO Problem with different physical locations of the same key
if "scancode" in old_event && "scancode" in event:
if event.scancode == old_event.scancode:
return
elif event == old_event:
return
var action_with_same_event: String = check_doubled_event(event)
# Routine to swap buttons
# TODO put into function
if action_with_same_event != "":
# Check doubled reads from the InputMap and alternative actions are only virtual
if action_with_same_event == action_name:
action_with_same_event = "alt " + action_name
$"%SwapKeysMenu".open(action_name, action_with_same_event, old_event, event)
var swap = yield($"SwapKeysMenu", "selection_made")
if swap:
swap_buttons(action_name, action_with_same_event, old_event, event)
print("bakayaroo!")
return
if $InputMapper.change_action_key(action_name, event, old_event):
changes_made = true changes_made = true
changes_saved = false changes_saved = false
line.update_key(event) line.update_key(event)
func check_doubled_event(event: InputEvent) -> String:
for action in $InputMapper.get_selected_profile().keys():
if action.begins_with("ui_") || action.ends_with("_old"):
continue
var assigned_event: InputEvent = $InputMapper.get_selected_profile()[action]
if "scancode" in assigned_event && "scancode" in event:
if event.scancode == assigned_event.scancode:
return action
else:
if event == assigned_event:
return action
return ""
func swap_buttons(action1, action2, old_event, new_event) -> void:
var input_line1 = $"%ActionKeyList".get_input_line(action1)
var input_line2 = $"%ActionKeyList".get_input_line(action2)
if $InputMapper.change_action_key(action1, new_event, old_event):
changes_made = true
changes_saved = false
input_line1.update_key(new_event)
else:
return
# Avoid erasing the just assigned "old" event from the input map,
# when swapping alternative button assignments in place
if action1.trim_prefix("alt ") == action2.trim_prefix("alt "):
new_event = old_event
if $InputMapper.change_action_key(action2, old_event, new_event):
input_line2.update_key(old_event)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=28 format=2] [gd_scene load_steps=31 format=2]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/SaveButton.gd" type="Script" id=1] [ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/SaveButton.gd" type="Script" id=1]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/SavedCheckBackButton.gd" type="Script" id=2] [ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/SavedCheckBackButton.gd" type="Script" id=2]
@ -10,6 +10,7 @@
[ext_resource path="res://src/UserInterface/Buttons/AudibleButton.gd" type="Script" id=8] [ext_resource path="res://src/UserInterface/Buttons/AudibleButton.gd" type="Script" id=8]
[ext_resource path="res://assets/environment/background/Spaceship-Wall-Menu.png" type="Texture" id=9] [ext_resource path="res://assets/environment/background/Spaceship-Wall-Menu.png" type="Texture" id=9]
[ext_resource path="res://assets/environment/background/starry-space.png" type="Texture" id=10] [ext_resource path="res://assets/environment/background/starry-space.png" type="Texture" id=10]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/SwapKeysMenu.gd" type="Script" id=11]
[ext_resource path="res://assets/ui/Screenshot 2023-05-23 160521.png" type="Texture" id=12] [ext_resource path="res://assets/ui/Screenshot 2023-05-23 160521.png" type="Texture" id=12]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/ProfilesMenu.gd" type="Script" id=13] [ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/ProfilesMenu.gd" type="Script" id=13]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/ActionKeyList.gd" type="Script" id=14] [ext_resource path="res://src/UserInterface/Screens/MainMenu/ControlsMenu/ActionKeyList.gd" type="Script" id=14]
@ -21,6 +22,8 @@
[ext_resource path="res://assets/ui/sci-fi-godot-theme/sci-fi-theme.tres" type="Theme" id=20] [ext_resource path="res://assets/ui/sci-fi-godot-theme/sci-fi-theme.tres" type="Theme" id=20]
[ext_resource path="res://assets/ui/fonts/Kenney Thick.ttf" type="DynamicFontData" id=21] [ext_resource path="res://assets/ui/fonts/Kenney Thick.ttf" type="DynamicFontData" id=21]
[ext_resource path="res://assets/ui/fonts/kenny_thick.tres" type="DynamicFont" id=22] [ext_resource path="res://assets/ui/fonts/kenny_thick.tres" type="DynamicFont" id=22]
[ext_resource path="res://addons/controller_icons/objects/Button.gd" type="Script" id=23]
[ext_resource path="res://addons/controller_icons/assets/key/arrow_down.png" type="Texture" id=24]
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=1]
size = 42 size = 42
@ -255,6 +258,8 @@ follow_focus = true
[node name="ActionKeyList" type="VBoxContainer" parent="Panel/KeymapViewer/ScrollContainer"] [node name="ActionKeyList" type="VBoxContainer" parent="Panel/KeymapViewer/ScrollContainer"]
unique_name_in_owner = true unique_name_in_owner = true
margin_right = 600.0
margin_bottom = 189.0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
script = ExtResource( 14 ) script = ExtResource( 14 )
@ -421,6 +426,140 @@ text = "Quit Don't Save"
script = ExtResource( 19 ) script = ExtResource( 19 )
next_screen_path = "res://src/UserInterface/Screens/MainMenu/MainScreen.tscn" next_screen_path = "res://src/UserInterface/Screens/MainMenu/MainScreen.tscn"
[node name="SwapKeysMenu" type="Panel" parent="."]
unique_name_in_owner = true
visible = false
material = SubResource( 8 )
anchor_right = 1.0
anchor_bottom = 1.0
focus_mode = 2
input_pass_on_modal_close_click = false
script = ExtResource( 11 )
[node name="VBoxContainer2" type="VBoxContainer" parent="SwapKeysMenu"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -139.0
margin_top = -123.0
margin_right = 139.0
margin_bottom = 123.0
focus_mode = 2
custom_constants/separation = 30
[node name="Prompt" type="Label" parent="SwapKeysMenu/VBoxContainer2"]
margin_right = 278.0
margin_bottom = 21.0
grow_horizontal = 2
mouse_filter = 0
size_flags_horizontal = 3
size_flags_vertical = 0
custom_fonts/font = SubResource( 10 )
text = "selected button already assigned
swap Button actions?"
align = 1
valign = 1
[node name="HBoxContainer" type="HBoxContainer" parent="SwapKeysMenu/VBoxContainer2"]
margin_top = 51.0
margin_right = 278.0
margin_bottom = 174.0
custom_constants/separation = 20
alignment = 1
[node name="VBoxContainer" type="VBoxContainer" parent="SwapKeysMenu/VBoxContainer2/HBoxContainer"]
margin_left = 15.0
margin_right = 129.0
margin_bottom = 123.0
size_flags_horizontal = 0
size_flags_vertical = 0
[node name="Action1" type="Label" parent="SwapKeysMenu/VBoxContainer2/HBoxContainer/VBoxContainer"]
unique_name_in_owner = true
margin_right = 114.0
margin_bottom = 9.0
text = "Action 1"
align = 1
[node name="ControllerButton1" type="Button" parent="SwapKeysMenu/VBoxContainer2/HBoxContainer/VBoxContainer"]
unique_name_in_owner = true
margin_top = 13.0
margin_right = 114.0
margin_bottom = 123.0
focus_mode = 0
size_flags_horizontal = 0
size_flags_vertical = 0
shortcut_in_tooltip = false
button_mask = 0
enabled_focus_mode = 0
icon = ExtResource( 24 )
icon_align = 1
script = ExtResource( 23 )
path = "duck"
[node name="VBoxContainer2" type="VBoxContainer" parent="SwapKeysMenu/VBoxContainer2/HBoxContainer"]
margin_left = 149.0
margin_right = 263.0
margin_bottom = 123.0
size_flags_horizontal = 0
size_flags_vertical = 0
[node name="Action2" type="Label" parent="SwapKeysMenu/VBoxContainer2/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
margin_right = 114.0
margin_bottom = 9.0
text = "Action 2"
align = 1
[node name="ControllerButton2" type="Button" parent="SwapKeysMenu/VBoxContainer2/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
margin_top = 13.0
margin_right = 114.0
margin_bottom = 123.0
focus_mode = 0
size_flags_horizontal = 0
size_flags_vertical = 0
shortcut_in_tooltip = false
button_mask = 0
enabled_focus_mode = 0
icon = ExtResource( 24 )
icon_align = 1
script = ExtResource( 23 )
path = "duck"
[node name="VBoxContainer" type="VBoxContainer" parent="SwapKeysMenu/VBoxContainer2"]
margin_top = 204.0
margin_right = 278.0
margin_bottom = 246.0
grow_horizontal = 2
grow_vertical = 2
focus_mode = 2
mouse_filter = 0
input_pass_on_modal_close_click = false
size_flags_horizontal = 3
size_flags_vertical = 0
alignment = 1
[node name="Yes" type="Button" parent="SwapKeysMenu/VBoxContainer2/VBoxContainer"]
unique_name_in_owner = true
margin_right = 278.0
margin_bottom = 19.0
focus_neighbour_top = NodePath("../No")
focus_neighbour_bottom = NodePath("../No")
text = "Yes"
script = ExtResource( 8 )
[node name="No" type="Button" parent="SwapKeysMenu/VBoxContainer2/VBoxContainer"]
unique_name_in_owner = true
margin_top = 23.0
margin_right = 278.0
margin_bottom = 42.0
focus_neighbour_top = NodePath("../Yes")
focus_neighbour_bottom = NodePath("../Yes")
text = "NO"
script = ExtResource( 8 )
[connection signal="button_up" from="Panel/Back" to="Panel/Back" method="_on_button_up"] [connection signal="button_up" from="Panel/Back" to="Panel/Back" method="_on_button_up"]
[connection signal="button_up" from="Panel/Reset" to="Panel/Reset" method="_on_button_up"] [connection signal="button_up" from="Panel/Reset" to="Panel/Reset" method="_on_button_up"]
[connection signal="button_up" from="Panel/Save" to="Panel/Save" method="_on_button_up"] [connection signal="button_up" from="Panel/Save" to="Panel/Save" method="_on_button_up"]
@ -429,3 +568,5 @@ next_screen_path = "res://src/UserInterface/Screens/MainMenu/MainScreen.tscn"
[connection signal="button_up" from="ReallyQuitMenu/VBoxContainer/SaveNQuit" to="ReallyQuitMenu/VBoxContainer/SaveNQuit" method="_on_button_up"] [connection signal="button_up" from="ReallyQuitMenu/VBoxContainer/SaveNQuit" to="ReallyQuitMenu/VBoxContainer/SaveNQuit" method="_on_button_up"]
[connection signal="button_up" from="ReallyQuitMenu/VBoxContainer/ContinueEdit" to="ReallyQuitMenu" method="close"] [connection signal="button_up" from="ReallyQuitMenu/VBoxContainer/ContinueEdit" to="ReallyQuitMenu" method="close"]
[connection signal="button_up" from="ReallyQuitMenu/VBoxContainer/QuitDontSave" to="ReallyQuitMenu/VBoxContainer/QuitDontSave" method="_on_button_up"] [connection signal="button_up" from="ReallyQuitMenu/VBoxContainer/QuitDontSave" to="ReallyQuitMenu/VBoxContainer/QuitDontSave" method="_on_button_up"]
[connection signal="pressed" from="SwapKeysMenu/VBoxContainer2/VBoxContainer/Yes" to="SwapKeysMenu" method="swap"]
[connection signal="pressed" from="SwapKeysMenu/VBoxContainer2/VBoxContainer/No" to="SwapKeysMenu" method="do_not_swap"]

View File

@ -5,8 +5,10 @@ signal change_button_pressed
export var button_size: Vector2 = Vector2(30, 30) export var button_size: Vector2 = Vector2(30, 30)
export var interactable: bool = false export var interactable: bool = false
onready var action = ""
func initialize(action_name, event): func initialize(action_name, event):
action = action_name
$Action.text = action_name.capitalize() $Action.text = action_name.capitalize()
$Key.add_child(create_controller_button(event)) $Key.add_child(create_controller_button(event))

View File

@ -5,63 +5,89 @@ 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'
} }
var profile_order = ["move_left", "alt move_left", "move_right", "alt move_right", "jump", "run", "duck",
"alt duck", "up", "alt up", "interact", "pause"]
var keyboard = {} var keyboard = {}
var controller = {} var controller = {}
func change_profile(id): func change_profile(id: int) -> Dictionary:
current_profile_id = id current_profile_id = id
var profile = get(profiles[id]) var profile = get(profiles[id])
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])
emit_signal('profile_changed', profile)
return profile emit_signal('profile_changed', profile)
return profile
func commit_to_changes(): func commit_to_changes() -> void:
for profile_name in profiles.values(): for profile_name in profiles.values():
var profile = get(profile_name) var profile = get(profile_name)
for action_name in profile.keys(): for action_name in profile.keys():
if(action_name.ends_with("_old")): if(action_name.ends_with("_old")):
continue continue
erase_old_action_event(action_name) erase_old_action_event(action_name)
profile[action_name + "_old"] = profile[action_name] profile[action_name + "_old"] = profile[action_name]
InputMap.action_add_event(action_name, profile[action_name]) var a_name = action_name
# Assign the alternative event to the same action as the regular event
if(action_name.begins_with("alt")):
action_name = action_name.trim_prefix("alt ")
InputMap.action_add_event(action_name, profile[a_name])
func change_action_key(action_name, event, old_event = null) -> bool: func change_action_key(action_name, event, old_event = null) -> bool:
if(old_event != null): if(old_event != null):
if(event.as_text().match("*Joy*") != old_event.as_text().match("*Joy*")): if(event.as_text().match("*Joy*") != old_event.as_text().match("*Joy*")):
return false return false
get_selected_profile()[action_name+"_old"] = old_event get_selected_profile()[action_name+"_old"] = old_event
get_selected_profile()[action_name] = event get_selected_profile()[action_name] = event
return true return true
func erase_old_action_event(action_name): func erase_old_action_event(action_name: String) -> void:
if(get_selected_profile().has(action_name+"_old")): if(get_selected_profile().has(action_name+"_old")):
var old_event = get_selected_profile()[action_name+"_old"] var old_event = get_selected_profile()[action_name+"_old"]
var event = get_selected_profile()[action_name] var event = get_selected_profile()[action_name]
if(old_event != event): if(old_event != event):
InputMap.action_erase_event(action_name, old_event) if(action_name.begins_with("alt")):
action_name = action_name.trim_prefix("alt ")
InputMap.action_erase_event(action_name, old_event)
func initialize_profiles() -> void: func initialize_profiles() -> void:
var actions: Array = InputMap.get_actions() var actions: Array = InputMap.get_actions()
actions.sort() actions.sort()
for action in actions: for action in actions:
var input_events = InputMap.get_action_list(action) var input_events: Array = InputMap.get_action_list(action)
for event in input_events: var controller_events: Array = []
if event.as_text().match("*JoypadButton*"): var keyboard_events: Array = []
controller[action] = event
controller[action+"_old"] = event for input_event in input_events:
elif !event.as_text().match("*Joy*"): if input_event.as_text().match("*Joypad*"):
keyboard[action] = event controller_events.append(input_event)
keyboard[action+"_old"] = event if !input_event.as_text().match("*Joy*"):
change_profile(current_profile_id) keyboard_events.append(input_event)
if controller_events.size() > 0:
controller[action] = controller_events[0]
controller[action+"_old"] = controller_events[0]
if controller_events.size() > 1:
controller["alt " + action] = controller_events[1]
controller["alt " + action +"_old"] = controller_events[1]
if keyboard_events.size() > 0:
keyboard[action] = keyboard_events[0]
keyboard[action + "_old"] = keyboard_events[0]
if keyboard_events.size() > 1:
keyboard["alt " + action] = keyboard_events[1]
keyboard["alt " + action + "_old"] = keyboard_events[1]
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])
func _on_ProfilesMenu_item_selected(ID): func _on_ProfilesMenu_item_selected(ID):
change_profile(ID) change_profile(ID)

View File

@ -17,8 +17,8 @@ func _input(event: InputEvent) -> void:
event = null event = null
accept_event() accept_event()
get_tree().set_input_as_handled() get_tree().set_input_as_handled()
emit_signal("key_selected", event)
close() close()
emit_signal("key_selected", event)
func open(): func open():
show() show()

View File

@ -3,22 +3,22 @@ extends Panel
var prev_focus var prev_focus
func open(): func open():
visible = true visible = true
prev_focus = get_focus_owner() prev_focus = get_focus_owner()
mitigate_ui_navigation_spill_over(true) mitigate_ui_navigation_spill_over(true)
$"%SaveNQuit".grab_focus() $"%SaveNQuit".grab_focus()
func mitigate_ui_navigation_spill_over(var value: bool): func mitigate_ui_navigation_spill_over(var value: bool):
var mode = Control.FOCUS_NONE if value else Control.FOCUS_ALL var mode = Control.FOCUS_NONE if value else Control.FOCUS_ALL
$"%ProfilesMenu".focus_mode = mode $"%ProfilesMenu".focus_mode = mode
$"%Back".focus_mode = mode $"%Back".focus_mode = mode
$"%Reset".focus_mode = mode $"%Reset".focus_mode = mode
$"%Save".focus_mode = mode $"%Save".focus_mode = mode
for line in $"%ActionKeyList".get_children(): for line in $"%ActionKeyList".get_children():
line.get_node("ChangeButton").focus_mode = mode line.get_node("ChangeButton").focus_mode = mode
func close(): func close():
visible = false visible = false
mitigate_ui_navigation_spill_over(false) mitigate_ui_navigation_spill_over(false)
self.release_focus() self.release_focus()
prev_focus.grab_focus() prev_focus.grab_focus()

View File

@ -3,6 +3,6 @@ extends AudibleButton
onready var mapper := $"%InputMapper" 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() mapper.initialize_profiles()
SaveManager.save_default() SaveManager.save_default()

View File

@ -4,7 +4,7 @@ onready var mapper := $"%InputMapper"
onready var controllsMenu := $"../.." onready var controllsMenu := $"../.."
func _on_button_up() -> void: func _on_button_up() -> void:
mapper.commit_to_changes() mapper.commit_to_changes()
SaveManager.save_default() SaveManager.save_default()
controllsMenu.changes_saved = true controllsMenu.changes_saved = true
controllsMenu.changes_made = false controllsMenu.changes_made = false

View File

@ -0,0 +1,53 @@
extends Panel
signal selection_made(result)
var prev_focus
var selected_action
var action_with_same_event
var new_event_for_selected_action
var old_event_for_selected_action
func open(selected_action: String, action_with_same_event: String,
old_event_for_selected_action: InputEvent, new_event_for_selected_action: InputEvent) -> void:
prev_focus = get_focus_owner()
self.selected_action = selected_action
self.action_with_same_event = action_with_same_event
self.new_event_for_selected_action = new_event_for_selected_action
self.old_event_for_selected_action = old_event_for_selected_action
$"%Action1".text = selected_action
var event_path1 = ControllerIcons._convert_event_to_path(old_event_for_selected_action)
$"%ControllerButton1".path = event_path1
$"%Action2".text = action_with_same_event
var event_path2 = ControllerIcons._convert_event_to_path(new_event_for_selected_action)
$"%ControllerButton2".path = event_path2
visible = true
mitigate_ui_navigation_spill_over(true)
$"%Yes".grab_focus()
func mitigate_ui_navigation_spill_over(var value: bool):
var mode = Control.FOCUS_NONE if value else Control.FOCUS_ALL
var inverse_mode = Control.FOCUS_ALL if value else Control.FOCUS_NONE
$"%No".focus_mode = inverse_mode
$"%Yes".focus_mode = inverse_mode
for line in $"%ActionKeyList".get_children():
line.get_node("ChangeButton").focus_mode = mode
func close() -> void:
visible = false
mitigate_ui_navigation_spill_over(false)
prev_focus.set_focus_mode(Control.FOCUS_ALL)
prev_focus.grab_focus()
func swap() -> void:
close()
emit_signal("selection_made", true)
func do_not_swap() -> void:
close()
emit_signal("selection_made", false)

View File

@ -11,8 +11,8 @@ func initialize_with_progress(levelFullName: String) -> void:
var level_time : float = GlobalState.get_level_time(levelFullName) var level_time : float = GlobalState.get_level_time(levelFullName)
if(GlobalState.get_level_completed(levelFullName)): if(GlobalState.get_level_completed(levelFullName)):
$LevelTime.visible = true $"%LevelTime".visible = true
$LevelTime.text = "Time " + str(round(level_time*1000)/1000) + " sec" $"%LevelTime".text = "Time " + str(round(level_time*1000)/1000) + " sec"
func register_froggy(var count : int = 0, var freed: bool = false) -> void: func register_froggy(var count : int = 0, var freed: bool = false) -> void:

View File

@ -45,9 +45,9 @@ script = ExtResource( 4 )
[node name="FreedFroggy1" type="TextureRect" parent="."] [node name="FreedFroggy1" type="TextureRect" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
margin_top = 28.0 margin_top = 21.0
margin_right = 119.0 margin_right = 126.0
margin_bottom = 47.0 margin_bottom = 40.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
focus_mode = 2 focus_mode = 2
@ -163,10 +163,12 @@ size_flags_vertical = 3
texture = ExtResource( 2 ) texture = ExtResource( 2 )
[node name="LevelTime" type="Label" parent="."] [node name="LevelTime" type="Label" parent="."]
unique_name_in_owner = true
visible = false visible = false
margin_top = 21.0 margin_top = 21.0
margin_right = 126.0 margin_right = 126.0
margin_bottom = 32.0 margin_bottom = 32.0
focus_mode = 2
custom_colors/font_color = Color( 0.717647, 0.717647, 0.717647, 1 ) custom_colors/font_color = Color( 0.717647, 0.717647, 0.717647, 1 )
custom_fonts/font = SubResource( 13 ) custom_fonts/font = SubResource( 13 )
text = "Time: 10 sec" text = "Time: 10 sec"