Files
glitch-in-the-system/scripts/v2/loading/progress_step_tracker.gd

59 lines
1.2 KiB
GDScript

class_name ProgressStepTracker
extends Object
var _step_name: String = ""
var _message: String = ""
var _subset_index: int = 0
var _subset_count: int = 0
var _tracker: ProgressTracker = null
func _init(tracker: ProgressTracker, step_name: String):
self._tracker = tracker
self._step_name = step_name
## Sets the number of substeps for this step
func set_substeps(substeps: int):
self._subset_count = substeps
## Progresses to the next substep
func substep(message: String = ""):
self._subset_index += 1
self._message = message
self._tracker.progress_update.emit()
## Completes this step
func complete():
self._tracker.step_complete.emit()
## Returns the name of this step
func get_step_name() -> String:
return self._step_name
## Returns the message for this step
func get_message() -> String:
return self._message
## Returns the index of the current substep
func get_substep_index() -> int:
return self._subset_index
## Returns the number of substeps for this step
func get_substep_count() -> int:
return self._subset_count
## Returns the progress of this step
func get_progress() -> float:
if self._subset_count == 0:
return 0.0
return float(self._subset_index) / float(self._subset_count)