rebinding keys in effect! credits now on StartMenu & new key added to UI! (-;

This commit is contained in:
Harmony Honey 2024-01-23 00:54:53 -05:00
parent d7c775592a
commit f7e173385f
11 changed files with 334 additions and 326 deletions

View file

@ -194,8 +194,7 @@ ui_home={
}
ui_end={
"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":16777224,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [ ]
}
ui_up={
"deadzone": 0.5,
@ -221,6 +220,15 @@ ui_right={
, 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)
]
}
ui_pause={
"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":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":10,"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":80,"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":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
ui_yes={
"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":75,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
@ -235,13 +243,9 @@ ui_no={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
ui_pause={
ui_del={
"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":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":10,"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":80,"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":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777224,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
up={

View file

@ -213,7 +213,7 @@ func change_map():
elif is_level_select:
is_replay = false
is_replay_note = false
UI.keys()
UI.keys(true, true)
TouchScreen.turn_arrows(false)
TouchScreen.show_keys(true, true, true, true)
@ -228,9 +228,6 @@ func change_map():
UI.keys(false, false)
TouchScreen.turn_arrows(true)
TouchScreen.show_keys(true, false, true)
elif scene_path == credits_path:
UI.keys(true, false, false, false)
TouchScreen.show_keys(false, true, false)
elif scene_path == creator_path:
UI.keys(false, false, true, true, true, true)

View file

@ -1,12 +1,14 @@
extends CanvasLayer
onready var bottom := $Center/Control/Bottom
onready var arrows := $Center/Control/Bottom/Arrows
onready var spacer := $Center/Control/Bottom/Spacer
onready var x := $Center/Control/Bottom/Keys/X
onready var x_label := $Center/Control/Bottom/Keys/X/Desc
onready var c := $Center/Control/Bottom/Keys/C
onready var c_label := $Center/Control/Bottom/Keys/C/Desc
onready var arrows := $Center/Control/Bottom/Arrows
onready var spacer := $Center/Control/Bottom/Spacer
onready var v := $Center/Control/Bottom/Keys/V
onready var v_label := $Center/Control/Bottom/Keys/V/Desc
onready var top := $Center/Control/Top
onready var pause_label := $Center/Control/Top/P/Desc
@ -33,18 +35,20 @@ func _ready():
map.visible = false
stats.visible = false
func keys(is_expand := true, _top := false, _arrows := true, left := true, right := true, _stack := false):
func keys(is_expand := true, _top := false, _arrows := true, _x := true, _c := true, _stack := false, _v := false):
spacer.size_flags_horizontal = spacer.SIZE_EXPAND_FILL if is_expand else spacer.SIZE_FILL
top.visible = _top
arrows.visible = _arrows
x.visible = left
c.visible = right
x.visible = _x
c.visible = _c
bottom.columns = 2 if _stack or !_arrows else 3
v.visible = _v
func labels(_x := "pick", _c := "back", _pause := "pause"):
func labels(_x := "pick", _c := "back", _pause := "pause", _v := "clear"):
x_label.text = _x
c_label.text = _c
pause_label.text = _pause
v_label.text = _v
func show_stats():
var m = {}

View file

@ -79,13 +79,15 @@ margin_left = 5.0
margin_top = 83.0
margin_right = 223.0
margin_bottom = 121.0
custom_constants/vseparation = 0
custom_constants/hseparation = 2
columns = 2
[node name="Arrows" type="HBoxContainer" parent="Center/Control/Bottom"]
visible = false
margin_top = 10.0
margin_top = 12.0
margin_right = 50.0
margin_bottom = 17.0
margin_bottom = 19.0
size_flags_vertical = 10
custom_constants/separation = 3
@ -95,23 +97,23 @@ margin_bottom = 7.0
custom_constants/separation = 1
[node name="Key" parent="Center/Control/Bottom/Arrows/HBoxContainer" instance=ExtResource( 7 )]
action = "left"
action = "ui_left"
[node name="Key4" parent="Center/Control/Bottom/Arrows/HBoxContainer" instance=ExtResource( 7 )]
margin_left = 8.0
margin_right = 15.0
action = "down"
action = "ui_down"
text = "down"
[node name="Key3" parent="Center/Control/Bottom/Arrows/HBoxContainer/Key4" instance=ExtResource( 7 )]
margin_top = -8.0
margin_bottom = -1.0
action = "up"
action = "ui_up"
[node name="Key2" parent="Center/Control/Bottom/Arrows/HBoxContainer" instance=ExtResource( 7 )]
margin_left = 16.0
margin_right = 23.0
action = "right"
action = "ui_right"
text = "right"
[node name="Desc" type="Label" parent="Center/Control/Bottom/Arrows"]
@ -123,26 +125,28 @@ custom_fonts/font = SubResource( 3 )
text = "move"
[node name="Spacer" type="Control" parent="Center/Control/Bottom"]
margin_right = 174.0
margin_right = 158.0
margin_bottom = 38.0
size_flags_horizontal = 3
[node name="Keys" type="VBoxContainer" parent="Center/Control/Bottom"]
margin_left = 178.0
margin_top = 21.0
margin_left = 160.0
margin_top = 11.0
margin_right = 218.0
margin_bottom = 38.0
size_flags_horizontal = 0
size_flags_vertical = 10
custom_constants/separation = 3
alignment = 2
[node name="X" type="HBoxContainer" parent="Center/Control/Bottom/Keys"]
margin_right = 40.0
margin_left = 24.0
margin_right = 58.0
margin_bottom = 7.0
size_flags_horizontal = 10
custom_constants/separation = 3
[node name="Key" parent="Center/Control/Bottom/Keys/X" instance=ExtResource( 7 )]
action = "ui_yes"
text = "x"
[node name="Desc" type="Label" parent="Center/Control/Bottom/Keys/X"]
@ -154,14 +158,16 @@ custom_fonts/font = SubResource( 3 )
text = "pick"
[node name="C" type="HBoxContainer" parent="Center/Control/Bottom/Keys"]
margin_left = 18.0
margin_top = 10.0
margin_right = 40.0
margin_right = 58.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( -248, -67 )
size_flags_horizontal = 10
custom_constants/separation = 3
[node name="Key" parent="Center/Control/Bottom/Keys/C" instance=ExtResource( 7 )]
action = "action"
action = "ui_no"
text = "c"
[node name="Desc" type="Label" parent="Center/Control/Bottom/Keys/C"]
@ -172,6 +178,28 @@ margin_bottom = 6.0
custom_fonts/font = SubResource( 3 )
text = "erase"
[node name="V" type="HBoxContainer" parent="Center/Control/Bottom/Keys"]
margin_top = 20.0
margin_right = 58.0
margin_bottom = 27.0
rect_pivot_offset = Vector2( -248, -67 )
size_flags_horizontal = 10
custom_constants/separation = 3
[node name="Key" parent="Center/Control/Bottom/Keys/V" instance=ExtResource( 7 )]
margin_right = 19.0
rect_min_size = Vector2( 19, 7 )
action = "ui_del"
text = "del"
[node name="Desc" type="Label" parent="Center/Control/Bottom/Keys/V"]
margin_left = 22.0
margin_top = 1.0
margin_right = 58.0
margin_bottom = 6.0
custom_fonts/font = SubResource( 3 )
text = "unbind"
[node name="Map" type="Control" parent="Center/Control"]
visible = false
margin_right = 40.0

View file

@ -14,6 +14,8 @@ onready var open_player_mat : ShaderMaterial = get_node(open_player_path).materi
export var demo_player_path : NodePath = ""
onready var demo_player_mat : ShaderMaterial = get_node(demo_player_path).sprite_mat
onready var credits_node := $Credits
var cursor := 0 setget set_cursor
var menu_items := []
var main_items := ["play", "options", "credits"]
@ -26,6 +28,7 @@ var menu_name := "main"
var menu_last := menu_name
var is_input = true
export var is_credits := false
export var cursor_offset := Vector2.ZERO
export var cursor_expand := Vector2.ZERO
@ -45,7 +48,7 @@ func _ready():
switch_menu(Shared.last_menu, true)
self.cursor = Shared.last_cursor
credits_node.visible = false
func setup_slots():
var slot_items := slot_menu.get_children()
@ -78,7 +81,17 @@ func setup_slots():
func _input(event):
if !is_input or Wipe.is_wipe or switch_clock > 0.0: return
if event.is_action_pressed("ui_no"):
var is_no : bool = event.is_action_pressed("ui_no")
if is_credits:
if is_no:
is_credits = false
credits_node.visible = false
resume()
return
else: return
if is_no:
if menu_items == open_items:
Player.set_palette(demo_player_mat, Shared.pick_player_colors())
var s = "main"
@ -122,8 +135,13 @@ func menu_select(tag : String = menu_items[cursor].to_lower()):
Shared.cam.pos_target += Vector2(24, -4)
control.visible = false
"credits":
Shared.wipe_scene(Shared.credits_path)
is_credits = true
credits_node.visible = true
control.visible = false
Shared.cam.pos_target += Vector2(104, 0)
Audio.play("menu_pick", 0.9, 1.1)
UI.keys(false, false, false, false)
TouchScreen.show_keys(false, true, false)
"yes":
Audio.play("menu_yes", 0.9, 1.1)
if OS.get_name() == "HTML5":

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=35 format=2]
[gd_scene load_steps=38 format=2]
[ext_resource path="res://media/image/creator.png" type="Texture" id=1]
[ext_resource path="res://media/image/crate_tiles.png" type="Texture" id=2]
@ -22,7 +22,9 @@
[ext_resource path="res://media/image/diamond8.png" type="Texture" id=20]
[ext_resource path="res://src/menu/Blink.gd" type="Script" id=21]
[ext_resource path="res://src/actor/Exit.tscn" type="PackedScene" id=22]
[ext_resource path="res://media/font/m6x11.ttf" type="DynamicFontData" id=23]
[ext_resource path="res://media/font/QuinqueFive.ttf" type="DynamicFontData" id=24]
[ext_resource path="res://media/font/m3x6.tres" type="DynamicFont" id=25]
[sub_resource type="DynamicFont" id=3]
extra_spacing_top = -3
@ -167,6 +169,10 @@ font_data = ExtResource( 5 )
size = 5
font_data = ExtResource( 24 )
[sub_resource type="DynamicFont" id=18]
extra_spacing_bottom = -1
font_data = ExtResource( 23 )
[sub_resource type="TileSet" id=13]
0/name = "solid_bricks.png 0"
0/texture = ExtResource( 17 )
@ -816,6 +822,49 @@ text = "hhoney.net"
align = 2
valign = 2
[node name="Credits" type="Control" parent="."]
margin_left = 136.0
margin_top = 12.0
margin_right = 176.0
margin_bottom = 52.0
[node name="Header" type="Label" parent="Credits"]
margin_top = 11.0
margin_right = 228.0
margin_bottom = 24.0
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_constants/shadow_as_outline = 1
custom_fonts/font = SubResource( 18 )
text = "TINY CRATE"
align = 1
[node name="By" type="Label" parent="Credits"]
margin_left = 105.0
margin_top = 25.0
margin_right = 115.0
margin_bottom = 35.0
custom_fonts/font = ExtResource( 25 )
text = "by"
align = 1
valign = 1
[node name="HarmonyHoneyLogo" type="Sprite" parent="Credits"]
position = Vector2( 114, 49 )
texture = ExtResource( 4 )
[node name="List" type="Label" parent="Credits"]
margin_top = 59.0
margin_right = 228.0
margin_bottom = 128.0
custom_fonts/font = ExtResource( 25 )
text = "hhoney.net
Made with Godot Engine
Fonts by Daniel Linssen"
align = 1
valign = 1
[node name="Stage" type="Node2D" parent="."]
[node name="SolidTileMap" parent="Stage" instance=ExtResource( 11 )]

View file

@ -1,8 +0,0 @@
extends Node2D
func _input(event):
if Wipe.is_wipe: return
if event.is_action_pressed("ui_no"):
Shared.wipe_scene(Shared.main_menu_path)
Audio.play("menu_back", 0.9, 1.1)

View file

@ -1,189 +0,0 @@
[gd_scene load_steps=18 format=2]
[ext_resource path="res://media/font/m3x6.tres" type="DynamicFont" id=1]
[ext_resource path="res://src/stage/DetailTileMap.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/stage/SolidTileMap.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/menu/credits.gd" type="Script" id=4]
[ext_resource path="res://media/image/crate_tiles.png" type="Texture" id=5]
[ext_resource path="res://src/stage/GameCamera.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/actor/Exit.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/actor/Box.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/actor/Player.tscn" type="PackedScene" id=9]
[ext_resource path="res://media/font/m6x11.ttf" type="DynamicFontData" id=10]
[ext_resource path="res://media/image/HarmonyHoneyLogo.png" type="Texture" id=11]
[ext_resource path="res://media/image/bricks.png" type="Texture" id=12]
[ext_resource path="res://media/image/8pixel.png" type="Texture" id=13]
[ext_resource path="res://media/image/solid_bricks.png" type="Texture" id=14]
[sub_resource type="DynamicFont" id=1]
extra_spacing_bottom = -1
font_data = ExtResource( 10 )
[sub_resource type="TileSet" id=2]
0/name = "solid_bricks.png 0"
0/texture = ExtResource( 14 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 0.760784, 0.764706, 0.780392, 1 )
0/region = Rect2( 0, 0, 16, 8 )
0/tile_mode = 2
0/autotile/icon_coordinate = Vector2( 0, 0 )
0/autotile/tile_size = Vector2( 8, 8 )
0/autotile/spacing = 0
0/autotile/occluder_map = [ ]
0/autotile/navpoly_map = [ ]
0/autotile/priority_map = [ ]
0/autotile/z_index_map = [ ]
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape_one_way = false
0/shape_one_way_margin = 0.0
0/shapes = [ ]
0/z_index = 0
1/name = "8pixel.png 1"
1/texture = ExtResource( 13 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 0, 1, 0.33 )
1/region = Rect2( 0, 0, 8, 8 )
1/tile_mode = 0
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )
1/shape_offset = Vector2( 0, 0 )
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
1/shape_one_way = false
1/shape_one_way_margin = 0.0
1/shapes = [ ]
1/z_index = 0
[sub_resource type="TileSet" id=3]
4/name = "bricks.png 4"
4/texture = ExtResource( 12 )
4/tex_offset = Vector2( 0, 0 )
4/modulate = Color( 0.372549, 0.341176, 0.309804, 1 )
4/region = Rect2( 0, 0, 40, 8 )
4/tile_mode = 2
4/autotile/icon_coordinate = Vector2( 0, 0 )
4/autotile/tile_size = Vector2( 8, 8 )
4/autotile/spacing = 0
4/autotile/occluder_map = [ ]
4/autotile/navpoly_map = [ ]
4/autotile/priority_map = [ ]
4/autotile/z_index_map = [ ]
4/occluder_offset = Vector2( 0, 0 )
4/navigation_offset = Vector2( 0, 0 )
4/shape_offset = Vector2( 0, 0 )
4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
4/shape_one_way = false
4/shape_one_way_margin = 0.0
4/shapes = [ ]
4/z_index = 0
5/name = "crate_tiles.png 5"
5/texture = ExtResource( 5 )
5/tex_offset = Vector2( 0, 0 )
5/modulate = Color( 0, 0.529412, 0.317647, 1 )
5/region = Rect2( 0, 16, 24, 8 )
5/tile_mode = 2
5/autotile/icon_coordinate = Vector2( 0, 0 )
5/autotile/tile_size = Vector2( 8, 8 )
5/autotile/spacing = 0
5/autotile/occluder_map = [ ]
5/autotile/navpoly_map = [ ]
5/autotile/priority_map = [ ]
5/autotile/z_index_map = [ ]
5/occluder_offset = Vector2( 0, 0 )
5/navigation_offset = Vector2( 0, 0 )
5/shape_offset = Vector2( 0, 0 )
5/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
5/shape_one_way = false
5/shape_one_way_margin = 0.0
5/shapes = [ ]
5/z_index = 0
6/name = "crate_tiles.png 6"
6/texture = ExtResource( 5 )
6/tex_offset = Vector2( 0, 0 )
6/modulate = Color( 0.670588, 0.321569, 0.211765, 1 )
6/region = Rect2( 0, 24, 8, 8 )
6/tile_mode = 0
6/occluder_offset = Vector2( 0, 0 )
6/navigation_offset = Vector2( 0, 0 )
6/shape_offset = Vector2( 0, 0 )
6/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
6/shape_one_way = false
6/shape_one_way_margin = 0.0
6/shapes = [ ]
6/z_index = 0
[node name="Credits" type="Node2D"]
script = ExtResource( 4 )
[node name="Header" type="Label" parent="."]
margin_left = -2.0
margin_top = 11.0
margin_right = 226.0
margin_bottom = 24.0
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_constants/shadow_as_outline = 1
custom_fonts/font = SubResource( 1 )
text = "TINY CRATE"
align = 1
[node name="By" type="Label" parent="."]
margin_left = 103.0
margin_top = 25.0
margin_right = 113.0
margin_bottom = 35.0
custom_fonts/font = ExtResource( 1 )
text = "by"
align = 1
valign = 1
[node name="HarmonyHoneyLogo" type="Sprite" parent="."]
position = Vector2( 112, 49 )
texture = ExtResource( 11 )
[node name="List" type="Label" parent="."]
margin_left = -2.0
margin_top = 59.0
margin_right = 226.0
margin_bottom = 128.0
custom_fonts/font = ExtResource( 1 )
text = "hhoney.net
Made with Godot Engine
Fonts by Daniel Linssen"
align = 1
valign = 1
[node name="Stage" type="Node2D" parent="."]
[node name="SolidTileMap" parent="Stage" instance=ExtResource( 3 )]
tile_set = SubResource( 2 )
tile_data = PoolIntArray( -65531, 0, 1, 5, 536870912, 0, 65541, 0, 1, 131077, 0, 0, 196613, 0, 1, 262149, 536870912, 0, 327685, 0, 0, 393221, 0, 1, 524287, 0, 1, 458752, 0, 0, 458753, 0, 1, 458754, 536870912, 0, 458755, 0, 1, 458756, 0, 1, 458757, 0, 0, 458758, 0, 1, 458759, 536870912, 0, 589845, 536870912, 0, 589846, 0, 1, 589847, 0, 0, 589848, 0, 1, 589849, 0, 1, 589850, 536870912, 0, 589851, 0, 1, 589852, 0, 1, 655381, 0, 1, 720917, 536870912, 0, 786453, 0, 0, 786454, 0, 1, 786455, 536870912, 0, 851991, 0, 1, 917527, 0, 0, 983063, 536870912, 0, 1048599, 0, 1 )
[node name="DetailTileMap" parent="Stage" instance=ExtResource( 2 )]
z_index = -11
tile_set = SubResource( 3 )
tile_data = PoolIntArray( -1, 4, 0, -65536, 536870916, 1, -65535, 4, 0, -65532, 5, 0, -65529, 536870916, 3, -65528, 536870916, 1, -65527, 536870916, 0, -65526, 4, 3, -65510, 536870916, 0, -65509, 4, 1, -65508, 4, 1, 65535, 536870916, 1, 0, 536870916, 0, 1, 536870916, 2, 4, -1073741819, 0, 7, 4, 2, 8, 4, 0, 9, 536870916, 1, 10, 536870916, 2, 17, 4, 2, 18, 536870916, 0, 19, 4, 1, 20, 4, 1, 21, 4, 0, 22, 536870916, 2, 26, 4, 2, 27, 4, 0, 28, 4, 1, 131071, 4, 0, 65536, 536870916, 2, 65540, -1073741819, 0, 65543, 536870916, 3, 65544, 536870916, 2, 65555, 4, 2, 65556, 4, 1, 65557, 536870916, 2, 65563, 4, 2, 65564, 536870916, 0, 131076, -1073741819, 0, 131095, 5, 2, 131096, 5, 0, 131097, -1610612731, 2, 196612, -1073741819, 2, 196614, 536870917, 2, 196631, 5, 0, 196632, 5, 0, 196633, 5, 0, 196634, -1610612731, 2, 262150, -1610612731, 0, 262166, -1610612731, 0, 262167, 5, 0, 262168, 5, 0, 262169, 5, 0, 262170, -1073741819, 0, 327686, -1610612731, 0, 327702, -1073741819, 2, 327703, 5, 0, 327704, 5, 0, 327705, 5, 0, 458751, 5, 0, 393216, 5, 0, 393217, 536870917, 2, 393220, 5, 2, 393222, -536870907, 2, 393239, -1073741819, 2, 393240, 5, 0, 393241, 1610612741, 2, 393242, 536870916, 3, 393243, 536870916, 1, 393244, 536870916, 1, 458776, 6, 0, 458778, 4, 2, 458779, 536870916, 0, 458780, 536870916, 1, 524289, 1073741829, 2, 524290, 5, 0, 524291, 6, 0, 524292, 1610612741, 2, 524312, 6, 0, 524313, 536870917, 2, 655359, 536870916, 1, 589824, 4, 3, 589827, 6, 0, 720895, 536870916, 1, 655360, 536870916, 2, 655362, 5, 2, 655363, 6, 0, 655364, 5, 0, 655365, -1610612731, 2, 655380, 5, 2, 655382, 5, 0, 655383, 5, 0, 655384, 5, 0, 655385, 1610612741, 2, 720897, 5, 2, 720898, 5, 0, 720899, 5, 0, 720900, -1610612730, 0, 720901, -1610612730, 0, 720902, -1610612730, 0, 720903, -1610612731, 2, 720916, -1073741819, 0, 720922, 4, 2, 720923, 4, 0, 720924, 4, 1, 786433, 5, 0, 786434, 1610612742, 0, 786435, 5, 0, 786436, 5, 0, 786452, -1073741819, 2, 786456, -1610612731, 2, 786459, 4, 2, 786460, 536870916, 1, 851969, -1073741819, 2, 851970, 5, 0, 851971, -1073741818, 0, 851972, -1073741818, 0, 851973, -536870907, 2, 851992, 5, 0, 983039, 536870916, 0, 917504, 4, 3, 917506, -1073741819, 2, 917507, 5, 0, 917508, 1610612741, 2, 917528, 5, 0, 917531, 536870916, 3, 917532, 4, 0, 1048575, 4, 1, 983040, 4, 0, 983041, 4, 3, 983052, 536870916, 3, 983053, 4, 1, 983054, 4, 0, 983055, 4, 3, 983062, -2147483643, 2, 983064, 1610612741, 2, 983066, 536870916, 3, 983067, 536870916, 0, 983068, 536870916, 1, 1114111, 4, 1, 1048576, 4, 1, 1048577, 536870916, 0, 1048588, 4, 2, 1048589, 536870916, 1, 1048590, 536870916, 1, 1048591, 536870916, 2, 1048598, -2147483643, 0, 1048602, 4, 0, 1048603, 536870916, 1, 1048604, 4, 0 )
[node name="GameCamera" parent="Stage" instance=ExtResource( 6 )]
position = Vector2( 112, 64 )
[node name="Actors" type="Node2D" parent="Stage"]
[node name="Exit" parent="Stage/Actors" instance=ExtResource( 7 )]
position = Vector2( 13, 21 )
[node name="Box" parent="Stage/Actors" instance=ExtResource( 8 )]
position = Vector2( 19, 48 )
[node name="Player" parent="Stage/Actors" instance=ExtResource( 9 )]
position = Vector2( 172, 64 )
is_attract_mode = true
[node name="Sprite" parent="Stage/Actors/Player" index="0"]
flip_h = true
[editable path="Stage/GameCamera"]
[editable path="Stage/Actors/Player"]

View file

@ -4,13 +4,15 @@ class_name Key
export var action := "" setget set_action
export var text := "key" setget set_text
export var font_width := 6
export var is_refresh := true
export var is_gamepad := false
onready var white := $White
onready var black := $Black
onready var label := $Label
onready var sprite := $Sprite
var is_gamepad := false
var swap := {"control" : "ctrl",
"quoteleft" : "~",
@ -40,13 +42,17 @@ var images := {"up" : 0,
"right" : 3,
"," : 4}
export var font_width := 6
func _ready():
KeyMenu.connect("refresh", self, "refresh")
set_action()
set_text()
if Engine.editor_hint: return
func refresh():
if is_refresh:
set_action()
func set_text(arg := text):
text = arg.to_lower()
var frame = -1

View file

@ -5,37 +5,53 @@ onready var default_keys := {}
export var is_gamepad := false
onready var control := $Control
export var scroll_path : NodePath = ""
onready var scroll_node := get_node_or_null(scroll_path)
onready var popup := $PopUp
var is_rebind := false
onready var list_node := $Control/VBox
onready var row_node := $Control/VBox/Row
export var row_path : NodePath = ""
onready var row_dupe := get_node_or_null(row_path).duplicate()
export var label_path : NodePath = ""
onready var label_dupe := get_node_or_null(label_path).duplicate()
var cursor := 0 setget set_cursor
onready var cursor_node := $Control/Cursor
export var cursor_expand := Vector2.ZERO
export var cursor_lerp := 0.2
var list := []
var actions := []
export var keys_action := {
"h_game" : "gameplay",
"jump" : "jump",
"action" : "lift",
"up" : "up",
"down" : "down",
"left" : "left",
"right": "right",
"jump" : "jump",
"action" : "lift",
"h_menu" : "menu",
"ui_pause": "pause",
"ui_up" : "menu up",
"ui_down" : "menu down",
"ui_left" : "menu left",
"ui_right" : "menu right",
"ui_yes" : "menu yes",
"ui_no" : "menu no",
"ui_yes" : "yes",
"ui_no" : "no",
"ui_up" : "up",
"ui_down" : "down",
"ui_left" : "left",
"ui_right" : "right",
"ui_del" : "unbind key",
"b_reset" : "reset to defaults",
}
signal refresh
func _ready():
for i in [row_path, label_path]:
get_node(i).queue_free()
open(false)
popup.visible = false
@ -45,8 +61,16 @@ func _ready():
# setup list
for i in keys_action.keys():
if InputMap.has_action(i):
var r = row_node.duplicate()
var h = i.begins_with("h_")
var b = i.begins_with("b_")
if h or b:
var d = label_dupe.duplicate()
d.text = keys_action[i]
list_node.add_child(d)
if b:
list.append(d)
elif InputMap.has_action(i):
var r = row_dupe.duplicate()
r.get_node("Label").text = keys_action[i]
list_node.add_child(r)
list.append(r)
@ -54,18 +78,78 @@ func _ready():
fill_row(r, i)
row_node.queue_free()
set_cursor()
func _input(event):
if !is_open or Wipe.is_wipe: return
var is_del : bool = event.is_action_pressed("ui_del")
var is_no : bool = event.is_action_pressed("ui_no")
var is_yes : bool = event.is_action_pressed("ui_yes")
var btny = btn.p("ui_down") - btn.p("ui_up")
if is_rebind:
if is_del:
is_rebind = false
popup.visible = false
ui_keys()
elif event.is_pressed() and !event.is_echo() and Key.is_type(event) and !is_del:
assign_key(actions[cursor], event)
is_rebind = false
ui_keys()
popup.visible = false
get_tree().set_input_as_handled()
else:
var is_action = cursor < actions.size()
if is_del:
if is_action:
clear_action()
Audio.play("menu_scroll", 0.8, 1.2)
elif is_no:
open(false)
OptionsMenu.open(true)
elif is_yes:
if is_action:
popup.visible = true
is_rebind = true
ui_keys()
else:
reset_to_defaults()
elif btny != 0:
self.cursor += btny
Audio.play("menu_scroll", 0.8, 1.2)
func _physics_process(delta):
if is_instance_valid(cursor_node):
cursor_node.rect_size = cursor_node.rect_size.linear_interpolate(list[cursor].rect_size + cursor_expand, cursor_lerp)
cursor_node.rect_global_position = cursor_node.rect_global_position.linear_interpolate(list[cursor].rect_global_position - (cursor_expand * 0.5), cursor_lerp)
if is_instance_valid(scroll_node):
scroll_node.rect_position.y = 64 - cursor_node.rect_position.y - (cursor_node.rect_size.y * 0.5)
func ui_keys():
UI.keys(true, false, !is_rebind, !is_rebind, !is_rebind, false, true)
func open(arg := false):
is_open = arg
visible = is_open
if is_open:
set_cursor(0)
ui_keys()
UI.labels()
func set_cursor(arg := cursor):
cursor = clamp(arg, 0, list.size() - 1)
func fill_row(row, action):
var a = InputMap.get_action_list(action)
var a = get_action_list_is_type(action)
var k := []
for y in a:
if Key.is_type(y, is_gamepad):
k.append(y.as_text())
k.append(y.as_text())
var keys = row.get_node("Keys").get_children()
for x in keys.size():
@ -74,41 +158,12 @@ func fill_row(row, action):
if less:
keys[x].text = k[x]
func _input(event):
if !is_open or Wipe.is_wipe: return
if is_rebind:
if event.is_action_pressed("ui_end"):
is_rebind = false
popup.visible = false
elif event.is_pressed() and !event.is_echo() and Key.is_type(event):
assign_key(actions[cursor], event)
is_rebind = false
popup.visible = false
get_tree().set_input_as_handled()
else:
var btny = btn.p("ui_down") - btn.p("ui_up")
if event.is_action_pressed("ui_no"):
open(false)
OptionsMenu.open(true)
elif event.is_action_pressed("ui_yes"):
popup.visible = true
is_rebind = true
elif btny != 0:
self.cursor += btny
func open(arg := false):
is_open = arg
visible = is_open
func set_cursor(arg := cursor):
cursor = clamp(arg, 0, list.size() - 1)
cursor_node.rect_size = list[cursor].rect_size + cursor_expand
cursor_node.rect_global_position = list[cursor].rect_global_position - (cursor_expand * 0.5)
control.rect_position.y = 64 - cursor_node.rect_position.y
func get_action_list_is_type(_action, _gamepad := is_gamepad):
var e = []
for i in InputMap.get_action_list(_action):
if Key.is_type(i, _gamepad):
e.append(i)
return e
func assign_key(action : String, event):
var is_ui = action.begins_with("ui_")
@ -122,14 +177,38 @@ func assign_key(action : String, event):
InputMap.action_add_event(action, event)
# keep action size to 4 events of type
var e = []
for i in InputMap.get_action_list(action):
if Key.is_type(i):
e.append(i)
var e = get_action_list_is_type(action)
if e.size() > 4:
InputMap.action_erase_event(action, e[0])
for i in list.size():
emit_signal("refresh")
for i in actions.size():
fill_row(list[i], actions[i])
func clear_action(_cursor := cursor):
var action : String = actions[_cursor]
var is_ui := action.begins_with("ui_")
var e = get_action_list_is_type(action)
if is_ui:
e.pop_back()
for i in e:
InputMap.action_erase_event(action, i)
fill_row(list[_cursor], actions[_cursor])
func reset_to_defaults():
for action in InputMap.get_actions():
for event in InputMap.get_action_list(action):
if Key.is_type(event, is_gamepad):
InputMap.action_erase_event(action, event)
for action in default_keys.keys():
for event in default_keys[action]:
if Key.is_type(event, is_gamepad):
InputMap.action_add_event(action, event)
for i in actions.size():
fill_row(list[i], actions[i])
emit_signal("refresh")

View file

@ -14,6 +14,9 @@ font_data = ExtResource( 1 )
[node name="KeyMenu" type="CanvasLayer"]
script = ExtResource( 3 )
scroll_path = NodePath("Control")
row_path = NodePath("Control/VBox/Row")
label_path = NodePath("Control/VBox/Label")
cursor_expand = Vector2( 4, 4 )
[node name="Back" type="ColorRect" parent="."]
@ -34,79 +37,96 @@ margin_bottom = 47.0
script = ExtResource( 4 )
[node name="VBox" type="VBoxContainer" parent="Control"]
margin_left = 48.0
margin_right = 175.0
margin_bottom = 73.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 50.0
margin_right = -50.0
[node name="Guide" type="HBoxContainer" parent="Control/VBox"]
margin_right = 127.0
margin_right = 128.0
margin_bottom = 5.0
[node name="Label" type="Label" parent="Control/VBox/Guide"]
margin_right = 36.0
margin_bottom = 5.0
size_flags_horizontal = 9
custom_fonts/font = SubResource( 1 )
text = "action"
[node name="Spacer" type="Control" parent="Control/VBox/Guide"]
margin_left = 40.0
margin_right = 99.0
margin_right = 100.0
margin_bottom = 5.0
size_flags_horizontal = 3
[node name="Label2" type="Label" parent="Control/VBox/Guide"]
margin_left = 103.0
margin_right = 127.0
margin_left = 104.0
margin_right = 128.0
margin_bottom = 5.0
custom_fonts/font = SubResource( 1 )
text = "keys"
[node name="Row" type="HBoxContainer" parent="Control/VBox" groups=["menu_item"]]
[node name="Label" type="Label" parent="Control/VBox"]
margin_top = 9.0
margin_right = 127.0
margin_bottom = 16.0
margin_right = 128.0
margin_bottom = 14.0
size_flags_horizontal = 9
custom_fonts/font = SubResource( 1 )
text = "game"
align = 1
[node name="Row" type="HBoxContainer" parent="Control/VBox"]
margin_top = 18.0
margin_right = 128.0
margin_bottom = 34.0
custom_constants/separation = 4
[node name="Label" type="Label" parent="Control/VBox/Row"]
margin_top = 1.0
margin_top = 5.0
margin_right = 24.0
margin_bottom = 6.0
margin_bottom = 10.0
custom_fonts/font = SubResource( 1 )
text = "jump"
[node name="Spacer" type="Control" parent="Control/VBox/Row"]
[node name="Keys" type="HFlowContainer" parent="Control/VBox/Row"]
margin_left = 28.0
margin_right = 47.0
margin_bottom = 7.0
margin_right = 128.0
margin_bottom = 16.0
size_flags_horizontal = 3
[node name="Keys" type="HBoxContainer" parent="Control/VBox/Row"]
margin_left = 51.0
margin_right = 127.0
margin_bottom = 7.0
custom_constants/vseparation = 2
custom_constants/hseparation = 2
[node name="Key" parent="Control/VBox/Row/Keys" instance=ExtResource( 2 )]
action = ""
text = "k"
[node name="Key2" parent="Control/VBox/Row/Keys" instance=ExtResource( 2 )]
margin_left = 11.0
margin_right = 42.0
margin_left = 3.0
margin_right = 34.0
rect_min_size = Vector2( 31, 7 )
size_flags_horizontal = 10
action = ""
text = "space"
is_refresh = false
[node name="Key2" parent="Control/VBox/Row/Keys" instance=ExtResource( 2 )]
margin_left = 36.0
margin_right = 67.0
rect_min_size = Vector2( 31, 7 )
action = ""
text = "pause"
is_refresh = false
[node name="Key3" parent="Control/VBox/Row/Keys" instance=ExtResource( 2 )]
margin_left = 46.0
margin_right = 53.0
margin_left = 69.0
margin_right = 100.0
rect_min_size = Vector2( 31, 7 )
action = ""
text = "x"
text = "enter"
is_refresh = false
[node name="Key4" parent="Control/VBox/Row/Keys" instance=ExtResource( 2 )]
margin_left = 57.0
margin_right = 76.0
rect_min_size = Vector2( 19, 7 )
margin_top = 9.0
margin_bottom = 16.0
action = ""
text = "del"
text = "x"
is_refresh = false
[node name="PopUp" type="CenterContainer" parent="."]
margin_right = 228.0