Skip to content

Commit

Permalink
Optimized performance
Browse files Browse the repository at this point in the history
Fps is limited to 5 whenever nothing is happening.
  • Loading branch information
GsLogiMaker committed Oct 11, 2022
1 parent 5cb4f90 commit 9da0a81
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 1,040 deletions.
8 changes: 5 additions & 3 deletions BibleViwer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ func load_book_names() -> Array:


func get_chapter_text(book:String, chapter:int) -> String:
var path:= "Bibles/%s/%s_%s.txt" \
var path:= "res://bibles/%s/%s_%s.txt" \
% [bible_version, book.replace(" ", "_"), int(chapter)]
if not DirAccess.dir_exists_absolute(path):
path = "user://bibles/%s/%s_%s.txt" \
% [bible_version, book.replace(" ", "_"), int(chapter)]

var file:= FileAccess.open(path, FileAccess.READ)

if file == null:
return ""

return file.get_as_text()


Expand Down
27 changes: 0 additions & 27 deletions BibleViwer.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ chapter_tab = ExtResource("2_rn5h4")

[node name="ChapterTabs" type="MarginContainer" parent="."]
unique_name_in_owner = true
layout_mode = 2
offset_left = 5.0
offset_top = 5.0
offset_right = 1147.0
Expand All @@ -64,19 +63,16 @@ theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5

[node name="VBoxContainer" type="VBoxContainer" parent="Window/MarginContainer"]
layout_mode = 2
offset_left = 5.0
offset_top = 5.0
offset_right = 1147.0
offset_bottom = 643.0

[node name="TabControls" type="HBoxContainer" parent="Window/MarginContainer/VBoxContainer"]
layout_mode = 2
offset_right = 1142.0
offset_bottom = 31.0

[node name="ScrollContainer" type="ScrollContainer" parent="Window/MarginContainer/VBoxContainer/TabControls"]
layout_mode = 2
offset_right = 1049.0
offset_bottom = 31.0
size_flags_horizontal = 3
Expand All @@ -85,35 +81,30 @@ vertical_scroll_mode = 0

[node name="ChapterTabBar" type="TabBar" parent="Window/MarginContainer/VBoxContainer/TabControls/ScrollContainer"]
unique_name_in_owner = true
layout_mode = 2
offset_right = 1049.0
size_flags_horizontal = 3
clip_tabs = false
tab_close_display_policy = 2

[node name="NewTab" type="Button" parent="Window/MarginContainer/VBoxContainer/TabControls"]
layout_mode = 2
offset_left = 1053.0
offset_right = 1142.0
offset_bottom = 31.0
size_flags_vertical = 0
text = "+ New Tab"

[node name="BookSearchContainer" type="HBoxContainer" parent="Window/MarginContainer/VBoxContainer"]
layout_mode = 2
offset_top = 35.0
offset_right = 1142.0
offset_bottom = 66.0

[node name="VBoxContainer" type="VBoxContainer" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer"]
layout_mode = 2
offset_right = 569.0
offset_bottom = 31.0
size_flags_horizontal = 3

[node name="SearchBook" type="LineEdit" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
offset_right = 569.0
offset_bottom = 31.0
focus_neighbor_right = NodePath("../../SearchChapter")
Expand All @@ -126,20 +117,17 @@ script = SubResource("GDScript_jd8xs")
[node name="FuzzyBooks" type="PanelContainer" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer/VBoxContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
offset_top = 35.0
offset_right = 569.0
offset_bottom = 67.0

[node name="VBoxContainer" type="VBoxContainer" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer/VBoxContainer/FuzzyBooks"]
layout_mode = 2
offset_right = 569.0
offset_bottom = 32.0
theme_override_constants/separation = 0

[node name="FuzzyBook1" type="Button" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer/VBoxContainer/FuzzyBooks/VBoxContainer" node_paths=PackedStringArray("shortcut_context")]
unique_name_in_owner = true
layout_mode = 2
offset_right = 569.0
offset_bottom = 8.0
shortcut = SubResource("Shortcut_apwqq")
Expand All @@ -149,7 +137,6 @@ alignment = 0

[node name="FuzzyBook2" type="Button" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer/VBoxContainer/FuzzyBooks/VBoxContainer" node_paths=PackedStringArray("shortcut_context")]
unique_name_in_owner = true
layout_mode = 2
offset_top = 8.0
offset_right = 569.0
offset_bottom = 16.0
Expand All @@ -159,7 +146,6 @@ alignment = 0

[node name="FuzzyBook3" type="Button" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer/VBoxContainer/FuzzyBooks/VBoxContainer" node_paths=PackedStringArray("shortcut_context")]
unique_name_in_owner = true
layout_mode = 2
offset_top = 16.0
offset_right = 569.0
offset_bottom = 24.0
Expand All @@ -169,7 +155,6 @@ alignment = 0

[node name="FuzzyBook4" type="Button" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer/VBoxContainer/FuzzyBooks/VBoxContainer" node_paths=PackedStringArray("shortcut_context")]
unique_name_in_owner = true
layout_mode = 2
offset_top = 24.0
offset_right = 569.0
offset_bottom = 32.0
Expand All @@ -180,7 +165,6 @@ alignment = 0

[node name="SearchChapter" type="SpinBox" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer"]
unique_name_in_owner = true
layout_mode = 2
offset_left = 573.0
offset_right = 1142.0
offset_bottom = 31.0
Expand All @@ -193,7 +177,6 @@ value = 1.0
[node name="SearchVerse" type="SpinBox" parent="Window/MarginContainer/VBoxContainer/BookSearchContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
offset_left = 764.0
offset_right = 1142.0
offset_bottom = 31.0
Expand All @@ -204,21 +187,18 @@ max_value = 200.0
value = 1.0

[node name="PageLabel" type="Label" parent="Window/MarginContainer/VBoxContainer"]
layout_mode = 2
offset_top = 70.0
offset_right = 1142.0
offset_bottom = 96.0
text = "Page Resolution"

[node name="PageResolutionControls" type="HBoxContainer" parent="Window/MarginContainer/VBoxContainer"]
layout_mode = 2
offset_top = 100.0
offset_right = 1142.0
offset_bottom = 131.0

[node name="PageResolutionX" type="SpinBox" parent="Window/MarginContainer/VBoxContainer/PageResolutionControls"]
unique_name_in_owner = true
layout_mode = 2
offset_right = 516.0
offset_bottom = 31.0
size_flags_horizontal = 3
Expand All @@ -229,7 +209,6 @@ suffix = "px"

[node name="PageResolutionY" type="SpinBox" parent="Window/MarginContainer/VBoxContainer/PageResolutionControls"]
unique_name_in_owner = true
layout_mode = 2
offset_left = 520.0
offset_right = 1037.0
offset_bottom = 31.0
Expand All @@ -241,37 +220,32 @@ suffix = "px"

[node name="PageResiazable" type="CheckBox" parent="Window/MarginContainer/VBoxContainer/PageResolutionControls"]
unique_name_in_owner = true
layout_mode = 2
offset_left = 1041.0
offset_right = 1142.0
offset_bottom = 31.0
button_pressed = true
text = "Resizable"

[node name="FontLabel" type="Label" parent="Window/MarginContainer/VBoxContainer"]
layout_mode = 2
offset_top = 135.0
offset_right = 1142.0
offset_bottom = 161.0
text = "Font"

[node name="FontControls" type="HBoxContainer" parent="Window/MarginContainer/VBoxContainer"]
layout_mode = 2
offset_top = 165.0
offset_right = 1142.0
offset_bottom = 196.0

[node name="FontSizeLabel" type="Label" parent="Window/MarginContainer/VBoxContainer/FontControls"]
self_modulate = Color(0.678431, 0.678431, 0.678431, 1)
layout_mode = 2
offset_top = 2.0
offset_right = 70.0
offset_bottom = 28.0
text = "Font Size"

[node name="FontSize" type="SpinBox" parent="Window/MarginContainer/VBoxContainer/FontControls"]
unique_name_in_owner = true
layout_mode = 2
offset_left = 74.0
offset_right = 157.0
offset_bottom = 31.0
Expand All @@ -282,7 +256,6 @@ suffix = "px"
[node name="PanelContainer" type="PanelContainer" parent="Window/MarginContainer/VBoxContainer"]
visible = false
self_modulate = Color(1, 1, 1, 0)
layout_mode = 2
offset_top = 200.0
offset_right = 1142.0
offset_bottom = 638.0
Expand Down
8 changes: 8 additions & 0 deletions Scenes/ChapterTab.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ extends VBoxContainer
text = v
%BibleText.text = text



func _on_text_scroll_velocity_started() -> void:
Engine.target_fps = 30


func _on_text_scroll_velocity_stopped() -> void:
Engine.target_fps = 5
15 changes: 14 additions & 1 deletion Scenes/ChapterTab.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ grow_vertical = 2
script = ExtResource("1_qo15t")

[node name="PanelContainer2" type="PanelContainer" parent="."]
layout_mode = 2
offset_right = 1152.0
offset_bottom = 46.0

[node name="MarginContainer" type="MarginContainer" parent="PanelContainer2"]
layout_mode = 2
offset_right = 1152.0
offset_bottom = 46.0
theme_override_constants/margin_left = 10
Expand All @@ -58,6 +60,7 @@ theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10

[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer2/MarginContainer"]
layout_mode = 2
offset_left = 10.0
offset_top = 10.0
offset_right = 1142.0
Expand All @@ -66,12 +69,14 @@ theme_override_constants/separation = 0

[node name="BookTitle" type="Label" parent="PanelContainer2/MarginContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
offset_right = 38.0
offset_bottom = 26.0
text = "Luke"

[node name="TextScroll" type="ScrollContainer" parent="."]
visible = false
layout_mode = 2
offset_top = 50.0
offset_right = 1152.0
offset_bottom = 347.0
Expand All @@ -80,12 +85,14 @@ theme = SubResource("Theme_d175w")
horizontal_scroll_mode = 0

[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 2
offset_top = 50.0
offset_right = 1152.0
offset_bottom = 648.0
size_flags_vertical = 3

[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
layout_mode = 2
offset_right = 1152.0
offset_bottom = 598.0
theme_override_constants/margin_left = 10
Expand All @@ -95,17 +102,20 @@ theme_override_constants/margin_bottom = 10

[node name="TextScroll" type="ScrollContainer" parent="PanelContainer/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
offset_left = 10.0
offset_top = 10.0
offset_right = 1142.0
offset_bottom = 588.0
theme = SubResource("Theme_d175w")
script = ExtResource("2_h6cu7")
speed = 1.0
speed = 3.0
damping = 0.05
friction_scroll = 0.91

[node name="BibleText" type="RichTextLabel" parent="PanelContainer/MarginContainer/TextScroll"]
unique_name_in_owner = true
layout_mode = 2
offset_right = 1132.0
offset_bottom = 920.0
size_flags_horizontal = 3
Expand Down Expand Up @@ -153,3 +163,6 @@ context_menu_enabled = true
custom_effects = [ExtResource("3_i2cr3")]
progress_bar_delay = 0
selection_enabled = true

[connection signal="velocity_started" from="PanelContainer/MarginContainer/TextScroll" to="." method="_on_text_scroll_velocity_started"]
[connection signal="velocity_stopped" from="PanelContainer/MarginContainer/TextScroll" to="." method="_on_text_scroll_velocity_stopped"]
Loading

0 comments on commit 9da0a81

Please sign in to comment.