コード例 #1
0
        private void OpenFiles()
        {
            Bitmap atlas = null;
            KBuild build = null;
            KAnim  anim  = null;

            if (currentAtlasFile != null)
            {
                using (FileStream fs = new FileStream(currentAtlasFile, FileMode.Open))
                {
                    Bitmap bmp = new Bitmap(fs);
                    atlas = (Bitmap)bmp.Clone();
                }
            }

            if (currentBuildFile != null)
            {
                build = KAnimUtils.ReadBuild(currentBuildFile);
            }

            if (currentAnimFile != null)
            {
                anim = KAnimUtils.ReadAnim(currentAnimFile);
            }

            OpenData(atlas, build, anim);
        }
コード例 #2
0
        private void saveBlankAnimbytesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (KAnimUtils.WriteAnim(dlg.FileName, KAnimUtils.CreateEmptyAnim()))
                {
                    MessageBox.Show(this, "Blank anim file saved successfully.", "Save Success", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show(this, "Failed to save blank anim file.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
        public IWizardPage Next()
        {
            string buildingName   = textBoxName.Text;
            int    buildingWidth  = (int)numericUpDownWidth.Value;
            int    buildingHeight = (int)numericUpDownHeight.Value;
            string outDir         = textBoxOutputPath.Text;

            if (string.IsNullOrWhiteSpace(buildingName))
            {
                throw new Exception("Building name must not be empty.");
            }
            if (buildingWidth < 1)
            {
                throw new Exception("Building width must not be less than 1.");
            }
            if (buildingHeight < 1)
            {
                throw new Exception("Building height must not be less than 1.");
            }
            if (string.IsNullOrWhiteSpace(outDir) || !Directory.Exists(outDir))
            {
                throw new Exception("Output directory is not valid.");
            }

            string texFile   = Path.Combine(outDir, $"{buildingName}_0.png");
            string buildFile = Path.Combine(outDir, $"{buildingName}_build.bytes");
            string animFile  = Path.Combine(outDir, $"{buildingName}_anim.bytes");

            try
            {
                AnimFactory.MakePlaceholderBuilding(buildingName, buildingWidth, buildingHeight, out Bitmap tex, out KBuild build, out KAnim anim);
                tex.Save(texFile, ImageFormat.Png);
                KAnimUtils.WriteBuild(buildFile, build);
                KAnimUtils.WriteAnim(animFile, anim);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to generate building data.", ex);
            }

            return(null);
        }
コード例 #4
0
        private void saveBuildFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (data.Build.NeedsRepack)
            {
                MessageBox.Show("The texture atlas needs to be rebuilt first.");
                // Repack
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (KAnimUtils.WriteBuild(dlg.FileName, data.Build))
                {
                    MessageBox.Show(this, "Build file saved successfully.", "Save Success", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show(this, "Failed to save build file.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #5
0
        public IWizardPage Next()
        {
            string name   = textBoxName.Text;
            string inDir  = textBoxInput.Text;
            string outDir = textBoxOutput.Text;

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new Exception("Name must not be empty.");
            }
            if (string.IsNullOrWhiteSpace(inDir) || !Directory.Exists(inDir))
            {
                throw new Exception("Input path is invalid.");
            }
            if (string.IsNullOrWhiteSpace(outDir) || !Directory.Exists(outDir))
            {
                throw new Exception("Output path is invalid.");
            }

            string texFile   = Path.Combine(outDir, $"{name}_0.png");
            string buildFile = Path.Combine(outDir, $"{name}_build.bytes");
            string animFile  = Path.Combine(outDir, $"{name}_anim.bytes");

            try
            {
                AnimFactory.MakeSpritePack(name, inDir, out Bitmap tex, out KBuild build, out KAnim anim);
                tex.Save(texFile, ImageFormat.Png);
                KAnimUtils.WriteBuild(buildFile, build);
                KAnimUtils.WriteAnim(animFile, anim);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to pack sprites.", ex);
            }

            return(null);
        }