Provides PCC creation methods.
예제 #1
0
        /// <summary>
        /// Searches for PCC by name in a certain game specified by PathInclDLC. Can also use expID to narrow search if required. Return name of PCC, empty if not found.
        /// </summary>
        /// <param name="pccname">Name of PCC to search for.</param>
        /// <param name="PathInclDLC">Path encasing BIOGame and DLC. i.e. Parent folder containing folders BIOGame and DLC.</param>
        /// <param name="expID">ExpID of an object inside the desired PCC.</param>
        /// <returns>Name of PCC if found, else empty string.</returns>

        /*public static string SearchForPCC(string pccname, string PathInclDLC, int expID, string objectName, bool isTexture, int whichgame)
         * {
         *  // KFreon: Lowercase PCC name
         *  string name = Path.GetFileName(pccname).ToLowerInvariant();
         *  List<string> searchResults = new List<string>();
         *
         *  // KFreon: Create lists of valid files if necessary
         *  lock (ValidFiles)
         *      if (!ValidFiles.ContainsKey(PathInclDLC.ToLowerInvariant()))
         *      {
         *          List<string> temp = Directory.EnumerateFiles(PathInclDLC, "*", SearchOption.AllDirectories).Where(pcc => pcc.EndsWith(".pcc", true, null) || pcc.EndsWith(".u", true, null) || pcc.EndsWith(".sfm", true, null) || pcc.EndsWith(".upk", true, null)).ToList();
         *          ValidFiles.Add(PathInclDLC.ToLowerInvariant(), temp);
         *      }
         *
         *  // KFreon: Attempt to find PCC
         *  searchResults.AddRange(ValidFiles[PathInclDLC.ToLowerInvariant()].Where(pcc => pcc.ToLowerInvariant().Contains(name)));
         *
         *  string retval = "";
         *
         *  // KFreon: Do special stuff if multiple files found
         *  if (searchResults.Count > 1)
         *  {
         *      // KFreon: If expID given, use it to try to discern correct pcc
         *      if (expID != -1)
         *      {
         *          List<string> temp = new List<string>();
         *          foreach (string file in searchResults)
         *          {
         *              // KFreon: Only work on stuff if file is correct given the provided information
         *              if (CheckSearchedTexture(file, expID, objectName, whichgame))
         *              {
         *                  temp.Add(file);
         *
         *                  // KFreon: See if DLC is relevent
         *                  string dlcname = KFreonLib.Misc.Methods.GetDLCNameFromPath(pccname);
         *                  if (dlcname != "")
         *                  {
         *                      temp.Clear();
         *                      temp.Add(file);
         *                      break;
         *                  }
         *              }
         *          }
         *          if (temp.Count == 1)
         *              retval = temp[0];
         *          else if (temp.Count > 1)
         *          {
         *              // KFreon: If still multiple files found, break things.
         *              using (SelectionForm sf = new SelectionForm(temp, "LET ME KNOW ABOUT THIS PLEASE!!", "Oh dang. More work for me.", false))
         *                  sf.Show();
         *
         *              retval = String.Join("#", temp.ToArray());
         *              DebugOutput.PrintLn("Multiple pccs found for: " + pccname);
         *              foreach (string item in temp)
         *                  DebugOutput.PrintLn(item);
         *              DebugOutput.PrintLn();
         *          }
         *      }
         *  }
         *  else if (searchResults.Count == 1)
         *  {
         *      if (isTexture && CheckSearchedTexture(searchResults[0], expID, objectName, whichgame) || !isTexture)
         *          retval = searchResults[0];
         *  }
         *
         *  return retval;
         * }*/

        private static bool CheckSearchedTexture(string file, int expID, string objectName, int whichgame)
        {
            DebugOutput.PrintLn("Checking texture");


            // KFreon: Test if this files' expID is the one we want
            IPCCObject pcc = Creation.CreatePCCObject(file, whichgame);

            // KFreon: First check if there's enough expID's in current file, then if we're looking at a texture in current file
            if (pcc.Exports.Count >= expID && pcc.Exports[expID].ValidTextureClass())
            {
                bool nametest = (objectName == null ? true : pcc.Exports[expID].ObjectName.ToLowerInvariant().Contains(objectName.ToLowerInvariant()));
                return(nametest);
            }
            return(false);
        }
예제 #2
0
 /// <summary>
 /// Reorders files in a Tex2D object so the first file has a proper arcname variable. THANKS PRINCE.
 /// </summary>
 /// <param name="files">List of PCC's to check.</param>
 /// <param name="expIDs">List of ExpID's for given PCC's.</param>
 /// <param name="pathBIOGame">Path to BIOGame folder.</param>
 /// <param name="GameVersion">Game in question.</param>
 public static bool ReorderFiles(ref List <string> files, ref List <int> expIDs, string pathBIOGame, int GameVersion)
 {
     // KFreon: Loop over all files to find one that has the correct arcName property
     for (int i = 0; i < files.Count; i++)
     {
         ITexture2D tex = Creation.CreatePCCObject(files[i], GameVersion).CreateTexture2D(expIDs[i], pathBIOGame);
         string     arc = tex.arcName;
         if (i == 0 && (arc != "None" && !String.IsNullOrEmpty(arc)))
         {
             return(true);
         }
         else if (arc != "None" && !String.IsNullOrEmpty(arc))
         {
             string file = files[i];
             int    id   = expIDs[i];
             files.RemoveAt(i);
             expIDs.RemoveAt(i);
             files.Insert(0, file);
             expIDs.Insert(0, id);
             return(true);
         }
     }
     return(false);
 }