private void textBoxColorHTML_Validated(object sender, EventArgs e) { _ignoreHTMLBoxClick = false; String text = textBoxColorHTML.Text.Trim().ToUpperInvariant(); if (text.Length == 7 && text.Substring(0, 1) == "#") { // ignore the leading char '#' text = text.Substring(1); } if (text.Length == 6) { try { decimal red = Int32.Parse(text.Substring(0, 2), NumberStyles.AllowHexSpecifier); decimal green = Int32.Parse(text.Substring(2, 2), NumberStyles.AllowHexSpecifier); decimal blue = Int32.Parse(text.Substring(4, 2), NumberStyles.AllowHexSpecifier); _ignoreNumericUpDownEvent = true; numericUpDownTintRed.Value = red; numericUpDownTintGreen.Value = green; numericUpDownTintBlue.Value = blue; _ignoreNumericUpDownEvent = false; ApplyUpDownColors(); } catch { } } textBoxColorHTML.Text = SpriteEditor.GetHTMLFromColor(this.AnimatedSprite.Tint); }
private void AnimatedSpriteEditor_Load(object sender, EventArgs e) { this.ZoomBox = new ZoomBox(); this.ZoomBox.SetToolStripButtomZoomIn(toolStripButtonZoomIn); this.ZoomBox.SetToolStripButtomZoomOut(toolStripButtonZoomOut); this.ZoomBox.SetToolStripButtomZoomNormal(toolStripButtonZoomNormal); this.ZoomBox.Camera.Pivot = new Vector2(0.5f); this.ZoomBox.Camera.IsPivotRelative = true; if (this.AnimatedSprite.Material != null) { labelTextureName.Text = this.AnimatedSprite.Material.ToString(); } // hack around designer bug that resize the control labelTextureName.Size = new Size(labelTextureName.Size.Width, 22); // load all the Blending Type values in the combo box for (int i = 0; i < (int)DrawingBlendingType.EnumSize; i++) { comboBoxBlendingType.Items.Add(((DrawingBlendingType)i).ToString()); } comboBoxBlendingType.SelectedIndex = (int)this.AnimatedSprite.BlendingType; pictureBoxTint.BackColor = MilkshakeForm.GetGDIColor(this.AnimatedSprite.Tint); _ignoreNumericUpDownEvent = true; numericUpDownTintRed.Value = this.AnimatedSprite.Tint.R; numericUpDownTintGreen.Value = this.AnimatedSprite.Tint.G; numericUpDownTintBlue.Value = this.AnimatedSprite.Tint.B; textBoxColorHTML.Text = SpriteEditor.GetHTMLFromColor(this.AnimatedSprite.Tint); _ignoreNumericUpDownEvent = false; sceneItemPreviewControl.SceneItem = this.AnimatedSprite; sceneItemPreviewControl.Camera = this.ZoomBox.Camera; RefreshAreaComboList(); LoadAnimationsList(); }
public ToolBar() { InitializeComponent(); ToolBarViewModel.GetInstance().UI = this; Border selectedToolButton = null; viewModel = ToolBarViewModel.GetInstance(); viewModel.AddButton(eraserButton, SpriteEditor.Tools.Eraser); viewModel.AddButton(pencilButton, SpriteEditor.Tools.Pencil); viewModel.AddButton(editButton, SpriteEditor.Tools.Edit); viewModel.AddButton(zoomButton, SpriteEditor.Tools.Zoom); viewModel.AddButton(colorPickerButton, SpriteEditor.Tools.ColorPicker); viewModel.EditButton = (EditButton)editButton.Child; switch (SpriteEditor.GetInstance().SelectedToolType) { case SpriteEditor.Tools.Eraser: selectedToolButton = eraserButton; break; case SpriteEditor.Tools.Pencil: selectedToolButton = pencilButton; break; case SpriteEditor.Tools.Edit: selectedToolButton = editButton; break; case SpriteEditor.Tools.Zoom: selectedToolButton = zoomButton; break; } viewModel.SelectTool(selectedToolButton); }
public UndoSpritesetExchangeLayer(SpriteEditor Editor, SpriteProject Project, int LayerIndex1, int LayerIndex2) { this.Editor = Editor; this.Project = Project; this.LayerIndex1 = LayerIndex1; this.LayerIndex2 = LayerIndex2; }
public UndoSpritesetRemoveLayer(SpriteEditor Editor, SpriteProject Project, int LayerIndex) { this.Editor = Editor; this.Project = Project; RemovedLayer = Project.SpriteLayers[LayerIndex]; this.LayerIndex = LayerIndex; }
public override bool HandleImport(SpriteProject Project, SpriteEditor Editor) { string filename; if (!Editor.OpenFile("Import Sprites from Image", RetroDevStudio.Types.Constants.FILEFILTER_IMAGE_FILES, out filename)) { return(false); } GR.Image.FastImage spriteImage; var mcSettings = new ColorSettings(Project.Colors); var importType = Types.GraphicType.SPRITES; if (Project.Mode == SpriteProject.SpriteProjectMode.MEGA65_16_X_21_16_COLORS) { importType = GraphicType.SPRITES_16_COLORS; } bool pasteAsBlock = false; if (!Core.MainForm.ImportImage(filename, null, importType, mcSettings, out spriteImage, out mcSettings, out pasteAsBlock)) { return(false); } Project.Colors.BackgroundColor = mcSettings.BackgroundColor; Project.Colors.MultiColor1 = mcSettings.MultiColor1; Project.Colors.MultiColor2 = mcSettings.MultiColor2; if (mcSettings.Palettes.Count > Project.Colors.Palettes.Count) { // a palette was imported! Project.Colors.Palettes.Add(mcSettings.Palettes[mcSettings.Palettes.Count - 1]); } Editor.ChangeColorSettingsDialog(); int currentSpriteIndex = 0; int curX = 0; int curY = 0; while (curY + Editor.m_SpriteHeight <= spriteImage.Height) { //DocumentInfo.UndoManager.AddUndoTask( new Undo.UndoSpritesetSpriteChange( this, Project, currentSpriteIndex ), firstUndoStep ); Editor.ImportSprite(spriteImage.GetImage(curX, curY, Editor.m_SpriteWidth, Editor.m_SpriteHeight) as GR.Image.FastImage, currentSpriteIndex); Editor.SpriteChanged(currentSpriteIndex); ++currentSpriteIndex; curX += Editor.m_SpriteWidth; if (curX >= spriteImage.Width) { curX = 0; curY += Editor.m_SpriteHeight; } } return(true); }
public UndoSpritesetValuesChange(SpriteEditor Editor, SpriteProject Project) { this.Editor = Editor; this.Project = Project; Mode = Project.Mode; Colors = new ColorSettings(Project.Colors); }
public void UpdateToScale() { double scale = SpriteEditor.GetInstance().Scale; base.Width = Width * scale; base.Height = Height * scale; base.Margin = new Thickness(Position.X * scale, Position.Y * scale, 0, 0); }
private void newSpriteBt_Click(object sender, EventArgs e) { SpriteEditor childForm = new SpriteEditor(); childForm.MdiParent = this; childForm.Text = "Sprite"; childForm.Show(); }
public MainWindow() { SpriteEditor = new SpriteEditor(); ColorPicker = new ColorPicker(); Filename = ""; InitializeComponent(); CreateUndoBuffers(); }
public UndoSpritesetValuesChange(SpriteEditor Editor, SpriteProject Project) { this.Editor = Editor; this.Project = Project; BGColor = Project.BackgroundColor; MultiColor1 = Project.MultiColor1; MultiColor2 = Project.MultiColor2; }
public void Initialize(SpriteSetFromImageEditorVM vm) { this.vm = vm ?? throw new InvalidOperationException(nameof(vm)); SpriteEditor.Initialize(this.vm.SpriteEditor); BindControls(); BindEvents(); }
public override bool HandleImport(SpriteProject Project, SpriteEditor Editor) { string filename; if (!Editor.OpenFile("Open sprite file", Types.Constants.FILEFILTER_SPRITE + Types.Constants.FILEFILTER_SPRITE_SPRITEPAD + Types.Constants.FILEFILTER_ALL, out filename)) { return(false); } return(Editor.ImportSprites(filename, true, true)); }
public UndoSpritesetSpriteChange(SpriteEditor Editor, SpriteProject Project, int SpriteIndex) { this.Editor = Editor; this.Project = Project; this.SpriteIndex = SpriteIndex; ActivePalette = Project.Sprites[SpriteIndex].Tile.Colors.ActivePalette; Sprite = new SpriteProject.SpriteData(Project.Sprites[SpriteIndex]); }
public void ChangeTilesImage(List <Tile> tiles, Lvl lvl) { var newSprites = SpriteEditor.CutTheSprite(lvl.texture2D, lvl.numberOfColumnsAndRows); foreach (var tile in tiles) { var position = ((TileFor15)tile).trueCell.positionInOddrCoordinates; var number = cellGrid.OddrCoordinatesInIndex(new Vector3Int(position.x, position.y, position.z)); tile.GetComponent <Image>().sprite = newSprites[number]; } }
public UndoSpritesetSpriteChange(SpriteEditor Editor, SpriteProject Project, int SpriteIndex) { this.Editor = Editor; this.Project = Project; this.SpriteIndex = SpriteIndex; Sprite = new SpriteProject.SpriteData(); Sprite.Color = Project.Sprites[SpriteIndex].Color; Sprite.Data = new GR.Memory.ByteBuffer(Project.Sprites[SpriteIndex].Data); Sprite.Multicolor = Project.Sprites[SpriteIndex].Multicolor; }
public override bool HandleImport(SpriteProject CharSet, SpriteEditor Editor) { var data = Util.FromASMData(editInput.Text); if (data == null) { return(false); } Editor.ImportFromData(data); return(true); }
private void ApplyUpDownColors() { if (_ignoreNumericUpDownEvent == false) { Color color = Color.FromArgb((int)numericUpDownTintRed.Value, (int)numericUpDownTintGreen.Value, (int)numericUpDownTintBlue.Value); pictureBoxTint.BackColor = color; this.AnimatedSprite.Tint = new XnaColor(color.R, color.G, color.B, this.AnimatedSprite.Tint.A); textBoxColorHTML.Text = SpriteEditor.GetHTMLFromColor(this.AnimatedSprite.Tint); } }
public override bool HandleImport(SpriteProject CharSet, SpriteEditor Editor) { string binaryText = editInput.Text.Replace(" ", "").Replace("\r", "").Replace("\n", ""); GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(binaryText); if (data == null) { return(false); } Editor.ImportFromData(data); return(true); }
private void toolStripButton3_Click(object sender, EventArgs e) { //Add new Sprite BTN if (spriteEditor == null) { spriteEditor = new SpriteEditor(this); spriteEditor.Show(); } spriteEditor.Visible = true; spriteEditor.Play(); spriteEditor.setTask(1, null); }
private void Editing_Sprite_Click(object sender, EventArgs e) { if (selectedSpriteID != -1) { if (spriteEditor == null) { spriteEditor = new SpriteEditor(this); spriteEditor.Show(); } spriteEditor.Visible = true; spriteEditor.Play(); spriteEditor.setTask(2, (Sprite)selectedSprite.Clone()); } }
public override bool HandleImport(SpriteProject Project, SpriteEditor Editor) { ByteBuffer data; if (checkHexData.Checked) { data = Util.FromBASICHex(editInput.Text); } else { data = Util.FromBASIC(editInput.Text); } Editor.ImportFromData(data); return(true); }
private IScreenThing GetScreenThing(int x, int y) { if (SpriteEditor.HitTest(x, y)) { return(SpriteEditor); } for (var i = 0; i < SpriteArray.Length; i++) { if (Sprites[i].HitTest(x, y)) { return(Sprites[i]); } } return(null); }
public ImageView() { InitializeComponent(); editor = SpriteEditor.GetInstance(); cursorCanvas.MouseDown += CanvasMouseDown; cursorCanvas.MouseUp += CanvasMouseUp; cursorCanvas.MouseMove += CanvasMousMove; imageViewPort.ScrollChanged += ScrollToWholeNumer; root.DataContext = this; editor.Content = content; editor.ImageDisplay = image; editor.CursorImage = customCursor; editor.SpriteCollection = spritesCollection; editor.ImageViewPort = imageViewPort; editor.CursorContainer = cursorCanvas; }
private void exportPNGToolStripMenuItem_Click(object sender, EventArgs e) { using var x = new ExportPngDialog(); x.Multicolor = CurrentSprite.Multicolor; if (x.ShowDialog(this) != DialogResult.OK) { return; } using var y = new SaveFileDialog(); y.Title = @"Export PNG"; y.Filter = @"PNG files (*.png)|*.png|All files (*.*)|*.*"; if (y.ShowDialog(this) != DialogResult.OK) { return; } try { if (CurrentSprite.Multicolor) { if (x.DoubleWidth) { SpriteEditor.SavePngMultiColorDoubleWidth(y.FileName, Sprites, x.TransparentBackground); } else { SpriteEditor.SavePngMultiColor(y.FileName, Sprites, x.TransparentBackground); } } else { SpriteEditor.SavePng(y.FileName, Sprites, x.TransparentBackground); } } catch (Exception ex) { MessageDisplayer.Fail(ex.Message, @"Export failed"); } }
private void multicolorToolStripMenuItem_Click(object sender, EventArgs e) { var cursorX = SpriteEditor.GetCursorX(); multicolorToolStripMenuItem.Checked = !multicolorToolStripMenuItem.Checked; CurrentSprite.Multicolor = multicolorToolStripMenuItem.Checked; if (!multicolorToolStripMenuItem.Checked && ColorPicker.SelectedColor > 1) { ColorPicker.SelectedColor = 1; } if (CurrentSprite.Multicolor && cursorX % 2 != 0) { cursorX -= 1; SpriteEditor.SetCursorX(cursorX); } SpriteEditor.SetCursorX(cursorX); ResetPixels(); }
public static void Paint(Graphics g, bool redrawBackground, Color backColor, int windowWidth, int windowHeight, int extraOffsetY, SpriteEditor spriteEditor, SpriteArray sprites, C64Sprite sprite, ColorPicker colorPicker) { g.CompositingMode = CompositingMode.SourceOver; g.CompositingQuality = CompositingQuality.AssumeLinear; g.SmoothingMode = SmoothingMode.None; g.InterpolationMode = InterpolationMode.NearestNeighbor; g.PixelOffsetMode = PixelOffsetMode.HighSpeed; if (redrawBackground) { g.Clear(backColor); } spriteEditor.X = 10; spriteEditor.Y = 10 + ColorPickerCell.Size + extraOffsetY; var pw = (windowWidth - 200) / C64Sprite.Width; var ph = (windowHeight - 200) / C64Sprite.Height; spriteEditor.PixelSize = Math.Min(pw, ph); spriteEditor.PixelSize = spriteEditor.PixelSize < 6 ? 6 : spriteEditor.PixelSize; var doubleSize = windowWidth * 1.5 > windowHeight; var spritesStartX = doubleSize ? windowWidth - 68 : windowWidth - 44; var spritesStartY = spriteEditor.Y; for (var i = 0; i < SpriteArray.Length; i++) { sprites[i].Draw(g, spritesStartX, spritesStartY, doubleSize); spritesStartY += doubleSize ? 44 : 22; } spriteEditor.Draw(g); ColorPickerCell.Size = spriteEditor.PixelSize * 2; colorPicker.Draw( g, sprite, spriteEditor.X, spriteEditor.Y - (ColorPickerCell.Size + 8) ); }
private void SliceMouseDown(object sender, MouseButtonEventArgs e) { SpriteEditor.GetInstance().AutoSliceSprite(); ((ButtonBase)sender).IsMouseDown = false; }
private void ExportMouseDown(object sender, MouseButtonEventArgs e) { SpriteEditor.GetInstance().Export(); ((ButtonBase)sender).IsMouseDown = false; }
private void OpenMouseDown(object sender, MouseButtonEventArgs e) { SpriteEditor.GetInstance().LoadImage(); ((ButtonBase)sender).IsMouseDown = false; }