/// <summary> /// Add a default sprite to the new document when Spritely is first launched. /// This is so that first-time users don't see an empty window - they can /// start editing their first sprite immediately. /// </summary> public void InitializeEmptyDocument() { // Palettes Palette16 pal = m_data.Palettes.AddPalette16(Options.DefaultPaletteName, 0, ""); pal.SetDefaultPalette(); // Spritesets Spriteset ss = m_data.Spritesets.AddSpriteset(Options.DefaultSpritesetName, Options.DefaultPaletteId, "", pal); // Add a single 2x2 sprite. ss.AddSprite(2, 2, "", -1, "", 0, null); ss.SelectFirstSprite(); // Background palettes Palette16 bgpal = m_data.BackgroundPalettes.AddPalette16(Options.DefaultBgPaletteName, 0, ""); bgpal.SetDefaultPalette(); // Background tiles (bgsprites and bgtilegroups) Spriteset bss = m_data.BackgroundSpritesets.AddSpriteset(Options.DefaultBgTilesetName, Options.DefaultBgPaletteId, "", bgpal); // Add a single blank background tile. bss.AddSprite(1, 1, "", -1, "", 0, null); bss.SelectFirstSprite(); // Background tile map m_data.BackgroundMaps.AddMap("map", 0, "", m_data.BackgroundSpritesets.Current); // The sprites we just added above don't count as document changes. HasUnsavedChanges = false; }
/// <summary> /// Copy the newly opened Document into the current document. /// </summary> /// <param name="doc">The newly opened document</param> private void Open_(Document doc) { // Copy data from newly loaded doc into this doc m_data = doc.m_data; // Update the document references to point to this document m_data.Palettes.UpdateDocument(this); m_data.Spritesets.UpdateDocument(this); m_data.BackgroundPalettes.UpdateDocument(this); m_data.BackgroundSpritesets.UpdateDocument(this); m_data.BackgroundMaps.UpdateDocument(this); m_data.Filer.UpdateDocument(this); Spriteset ss = m_data.Spritesets.Current; if (ss != null) { ss.SelectFirstSprite(); } Spriteset bss = m_data.BackgroundSpritesets.Current; if (bss != null) { bss.SelectFirstSprite(); } BgImages bgis = m_data.BackgroundImages; if (bgis != null) { bgis.SelectFirstImage(); } Owner.ClearUndo(); }
public override void ApplyUndo() { if (m_fAdd) { m_ss.RemoveSprite(m_sprite, null); m_ss.CurrentSprite = m_mgr.FindMostRecentSprite(); if (m_ss.CurrentSprite == null) { m_ss.SelectFirstSprite(); } } else { m_ss.AddSprite(m_sprite, null); m_ss.CurrentSprite = m_sprite; } }