Questions about implementing a mod's setting

Discussion in 'Mod Support' started by Fr33Lancer, August 12, 2014.

  1. Fr33Lancer

    Fr33Lancer Well-Known Member

    Messages:
    595
    Likes Received:
    288
    I wanted to implement a setting to either switch primary / secondary color for the uber cannon mod for quite some time, and now seems rather quite a good time since there is a nice settings manager (well documented too apparently) to organize mods' settings, thanks to @gonzo4711 (No one seems to be using it yet, that's sad :().

    So, the non developper that I am has several questions.
    As I understand how mods are loaded, they "shadow" (I read "temporary overwrite") existing PA files (+ add any other the modder may have created) at startup.

    In the above mentioned mod, it loads 3 *.pfx files, containing shaders (textual).
    Their content looks like that basically:
    I would have liked to have :
    where MyColorVar would be defined by the setting, but I don't think it's possible to (at least easily) integrate variables into that kind of files. Am I right ?

    So, I was wondering if it's possible, with multiple occurrences (predefined) of a file, to get around the problem:

    If Setting is set to Value 1
    Use Modified_File_1.pfx instead of OriginalPA_File.pfx
    If Setting is set to Value 2
    Use Modified_File_2.pfx instead of OriginalPA_File.pfx
    Is that kind of thing possible ?
    As I understand how it works, the shader (uber_proj_explosion.pfx) is loaded by some ammo file (cannon_uber.json), itself loaded by some file in pa/tool directory (uber_cannon.json)
    I am not sure at which level, the logic layout (*.js ?) could be done (if even possible).

    So if anyone can provide some advice, or point me to a mod already doing that kind of stuff, that would be great ;)
    Thanks for reading me this far :p
  2. wondible

    wondible Post Master General

    Messages:
    3,279
    Likes Received:
    2,084
    The only way I can see this working is by loading the shader contents and using mountMemoryFiles, but that seems a pretty dim prospect given the need to restart the game to test shaders, last I tried to do it.
    Fr33Lancer likes this.
  3. Fr33Lancer

    Fr33Lancer Well-Known Member

    Messages:
    595
    Likes Received:
    288
    Thanks. Do you happen to know if a published mod ever used that api stuff ? Since my dev skill are being close to zero :oops:, I would have liked to attempt to understand it with an existing example.
    I naively made a search on my installed mods folder to see if one was already using this function, but result came empty :( (though I don't have all of them installed, obviously)
  4. wondible

    wondible Post Master General

    Messages:
    3,279
    Likes Received:
    2,084
    Unfortunately, I don't know of any, and I've got too much going on for a long-shot research project right now.
    Fr33Lancer likes this.
  5. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Hmm what's this mountMemoryFiles and where do I find it ?
  6. wondible

    wondible Post Master General

    Messages:
    3,279
    Likes Received:
    2,084
    Used principally in Galactic War, lets see..

    Code:
    ui/main/game/galactic_war/gw_play/gw_referee.js|163| api.file.mountMemoryFiles(cookedFiles);
    ui/main/game/replay_loading/replay_loading.js|86| api.file.mountMemoryFiles(cookedFiles);
    ui/main/shared/js/api/file.js|4| mountMemoryFiles: function (files) { engine.call("file.mountMemoryFiles", JSON.stringify(files)); },
    
    But you have to keep any eye out for it's nuclear dual:

    Code:
    ui/main/game/galactic_war/gw_play/gw_referee.js|21| api.file.unmountAllMemoryFiles();
    ui/main/game/galactic_war/gw_play/gw_referee.js|162| api.file.unmountAllMemoryFiles();
    ui/main/game/replay_loading/replay_loading.js|85| api.file.unmountAllMemoryFiles();
    ui/main/game/start/start.js|820| api.file.unmountAllMemoryFiles();
    ui/main/shared/js/api/file.js|5| unmountAllMemoryFiles: function () { engine.call("file.unmountAllMemoryFiles"); }
    
  7. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Thanks I've put it on my list of things to checkout. Maybe this could solve Blueprint Unit Framework and Balance Mods.
  8. Alpha2546

    Alpha2546 Post Master General

    Messages:
    977
    Likes Received:
    1,561
    So necroing this thread.

    I just got this idea reading this thread. Is it possible to send a copy paste command from the settings menu? I think that should be possible?

    In that case if you tick the option teamcolour then the specific pfx files will be replaced by the teamcoloured ones. This definately isn't the most elegant solution but it probably is the most easiest if possible and would definately work for the pfx files since they can be changed instantly without any crashes. Not sure about the json files though.

    Any comments on this idea?
  9. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,323
    We do not have access to the filesystem from within the game, so we cannot modify or create files like this.
    Alpha2546 likes this.

Share This Page