diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-12-28 15:08:23 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-12-28 15:08:23 +0100 |
commit | 474ef692613f298ab05bbb65ad85625f178b63cc (patch) | |
tree | d069e587c8d731ea8191ee0318abc85694c04351 /ui | |
parent | d572bc0a27b05c6632ba76bd630c7c4fd8f0ae5d (diff) |
next commit
Diffstat (limited to 'ui')
-rw-r--r-- | ui/assets/tilemap_white.png | bin | 0 -> 10054 bytes | |||
-rw-r--r-- | ui/assets/tilemap_white.png.import | 34 | ||||
-rw-r--r-- | ui/mobile/button.gd | 45 | ||||
-rw-r--r-- | ui/mobile/button.tscn | 43 | ||||
-rw-r--r-- | ui/mobile/mobile_controls.gd | 17 | ||||
-rw-r--r-- | ui/mobile/mobile_controls.tscn | 78 | ||||
-rw-r--r-- | ui/start_screen.tscn | 1 | ||||
-rw-r--r-- | ui/theme.tres | 2 |
8 files changed, 219 insertions, 1 deletions
diff --git a/ui/assets/tilemap_white.png b/ui/assets/tilemap_white.png Binary files differnew file mode 100644 index 0000000..207208e --- /dev/null +++ b/ui/assets/tilemap_white.png diff --git a/ui/assets/tilemap_white.png.import b/ui/assets/tilemap_white.png.import new file mode 100644 index 0000000..4a91aca --- /dev/null +++ b/ui/assets/tilemap_white.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cywefso7qpdan" +path="res://.godot/imported/tilemap_white.png-0d4219020eb50271e0e65cbcc8eff609.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/assets/tilemap_white.png" +dest_files=["res://.godot/imported/tilemap_white.png-0d4219020eb50271e0e65cbcc8eff609.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/ui/mobile/button.gd b/ui/mobile/button.gd new file mode 100644 index 0000000..2e3653c --- /dev/null +++ b/ui/mobile/button.gd @@ -0,0 +1,45 @@ +@tool +extends Panel + + +@export var texture: Texture2D: + set(value): + texture = value + $TouchScreenButton.texture_normal = value + _on_resized() + +@export var label: String: + set(value): + label = value + $Label.text = value + +@export var action: StringName = "": + set(value): + action = value + $TouchScreenButton.action = value + + +func _ready() -> void: + _on_resized() + + +func _on_resized() -> void: + $TouchScreenButton.shape.size = size + + var texture_size := Vector2.ZERO + if texture: + texture_size = texture.get_size() + + $TouchScreenButton.position = Vector2( + (size.x - texture_size.x) / 2, + (size.y - texture_size.y) / 2 + ) + + $Label.size = size + + +func _on_touch_screen_button_pressed() -> void: + modulate = Color(0.5, 0.5, 0.5, 1.0) + +func _on_touch_screen_button_released() -> void: + modulate = Color(1.0, 1.0, 1.0, 1.0) diff --git a/ui/mobile/button.tscn b/ui/mobile/button.tscn new file mode 100644 index 0000000..64a413f --- /dev/null +++ b/ui/mobile/button.tscn @@ -0,0 +1,43 @@ +[gd_scene load_steps=5 format=3 uid="uid://evppekv62x0g"] + +[ext_resource type="Script" path="res://ui/mobile/button.gd" id="1_2pd68"] +[ext_resource type="Theme" uid="uid://b067xhqktnmhr" path="res://ui/theme.tres" id="2_rnfal"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qy0ya"] +bg_color = Color(0.0297164, 0.155372, 0.181691, 1) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0, 0, 0, 1) +border_blend = true + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_cuu3o"] +resource_local_to_scene = true +size = Vector2(160, 20) + +[node name="Button" type="Panel"] +texture_filter = 1 +offset_right = 160.0 +offset_bottom = 20.0 +theme_override_styles/panel = SubResource("StyleBoxFlat_qy0ya") +script = ExtResource("1_2pd68") + +[node name="TouchScreenButton" type="TouchScreenButton" parent="."] +position = Vector2(80, 10) +shape = SubResource("RectangleShape2D_cuu3o") +shape_visible = false +visibility_mode = 1 + +[node name="Label" type="Label" parent="."] +layout_mode = 0 +offset_right = 160.0 +offset_bottom = 20.0 +theme = ExtResource("2_rnfal") +theme_override_colors/font_color = Color(1, 1, 1, 1) +horizontal_alignment = 1 +vertical_alignment = 1 + +[connection signal="resized" from="." to="." method="_on_resized"] +[connection signal="pressed" from="TouchScreenButton" to="." method="_on_touch_screen_button_pressed"] +[connection signal="released" from="TouchScreenButton" to="." method="_on_touch_screen_button_released"] diff --git a/ui/mobile/mobile_controls.gd b/ui/mobile/mobile_controls.gd new file mode 100644 index 0000000..a87ceea --- /dev/null +++ b/ui/mobile/mobile_controls.gd @@ -0,0 +1,17 @@ +class_name MobileControls +extends CanvasLayer + + +var size: Vector2: + get(): + return (get_child(0) as Control).size + + +func _init() -> void: + visible = false + process_mode = ProcessMode.PROCESS_MODE_DISABLED + + +func enable() -> void: + process_mode = ProcessMode.PROCESS_MODE_ALWAYS + visible = true diff --git a/ui/mobile/mobile_controls.tscn b/ui/mobile/mobile_controls.tscn new file mode 100644 index 0000000..333b0ad --- /dev/null +++ b/ui/mobile/mobile_controls.tscn @@ -0,0 +1,78 @@ +[gd_scene load_steps=7 format=3 uid="uid://cvx1vj47uf5k2"] + +[ext_resource type="Script" path="res://ui/mobile/mobile_controls.gd" id="1_ts8mv"] +[ext_resource type="PackedScene" uid="uid://evppekv62x0g" path="res://ui/mobile/button.tscn" id="2_7um2b"] +[ext_resource type="Texture2D" uid="uid://cywefso7qpdan" path="res://ui/assets/tilemap_white.png" id="2_n84be"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e3qjv"] +bg_color = Color(0.0313726, 0.156863, 0.180392, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hxyr7"] +bg_color = Color(0.0297164, 0.155372, 0.181691, 1) +border_width_left = 1 +border_width_top = 2 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0, 0, 0, 1) +border_blend = true + +[sub_resource type="AtlasTexture" id="AtlasTexture_kr7mh"] +atlas = ExtResource("2_n84be") +region = Rect2(445, 292, 10, 10) +filter_clip = true + +[node name="MobileControls" type="CanvasLayer"] +script = ExtResource("1_ts8mv") + +[node name="Control" type="Panel" parent="."] +offset_top = 144.0 +offset_right = 160.0 +offset_bottom = 249.0 +theme_override_styles/panel = SubResource("StyleBoxFlat_e3qjv") + +[node name="Up" parent="Control" instance=ExtResource("2_7um2b")] +layout_mode = 0 +offset_bottom = 26.0 +theme_override_styles/panel = SubResource("StyleBoxFlat_hxyr7") +texture = SubResource("AtlasTexture_kr7mh") +label = "" +action = &"ui_up" + +[node name="Down" parent="Control" instance=ExtResource("2_7um2b")] +layout_mode = 0 +offset_left = 160.0 +offset_top = 92.0 +offset_right = 320.0 +offset_bottom = 118.0 +rotation = 3.14159 +texture = SubResource("AtlasTexture_kr7mh") +label = "" +action = &"ui_down" + +[node name="Left" parent="Control" instance=ExtResource("2_7um2b")] +layout_mode = 0 +offset_left = 160.0 +offset_top = 26.0 +offset_right = 200.0 +offset_bottom = 106.0 +rotation = 1.5708 +texture = SubResource("AtlasTexture_kr7mh") +label = "" +action = &"ui_right" + +[node name="Right" parent="Control" instance=ExtResource("2_7um2b")] +layout_mode = 0 +offset_top = 66.0 +offset_right = 40.0 +offset_bottom = 146.0 +rotation = -1.5708 +texture = SubResource("AtlasTexture_kr7mh") +label = "" +action = &"ui_left" + +[node name="Start" parent="Control" instance=ExtResource("2_7um2b")] +layout_mode = 0 +offset_top = 92.0 +offset_bottom = 105.0 +label = "Start" +action = &"ui_accept" diff --git a/ui/start_screen.tscn b/ui/start_screen.tscn index 6d40d01..5b19aa3 100644 --- a/ui/start_screen.tscn +++ b/ui/start_screen.tscn @@ -45,7 +45,6 @@ text = "0" [node name="CountdownTimer" type="Timer" parent="."] unique_name_in_owner = true -wait_time = 3.0 one_shot = true [connection signal="timeout" from="CountdownTimer" to="." method="_on_countdown_timer_timeout"] diff --git a/ui/theme.tres b/ui/theme.tres index eb181eb..d4ee617 100644 --- a/ui/theme.tres +++ b/ui/theme.tres @@ -3,6 +3,8 @@ [ext_resource type="FontFile" uid="uid://16usq1tjtauh" path="res://ui/assets/Minimal3x5.ttf" id="1_qtw8w"] [resource] +Button/font_sizes/font_size = 8 +Button/fonts/font = ExtResource("1_qtw8w") Label/colors/font_color = Color(0.12549, 0.345098, 0.313726, 1) Label/font_sizes/font_size = 8 Label/fonts/font = ExtResource("1_qtw8w") |