diff --git a/week6/example/UIDemo/.gitattributes b/week6/example/UIDemo/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/week6/example/UIDemo/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/week6/example/UIDemo/.gitignore b/week6/example/UIDemo/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/week6/example/UIDemo/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/week6/example/UIDemo/graphics/Player Idle 48x48.png b/week6/example/UIDemo/graphics/Player Idle 48x48.png new file mode 100644 index 0000000..b618511 Binary files /dev/null and b/week6/example/UIDemo/graphics/Player Idle 48x48.png differ diff --git a/week6/example/UIDemo/graphics/Player Idle 48x48.png.import b/week6/example/UIDemo/graphics/Player Idle 48x48.png.import new file mode 100644 index 0000000..ac91d82 --- /dev/null +++ b/week6/example/UIDemo/graphics/Player Idle 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b1jefdr3xicmi" +path="res://.godot/imported/Player Idle 48x48.png-b25968a287377bab7d6899f33fed0ec9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/Player Idle 48x48.png" +dest_files=["res://.godot/imported/Player Idle 48x48.png-b25968a287377bab7d6899f33fed0ec9.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/week6/example/UIDemo/graphics/player run 48x48.png b/week6/example/UIDemo/graphics/player run 48x48.png new file mode 100644 index 0000000..aca5b55 Binary files /dev/null and b/week6/example/UIDemo/graphics/player run 48x48.png differ diff --git a/week6/example/UIDemo/graphics/player run 48x48.png.import b/week6/example/UIDemo/graphics/player run 48x48.png.import new file mode 100644 index 0000000..656f800 --- /dev/null +++ b/week6/example/UIDemo/graphics/player run 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cm1woggnuul4l" +path="res://.godot/imported/player run 48x48.png-626defb011aee5b3f5c54d9acb45d5f5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/player run 48x48.png" +dest_files=["res://.godot/imported/player run 48x48.png-626defb011aee5b3f5c54d9acb45d5f5.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/week6/example/UIDemo/icon.svg b/week6/example/UIDemo/icon.svg new file mode 100644 index 0000000..b370ceb --- /dev/null +++ b/week6/example/UIDemo/icon.svg @@ -0,0 +1 @@ + diff --git a/week6/example/UIDemo/icon.svg.import b/week6/example/UIDemo/icon.svg.import new file mode 100644 index 0000000..3e8aca1 --- /dev/null +++ b/week6/example/UIDemo/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bpxaclgteuqnl" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/week6/example/UIDemo/main.tscn b/week6/example/UIDemo/main.tscn new file mode 100644 index 0000000..f726c75 --- /dev/null +++ b/week6/example/UIDemo/main.tscn @@ -0,0 +1,199 @@ +[gd_scene load_steps=24 format=3 uid="uid://2imtdevb7dgp"] + +[ext_resource type="Script" path="res://scripts/uicontrols.gd" id="1_jdye0"] +[ext_resource type="Theme" uid="uid://c1bv8x07p5hcq" path="res://themes/basic_theme.tres" id="1_rased"] +[ext_resource type="Texture2D" uid="uid://b1jefdr3xicmi" path="res://graphics/Player Idle 48x48.png" id="3_8gddj"] +[ext_resource type="Texture2D" uid="uid://cm1woggnuul4l" path="res://graphics/player run 48x48.png" id="4_feex0"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_2g7pn"] +atlas = ExtResource("3_8gddj") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lkww2"] +atlas = ExtResource("3_8gddj") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_op60x"] +atlas = ExtResource("3_8gddj") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_u4y5s"] +atlas = ExtResource("3_8gddj") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8iwh7"] +atlas = ExtResource("3_8gddj") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_e1wx7"] +atlas = ExtResource("3_8gddj") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hi7vn"] +atlas = ExtResource("3_8gddj") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ljcxo"] +atlas = ExtResource("3_8gddj") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_3vbn3"] +atlas = ExtResource("3_8gddj") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_3jbx1"] +atlas = ExtResource("3_8gddj") +region = Rect2(432, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_632tr"] +atlas = ExtResource("4_feex0") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_16llu"] +atlas = ExtResource("4_feex0") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1h853"] +atlas = ExtResource("4_feex0") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_g3x76"] +atlas = ExtResource("4_feex0") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ojjof"] +atlas = ExtResource("4_feex0") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vsvld"] +atlas = ExtResource("4_feex0") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wyf10"] +atlas = ExtResource("4_feex0") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_76v8x"] +atlas = ExtResource("4_feex0") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="SpriteFrames" id="SpriteFrames_ykw1q"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_2g7pn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lkww2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_op60x") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_u4y5s") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8iwh7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_e1wx7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hi7vn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ljcxo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_3vbn3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_3jbx1") +}], +"loop": true, +"name": &"idle", +"speed": 15.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_632tr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_16llu") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1h853") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_g3x76") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ojjof") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vsvld") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wyf10") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_76v8x") +}], +"loop": true, +"name": &"run", +"speed": 15.0 +}] + +[node name="CenterContainer" type="CenterContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_jdye0") + +[node name="PanelContainer" type="PanelContainer" parent="."] +custom_minimum_size = Vector2(400, 0) +layout_mode = 2 +theme = ExtResource("1_rased") + +[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"] +layout_mode = 2 +theme = ExtResource("1_rased") + +[node name="Label" type="Label" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +theme = ExtResource("1_rased") +text = "MAIN MENU" +horizontal_alignment = 1 + +[node name="NewGameButton" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +theme = ExtResource("1_rased") +text = "New Game" + +[node name="ContinueButton" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +text = "Continue" + +[node name="SettingsButton" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +text = "Settings" + +[node name="QuitButton" type="Button" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +text = "Quit" + +[node name="Control" type="Control" parent="PanelContainer/VBoxContainer"] +custom_minimum_size = Vector2(0, 120) +layout_mode = 2 + +[node name="Node2D" type="Node2D" parent="PanelContainer/VBoxContainer/Control"] +texture_filter = 1 +position = Vector2(150, 42) +scale = Vector2(2, 2) + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="PanelContainer/VBoxContainer/Control/Node2D"] +sprite_frames = SubResource("SpriteFrames_ykw1q") +animation = &"run" +autoplay = "idle" diff --git a/week6/example/UIDemo/project.godot b/week6/example/UIDemo/project.godot new file mode 100644 index 0000000..ba34059 --- /dev/null +++ b/week6/example/UIDemo/project.godot @@ -0,0 +1,21 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="UIDemo-CustomTheme" +run/main_scene="res://main.tscn" +config/features=PackedStringArray("4.2", "Forward Plus") +config/icon="res://icon.svg" + +[display] + +window/size/viewport_width=600 +window/size/viewport_height=600 diff --git a/week6/example/UIDemo/scripts/uicontrols.gd b/week6/example/UIDemo/scripts/uicontrols.gd new file mode 100644 index 0000000..add3e73 --- /dev/null +++ b/week6/example/UIDemo/scripts/uicontrols.gd @@ -0,0 +1,29 @@ +extends CenterContainer +@onready var new_game_button = $PanelContainer/VBoxContainer/NewGameButton as Button +@onready var continue_button = $PanelContainer/VBoxContainer/ContinueButton as Button +@onready var settings_button = $PanelContainer/VBoxContainer/SettingsButton as Button +@onready var quit_button = $PanelContainer/VBoxContainer/QuitButton as Button +@onready var animated_sprite_2d = $PanelContainer/VBoxContainer/Control/Node2D/AnimatedSprite2D + + +# Called when the node enters the scene tree for the first time. +func _ready(): + new_game_button.button_down.connect(on_button_down) + new_game_button.mouse_entered.connect(on_button_entered) + new_game_button.mouse_exited.connect(on_button_exited) + + continue_button.button_down.connect(on_button_down) + settings_button.button_down.connect(on_button_down) + quit_button.button_down.connect(on_exit_pressed) + +func on_button_down(): + print("button pressed down ") + +func on_button_entered(): + animated_sprite_2d.play("run") +func on_button_exited(): + animated_sprite_2d.play("idle") + +func on_exit_pressed(): + print("attempting to quit game") + get_tree().quit() diff --git a/week6/example/UIDemo/themes/basic_flat.tres b/week6/example/UIDemo/themes/basic_flat.tres new file mode 100644 index 0000000..975c091 --- /dev/null +++ b/week6/example/UIDemo/themes/basic_flat.tres @@ -0,0 +1,12 @@ +[gd_resource type="StyleBoxFlat" format=3 uid="uid://rug1bma4m4p3"] + +[resource] +content_margin_left = 50.0 +content_margin_top = 50.0 +content_margin_right = 50.0 +content_margin_bottom = 50.0 +bg_color = Color(0.117647, 0.117647, 0.117647, 0.819608) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_right = 10 +corner_radius_bottom_left = 10 diff --git a/week6/example/UIDemo/themes/basic_theme.tres b/week6/example/UIDemo/themes/basic_theme.tres new file mode 100644 index 0000000..56ab415 --- /dev/null +++ b/week6/example/UIDemo/themes/basic_theme.tres @@ -0,0 +1,14 @@ +[gd_resource type="Theme" load_steps=4 format=3 uid="uid://c1bv8x07p5hcq"] + +[ext_resource type="StyleBox" uid="uid://bvppr1mi3251g" path="res://themes/button_flat.tres" id="1_22x2v"] +[ext_resource type="StyleBox" uid="uid://rug1bma4m4p3" path="res://themes/basic_flat.tres" id="2_ls5x7"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_g1o25"] +content_margin_bottom = 20.0 + +[resource] +Button/styles/normal = ExtResource("1_22x2v") +Label/font_sizes/font_size = 22 +Label/styles/normal = SubResource("StyleBoxEmpty_g1o25") +PanelContainer/styles/panel = ExtResource("2_ls5x7") +VBoxContainer/constants/separation = 15 diff --git a/week6/example/UIDemo/themes/button_flat.tres b/week6/example/UIDemo/themes/button_flat.tres new file mode 100644 index 0000000..761c391 --- /dev/null +++ b/week6/example/UIDemo/themes/button_flat.tres @@ -0,0 +1,8 @@ +[gd_resource type="StyleBoxFlat" format=3 uid="uid://bvppr1mi3251g"] + +[resource] +content_margin_left = 15.0 +content_margin_top = 15.0 +content_margin_right = 15.0 +content_margin_bottom = 15.0 +bg_color = Color(0.25098, 0.25098, 0.25098, 1)