private void SpriteSheetGenerator_Load(object sender, EventArgs e) { Array fileFormats = Enum.GetValues(typeof(ImageFileFormat)); foreach (object format in fileFormats) { comboBoxFileFormat.Items.Add(format.ToString()); } comboBoxFileFormat.SelectedItem = "Png"; MilkshakePreferences prefs = MilkshakeForm.Instance.Preferences; this.LastInputDir = ConvertStringToList(prefs.ToolSpritesheetLastInputFolder); this.LastOutputDir = ConvertStringToList(prefs.ToolSpritesheetLastOutputFolder); this.LastNames = ConvertStringToList(prefs.ToolSpritesheetLastOutputName); LoadCombobox(comboBoxInputDir, this.LastInputDir); LoadCombobox(comboBoxOutputDir, this.LastOutputDir); LoadCombobox(comboBoxName, this.LastNames); numericUpDownSafeBorderSize.Value = (decimal)prefs.ToolSpritesheetLastSafeBorderSize; checkBoxAlphaCorrection.Checked = prefs.ToolSpritesheetLastCorrectTransparencyColor; checkBoxOverrideBaseColor.Checked = prefs.ToolSpritesheetLastReplaceBaseColor; checkBoxPowerOf2.Checked = prefs.ToolSpritesheetLastPadTexturePowerOfTwo; XnaColor backColor = prefs.ToolSpritesheetLastBaseColor; this.BaseTextureColor = GdiColor.FromArgb(backColor.R, backColor.G, backColor.B); pictureBoxTint.BackColor = this.BaseTextureColor; CheckValidation(); }
public void StartSpriteSheetGeneration() { MilkshakePreferences prefs = MilkshakeForm.Instance.Preferences; CheckForNewEntry(comboBoxInputDir.Text, this.LastInputDir); CheckForNewEntry(comboBoxOutputDir.Text, this.LastOutputDir); CheckForNewEntry(comboBoxName.Text, this.LastNames); prefs.ToolSpritesheetLastInputFolder = ConvertListToString(this.LastInputDir); prefs.ToolSpritesheetLastOutputFolder = ConvertListToString(this.LastOutputDir); prefs.ToolSpritesheetLastOutputName = ConvertListToString(this.LastNames); prefs.ToolSpritesheetLastSafeBorderSize = (int)numericUpDownSafeBorderSize.Value; prefs.ToolSpritesheetLastCorrectTransparencyColor = checkBoxAlphaCorrection.Checked; prefs.ToolSpritesheetLastReplaceBaseColor = checkBoxOverrideBaseColor.Checked; prefs.ToolSpritesheetLastPadTexturePowerOfTwo = checkBoxPowerOf2.Checked; prefs.ToolSpritesheetLastBaseColor = new XnaColor(this.BaseTextureColor.R, this.BaseTextureColor.G, this.BaseTextureColor.B); this.Sprites.Clear(); String path = comboBoxInputDir.Text; DirectoryInfo di = new DirectoryInfo(path); FileInfo[] rgFiles = di.GetFiles("*.*"); foreach (FileInfo fi in rgFiles) { String fileExt = fi.Extension.ToLower(); if (fileExt == ".png" || fileExt == ".jpg" || fileExt == ".dds" || fileExt == ".bmp" || fileExt == ".tga") { Console.WriteLine(Sprites.Count + "] Packing sprite " + fi.Name); SpriteInfo newInfo = new SpriteInfo(Path.GetFileNameWithoutExtension(fi.Name)); newInfo.Texture2D = Texture2D.FromFile(IceCream.Drawing.DrawingManager.GraphicsDevice, fi.FullName); newInfo.PixelData = new uint[newInfo.Texture2D.Width * newInfo.Texture2D.Height]; newInfo.Texture2D.GetData <uint>(newInfo.PixelData); Sprites.Add(newInfo); } } PackSprites((int)numericUpDownSafeBorderSize.Value, comboBoxOutputDir.Text, comboBoxName.Text); }