Пример #1
0
  /**
   * Returns BSA object associated with modlisting, or null if there is none.
   *
   * @param m
   * @return
   */
  public static BSA getBSA(ModListing m) {
    if (pluginLoadOrder.containsKey(m)) {
      return pluginLoadOrder.get(m);
    }

    File bsaPath = new File(SPGlobal.pathToData + Ln.changeFileTypeTo(m.print(), "bsa"));
    if (bsaPath.exists()) {
      try {
        BSA bsa = new BSA(bsaPath, false);
        pluginLoadOrder.put(m, bsa);
        return bsa;
      } catch (IOException | BadParameter ex) {
        logBSAError(m.printNoSuffix() + ".bsa", ex);
        return null;
      }
    }

    if (SPGlobal.logging()) {
      SPGlobal.logSpecial(
          LogTypes.BSA, header, "  BSA skipped because it didn't exist: " + bsaPath);
    }
    return null;
  }
Пример #2
0
 /**
  * @param m
  * @return
  */
 public static boolean hasBSA(ModListing m) {
   File bsaPath = new File(SPGlobal.pathToData + Ln.changeFileTypeTo(m.print(), "bsa"));
   return bsaPath.exists();
 }
Пример #3
0
  static void loadResourceLoadOrder() {
    if (resourceLoadOrder != null) {
      return;
    }
    try {
      ArrayList<String> resources = new ArrayList<>();
      boolean line1 = false, line2 = false;
      try {
        File ini = SPGlobal.getSkyrimINI();

        if (SPGlobal.logging()) {
          SPGlobal.logSpecial(LogTypes.BSA, header, "Loading in BSA list from Skyrim.ini: " + ini);
        }
        LInChannel input = new LInChannel(ini);

        String line = "";
        // First line
        while (input.available() > 0 && !line.toUpperCase().contains("SRESOURCEARCHIVELIST")) {
          line = input.extractLine();
        }
        if (line.toUpperCase().contains("SRESOURCEARCHIVELIST2")) {
          line2 = true;
          resources.addAll(processINIline(line));
        } else {
          line1 = true;
          resources.addAll(0, processINIline(line));
        }

        // Second line
        line = "";
        while (input.available() > 0 && !line.toUpperCase().contains("SRESOURCEARCHIVELIST")) {
          line = Ln.cleanLine(input.extractLine(), "#");
        }
        if (line.toUpperCase().contains("SRESOURCEARCHIVELIST2")) {
          line2 = true;
          resources.addAll(processINIline(line));
        } else {
          line1 = true;
          resources.addAll(0, processINIline(line));
        }
      } catch (IOException e) {
        SPGlobal.logException(e);
      }

      if (!line1 || !line2) {
        // Assume standard BSA listing
        if (!resources.contains("Skyrim - Misc.bsa")) {
          resources.add("Skyrim - Misc.bsa");
        }

        if (!resources.contains("Skyrim - Shaders.bsa")) {
          resources.add("Skyrim - Shaders.bsa");
        }

        if (!resources.contains("Skyrim - Textures.bsa")) {
          resources.add("Skyrim - Textures.bsa");
        }

        if (!resources.contains("Skyrim - Interface.bsa")) {
          resources.add("Skyrim - Interface.bsa");
        }

        if (!resources.contains("Skyrim - Animations.bsa")) {
          resources.add("Skyrim - Animations.bsa");
        }

        if (!resources.contains("Skyrim - Meshes.bsa")) {
          resources.add("Skyrim - Meshes.bsa");
        }

        if (!resources.contains("Skyrim - Sounds.bsa")) {
          resources.add("Skyrim - Sounds.bsa");
        }

        if (!resources.contains("Skyrim - Sounds.bsa")) {
          resources.add("Skyrim - Voices.bsa");
        }

        if (!resources.contains("Skyrim - Sounds.bsa")) {
          resources.add("Skyrim - VoicesExtra.bsa");
        }
      }

      if (SPGlobal.logging()) {
        SPGlobal.logSpecial(LogTypes.BSA, header, "BSA resource load order: ");
        for (String s : resources) {
          SPGlobal.logSpecial(LogTypes.BSA, header, "  " + s);
        }
        SPGlobal.logSpecial(LogTypes.BSA, header, "Loading in their headers.");
      }

      // Get BSAs loaded from all active pluging's plugin.ini files
      ArrayList<ModListing> activeMods = SPImporter.getActiveModList();
      for (ModListing m : activeMods) {
        File pluginIni = new File(SPGlobal.pathToData + Ln.changeFileTypeTo(m.print(), "ini"));
        if (pluginIni.exists()) {
          LInChannel input = new LInChannel(pluginIni);

          String line = "";
          // First line
          while (input.available() > 0 && !line.toUpperCase().contains("SRESOURCEARCHIVELIST")) {
            line = input.extractLine();
          }
          if (line.toUpperCase().contains("SRESOURCEARCHIVELIST2")) {
            resources.addAll(processINIline(line));
          } else {
            resources.addAll(0, processINIline(line));
          }

          // Second line
          line = "";
          while (input.available() > 0 && !line.toUpperCase().contains("SRESOURCEARCHIVELIST")) {
            line = Ln.cleanLine(input.extractLine(), "#");
          }
          if (line.toUpperCase().contains("SRESOURCEARCHIVELIST2")) {
            resources.addAll(processINIline(line));
          } else {
            resources.addAll(0, processINIline(line));
          }
        }
      }

      resourceLoadOrder = new ArrayList<>(resources.size());
      for (String s : resources) {
        File bsaPath = new File(SPGlobal.pathToData + s);
        if (bsaPath.exists()) {
          try {
            if (SPGlobal.logging()) {
              SPGlobal.logSpecial(LogTypes.BSA, header, "Loading: " + bsaPath);
            }
            BSA bsa = new BSA(bsaPath, false);
            resourceLoadOrder.add(bsa);
          } catch (BadParameter | FileNotFoundException ex) {
            logBSAError(s, ex);
          }
        } else if (SPGlobal.logging()) {
          SPGlobal.logSpecial(
              LogTypes.BSA, header, "  BSA skipped because it didn't exist: " + bsaPath);
        }
      }

    } catch (IOException ex) {
      SPGlobal.logException(ex);
    }
  }