private void panelImage_MouseDown(object sender, MouseEventArgs e) { buttonSetAnchorPoint.BackColor = SystemColors.Control; AddAnchorMode = false; if (MapImageRect.Contains(e.Location)) { DlgSelectLocation dlg3 = new DlgSelectLocation(); if (dlg3.ShowDialog() == DialogResult.Cancel) { return; } GCMapAnchor ma = new GCMapAnchor(); ma.Location = dlg3.SelectedLocation.Title; ma.Longitude = dlg3.SelectedLocation.Longitude; ma.Latitude = dlg3.SelectedLocation.Latitude; ma.relX = (double)(e.X - MapImageRect.X) / MapImageRect.Width; ma.relY = (double)(e.Y - MapImageRect.Y) / MapImageRect.Height; SelectedMap.AnchorPoints.Add(ma); SelectedMap.RecalculateDimensions(); panelImage.Invalidate(); buttonSelect.Enabled = SelectedMap.MapUsable; } }
/// <summary> /// Given a selected map, get the list of available map location unit formats. /// This will be displayed in the combo box. The map's display unit can be changed to any of these location unit values. /// </summary> private async void GetAvailableDisplayUnits() { //Clear the current available units MapAvailableDisplayUnits.Clear(); var units = await QueuedTask.Run(() => { //Gets the list of available map location unit formats for the given map. return(SelectedMap.GetAvailableLocationUnitFormats()); }); //Update combo box binding collection to the units for the selected map. foreach (var item in units) { MapAvailableDisplayUnits.Add(item); } //Gets the current map location unit format for the current project _mapDisplayUnitFormat = await QueuedTask.Run(() => { return(SelectedMap.GetLocationUnitFormat()); }); //Set the location unit combo box item to the map's location unit format (Meters, decimal degree, etc) SelectedMapAvailableDisplayUnit = MapAvailableDisplayUnits.FirstOrDefault(u => u.UnitCode == _mapDisplayUnitFormat.UnitCode); //Should the Apply button be enabled? CanChangeMapDU = false; //They will match }
private void OpenDemoWorld(string mapName, string templateName) { if (voxelArray == null || SelectedMap.Instance().mapName != mapName) { // create and load the file string filePath = WorldFiles.GetFilePath(mapName); if (!File.Exists(filePath)) { TextAsset mapText = Resources.Load <TextAsset>(templateName); using (FileStream fileStream = File.Create(filePath)) { using (var sw = new StreamWriter(fileStream)) { sw.Write(mapText.text); sw.Flush(); } } } if (voxelArray != null) { voxelArray.GetComponent <EditorFile>().Save(); } SelectedMap.Instance().mapName = mapName; SceneManager.LoadScene("editScene"); } Destroy(this); }
public static void OpenMap(string name, string scene) { SelectedMap selectedMap = SelectedMap.Instance(); selectedMap.mapName = name; SceneManager.LoadScene(scene); }
private IEnumerator LoadCoroutine() { yield return null; string mapName = SelectedMap.Instance().mapName; Debug.unityLogger.Log("EditorFile", "Loading " + mapName); MapFileReader reader = new MapFileReader(mapName); List<string> warnings; try { warnings = reader.Read(cameraPivot, voxelArray, true); } catch (MapReadException e) { var dialog = loadingGUI.gameObject.AddComponent<DialogGUI>(); dialog.message = e.Message; dialog.yesButtonText = "Close"; dialog.yesButtonHandler = () => { voxelArray.unsavedChanges = false; Close(); }; // fix issue where message dialog doesn't use correct skin: dialog.guiSkin = loadingGUI.guiSkin; Destroy(loadingGUI); Debug.Log(e.InnerException); yield break; } // reading the file creates new voxels which sets the unsavedChanges flag // and clears existing voxels which sets the selectionChanged flag voxelArray.unsavedChanges = false; voxelArray.selectionChanged = false; Destroy(loadingGUI); foreach (MonoBehaviour b in enableOnLoad) b.enabled = true; if (warnings.Count > 0) { string message = "There were some issues with reading the world:\n\n • " + string.Join("\n • ", warnings.ToArray()); LargeMessageGUI.ShowLargeMessageDialog(loadingGUI.gameObject, message); } if (!PlayerPrefs.HasKey("last_editScene_version")) { var dialog = loadingGUI.gameObject.AddComponent<DialogGUI>(); dialog.message = "This is your first time using the app. Would you like a tutorial?"; dialog.yesButtonText = "Yes"; dialog.noButtonText = "No"; dialog.yesButtonHandler = () => { TutorialGUI.StartTutorial(Tutorials.INTRO_TUTORIAL, dialog.gameObject, voxelArray, touchListener); }; } PlayerPrefs.SetString("last_editScene_version", Application.version); }
public void Save() { if (!voxelArray.unsavedChanges) { Debug.unityLogger.Log("EditorFile", "No unsaved changes"); return; } Debug.unityLogger.Log("EditorFile", "Saving..."); MapFileWriter writer = new MapFileWriter(SelectedMap.Instance().mapName); writer.Write(cameraPivot, voxelArray); voxelArray.unsavedChanges = false; }
public void ChangeSceneDisplayUnit() { if (SelectedMap == null) { return; } if (SelectedSceneAvailableElevUnit == null) { return; //No DisplayUnitFormat selected. } //Change the selected scene's elevation unit. QueuedTask.Run(() => SelectedMap.SetElevationUnitFormat(SelectedSceneAvailableElevUnit)); CanChangeSceneEU = false; //Scene's Elevation Unit will match the selected unit. Since we just made the change. }
public void ChangeMapDisplayUnit() { if (SelectedMap == null) { return; } if (SelectedMapAvailableDisplayUnit == null) { return; //No DisplayUnitFormat selected. } //Change the selected map's display unit. QueuedTask.Run(() => SelectedMap.SetLocationUnitFormat(SelectedMapAvailableDisplayUnit)); CanChangeMapDU = false; //Map's Display Unit will match the selected display unit. Since we just made the change. }
private IEnumerator LoadCoroutine() { yield return(null); MapFileReader reader = new MapFileReader(SelectedMap.Instance().mapName); try { reader.Read(null, GetComponent <VoxelArray>(), false); } catch (MapReadException) { SceneManager.LoadScene("editScene"); // TODO: this is a very bad solution } loadingText.enabled = false; }
private void listBoxMaps_SelectedIndexChanged(object sender, EventArgs e) { ListBox lb = listBoxMaps; if (lb.SelectedIndex >= 0 && lb.SelectedIndex < lb.Items.Count) { SelectedMap = (GCMap)lb.Items[lb.SelectedIndex]; SelectedMap.ResetDisplay(); } else { SelectedMap = null; } panelImage.Invalidate(); EnableButtonsAccordingSelectedMap(); }
public static void Prefix(ShipStatus __instance) { CustomVentsController.ResetAll(); UpdateSelectedMap(); if (SelectedMap == null) { return; } foreach (var TransformObject in __instance.transform) { Object.Destroy(TransformObject.Cast <Transform>().gameObject); } SelectedMap.RuntimeMap = Object.Instantiate( SelectedMap.MapPrefab, __instance.transform); SelectedMap.RecalculateRuntime(); SelectedMap.ComponentsAwake(); CustomVentsController.MoveAllVents(); }
private void mnuSave_Click(object sender, EventArgs e) { CurrentMap.MapSong = Convert.ToUInt16(txtSong.Text, HEX); CurrentMap.CaveBehaviour = (byte)cmbCaveBehaviour.SelectedIndex; CurrentMap.Weather = (byte)cmbWeather.SelectedIndex; CurrentMap.MapType = (byte)cmbType.SelectedIndex; CurrentMap.BattleStyle = (byte)cmbBattleStyle.SelectedIndex; if (CurrentROM.GameCode.Substring(0, 3) == "BPR" || CurrentROM.GameCode.Substring(0, 3) == "BPG") { CurrentMap.MapNameIndex = (byte)(cmbMapNames.SelectedIndex + 0x58); CurrentMap.FloorLevel = (sbyte)numFloorLevel.Value; } else { CurrentMap.MapNameIndex = (byte)cmbMapNames.SelectedIndex; } Maps.SaveMap(CurrentROM, CurrentMap); // Write changes to ROM treeMaps.Nodes[SelectedBank].Nodes[SelectedMap].Text = "Map " + SelectedMap.ToString() + " - " + Maps.MapNameList[cmbMapNames.SelectedIndex]; }
private void treeMaps_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Parent == null || e.Node.Text.Substring(9, 8) == "RESERVED") { return; } if (!pnlMap.Visible) { pnlMap.Visible = true; pnlEvents.Visible = true; pnlEventProps.Visible = true; pnlTileset.Visible = true; picAttributes.Visible = true; pnlProperties.Visible = true; pnlHeader.Visible = true; } tabEditor.SelectedIndex = 0; SelectedMap = e.Node.Index; SelectedBank = e.Node.Parent.Index; lblCurrentMap.Text = "Map " + SelectedMap.ToString(); lblCurrentBank.Text = "Bank: " + SelectedBank.ToString(); long ExecutionTime = System.DateTime.Now.Ticks; CurrentMap = Maps.LoadMap(CurrentROM, SelectedBank, SelectedMap); // Load map LoadHeader(); // Load stuff for Header View LoadProperties(); // Load stuff for Properties View MapEvents.Load(CurrentROM, CurrentMap); // Load events DrawMap(); // Renders the map, tileset & border lblStatus.Text = "Map loaded in " + ((System.DateTime.Now.Ticks - ExecutionTime) / TimeSpan.TicksPerMillisecond) + " milliseconds."; lblCurrentTile.Text = "Current Tile: 0x0"; picTileset.Invalidate(); }
private void OnOpen() { if (SelectedMap == null) { return; } var n = string.Format("({0}) {1}: {2}", SelectedMap.Id, SelectedMap.RegionPlaceName, SelectedMap.PlaceName); try { var t = SelectedMap.GetTerritory(); if (t == null) { System.Windows.MessageBox.Show(string.Format("Could not find territory data for {0}.", n), "Territory not found", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } else { Parent.EngineHelper.OpenInNew(n, (e) => new SaintCoinach.Graphics.Viewer.Content.ContentTerritory(e, t)); } } catch (Exception e) { System.Windows.MessageBox.Show(string.Format("Error reading territory for {0}:{1}{2}", n, Environment.NewLine, e), "Failure to read territory", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }
/// <summary> /// Given a selected scene, get the list of available elevation unit formats. /// This will be displayed in the combo box. The scene's elevation unit can be changed to any of these location unit values. /// </summary> private async void GetAvailableElevationUnits() { //Clear the current available units SceneAvailableElevUnits.Clear(); var units = await QueuedTask.Run(() => { //Gets the list of available Scene Elevation unit formats for the given scene. return(SelectedMap.GetAvailableElevationUnitFormats()); }); //Update combo box binding collection to the units for the selected scene. foreach (var item in units) { SceneAvailableElevUnits.Add(item); } //Gets the current scene elevation unit format for the current project _sceneElevationUnitFormat = await QueuedTask.Run(() => { return(SelectedMap.GetElevationUnitFormat()); }); SelectedSceneAvailableElevUnit = SceneAvailableElevUnits.FirstOrDefault(e => e.UnitCode == _sceneElevationUnitFormat.UnitCode); //Should the Apply button be enabled? CanChangeSceneEU = false; }