Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

lucianposton
Copy link
Contributor

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

@remyroy
Copy link
Contributor

remyroy commented Mar 20, 2016

This is similar to #14418 if you wanna check.

@@ -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())) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@lucianposton lucianposton force-pushed the user-data-paths branch 2 times, most recently from 68d719f to 6078cb4 Compare March 23, 2016 08:35
@lucianposton lucianposton changed the title [WIP][CR] Load additional gfx, sounds, & mods from user directory Load additional gfx, sounds, & mods from user directory Mar 24, 2016
@lucianposton lucianposton force-pushed the user-data-paths branch 3 times, most recently from 821d76e to 265ba3f Compare March 30, 2016 06:27
@lucianposton lucianposton changed the title Load additional gfx, sounds, & mods from user directory User-installed mods, gfx, & sounds Apr 13, 2016
@lucianposton lucianposton changed the title User-installed mods, gfx, & sounds User-installable mods, gfx, & sounds Apr 14, 2016
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.
@lucianposton lucianposton changed the title User-installable mods, gfx, & sounds [Ready] User-installable mods, gfx, & sounds Apr 20, 2016
@@ -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/");
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@lucianposton lucianposton May 5, 2016

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

@lucianposton
Copy link
Contributor Author

Going to mark as WIP until I get around to fixing this for the "run from current directory" mode.

@lucianposton lucianposton changed the title [Ready] User-installable mods, gfx, & sounds [WIP] User-installable mods, gfx, & sounds May 5, 2016
@mugling
Copy link
Contributor

mugling commented Jun 24, 2016

Closed as appears stalled, can reopen if work resumes

@mugling mugling closed this Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants