Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 2 [3]

Author Topic: [0.97a] WhichMod 1.2.2a  (Read 111684 times)

theDragn

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: [0.95.1a] WhichMod 1.2.1
« Reply #30 on: October 18, 2022, 01:24:59 AM »

Nothing to update here (and hopefully I won't ever have to update this), but I've been asked about how to include mod-identifying descriptions without interfering with WhichMod, so I've got some code for anyone who wants to include it in their mod. This will just add whichmod-style descriptions to ships and weapons from your mod if the user doesn't have whichmod active.

Code
public class YourModPlugin extends BaseModPlugin {
    @Override
    public void onApplicationLoad() {
        SettingsAPI settings = Global.getSettings();
        JSONArray csvData;
        if (settings.getModManager().isModEnabled("whichmod"))
            return;
        try {
            csvData = settings.loadCSV("data/strings/descriptions.csv", "YOUR MOD ID HERE");
        } catch (Exception e) {
            return;
        }

        // try reading each row in descriptions.csv
        for (int i = 0; i < csvData.length(); i++) {
            try {
                JSONObject row = csvData.getJSONObject(i);
                String id = row.getString("id");
                String type = row.getString("type");
                if (!(id == null || type == null || id.equals("") || type.equals(""))) {
                    Description desc;
                    Type descType = Enum.valueOf(Type.class, type);
                    if (descType == Type.SHIP || descType == Type.WEAPON)
                        desc = settings.getDescription(id, descType);
                    else
                        continue;
                    desc.setText1("[YOUR MOD NAME HERE] " + desc.getText1());
                    String prefix;
                }

            } catch (Exception e) {
                //logger.log(Level.INFO, e);
            }
        }
    }
}

theDragn

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: [0.96a] WhichMod 1.2.2
« Reply #31 on: May 09, 2023, 10:41:49 PM »

Updated version number for 0.96 compatibility. Will probably see about getting it to work on skins now that they have mutable descriptions, but for now it's just the quick and easy update.

eidolad

  • Commander
  • ***
  • Posts: 227
    • View Profile
Re: [0.96a] WhichMod 1.2.2
« Reply #32 on: May 13, 2023, 07:16:01 PM »

thanks very much for keeping this mod up to date...super useful
Logged

SpaceshipCaptainYukari

  • Ensign
  • *
  • Posts: 16
    • View Profile
Re: [0.96a] WhichMod 1.2.2
« Reply #33 on: May 26, 2023, 04:36:28 AM »

Excuse me, the downloadable version is ahead of the version on the version checker. Just letting you know.
Logged

theDragn

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: [0.96a] WhichMod 1.2.2
« Reply #34 on: May 27, 2023, 04:17:27 PM »

Excuse me, the downloadable version is ahead of the version on the version checker. Just letting you know.
Thanks for the heads up. Fixed.

theDragn

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: [0.96a] WhichMod 1.2.2a
« Reply #35 on: February 03, 2024, 12:07:15 PM »

Updated the version number for 0.97. No other changes.
Pages: 1 2 [3]