public static void OnSaveCompleted(bool success) { if (!success) { LocalizedMessageBox.Show(Localizer.Localize("ERROR_SAVE_FAILED"), Localizer.Localize("ERROR"), Localizer.Localize("Generic", "GENERIC_OK"), null, null, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); } if (EditorDocument.m_saveCompletedCallback != null) { EditorDocument.m_saveCompletedCallback(success); } }
public static void OnLoadCompleted(bool success) { if (!success) { LocalizedMessageBox.Show(Localizer.Localize("ERROR_LOAD_FAILED"), Localizer.Localize("ERROR"), Localizer.Localize("Generic", "GENERIC_OK"), null, null, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); MainForm.Instance.ClearMapPath(); } if (EditorDocument.m_loadCompletedCallback != null) { EditorDocument.m_loadCompletedCallback(success); } }
public bool ImportWorld(int sectorX1, int sectorY1, string[] layers) { if (!File.Exists(this.m_worldFile)) { return(false); } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this.m_worldFile); MainForm.Instance.SetupImportMap(string.Concat(new object[] { fileNameWithoutExtension, " sector (", sectorX1, ",", sectorY1, ") to (", sectorX1 + 7, ",", sectorY1 + 7, ")" })); Rectangle sectorRect = new Rectangle(sectorX1, sectorY1, 8, 8); Rectangle sectionRect = new Rectangle(sectorRect.Left / 4, sectorRect.Top / 4, sectorRect.Right / 4 - sectorRect.Left / 4, sectorRect.Bottom / 4 - sectorRect.Top / 4); string text = Path.GetTempPath(); text += "\\tmpmap\\"; if (Directory.Exists(text)) { Directory.Delete(text, true); } Directory.CreateDirectory(text); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(this.m_worldFile); XmlDocument xmlDocument2 = new XmlDocument(); XmlElement xmlElement = xmlDocument2.CreateElement("FarCry2.Editor.Map"); xmlDocument2.AppendChild(xmlElement); XmlElement xmlElement2 = xmlDocument2.CreateElement("TerrainManager"); xmlElement.AppendChild(xmlElement2); XmlElement xmlElement3 = xmlDocument2.CreateElement("textureEntries"); xmlElement2.AppendChild(xmlElement3); XmlElement xmlElement4 = xmlDocument2.CreateElement("CollectionManager"); xmlElement.AppendChild(xmlElement4); XmlElement xmlElement5 = xmlDocument2.CreateElement("ObjectManager"); xmlElement.AppendChild(xmlElement5); this.ImportHeightmap(this.m_worldPath + "\\heightmaps\\", text, sectorRect, sectionRect); this.ImportHolemap(this.m_worldPath + "\\holemaps\\", text, sectorRect, sectionRect); this.ImportTextures(this.m_worldPath + "\\textures\\", text, sectorRect, sectionRect, xmlElement3); this.ImportCollections(this.m_worldPath + "\\collections\\", text, sectorRect, sectionRect, xmlElement4); this.ImportObjects(this.m_worldPath + "\\objects\\", text, sectorRect, sectionRect, layers, xmlElement5); XmlElement elementByName = XmlHelper.GetElementByName(xmlDocument.DocumentElement, "WaterSectors"); this.ImportWater(elementByName, sectorRect, xmlElement2); xmlElement2.SetAttribute("WaterLevel", "100"); xmlDocument2.Save(text + "map.xml"); return(EditorDocument.LoadPhysical(text)); }
public static bool Load(string fileName, EditorDocument.LoadCompletedCallback callback) { string s = Path.GetDirectoryName(fileName) + Path.DirectorySeparatorChar; string fileName2 = Path.GetFileName(fileName); byte[] bytes = Encoding.UTF8.GetBytes(s); byte[] bytes2 = Encoding.UTF8.GetBytes(fileName2); EditorDocument.m_loadCompletedCallback = callback; return Binding.FCE_Document_Load(bytes, bytes2); }
public static void Save(string fileName, EditorDocument.SaveCompletedCallback callback) { string s = Path.GetDirectoryName(fileName) + Path.DirectorySeparatorChar; string fileName2 = Path.GetFileName(fileName); byte[] bytes = Encoding.UTF8.GetBytes(s); byte[] bytes2 = Encoding.UTF8.GetBytes(fileName2); EditorDocument.m_saveCompletedCallback = callback; Binding.FCE_Document_Save(bytes, bytes2); }
private static void LoadCompletedCallback(bool success) { EditorDocument.OnLoadCompleted(success); }
private bool SaveMap(bool saveAs, bool silent, EditorDocument.SaveCompletedCallback callback) { if (!EditorDocument.Validate() && LocalizedMessageBox.Show(Localizer.Localize("ERROR_VALIDATION_FAILED"), Localizer.Localize("ERROR"), Localizer.Localize("Generic", "GENERIC_YES"), Localizer.Localize("Generic", "GENERIC_NO"), null, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) == DialogResult.No) { return false; } string text = this.m_documentPath; if (saveAs || this.m_documentPath == null) { this.saveMapDialog.FileName = text; if (this.saveMapDialog.ShowDialog(this) != DialogResult.OK) { return false; } text = this.saveMapDialog.FileName; } if (EditorDocument.MapName == EditorDocument.DefaultMapName) { using (PromptForm promptForm = new PromptForm(Localizer.LocalizeCommon("VKEYBOARD_TITLE_MAPNAME"))) { promptForm.Text = Localizer.LocalizeCommon("VKEYBOARD_DESC_MAPNAME"); promptForm.Input = Path.GetFileNameWithoutExtension(text); promptForm.MaxLength = 20; if (promptForm.ShowDialog(this) != DialogResult.OK) { bool result = false; return result; } EditorDocument.MapName = promptForm.Input; } } string text2 = null; if (string.IsNullOrEmpty(EditorDocument.CreatorName)) { using (PromptForm promptForm2 = new PromptForm(Localizer.Localize("PROMPT_CREATOR_TEXT"))) { promptForm2.Text = Localizer.Localize("PROMPT_CREATOR_TITLE"); promptForm2.Input = EditorDocument.AuthorName; promptForm2.MaxLength = 20; if (promptForm2.ShowDialog(this) != DialogResult.OK) { bool result = false; return result; } text2 = promptForm2.Input; } } if (saveAs) { EditorDocument.MapId = Guid.NewGuid(); } if (text2 != null) { EditorDocument.CreatorName = text2; } this.m_documentPath = text; EditorDocument.Save(this.m_documentPath, callback); this.UpdateTitleBar(); return true; }
private bool PromptSave(EditorDocument.SaveCompletedCallback callback) { DialogResult dialogResult = LocalizedMessageBox.Show(MainForm.Instance, Localizer.Localize("EDITOR_CHANGE_MAP_PROMPT"), Localizer.Localize("EDITOR_CONFIRMATION"), Localizer.Localize("Generic", "GENERIC_YES"), Localizer.Localize("Generic", "GENERIC_NO"), Localizer.Localize("Generic", "GENERIC_CANCEL"), MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); DialogResult dialogResult2 = dialogResult; if (dialogResult2 == DialogResult.Cancel) { return false; } switch (dialogResult2) { case DialogResult.Yes: this.SaveMap(false, true, callback); return false; case DialogResult.No: return true; default: return false; } }
private void LoadMapInternal(string fileName, EditorDocument.LoadCompletedCallback callback) { if (fileName == null) { if (this.openMapDialog.ShowDialog(this) != DialogResult.OK) { return; } fileName = this.openMapDialog.FileName; } this.m_documentPath = fileName; this.CurrentTool = null; EditorDocument.Load(this.m_documentPath, callback); this.UpdateTitleBar(); }
private void LoadMap(string fileName, EditorDocument.LoadCompletedCallback callback) { if (!this.PromptSave(delegate(bool success) { if (success) { this.LoadMapInternal(null, callback); } } )) { return; } this.LoadMapInternal(fileName, callback); }