summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/HackButton.gd27
-rw-r--r--components/HackButton.tscn37
-rw-r--r--components/button.gd2
-rw-r--r--components/button.tscn1
-rw-r--r--components/textreveal.gd46
-rw-r--r--components/textreveal.tscn19
6 files changed, 67 insertions, 65 deletions
diff --git a/components/HackButton.gd b/components/HackButton.gd
deleted file mode 100644
index 9dc1b30..0000000
--- a/components/HackButton.gd
+++ /dev/null
@@ -1,27 +0,0 @@
-extends Area2D
-
-signal on_click()
-
-var is_hovered = false
-
-onready var sprite : Sprite = $Sprite
-export(String, FILE, '*.png') var hovered_texture = "res://textures/blauuu.png"
-onready var _hovered_texture : Texture = load(hovered_texture)
-onready var _default_texture : Texture = sprite.texture
-
-func _on_HackButton_mouse_entered():
- is_hovered = true
- sprite.texture = _hovered_texture
-
-func _on_HackButton_mouse_exited():
- is_hovered = false
- sprite.texture = _default_texture
-
-
-func _on_HackButton_input_event(viewport, event, shape_idx):
- if not (event is InputEventMouseButton):
- return
- if not event.pressed:
- return
- emit_signal("on_click")
-
diff --git a/components/HackButton.tscn b/components/HackButton.tscn
deleted file mode 100644
index dd665f3..0000000
--- a/components/HackButton.tscn
+++ /dev/null
@@ -1,37 +0,0 @@
-[gd_scene load_steps=6 format=2]
-
-[ext_resource path="res://textures/rooot.png" type="Texture" id=1]
-[ext_resource path="res://components/HackButton.gd" type="Script" id=2]
-
-[sub_resource type="Shader" id=1]
-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=2]
-shader = SubResource( 1 )
-shader_param/glow_color = Color( 0.254902, 0, 0, 1 )
-
-[sub_resource type="RectangleShape2D" id=3]
-extents = Vector2( 100, 100 )
-
-[node name="HackButton" type="Area2D"]
-monitoring = false
-monitorable = false
-script = ExtResource( 2 )
-
-[node name="Sprite" type="Sprite" parent="."]
-material = SubResource( 2 )
-scale = Vector2( 0.5, 0.5 )
-texture = ExtResource( 1 )
-
-[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
-shape = SubResource( 3 )
-
-[connection signal="input_event" from="." to="." method="_on_HackButton_input_event"]
-[connection signal="mouse_entered" from="." to="." method="_on_HackButton_mouse_entered"]
-[connection signal="mouse_exited" from="." to="." method="_on_HackButton_mouse_exited"]
diff --git a/components/button.gd b/components/button.gd
index 4bce086..1171cbd 100644
--- a/components/button.gd
+++ b/components/button.gd
@@ -55,6 +55,8 @@ func _on_ButtonTest_input_event(viewport, event, shape_idx):
_set_pressed(false)
return
_set_pressed(true)
+ if not (event.button_index == BUTTON_LEFT):
+ return
emit_signal("on_click")
func _set_all_textures(l, m, r):
diff --git a/components/button.tscn b/components/button.tscn
index f7d0cea..6248b45 100644
--- a/components/button.tscn
+++ b/components/button.tscn
@@ -48,7 +48,6 @@ __meta__ = {
[node name="Hitbox" type="CollisionShape2D" parent="."]
shape = SubResource( 3 )
-
[connection signal="input_event" from="." to="." method="_on_ButtonTest_input_event"]
[connection signal="mouse_entered" from="." to="." method="_on_ButtonTest_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_ButtonTest_mouse_exited"]
diff --git a/components/textreveal.gd b/components/textreveal.gd
new file mode 100644
index 0000000..0d9004c
--- /dev/null
+++ b/components/textreveal.gd
@@ -0,0 +1,46 @@
+extends Node2D
+
+onready var font_source : RichTextLabel = $FontSource
+signal finished_reveal()
+
+export var text = "Text"
+export var speed = 100.0
+
+var revealed = 0
+var started = false
+var finished = false
+
+var label
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ label = RichTextLabel.new()
+ label.theme = font_source.theme
+ add_child(label)
+ label.rect_position = -label.rect_size / 2
+
+
+func _show_text(text):
+ label.add_text(text)
+ label.rect_position = -label.rect_size / 2
+
+# Called every frame. 'delta' is the elapsed time since the previous frame.
+func _process(delta):
+ if started:
+ var reveal = speed * delta
+ var oldreveal = revealed
+ revealed += reveal
+ var t = text.substr(oldreveal, revealed)
+ _show_text(t)
+ if text.length() <= revealed:
+ started = false
+ finished = true
+ emit_signal("finished_reveal")
+
+func start():
+ started = true
+ finished = false
+
+
+func has_finished():
+ return finished
diff --git a/components/textreveal.tscn b/components/textreveal.tscn
new file mode 100644
index 0000000..19a1833
--- /dev/null
+++ b/components/textreveal.tscn
@@ -0,0 +1,19 @@
+[gd_scene load_steps=5 format=2]
+
+[ext_resource path="res://components/textreveal.gd" type="Script" id=1]
+[ext_resource path="res://fonts/Fipps-Regular.otf" type="DynamicFontData" id=2]
+
+[sub_resource type="DynamicFont" id=1]
+font_data = ExtResource( 2 )
+
+[sub_resource type="Theme" id=2]
+default_font = SubResource( 1 )
+
+[node name="Node2D" type="Node2D"]
+script = ExtResource( 1 )
+
+[node name="FontSource" type="RichTextLabel" parent="."]
+theme = SubResource( 2 )
+__meta__ = {
+"_edit_use_anchors_": false
+}