[solved] Can't successfully overwrite stock CSS file with a mod

Discussion in 'Mod Support' started by coldboot, May 1, 2015.

  1. coldboot

    coldboot Active Member

    Messages:
    447
    Likes Received:
    112
    I'm trying to replace the CSS for the "Game Paused" button with a mod. I know it's not recommended to replace files, but replacing the CSS file seems to be the only way to get CSS that will change the Pause button.

    I've made a mod that shows up in PAMM, activates, and should have the same relative path as the file I'm trying to modify, but the old CSS is intact.

    Is there something you have to do to load the mod's CSS after the original game's CSS file?

    Details about how I set up the relative paths are below:

    I'm trying to replace this CSS file:
    ui/main/game/live_game/live_game_paused_popup.css

    Which comes from this relative path in PA's code in Mac OS:
    ~/Library/Application Support/Steam/SteamApps/common/Planetary Annihilation/PA.app/Contents/Resources/media/

    So I made a Git repository with these files:

    $ git ls-files
    modinfo.json
    ui/main/game/live_game/live_game_paused_popup.css
    # (CSS file has the same relative path as the one to be replaced)


    # modinfo.json
    Code:
    {
         "context": "client",
         "identifier": "com.pa.coldboot.smallpause",
         "display_name": "Small Pause Dialogue",
         "description": "Makes the Game Pause dialogue small so it isn't in the way of selecting units.",
         "author": "coldboot",
         "version": "1.0.0",
         "signature": "not yet implemented",
         "priority": 10,
         "enabled": true,
         "id": "smallPause",
         "forum": "[URL]http://TODO[/URL]",
         "category": [
              "in-game",
              "ui"
         ],
         "scenes": {
              "live_game": [
                    "coui://ui/main/game/live_game/live_game_paused_popup.css"
              ]
         },
         "date": "2015/04/30",
         "build": "80462"
    }


    Then I made a symlink to the git repository's root here:
    ~/Library/Application Support/Uber Entertainment/Planetary Annihilation/client_mods/com.pa.coldboot.smallpause
    (Which is where all of the other PAMM mods are installed)

    Then I enabled the mod in PAMM, where is is displayed successfully.
    However, when I start PA, the CSS file appears unchanged.

    Is there some way to check what files are getting loaded?
    Am I doing something incorrectly?
    Last edited: May 1, 2015
  2. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,327
    Likes Received:
    2,125
    That all looks ok. PA had trouble with symlinks in that past though. Not sure if they every fixed that. So try it without the symlink.
    Also, you can see in the log file (or from starting PA from the terminal), which mods are found and loaded.
  3. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    You don't need to list shadowed files in modinfo, that is for patches on top of the base file.

    And yeah, I haven't retested it but symlinks didn't work on OS X when I tried.
    DeathByDenim likes this.
  4. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,327
    Likes Received:
    2,125
    True. To load a custom CSS file after the Uber one, you can just stick you .css in the modinfo file in the appropriate "scenes" like you have done. But use your own custom path for that and don't shadow Uber's one. Just put it in coui://ui/mods/yourmod somewhere.
  5. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    I'd recommend to use some simple lines of javascript instead, apply style tags dynamically.
  6. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,327
    Likes Received:
    2,125
    Does that work for the live_game panels? I had trouble with that when I was working on the 70% zoomed UI. CSS properties such as width, and left and such were all zero at first during loadMods.
  7. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    The size of the panel has to be passed into it from the outside, so size-stuff is a bit tricky but can be made to work.
  8. coldboot

    coldboot Active Member

    Messages:
    447
    Likes Received:
    112
    I'm not sure which paths you're saying I should change. There is the actual path of the CSS file in the git repository, and the path specified in the "scenes" directive in the modinfo.json file. If those two are different from each other, the mod won't know about the file, and if both of them are different from the path of the Uber version of the CSS file, then it won't get overwritten by the mod's version. So what are you saying to do?
  9. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    To check what file is loaded you can start the UI debugger and inspect the network request for the css file, it shows the content of the file it got.
    But I really think a bit of js would do a much better job. Can you post the changes you want? I can make you a quick example of how to apply them via js.
  10. coldboot

    coldboot Active Member

    Messages:
    447
    Likes Received:
    112
    The code is all here:
    https://github.com/nhooey/pa-uimod-smallpause
  11. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Made a pull request with a modified version that uses js to modify the style attributes of the html.
    Works fine, nice mod :)

    [​IMG]
    DeathByDenim likes this.
  12. coldboot

    coldboot Active Member

    Messages:
    447
    Likes Received:
    112
    Thanks Colin!

    What was the point of doing this move, instead of just adding the CSS to the JavaScript and deleting the CSS file?
    ui/{main => main_old_no_shadow}/game/live_game/live_game_paused_popup.css
  13. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    I wasn't sure if the css file still shadows something and I didn't want it to shadow, but didn't want to delete your file, so I renamed the folder. If you don't need it anymore just delete it.
  14. coldboot

    coldboot Active Member

    Messages:
    447
    Likes Received:
    112
    I still can't get it to work in Mac OS.

    If you look at the latest version of the repository, you can see the com.pa.coldboot.smallpause directory. I copy that entire directory to:

    ~/Library/Application Support/Uber Entertainment/Planetary Annihilation/client_mods/com.pa.coldboot.smallpause

    That's where PAMM puts all of the other mods, and PAMM can definitely see the Small Pause mod in the list, and it's activated.

    But nothing happens when I load a game, un-pause and re-pause. There's no console output either.
  15. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,327
    Likes Received:
    2,125
    Well, for one, you never merged cola_colin's changes. :)
    ( See https://github.com/nhooey/pa-uimod-smallpause/network )
  16. coldboot

    coldboot Active Member

    Messages:
    447
    Likes Received:
    112
  17. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    For such cases I usually add a console log into the first line of my js file to load, like I also did in yours:
    console.log("setting small pause styles...");

    does that line show up in your pause scene?

    Also your commit doesn't contain the change to the modinfo.json which means the file very likely indeed won't be loaded.
  18. coldboot

    coldboot Active Member

    Messages:
    447
    Likes Received:
    112
    Although I've fixed those issues, they were unrelated to the reason why the mod wasn't updating.

    I've found that at least in Mac OS Steam PA, you have to do these two things when you change a mod:
    0. Copy your updated mod code to: ~/Library/Application Support/Uber Entertainment/Planetary Annihilation/client_mods
    1. Reload PAMM
    2. Deactivate and reactivate the mod

    If you neglect to do any of those things, or do them in the wrong order, the mod will not be updated in the game.

    I'm not sure why this happens. Do you know what PAMM does when it's reloaded, or when you deactivate and reactivate a mod in PAMM?
  19. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Mods only run out of client_mods (aka mods) or server_mods

    If you changed the "scenes", you have to do something with PAMM to make it rebuild the scene_mod_list - I refresh to make sure it has the current modinfo loaded, and then toggle the mod. I always restart PA to make sure it reloads the new list. But as long as the scene list isn't changing, you should just be able to refresh the UI to see changes in existing files.

    For live game panels, it's also possible to do a reload of only the current debugged panel - paste this into the debugger: api.game.debug.reloadScene(api.Panel.pageId);
  20. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    You can just press F5 in debugger console for the panel.

Share This Page