Beispiel #1
0
        public DDOUISkinAsset AddAsset(string n, string p, string s)
        {
            if (AssetCache.ContainsKey(n))
            {
                return(null);
            }
            DDOUISkinAsset sa = new DDOUISkinAsset
            {
                AssetName   = n,
                AssetPath   = p,
                AssetSource = s
            };

            Assets.Add(sa);
            AssetCache[sa.AssetName] = sa;

            return(sa);
        }
Beispiel #2
0
        private void ProcessXDocs_DoWork(object sender, DoWorkEventArgs e)
        {
            ProcessErrors = new StringBuilder();
            BackgroundWorker bw = sender as BackgroundWorker;
            StatusBarUpdate  sbu;
            DDOUISkin        skin;

            for (int i = 0; i < XDocsToProcess.Count; i++)
            {
                skin = new DDOUISkin();
                XmlElement xe = XDocsToProcess[i].GetElementsByTagName("SkinName")[0] as XmlElement;
                skin.Name     = xe.GetAttribute("Name");
                skin.RootPath = Path.Combine(SkinsPath, skin.Name);
                try
                {
                    if (Directory.Exists(skin.RootPath))
                    {
                        if (!DeleteFolder(skin.RootPath))
                        {
                            ProcessErrors.AppendLine("Unable to delete existing skin directory " + skin.RootPath);
                            continue;
                        }
                    }
                    Directory.CreateDirectory(skin.RootPath);
                }
                catch (Exception ex)
                {
                    ProcessErrors.AppendLine(ex.Message);
                    continue;
                }
                sbu.MainString = "Processing " + skin.Name;
                var maps = XDocsToProcess[i].GetElementsByTagName("Mapping");
                sbu.ProgressBarMax = maps.Count;
                sbu.ProgressBarMin = 0;

                for (int m = 0; m < maps.Count; m++)
                {
                    sbu.SecondaryString  = (m + 1).ToString();
                    sbu.ProgressBarValue = m + 1;
                    bw.ReportProgress(m, sbu);

                    xe = maps[m] as XmlElement;
                    string         fn = xe.GetAttribute("FileName").Replace('/', '\\');
                    DDOUISkinAsset sa = skin.AddAsset(xe.GetAttribute("ArtAssetID"), Path.Combine(skin.RootPath, Path.GetFileName(fn)), skin.Name);
                    if (sa == null)
                    {
                        continue;
                    }
                    try
                    {
                        File.Copy(Path.Combine(XDocPaths[i], fn), sa.AssetPath, true);
                    }
                    catch (Exception ex)
                    {
                        ProcessErrors.AppendLine(ex.Message);
                        continue;
                    }
                    xe.SetAttribute("FileName", Path.GetFileName(sa.AssetPath));
                }

                try
                {
                    XDocsToProcess[i].Save(Path.Combine(skin.RootPath, "SkinDefinition.xml"));
                }
                catch (Exception ex)
                {
                    ProcessErrors.AppendLine(ex.Message);
                    continue;
                }

                Dispatcher.Invoke(new Action(() => ProcessNewSkin(skin)));
            }

            XDocPaths.Clear();
            XDocsToProcess.Clear();
        }