Beispiel #1
0
 private static void GraphicPack_NewGraphicPack(object sender, GraphicPack pack)
 {
     if (!GraphicPacks.Contains(pack))
     {
         GraphicPacks.Add(pack);
     }
 }
Beispiel #2
0
        private static void Process(ZipArchiveEntry entry)
        {
            try {
                var entries = entry.Archive.Entries;
                var files   = entries.Where(x => Match(x, entry)).ToList();

                var rules   = files.Find(x => x.Name.ToLower() == "rules.txt")?.GetString();
                var sources = files.Where(x => x.Name.ToLower().Contains("source.txt")).ToList();

                if (string.IsNullOrEmpty(rules))
                {
                    return;
                }

                var parser = new IniDataParser
                {
                    Configuration =
                    {
                        SkipInvalidLines       = true,
                        AllowDuplicateKeys     = true,
                        AllowDuplicateSections = true
                    }
                };
                var data = parser.Parse(rules);

                if (data["Definition"]?["titleIds"] == null || data["Definition"]?["name"] == null)
                {
                    return;
                }

                var value = data["Definition"]?["titleIds"]?.ToUpper();
                if (string.IsNullOrEmpty(value))
                {
                    return;
                }

                var titleIds = value.Split(',');
                var name     = data["Definition"]?["name"].Replace("\"", "").Trim();

                var pack = new GraphicPack {
                    Name = name, Rules = rules
                };
                pack.TitleIds.AddRange(titleIds);
                foreach (var source in sources)
                {
                    var graphicPackSource = new GraphicPackSource {
                        FileName = source.Name, Data = source.GetBytes()
                    };
                    pack.Sources.Add(graphicPackSource);
                }

                NewGraphicPack?.Invoke(null, pack);
            }
            catch (Exception e) {
                TextLog.MesgLog.WriteLog($"{e.Message}\n{e.StackTrace}");
                //MessageBox.Show($@"{e.Message}\n{e.StackTrace}");
            }
        }