Beispiel #1
0
        public bool CreateEmpty(Core.Version version, ClientFeatures features)
        {
            if (version == null)
            {
                throw new ArgumentNullException(nameof(version));
            }

            this.Things = ThingTypeStorage.Create(version, features);
            if (this.Things == null)
            {
                return(false);
            }

            this.Sprites = SpriteStorage.Create(version, features);
            if (this.Sprites == null)
            {
                return(false);
            }

            this.Things.ProgressChanged  += new ProgressHandler(this.StorageProgressChanged_Handler);
            this.Things.StorageChanged   += new ThingListChangedHandler(this.ThingListChanged_Handler);
            this.Things.StorageCompiled  += new StorageHandler(this.StorageCompiled_Handler);
            this.Things.StorageDisposed  += new StorageHandler(this.StorageDisposed_Handler);
            this.Sprites.StorageChanged  += new SpriteListChangedHandler(this.SpriteListChanged_Handler);
            this.Sprites.ProgressChanged += new ProgressHandler(this.StorageProgressChanged_Handler);
            this.Sprites.StorageCompiled += new StorageHandler(this.StorageCompiled_Handler);
            this.Sprites.StorageDisposed += new StorageHandler(this.StorageDisposed_Handler);

            if (this.Loaded && this.ClientLoaded != null)
            {
                this.ClientLoaded(this, new EventArgs());
            }

            return(this.Loaded);
        }
Beispiel #2
0
        public void LoadSprites()
        {
            LoadCatalogJson();
            catalog.Sort((x, y) => x.FirstSpriteid.CompareTo(y.FirstSpriteid));
            var options = new ParallelOptions()
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount * 5
            };

            if (ToSpr.Checked)
            {
                version  = new OpenTibia.Core.Version(1000, "Client 10.00", DatSignature, SprSignature, 0);
                Features = OpenTibia.Client.ClientFeatures.Extended;
                sprites  = SpriteStorage.Create(version, Features);
            }

            progress = 0;
            Directory.CreateDirectory(_dumpToPath + @"//slices//");
            Parallel.ForEach(catalog, options, (sheet, state) =>
            {
                progress++;
                if (sheet.Type == "sprite")
                {
                    DumpSpriteSheet(sheet);
                }

                worker.ReportProgress((int)(progress * 100 / catalog.Count));
            });

            if (ToSpr.Checked)
            {
                foreach (var tile in concurrentDictionary.OrderBy(tile => tile.Key))
                {
                    sprites.AddSprites(tile.Value);
                }

                sprites.Save(String.Format("{0}//Clients//Tibia.spr", _dumpToPath), version);
            }
        }