Package org.ini4j

Examples of org.ini4j.Wini


    // load ini?
    File i = new File(path, id + ".ini");
    if (i.exists()) {
      if (install == null) {
        try {
          Wini ini = new Wini(i);
          install = ini.get(id);
        } catch (Throwable t) {
          ymd.add(YEx.toString(I18N.t("Kann {0} nicht lesen.", i), t, true), Level.INFO_INT);
        }

        // can use?
        if (getElement("core", null) != null && getElement("core", " ").indexOf(Double.toString(YAamsCore.VERSION)) == -1) {
          return setMessage(I18N.t("Kann {0} unter {1} nicht starten, da es für {2} geschrieben wurde.", getTitle(),
              YAamsCore.TITLE, getElement("core", "MISSING CORE")), ymd, STAGE.NOTUSEABLE, true);
        }

        // check class
        if (getElement("class", null) == null) {
          return setMessage(I18N.t("Kann {0} nicht starten, da keine Startklasse angegeben wurde.", getTitle()), ymd,
              STAGE.NOTUSEABLE, true);
        }
      }
    } else {
      return setMessage(I18N.t("Nicht installiert.", getTitle()), ymd, STAGE.NOTUSEABLE, false);
    }

    // load online info?
    if (online == null) {
      i = new File(path, "online.ini");
      if (i.exists()) {
        try {
          Wini ini = new Wini(i);
          online = ini.get(id);
        } catch (Throwable t) {
          ymd.add(YEx.toString(I18N.t("Kann {0} nicht lesen.", i), t, true), Level.INFO_INT);
        }
      }
    }
View Full Code Here


    try {
      FormBuilder f = new FormBuilder("plugin.updates");

      // run over all plugins
      final Wini ini = new Wini(catalog);
      // add all
      for (final String id : ini.keySet()) {
        // create folder?
        File o = new File(new File(folder, id), "online.ini");
        if (!o.getParentFile().exists()) {
          FileHelper.mkdirs(o.getParentFile());
        }

        // clear file
        if (o.exists()) {
          o.delete();
        }
        o.createNewFile();

        // save in folder
        Wini out = new Wini(o);
        out.add(id, ini.get(id));
        out.store();

        // exist?
        if (!PluginLoader.getPlugins().containsKey(id)) {
          PluginLoader.getPlugins().put(id, new PluginInfo(o.getParentFile()));
        }
View Full Code Here

      // read game ini
      if (FileHelper.checkPath("Can not read " + RGSSProjectHelper.getGameIniFile(p) + " for " + p.getTitle(),
          RGSSProjectHelper.getGameIniFile(p), false, false)) {
        try {
          Wini ini = new Wini(RGSSProjectHelper.getGameIniFile(p));
          p.getCache().put("gameini", ini.get("Game"));

        } catch (Throwable t) {
          YEx.info("Can not read " + RGSSProjectHelper.getGameIniFile(p) + " for " + p.getTitle(), t);
        }
      } else {
View Full Code Here

   * @param p
   */
  protected void readGameIniToData(Project p) {
    // read Game.ini
    try {
      Wini ini = new Wini(new File(p.getPath(), "Game.ini"));
      p.getData().put("library", ini.get("Game", "Library"));
      p.getData().put("scripts", ini.get("Game", "Scripts"));
    } catch (Throwable t) {
      YEx.info("Can not edit " + new File(p.getPath(), "Game.ini"), t);
    }

    YMessagesDialog mess = new YMessagesDialog(I18N.t("Probleme beim Öffnen des Projects {0}", p.getTitle()), "rgss.project.open");
View Full Code Here

   * @param p
   */
  protected void saveDataToGameIni(Project p) {
    // save title
    try {
      Wini ini = new Wini(new File(p.getPath(), "Game.ini"));
      ini.put("Game", "Title", p.getTitle());
      ini.put("Game", "Library", p.getData().get("library"));
      ini.store();
    } catch (Throwable t) {
      YEx.info("Can not edit " + new File(p.getPath(), "Game.ini"), t);
    }
  }
View Full Code Here

      return false;
    }

    // edit Game.ini
    try {
      Wini ini = new Wini(new File(p.getPath(), "Game.ini"));
      ini.put("Game", "Title", p.getTitle());
      ini.store();
    } catch (Throwable t) {
      YEx.info("Can not edit " + new File(p.getPath(), "Game.ini"), t);
      return false;
    }
    return true;
View Full Code Here

    }

    HashMap<String, File> rtpFiles = new HashMap<String, File>();
    // read game ini
    try {
      Wini ini = new Wini(RGSSProjectHelper.getGameIniFile(p));

      // rgss1?
      if (RGSSProjectHelper.getRGSSVersion(p) == 1) {
        // read rtp
        for (String s : new String[] { "RTP1", "RTP2", "RTP3" }) {
          // exist?
          String rtp = ini.get("Game", s);
          if (rtp != null && rtp.length() > 0) {
            if (installRTP(rtp, 1)) {
              p.getCache().put(s, rtp);
              rtpFiles.put(rtp, rtps.get(1).get(rtp));
            }
          } else {
            p.getCache().put(s, "");
          }
        }
      }

      // rgss2?
      if (RGSSProjectHelper.getRGSSVersion(p) == 2) {
        // read rtp
        // exist?
        String rtp = ini.get("Game", "RTP");
        if (rtp != null && rtp.length() > 0) {
          if (installRTP(rtp, 2)) {
            p.getCache().put("rtp", rtp);
            rtpFiles.put(rtp, rtps.get(2).get(rtp));
          }
View Full Code Here

    }

    HashMap<String, File> rtpFiles = new HashMap<String, File>();
    // read game ini
    try {
      Wini ini = new Wini(p.getGameIniFile());

      // rgss1?
      if (p.getRgssVersion() == 1) {
        // read rtp
        for (String s : new String[] { "RTP1", "RTP2", "RTP3" }) {
          // exist?
          String rtp = ini.get("Game", s);
          if (rtp != null && rtp.length() > 0) {
            if (installRTP(rtp, 1)) {
              p.getObjects().put(s, rtp);
              rtpFiles.put(rtp, rtps.get(1).get(rtp));
            }
          } else {
            p.getObjects().put(s, "");
          }
        }
      }

      // rgss2?
      if (p.getRgssVersion() == 2) {
        // read rtp
        // exist?
        String rtp = ini.get("Game", "RTP");
        if (rtp != null && rtp.length() > 0) {
          if (installRTP(rtp, 2)) {
            p.getObjects().put("rtp", rtp);
            rtpFiles.put(rtp, rtps.get(2).get(rtp));
          }
View Full Code Here

    // exist it?
    if (!objects.containsKey("gameini")) {

      // read game ini
      try {
        Wini ini = new Wini(getGameIniFile());
        objects.put("gameini", ini.get("Game"));

      } catch (Throwable t) {
        YEx.info("Can not read " + getGameIniFile() + " for rtp", t);
      }
    }
View Full Code Here

  public boolean modsCoal() {
    return modCoal;
  }

  private void readDesc() throws InvalidFileFormatException, IOException {
    Wini wini = new Wini(modDescFile);

    modDesc = wini.get("ModInfo", "moddesc");
    modName = wini.get("ModInfo", "modname");
    if (ModManager.logging){
      ModManager.debugLogger.writeMessage("------------------------"+modName+"------------------------");
      ModManager.debugLogger.writeMessage("Validating that this is a valid mod");
      }
    // Check if this mod has been made for Mod Manager 2.0 or legacy mode
    float modcmmver = 0;
    try {
      modcmmver = Float.parseFloat(wini.get("ModManager", "cmmver"));
    } catch (NumberFormatException e) {
      if (ModManager.logging){
        ModManager.debugLogger.writeMessage("Didn't read a ModManager version of the mod. Setting modtype to legacy");
      }
      modcmmver = 0.0f;
    }

    // Backwards compatibility for mods that are built to target older versions of mod manager (NO DLC)
    if (modcmmver < 2.0f) {
      if (ModManager.logging){
        ModManager.debugLogger.writeMessage("Modcmmver is less than 2, checking for coalesced.bin (legacy)");
      }
      File file = new File(ModManagerWindow.appendSlash(modPath) + "Coalesced.bin");
      if (!file.exists()) {
        if (ModManager.logging){
          ModManager.debugLogger.writeMessage(modName + " doesn't have Coalesced.bin and is marked as legacy, marking as invalid.");
        }
        return;
      }

      addTask(ModType.COAL, null);
      setModDescription(true);

      validMod = true;
      if (ModManager.logging){
        ModManager.debugLogger.writeMessage(modName + " valid, marked as legacy mod. Added coalesced swap job, marked valid, finish reading mod.");
        ModManager.debugLogger.writeMessage("--------------------------END OF "+modName+"--------------------------");
      }
      return;
    }
   
    if (ModManager.logging){
      ModManager.debugLogger.writeMessage("Mod Manager version read was >= 2.0, marked as modern style mod.");
      ModManager.debugLogger.writeMessage("Checking for DLC headers in the ini file.");
    }
    // It's a 2.0 or above mod. Check for mod tags in the desc file
    String[] modIniHeaders = ModType.getHeaderNameArray();
    for (String modHeader : modIniHeaders) {
      if (ModManager.logging){
        ModManager.debugLogger.writeMessage("Reading header: " + modHeader + " in ini of " + modName);
      }
      // Check for each mod. If it exists, add the task
      String iniModDir = wini.get(modHeader, "moddir");
      if (iniModDir != null && !iniModDir.equals("")) {
        // It's a DLC header, we should check for the files to mod, and make sure they all match properly
        if (ModManager.logging){
          ModManager.debugLogger.writeMessage(modName + ": Found ini header " + modHeader);
        }
        String newFileIni = wini.get(modHeader, "newfiles");
        String oldFileIni = wini.get(modHeader, "replacefiles");
        // System.out.println("New files: "+newFileIni);
        // System.out.println("Old Files: "+oldFileIni);
        if (newFileIni == null || oldFileIni == null || newFileIni.equals("") || oldFileIni.equals("")) {
          if (ModManager.logging){
            ModManager.debugLogger.writeMessage("newfiles/replace files was null or empty, mod marked as invalid.");
          }
          return;
        }

        StringTokenizer newStrok = new StringTokenizer(newFileIni, ";");
        StringTokenizer oldStrok = new StringTokenizer(oldFileIni, ";");
        if (newStrok.countTokens() != oldStrok.countTokens()) {
          // Same number of tokens aren't the same
          if (ModManager.logging){
            ModManager.debugLogger.writeMessage("Number of files to update/replace do not match, mod being marked as invalid.");
          }
          return;
        }

        // Check to make sure the filenames are the same, and if they are, then the mod is going to be valid.
        // Start building the DLC mod job.
        DLCInjectJob newJob = new DLCInjectJob(ModType.getDLCPath(modHeader));
        while (newStrok.hasMoreTokens()) {
          String newFile = newStrok.nextToken();
          String oldFile = oldStrok.nextToken();
          // System.out.println("Validating tokens: "+newFile+" vs "+oldFile);
          if (!newFile.equals(getSfarFilename(oldFile))) {
            if (ModManager.logging){
              ModManager.debugLogger.writeMessage("Filenames failed to match, mod marked as invalid: " + newFile + " vs " + getSfarFilename(oldFile));
            }
            return; // The names of the files don't match
          }
         
          //Add the file swap to task job - if this method returns false it means a file doesn't exist somewhere
          if (!(newJob.addFileReplace(ModManagerWindow.appendSlash(modDescFile.getParent()) + ModManagerWindow.appendSlash(iniModDir) + newFile, oldFile))){
            if (ModManager.logging){
              ModManager.debugLogger.writeMessage("Failed to add file to replace (File likely does not exist), marking as invalid.");
            }
            return;
          }
        }
          if (ModManager.logging){
            ModManager.debugLogger.writeMessage(modName + ": Successfully made a new DLC Injection Job for: " + modHeader);
          }
        addTask(modHeader, newJob);
      }
    }

    // Check for coalesced in the new mod manager version (modcoal)
    if (ModManager.logging){
      ModManager.debugLogger.writeMessage(modName + ": Checking for coalesced flag in moddesc.ini");
    }
    int modCoalFlag = 0;
    try {
      modCoalFlag = Integer.parseInt(wini.get("ModInfo", "modcoal"));
      if (ModManager.logging){
        ModManager.debugLogger.writeMessage("Coalesced flag: "+modCoalFlag);
      }

      if (modCoalFlag != 0) {
View Full Code Here

TOP

Related Classes of org.ini4j.Wini

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.