private void paintBack(Graphics g) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; int blockWidth = formMain.Layers[0].blockWidth; int blockHeight = formMain.Layers[0].blockHeight; int scrLevelNo = getLevelRecForGameType().levelNo; int width = ConfigScript.getScreenWidth(scrLevelNo); int height = ConfigScript.getScreenHeight(scrLevelNo); int scrWidth = (int)(width * blockWidth * curScale); int scrHeight = (int)(height * blockHeight * curScale); for (int x = 0; x < curLevelLayerData.width; x++) { for (int y = 0; y < curLevelLayerData.height; y++) { int noInLayout = y * curLevelLayerData.width + x; int scrNo = calcScrNo(noInLayout); if (scrNo < formMain.Layers[0].screens.Length && scrNo >= 0) { var visibleRect = UtilsGui.getVisibleRectangle(pnView, mapScreen); int leftMargin = scrWidth * x; int topMargin = scrHeight * y; MapEditor.Render(g, bigBlocks, visibleRect, formMain.Layers, scrNo, curScale, false, formMain.ShowAxis, leftMargin, topMargin, width, height); //ConfigScript.renderToMainScreen(g, (int)curScale); } else { //g.FillRectangle(Brushes.Black, new Rectangle(0, 0, 512, 512)); } } } }
private void SegaBlockEdit_FormClosing(object sender, FormClosingEventArgs e) { if (!UtilsGui.askToSave(ref dirty, saveFunc, null)) { e.Cancel = true; } }
private bool openFile() { if (!UtilsGui.askToSave(ref dirty, saveToFile, returnCbLevelIndex)) { updateSaveVisibility(); return(false); } updateSaveVisibility(); var f = new OpenFile(); if (f.ShowDialog() == DialogResult.OK) { if (!Globals.loadData(OpenFile.fileName, OpenFile.dumpName, OpenFile.configName)) { Close(); return(false); } setDefaultScale(); fileLoaded = true; resetControls(); setWindowText(); } if (!fileLoaded) { return(false); } return(true); }
private void mapScreen_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; if (curTileStruct == null) { g.Clear(Color.Black); return; } var visibleRect = UtilsGui.getVisibleRectangle(this, mapScreen); g.Clear(Color.Black); var blockLayer = new BlockLayer(curTileStruct.toArray()); blockLayer.showLayer = true; var screens = new[] { new Screen(blockLayer, curTileStruct.width, curTileStruct.height) }; MapEditor.render(g, screens, 0, new MapEditor.RenderParams { bigBlocks = bigBlocks, visibleRect = visibleRect, curScale = 2.0f, showBlocksAxis = formMain.showAxis, showBorder = false, width = curTileStruct.width, height = curTileStruct.height, additionalRenderEnabled = false, }); }
private void renderMapScreen(Graphics g, MapData mapData) { var visibleRect = UtilsGui.getVisibleRectangle(mapPanel, mapScreen); for (int i = 0; i < mapData.width * mapData.height; i++) { int x = i % mapData.width; int y = i / mapData.width; int colorByte = mapData.attrData[x / 4 + mapData.width / 4 * (y / 4)]; int subPal = (colorByte >> (x % 4 / 2 * 2 + y % 4 / 2 * 4)) & 0x03; var tileRect = new Rectangle(new Point(x * 16, y * 16), new Size(16, 16)); if (visibleRect.Contains(tileRect) || visibleRect.IntersectsWith(tileRect)) { g.DrawImage(videos[subPal][mapData.mapData[i]], tileRect); } } //add axis if (showAxis) { for (int x = 0; x < mapData.width; x++) { g.DrawLine(new Pen(Color.White, 1.0f), new Point(x * 32, 0), new Point(x * 32, 32 * mapData.height)); } for (int y = 0; y < mapData.height; y++) { g.DrawLine(new Pen(Color.White, 1.0f), new Point(0, y * 32), new Point(32 * mapData.width, y * 32)); } } }
private void cbLevel_SelectedIndexChanged(object sender, EventArgs e) { if (!UtilsGui.askToSave(ref dirty, saveToFile, returnCbLevelIndex)) { return; } if (cbLayoutNo.SelectedIndex == -1) { return; } curActiveLayout = cbLayoutNo.SelectedIndex; curWidth = ConfigScript.getLevelWidth(curActiveLayout); curHeight = ConfigScript.getLevelHeight(curActiveLayout); drawMode = MapDrawMode.Screens; curActiveBlock = 0; activeBlock.Image = screenImages.Images[0]; updatePanelsVisibility(); cbLayoutNo.Items.Clear(); foreach (var lr in ConfigScript.getLevelRecs()) { cbLayoutNo.Items.Add(String.Format("0x{0:X} ({1}x{2})", lr.layoutAddr, lr.width, lr.height)); } UtilsGui.setCbIndexWithoutUpdateLevel(cbLayoutNo, cbLevel_SelectedIndexChanged, curActiveLayout); reloadLevelLayer(); }
private void blocksScreen_Paint(object sender, PaintEventArgs e) { if (!fileLoaded) { return; } var g = e.Graphics; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; bool renderPhysics = isPhysicsLayerSelected(); var renderParams = new MapEditor.RenderParams { bigBlocks = bigBlocks, visibleRect = UtilsGui.getVisibleRectangle(pnBlocks, blocksScreen), curScale = curScale, showBlocksAxis = showAxis, renderBlockFunc = renderPhysics ? MapEditor.renderPhysicsOnPanelFunc : MapEditor.renderBlocksOnPanelFunc }; int blocksCount = renderPhysics ? ConfigScript.getPhysicsBlocksCount() : bigBlocks.Length; //hardcode physics blocks count MapEditor.renderAllBlocks(g, blocksScreen, curActiveBlock, blocksCount, renderParams); }
private void cbLevel_SelectedIndexChanged(object sender, EventArgs e) { if (cbLayoutNo.SelectedIndex == -1) { return; } bool realReload = sender == cbLayoutNo; bool reloadObjects = realReload; if (!readOnly && realReload) { if (!UtilsGui.askToSave(ref dirty, saveToFile, returnCbLevelIndex)) { return; } } curActiveLayout = cbLayoutNo.SelectedIndex; curScale = cbScale.SelectedIndex + 1; //TODO: normal scale factors; cbLayoutNo.Items.Clear(); foreach (var lr in ConfigScript.levelRecs) { cbLayoutNo.Items.Add(String.Format("{0}:0x{1:X} ({2}x{3})", lr.name, lr.layoutAddr, lr.width, lr.height)); } UtilsGui.setCbIndexWithoutUpdateLevel(cbLayoutNo, cbLevel_SelectedIndexChanged, curActiveLayout); reloadLevel(reloadObjects); resizeMapScreen(); mapScreen.Invalidate(); }
private void bttReload_Click(object sender, EventArgs e) { if (UtilsGui.askToSave(ref dirty, saveToFile, returnCbLevelIndex)) { reloadLevel(true, true); mapScreen.Invalidate(); } }
private void updateBlocksImages() { if (bigBlocks.Length > 0) { UtilsGui.resizeBlocksScreen(bigBlocks, blocksScreen, bigBlocks[0].Width, bigBlocks[0].Height, curScale); blocksScreen.Invalidate(); } }
private void FormMain_FormClosing(object sender, FormClosingEventArgs e) { if (!UtilsGui.askToSave(ref dirty, saveToFile, returnCbLevelIndex)) { updateSaveVisibility(); e.Cancel = true; } }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { if (!fileLoaded) { return; } int[] indexes = layers[0].screens[curActiveScreen]; int[] indexes2 = (ConfigScript.getLayersCount() > 1) ? layers[1].screens[curActiveScreen] : null; var g = e.Graphics; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; int WIDTH = ConfigScript.getScreenWidth(curActiveLevelForScreen); int HEIGHT = ConfigScript.getScreenHeight(curActiveLevelForScreen); int TILE_SIZE_X = (int)(layers[0].blockWidth * curScale); int TILE_SIZE_Y = (int)(layers[0].blockHeight * curScale); int SIZE = WIDTH * HEIGHT; var visibleRect = UtilsGui.getVisibleRectangle(pnView, mapScreen); //ConfigScript.getScreenVertical() ? TILE_SIZE_Y : TILE_SIZE_X MapEditor.Render(e.Graphics, bigBlocks, visibleRect, layers, curActiveScreen, curScale, true, showAxis, ConfigScript.getScreenVertical() ? 0 : TILE_SIZE_X, ConfigScript.getScreenVertical() ? TILE_SIZE_X : 0, WIDTH, HEIGHT); if (!ConfigScript.getScreenVertical() && showNeiScreens && (curActiveScreen > 0) && layers[0].showLayer) { renderNeighbornLine(g, curActiveScreen - 1, (WIDTH - 1), 0); } if (!ConfigScript.getScreenVertical() && showNeiScreens && (curActiveScreen < ConfigScript.screensOffset[curActiveLevelForScreen].recCount - 1) && layers[0].showLayer) { renderNeighbornLine(g, curActiveScreen + 1, 0, (WIDTH + 1) * TILE_SIZE_X); } //show brush bool altPressed = Control.ModifierKeys == Keys.Alt; if (showBrush && curActiveBlock != -1 && (curDx != OUTSIDE || curDy != OUTSIDE) && !altPressed) { if (!useStructs) { var tx = ConfigScript.getScreenVertical() ? curDy * TILE_SIZE_X : (curDx + 1) * TILE_SIZE_X; var ty = ConfigScript.getScreenVertical() ? (curDx + 1) * TILE_SIZE_Y : curDy * TILE_SIZE_Y; var tileRect = new Rectangle(tx, ty, TILE_SIZE_X, TILE_SIZE_Y); g.DrawImage(bigBlocks[curActiveBlock], tileRect); } else { drawActiveTileStruct(g, visibleRect); } } if (altPressed && selectionRect) { int x = Math.Min(selectionMouseX, selectionBeginMouseX); int y = Math.Min(selectionMouseY, selectionBeginMouseY); int w = Math.Abs(selectionMouseX - selectionBeginMouseX); int h = Math.Abs(selectionMouseY - selectionBeginMouseY); g.DrawRectangle(new Pen(Brushes.Black, 2.0f), new Rectangle(x, y, w, h)); } }
private void blocksScreen_Paint(object sender, PaintEventArgs e) { var visibleRect = UtilsGui.getVisibleRectangle(pnBlocks, blocksScreen); var sb0 = smallBlocksImages[0]; int sbw = sb0[0].Width; int sbh = sb0[0].Height; MapEditor.RenderAllBlocks(e.Graphics, blocksScreen, smallBlocksImages[0], sbw, sbh, visibleRect, 1.0f, curActiveBlock, false); }
private void FormStructuresName_Load(object sender, EventArgs e) { UtilsGui.setCbItemsCount(cbWidth, 64, 1); UtilsGui.setCbItemsCount(cbHeight, 64, 1); cbWidth.SelectedIndex = StructWidth - 1; cbHeight.SelectedIndex = StructHeight - 1; cbName.Text = StructName; Result = false; }
private void blocksScreen_Paint(object sender, PaintEventArgs e) { var visibleRect = UtilsGui.getVisibleRectangle(pnBlocks, blocksScreen); var g = e.Graphics; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; MapEditor.RenderAllBlocks(g, blocksScreen, bigBlocks, blockWidth, blockHeight, visibleRect, 1.0f, curActiveTile, showAxis); }
private void resetTileStructControls() { if (curTileStruct != null) { UtilsGui.setCbItemsCount(cbWidth, 64, 1); UtilsGui.setCbItemsCount(cbHeight, 64, 1); UtilsGui.setCbIndexWithoutUpdateLevel(cbWidth, cbWidth_SelectedIndexChanged, curTileStruct.Width - 1); UtilsGui.setCbIndexWithoutUpdateLevel(cbHeight, cbWidth_SelectedIndexChanged, curTileStruct.Height - 1); } }
private void bttReload_Click(object sender, EventArgs e) { if (UtilsGui.askToSave(ref dirty, saveToFile, returnCbLevelIndex)) { Globals.loadData(OpenFile.FileName, OpenFile.DumpName, OpenFile.ConfigName); resetControls(); reloadLevel(true, true); mapScreen.Invalidate(); } }
private void updateMappingControls(int index) { ushort word = tiles[index]; UtilsGui.setCbIndexWithoutUpdateLevel(cbTile, cbTile_SelectedIndexChanged, Mapper.tileIdx(word)); UtilsGui.setCbIndexWithoutUpdateLevel(cbPal, cbPal_SelectedIndexChanged, Mapper.palIdx(word)); UtilsGui.setCbCheckedWithoutUpdateLevel(cbHFlip, cbHFlip_CheckedChanged, Mapper.hf(word)); UtilsGui.setCbCheckedWithoutUpdateLevel(cbVFlip, cbVFlip_CheckedChanged, Mapper.vf(word)); UtilsGui.setCbCheckedWithoutUpdateLevel(cbPrior, cbPrior_CheckedChanged, Mapper.p(word)); }
private void paintBack(Graphics g) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; var screen = getActiveScreen(); int blockWidth = bigBlocks[0].Width; int blockHeight = bigBlocks[0].Height; int width = screen.width; int height = screen.height; int scrWidth = (int)(width * blockWidth * curScale); int scrHeight = (int)(height * blockHeight * curScale); int tileSizeX = (int)(bigBlocks[0].Width * curScale); int tileSizeY = (int)(bigBlocks[0].Height * curScale); for (int x = 0; x < curLevelLayerData.width; x++) { for (int y = 0; y < curLevelLayerData.height; y++) { int noInLayout = y * curLevelLayerData.width + x; int scrNo = calcScrNo(noInLayout); if (scrNo < screens.Length && scrNo >= 0) { var visibleRect = UtilsGui.getVisibleRectangle(pnView, mapScreen); int leftMargin = scrWidth * x; int topMargin = scrHeight * y; MapEditor.render(g, screens, scrNo, new MapEditor.RenderParams { bigBlocks = bigBlocks, visibleRect = visibleRect, curScale = curScale, showBlocksAxis = showAxis, width = width, height = height, additionalRenderEnabled = formMain.additionalRenderEnabled, leftMargin = leftMargin, topMargin = topMargin }); if (showScreenAxis) { g.DrawRectangle(new Pen(Brushes.Black, 2.0f), new Rectangle(leftMargin, topMargin, tileSizeX * width, tileSizeY * height)); } } else { //g.FillRectangle(Brushes.Black, new Rectangle(0, 0, 512, 512)); } } } }
private void EditMap_Load(object sender, EventArgs e) { UtilsGui.setCbItemsCount(cbScreenNo, MapConfig.mapsInfo.Length); cbScreenNo.SelectedIndex = 0; //reloadAllData(); cbShowSecondNametable.Checked = mapDatas.Length > 1; cbShowSecondNametable.Visible = mapDatas.Length > 1; cbSubpalette.DrawItem += cbSubpalette_DrawItemEvent; }
private void blocksScreen_Paint(object sender, PaintEventArgs e) { MapEditor.renderAllBlocks(e.Graphics, blocksScreen, curActiveBlock, bigBlocks.Length, new MapEditor.RenderParams { bigBlocks = bigBlocks, visibleRect = UtilsGui.getVisibleRectangle(pnBlocks, blocksScreen), curScale = curScale, showBlocksAxis = formMain.showAxis, renderBlockFunc = MapEditor.renderBlocksOnPanelFunc }); }
void resetControls(bool needToRefillBlockPanel) { lbStructures.Items.Clear(); for (int i = 0; i < tileStructs.Count; i++) { lbStructures.Items.Add(tileStructs[i].Name); } bigBlocks = formMain.getBigBlockImages(); UtilsGui.resizeBlocksScreen(bigBlocks, blocksScreen, blockWidth, blockHeight, curScale); resetTileStructControls(); }
private void blocksScreen_Paint(object sender, PaintEventArgs e) { MapEditor.renderAllBlocks(e.Graphics, blocksScreen, curActiveBlock, smallBlocksImages[0].Length, new MapEditor.RenderParams { bigBlocks = smallBlocksImages[0], visibleRect = UtilsGui.getVisibleRectangle(pnBlocks, blocksScreen), curScale = 1.0f, showBlocksAxis = false, renderBlockFunc = MapEditor.renderBlocksOnPanelFunc }); }
private void EditVideo_Load(object sender, EventArgs e) { curActiveVideo = 0; curSubPal = 0; UtilsGui.setCbItemsCount(cbVideoNo, ConfigScript.videoOffset.recCount); UtilsGui.setCbItemsCount(cbPalleteNo, ConfigScript.palOffset.recCount); UtilsGui.setCbIndexWithoutUpdateLevel(cbVideoNo, cbVideoNo_SelectedIndexChanged); UtilsGui.setCbIndexWithoutUpdateLevel(cbSubPal, cbVideoNo_SelectedIndexChanged); //UtilsGui.setCbIndexWithoutUpdateLevel(cbPalleteNo, cbPalleteNo_SelectedIndexChanged); cbPalleteNo.SelectedIndex = 0; }
private void cbLevelNo_SelectedIndexChanged(object sender, EventArgs e) { if (!UtilsGui.askToSave(ref dirty, saveToFile, returnCbLevelIndex)) { updateSaveVisibility(); return; } curActiveLevelForScreen = cbLevelNo.SelectedIndex; resetScreens(); resetMapScreenSize(); mapScreen.Invalidate(); }
private void SegaBlockEdit_Load(object sender, EventArgs e) { dirty = false; reloadTiles(); UtilsGui.setCbItemsCount(cbPalSubpart, 4); UtilsGui.setCbIndexWithoutUpdateLevel(cbPalSubpart, cbPalNo_SelectedIndexChanged); UtilsGui.setCbItemsCount(cbBlockNo, getBlocksCount(), inHex: true); UtilsGui.setCbItemsCount(cbTile, SEGA_TILES_COUNT, inHex: true); UtilsGui.setCbItemsCount(cbPal, 4); UtilsGui.setCbIndexWithoutUpdateLevel(cbBlockNo, cbBlockNo_SelectedIndexChanged); resetControls(); }
protected void reloadBlocksPanel() { if (smallBlocksImages == null) { return; } var sb0 = smallBlocksImages[0]; int sbw = sb0[0].Width; int sbh = sb0[0].Height; UtilsGui.resizeBlocksScreen(sb0, blocksScreen, sbw, sbh, 1.0f); blocksScreen.Invalidate(); }
private void blocksScreen_Paint(object sender, PaintEventArgs e) { if (!fileLoaded) { return; } var g = e.Graphics; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; var visibleRect = UtilsGui.getVisibleRectangle(pnBlocks, blocksScreen); MapEditor.RenderAllBlocks(e.Graphics, blocksScreen, bigBlocks, layers[0].blockWidth, layers[0].blockHeight, visibleRect, curScale, curActiveBlock, showAxis); }
private void cbLevelPair_SelectedIndexChanged(object sender, EventArgs e) { if ( cbTileset.SelectedIndex == -1 || cbVideoNo.SelectedIndex == -1 || cbPaletteNo.SelectedIndex == -1 || cbPart.SelectedIndex == -1 || cbViewType.SelectedIndex == -1 || cbSmallBlock.SelectedIndex == -1 || cbHierarchyLevel.SelectedIndex == -1 ) { return; } if (!readOnly && dirty && (sender == cbTileset || sender == cbHierarchyLevel)) { DialogResult dr = MessageBox.Show("Tiles was changed. Do you want to save current tileset?", "Save", MessageBoxButtons.YesNoCancel); if (dr == DialogResult.Cancel) { returnCbLevelIndexes(); return; } else if (dr == DialogResult.Yes) { if (!saveToFile()) { returnCbLevelIndexes(); return; } } else { dirty = false; updateSaveVisibility(); } } //generic version curHierarchyLevel = cbHierarchyLevel.SelectedIndex; curTileset = cbTileset.SelectedIndex; curSmallBlockNo = cbSmallBlock.SelectedIndex; curViewType = (MapViewType)cbViewType.SelectedIndex; curVideo = cbVideoNo.SelectedIndex; curPallete = cbPaletteNo.SelectedIndex; curPart = cbPart.SelectedIndex; UtilsGui.setCbItemsCount(cbPart, Math.Max(ConfigScript.getBigBlocksCount(curHierarchyLevel) / 256, 1)); UtilsGui.setCbIndexWithoutUpdateLevel(cbPart, cbLevelPair_SelectedIndexChanged, curPart); reloadLevel(); }
private void cbGroup_SelectedIndexChanged(object sender, EventArgs e) { if (cbGroup.SelectedIndex < 0) { return; } GroupRec g = ConfigScript.getGroup(cbGroup.SelectedIndex); UtilsGui.setCbIndexWithoutUpdateLevel(cbVideoNo, cbLevel_SelectedIndexChanged, g.videoNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbBigBlockNo, cbLevel_SelectedIndexChanged, g.bigBlockNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbBlockNo, cbLevel_SelectedIndexChanged, g.blockNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbPaletteNo, cbLevel_SelectedIndexChanged, g.palNo); cbLevel_SelectedIndexChanged(cbVideoNo, new EventArgs()); }