private void btnAddArea_Click_1(object sender, EventArgs e) { Area newArea = new Area(); newArea.Filename = "new area"; prntForm.mod.moduleAreasList.Add(newArea.Filename); refreshListBoxAreas(); // should I create a new file at this point? }
private void btnDuplicate_Click(object sender, EventArgs e) { if ((lbxAreas.Items.Count > 0) && (lbxAreas.SelectedIndex >= 0)) { //if file exists, rename the file string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\areas"; string filename = prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex]; if (File.Exists(filePath + "\\" + filename + ".lvl")) { try { //rename file File.Copy(filePath + "\\" + filename + ".lvl", filePath + "\\" + filename + "-Copy.lvl"); try { //load area Area newArea = new Area(); newArea = newArea.loadAreaFile(filePath + "\\" + filename + "-Copy.lvl"); if (newArea == null) { MessageBox.Show("returned a null area"); } //change area file name in area file object properties newArea.Filename = filename + "-Copy"; newArea.saveAreaFile(filePath + "\\" + filename + "-Copy.lvl"); prntForm.mod.moduleAreasList.Add(newArea.Filename); refreshListBoxAreas(); } catch (Exception ex) { MessageBox.Show("failed to open file: " + ex.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); // Write error } } else { MessageBox.Show("File: " + filename + ".lvl does not exist in the areas folder"); } refreshListBoxAreas(); } }
public void CheckAreas() { //iterate through all areas from the area list and load one at a time and check //if load fails report foreach (string areafilename in frm.mod.moduleAreasList) { area = area.loadAreaFile(frm._mainDirectory + "\\modules\\" + frm.mod.moduleName + "\\areas\\" + areafilename + ".lvl"); if (area == null) { frm.logText("AREA ERROR: returned a null area for " + areafilename + ", most likely couldn't find file" + Environment.NewLine); continue; } //go through all triggers and check for missing data foreach (Trigger trg in area.Triggers) { //check if transition with no destination if ((trg.Event1Type == "transition") && ((trg.Event1TransPointX == 0) && (trg.Event1TransPointY == 0))) { frm.logText("TRIGGER ERROR: " + areafilename + ": trigger " + trg.TriggerTag + "event1 has a x=0 and y=0 location, is that intended?" + Environment.NewLine); } if ((trg.Event2Type == "transition") && ((trg.Event2TransPointX == 0) && (trg.Event2TransPointY == 0))) { frm.logText("TRIGGER ERROR: " + areafilename + ": trigger " + trg.TriggerTag + "event2 has a x=0 and y=0 location, is that intended?" + Environment.NewLine); } if ((trg.Event3Type == "transition") && ((trg.Event3TransPointX == 0) && (trg.Event3TransPointY == 0))) { frm.logText("TRIGGER ERROR: " + areafilename + ": trigger " + trg.TriggerTag + "event3 has a x=0 and y=0 location, is that intended?" + Environment.NewLine); } if ((trg.Event1Type != "none") && (trg.Event1FilenameOrTag == "none")) { frm.logText("TRIGGER ERROR: " + areafilename + ": trigger " + trg.TriggerTag + ": event1 has type of " + trg.Event1Type + " but filename/tag of 'none'" + Environment.NewLine); } if ((trg.Event2Type != "none") && (trg.Event2FilenameOrTag == "none")) { frm.logText("TRIGGER ERROR: " + areafilename + ": trigger " + trg.TriggerTag + ": event2 has type of " + trg.Event2Type + " but filename/tag of 'none'" + Environment.NewLine); } if ((trg.Event3Type != "none") && (trg.Event3FilenameOrTag == "none")) { frm.logText("TRIGGER ERROR: " + areafilename + ": trigger " + trg.TriggerTag + ": event3 has type of " + trg.Event3Type + " but filename/tag of 'none'" + Environment.NewLine); } } } }
private void btnRename_Click(object sender, EventArgs e) { if ((lbxAreas.Items.Count > 0) && (lbxAreas.SelectedIndex >= 0)) { RenameDialog newName = new RenameDialog(); DialogResult result = newName.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { try { #region New Area if (prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] == "new area") { //if file exists, rename the file string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\areas"; if (File.Exists(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl")) { try { //rename file File.Move(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl", filePath + "\\" + newName.RenameText + ".lvl"); // Try to move try { //load area Area newArea = new Area(); newArea = newArea.loadAreaFile(filePath + "\\" + newName.RenameText + ".lvl"); if (newArea == null) { MessageBox.Show("returned a null area"); } //change area file name in area file object properties newArea.Filename = newName.RenameText; newArea.saveAreaFile(filePath + "\\" + newName.RenameText + ".lvl"); prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText; } catch (Exception ex) { MessageBox.Show("failed to open file: " + ex.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); // Write error } } else { prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText; } refreshListBoxAreas(); } #endregion #region Existing Area else { DialogResult sure = MessageBox.Show("Are you sure you wish to change the area name and the area file name? (make sure to update any references to this area name such as transitions and scripts)", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (sure == System.Windows.Forms.DialogResult.Yes) { //if file exists, rename the file string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\areas"; if (File.Exists(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl")) { try { //rename file File.Move(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl", filePath + "\\" + newName.RenameText + ".lvl"); // Try to move try { //load area Area newArea = new Area(); newArea = newArea.loadAreaFile(filePath + "\\" + newName.RenameText + ".lvl"); if (newArea == null) { MessageBox.Show("returned a null area"); } //change area file name in area file object properties newArea.Filename = newName.RenameText; newArea.saveAreaFile(filePath + "\\" + newName.RenameText + ".lvl"); prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText; } catch (Exception ex) { MessageBox.Show("failed to open file: " + ex.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); // Write error } } else { prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText; } refreshListBoxAreas(); } } #endregion } catch { } } } }
public void loadAreas(string path) { Area newArea = new Area(); foreach (string areaName in moduleAreasList) { try { newArea = newArea.loadAreaFile(path + areaName + ".level"); if (newArea == null) { MessageBox.Show("returned a null area filling areaList"); } moduleAreasObjects.Add(newArea); //MessageBox.Show("open file success"); } catch (Exception ex) { MessageBox.Show("failed to open all files: " + ex.ToString() + ex.Message); } } }
private void openLevel(string g_dir, string g_fil, string g_filNoEx) { this.Cursor = Cursors.WaitCursor; try { area = area.loadAreaFile(g_dir + "\\" + g_fil + ".lvl"); if (area == null) { MessageBox.Show("returned a null area"); } loadAreaObjectBitmapLists(); } catch (Exception ex) { MessageBox.Show("failed to open file: " + ex.ToString()); } refreshLeftPanelInfo(); panelView.Width = area.MapSizeX * sqr; panelView.Height = area.MapSizeY * sqr; panelView.BackgroundImage = (Image)surface; device = Graphics.FromImage(surface); if (surface == null) { MessageBox.Show("returned a null Map bitmap"); return; } refreshMap(true); this.Cursor = Cursors.Arrow; }
private void createNewArea(int width, int height) { //create tilemap area = null; area = new Area(); area.MapSizeX = width; area.MapSizeY = height; for (int index = 0; index < (width * height); index++) { Tile newTile = new Tile(); newTile.Walkable = true; newTile.LoSBlocked = false; newTile.Visible = false; area.Tiles.Add(newTile); } refreshLeftPanelInfo(); panelView.Width = area.MapSizeX * sqr; panelView.Height = area.MapSizeY * sqr; panelView.BackgroundImage = (Image)surface; device = Graphics.FromImage(surface); if (surface == null) { MessageBox.Show("returned a null Map bitmap"); return; } refreshMap(true); }
private void WorldMapEditor_Load(object sender, EventArgs e) { //LoadEncounters(); radioButton1.Checked = true; checkBox1.Checked = true; checkBox2.Checked = true; //createTileImageButtons(); area = new Area(); area.MapSizeX = 16; area.MapSizeY = 16; // try and load the file selected if it exists string g_filename = mod.moduleAreasList[prntForm._selectedLbxAreaIndex]; string g_directory = prntForm._mainDirectory + "\\modules\\" + mod.moduleName + "\\areas"; string filenameNoExtension = Path.GetFileNameWithoutExtension(mod.moduleAreasList[prntForm._selectedLbxAreaIndex]); if (File.Exists(g_directory + "\\" + g_filename + ".lvl")) { openLevel(g_directory, g_filename, filenameNoExtension); if (area == null) { createNewArea(area.MapSizeX, area.MapSizeY); area.Filename = g_filename; } } else { createNewArea(area.MapSizeX, area.MapSizeY); area.Filename = g_filename; } //set up level drawing surface panelView.Width = area.MapSizeX * sqr; panelView.Height = area.MapSizeY * sqr; surface = new Bitmap(panelView.Size.Width, panelView.Size.Height); //UpdatePB(); device = Graphics.FromImage(surface); panelView.BackgroundImage = (Image)surface; //refreshCmbBoxes(); prntForm.openAreasList.Add(area); rbtnInfo.Checked = true; rbtnZoom1x.Checked = true; //refreshMap(true); //Set this map to be a WORLD MAP area.IsWorldMap = true; }