aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-08-12 18:56:14 +0200
committer Hop311 <hop3114@gmail.com>2023-08-12 18:56:14 +0200
commitfe74604d96d1d28b811ebe45d1d06356cf79bc6f (patch)
treef57c608c657681666c29e28bf1283833767cb7ea /game
parent4c43951e70aaa2e7265d3b3f3c4964c048b9328d (diff)
string_view changes + general cleanup
Diffstat (limited to 'game')
-rw-r--r--game/src/Game/Autoload/GuiScale.gd10
-rw-r--r--game/src/Game/GameStart.gd9
-rw-r--r--game/src/Game/GameStart.tscn3
-rw-r--r--game/src/Game/LoadingScreen.gd10
-rw-r--r--game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd2
-rw-r--r--game/src/Game/Theme/PieChart/PieChart.gd14
6 files changed, 16 insertions, 32 deletions
diff --git a/game/src/Game/Autoload/GuiScale.gd b/game/src/Game/Autoload/GuiScale.gd
index afd73df..d364ff5 100644
--- a/game/src/Game/Autoload/GuiScale.gd
+++ b/game/src/Game/Autoload/GuiScale.gd
@@ -26,7 +26,7 @@ func _ready():
func has_guiscale(guiscale_value : float) -> bool:
return guiscale_value in _guiscales
-
+
func add_guiscale(guiscale_value: float, guiscale_name: StringName=&"") -> bool:
if has_guiscale(guiscale_value): return true
var scale_dict := { value = guiscale_value }
@@ -39,24 +39,24 @@ func add_guiscale(guiscale_value: float, guiscale_name: StringName=&"") -> bool:
return false
_guiscales[guiscale_value] = scale_dict
return true
-
+
#returns floats
func get_guiscale_value_list() -> Array:
var list := _guiscales.keys()
list.sort_custom(func(a, b): return a > b)
return list
-
+
func get_guiscale_display_name(guiscale_value : float) -> StringName:
return _guiscales.get(guiscale_value, {display_name = &"unknown gui scale"}).display_name
func get_current_guiscale() -> float:
return get_tree().root.content_scale_factor
-
+
func set_guiscale(guiscale:float) -> void:
print("New GUI scale: %f" % guiscale)
if not has_guiscale(guiscale):
push_warning("Setting GUI Scale to non-standard value %sx" % [guiscale])
get_tree().root.content_scale_factor = guiscale
-
+
func reset_guiscale() -> void:
set_guiscale(get_current_guiscale())
diff --git a/game/src/Game/GameStart.gd b/game/src/Game/GameStart.gd
index 995541f..bfbbfb1 100644
--- a/game/src/Game/GameStart.gd
+++ b/game/src/Game/GameStart.gd
@@ -49,12 +49,3 @@ func _initialize_game() -> void:
func _on_splash_container_splash_end():
loading_screen.show()
-
-func _on_loading_screen_load_started():
- Events.Loader.startup_load_begun.emit()
-
-func _on_loading_screen_load_changed(percentage : float) -> void:
- Events.Loader.startup_load_changed.emit(percentage)
-
-func _on_loading_screen_load_ended():
- Events.Loader.startup_load_ended.emit()
diff --git a/game/src/Game/GameStart.tscn b/game/src/Game/GameStart.tscn
index f16daa3..189e72f 100644
--- a/game/src/Game/GameStart.tscn
+++ b/game/src/Game/GameStart.tscn
@@ -51,8 +51,5 @@ stream = ExtResource("5_8euyy")
autoplay = true
expand = true
-[connection signal="load_changed" from="LoadingScreen" to="." method="_on_loading_screen_load_changed"]
-[connection signal="load_ended" from="LoadingScreen" to="." method="_on_loading_screen_load_ended"]
-[connection signal="load_started" from="LoadingScreen" to="." method="_on_loading_screen_load_started"]
[connection signal="splash_end" from="SplashContainer" to="." method="_on_splash_container_splash_end"]
[connection signal="finished" from="SplashContainer/SplashVideo" to="SplashContainer" method="_on_splash_startup_finished"]
diff --git a/game/src/Game/LoadingScreen.gd b/game/src/Game/LoadingScreen.gd
index 3cbf199..d953d20 100644
--- a/game/src/Game/LoadingScreen.gd
+++ b/game/src/Game/LoadingScreen.gd
@@ -1,9 +1,5 @@
extends Control
-signal load_started()
-signal load_changed(percentage : float)
-signal load_ended()
-
@export var quote_file_path : String = "res://common/quotes.txt"
@export_subgroup("Nodes")
@@ -24,7 +20,7 @@ func start_loading_screen(thread_safe_function : Callable) -> void:
thread.wait_to_finish()
thread.start(thread_safe_function)
- load_started.emit()
+ Events.Loader.startup_load_begun.emit()
func try_update_loading_screen(percent_complete: float, quote_should_change = false):
# forces the function to behave as if deferred
@@ -34,9 +30,9 @@ func try_update_loading_screen(percent_complete: float, quote_should_change = fa
quote_label.text = quotes[randi() % quotes.size()]
if is_equal_approx(percent_complete, 100):
thread.wait_to_finish()
- load_ended.emit()
+ Events.Loader.startup_load_ended.emit()
else:
- load_changed.emit(percent_complete)
+ Events.Loader.startup_load_changed.emit(percent_complete)
func _ready():
if Engine.is_editor_hint(): return
diff --git a/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd b/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd
index 4dd86e1..42be5e0 100644
--- a/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd
+++ b/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd
@@ -32,7 +32,7 @@ func _sync_guiscales(to_select : float = GuiScale.get_current_guiscale()) -> voi
if selected == -1:
selected = default_selected
-
+
func _setup_button():
if default_value <= 0:
default_value = ProjectSettings.get_setting("display/window/stretch/scale")
diff --git a/game/src/Game/Theme/PieChart/PieChart.gd b/game/src/Game/Theme/PieChart/PieChart.gd
index b06dacf..94366c7 100644
--- a/game/src/Game/Theme/PieChart/PieChart.gd
+++ b/game/src/Game/Theme/PieChart/PieChart.gd
@@ -111,8 +111,8 @@ func sort_slices() -> void:
func _ready():
if not Engine.is_editor_hint():
- const size : int = 256
- _pie_chart_image = Image.create(size, size, false, Image.FORMAT_RGBA8)
+ const image_size : int = 256
+ _pie_chart_image = Image.create(image_size, image_size, false, Image.FORMAT_RGBA8)
texture = ImageTexture.create_from_image(_pie_chart_image)
_recalculate()
@@ -160,11 +160,11 @@ func _on_mouse_exited():
# is hovered over. Returns a boolean on whether the tooltip was handled.
func _handle_tooltip(pos : Vector2) -> bool:
# Is it within the circle?
- var radius := size.x / 2.0
- var center := Vector2(radius, radius)
+ var real_radius := size.x / 2.0
+ var center := Vector2(real_radius, real_radius)
var distance := center.distance_to(pos)
- var real_donut_inner_radius : float = radius * donut_inner_radius
- if distance <= radius and (not donut or distance >= real_donut_inner_radius):
+ var real_donut_inner_radius : float = real_radius * donut_inner_radius
+ if distance <= real_radius and (not donut or distance >= real_donut_inner_radius):
if _slice_order.is_empty():
_rich_tooltip.text = "PIECHART_TOOLTIP_NO_DATA"
else:
@@ -189,7 +189,7 @@ func _handle_tooltip(pos : Vector2) -> bool:
# Create a list of all the values and percentages
# with the hovered one highlighted
func _create_tooltip(labelHovered : String) -> String:
- var slice_tooltips : PackedStringArray
+ var slice_tooltips : PackedStringArray = []
for label in _slice_order:
var slice : SliceData = _slices.get(label)
var percent := _format_percent(slice.percentage)