/// <summary> /// Initialises Sonic Colors Set Editor /// </summary> public void Init() { HasBeenInit = true; Config.LoadConfig("config.bin"); UpdateObjects(); if (!Directory.Exists("Templates")) { var result = MessageBox.Show(Resources.NoTemplatesText, ProgramName, MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (result == DialogResult.OK) { Process.Start(Resources.TemplatesURL); } Environment.Exit(-1); } else { // Loads the object templates TemplatesColors = SetObjectType.LoadObjectTemplates(TemplatesPath, SonicColorsShortName); foreach (string objName in TemplatesColors.Keys) { ComboBox_ObjectType.Items.Add(objName); } Console.WriteLine("Loaded {0} Templates.", TemplatesColors.Count); // Load the Modifiers file if (File.Exists("Templates/Colors/Modifiers-ColorsToGenerations.xml")) { var doc = XDocument.Load("Templates/Colors/Modifiers-ColorsToGenerations.xml"); var renameNodes = doc.Root.Element("Rename").DescendantNodes().OfType <XElement>(); var objPhysNodes = doc.Root.Element("MakeObjectPhysics").DescendantNodes().OfType <XElement>(); var posYNodes = doc.Root.Element("Position-Y").DescendantNodes().OfType <XElement>(); var rotateXNodes = doc.Root.Element("Rotation-X").DescendantNodes().OfType <XElement>(); var rotateYNodes = doc.Root.Element("Rotation-Y").DescendantNodes().OfType <XElement>(); var paramNodes = doc.Root.Element("Param-Divide").DescendantNodes().OfType <XElement>(); ColorstoGensRenamers = renameNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); ColorstoGensObjPhys = objPhysNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); ColorstoGensPosYMods = posYNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); ColorstoGensRotateXMods = rotateXNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); ColorstoGensRotateYMods = rotateYNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); ColorstoGensParamMods = paramNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); } } if (File.Exists("CpkMaker.dll")) { HasCPKMaker = true; ToolStripMenuItem_ExtractCPK.Enabled = true; } else { Message(Resources.CPKMakerNotFoundText); } }
private void ReloadTemplates_ToolStripMenuItem_Click(object sender, EventArgs e) { // Loads the object templates ComboBox_ObjectType.Items.Clear(); TemplatesColors = SetObjectType.LoadObjectTemplates(TemplatesPath, SonicColorsShortName); foreach (string objName in TemplatesColors.Keys) { ComboBox_ObjectType.Items.Add(objName); } Console.WriteLine("Loaded {0} Templates.", TemplatesColors.Count); }
// Methods public static void Load(string startupPath) { string filePath = Helpers.CombinePaths(startupPath, FilePath); string templatesDir = Helpers.CombinePaths(startupPath, TemplatesDir); using (var fileStream = File.OpenRead(filePath)) { var xml = XDocument.Load(fileStream); var versionAttr = xml.Root.Attribute("version"); if (versionAttr == null) { return; } if (float.TryParse(versionAttr.Value, out float v) && v > HighestSupportedVersion) { throw new FileLoadException(string.Format( "Could not load GameList. GameLists of version ({0}) are unsupported.", versionAttr.Value), filePath); } foreach (var element in xml.Root.Elements("Game")) { // Game Name var shortNameAttr = element.Attribute("shortName"); var nameAttr = element.Attribute("name"); var unitMultiplierAttr = element.Attribute("unitMultiplier"); if (shortNameAttr == null) { continue; } string shortName = shortNameAttr.Value; // Game Entry var templates = SetObjectType.LoadObjectTemplates(templatesDir, shortName); var game = new GameEntry() { Name = (nameAttr == null) ? shortName : nameAttr.Value, ShortName = shortName, ObjectTemplates = templates, UnitMultiplier = (unitMultiplierAttr == null) ? 1 : Convert.ToSingle(unitMultiplierAttr.Value) }; Games.Add(game); // TODO: Remove this line Console.WriteLine("Loaded {0} templates for {1}.", game.ObjectTemplates.Count, game.Name); } } }