-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate data from executable #90
Open
teackot
wants to merge
13
commits into
qrrk:master
Choose a base branch
from
teackot:separate-data
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eb0f6b9
Settings and game installations can now be stored separately from the…
teackot 49aa2f9
Remove a todo
teackot e6756df
Added new translation strings (not translated)
teackot ef8282b
Changed naming
teackot c4677f1
Cleaner catapult_dir initialization
teackot 0b44e19
Implement global config
teackot 01d7e2d
Added installation directory input field in settings
teackot 0736cca
Implemented installation_dir setting
teackot e484a6d
Use XDG config directory if possible
teackot 6df9644
Fix installation_dir not using env variables
teackot 6a9f711
Revert last fix with only replacing '~'
teackot d16fc59
Check if dir creation was successful
teackot ba74a8b
Merge branch 'master' into separate-data
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,11 @@ extends Node | |
|
||
signal status_message | ||
|
||
var own_dir: String setget , _get_own_dir | ||
var catapult_dir: String setget _set_catapult_dir , _get_catapult_dir | ||
var settings_dir: String setget _set_settings_dir , _get_settings_dir | ||
var installs_summary: Dictionary setget , _get_installs_summary | ||
var game_dir: String setget , _get_game_dir | ||
var next_install_dir: String setget , _get_next_install_dir | ||
var next_data_dir: String setget , _get_next_data_dir | ||
var userdata: String setget , _get_userdata_dir | ||
var config: String setget , _get_config_dir | ||
var savegames: String setget , _get_savegame_dir | ||
|
@@ -30,19 +31,101 @@ var _last_active_install_name := "" | |
var _last_active_install_dir := "" | ||
|
||
|
||
func _get_own_dir() -> String: | ||
func _init() -> void: | ||
|
||
catapult_dir = _determine_catapult_dir() | ||
settings_dir = _determine_settings_dir() | ||
|
||
Settings.load_settings(settings_dir) | ||
var inst_dir_setting = Settings.read("installation_dir") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There needs to be a hard-coded default value for |
||
inst_dir_setting = inst_dir_setting.replace("~", OS.get_environment("HOME")) | ||
|
||
if inst_dir_setting != null: | ||
var d = Directory.new() | ||
|
||
var error = 0 | ||
if not d.dir_exists(inst_dir_setting): | ||
error = d.make_dir_recursive(inst_dir_setting) | ||
|
||
if not error: | ||
catapult_dir = inst_dir_setting | ||
|
||
|
||
func _determine_catapult_dir() -> String: | ||
|
||
for arg in OS.get_cmdline_args(): | ||
if arg.find("=") > -1: # if arg is a key-value pair | ||
var arg_pair = arg.split("=") | ||
if arg_pair[0] == "--catapult_dir_abs": | ||
var dirname = arg_pair[1] | ||
|
||
if not dirname.is_abs_path(): | ||
# relative paths are not supported, fallback to executable path | ||
Status.post(tr("msg_path_not_absolute") % dirname, Enums.MSG_ERROR) | ||
break | ||
|
||
# Ensure that catapult_dir_abs exists | ||
var d = Directory.new() | ||
if not d.dir_exists(dirname): | ||
var error = d.make_dir_recursive(dirname) | ||
if error: | ||
# something went wrong, fallback to executable path | ||
Status.post(tr("msg_cannot_create_target_dir") % [dirname, error], Enums.MSG_ERROR) | ||
break | ||
|
||
return dirname | ||
|
||
return OS.get_executable_path().get_base_dir() | ||
|
||
|
||
func _determine_settings_dir() -> String: | ||
|
||
var global_settings_dir: String | ||
|
||
match OS.get_name(): | ||
"X11": | ||
var xdg_config_home = OS.get_environment("XDG_CONFIG_HOME") | ||
var config_home = xdg_config_home if not xdg_config_home.empty() else OS.get_environment("HOME").plus_file(".config") | ||
global_settings_dir = config_home.plus_file("catapult/") | ||
"Windows": | ||
global_settings_dir = OS.get_environment("USERPROFILE").plus_file("AppData/Local/Catapult/") | ||
_: | ||
return catapult_dir | ||
|
||
if Settings.dir_contains_settings(global_settings_dir): | ||
return global_settings_dir | ||
else: | ||
return catapult_dir | ||
|
||
|
||
func _set_catapult_dir(path: String) -> void: | ||
|
||
catapult_dir = path | ||
|
||
|
||
func _get_catapult_dir() -> String: | ||
|
||
return catapult_dir | ||
|
||
|
||
func _set_settings_dir(path: String) -> void: | ||
|
||
settings_dir = path | ||
|
||
|
||
func _get_settings_dir() -> String: | ||
|
||
return settings_dir | ||
|
||
|
||
func _get_installs_summary() -> Dictionary: | ||
|
||
var result = {} | ||
var d = Directory.new() | ||
|
||
for game in ["dda", "bn", "eod", "tish"]: | ||
var installs = {} | ||
var base_dir = Paths.own_dir.plus_file(game) | ||
var base_dir = Paths.catapult_dir.plus_file(game) | ||
for subdir in FS.list_dir(base_dir): | ||
var info_file = base_dir.plus_file(subdir).plus_file(Helpers.INFO_FILENAME) | ||
if d.file_exists(info_file): | ||
|
@@ -66,7 +149,7 @@ func _get_game_dir() -> String: | |
var active_name = Settings.read("active_install_" + Settings.read("game")) | ||
|
||
if active_name == "": | ||
return _get_next_install_dir() | ||
return _get_next_data_dir() | ||
elif active_name == _last_active_install_name: | ||
return _last_active_install_dir | ||
else: | ||
|
@@ -76,7 +159,7 @@ func _get_game_dir() -> String: | |
func _find_active_game_dir() -> String: | ||
|
||
var d = Directory.new() | ||
var base_dir = _get_own_dir().plus_file(Settings.read("game")) | ||
var base_dir = _get_catapult_dir().plus_file(Settings.read("game")) | ||
for subdir in FS.list_dir(base_dir): | ||
var curr_dir = base_dir.plus_file(subdir) | ||
var info_file = curr_dir.plus_file("catapult_install_info.json") | ||
|
@@ -89,11 +172,11 @@ func _find_active_game_dir() -> String: | |
return "" | ||
|
||
|
||
func _get_next_install_dir() -> String: | ||
func _get_next_data_dir() -> String: | ||
# Finds a suitable directory name for a new game installation in the | ||
# multi-install system. The names follow the pattern "game0, game1, ..." | ||
|
||
var base_dir := _get_own_dir().plus_file(Settings.read("game")) | ||
var base_dir := _get_catapult_dir().plus_file(Settings.read("game")) | ||
var dir_number := 0 | ||
var d := Directory.new() | ||
while d.dir_exists(base_dir.plus_file("game" + str(dir_number))): | ||
|
@@ -103,7 +186,7 @@ func _get_next_install_dir() -> String: | |
|
||
func _get_userdata_dir() -> String: | ||
|
||
return _get_own_dir().plus_file(Settings.read("game")).plus_file("userdata") | ||
return _get_catapult_dir().plus_file(Settings.read("game")).plus_file("userdata") | ||
|
||
|
||
func _get_config_dir() -> String: | ||
|
@@ -168,19 +251,19 @@ func _get_graveyard_dir() -> String: | |
|
||
func _get_modrepo_dir() -> String: | ||
|
||
return _get_own_dir().plus_file(Settings.read("game")).plus_file("mod_repo") | ||
return _get_catapult_dir().plus_file(Settings.read("game")).plus_file("mod_repo") | ||
|
||
|
||
func _get_tmp_dir() -> String: | ||
|
||
return _get_own_dir().plus_file(Settings.read("game")).plus_file("tmp") | ||
return _get_catapult_dir().plus_file(Settings.read("game")).plus_file("tmp") | ||
|
||
|
||
func _get_utils_dir() -> String: | ||
|
||
return _get_own_dir().plus_file("utils") | ||
return _get_catapult_dir().plus_file("utils") | ||
|
||
|
||
func _get_save_backups_dir() -> String: | ||
|
||
return _get_own_dir().plus_file(Settings.read("game")).plus_file("save_backups") | ||
return _get_catapult_dir().plus_file(Settings.read("game")).plus_file("save_backups") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"keys","en" | ||
, | ||
"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[remap] | ||
|
||
importer="csv_translation" | ||
type="Translation" | ||
|
||
[deps] | ||
|
||
files=[ "res://text/cs/path_helper.en.translation" ] | ||
|
||
source_file="res://text/cs/path_helper.csv" | ||
dest_files=[ "res://text/cs/path_helper.en.translation" ] | ||
|
||
[params] | ||
|
||
compress=true | ||
delimiter=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"keys","en" | ||
, | ||
"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[remap] | ||
|
||
importer="csv_translation" | ||
type="Translation" | ||
|
||
[deps] | ||
|
||
files=[ "res://text/en/path_helper.en.translation" ] | ||
|
||
source_file="res://text/en/path_helper.csv" | ||
dest_files=[ "res://text/en/path_helper.en.translation" ] | ||
|
||
[params] | ||
|
||
compress=true | ||
delimiter=0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed, it is called automatically when
Settings.read
is called for the first time.