Update loader & misc
- [src/misc.gd] Add get_sign() function - [src/misc.gd] Add get_sign_float() function - [src/loader.gd] Change variable order (that makes a bit more sense) - [src/loader.gd] Fix path resolution - [src/loader.gd] Prefix all logger.error() calls in initialize() with "await" to prevent Godot debugger errors
This commit is contained in:
parent
73d6e889c5
commit
751adc312e
2 changed files with 18 additions and 6 deletions
|
@ -24,11 +24,11 @@
|
|||
extends Control
|
||||
|
||||
# Loader configuration
|
||||
## Skip malicious scripts warning if running as debug build
|
||||
var config_skipwarning: bool = true
|
||||
## Window size support
|
||||
### This is/was used for configuring scaling
|
||||
var config_window_size_support: bool = false
|
||||
## Skip malicious scripts warning if running as debug build
|
||||
var config_skipwarning: bool = true
|
||||
## Slow init
|
||||
### I don't know why I put this here lol
|
||||
var config_slow_init: bool = false
|
||||
|
@ -131,7 +131,7 @@ ONLY VIEW PRESENCODE PRESENTATIONS IF YOU TRUST THE
|
|||
# Open presentation archive/directory
|
||||
var path: String = " ".join(OS.get_cmdline_user_args())
|
||||
if OS.get_cmdline_user_args().size() == 0:
|
||||
logger.error("No presentation was passed to Presencode")
|
||||
await logger.error("No presentation was passed to Presencode")
|
||||
if FileAccess.file_exists(path) and path.ends_with(".zip") or path.ends_with(".pcpa"): # .pcpa = presencode presentation archive
|
||||
logger.info("Opening presentation archive")
|
||||
preader.open_presentation(path, true)
|
||||
|
@ -139,7 +139,7 @@ ONLY VIEW PRESENCODE PRESENTATIONS IF YOU TRUST THE
|
|||
logger.info("Opening presentation directory")
|
||||
preader.open_presentation(path, false)
|
||||
else:
|
||||
logger.error("Presentation file/directory \"" + path + "\" not found")
|
||||
await logger.error("Presentation file/directory \"" + path + "\" not found")
|
||||
if config_slow_init: await get_tree().create_timer(randf_range(0.6, 1)).timeout
|
||||
# Read manifest & entrypoint files
|
||||
preader.read_manifest()
|
||||
|
|
14
src/misc.gd
14
src/misc.gd
|
@ -81,7 +81,7 @@ func shutdown(exitcode: int = 0) -> void:
|
|||
await get_tree().create_timer(0.25, true).timeout
|
||||
print("Exiting!")
|
||||
get_tree().quit(exitcode)
|
||||
# Insanely long timer as Godot executes code further even while it's exiting
|
||||
# Insanely long timer to prevent Godot from executing code during exit
|
||||
await get_tree().create_timer(999, true).timeout
|
||||
|
||||
# Calculate the center of a child inside its parent (Vector2i)
|
||||
|
@ -93,6 +93,18 @@ func get_center(parent_size: Vector2i, child_size: Vector2i) -> Vector2i:
|
|||
func get_center_float(parent_size: Vector2, child_size: Vector2) -> Vector2:
|
||||
return Vector2(parent_size.x/2-child_size.x/2, parent_size.y/2-child_size.y/2)
|
||||
|
||||
# Returns the sign (-1, +1, 0) of an int
|
||||
func get_sign(number: int) -> int:
|
||||
if number > 0: return +1
|
||||
elif number < 0: return -1
|
||||
else: return 0
|
||||
|
||||
# Returns the sign (-1, +1, 0) of a float
|
||||
func get_sign_float(number: float) -> float:
|
||||
if number > 0: return +1
|
||||
elif number < 0: return -1
|
||||
else: return 0
|
||||
|
||||
# Return path to temporary directory
|
||||
## This function tries to utilize the operating system's temporary directory.
|
||||
## If all of them can't be used, it falls back to "user://temp" instead.
|
||||
|
|
Loading…
Reference in a new issue