private void btnAddProp_Click_1(object sender, EventArgs e) { Prop newProp = new Prop(); newProp.PropName = "newProp"; newProp.PropCategoryName = "New Category"; newProp.PropTag = "newPropTag_" + prntForm.mod.nextIdNumber; prntForm.nodeCount++; prntForm.propsList.Add(newProp); UpdateTreeViewProps(); }
private bool propExists(Prop itImp) { foreach (Prop it in prntForm.propsList) { if (it.PropTag == itImp.PropTag) { return true; } } return false; }
private void panelView_MouseEnter(object sender, EventArgs e) { panelView.Select(); try { if (prntForm.selectedLevelMapCreatureTag != "") { prntForm.CreatureSelected = true; } if (prntForm.selectedLevelMapPropTag != "") { prntForm.PropSelected = true; } if (prntForm.CreatureSelected) { string selectedCrt = prntForm.selectedEncounterCreatureTag; le_selectedCreature = prntForm.getCreatureByTag(selectedCrt); if (le_selectedCreature != null) { selectedBitmap = le_selectedCreature.creatureIconBitmap; //selectedBitmapSize = le_selectedCreature.Size; } } else if (prntForm.PropSelected) { string selectedProp = prntForm.selectedLevelMapPropTag; le_selectedProp = prntForm.getPropByTag(selectedProp); if (le_selectedProp != null) { selectedBitmap = le_selectedProp.propBitmap; //selectedBitmapSize = le_selectedProp.propBitmap.Width / (tileSize * 2); } } } catch (Exception ex) { MessageBox.Show("failed on mouse enter map: " + ex.ToString()); } }
private void clickDrawArea(MouseEventArgs e) { switch (e.Button) { #region Left Button case MouseButtons.Left: refreshLeftPanelInfo(); prntForm.currentSelectedTrigger = null; gridX = e.X / sqr; gridY = e.Y / sqr; lastSquareClicked.X = currentSquareClicked.X; lastSquareClicked.Y = currentSquareClicked.Y; currentSquareClicked.X = gridX; currentSquareClicked.Y = gridY; #region Tile Selected if (rbtnPaintTile.Checked) { //gridX = e.X / sqr; //gridY = e.Y / sqr; selectedTile.index = gridY * area.MapSizeX + gridX; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); if (radioButton1.Checked) { area.Tiles[selectedTile.index].Layer1Filename = currentTileFilename; //if shift key is down, draw all between here and lastclickedsquare if (Control.ModifierKeys == Keys.Shift) { Point cSqr = new Point(currentSquareClicked.X, currentSquareClicked.Y); Point lSqr = new Point(lastSquareClicked.X, lastSquareClicked.Y); int startX = lSqr.X; int startY = lSqr.Y; int endX = cSqr.X; int endY = cSqr.Y; if (lSqr.X >= cSqr.X) { startX = cSqr.X; endX = lSqr.X; } if (lSqr.Y >= cSqr.Y) { startY = cSqr.Y; endY = lSqr.Y; } for (int x = startX; x <= endX; x++) { for (int y = startY; y <= endY; y++) { area.Tiles[y * area.MapSizeX + x].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(x, y); refreshMap(false); } } /*if (cSqr.X == lSqr.X) { if (cSqr.Y > lSqr.Y) { for (int i = lSqr.Y; i <= cSqr.Y; i++) { area.Tiles[i * area.MapSizeX + cSqr.X].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(cSqr.X, i); refreshMap(false); } } else { for (int i = cSqr.Y; i <= lSqr.Y; i++) { area.Tiles[i * area.MapSizeX + cSqr.X].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(cSqr.X, i); refreshMap(false); } } } else if (cSqr.Y == lSqr.Y) { if (cSqr.X > lSqr.X) { for (int i = lSqr.X; i <= cSqr.X; i++) { area.Tiles[cSqr.Y * area.MapSizeX + i].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(i, cSqr.Y); refreshMap(false); } } else { for (int i = cSqr.X; i <= lSqr.X; i++) { area.Tiles[cSqr.Y * area.MapSizeX + i].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(i, cSqr.Y); refreshMap(false); } } } else { int startX = lSqr.X; int startY = lSqr.Y; int endX = cSqr.X; int endY = cSqr.Y; if (lSqr.X >= cSqr.X) { startX = cSqr.X; endX = lSqr.X; } if (lSqr.Y >= cSqr.Y) { startY = cSqr.Y; endY = lSqr.Y; } for (int x = startX; x <= endX; x++) { for (int y = startY; y <= endY; y++) { area.Tiles[y * area.MapSizeX + x].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(x, y); refreshMap(false); } } prntForm.logText("Shift key down for line painting but last click must be a straight line to this click"); prntForm.logText(Environment.NewLine); }*/ } } else if (radioButton2.Checked) { area.Tiles[selectedTile.index].Layer2Filename = currentTileFilename; if (Control.ModifierKeys == Keys.Shift) { Point cSqr = new Point(currentSquareClicked.X, currentSquareClicked.Y); Point lSqr = new Point(lastSquareClicked.X, lastSquareClicked.Y); int startX = lSqr.X; int startY = lSqr.Y; int endX = cSqr.X; int endY = cSqr.Y; if (lSqr.X >= cSqr.X) { startX = cSqr.X; endX = lSqr.X; } if (lSqr.Y >= cSqr.Y) { startY = cSqr.Y; endY = lSqr.Y; } for (int x = startX; x <= endX; x++) { for (int y = startY; y <= endY; y++) { area.Tiles[y * area.MapSizeX + x].Layer2Filename = currentTileFilename; currentSquareClicked = new Point(x, y); refreshMap(false); } } } } refreshMap(false); } #endregion #region Prop Selected else if (prntForm.PropSelected) { string selectedProp = prntForm.selectedLevelMapPropTag; prntForm.logText(selectedProp); prntForm.logText(Environment.NewLine); //gridX = e.X / sqr; //gridY = e.Y / sqr; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); // verify that there is no creature, blocked, or PC already on this location // add to a List<> a new item with the x,y coordinates if (le_selectedProp.ImageFileName == "blank") { return; } Prop newProp = new Prop(); newProp = le_selectedProp.DeepCopy(); newProp.PropTag = le_selectedProp.PropTag + "_" + prntForm.mod.nextIdNumber; newProp.LocationX = gridX; newProp.LocationY = gridY; area.Props.Add(newProp); // show the item on the map if (mod.moduleName != "NewModule") { Bitmap newBitmap = new Bitmap(prntForm._mainDirectory + "\\modules\\" + mod.moduleName + "\\graphics\\" + le_selectedProp.ImageFileName + ".png"); propBitmapList.Add(newBitmap); } else { //do nothing if default module } refreshMap(false); } #endregion #region Paint New Trigger Selected else if (rbtnPaintTrigger.Checked) { string selectedTrigger = prntForm.selectedLevelMapTriggerTag; prntForm.logText(selectedTrigger); prntForm.logText(Environment.NewLine); //gridX = e.X / sqr; //gridY = e.Y / sqr; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); Point newPoint = new Point(gridX, gridY); //add the selected square to the squareList if doesn't already exist try { //check: if click square already exists, then erase from list Trigger newTrigger = area.getTriggerByTag(selectedTrigger); bool exists = false; foreach (Coordinate p in newTrigger.TriggerSquaresList) { if ((p.X == newPoint.X) && (p.Y == newPoint.Y)) { //already exists, erase newTrigger.TriggerSquaresList.Remove(p); exists = true; break; } } if (!exists) //doesn't exist so is a new point, add to list { Coordinate newCoor = new Coordinate(); newCoor.X = newPoint.X; newCoor.Y = newPoint.Y; newTrigger.TriggerSquaresList.Add(newCoor); } } catch { MessageBox.Show("The tag of the selected Trigger was not found in the area's trigger list"); } //update the map to show colored squares refreshMap(false); } #endregion #region Edit Trigger Selected else if (rbtnEditTrigger.Checked) { if (prntForm.selectedLevelMapTriggerTag != null) { string selectedTrigger = prntForm.selectedLevelMapTriggerTag; prntForm.logText(selectedTrigger); prntForm.logText(Environment.NewLine); //gridX = e.X / sqr; //gridY = e.Y / sqr; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); Point newPoint = new Point(gridX, gridY); try { //check: if click square already exists, then erase from list Trigger newTrigger = area.getTriggerByTag(selectedTrigger); if (newTrigger == null) { MessageBox.Show("error: make sure to select a trigger to edit first (click info button then click on trigger)"); } bool exists = false; foreach (Coordinate p in newTrigger.TriggerSquaresList) { if ((p.X == newPoint.X) && (p.Y == newPoint.Y)) { //already exists, erase newTrigger.TriggerSquaresList.Remove(p); exists = true; break; } } if (!exists) //doesn't exist so is a new point, add to list { Coordinate newCoor = new Coordinate(); newCoor.X = newPoint.X; newCoor.Y = newPoint.Y; newTrigger.TriggerSquaresList.Add(newCoor); //newTrigger.TriggerSquaresList.Add(newPoint); } } catch { MessageBox.Show("The tag of the selected Trigger was not found in the area's trigger list"); } //update the map to show colored squares refreshMap(false); } } #endregion #region Walkmesh Toggle Selected else if (rbtnWalkable.Checked) { //gridX = e.X / sqr; //gridY = e.Y / sqr; selectedTile.index = gridY * area.MapSizeX + gridX; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); if (area.Tiles[selectedTile.index].Walkable == true) { area.Tiles[selectedTile.index].Walkable = false; } else { area.Tiles[selectedTile.index].Walkable = true; } refreshMap(false); } #endregion #region LoS mesh Toggle Selected else if (rbtnLoS.Checked) { //gridX = e.X / sqr; //gridY = e.Y / sqr; selectedTile.index = gridY * area.MapSizeX + gridX; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); if (area.Tiles[selectedTile.index].LoSBlocked == true) { area.Tiles[selectedTile.index].LoSBlocked = false; } else { area.Tiles[selectedTile.index].LoSBlocked = true; } refreshMap(false); } #endregion #region None Selected else // not placing, just getting info and possibly deleteing icon { contextMenuStrip1.Items.Clear(); //when left click, get location //gridX = e.X / sqr; //gridY = e.Y / sqr; Point newPoint = new Point(gridX, gridY); EventHandler handler = new EventHandler(HandleContextMenuClick); //loop through all the objects //if has that location, add the tag to the list //draw selection box refreshMap(false); drawSelectionBox(gridX, gridY); txtSelectedIconInfo.Text = ""; foreach (Prop prp in area.Props) { if ((prp.LocationX == newPoint.X) && (prp.LocationY == newPoint.Y)) { // if so then give details about that icon (name, tag, etc.) txtSelectedIconInfo.Text = "name: " + prp.ImageFileName + Environment.NewLine + "tag: " + prp.PropTag + Environment.NewLine; lastSelectedObjectTag = prp.PropTag; //prntForm.selectedLevelMapPropTag = prp.PropTag; panelView.ContextMenuStrip.Items.Add(prp.PropTag, null, handler); //string, image, handler prntForm.frmIceBlinkProperties.propertyGrid1.SelectedObject = prp; } } foreach (Trigger t in area.Triggers) { foreach (Coordinate p in t.TriggerSquaresList) { if ((p.X == newPoint.X) && (p.Y == newPoint.Y)) { txtSelectedIconInfo.Text = "Trigger Tag: " + Environment.NewLine + t.TriggerTag; lastSelectedObjectTag = t.TriggerTag; prntForm.currentSelectedTrigger = t; prntForm.frmTriggerEvents.refreshTriggers(); panelView.ContextMenuStrip.Items.Add(t.TriggerTag, null, handler); //string, image, handler //prntForm.frmIceBlinkProperties.propertyGrid1.SelectedObject = t; } } } //if the list is less than 2, do nothing if (panelView.ContextMenuStrip.Items.Count > 1) { contextMenuStrip1.Show(panelView, e.Location); } prntForm.frmTriggerEvents.refreshTriggers(); } #endregion break; #endregion #region Right Button case MouseButtons.Right: // exit by right click or ESC prntForm.logText("entered right-click"); prntForm.logText(Environment.NewLine); prntForm.selectedLevelMapCreatureTag = ""; prntForm.selectedLevelMapPropTag = ""; prntForm.CreatureSelected = false; prntForm.PropSelected = false; prntForm.currentSelectedTrigger = null; refreshMap(true); UpdatePB(); rbtnInfo.Checked = true; break; #endregion } }