예제 #1
0
        private void cbLevel_SelectedIndexChanged(object sender, EventArgs e)
        {
            selectedIndex = -1;
            pnScreens.Controls.Clear();
            int levelNo = cbLevel.SelectedIndex;

            if (levelNo == -1)
            {
                return;
            }
            LevelData ld = GlobalsCad.levelData[levelNo];
            int       h  = ld.getHeight();
            int       w  = ld.getWidth();

            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < h; j++)
                {
                    var b = new Button();
                    b.Size     = new Size(28, 20);
                    b.Location = new Point(i * 29, j * 21);
                    int coord = j * w + i;
                    b.Text   = String.Format("{0:X}", coord);
                    b.Tag    = coord;
                    b.Click += new EventHandler(b_Click);
                    pnScreens.Controls.Add(b);
                }
            }
        }
예제 #2
0
        private void cbLevel_SelectedIndexChanged(object sender, EventArgs e)
        {
            //TODO: refactor this block to separate method
            if (dirty)
            {
                DialogResult dr = MessageBox.Show("Level was changed. Do you want to save current level?", "Save", MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Cancel)
                {
                    returnCbLevelIndex();
                    return;
                }
                else if (dr == DialogResult.Yes)
                {
                    if (!saveToFile())
                    {
                        returnCbLevelIndex();
                        return;
                    }
                }
                else
                {
                    dirty = false;
                }
            }
            int no = cbLevel.SelectedIndex;

            curActiveLevel = no;
            if (no == -1)
            {
                return;
            }
            bool isLevel = no < GlobalsCad.LEVELS_COUNT;

            if (isLevel)
            {
                LevelData ld = GlobalsCad.levelData[no];
                cbBackGfx.SelectedIndex      = id89toIndex(ld.backId);
                cbObjGfx.SelectedIndex       = id89toIndex(ld.objId);
                cbPalleteNo.SelectedIndex    = ld.palId;
                cbPallete2No.SelectedIndex   = ld.palId2;
                cbPalBlinkByte.SelectedIndex = ld.palBlink;

                cbStartLoc.SelectedIndex     = ld.startLoc;
                cbLayoutWidth.SelectedIndex  = ld.getWidth() - 1;
                cbLayoutHeight.SelectedIndex = ld.getHeight() - 1;
                cbLayoutAddr.Text            = String.Format("{0:X}", ld.layoutAddr);
                cbScrollAddr.Text            = String.Format("{0:X}", ld.scrollAddr);
                cbDirsAddr.Text      = String.Format("{0:X}", ld.dirsAddr);
                lbLayoutAddress.Text = String.Format("{0:X}", ld.getActualLayoutAddr());
                lbScrollAddr.Text    = String.Format("{0:X}", ld.getActualScrollAddr());
                lbDirsAddr.Text      = String.Format("{0:X}", ld.getActualDirsAddr());

                cbBigBlocks.SelectedIndex = ld.bigBlockId;
                cbMusicNo.SelectedIndex   = ld.musicNo;

                cbScrX.Enabled         = false;
                cbScrY.Enabled         = false;
                cbPlayerX.Enabled      = false;
                cbPlayerY.Enabled      = false;
                cbLayoutWidth.Enabled  = true;
                cbLayoutHeight.Enabled = true;
                //cbScrollAddr.Enabled = true;
                //cbLayoutAddr.Enabled = true;
                //cbDirsAddr.Enabled = true;
                cbBigBlocks.Enabled = true;
                cbMusicNo.Enabled   = true;
            }
            else
            {
                no -= GlobalsCad.LEVELS_COUNT;
                DoorData ld = GlobalsCad.doorsData[no];
                cbBackGfx.SelectedIndex      = id89toIndex(ld.backId);
                cbObjGfx.SelectedIndex       = id89toIndex(ld.objId);
                cbPalleteNo.SelectedIndex    = ld.palId;
                cbPallete2No.SelectedIndex   = ld.palId2;
                cbPalBlinkByte.SelectedIndex = ld.palBlink;

                cbStartLoc.SelectedIndex = ld.startLoc;
                cbScrX.SelectedIndex     = ld.scrX;
                cbScrY.SelectedIndex     = ld.scrY;
                cbPlayerX.SelectedIndex  = ld.playerX;
                cbPlayerY.SelectedIndex  = ld.playerY;

                cbScrX.Enabled         = true;
                cbScrY.Enabled         = true;
                cbPlayerX.Enabled      = true;
                cbPlayerY.Enabled      = true;
                cbLayoutWidth.Enabled  = false;
                cbLayoutHeight.Enabled = false;
                //cbScrollAddr.Enabled = false;
                //cbLayoutAddr.Enabled = false;
                //cbDirsAddr.Enabled = false;
                cbBigBlocks.Enabled = false;
                cbMusicNo.Enabled   = false;
            }
            lbl1.Enabled = isLevel;
            lbl2.Enabled = isLevel;
            lbl3.Enabled = isLevel;
            lbl4.Enabled = isLevel;
            lbl5.Enabled = isLevel;
            lbl6.Enabled = isLevel;
            lbl7.Enabled = isLevel;
            lbd1.Enabled = !isLevel;
            lbd2.Enabled = !isLevel;
            lbd3.Enabled = !isLevel;
            lbd4.Enabled = !isLevel;
            dirty        = false;
        }