Compare commits
2 commits
4914567fce
...
75575991fa
Author | SHA1 | Date | |
---|---|---|---|
75575991fa | |||
450bac51c4 |
6 changed files with 67 additions and 1 deletions
38
assetloader/assetloader.gd
Normal file
38
assetloader/assetloader.gd
Normal file
|
@ -0,0 +1,38 @@
|
|||
extends Object
|
||||
class_name AssetLoader
|
||||
|
||||
const DEFAULT_ASSETS_PATH = "res://mods"
|
||||
|
||||
## Path to the mods folder : [param res://mods] by default
|
||||
## [br]
|
||||
## (is not a const but should be treated as such, so the uppercase)
|
||||
var ASSETS_PATH
|
||||
|
||||
var critical_error := false
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
ASSETS_PATH = ProjectSettings.get_setting("game/mods/mod_path", DEFAULT_ASSETS_PATH)
|
||||
var dir := DirAccess.open(ASSETS_PATH)
|
||||
if not dir:
|
||||
push_error("AssetLoader: Mods folder not found at '%s'" % ASSETS_PATH)
|
||||
_show_error_popup("Mods folder not found at '%s'" % ASSETS_PATH)
|
||||
critical_error = true
|
||||
return
|
||||
var mod_folders := dir.get_directories()
|
||||
|
||||
if mod_folders.is_empty():
|
||||
push_error("AssetLoader: Mods folder '%s' is empty — no mods to load." % ASSETS_PATH)
|
||||
_show_error_popup("Mods folder '%s' is empty — no mods to load." % ASSETS_PATH)
|
||||
critical_error = true
|
||||
return
|
||||
|
||||
|
||||
## This will show a native MessageBox on Windows,
|
||||
## a native dialog on macOS, and GTK/QT dialog on Linux.
|
||||
func _show_error_popup(message: String) -> void:
|
||||
OS.alert("AssetLoader:"+message, "AssetLoader:Error")
|
||||
|
||||
|
||||
func load_all():
|
||||
pass
|
1
assetloader/assetloader.gd.uid
Normal file
1
assetloader/assetloader.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://qkh5uvr4st7i
|
25
autoloads/bootstrap.gd
Normal file
25
autoloads/bootstrap.gd
Normal file
|
@ -0,0 +1,25 @@
|
|||
extends Node
|
||||
## Should always be at the top of autoloads
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var loader := AssetLoader.new()
|
||||
# If there was a critical error, quit immediately
|
||||
if loader.critical_error:
|
||||
Engine.get_main_loop().quit(1)
|
||||
return
|
||||
loader.load_all() # TODO: Making it async
|
||||
|
||||
# Otherwise, continue startup
|
||||
_start_game()
|
||||
|
||||
|
||||
## This will show a native MessageBox on Windows,
|
||||
## a native dialog on macOS, and GTK/QT dialog on Linux.
|
||||
func _show_error_popup(context:String, message: String) -> void:
|
||||
OS.alert(context+":"+message, context+":Error")
|
||||
|
||||
|
||||
func _start_game() -> void:
|
||||
print("Game starting...")
|
||||
#TODO: Load main menu or world scene
|
1
autoloads/bootstrap.gd.uid
Normal file
1
autoloads/bootstrap.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://bbmtxflx0ivgp
|
File diff suppressed because one or more lines are too long
|
@ -21,6 +21,7 @@ config/windows_native_icon="res://4589AD_icon.ico"
|
|||
|
||||
[autoload]
|
||||
|
||||
Bootstrap="*res://autoloads/bootstrap.gd"
|
||||
DebugTools="*res://dev/debug_tools.tscn"
|
||||
|
||||
[debug]
|
||||
|
|
Loading…
Reference in a new issue