public static void SetCardFormat(string[] args) { bool success = true; ETGSettings.Save(); if (args == null || args.Length < 1) { Log("You must enter a value"); success = false; } switch (args[0]) { case "lite": case "LITE": case "Lite": { var card = new ItemCardFormat(ItemCardFormat.LITE); ETGSettings.SetCurrentFormat(card); break; } case "full": case "FULL": case "Full": { var card = new ItemCardFormat(ItemCardFormat.FULL); ETGSettings.SetCurrentFormat(card); break; } default: try { string text = File.ReadAllText("mods/ItemCardFormats/" + args[0] + ".txt"); var format = new ItemCardFormat(text); ETGSettings.SetCurrentFormat(format); } catch (System.IO.IOException e) { Log("Failed to load file \"" + args[0] + ".\"\n Format files should be installed in mods/ItemCardFormats"); success = false; } catch (ItemCardFormat.ItemCardFormatException e) { Log("Invalid Format"); success = false; } break; } if (success) { Log("Item card format set:"); Log(ETGSettings.CurrentFormat.format); } }
private static ETGSettings LoadFromFile() { FileStream fs = null; try { XmlSerializer ser = new XmlSerializer(typeof(ETGSettings)); fs = File.Open(filepath, FileMode.Open); ETGSettings output = (ETGSettings)ser.Deserialize(fs); return(output); } catch { return(new ETGSettings()); } finally { if (fs != null) { fs.Close(); } } }