private static void AddToXml(PatchStructure patch)
 {
     if (patch.From > 0)
     {
         Kernel.MyXml.AddNewNode("", patch.From.ToString(), "Patch", "Config", "BundlePatches");
         Kernel.MyXml.AddNewNode(patch.From.ToString(), null, "From", "Config", "BundlePatches", $"Patch[@id='{patch.From}']");
         Kernel.MyXml.AddNewNode(patch.To.ToString(), null, "To", "Config", "BundlePatches", $"Patch[@id='{patch.From}']");
         Kernel.MyXml.AddNewNode(patch.FileName, null, "FileName", "Config", "BundlePatches", $"Patch[@id='{patch.From}']");
     }
     else
     {
         Kernel.MyXml.AddNewNode(patch.FileName, patch.To.ToString(), "Patch", "Config", "AllowedPatches");
     }
 }
        public static void AddPatch(PatchStructure patch, bool isLoading)
        {
            if (patch.To < UPDATER_VERSION_MIN)
            {
                patch.IsGameUpdate = true;
            }

            bool added = false;

            if (m_patchLibrary.ContainsKey(patch.From))
            {
                if (m_patchLibrary[patch.From].To < patch.To)
                {
                    RemovePatch(patch.From, true);
                    m_patchLibrary.TryAdd(patch.From, patch);

                    if (!isLoading)
                    {
                        AddToXml(patch);
                        added = true;
                    }
                }
            }
            else
            {
                m_patchLibrary.TryAdd(patch.To, patch);

                if (!isLoading)
                {
                    AddToXml(patch);
                    added = true;
                }
            }

            if (added)
            {
                if (!patch.IsGameUpdate && patch.To > Kernel.LatestUpdaterPatch)
                {
                    Kernel.LatestUpdaterPatch = patch.To;
                    Kernel.MyXml.ChangeValue(patch.To.ToString(), "Config", "LatestUpdaterVersion");
                }
                else if (patch.IsGameUpdate && patch.To > Kernel.LatestGamePatch)
                {
                    Kernel.LatestGamePatch = patch.To;
                    Kernel.MyXml.ChangeValue(patch.To.ToString(), "Config", "LatestGameVersion");
                }
            }
        }
        //mxd. Constructor for hires patches
        public TexturePatch(PatchStructure patch)
        {
            // Initialize
            this.LumpName    = patch.Name.ToUpperInvariant();
            this.X           = patch.OffsetX;
            this.Y           = patch.OffsetY;
            this.FlipX       = patch.FlipX;
            this.FlipY       = patch.FlipY;
            this.Rotate      = patch.Rotation;
            this.BlendColor  = patch.BlendColor;
            this.Alpha       = patch.Alpha;
            this.RenderStyle = patch.RenderStyle;
            this.BlendStyle  = patch.BlendStyle;
            this.HasLongName = (Path.GetFileNameWithoutExtension(this.LumpName) != this.LumpName);
            this.Skip        = patch.Skip;

            //mxd. Check data so we don't perform unneeded operations later on
            if (this.Alpha == 1.0f)
            {
                switch (this.RenderStyle)
                {
                case TexturePathRenderStyle.BLEND:
                case TexturePathRenderStyle.COPY_ALPHA:
                case TexturePathRenderStyle.COPY_NEW_ALPHA:
                case TexturePathRenderStyle.OVERLAY:
                    this.RenderStyle = TexturePathRenderStyle.COPY;
                    break;
                }
            }

            //mxd. and get rid of render styles we don't support
            if (this.RenderStyle == TexturePathRenderStyle.OVERLAY)
            {
                this.RenderStyle = TexturePathRenderStyle.COPY;
            }
        }