// When a map is saved public override void OnMapSaveBegin(SavePurpose purpose) { base.OnMapSaveBegin(purpose); if (purpose == SavePurpose.Testing) { return; } CleanUpRejectStates(); // Write the reject states to the map config General.Map.Options.WritePluginSetting("numchanges", changes.Count); int index = 0; foreach (KeyValuePair <int, List <RejectSet> > rs in changes) { // Encode the reject settings for this source sector string rejectstr = EncodeRejectString(rs.Value, rs.Key); // Store in map config General.Map.Options.WritePluginSetting("s" + index.ToString(CultureInfo.InvariantCulture), rejectstr); index++; } }
public void OnMapSaveEnd(SavePurpose purpose) { foreach (Plugin p in plugins) { p.Plug.OnMapSaveEnd(purpose); } }
// Map is being saved public override void OnMapSaveBegin(SavePurpose purpose) { base.OnMapSaveBegin(purpose); if (this.EditorOpen) { mainform.SaveData(); } }
// Write the slope data to the .dbs file when the map is saved public override void OnMapSaveBegin(SavePurpose purpose) { base.OnMapSaveBegin(purpose); ListDictionary slopedata = new ListDictionary(); foreach (SlopeVertexGroup svg in BuilderPlug.Me.SlopeVertexGroups) { ListDictionary data = new ListDictionary(); for (int i = 0; i < svg.Vertices.Count; i++) { string name = String.Format("vertex{0}.", i + 1); data.Add(name + "x", svg.Vertices[i].Pos.x); data.Add(name + "y", svg.Vertices[i].Pos.y); data.Add(name + "z", svg.Vertices[i].Z); } slopedata.Add("slope" + svg.Id.ToString(), data); } General.Map.Options.WritePluginSetting("slopes", slopedata); }
/// <summary> /// Occurs after a map is saved. /// </summary> public virtual void OnMapSaveEnd(SavePurpose purpose) { }
/// <summary> /// Occurs before a map is saved. /// </summary> public virtual void OnMapSaveBegin(SavePurpose purpose) { }
public override void OnMapSaveBegin(SavePurpose purpose) { base.OnMapSaveBegin(purpose); soundenvironmentisupdated = false; }
//mxd. Don't save the map if it was not changed internal bool MapSaveRequired(string newfilepathname, SavePurpose purpose) { return(changed || newfilepathname != filepathname || purpose != SavePurpose.Normal); }
// Initializes for an existing map internal bool SaveMap(string newfilepathname, SavePurpose purpose) { General.WriteLogLine("Saving map to " + newfilepathname); // Suspend data resources data.Suspend(); try { // Backup existing file, if any if (File.Exists(newfilepathname)) { if (File.Exists(newfilepathname + ".backup3")) { File.Delete(newfilepathname + ".backup3"); } if (File.Exists(newfilepathname + ".backup2")) { File.Move(newfilepathname + ".backup2", newfilepathname + ".backup3"); } if (File.Exists(newfilepathname + ".backup1")) { File.Move(newfilepathname + ".backup1", newfilepathname + ".backup2"); } File.Copy(newfilepathname, newfilepathname + ".backup1"); } // Kill the target file if it is different from source file if (newfilepathname != filepathname) { // Kill target file if (File.Exists(newfilepathname)) { File.Delete(newfilepathname); } // Kill .dbs settings file string settingsfile = newfilepathname.Substring(0, newfilepathname.Length - 4) + ".dbs"; if (File.Exists(settingsfile)) { File.Delete(settingsfile); } } //mxd. Save map using (FileStream stream = File.OpenWrite(newfilepathname)) { io.Write(map, stream); } } catch (IOException) { General.ShowErrorMessage("IO Error while writing target file: " + newfilepathname + ". Please make sure the location is accessible and not in use by another program.", MessageBoxButtons.OK); data.Resume(); General.WriteLogLine("Map saving failed"); return(false); } catch (UnauthorizedAccessException) { General.ShowErrorMessage("Error while accessing target file: " + newfilepathname + ". Please make sure the location is accessible and not in use by another program.", MessageBoxButtons.OK); data.Resume(); General.WriteLogLine("Map saving failed"); return(false); } // Resume data resources data.Resume(); // Not saved for testing purpose? if (purpose != SavePurpose.Testing) { // Saved in a different file? if (newfilepathname != filepathname) { // Keep new filename filepathname = newfilepathname; filename = Path.GetFileName(filepathname); filepath = Path.GetDirectoryName(filepathname); // Reload resources ReloadResources(); } try { // Open or create the map settings string settingsfile = newfilepathname.Substring(0, newfilepathname.Length - 4) + ".dbs"; options.WriteConfiguration(settingsfile); } catch (Exception e) { // Warning only General.ErrorLogger.Add(ErrorType.Warning, "Could not write the map settings configuration file. " + e.GetType().Name + ": " + e.Message); } // Changes saved changed = false; } // Success! General.WriteLogLine("Map saving done"); General.MainWindow.UpdateTitle(); //mxd return(true); }