beatiful buttons

This commit is contained in:
Ententerminator 2020-02-02 14:54:22 +01:00
parent 26bd9c953a
commit 2375df837b
4 changed files with 59 additions and 19 deletions

View File

@ -1,5 +1,6 @@
extends VBoxContainer extends VBoxContainer
var _custom_button = preload("res://UI/LimbButton.tscn")
onready var delete = get_node("Delete") onready var delete = get_node("Delete")
@ -7,7 +8,7 @@ onready var delete = get_node("Delete")
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
for entry in BodyPartLoader.bodyparts: for entry in BodyPartLoader.bodyparts:
var button = Button.new() var button = _custom_button.instance()
button.text = entry button.text = entry
add_child(button) add_child(button)
button.connect("pressed", get_parent().get_parent().get_parent(), "body_part_chosen", [button.text]) button.connect("pressed", get_parent().get_parent().get_parent(), "body_part_chosen", [button.text])

View File

@ -1,9 +1,13 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://BodyParts/BodyBase/BodyBase.tscn" type="PackedScene" id=1] [ext_resource path="res://BodyParts/BodyBase/BodyBase.tscn" type="PackedScene" id=1]
[ext_resource path="res://BodyConfig/bodyBuildingScript.gd" type="Script" id=2] [ext_resource path="res://BodyConfig/bodyBuildingScript.gd" type="Script" id=2]
[ext_resource path="res://BodyConfig/LoadBodyParts.gd" type="Script" id=3] [ext_resource path="res://BodyConfig/LoadBodyParts.gd" type="Script" id=3]
[ext_resource path="res://Ingame/Arena.tscn" type="PackedScene" id=4] [ext_resource path="res://Ingame/Arena.tscn" type="PackedScene" id=4]
[ext_resource path="res://Resources/Fonts/SmallButtonFont.tres" type="DynamicFont" id=5]
[ext_resource path="res://Resources/Styles/ButtonHoverStyle.tres" type="StyleBox" id=6]
[ext_resource path="res://Resources/Styles/ButtonPressedStyle.tres" type="StyleBox" id=7]
[ext_resource path="res://Resources/Styles/ButtonNormalStyle.tres" type="StyleBox" id=8]
[node name="Body Builder Menu" type="Spatial"] [node name="Body Builder Menu" type="Spatial"]
script = ExtResource( 2 ) script = ExtResource( 2 )
@ -30,40 +34,51 @@ __meta__ = {
} }
[node name="VBoxC" type="VBoxContainer" parent="GUI/HBoxC"] [node name="VBoxC" type="VBoxContainer" parent="GUI/HBoxC"]
margin_right = 300.0 margin_right = 301.0
margin_bottom = 600.0 margin_bottom = 600.0
rect_min_size = Vector2( 300, 500 ) rect_min_size = Vector2( 300, 500 )
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="HBoxContainer" type="HBoxContainer" parent="GUI/HBoxC/VBoxC"] [node name="HBoxContainer" type="HBoxContainer" parent="GUI/HBoxC/VBoxC"]
margin_right = 300.0 margin_right = 301.0
margin_bottom = 14.0 margin_bottom = 38.0
[node name="Label" type="Label" parent="GUI/HBoxC/VBoxC/HBoxContainer"] [node name="Label" type="Label" parent="GUI/HBoxC/VBoxC/HBoxContainer"]
margin_right = 36.0 margin_right = 47.0
margin_bottom = 14.0 margin_bottom = 38.0
custom_fonts/font = ExtResource( 5 )
text = "Cost: " text = "Cost: "
[node name="ProgressBar" type="ProgressBar" parent="GUI/HBoxC/VBoxC/HBoxContainer"] [node name="ProgressBar" type="ProgressBar" parent="GUI/HBoxC/VBoxC/HBoxContainer"]
margin_left = 40.0 margin_left = 51.0
margin_right = 240.0 margin_right = 301.0
margin_bottom = 14.0 margin_bottom = 38.0
rect_min_size = Vector2( 200, 0 ) rect_min_size = Vector2( 250, 30 )
size_flags_vertical = 3
custom_fonts/font = ExtResource( 5 )
[node name="Start" type="Button" parent="GUI/HBoxC/VBoxC"] [node name="Start" type="Button" parent="GUI/HBoxC/VBoxC"]
margin_top = 18.0 margin_top = 42.0
margin_right = 300.0 margin_right = 301.0
margin_bottom = 38.0 margin_bottom = 80.0
custom_styles/hover = ExtResource( 6 )
custom_styles/pressed = ExtResource( 7 )
custom_styles/normal = ExtResource( 8 )
custom_fonts/font = ExtResource( 5 )
text = "Start Game" text = "Start Game"
[node name="Delete" type="Button" parent="GUI/HBoxC/VBoxC"] [node name="Delete" type="Button" parent="GUI/HBoxC/VBoxC"]
margin_top = 42.0 margin_top = 84.0
margin_right = 300.0 margin_right = 301.0
margin_bottom = 62.0 margin_bottom = 122.0
custom_styles/hover = ExtResource( 6 )
custom_styles/pressed = ExtResource( 7 )
custom_styles/normal = ExtResource( 8 )
custom_fonts/font = ExtResource( 5 )
text = "Delete" text = "Delete"
[node name="ViewportContainer" type="ViewportContainer" parent="GUI/HBoxC"] [node name="ViewportContainer" type="ViewportContainer" parent="GUI/HBoxC"]
margin_left = 304.0 margin_left = 305.0
margin_right = 1024.0 margin_right = 1024.0
margin_bottom = 600.0 margin_bottom = 600.0
rect_min_size = Vector2( 500, 500 ) rect_min_size = Vector2( 500, 500 )
@ -72,7 +87,7 @@ size_flags_vertical = 3
stretch = true stretch = true
[node name="Viewport" type="Viewport" parent="GUI/HBoxC/ViewportContainer"] [node name="Viewport" type="Viewport" parent="GUI/HBoxC/ViewportContainer"]
size = Vector2( 720, 600 ) size = Vector2( 719, 600 )
handle_input_locally = false handle_input_locally = false
render_target_update_mode = 3 render_target_update_mode = 3

View File

@ -0,0 +1,7 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://Resources/Fonts/beneg___.ttf" type="DynamicFontData" id=1]
[resource]
size = 36
font_data = ExtResource( 1 )

17
UI/LimbButton.tscn Normal file
View File

@ -0,0 +1,17 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Resources/Fonts/SmallButtonFont.tres" type="DynamicFont" id=1]
[ext_resource path="res://Resources/Styles/ButtonHoverStyle.tres" type="StyleBox" id=2]
[ext_resource path="res://Resources/Styles/ButtonPressedStyle.tres" type="StyleBox" id=3]
[ext_resource path="res://Resources/Styles/ButtonNormalStyle.tres" type="StyleBox" id=4]
[node name="Button" type="Button"]
margin_right = 301.0
margin_bottom = 38.0
custom_styles/hover = ExtResource( 2 )
custom_styles/pressed = ExtResource( 3 )
custom_styles/normal = ExtResource( 4 )
custom_fonts/font = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}