Beispiel #1
0
        public void ImportCodes(string AFileName, bool AQuiet = false)
        {
            if (File.Exists(AFileName))
            {
                XmlDocument  lXml       = new XmlDocument();
                XmlNodeList  lCodes     = null;
                XmlNode      lCodeNode  = null;
                XmlAttribute lAttribute = null;

                lXml.Load(AFileName);
                lCodes = lXml.SelectNodes("//genie/..");

                FModified = true;

                XmlNode lDeleteNode = GameNode.FirstChild;
                while (lDeleteNode != null)
                {
                    GameNode.RemoveChild(GameNode.FirstChild);
                    lDeleteNode = GameNode.FirstChild;
                }
                GameCodes.Clear();

                string lGameFileName = Path.Combine(Path.Combine(Path.Combine(Program.BaseDirectoryExternal, "games"), FGame.Code), FGame.Code + ".nes");
                foreach (XmlNode lCurCode in lCodes)
                {
                    NesFile lGame = new NesFile(lGameFileName);
                    try
                    {
                        lGame.PRG = GameGeniePatcherNes.Patch(lGame.PRG, lCurCode["genie"].InnerText);

                        lCodeNode = FXml.CreateElement("gamegenie");
                        GameNode.AppendChild(lCodeNode);

                        lAttribute       = FXml.CreateAttribute("code");
                        lAttribute.Value = lCurCode["genie"].InnerText.ToUpper().Trim();
                        lCodeNode.Attributes.Append(lAttribute);

                        lAttribute       = FXml.CreateAttribute("description");
                        lAttribute.Value = lCurCode["description"].InnerText;
                        lCodeNode.Attributes.Append(lAttribute);

                        GameCodes.Add(new GameGenieCode(lCurCode["genie"].InnerText.ToUpper().Trim(), lCurCode["description"].InnerText));
                    }
                    catch (GameGenieFormatException)
                    {
                        if (!AQuiet)
                        {
                            Tasks.MessageForm.Show(Resources.Error, string.Format(Resources.GameGenieFormatError, lCurCode["genie"].InnerText, FGame.Name), Resources.sign_error);
                        }
                    }
                    catch (GameGenieNotFoundException)
                    {
                        if (!AQuiet)
                        {
                            Tasks.MessageForm.Show(Resources.Error, string.Format(Resources.GameGenieNotFound, lCurCode["genie"].InnerText, FGame.Name), Resources.sign_error);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void AddCode(GameGenieCode ACode)
        {
            FModified = true;

            XmlNode lCodeNode = FXml.CreateElement("gamegenie");

            GameNode.AppendChild(lCodeNode);

            XmlAttribute lAttribute;

            lAttribute       = FXml.CreateAttribute("code");
            lAttribute.Value = ACode.Code.ToUpper().Trim();
            lCodeNode.Attributes.Append(lAttribute);

            lAttribute       = FXml.CreateAttribute("description");
            lAttribute.Value = ACode.Description;
            lCodeNode.Attributes.Append(lAttribute);

            if (FGameCodes == null)
            {
                FGameCodes = new List <GameGenieCode>();
            }

            FGameCodes.Add(ACode);
        }