Esempio n. 1
0
        /// <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();
        }
Esempio n. 2
0
        /// <summary>
        /// The background image list has changed.
        /// E.g., by having an image added or deleted.
        /// </summary>
        public void HandleBackgroundImageListChanged(BgImages bgis)
        {
            m_doc.HasUnsavedChanges = true;
            BgImageListForm win = bgis.BgImageListWindow;

            if (win != null)
            {
                win.RecalcScrollHeights();
                win.AdjustScrollbar();
            }
        }
Esempio n. 3
0
        public BgImageListForm(ProjectMainForm parent, BgImages bmis)
        {
            m_parent   = parent;
            m_bgimages = bmis;

            InitializeComponent();

            MdiParent       = parent;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
            StartPosition   = FormStartPosition.Manual;
            Visible         = false;
            ControlBox      = false;
            Text            = "Background Images";
        }
Esempio n. 4
0
 /// <summary>
 /// The current background image seletion has changed.
 /// </summary>
 public void HandleBackgroundImageSelectionChanged(BgImages bgis)
 {
     bgis.BgImageListWindow.BgImageSelectionChanged();
     bgis.BgImageWindow.BgImageSelectionChanged();
 }
Esempio n. 5
0
        private bool ExportFromTemplate(string strProjName, string strTemplateFilename, string strOutputFilename, bool fNDS)
        {
            try
            {
                string strExeDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                string strTemplateDir = String.Format("{0}{1}{2}{3}", strExeDir,
                                                      Path.DirectorySeparatorChar,
                                                      "templates",
                                                      Path.DirectorySeparatorChar);

                using (TextReader tr = new StreamReader(strTemplateDir + strTemplateFilename, Encoding.UTF8))
                {
                    using (TextWriter tw = new StreamWriter(strOutputFilename))
                    {
                        Spritesets sprites    = m_doc.Spritesets;
                        Spritesets bgsprites  = m_doc.BackgroundSpritesets;
                        Palettes   palettes   = m_doc.Palettes;
                        Palettes   bgpalettes = m_doc.BackgroundPalettes;
                        Maps       maps       = m_doc.BackgroundMaps;
                        BgImages   bgimages   = m_doc.BackgroundImages;

                        sprites.Export_AssignIDs();
                        bgsprites.Export_AssignIDs();
                        palettes.Export_AssignIDs();
                        bgpalettes.Export_AssignIDs();
                        maps.Export_AssignIDs();
                        bgimages.Export_AssignIDs();

                        string strLine;
                        while ((strLine = tr.ReadLine()) != null)
                        {
                            if (strLine.StartsWith("%%NDS:%%"))
                            {
                                if (fNDS)
                                {
                                    tw.WriteLine(strLine.Substring(8));
                                }
                                continue;
                            }
                            if (strLine.StartsWith("%%GBA:%%"))
                            {
                                if (!fNDS)
                                {
                                    tw.WriteLine(strLine.Substring(8));
                                }
                                continue;
                            }

                            if (strLine == "%%_SPRITE_PALETTE_INFO_%%")
                            {
                                palettes.Export_PaletteInfo(tw);
                                continue;
                            }
                            if (strLine == "%%_SPRITE_PALETTES_%%")
                            {
                                palettes.Export_Palettes(tw);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_PALETTE_INFO_%%")
                            {
                                bgpalettes.Export_PaletteInfo(tw);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_PALETTES_%%")
                            {
                                bgpalettes.Export_Palettes(tw);
                                continue;
                            }

                            if (strLine == "%%_SPRITESET_INFO_%%")
                            {
                                sprites.Export_SpritesetInfo(tw);
                                continue;
                            }
                            if (strLine == "%%_SPRITESET_IDS_%%")
                            {
                                sprites.Export_SpritesetIDs(tw);
                                continue;
                            }

                            if (strLine == "%%_SPRITE_INFO_%%")
                            {
                                sprites.Export_SpriteInfo(tw);
                                continue;
                            }
                            if (strLine == "%%_SPRITE_TILES_%%")
                            {
                                sprites.Export_TileData(tw);
                                continue;
                            }
                            if (strLine == "%%_SPRITE_MASKS_%%")
                            {
                                sprites.Export_SpriteMaskData(tw);
                                continue;
                            }
                            if (strLine == "%%_SPRITE_IDS_%%")
                            {
                                sprites.Export_SpriteIDs(tw);
                                continue;
                            }

                            if (strLine == "%%_BACKGROUND_TILESET_INFO_%%")
                            {
                                bgsprites.Export_BgTilesetInfo(tw);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_TILESET_IDS_%%")
                            {
                                bgsprites.Export_BgTilesetIDs(tw);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_TILES_%%")
                            {
                                bgsprites.Export_TileData(tw);
                                continue;
                            }

                            if (strLine == "%%_BACKGROUND_TILE_IDS_%%")
                            {
                                bgsprites.Export_TileIDs(tw);
                                continue;
                            }

                            if (strLine == "%%_BACKGROUND_MAP_INFO_%%")
                            {
                                maps.Export_MapInfo(tw);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_MAP_IDS_%%")
                            {
                                maps.Export_MapIDs(tw);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_MAP_DATA_%%")
                            {
                                maps.Export_MapData(tw);
                                continue;
                            }

                            if (strLine == "%%_BACKGROUND_IMAGE_INFO_%%")
                            {
                                bgimages.Export_BgImageInfo(tw, fNDS);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_IMAGE_IDS_%%")
                            {
                                bgimages.Export_BgImageIDs(tw);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_IMAGE_HEADERS_%%")
                            {
                                bgimages.Export_BgImageHeaders(tw, fNDS);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_IMAGE_PALETTEDATA_%%")
                            {
                                bgimages.Export_BgImagePaletteData(tw);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_IMAGE_DATA_PALETTED_%%")
                            {
                                bgimages.Export_BgImageData_Paletted(tw);
                                continue;
                            }
                            if (strLine == "%%_BACKGROUND_IMAGE_DATA_DIRECT_%%")
                            {
                                bgimages.Export_BgImageData_Direct(tw);
                                continue;
                            }

                            strLine = strLine.Replace("%%_NAME_%%", strProjName);
                            strLine = strLine.Replace("%%_VERSION_%%", ResourceMgr.GetString("Version"));
                            strLine = strLine.Replace("%%_PLATFORM_%%", fNDS ? "NDS" : "GBA");

                            strLine = strLine.Replace("%%_NUM_PALETTES_%%", palettes.NumPalettes.ToString());
                            strLine = strLine.Replace("%%_NUM_SPRITESETS_%%", sprites.NumSpritesets.ToString());
                            strLine = strLine.Replace("%%_NUM_SPRITES_%%", sprites.NumSprites.ToString());
                            strLine = strLine.Replace("%%_NUM_TILES_%%", sprites.NumTiles.ToString());

                            strLine = strLine.Replace("%%_NUM_BACKGROUND_PALETTES_%%", bgpalettes.NumPalettes.ToString());
                            strLine = strLine.Replace("%%_NUM_BACKGROUND_TILESETS_%%", bgsprites.NumSpritesets.ToString());
                            strLine = strLine.Replace("%%_NUM_BACKGROUND_TILES_%%", bgsprites.NumTiles.ToString());

                            strLine = strLine.Replace("%%_NUM_BACKGROUND_MAPS_%%", maps.NumMaps.ToString());

                            strLine = strLine.Replace("%%_NUM_BACKGROUND_IMAGES_%%", bgimages.NumImages.ToString());

                            tw.WriteLine(strLine);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // "An exception was thrown while load the project template files: {0}"
                m_doc.ErrorId("ExceptionLoadTemplate", ex.Message);
                // "An exception was thrown while opening the project file for writing: {0}"
                //m_doc.ErrorId("ExceptionOpenProjectWrite", ex.Message);
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
 /// <summary>
 /// The current background image seletion has changed.
 /// </summary>
 public void HandleBackgroundImageSelectionChanged(BgImages bgis)
 {
     bgis.BgImageListWindow.BgImageSelectionChanged();
     bgis.BgImageWindow.BgImageSelectionChanged();
 }
Esempio n. 7
0
 /// <summary>
 /// The background image list has changed.
 /// E.g., by having an image added or deleted.
 /// </summary>
 public void HandleBackgroundImageListChanged(BgImages bgis)
 {
     m_doc.HasUnsavedChanges = true;
     BgImageListForm win = bgis.BgImageListWindow;
     if (win != null)
     {
         win.RecalcScrollHeights();
         win.AdjustScrollbar();
     }
 }