ScriptManager changes

updated PaginatedScript to include functions for getting page length
added setget funcs
added ScriptManager into Autoloads
master
Zac 4 years ago
parent e45fd91e72
commit cedf812445
  1. 1
      project.godot
  2. 24
      scripts/globals/ScriptManager.gd

@ -17,6 +17,7 @@ config/icon="res://icon.png"
AudioManager="*res://scripts/globals/AudioManager.gd"
LevelManager="*res://scripts/globals/LevelManager.gd"
ScriptManager="*res://scripts/globals/ScriptManager.gd"
[display]

@ -1,12 +1,13 @@
extends Node
var _current_script
var _current_script setget set_script, get_script
# custom class to paginate the loaded script
class PaginatedScript:
const _CharsPerPage = 120
var _pages = PoolStringArray()
var _cur_page = 0
var _cur_page = 0 setget , get_page_number
func _init(file):
var txt
@ -41,7 +42,7 @@ class PaginatedScript:
_pages.append(l.strip_edges())
func next_page():
_cur_page = min(_cur_page + 1, len(_pages) - 1)
_cur_page = min(_cur_page + 1, _pages.size() - 1)
return _pages[_cur_page]
@ -49,4 +50,21 @@ class PaginatedScript:
_cur_page = max(_cur_page - 1, 0)
return _pages[_cur_page]
func current_page():
return _pages[_cur_page]
func get_page_number():
return _cur_page
func total_pages():
return _pages.size()
func set_script(script):
_current_script = PaginatedScript.new(script)
func get_script():
return _current_script
func get_max_pages():
return _current_script.total_pages() - 1
Loading…
Cancel
Save