[REL] PA Alpha Client Mod Manager

Discussion in 'Mod Discussions' started by jacoby6000, July 11, 2013.

  1. jacoby6000

    jacoby6000 Member

    Messages:
    105
    Likes Received:
    8
    So, I was bored in my downtime at work today and I noticed there's quite a few PA mods out there. Rather than be totally unproductive, I decided to develop this.

    This is written in C# on .NET 4.5. If you do not have .NET 4.5 installed you need to get that.

    I've only tested on Non-Steam Windows. Other platforms that have Mono installed may be able to run it (not sure how all that works), but it should work fine with the steam version on windows, as well.

    The mod manager works for managing any files within PA/media

    If anybody would like to contribute, or just look at the code out of curiosity, the source is located here: https://github.com/Jacoby6000/PA-Alpha-Mod-Manager

    [​IMG]
    Please excuse my cropping.

    For Users:


    MAKE SURE PA IS PURE VANILLA BEFORE USING

    1. Launch the Mod Manager as administrator.
    2. If your PA is NOT located in C:\Program Files (x86)\Planetary Annihilation then you will need to locate your Planetary Annhilation Folder.
    3. Locate your mod directory (can be wherever you want. I recommend Documents/PA/mods)
    4. Click Install New Mod
    5. Locate a zip file of any Mod that a developer has prepared (I'll set up a couple later, as an example. Along with a tut for developers on how to do it.)
    6. Click Open
    7. Select the mod from the list
    8. Click Launch PA!

    Something to keep in mind, is that this does not uninstall the mod after you close PA. It leaves PA with the mod you previously launched. Simply launch it as vanilla through the mod manager to go back to vanilla PA.

    When PA updates, you don't need to worry about the mods/Vanilla folder being out of date. The manager keeps track of updates, and knows when to delete old files to sustain compatibility (Atleast throughout the alpha, but maybe well beyond that).

    For Developers:

    Mod Packager
    Hashes for 50742 (SHA256)

    Wooo mod packager. It's pretty self-explanatory. Here's a picture!
    [​IMG]

    Here is the proper manual procedure to take your mod from being integrated with PA, to being a mod pack (this is what the mod packer does for you).

    Lets say you have a mod, and your mod is a modification to ui/alpha/live_game/img/icons/icons_command_attack.png, and you've also made a modification to shaders/black.fs and shaders/fog_of_war_resolve.fs

    What you will do, is retain the file structure of PA (getting rid of everything before /media/), but only zip up your changes.

    So this mod would be a zip file containing the following file structure
    Code:
    ui
     |_alpha
         |_live_game
            |_img
               |_icons
                  |_icons_command_attack.png
    
    shaders
     |_black.fs
     |_fog_of_war_resolve.fs
    
    info.txt
    
    You will then zip it up and name the zip with your mod name, exactly how you would like it displayed. eg: Jacoby6000's Awesome Mod.zip

    one last thing, is you need an info.txt at the root of your zip file.

    The first line of info.txt is the version of your mod
    The second line, is your (the author's) username
    And the third line is a short description.

    Anything after the 3rd line will be ignored.
    Currently, all fields are limited to 50 characters in length.

    How it works:

    It first extracts a mod from a .Zip into your mod directory, then whenever you select that mod, it iterates over all files in the mod directory and checks them against the mods/Vanilla folder (managed by this application. DO NOT TOUCH IT). If it finds a file in a mod that doesn't exist in mods/Vanilla, it copies the original unmodded file from PA, puts it into mods/Vanilla/<directory tree>/<file>. Then it deletes the file in PA and copies the modded file to replace it. This is why you must be logged in as an administrator.

    Whenever you load a new mod, it copies the vanilla files back in, and then repeats the process for the new mod.



    Upcoming Features:

    1. DONE Loading multiple (non-conflicting) mods at once!
    2. DONE Clean up code, make it open source via github on the apache license
    3. Support for long descriptions
    4. Merging mod files for files that edit the same file, but different parts of that file.
    4. Suggestions?


    NOTICE:
    Any errors you come across, PM to me. If I don't answer and resolve it in a day, then you can post it here. I'd like to not have stack traces cluttering up this thread. I want to keep this thread here for suggestions and discussion and not code vomit from the CLR.

    If any developers want help with anything (be it future projects or curiosity), I'm well versed in both languages that PA currently has exposed to modders (Javascript, HTML), so I can help you if you hit any road-blocks.

    It won't let me attach 1.22 as an attachment, so I'm afraid I have to externally link it
    PA Alpha Mod Manager V1.22.zip (11 kb)

    CHANGELOG:
    Code:
    V1.22
      Now the mod manager will specify which mods are incompatible, instead of just telling you it's not working.
    V1.21
      It's now really hard to pick the wrong PA directory!
    V1.2
      Everything is now Object Oriented!
      Mods can now add files without it breaking anything!
      The Git repository can be found [url=https://github.com/Jacoby6000/PA-Alpha-Mod-Manager]here[/url].
    V1.1
      Added multiple mod loading into the mix
      Some under the hood stuff
        *File paths are now properly combined, rather than through string concatenation
        *A few of the lists I had before were indexed with a hardcoded zero, it works much more dynmamically now
        *Started working on making the code cleaner. Beginning to resemble something that's actually Object Oriented
    
    Here's a list of mods that I KNOW are already compatible with the Mod Manager*:

    *this list will be updated as mods are created

    Old files:
    PA Alpha Mod Manager V1.21.zip (10kb)
    PA Alpha Mod Manager V1.2.zip (10 kb)
    PA Alpha Mod Manager V1.1.zip (9 KB)
    Last edited: July 16, 2013
  2. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
  3. jacoby6000

    jacoby6000 Member

    Messages:
    105
    Likes Received:
    8
    Thanks! that means a lot!

    I updated the OP with information for mod developers to help them figure out how to work this. I'm going to work on loading multiple mods at once right now. It shouldn't take longer than half an hour.
  4. infuscoletum

    infuscoletum Active Member

    Messages:
    606
    Likes Received:
    37
    What about mods that overwrite the same files? Could you compare each mod's file to vanilla's and only overwrite whats changed?

    This is pretty cool btw :ugeek: :mrgreen:
  5. zaphodx

    zaphodx Post Master General

    Messages:
    2,350
    Likes Received:
    2,409
  6. YourLocalMadSci

    YourLocalMadSci Well-Known Member

    Messages:
    766
    Likes Received:
    762
    Good Work.

    Feel free to use my files as an example. I will include a packaged version of my mod with the next release.
  7. jacoby6000

    jacoby6000 Member

    Messages:
    105
    Likes Received:
    8
    I have this planned I just haven't gotten it in the OP. I can probably get the confliction resolving down to the function level, but beyond that it won't be worth it, because that's when scopes start messing stuff up.

    What i mean is, if two mods modify the same file, but one mod midifies foo() and the other modifies bar() then they should be considered compatible. This won't work 100% if foo() calls bar() and the functionality of bar is different than it was before (though, that would just be bad programming).


    Alright, will do!

    If I work fast enough, I'll have the mod packager up by 3:00 (-6 US Central time). If I miss that deadline, you're going to have to wait til Monday evening, because this weekend I'm going to the beach with my parents.


    Side note: I ran into some difficulties working on getting mods to properly side-load last night, which is why that's not up yet. I'm adding that functionality before I start the mod packager, because the packager won't be too difficult to make.

    Unrelated: I left my mouse at home (we work from laptops), and I keep looking like an idiot trying to grab my mouse pad.

    Also unrelated: I'm able to work on this at my job, because we finished our projects faster than my boss had expected, so we get down time.

    EDIT:
    After a few hours of headache, I finally realized that my multiple mod loading *wasn't working* because I incorrectly packaged one of the mods I was testing with. Maybe I should've made that packager first XD.

    Updating OP with updates

    EDIT2:

    For some reason, the forum keeps telling me that the file i'm trying to upload is empty. It's also telling me the image I'm trying to upload is invalid. Can anybody help me out?
  8. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    good job! :D

    (there were server side issues people: couldn't update their avatar... does it work now?)
  9. syox

    syox Member

    Messages:
    859
    Likes Received:
    3
    +1
  10. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    I saw your post about merging files in the Economy mod thread, then thought of an idea.

    Would it be possible to allow developers to create patch files? This would be a file which is formatted in a certain way which tells the manager to alter the core file in a certain way.

    For instance in the live_game_alpha.html file I just want to add a single JavaScript tag in the header. I'd like to be able to tell the mod manager to insert this line of code at line x, or to look for the line which has <script src="live_game_alpha.js" type="text/javascript"></script> and place my code the line after that.

    The second would probably be more resilient than the first because Uber will likely be changing stuff in these files quite regularly.
  11. jacoby6000

    jacoby6000 Member

    Messages:
    105
    Likes Received:
    8
    What you're suggesting is exactly what the Mod Manager is going to do once merging works. Patch files are the only feasible way to accurately and precisely merge several mods.

    v1.2 of the mod manager is on it's way, and with it you won't see very much new stuff. The big thing is that the source will be open to the public, and it will be using actual object oriented concepts. Versions 1.0 and 1.1 had all of the code in one file (like C code), because I'm used to programming without Objects. It's a practice I need to embrace, and so I am... Painfully.

    Up next on the Mod Manager is merging files. After that, I'll start spicing up the ui a little bit. Currently it's a little bland, and descriptions don't fit in the box, and there is no place for a more lengthy description.

    v1.3 will probably add merging,
    v2 will be a UI overhaul.

    I'm wondering what the best way to spread this around to other mod creators/users is. It's a lot more safe to develop mods with it (because It keeps your files Separate from vanilla), and in the long-run it's better for the End-User than just overwriting files blindly.
  12. cwarner7264

    cwarner7264 Moderator Alumni

    Messages:
    4,460
    Likes Received:
    5,390
    I'm not a programmer so I won't profess to know anything about anything that's going on here, but from a lay person's perspective I can see a rather elegant solution.

    Uber have said from the start that they want PA to be extremely mod friendly. Unless there are good reasons not to, I would have thought including a mod manager in the client itself would be highly beneficial to all concerned. Would it not be possible to have your mod manager launchable from the PA client?

    If there are good reasons why this would be unfeasible, I'm all ears, but this would help to ensure high visibility to both modders and end users.
  13. jacoby6000

    jacoby6000 Member

    Messages:
    105
    Likes Received:
    8
    The big problem here, is that there currently is no modding API whatsoever. Once there is one, Uber will have a much more elegant way to switch mods around. If you look inside of PA/media/pa, there is a file called default.settings, and in it there is a file path that says "/PA". All that that means, is that PA is looking for files in the Planetary Annihilation/PA directory for it's content. This is important, because in the future there could be more files similar to that, which could tell PA to look for certain files in certain places which would be perfect for mods.

    In fact, the way the mod manager works right now could very easily be considered a "hack" because it's certainly not the way things SHOULD be done, but being alpha, not much is done the way that it should be. For this reason, I don't expect it to be integrated with the launcher.

    Another thing to consider, is that the mod-base isn't yet large enough to justify creating a mod-manager, so that's on the back burner most likely.

    I should also add that I thoroughly expect for this mod manager to be obsolete by the official release of this game. The only exception would be if PA doesn't come included with a mod manager. In which case, I (or the community, open source woo!) will keep this manager updated.

    Last thing to say. I can't merge it with the mod manager myself because #1 that's Uber's, not mine. And #2 I'm not even sure anybody would have the patience to modify the binary to implement the mod manager.
  14. cwarner7264

    cwarner7264 Moderator Alumni

    Messages:
    4,460
    Likes Received:
    5,390
    Ah. Then everything I said above was total bollocks anyway, even without the technical difficulties you listed above :D

    In that case, may I humbly suggest posting both to Reddit and to the General Discussion section to raise awareness? I'd say a fairly sizeable portion of the alpha (and indeed the future Beta) community would see it that way.
  15. jacoby6000

    jacoby6000 Member

    Messages:
    105
    Likes Received:
    8
    Ehh... I'd rather not clutter up entire forum sections, when there's a section created for stuff like this. The best way to spread this without imposing, is just to have developers package their mods for it, and include it in their mod descriptions. I already saw two that I didn't even know adopted it, so things shouldn't be too bad.

    I'm also hoping Uber fixes the "empty file" glitch soon. I hate using media fire to host my files, because I have to go there to check the download count (to see if anybody is using this). Not to mention, if people see that it's something that's downloaded often, they're more likely to accept it as being useful.
  16. cwarner7264

    cwarner7264 Moderator Alumni

    Messages:
    4,460
    Likes Received:
    5,390
    It's not clutter IMO. I'd say something like this is useful enough to warrant having an 'advert' post on the General Discussion forum. If you're worried about clutter, might want to ask a forum mod for the OK first, but I very much doubt they'd begrudge you it.

    The more people that use this tool, the better for the modding community in general! Some modders may not check this section of the forums - in which case they'll not package their mod files for it!
  17. jacoby6000

    jacoby6000 Member

    Messages:
    105
    Likes Received:
    8
    I'll wait for raevn to come by and say something instead of asking. It's not significant until it can merge files. Right now, it doesn't provide any extra functionality over just dropping files in PA/media. Sure, it's safer and easier, but most people aren't in the alpha for mods anyway. And if they are, they can sure as hell move a couple of files.

    I'll take that as a compliment :D, I suppose simplicity for the end user would help the community grow!

    EDIT:
    Just realized, raevn has already posted this both on the modding tools AND mods page. I can't really ask for more than that XD

    EDIT2:
    I'm going to PM mod developers to let them know this is here.
  18. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    you have to select the media folder.... shouldn't it be just the PA folder?

    the mod manger ran once, I can't run it again, the mod packger never ran. Whats the problem? both apps are crashing instantaneously.

    also are yourlocalmadsci's mod and oxide246's mods compatible yet?
  19. jacoby6000

    jacoby6000 Member

    Messages:
    105
    Likes Received:
    8
    That is something I'll update now. you should have to select your C:/whatever/Planetary Annihilation folder. It shouldn't have let you select the media folder. I'm fixing it as we speak. To fix that, you can manually enter the path in the .settings file that should be in the same directory as the Mod Manager.

    The mod manager will alert you if mods are incompatible, so just try selecting multiple mods before hitting launch and see what happens!

    Woo updates!

    Check out the OP for details.

    EDIT:

    regarding the instant "crash" are you using a steam version, or the launcher version?
  20. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    launcher version. I'm getting tons of problems. such as it takes a random folder called PA for the game folder. and there's no way for me to direct it to the right one.

    I just made a new ersion now based of yourlolcat's modmanager zip. does it work?

Share This Page