Skip to content

Commit

Permalink
new quote format
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Platt authored and Marc Platt committed Aug 2, 2024
1 parent ec80477 commit e5d607f
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 61 deletions.
Binary file modified resource/theme/black.theme
Binary file not shown.
6 changes: 4 additions & 2 deletions source/nodes/chain_providers_info/chain_provider_info.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

[ext_resource type="Script" path="res://source/nodes/chain_providers_info/chain_provider_info.gd" id="1_0uufu"]
[ext_resource type="FontFile" uid="uid://b1w37357tl3er" path="res://assets/fonts/Cantarell-Bold.ttf" id="2_jumpv"]
[ext_resource type="Texture2D" uid="uid://hcq0d87vm0xk" path="res://assets/images/folder-open-symbolic 1.svg" id="3_3cbqg"]

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_ihaj0"]
load_path = "res://.godot/imported/folder-open-symbolic 1.svg-d125f1a60e971d20e00dbf1ea893e0f1.editor.ctex"

[node name="ChainProviderInfo" type="ColorRect"]
anchors_preset = 15
Expand Down Expand Up @@ -103,7 +105,7 @@ expand_to_text_length = true

[node name="Button" type="Button" parent="Center/Panel/Margin/VBox/SidechainDirectory"]
layout_mode = 2
icon = ExtResource("3_3cbqg")
icon = SubResource("CompressedTexture2D_ihaj0")

[node name="LocalHash" type="HBoxContainer" parent="Center/Panel/Margin/VBox"]
layout_mode = 2
Expand Down
2 changes: 1 addition & 1 deletion source/nodes/node_panel/download.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ signal action_requested(action)
const DOWNLOAD_ICON = preload("res://assets/images/download-cloud-svgrepo.svg")
const RUN_ICON = preload("res://assets/images/play-svgrepo-com.svg")
const STOP_ICON = preload("res://assets/images/stop-circle-svgrepo-com.svg")
const CUSTOM_FONT = preload("res://assets/fonts/Cantarell-Regular.ttf")
const CUSTOM_FONT = preload("res://assets/fonts/Satoshi-Regular.otf")

enum STATE { NOT_DOWNLOADED, DOWNLOADING, NOT_RUNNING, RUNNING }

Expand Down
6 changes: 4 additions & 2 deletions source/nodes/node_panel/download.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[gd_scene load_steps=9 format=3 uid="uid://cjfcxi77d8pjt"]

[ext_resource type="Script" path="res://source/nodes/node_panel/download.gd" id="1_no5dn"]
[ext_resource type="Texture2D" uid="uid://sitylibnubgw" path="res://assets/images/download-cloud-svgrepo.svg" id="2_g8yfn"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2befl"]
bg_color = Color(1, 1, 1, 1)
Expand All @@ -24,6 +23,9 @@ corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_jn0ri"]
load_path = "res://.godot/imported/download-cloud-svgrepo.svg-5d91d83002443aa7d3d37428d7c35944.ctex"

[sub_resource type="Animation" id="Animation_rsgv1"]
length = 0.001
tracks/0/type = "value"
Expand Down Expand Up @@ -109,7 +111,7 @@ layout_mode = 2
texture_filter = 4
custom_minimum_size = Vector2(24, 24)
layout_mode = 2
texture = ExtResource("2_g8yfn")
texture = SubResource("CompressedTexture2D_jn0ri")
expand_mode = 1
stretch_mode = 5

Expand Down
18 changes: 12 additions & 6 deletions source/nodes/node_panel/node_panel.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[gd_scene load_steps=9 format=3 uid="uid://cq65ocurdi7c1"]

[ext_resource type="Script" path="res://source/nodes/node_panel/node_panel.gd" id="1_ijj0w"]
[ext_resource type="Texture2D" uid="uid://2xouba13q8q7" path="res://assets/images/pattern_33.png" id="2_lb2fn"]
[ext_resource type="PackedScene" uid="uid://cjfcxi77d8pjt" path="res://source/nodes/node_panel/download.tscn" id="2_ubul7"]
[ext_resource type="Texture2D" uid="uid://drrrqh5w6tl8t" path="res://assets/images/icons8-settings.svg" id="4_8w22k"]
[ext_resource type="FontFile" uid="uid://b1w37357tl3er" path="res://assets/fonts/Cantarell-Bold.ttf" id="4_h86ci"]
[ext_resource type="Texture2D" uid="uid://jpde6uqywmlg" path="res://assets/images/trash-svgrepo-com(1).svg" id="8_8l4af"]

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_bl3lx"]
load_path = "res://.godot/imported/pattern_33.png-6a06ad3b641dc052103386e82d92dac9.ctex"

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dqqs8"]
bg_color = Color(0.6, 0.6, 0.6, 0)
Expand All @@ -23,6 +23,12 @@ expand_margin_top = 8.0
expand_margin_right = 8.0
expand_margin_bottom = 8.0

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_orksi"]
load_path = "res://.godot/imported/icons8-settings.svg-3abab0a1cc1e22f71f96e60e0862595e.ctex"

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_aqe83"]
load_path = "res://.godot/imported/trash-svgrepo-com(1).svg-0f38edd909f1c2b1144dc0fc23313836.ctex"

[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_cnrh3"]

[node name="NodePanel" type="Control"]
Expand All @@ -45,7 +51,7 @@ anchor_bottom = 1.0
offset_right = -8.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("2_lb2fn")
texture = SubResource("CompressedTexture2D_bl3lx")
expand_mode = 1
stretch_mode = 1

Expand Down Expand Up @@ -93,15 +99,15 @@ custom_minimum_size = Vector2(0, 32)
layout_mode = 2
size_flags_vertical = 4
focus_mode = 0
icon = ExtResource("4_8w22k")
icon = SubResource("CompressedTexture2D_orksi")

[node name="Delete" type="Button" parent="MarginContainer/Container/Header"]
texture_filter = 4
custom_minimum_size = Vector2(0, 32)
layout_mode = 2
size_flags_vertical = 4
focus_mode = 0
icon = ExtResource("8_8l4af")
icon = SubResource("CompressedTexture2D_aqe83")

[node name="Description" type="Label" parent="MarginContainer/Container"]
layout_mode = 2
Expand Down
37 changes: 12 additions & 25 deletions ui/components/left_menu/left_menu.gd
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
extends PanelContainer

@onready var quotes_label: Label = $MarginContainer/HBox/Quotes
@onready var author_label: Label = $MarginContainer/HBox/Author
@onready var next_button: Button = $MarginContainer/HBox/NextButton
@onready var prev_button: Button = $MarginContainer/HBox/PrevButton

var quotes: Array = []
var current_quote_index: int = 0
var quote_timer: Timer

func _ready() -> void:
load_quotes()
change_quote(0)
next_button.pressed.connect(self._on_next_button_pressed)
prev_button.pressed.connect(self._on_prev_button_pressed)

quote_timer = Timer.new()
quote_timer.timeout.connect(self._on_quote_timer_timeout)
quote_timer.set_wait_time(10)
add_child(quote_timer)
quote_timer.start()

func load_quotes():
var file_path = "res://assets/data/quotes.json"
Expand Down Expand Up @@ -48,43 +41,37 @@ func change_quote(index: int):
var quote_data = quotes[index]
if quote_data is Dictionary and quote_data.has("quote") and quote_data.has("author"):
var quote_text = quote_data["quote"]
quotes_label.text = "\"" + quote_text + "\""
author_label.text = "- " + quote_data["author"]
var author_text = quote_data["author"]

quotes_label.text = "\"" + quote_text + "\n- " + author_text + "\""

var word_count = quote_text.split(" ").size()
if word_count < 30:
quotes_label.add_theme_font_size_override("font_size", 17)
quotes_label.add_theme_font_size_override("font_size", 15)
elif word_count < 50:
quotes_label.add_theme_font_size_override("font_size", 14)
else:
quotes_label.add_theme_font_size_override("font_size", 13)
else:
quotes_label.add_theme_font_size_override("font_size", 11)

# Adjust the position of the author's name
quotes_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
await get_tree().process_frame # Wait for the label to update
var last_line_start = quotes_label.get_line_count() - 1
else:
push_error("Invalid quote data format")

func fade_quote(index: int):
var fade_tween: Tween = create_tween()
fade_tween.tween_property(quotes_label, "modulate", Color(1,1,1,0), 0.25)
fade_tween.parallel().tween_property(author_label, "modulate", Color(1,1,1,0), 0.25)
await fade_tween.finished
change_quote(index)
fade_tween = create_tween()
fade_tween.tween_property(quotes_label, "modulate", Color(1,1,1,1), 0.25)
fade_tween.parallel().tween_property(author_label, "modulate", Color(1,1,1,1), 0.25)

func _on_next_button_pressed():
current_quote_index = (current_quote_index + 1) % quotes.size()
fade_quote(current_quote_index)
reset_quote_timer()

func _on_prev_button_pressed():
current_quote_index = (current_quote_index - 1 + quotes.size()) % quotes.size()
fade_quote(current_quote_index)
reset_quote_timer()

func _on_quote_timer_timeout():
current_quote_index = (current_quote_index + 1) % quotes.size()
fade_quote(current_quote_index)

func reset_quote_timer():
quote_timer.stop()
quote_timer.start()
40 changes: 15 additions & 25 deletions ui/components/left_menu/left_menu.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=8 format=3 uid="uid://dwhtby81ylt3s"]

[ext_resource type="Script" path="res://ui/components/left_menu/left_menu.gd" id="1_yja75"]
[ext_resource type="Texture2D" uid="uid://blq6pvspmkcbj" path="res://assets/images/prev.svg" id="3_3lhq3"]
[ext_resource type="Texture2D" uid="uid://c5ddyq86urmmy" path="res://assets/images/next.svg" id="7_k0tsh"]
[ext_resource type="Texture2D" uid="uid://c865fxarlp4e1" path="res://assets/images/left-arrow-svgrepo-com.png" id="2_5g8my"]
[ext_resource type="Texture2D" uid="uid://4ulwmgydwoi2" path="res://assets/images/right-arrow-next-svgrepo-com (2).png" id="3_2rq81"]
[ext_resource type="Script" path="res://ui/components/left_menu/Quotes.gd" id="7_kx1k8"]
[ext_resource type="FontFile" uid="uid://ciu7chyqqs4k7" path="res://assets/fonts/Saira_Expanded-Bold.ttf" id="11_6qy05"]
[ext_resource type="FontFile" uid="uid://dgxbgdcr3s84u" path="res://assets/fonts/Saira_Expanded-Regular.ttf" id="12_nwgc3"]
Expand Down Expand Up @@ -37,26 +37,30 @@ size_flags_stretch_ratio = 0.0
theme_override_constants/separation = 8

[node name="PrevButton" type="Button" parent="MarginContainer/HBox"]
texture_filter = 4
layout_mode = 2
text = "Prev"
size_flags_horizontal = 4
size_flags_vertical = 4
icon = ExtResource("2_5g8my")
flat = true

[node name="Quotes" type="Label" parent="MarginContainer/HBox"]
custom_minimum_size = Vector2(250, 0)
layout_direction = 3
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
theme_override_font_sizes/font_size = 13
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2

[node name="Author" type="Label" parent="MarginContainer/HBox"]
layout_mode = 2
theme_override_font_sizes/font_size = 16

[node name="NextButton" type="Button" parent="MarginContainer/HBox"]
texture_filter = 4
layout_mode = 2
text = "Next"
size_flags_horizontal = 8
size_flags_vertical = 4
icon = ExtResource("3_2rq81")
flat = true

[node name="QuotesDialog" type="AcceptDialog" parent="."]
title = "QUOTES"
Expand All @@ -77,13 +81,6 @@ grow_vertical = 2
[node name="Header" type="HBoxContainer" parent="QuotesDialog/Box"]
layout_mode = 2

[node name="PrevButton" type="Button" parent="QuotesDialog/Box/Header"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
icon = ExtResource("3_3lhq3")
flat = true

[node name="Author" type="Label" parent="QuotesDialog/Box/Header"]
layout_mode = 2
size_flags_horizontal = 3
Expand All @@ -97,13 +94,6 @@ text = "Name"
horizontal_alignment = 1
vertical_alignment = 1

[node name="NextButton" type="Button" parent="QuotesDialog/Box/Header"]
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 4
icon = ExtResource("7_k0tsh")
flat = true

[node name="Margin" type="ColorRect" parent="QuotesDialog/Box"]
custom_minimum_size = Vector2(0, 1)
layout_mode = 2
Expand All @@ -121,5 +111,5 @@ autowrap_mode = 2
script = ExtResource("7_kx1k8")
author_label = NodePath("../Header/Author")

[connection signal="pressed" from="QuotesDialog/Box/Header/PrevButton" to="QuotesDialog/Box/Quotes" method="_on_prev_button_pressed"]
[connection signal="pressed" from="QuotesDialog/Box/Header/NextButton" to="QuotesDialog/Box/Quotes" method="_on_next_button_pressed"]
[connection signal="pressed" from="MarginContainer/HBox/PrevButton" to="QuotesDialog/Box/Quotes" method="_on_prev_button_pressed"]
[connection signal="pressed" from="MarginContainer/HBox/NextButton" to="QuotesDialog/Box/Quotes" method="_on_next_button_pressed"]

0 comments on commit e5d607f

Please sign in to comment.