public static List <DataFile> GetFiles(string binPath) { List <DataFile> Files = new List <DataFile>(); try { if (!Directory.Exists(binPath)) { DirectoryInfo di = Directory.CreateDirectory(binPath); } if (!Directory.Exists(Path.Combine(binPath, "files"))) { DirectoryInfo di = Directory.CreateDirectory(Path.Combine(binPath, "files")); } if (File.Exists(Path.Combine(binPath, "files", "filelist.xml"))) { Debug.Log("", false, Debug.LogStates.Standard); Debug.Log("|'Found Core File List'|", false, Debug.LogStates.Standard); XmlReader xReader = XmlReader.Create(Path.Combine(binPath, "files", "filelist.xml")); Debug.Log("|'Collecting Core Game Files'|", false, Debug.LogStates.Standard); try { while (xReader.Read()) { if (xReader.NodeType == XmlNodeType.EndElement && xReader.Name.ToString().ToUpper() == "GAMEFILES") { List <DataFile> FilesToRemove = new List <DataFile>(); foreach (DataFile file in Files) { if (File.Exists(Path.Combine(MainThread.GameFolderPath, file.Path))) { Debug.Log(Path.Combine(MainThread.GameFolderPath, file.Path).ToString() + " > " + file.Type, false, Debug.LogStates.Standard); } else { FilesToRemove.Add(file); Debug.Log(Path.Combine(MainThread.GameFolderPath, file.Path).ToString() + " > " + file.Type, false, Debug.LogStates.Standard); Debug.Log("^'File Not Found'^", false, Debug.LogStates.Warning); } } if (FilesToRemove.Count > 0) { Debug.Log("", false, Debug.LogStates.Standard); Debug.Log("|'Reloading File List After Modifications'|,", false, Debug.LogStates.Standard); foreach (DataFile file in FilesToRemove) { Files.Remove(file); } foreach (DataFile file in Files) { if (File.Exists(Path.Combine(MainThread.GameFolderPath, file.Path))) { Debug.Log(Path.Combine(MainThread.GameFolderPath, file.Path).ToString() + " > " + file.Type, false, Debug.LogStates.Standard); } else { Files.Remove(file); Debug.Log(Path.Combine(MainThread.GameFolderPath, file.Path).ToString() + " > " + file.Type, false, Debug.LogStates.Standard); Debug.Log(" ^ 'File Not Found' ^ ", false, Debug.LogStates.Warning); } } } Debug.Log("|'Collected All Core Files'|", false, Debug.LogStates.Standard); } switch (xReader.NodeType) { case XmlNodeType.Element: switch (xReader.Name.ToString().ToUpper()) { case "DATA": DataFile file = new DataFile(xReader.GetAttribute("path"), GetFileType(xReader.GetAttribute("type"))); //Debug.Log("FileFound", false, Debug.LogStates.Standard); Files.Add(file); break; } break; } //xReader.Read(); } xReader.Close(); } catch (Exception e) { Console.Write("Unrecoverable Loading Error Has Occured."); Console.Write("Press Enter To Exit"); Debug.ExceptionCatch(e, Debug.LogStates.Error); Console.Read(); Program.Error_Exit(); } } else { throw new Exception("Core File List Doesn't Exist, Line 50, FileInterpreter"); } } catch (Exception e) { Console.Write("Error Finding FileData: {0}", e.ToString()); Debug.Log("Error Finding FileData: " + e.ToString(), false, Debug.LogStates.Error); } return(Files); }
public static void LoadFile(DataFile file) { FileType ft = file.Type; string _path = Path.Combine(MainThread.GameFolderPath, file.Path); //string path = @"C:\Users\PyroFlames\AppData\Roaming\.ETF_TextRPG\bin\classlist.xml"; XmlReader xReader = XmlReader.Create(_path); //Console.Clear(); switch (ft) { case FileType.Item: LoadItemFile(xReader, Item.ItemType.Material); break; case FileType.Armor: LoadItemFile(xReader, Item.ItemType.Armor); break; case FileType.Weapon: LoadItemFile(xReader, Item.ItemType.Weapon); break; case FileType.Consumable: LoadItemFile(xReader, Item.ItemType.Consumable); break; case FileType.Class: LoadClassFile(xReader); break; case FileType.Mob: break; case FileType.Boss: break; case FileType.Shop: break; case FileType.Recipe: break; } /* * while (xReader.Read()) * { * //Console.WriteLine(xReader.MoveToNextAttribute()); * switch (xReader.NodeType) * { * case XmlNodeType.Element: * //listBox1.Items.Add("<" + xReader.Name + ">"); * Console.WriteLine(" " + xReader.Name); * break; * case XmlNodeType.Text: * //listBox1.Items.Add(xReader.Value); * Console.WriteLine(" " + xReader.Value); * break; * case XmlNodeType.EndElement: * //listBox1.Items.Add(""); * break; * } * } */ }