Ejemplo n.º 1
0
        public Mir3Library Convert()
        {
            string shadowPath = _fileName.Replace(".wtl", "_S.wtl");

            WTLLibrary shadowLibrary = null;

            if (File.Exists(shadowPath))
            {
                shadowLibrary = new WTLLibrary(shadowPath);
            }

            Mir3Library lib = new Mir3Library
            {
                Images = new Mir3Image[Images.Length]
            };

            for (int i = 0; i < Images.Length; i++)
            {
                MImage image = Images[i];
                if (image?.Texture == null)
                {
                    continue;
                }

                lib.Images[i] = image.Convert(shadowLibrary, i);
            }

            shadowLibrary?.Dispose();

            return(lib);
        }
Ejemplo n.º 2
0
        private async void ConvertLibrariesButton_Click(object sender, EventArgs e)
        {
            DirectoryInfo directory = new DirectoryInfo((string)folderTextBox.Text);

            if (!directory.Exists)
            {
                return;
            }

            FileInfo[] targets = directory.GetFiles("*.WTL", SubFoldersCheckEdit.Checked ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);

            TotleCount    = targets.Length;
            ProgressCount = 0;

            if (targets.Length == 0)
            {
                return;
            }

            Task task = Task.Run(() =>
            {
                ParallelOptions po = new ParallelOptions {
                    MaxDegreeOfParallelism = 10
                };
                Parallel.For(0, targets.Length, po, i =>
                {
                    if (!targets[i].FullName.EndsWith("_S.wtl"))
                    {
                        using (WTLLibrary wtl = new WTLLibrary(targets[i].FullName))
                        {
                            Mir3Library library = wtl.Convert();

                            library.Save(Path.ChangeExtension(targets[i].FullName, @".Zl"));
                        }
                    }
                    Interlocked.Increment(ref ProgressCount);
                });
            });

            while (!task.IsCompleted)
            {
                UpdateProgress();

                await Task.Delay(100);
            }

            ProgressLabel.Text = "Compeleted.";
        }
Ejemplo n.º 3
0
        public Mir3Image Convert(WTLLibrary shadowLibrary, int index)
        {
            Mir3Image image = new Mir3Image
            {
                Width         = TWidth,
                Height        = THeight,
                OffSetX       = TOffSetX,
                OffSetY       = TOffSetY,
                ShadowType    = TShadow,
                Data          = GetBytes(Texture),
                ShadowOffSetX = TShadowX,
                ShadowOffSetY = TShadowY
            };

            if (shadowLibrary != null && shadowLibrary.HasImage(index))
            {
                MImage sImage = shadowLibrary.Images[index];

                image.ShadowWidth   = sImage.TWidth;
                image.ShadowHeight  = sImage.THeight;
                image.ShadowOffSetX = sImage.TOffSetX;
                image.ShadowOffSetY = sImage.TOffSetY;
                image.ShadowData    = GetBytes(sImage.Texture);
            }

            if (Overlay != null)
            {
                image.OverlayWidth  = OWidth;
                image.OverlayHeight = OHeight;


                image.OverLayData = GetBytes(Overlay);
            }

            return(image);
        }