private void lbStructures_SelectedIndexChanged(object sender, EventArgs e) { int index = lbStructures.SelectedIndex; var tss = FormStructures.getTileStructures(); if (index == -1 || index >= tss.Count) { return; } curTileStruct = tss[index]; }
private void mapScreen_MouseUp(object sender, MouseEventArgs ea) { var ee = ea.Location; if (ee.X < 0) { ee.X += 32768 * 2; } if (ee.Y < 0) { ee.Y += 32768 * 2; } if (selectionRect) { convertMouseToDxDy(ee, out selectionEndX, out selectionEndY); if (selectionEndX < selectionBeginX) { selectionBeginX ^= selectionEndX; selectionEndX ^= selectionBeginX; selectionBeginX ^= selectionEndX; } if (selectionEndY < selectionBeginY) { selectionBeginY ^= selectionEndY; selectionEndY ^= selectionBeginY; selectionBeginY ^= selectionEndY; } int deltaX = selectionEndX - selectionBeginX + 1; int deltaY = selectionEndY - selectionBeginY + 1; int [][] tiles = new int[deltaY][]; for (int arrs = 0; arrs < tiles.Length; arrs++) { tiles[arrs] = new int[deltaX]; } var curScreen = layers[0].screens[curActiveScreen]; //screens2? for (int i = 0; i < deltaX; i++) { for (int j = 0; j < deltaY; j++) { int index = (selectionBeginY + j) * ConfigScript.getScreenWidth(curActiveLevelForScreen) + (selectionBeginX + i); tiles[j][i] = curScreen[index]; } } FormStructures.addTileStruct(tiles); cbUseStructs.Checked = true; if (useStructs) { updateBlocksPanelVisible(); } } selectionRect = false; curClicked = false; }
private void mapScreen_MouseUp(object sender, MouseEventArgs ea) { var ee = ea.Location; //hack to WinAPI very big coordinates - convert signed to unsigned if (ee.X < 0) { ee.X += 32768 * 2; } if (ee.Y < 0) { ee.Y += 32768 * 2; } if (!isPhysicsLayerSelected() && selectionRect) { convertMouseToDxDy(ee, out selectionEndX, out selectionEndY); if (selectionEndX < selectionBeginX) { Utils.swap(ref selectionBeginX, ref selectionEndX); } if (selectionEndY < selectionBeginY) { Utils.swap(ref selectionBeginY, ref selectionEndY); } int deltaX = selectionEndX - selectionBeginX + 1; int deltaY = selectionEndY - selectionBeginY + 1; int [][] tiles = new int[deltaY][]; for (int arrs = 0; arrs < tiles.Length; arrs++) { tiles[arrs] = new int[deltaX]; } var curScreen = screens[screenNo]; for (int i = 0; i < deltaX; i++) { for (int j = 0; j < deltaY; j++) { int index = (selectionBeginY + j) * curScreen.width + (selectionBeginX + i); tiles[j][i] = curScreen.layers[curActiveLayer].data[index]; } } FormStructures.addTileStruct(tiles); cbUseStructs.Checked = true; if (useStructs) { updateBlocksPanelVisible(); } } selectionRect = false; curClicked = false; }
private void updateBlocksPanelVisible() { pnBlocks.Visible = !useStructs; lbStructures.Visible = useStructs; if (useStructs) { lbStructures.Items.Clear(); var tss = FormStructures.getTileStructures(); foreach (var ts in tss) { lbStructures.Items.Add(ts.Name); } } }
private void bttStructures_Click(object sender, EventArgs e) { var f = new FormStructures(); f.setFormMain(this); f.Show(); updateBlocksPanelVisible(); }