Пример #1
0
        private void cboFrame_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (loading)
            {
                return;
            }

            int index = cboSwirl.SelectedIndex;
            int frame = cboFrame.SelectedIndex;
            int pal   = cboPalette.SelectedIndex;
            var s     = GfxBattleSwirls.Sequences[index];

            txtFrameDuration.Text = s.Lengths[frame].ToString();

            // Arrangement stuff
            arrEditor.Clear();

            int[] gfxEntry = GfxBattleSwirls.GetEntry(s.GfxEntry);

            byte[] tileset = new byte[0x800];
            Array.Copy(M3Rom.Rom, gfxEntry[0], tileset, 0, gfxEntry[1]);
            arrEditor.SetTileset(tileset, 0, -1, gfxEntry[1] >> 5);
            arrEditor.SetArrangement(GfxBattleSwirls.GetArr(s.ArrStart + frame), 30, 20);
            arrEditor.SetPalette(GfxBattleSwirls.Palettes[pal]);

            arrEditor.RenderArr();
            arrEditor.RenderTileset();
            arrEditor.CurrentTile = 0;
            arrEditor.RefreshArr();
        }
Пример #2
0
        public frmBattleSwirlEditor()
        {
            InitializeComponent();

            // Init the swirl data
            GfxBattleSwirls.Init();

            // Populate the palette and swirl boxes
            loading = true;
            for (int i = 0; i < GfxBattleSwirls.SequenceEntries; i++)
            {
                cboSwirl.Items.Add(i.ToString());
                cboPalette.Items.Add(i.ToString());
            }
            cboPalette.SelectedIndex = 0;
            loading = false;
            cboSwirl.SelectedIndex = 0;
        }
Пример #3
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            int index = cboSwirl.SelectedIndex;
            int frame = cboFrame.SelectedIndex;
            int pal   = cboPalette.SelectedIndex;
            var s     = GfxBattleSwirls.Sequences[index];

            // Graphics entry
            try
            {
                s.GfxEntry = byte.Parse(txtGfxEntry.Text);
            }
            catch
            {
                txtGfxEntry.SelectAll();
                return;
            }

            // Arrangement start
            try
            {
                s.ArrStart = byte.Parse(txtArrStart.Text);
            }
            catch
            {
                txtArrStart.SelectAll();
                return;
            }

            // Arrangement length
            try
            {
                s.ArrLen = byte.Parse(txtArrLen.Text);
            }
            catch
            {
                txtArrLen.SelectAll();
                return;
            }

            // Frame duration
            try
            {
                s.Lengths[frame] = byte.Parse(txtFrameDuration.Text);
            }
            catch
            {
                txtFrameDuration.SelectAll();
                return;
            }

            if (index > 0)
            {
                // Arrangement
                GfxBattleSwirls.SetArr(s.ArrStart + frame, arrEditor.GetArrangement());

                // Graphics
                byte[] tileset  = arrEditor.GetTileset();
                int[]  gfxEntry = GfxBattleSwirls.GetEntry(s.GfxEntry);
                Array.Copy(tileset, 0, M3Rom.Rom, gfxEntry[0], gfxEntry[1]);

                // Palette
                var palette = arrEditor.GetPalette();
                M3Rom.Rom.WritePal(GfxBattleSwirls.GetEntry(0)[0] + (pal << 5), palette);
                GfxBattleSwirls.Palettes[pal] = palette;
            }

            s.Save();

            int currentpal   = arrEditor.CurrentPalette;
            int currenttile  = arrEditor.CurrentTile;
            int primarycol   = arrEditor.PrimaryColorIndex;
            int secondarycol = arrEditor.SecondaryColorIndex;

            cboFrame_SelectedIndexChanged(null, null);

            arrEditor.CurrentPalette      = currentpal;
            arrEditor.PrimaryColorIndex   = primarycol;
            arrEditor.SecondaryColorIndex = secondarycol;
            arrEditor.CurrentTile         = currenttile;
        }