Files
uarep-ctl/scenes/button-flat/button-flat.tscn

114 lines
3.4 KiB
Plaintext

[gd_scene load_steps=13 format=3 uid="uid://da7w3vkhadfwe"]
[ext_resource type="Script" path="res://scenes/button-flat/nine-patch-button.gd" id="1_ui6sg"]
[ext_resource type="Texture2D" uid="uid://ct0ajcwno03h7" path="res://data/кнопка-квадрат-0.png" id="2_0cn5u"]
[sub_resource type="StyleBoxEmpty" id="1"]
[sub_resource type="Shader" id="Shader_2bftm"]
code = "shader_type canvas_item;
uniform vec4 color_gap = vec4(0.0, 0.0, 0.0, 0.0);
uniform vec4 color_stripe = vec4(0.3, 0.3, 0.3, 0.7);
uniform float divisions = 50.0; // increase for more stripe density
uniform float stripe_bias = 2.0; // 1.0 means no stripes; 2.0 means stripes and gaps are equal size
uniform float speed = 0.01;
uniform float angle = 0.7854; // in radians
uniform bool disabled = false;
void fragment()
{
float w = cos(angle) * UV.x + sin(angle) * UV.y - speed * TIME;
if ((floor(mod(w * divisions, stripe_bias)) < 0.0001) && disabled)
{
COLOR = color_gap;
}
else
{
COLOR = color_stripe;
}
}
"
[sub_resource type="ShaderMaterial" id="ShaderMaterial_hhdyc"]
resource_local_to_scene = true
shader = SubResource("Shader_2bftm")
shader_parameter/color_gap = Vector4(1, 1, 1, 0.3)
shader_parameter/color_stripe = Vector4(0, 0, 1, 0)
shader_parameter/divisions = 50.0
shader_parameter/stripe_bias = 2.0
shader_parameter/speed = 0.0
shader_parameter/angle = 0.7854
shader_parameter/disabled = false
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_6nup5"]
[sub_resource type="GDScript" id="GDScript_uyl5d"]
script/source = "@tool
extends Sprite2D
@export var speed: float = 0.01:
set(val): material.set('shader_parameter/speed', val)
get: return material.get('shader_parameter/speed')
@export var disabled: bool = false:
set(val): material.set('shader_parameter/disabled', val)
get: return material.get('shader_parameter/disabled')
"
[sub_resource type="StyleBoxEmpty" id="6"]
[sub_resource type="StyleBoxEmpty" id="2"]
[sub_resource type="StyleBoxEmpty" id="3"]
[sub_resource type="StyleBoxEmpty" id="5"]
[sub_resource type="StyleBoxEmpty" id="4"]
[node name="container" type="PanelContainer"]
offset_right = 30.0
offset_bottom = 30.0
theme_override_styles/panel = SubResource("1")
script = ExtResource("1_ui6sg")
toggle_mode = true
[node name="state" type="NinePatchRect" parent="."]
layout_mode = 2
texture = ExtResource("2_0cn5u")
patch_margin_left = 10
patch_margin_top = 10
patch_margin_right = 10
patch_margin_bottom = 10
axis_stretch_horizontal = 2
axis_stretch_vertical = 2
[node name="back" type="Sprite2D" parent="."]
material = SubResource("ShaderMaterial_hhdyc")
scale = Vector2(30, 30)
texture = SubResource("PlaceholderTexture2D_6nup5")
centered = false
script = SubResource("GDScript_uyl5d")
speed = 0.0
[node name="button" type="Button" parent="."]
layout_mode = 2
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 4
theme_override_styles/normal = SubResource("6")
theme_override_styles/hover = SubResource("2")
theme_override_styles/pressed = SubResource("3")
theme_override_styles/disabled = SubResource("5")
theme_override_styles/focus = SubResource("4")
toggle_mode = true
clip_text = true
[connection signal="resized" from="." to="." method="_on_resized"]
[connection signal="visibility_changed" from="back" to="back" method="_on_visibility_changed"]
[connection signal="toggled" from="button" to="." method="_on_button_toggled"]