ui example

This commit is contained in:
OddlyTimbot 2024-08-12 17:45:20 -04:00
parent 03f366b0e1
commit 0a532de910
14 changed files with 393 additions and 0 deletions

2
week6/example/UIDemo/.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

2
week6/example/UIDemo/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -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

View File

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 950 B

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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)