From 3a22d5f9a6e539deb1fee5209af3557ae2b598fa Mon Sep 17 00:00:00 2001 From: Jonas Bernard Date: Sat, 24 Apr 2021 22:11:35 +0200 Subject: Push --- components/HackButton.tscn | 12 ++++++------ components/button.gd | 20 ++++++++++++++++++++ components/button.tscn | 44 ++++++++++++++++++++++++++++++++++++++++++++ components/buttontest.gd | 20 -------------------- components/buttontest.tscn | 46 ---------------------------------------------- 5 files changed, 70 insertions(+), 72 deletions(-) create mode 100644 components/button.gd create mode 100644 components/button.tscn delete mode 100644 components/buttontest.gd delete mode 100644 components/buttontest.tscn (limited to 'components') diff --git a/components/HackButton.tscn b/components/HackButton.tscn index e3f61bb..2241ac6 100644 --- a/components/HackButton.tscn +++ b/components/HackButton.tscn @@ -4,12 +4,12 @@ [ext_resource path="res://components/HackButton.gd" type="Script" id=2] [sub_resource type="Shader" id=2] -code = "shader_type canvas_item; -uniform vec4 glow_color : hint_color = vec4(1,1,1,1); - -void fragment() { - COLOR = texture(TEXTURE, UV) + glow_color; -} +code = "shader_type canvas_item; +uniform vec4 glow_color : hint_color = vec4(1,1,1,1); + +void fragment() { + COLOR = texture(TEXTURE, UV) + glow_color; +} " [sub_resource type="ShaderMaterial" id=3] diff --git a/components/button.gd b/components/button.gd new file mode 100644 index 0000000..0303480 --- /dev/null +++ b/components/button.gd @@ -0,0 +1,20 @@ +extends Node2D +class_name ButtonTest +export var text = "Hello, Button" +onready var stretcher : Node2D = $Middle +onready var left : Node2D = $Left +onready var right : Node2D = $Right +onready var font_source : RichTextLabel = $FontSource +const BASE_WIDTH = 6 + +func _ready(): + var label = Label.new() + label.text = text + label.theme = font_source.theme + add_child(label) + label.rect_position = -label.rect_size / 2 + var width = label.rect_size.x + stretcher.scale.x = width / BASE_WIDTH + left.position.x = -label.rect_size.x / 2 - BASE_WIDTH + right.position.x = label.rect_size.x / 2 + diff --git a/components/button.tscn b/components/button.tscn new file mode 100644 index 0000000..9519475 --- /dev/null +++ b/components/button.tscn @@ -0,0 +1,44 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://textures/components/button/middle.png" type="Texture" id=1] +[ext_resource path="res://textures/components/button/right.png" type="Texture" id=2] +[ext_resource path="res://fonts/Fipps-Regular.otf" type="DynamicFontData" id=3] +[ext_resource path="res://textures/components/button/left.png" type="Texture" id=4] +[ext_resource path="res://components/button.gd" type="Script" id=5] + +[sub_resource type="DynamicFont" id=1] +outline_color = Color( 0, 0, 0, 1 ) +font_data = ExtResource( 3 ) + +[sub_resource type="Theme" id=2] +default_font = SubResource( 1 ) + +[node name="ButtonTest" type="Node2D"] +script = ExtResource( 5 ) + +[node name="Left" type="Sprite" parent="."] +position = Vector2( -100, 0 ) +scale = Vector2( 4, 4 ) +texture = ExtResource( 4 ) + +[node name="Right" type="Sprite" parent="."] +position = Vector2( 100, 0 ) +scale = Vector2( 4, 4 ) +texture = ExtResource( 2 ) + +[node name="Middle" type="Sprite" parent="."] +position = Vector2( -0.5, 0 ) +scale = Vector2( 30.321, 4 ) +texture = ExtResource( 1 ) + +[node name="FontSource" type="RichTextLabel" parent="."] +grow_horizontal = 2 +grow_vertical = 2 +rect_clip_content = false +size_flags_horizontal = 3 +theme = SubResource( 2 ) +text = "Menu" +scroll_active = false +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/components/buttontest.gd b/components/buttontest.gd deleted file mode 100644 index 0303480..0000000 --- a/components/buttontest.gd +++ /dev/null @@ -1,20 +0,0 @@ -extends Node2D -class_name ButtonTest -export var text = "Hello, Button" -onready var stretcher : Node2D = $Middle -onready var left : Node2D = $Left -onready var right : Node2D = $Right -onready var font_source : RichTextLabel = $FontSource -const BASE_WIDTH = 6 - -func _ready(): - var label = Label.new() - label.text = text - label.theme = font_source.theme - add_child(label) - label.rect_position = -label.rect_size / 2 - var width = label.rect_size.x - stretcher.scale.x = width / BASE_WIDTH - left.position.x = -label.rect_size.x / 2 - BASE_WIDTH - right.position.x = label.rect_size.x / 2 - diff --git a/components/buttontest.tscn b/components/buttontest.tscn deleted file mode 100644 index d0d4e6b..0000000 --- a/components/buttontest.tscn +++ /dev/null @@ -1,46 +0,0 @@ -[gd_scene load_steps=7 format=2] - -[ext_resource path="res://textures/components/button/middle.png" type="Texture" id=1] -[ext_resource path="res://textures/components/button/right.png" type="Texture" id=2] -[ext_resource path="res://fonts/Fipps-Regular.otf" type="DynamicFontData" id=3] -[ext_resource path="res://textures/components/button/left.png" type="Texture" id=4] - -[sub_resource type="DynamicFont" id=1] -outline_color = Color( 0, 0, 0, 1 ) -font_data = ExtResource( 3 ) - -[sub_resource type="Theme" id=2] -default_font = SubResource( 1 ) - -[node name="Node2D" type="Node2D"] - -[node name="Left" type="Sprite" parent="."] -position = Vector2( -100, 0 ) -scale = Vector2( 4, 4 ) -texture = ExtResource( 4 ) - -[node name="Right" type="Sprite" parent="."] -position = Vector2( 100, 0 ) -scale = Vector2( 4, 4 ) -texture = ExtResource( 2 ) - -[node name="Middle" type="Sprite" parent="."] -scale = Vector2( 30.321, 4 ) -texture = ExtResource( 1 ) - -[node name="RichTextLabel" type="RichTextLabel" parent="."] -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -margin_left = -31.9373 -margin_top = -19.027 -margin_right = 76.0627 -margin_bottom = 27.973 -grow_horizontal = 2 -grow_vertical = 2 -theme = SubResource( 2 ) -text = "Menu" -__meta__ = { -"_edit_use_anchors_": false -} -- cgit