Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#4027 closed enhancement (fixed)

Make mod installer

Reported by: sanderd17 Owned by: Itms
Priority: Must Have Milestone: Alpha 23
Component: Core engine Keywords:
Cc: Patch: Phab:D1142

Description (last modified by leper)

It should be possible to install mods by opening a mod file with 0ad:

  • The modder makes a file available for download, named something like modName.pyromod (which is just the zip generated by the archivebuilder, which includes the mod.json file)
  • The player downloads the file to his downloads
  • Then the player is able to open the file with 0ad/pyrogenesis
  • The game places the mod zip in a new (TODO maybe allow overwriting the same mod if it is a newer version) mod folder.

Note that during the last step we can add a platform specific workaround for mods on Windows, as once a mod is mounted reading the mod.json from the zip is not possible.

Attachments (2)

4027_proposed.patch (6.2 KB ) - added by Vladislav Belov 6 years ago.
How a mod installation could work
4027_mod_installation.patch (7.1 KB ) - added by Vladislav Belov 6 years ago.
Added the basic checks, windows mod.json, additional directory

Download all attachments as: .zip

Change History (22)

comment:1 by sanderd17, 7 years ago

Description: modified (diff)

comment:2 by leper, 6 years ago

Component: UI & SimulationCore engine
Description: modified (diff)

comment:3 by Vladislav Belov, 6 years ago

So algorithm is that:

  1. Create a name.0admod/name.pyromod file (zipped archive f.e.).
  2. Assign .0admod/.pyromod extensions to the our program (so it could be pyrogenesis or not)
  3. An executing of this files should add mods to the game or open pyrogenesis with installed mods. (In the first case we don't even need the full pyrogenesis program, just a tool, in the second case, we shouldn't open new window, only update the currently opened).

in reply to:  3 ; comment:4 by leper, 6 years ago

Replying to vladislavbelov:

  1. Create a name.0admod/name.pyromod file (zipped archive f.e.).

.pyromod as this is a feature of the engine, and not of a mod. The creation is just renaming the archive generated by the archivebuilder to end with .pyromod, so it is just a valid .zip file the game can read.

  1. An executing of this files should add mods to the game or open pyrogenesis with installed mods. (In the first case we don't even need the full pyrogenesis program, just a tool, in the second case, we shouldn't open new window, only update the currently opened).

Add only. Starting it with the mods should be done via the mod selector. True, this could likely be done by a simple script, but keeping the functionality in the main game removes the need to duplicate locations for paths and similar. Installing is just moving the .pyromod file to a new folder in the user-writeable mod folder (not the user mod), and renaming it to .zip. Optionally (to work around that one Windows bug) it should also extract the mod.json file included in the .zip next to it.

in reply to:  4 comment:5 by Vladislav Belov, 6 years ago

Replying to leper:

Add only. Starting it with the mods should be done via the mod selector. True, this could likely be done by a simple script, but keeping the functionality in the main game removes the need to duplicate locations for paths and similar. Installing is just moving the .pyromod file to a new folder in the user-writeable mod folder (not the user mod), and renaming it to .zip. Optionally (to work around that one Windows bug) it should also extract the mod.json file included in the .zip next to it.

So adds only, not turn on? Then we need to add some cmdline arguments (i.e. --addmod path), use function like for autostart and close the game.

comment:6 by Vladislav Belov, 6 years ago

Description: modified (diff)

There is an easy way to associate the pyrogenesis with *.pyromod with NSIS: http://nsis.sourceforge.net/File_Association, but I'm not sure that easy too for all FM of WMs of *nix (usually a file manager uses the MIME type in /usr/share/applications or ~/.local/share/applications).

Last edited 6 years ago by Vladislav Belov (previous) (diff)

comment:7 by Vladislav Belov, 6 years ago

Also what we should do with the selected file: move or copy? In case when we copy, should we notice user that it was copied, and he could remove it?

comment:8 by leper, 6 years ago

There is https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/ which is supported by most DEs that a user that wants it to work without setting it up themselves. Not exactly sure about OS X.

Moving would be the preferred method, given that we shouldn't delete user files without them explicitly asking us to do so. Not sure if we should notify them.

comment:9 by Vladislav Belov, 6 years ago

About mod structure: there are at least two types: 1.

mod-name\
    -[art]
    -...
    -mod.json

2.

mod-name\
    -mod-name.zip
    -mod.json

Which one we should support, both or only one (is compress option needed)? I prefer the second one, just extract mod.json for Windows (because compressing).

Last edited 6 years ago by Vladislav Belov (previous) (diff)

comment:10 by leper, 6 years ago

Both are supported, but this is only about installing packaged (as in .zip, which we'll rename .pyromod to make handling easier) mods.

So

mod-name
+mod-name.zip

only. Where mod-name could be something unique, in case we care about people installing multiple versions of mods. (This is slightly complicated as it could be a valid use-case to have one mod in 2 versions that are both compatible, but I think we can just install them all in the same place, replacing previous versions (deleting, custom modifications shouldn't be in there (objections?)) by the new one.)

For the extension (which is working around a Windows issue that is most likely caused by something opening the zip file with the wrong flags thus preventing further opening, leading to the mod.json not being found due, causing the mod to be missing in the lists) we can then extract the mod.json file next to the .zip. But this is just working around a bug I can't debug and for which my few guesses were either incorrect or incomplete. The extension format would then be

mod-name
+mod-name.zip
+mod.json

Non-bundled (non-archived, non-packed, whatever you want to call it) mods are not part of this ticket, those are something only modders should need (or users who want to change something small, but that should be in the user mod).

in reply to:  10 comment:11 by Vladislav Belov, 6 years ago

Replying to leper:

For the extension (which is working around a Windows issue that is most likely caused by something opening the zip file with the wrong flags thus preventing further opening, leading to the mod.json not being found due, causing the mod to be missing in the lists) we can then extract the mod.json file next to the .zip. But this is just working around a bug I can't debug and for which my few guesses were either incorrect or incomplete.

So for Windows: if sometimes we couldn't find the mod.json in the archive, then to be completely sure we need to extract the all mod and copy mod.json to the mod path.

comment:12 by leper, 6 years ago

No, we only need the mod.json. We can't open the archive twice as it is already loaded, starting the mods unmounts all mods first, so we can then open it again. The mod selector only needs the mod.json files and doesn't care about anything else.

Also this is a workaround that shouldn't be part of this ticket, but I mentioned it since it might be useful to some and I don't see anyone trying to pinpoint the actual bug.

in reply to:  12 comment:13 by Vladislav Belov, 6 years ago

Replying to leper:

No, we only need the mod.json. We can't open the archive twice as it is already loaded.

Yes, in case that we already loaded mods, no needs to do that. Though I need to figure out what really happens with the mod.json.

in reply to:  12 comment:14 by Vladislav Belov, 6 years ago

Replying to leper:

No, we only need the mod.json. We can't open the archive twice as it is already loaded, starting the mods unmounts all mods first, so we can then open it again. The mod selector only needs the mod.json files and doesn't care about anything else.

I meant when pyrogenesis installs the mod, we don't need to load other mods for this.

Last edited 6 years ago by Vladislav Belov (previous) (diff)

by Vladislav Belov, 6 years ago

Attachment: 4027_proposed.patch added

How a mod installation could work

comment:15 by Vladislav Belov, 6 years ago

Keywords: patch added

by Vladislav Belov, 6 years ago

Attachment: 4027_mod_installation.patch added

Added the basic checks, windows mod.json, additional directory

comment:16 by leper, 5 years ago

Description: modified (diff)

Care to get this on Phabricator some day?

I'm not sure why you have an include for Xeromyces in there, that does not seem to be used. The Windows workaround should not be part of the same diff (an incremental one is fine) as that should have a detailed explanation of why it is needed.

We shouldn't need a special command line parameter, and I guess only supporting a single mod file is fine. There should most likely be some registration of pyrogenesis as the default handler for .pyromod files (I guess the Windows installer does that, and probably some mime type association by placing the right file in the right folder on *nix (some tests should be done for that, then packagers should be notified)).

Why isn't m_VFS done in the initializer list?

comment:17 by elexis, 5 years ago

Milestone: BacklogWork In Progress

comment:18 by elexis, 5 years ago

Patch: Phab:D1142

comment:19 by Itms, 5 years ago

Owner: set to Itms
Resolution: fixed
Status: newclosed

In 21726:

Add a mod installer, fixes #4027.

pyrogenesis can now take a zip file (rename it to .pyromod for direct file association following r21723) and install it. It then starts the mod selector.

Patch by vladislavbelov, with contributions from Imarok, elexis and myself.
Differential Revision: https://code.wildfiregames.com/D1142

comment:20 by Itms, 5 years ago

Keywords: patch removed
Milestone: Work In ProgressAlpha 23
Note: See TracTickets for help on using tickets.