コード例 #1
0
        void Core_Platform_InsertData(string filepath)
        {
            BattlePlatform platform;

            try
            {
                string path = Path.GetDirectoryName(filepath) + '\\';
                string file = Path.GetFileNameWithoutExtension(filepath);

                if (!File.Exists(path + file + ".chr"))
                {
                    throw new Exception("Could not find Tileset file:\n" + path + file + ".chr");
                }
                if (!File.Exists(path + file + ".pal"))
                {
                    throw new Exception("Could not find Palette file:\n" + path + file + ".pal");
                }

                byte[] tileset = File.ReadAllBytes(path + file + ".chr");
                byte[] palette = File.ReadAllBytes(path + file + ".pal");

                platform = new BattlePlatform(tileset, palette);
            }
            catch (Exception ex)
            {
                Program.ShowError("Could not load the image file.", ex);
                return;
            }
            Core_Insert(platform);
        }
コード例 #2
0
        void Core_Platform_InsertImage(string filepath)
        {
            BattlePlatform platform;

            try
            {
                platform = new BattlePlatform(new GBA.Image(filepath));
            }
            catch (Exception ex)
            {
                Program.ShowError("Could not load the image file.", ex);
                return;
            }
            Core_Insert(platform);
        }
コード例 #3
0
        void Core_LoadPlatform()
        {
            try
            {
                byte[] tileset = Core.ReadData((Pointer)Current["Tileset"], 0);
                byte[] palette = Core.ReadData((Pointer)Current["Palette"], Palette.LENGTH);

                CurrentPlatform = new BattlePlatform(tileset, palette);

                Platform_ImageBox.Load(CurrentPlatform);
                Platform_PaletteBox.Load(new Palette(palette));
            }
            catch (Exception ex)
            {
                Program.ShowError("Could not load the battle platform image.", ex);

                Platform_ImageBox.Reset();
                Platform_PaletteBox.Reset();
            }
        }
コード例 #4
0
        void Core_Insert(BattlePlatform insert)
        {
            Core.SuspendUpdate();
            try
            {
                byte[] data_tileset = insert.Sheet.ToBytes(true);
                byte[] data_palette = insert.Colors.ToBytes(false);

                bool cancel = Prompt.ShowRepointDialog(this, "Repoint Battle Platform",
                                                       "The battle platform to insert might need some of its parts to be repointed.",
                                                       CurrentEntry, new Tuple <string, Pointer, int>[] {
                    Tuple.Create("Tileset", (Pointer)Current["Tileset"], data_tileset.Length),
                    Tuple.Create("Palette", (Pointer)Current["Palette"], data_palette.Length),
                }, new Pointer[] {
                    Current.GetAddress(Current.EntryIndex, "Tileset"),
                    Current.GetAddress(Current.EntryIndex, "Palette"),
                });
                if (cancel)
                {
                    return;
                }

                Core.WriteData(this,
                               (Pointer)Current["Tileset"],
                               data_tileset,
                               CurrentEntry + "Tileset changed");

                Core.WriteData(this,
                               (Pointer)Current["Palette"],
                               data_palette,
                               CurrentEntry + "Palette changed");
            }
            catch (Exception ex)
            {
                Program.ShowError("Could not insert the image.", ex);
                Core_Update();
            }
            Core.ResumeUpdate();
            Core.PerformUpdate();
        }