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; }
public static LevelData readFromFile(byte[] romdata, int no) { LevelData res = new LevelData(); res.objId = romdata[LevelRecBaseOffset + 60 + no]; res.backId = romdata[LevelRecBaseOffset + 75 + no]; res.palId = romdata[LevelRecBaseOffset + 90 + no]; res.palId2 = romdata[LevelRecBaseOffset + 120 + no]; res.palBlink = romdata[LevelRecBaseOffset + 135 + no]; res.width = romdata[LevelRecBaseOffset + 45 + no]; res.height = romdata[LevelRecBaseOffset + 30 + no]; res.startLoc = romdata[LevelRecBaseOffset + 15 + no]; byte layoutByte1 = romdata[LevelRecBaseOffset + 150 + no]; byte layoutByte2 = romdata[LevelRecBaseOffset + 165 + no]; byte scrollByte1 = romdata[LevelRecBaseOffset + 180 + no]; byte scrollByte2 = romdata[LevelRecBaseOffset + 195 + no]; res.bigBlockId = romdata[LevelRecBaseOffset + 0 + no]; res.musicNo = romdata[LevelRecBaseOffset + 105 + no]; byte dirsByte1 = romdata[LevelRecDirOffset + 0 + no]; byte dirsByte2 = romdata[LevelRecDirOffset + 15 + no]; res.scrollAddr = makeAddrPtr(scrollByte2, scrollByte1); res.layoutAddr = makeAddrPtr(layoutByte2, layoutByte1); res.dirsAddr = makeAddrPtr(dirsByte2, dirsByte1); return res; }
private void loadLevelData() { LevelData.LoadOffsetsFromConfig(); DoorData.LoadOffsetsFromConfig(); GlobalsCad.reloadLevelParamsData(); }