-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[WIP] User-installable mods, gfx, & sounds #15836
Conversation
This is similar to #14418 if you wanna check. |
66065ef
to
9565e8f
Compare
@@ -349,6 +349,22 @@ int main(int argc, char *argv[]) | |||
FILENAMES["user_dir"].c_str()); | |||
exit(1); | |||
} | |||
if (!assure_dir_exist(FILENAMES["user_datadir"].c_str())) { |
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.
assure_dir_exist
accepts a std::string
, there is no need to call .c_str()
here.
Edit: why do those folder need to exists at all?
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.
It makes it easier for the end user to find where to install mods (rather than the extra step of the end user creating the directories himself).
I'll change that to pass a std::string.
68d719f
to
6078cb4
Compare
821d76e
to
265ba3f
Compare
265ba3f
to
6a2076a
Compare
This patch adds additional directories inside the user's directory from which to load gfx, sounds, and mods. The use case is that the user wants to install additional gfx packs, sound packs, and/or mods to the game installed on the system where the user cannot (or doesn't want to) modify system files e.g. /usr/share/cataclysm-dda/mods. With this patch, the user can install sound packs, etc to $XDG_DATA_HOME/cataclysm-dda/data/sound/, etc. Data from the application's data dir are loaded first and thus take precendence over user data with duplicate names. The use case is for end users who want to install additional mods, rather than moders who may have a use case to override pre-installed data packs and mods.
6a2076a
to
8060501
Compare
@@ -158,6 +158,12 @@ void PATH_INFO::set_standard_filenames(void) | |||
update_pathname("obsolete-mods", FILENAMES["moddir"] + "obsolete-mods.json"); | |||
update_pathname("defaultsounddir", FILENAMES["datadir"] + "sound"); | |||
|
|||
// User's data directories | |||
update_pathname("user_datadir", FILENAMES["user_dir"] + "data/"); | |||
update_pathname("user_gfxdir", FILENAMES["user_datadir"] + "gfx/"); |
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.
The default gfx dir lives under <user_dir>/gfx, not <user_datadir>/gfx, see line 122 in this method. This will break your check in build_tilesets_list() and also cause the creation of a phantom directory in the default install.
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.
The default gfx dir lives under /gfx, not /gfx, see line 122 in this method.
Don't understand this feedback. They are separate directories, and the location of the gfxdir depends on DATA_DIR_PREFIX. 122 puts gfxdir under base_path. 118 puts gfxdir under datadir. This line puts user_gfxdir under user_datadir, mirroring the behavior at 118, except in a user modifiedable directory instead of a system dir.
This will break your check in build_tilesets_list()
Which check?
also cause the creation of a phantom directory in the default install.
That's the idea. It creates a directory that the user can easily locate to install mods. See BevapDin's comment.
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.
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.
Ah, I see. For the case you describe, you have to define neither USE_HOME_DIR nor USE_XDG_DIR.
gfx is the only one that works properly actually, because the paths are different. sound and user_sound (and mod) paths are equivalent; however the strings are different (e.g. "./data/sound" and "data/sound"), causing the string comparison to pass when it shouldn't. I knew those naive string comparisons would fail for path comparisons. :)
I'll see if I can figure out a solution to compare filesystem paths w/o bringing in os-specific code.
Just curious, why even have the option to use the current directory for user_dir? The gentoo ebuild actually had a bug where it could fail to define one of those, causing save games, etc to spill out into current directory (leycec/raiagent#44). Is it just to keep dev save games separate?
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.
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.
all you need to do is define that path as FILENAMES ["user_dir"] + "gfx".
I see what you're saying. What's irking me is that the standard gfx, sound, and mods are in the same dir when a package manager would create a package for this (i.e. by setting PREFIX at compile time). I suppose I could mirror that by conditionally compiling based on DATA_DIR_PREFIX here, as done on line 118.
That's a hilarious question. That is the default, and the dominant way the game is packaged and distributed.
Hmm.. interesting that most people install it that way. I wonder how much that'd change if users had a way to install it via their os's package manager, like in gentoo.
Going to mark as WIP until I get around to fixing this for the "run from current directory" mode. |
Closed as appears stalled, can reopen if work resumes |
This patch adds additional directories inside the user's directory from which
to load gfx, sounds, and mods. The use case is that the user wants to install
additional gfx packs, sound packs, and/or mods to the game installed on the
system where the user cannot (or doesn't want to) modify system files e.g.
/usr/share/cataclysm-dda/mods. With this patch, the user can install sound
packs, etc to $XDG_DATA_HOME/cataclysm-dda/data/sound/, etc.
Data from the application's data dir are loaded first and thus take
precendence over user data with duplicate names. The use case is for end users
who want to install additional mods, rather than moders who may have a use
case to override pre-installed data packs and mods to make modifications.
Fixes #16023