mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
make the default library group location be based on the executable location (#164)
closes #163 Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/164 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
parent
f720efcc72
commit
ac6ede2b41
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -6,3 +6,6 @@ dist/*/
|
|||
|
||||
# vscode folder
|
||||
.vscode/
|
||||
|
||||
# lib groups folder
|
||||
library_groups/
|
||||
|
|
|
@ -95,7 +95,7 @@ static func create_lib_descriptors(path: String) -> void:
|
|||
current_file = dir.get_next()
|
||||
continue
|
||||
if libraries.has(type):
|
||||
DeckHolder.logger.toast_error("Library group '%s' collides with a library group with the same type." % type)
|
||||
DeckHolder.logger.toast_error("Library group '%s' is already added by a different library." % type)
|
||||
current_file = dir.get_next()
|
||||
continue
|
||||
var lib = deck.deck.library
|
||||
|
@ -121,7 +121,7 @@ static func create_lib_descriptors(path: String) -> void:
|
|||
static func reload_libraries() -> void:
|
||||
libraries.clear()
|
||||
for path in StreamGraphConfig.get_library_search_paths():
|
||||
create_lib_descriptors(path)
|
||||
create_lib_descriptors(Util.globalize_path(path))
|
||||
|
||||
|
||||
## Instantiates a [DeckNode] from a given [param node_type]. See [member DeckNode.node_type].
|
||||
|
|
|
@ -5,9 +5,7 @@ class_name StreamGraphConfig
|
|||
|
||||
|
||||
static var config := {
|
||||
&"library_search_paths": [
|
||||
ProjectSettings.globalize_path("user://library_groups"),
|
||||
],
|
||||
&"library_search_paths": [],
|
||||
}
|
||||
|
||||
const SAVE_PATH := "user://config.json"
|
||||
|
@ -53,7 +51,7 @@ static func add_library_search_path(path: String) -> void:
|
|||
|
||||
static func remove_library_search_path(path: String) -> void:
|
||||
var arr: Array = config[&"library_search_paths"]
|
||||
if arr.find(path) < 1:
|
||||
if arr.find(path) < 0:
|
||||
return
|
||||
arr.erase(path)
|
||||
NodeDB.reload_libraries()
|
||||
|
@ -63,7 +61,7 @@ static func remove_library_search_path(path: String) -> void:
|
|||
static func rename_library_search_path(old_path: String, new_path: String) -> void:
|
||||
var arr: Array = config[&"library_search_paths"]
|
||||
var idx := arr.find(old_path)
|
||||
if idx < 1:
|
||||
if idx < 0:
|
||||
return
|
||||
|
||||
arr[idx] = new_path
|
||||
|
@ -74,7 +72,7 @@ static func rename_library_search_path(old_path: String, new_path: String) -> vo
|
|||
static func move_library_path_up(path: String) -> void:
|
||||
var arr: Array = config[&"library_search_paths"]
|
||||
var idx := arr.find(path)
|
||||
if idx < 1:
|
||||
if idx < 0:
|
||||
return
|
||||
|
||||
var old_path = arr[idx]
|
||||
|
@ -87,7 +85,7 @@ static func move_library_path_up(path: String) -> void:
|
|||
static func move_library_path_down(path: String) -> void:
|
||||
var arr: Array = config[&"library_search_paths"]
|
||||
var idx := arr.find(path)
|
||||
if idx < 1 or idx == arr.size() - 1:
|
||||
if idx < 0 or idx == arr.size() - 1:
|
||||
return
|
||||
|
||||
var old_path = arr[idx]
|
||||
|
@ -98,7 +96,9 @@ static func move_library_path_down(path: String) -> void:
|
|||
|
||||
|
||||
static func get_library_search_paths() -> Array:
|
||||
return config[&"library_search_paths"]
|
||||
var res := ["{$PWD}/library_groups"]
|
||||
res.append_array(config[&"library_search_paths"])
|
||||
return res
|
||||
|
||||
|
||||
static func save() -> void:
|
||||
|
|
|
@ -39,6 +39,13 @@ static func pop_batch(key: StringName) -> void:
|
|||
_batches.erase(key)
|
||||
|
||||
|
||||
## Customized version of [method ProjectSettings.globalize_path] that handles
|
||||
## a [code]$PWD[/code] template which points to the current working folder.
|
||||
static func globalize_path(path: String) -> String:
|
||||
var pwd: String = ProjectSettings.globalize_path("res://").trim_suffix("/") if OS.has_feature("editor") else OS.get_executable_path().get_base_dir()
|
||||
return path.format({"$PWD": pwd})
|
||||
|
||||
|
||||
## An object representing multiple connections.
|
||||
##
|
||||
## Useful when there's a need to connect multiple signals in one operation, to be disconnected later.
|
||||
|
|
|
@ -94,7 +94,7 @@ class FolderView extends HBoxContainer:
|
|||
is_default = p_default
|
||||
|
||||
label = Label.new()
|
||||
label.text = path
|
||||
label.text = path.replace("$PWD", "app directory")
|
||||
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
label.clip_text = true
|
||||
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||
|
|
Loading…
Reference in a new issue