a game about throwing hammers made for the github game off
| -rw-r--r-- | godot.lock | 6 | ||||
| -rw-r--r-- | godot.package | 6 | ||||
| -rwxr-xr-x | install_addons.sh | 11 | ||||
| -rw-r--r-- | ui/cfg.gd | 18 | ||||
| -rw-r--r-- | ui/cfg.tscn | 272 | ||||
| -rw-r--r-- | ui/main.theme.tres | 6 | ||||
| -rw-r--r-- | ui/panel.tres | 14 | ||||
| -rw-r--r-- | ui/start.gd | 10 | ||||
| -rw-r--r-- | ui/start.tscn | 44 |
9 files changed, 378 insertions, 9 deletions
diff --git a/godot.lock b/godot.lock new file mode 100644 index 0000000..5725628 --- /dev/null +++ b/godot.lock @@ -0,0 +1,6 @@ +{ + "@bendn/remap": { + "version": "4.1.1", + "integrity": "sha512-zKFoc62rTp9noe1G+EPSboBtoqGVbPmmTaWVNljm2qJEmh9OvvUFoc6X63BS0yYr0jpzAfMj4i/Llv8u5c2U2g==" + } +}
\ No newline at end of file diff --git a/godot.package b/godot.package new file mode 100644 index 0000000..efd9e26 --- /dev/null +++ b/godot.package @@ -0,0 +1,6 @@ +{ + "name": "hammer_space", + "packages": { + "@bendn/remap": "4.1.1" + } +}
\ No newline at end of file diff --git a/install_addons.sh b/install_addons.sh new file mode 100755 index 0000000..c52e640 --- /dev/null +++ b/install_addons.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +rm -rf addons && mkdir addons +if [[ -d ~/godot-package-manager ]]; then + cp -r ~/godot-package-manager/addons/godot-package-manager addons/gpm +else + git clone --depth 1 https://github.com/you-win/godot-package-manager gpm/ + mv gpm/addons/godot-package-manager addons/gpm + rm -r gpm/ +fi +godot -s --no-window addons/gpm/cli.gd update +rm -r addons/gpm diff --git a/ui/cfg.gd b/ui/cfg.gd new file mode 100644 index 0000000..87e6f32 --- /dev/null +++ b/ui/cfg.gd @@ -0,0 +1,18 @@ +extends ColorRect + +signal close + +@export var focus: Control + +func open() -> void: + show() + focus.button.grab_focus() + +func _input(event: InputEvent) -> void: + if visible and event is InputEventKey and event.keycode == KEY_ESCAPE: + close.emit() + hide() + +func _on_exit_pressed() -> void: + close.emit() + hide() diff --git a/ui/cfg.tscn b/ui/cfg.tscn new file mode 100644 index 0000000..fc2dd12 --- /dev/null +++ b/ui/cfg.tscn @@ -0,0 +1,272 @@ +[gd_scene load_steps=11 format=3 uid="uid://c0u64ju7url7g"] + +[ext_resource type="Theme" uid="uid://b5sr8elfovyw3" path="res://ui/main.theme.tres" id="1_14aww"] +[ext_resource type="Script" path="res://addons/remap/RemapButton.gd" id="1_c3nk4"] +[ext_resource type="Script" path="res://ui/cfg.gd" id="2_3rpdm"] +[ext_resource type="FontFile" uid="uid://ck4uai24afp11" path="res://addons/remap/PromptFont.ttf" id="3_g7yde"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n07ao"] +bg_color = Color(0, 0.0784314, 0.168627, 0.615686) +corner_radius_top_left = 15 +corner_radius_top_right = 15 +corner_radius_bottom_right = 15 +corner_radius_bottom_left = 15 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nd1ad"] +content_margin_left = 15.0 +content_margin_top = 15.0 +content_margin_right = 15.0 +content_margin_bottom = 15.0 +bg_color = Color(0, 0, 0, 0) +border_width_left = 5 +border_width_top = 5 +border_width_right = 5 +border_width_bottom = 5 +corner_radius_top_left = 15 +corner_radius_top_right = 15 +corner_radius_bottom_right = 15 +corner_radius_bottom_left = 15 + +[sub_resource type="GDScript" id="GDScript_gnxo1"] +resource_name = "holder" +script/source = "extends VBoxContainer + +@export var font_size: int + +func _ready() -> void: + for c in get_children(): + if c.name == \"bbar\": + continue + c.button.add_theme_font_size_override(\"font_size\", font_size) +" + +[sub_resource type="GDScript" id="GDScript_dodrb"] +resource_name = "reset" +script/source = "extends Button + +func _pressed() -> void: + InputMap.load_from_project_settings() +" + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_t7ea5"] +content_margin_left = 10.0 +content_margin_top = 10.0 +content_margin_right = 10.0 +content_margin_bottom = 10.0 +bg_color = Color(0.427451, 0.117647, 0.156863, 1) +border_width_left = 5 +border_width_top = 5 +border_width_right = 5 +border_width_bottom = 5 +border_color = Color(0.658824, 0.129412, 0.294118, 1) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_right = 10 +corner_radius_bottom_left = 10 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_it6gr"] +content_margin_left = 10.0 +content_margin_top = 10.0 +content_margin_right = 10.0 +content_margin_bottom = 10.0 +bg_color = Color(0.513726, 0.117647, 0.156863, 1) +border_width_left = 5 +border_width_top = 5 +border_width_right = 5 +border_width_bottom = 5 +border_color = Color(0.92549, 0.345098, 0.278431, 1) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_right = 10 +corner_radius_bottom_left = 10 + +[node name="cfg" type="ColorRect" node_paths=PackedStringArray("focus")] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_14aww") +color = Color(0, 0, 0, 0.192157) +script = ExtResource("2_3rpdm") +focus = NodePath("margin/Scroll/V/left") + +[node name="margin" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="Panel" type="Panel" parent="margin"] +layout_mode = 2 +offset_left = 10.0 +offset_top = 10.0 +offset_right = 310.0 +offset_bottom = 310.0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_n07ao") + +[node name="Scroll" type="ScrollContainer" parent="margin"] +layout_mode = 2 +offset_left = 10.0 +offset_top = 10.0 +offset_right = 310.0 +offset_bottom = 310.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_nd1ad") +follow_focus = true +horizontal_scroll_mode = 3 +vertical_scroll_mode = 3 + +[node name="V" type="VBoxContainer" parent="margin/Scroll"] +show_behind_parent = true +layout_mode = 2 +offset_left = 15.0 +offset_top = 15.0 +offset_right = 285.0 +offset_bottom = 285.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = SubResource("GDScript_gnxo1") +font_size = 15 + +[node name="bbar" type="HBoxContainer" parent="margin/Scroll/V"] +show_behind_parent = true +layout_mode = 2 +offset_right = 270.0 +offset_bottom = 36.0 + +[node name="space3" type="Control" parent="margin/Scroll/V/bbar"] +custom_minimum_size = Vector2(20, 0) +layout_mode = 2 +anchors_preset = 0 +offset_right = 20.0 +offset_bottom = 36.0 + +[node name="reset" type="Button" parent="margin/Scroll/V/bbar"] +show_behind_parent = true +layout_mode = 2 +offset_left = 24.0 +offset_right = 79.0 +offset_bottom = 36.0 +size_flags_horizontal = 4 +theme_override_font_sizes/font_size = 12 +text = "reset" +script = SubResource("GDScript_dodrb") + +[node name="space" type="Control" parent="margin/Scroll/V/bbar"] +layout_mode = 2 +anchors_preset = 0 +offset_left = 83.0 +offset_right = 190.0 +offset_bottom = 36.0 +size_flags_horizontal = 3 + +[node name="exit" type="Button" parent="margin/Scroll/V/bbar"] +show_behind_parent = true +layout_mode = 2 +offset_left = 194.0 +offset_right = 226.0 +offset_bottom = 36.0 +size_flags_horizontal = 4 +theme_override_fonts/font = ExtResource("3_g7yde") +theme_override_font_sizes/font_size = 12 +theme_override_styles/normal = SubResource("StyleBoxFlat_t7ea5") +theme_override_styles/hover = SubResource("StyleBoxFlat_it6gr") +theme_override_styles/pressed = SubResource("StyleBoxFlat_it6gr") +theme_override_styles/focus = SubResource("StyleBoxFlat_it6gr") +text = "✗" + +[node name="space2" type="Control" parent="margin/Scroll/V/bbar"] +custom_minimum_size = Vector2(40, 0) +layout_mode = 2 +anchors_preset = 0 +offset_left = 230.0 +offset_right = 270.0 +offset_bottom = 36.0 + +[node name="left" type="HBoxContainer" parent="margin/Scroll/V"] +show_behind_parent = true +custom_minimum_size = Vector2(42, 42) +layout_mode = 2 +offset_top = 40.0 +offset_right = 270.0 +offset_bottom = 82.0 +script = ExtResource("1_c3nk4") +prompt_text = "push button" +_name = "left" +action = "left" +icon_size = Vector2(35, 35) +font_size = 19 +continuous_updating = true + +[node name="right" type="HBoxContainer" parent="margin/Scroll/V"] +show_behind_parent = true +custom_minimum_size = Vector2(42, 42) +layout_mode = 2 +offset_top = 86.0 +offset_right = 270.0 +offset_bottom = 128.0 +script = ExtResource("1_c3nk4") +prompt_text = "push button" +_name = "right" +action = "right" +icon_size = Vector2(35, 35) +font_size = 19 +continuous_updating = true + +[node name="up" type="HBoxContainer" parent="margin/Scroll/V"] +show_behind_parent = true +custom_minimum_size = Vector2(42, 42) +layout_mode = 2 +offset_top = 132.0 +offset_right = 270.0 +offset_bottom = 174.0 +script = ExtResource("1_c3nk4") +prompt_text = "push button" +_name = "jump" +action = "jump" +icon_size = Vector2(35, 35) +font_size = 19 +continuous_updating = true + +[node name="down" type="HBoxContainer" parent="margin/Scroll/V"] +show_behind_parent = true +custom_minimum_size = Vector2(42, 42) +layout_mode = 2 +offset_top = 178.0 +offset_right = 270.0 +offset_bottom = 220.0 +script = ExtResource("1_c3nk4") +prompt_text = "push button" +_name = "fall" +action = "down" +icon_size = Vector2(35, 35) +font_size = 19 +continuous_updating = true + +[node name="shoot" type="HBoxContainer" parent="margin/Scroll/V"] +show_behind_parent = true +custom_minimum_size = Vector2(42, 42) +layout_mode = 2 +offset_top = 224.0 +offset_right = 270.0 +offset_bottom = 266.0 +script = ExtResource("1_c3nk4") +prompt_text = "push button" +_name = "shoot" +action = "shoot" +icon_size = Vector2(35, 35) +font_size = 19 +continuous_updating = true + +[connection signal="pressed" from="margin/Scroll/V/bbar/exit" to="." method="_on_exit_pressed"] diff --git a/ui/main.theme.tres b/ui/main.theme.tres index 3991c0f..751298f 100644 --- a/ui/main.theme.tres +++ b/ui/main.theme.tres @@ -1,11 +1,12 @@ -[gd_resource type="Theme" load_steps=7 format=3 uid="uid://b5sr8elfovyw3"] +[gd_resource type="Theme" load_steps=8 format=3 uid="uid://b5sr8elfovyw3"] [ext_resource type="StyleBox" uid="uid://caxtg2fj6ffqx" path="res://ui/button/button_focus.tres" id="1_8x0ae"] [ext_resource type="StyleBox" uid="uid://483vjasgeg6x" path="res://ui/button/button_normal.tres" id="1_e241j"] [ext_resource type="StyleBox" uid="uid://cuwclicw8mxmg" path="res://ui/button/button_disabled.tres" id="1_kdwa2"] [ext_resource type="StyleBox" uid="uid://5c652jqp6x8q" path="res://ui/button/button_hover.tres" id="3_kg542"] [ext_resource type="StyleBox" uid="uid://kccji4f3l86p" path="res://ui/button/button_pressed.tres" id="5_fceyb"] -[ext_resource type="FontFile" uid="uid://eb52ighl8mnl" path="res://assets/ui/04B_19.ttf" id="6_ibow1"] +[ext_resource type="FontFile" uid="uid://w8xa1kya7ls5" path="res://assets/ui/04B_19.ttf" id="6_ibow1"] +[ext_resource type="StyleBox" uid="uid://c7plpsmtwl2tj" path="res://ui/panel.tres" id="6_s8neq"] [resource] default_font = ExtResource("6_ibow1") @@ -23,3 +24,4 @@ Button/styles/focus = ExtResource("1_8x0ae") Button/styles/hover = ExtResource("3_kg542") Button/styles/normal = ExtResource("1_e241j") Button/styles/pressed = ExtResource("5_fceyb") +PanelContainer/styles/panel = ExtResource("6_s8neq") diff --git a/ui/panel.tres b/ui/panel.tres new file mode 100644 index 0000000..8568ba7 --- /dev/null +++ b/ui/panel.tres @@ -0,0 +1,14 @@ +[gd_resource type="StyleBoxFlat" format=3 uid="uid://c7plpsmtwl2tj"] + +[resource] +bg_color = Color(0.0901961, 0.156863, 0.176471, 1) +border_width_left = 5 +border_width_top = 5 +border_width_right = 5 +border_width_bottom = 5 +border_color = Color(0.0705882, 0.12549, 0.141176, 1) +corner_radius_top_left = 30 +corner_radius_top_right = 30 +corner_radius_bottom_right = 30 +corner_radius_bottom_left = 30 +corner_detail = 12 diff --git a/ui/start.gd b/ui/start.gd new file mode 100644 index 0000000..fcee719 --- /dev/null +++ b/ui/start.gd @@ -0,0 +1,10 @@ +extends Control + +@export var focus: Control + +func _ready() -> void: + focus.grab_focus() + + +func _on_cfg_close() -> void: + focus.grab_focus() diff --git a/ui/start.tscn b/ui/start.tscn index 8169c2f..fc9bfd4 100644 --- a/ui/start.tscn +++ b/ui/start.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=4 format=3 uid="uid://bkyf7pxcw2ks3"] +[gd_scene load_steps=7 format=3 uid="uid://bkyf7pxcw2ks3"] [ext_resource type="Theme" uid="uid://b5sr8elfovyw3" path="res://ui/main.theme.tres" id="1_gj4yg"] +[ext_resource type="Script" path="res://ui/start.gd" id="2_iv77f"] +[ext_resource type="PackedScene" uid="uid://c0u64ju7url7g" path="res://ui/cfg.tscn" id="2_sqamp"] [sub_resource type="GDScript" id="GDScript_52jbq"] resource_name = "start" @@ -10,6 +12,16 @@ func _pressed() -> void: get_tree().change_scene_to_file(\"res://Main.tscn\") " +[sub_resource type="GDScript" id="GDScript_a3v0r"] +resource_name = "cfg" +script/source = "extends Button + +@onready var cfg := $\"%cfg\" + +func _pressed() -> void: + cfg.open() +" + [sub_resource type="GDScript" id="GDScript_vtoxm"] resource_name = "exit" script/source = "extends Button @@ -18,21 +30,31 @@ func _pressed() -> void: get_tree().quit() " -[node name="start" type="CenterContainer"] +[node name="start" type="Control" node_paths=PackedStringArray("focus")] +layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 theme = ExtResource("1_gj4yg") +script = ExtResource("2_iv77f") +focus = NodePath("VBox/StartButton") metadata/_edit_vertical_guides_ = [] [node name="VBox" type="VBoxContainer" parent="."] -layout_mode = 2 -offset_left = 74.0 -offset_top = 84.0 -offset_right = 246.0 -offset_bottom = 236.0 +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -86.0 +offset_top = -76.0 +offset_right = 86.0 +offset_bottom = 76.0 +grow_horizontal = 2 +grow_vertical = 2 [node name="StartButton" type="Button" parent="VBox"] layout_mode = 2 @@ -47,6 +69,7 @@ offset_top = 52.0 offset_right = 172.0 offset_bottom = 100.0 text = "configure" +script = SubResource("GDScript_a3v0r") [node name="ExitButton" type="Button" parent="VBox"] layout_mode = 2 @@ -55,3 +78,10 @@ offset_right = 172.0 offset_bottom = 152.0 text = "<!) exit (!>" script = SubResource("GDScript_vtoxm") + +[node name="cfg" parent="." instance=ExtResource("2_sqamp")] +unique_name_in_owner = true +visible = false +layout_mode = 1 + +[connection signal="close" from="cfg" to="." method="_on_cfg_close"] |