public void ImportMarkers() { var extensions = new[] { new ExtensionFilter("Faf Markers", "fafmapmarkers") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import markers", DefaultPath, extensions, false); if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0])) { ExportMarkers ImpMarkers = JsonUtility.FromJson <ExportMarkers>(System.IO.File.ReadAllText(paths[0])); bool AnyCreated = false; int mc = 0; MapLua.SaveLua.Marker[] CreatedMarkers = new MapLua.SaveLua.Marker[ImpMarkers.Markers.Length]; for (int m = 0; m < ImpMarkers.Markers.Length; m++) { if (!AnyCreated) { Undo.Current.RegisterMarkersAdd(); } AnyCreated = true; if (SelectionManager.Current.SnapToGrid) { ImpMarkers.Markers[m].Pos = ScmapEditor.SnapToGridCenter(ImpMarkers.Markers[m].Pos, true, SelectionManager.Current.SnapToWater); } MapLua.SaveLua.Marker NewMarker = new MapLua.SaveLua.Marker(ImpMarkers.Markers[m].MarkerType); CreatedMarkers[m] = NewMarker; NewMarker.position = ScmapEditor.WorldPosToScmap(ImpMarkers.Markers[m].Pos); NewMarker.orientation = ImpMarkers.Markers[m].Rot.eulerAngles; MarkersControler.CreateMarker(NewMarker, mc); ChainsList.AddToCurrentChain(NewMarker); MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Add(NewMarker); } for (int m = 0; m < ImpMarkers.Markers.Length; m++) { CreatedMarkers[m].AdjacentToMarker = new List <MapLua.SaveLua.Marker>(); for (int c = 0; c < ImpMarkers.Markers[m].Connected.Length; c++) { CreatedMarkers[m].AdjacentToMarker.Add(CreatedMarkers[ImpMarkers.Markers[m].Connected[c]]); } } RenderMarkersConnections.Current.UpdateConnections(); EnvPaths.SetLastPath(ExportPathKey, System.IO.Path.GetDirectoryName(paths[0])); GenericInfoPopup.ShowInfo("Markers imported"); } }
private void Awake() { Current = this; }
public void Place(Vector3[] Positions, Quaternion[] Rotations, Vector3[] Scales) { //List<MapLua.SaveLua.Marker> NewMarkers = new List<MapLua.SaveLua.Marker>(); int mc = 0; // MasterChainID LastAddedMarkers = new List <int>(); int TotalMarkersCount = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count; bool AnyCreated = false; if (CreationId == 5) { Vector3 NewPos; MarkerPreset Mpreset = MarkerPresets[SpawnPressetDropdown.value].GetComponent <MarkerPreset>(); for (int i = 0; i < Positions.Length; i++) { for (int m = 0; m < Mpreset.Markers.Length; m++) { if (!AnyCreated) { Undo.Current.RegisterMarkersAdd(); } AnyCreated = true; //Debug.Log(Mpreset.Markers[m].Tr.localPosition); NewPos = Positions[i] + Rotations[i] * Mpreset.Markers[m].Tr.localPosition; if (SelectionManager.Current.SnapToGrid) { NewPos = ScmapEditor.SnapToGridCenter(NewPos, true, SelectionManager.Current.SnapToWater); } //NewPos.y = ScmapEditor.Current.Teren.SampleHeight(NewPos); MapLua.SaveLua.Marker NewMarker = new MapLua.SaveLua.Marker(Mpreset.Markers[m].MarkerType); NewMarker.position = ScmapEditor.WorldPosToScmap(NewPos); //NewMarker.orientation = MarkersControler.CreateMarker(NewMarker, mc); ChainsList.AddToCurrentChain(NewMarker); LastAddedMarkers.Add(TotalMarkersCount); TotalMarkersCount++; MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Add(NewMarker); } } } else { for (int i = 0; i < Positions.Length; i++) { if (!AnyCreated) { Undo.Current.RegisterMarkersAdd(); } AnyCreated = true; MapLua.SaveLua.Marker NewMarker = new MapLua.SaveLua.Marker(LastCreationType); bool snapToWater = SelectionManager.Current.SnapToWater; if (LastCreationType == MapLua.SaveLua.Marker.MarkerTypes.Mass || LastCreationType == MapLua.SaveLua.Marker.MarkerTypes.Hydrocarbon) { snapToWater = false; } if (SelectionManager.Current.SnapToGrid) { Positions[i] = ScmapEditor.SnapToGridCenter(Positions[i], true, snapToWater); } //Positions[i].y = ScmapEditor.Current.Teren.SampleHeight(Positions[i]); ChainsList.AddToCurrentChain(NewMarker); NewMarker.position = ScmapEditor.WorldPosToScmap(Positions[i]); if (CreationId == 3) { NewMarker.orientation = Rotations[i].eulerAngles; } else { NewMarker.orientation = Vector3.zero; } MarkersControler.CreateMarker(NewMarker, mc); LastAddedMarkers.Add(TotalMarkersCount); TotalMarkersCount++; MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Add(NewMarker); } } if (AnyCreated) { //MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Concat<MapLua.SaveLua.Marker>(NewMarkers.ToArray()); MarkerSelectionOptions.UpdateOptions(); MarkersControler.UpdateBlankMarkersGraphics(); RenderMarkersWarnings.Generate(); } }
public void ImportMarkers() { var extensions = new[] { new ExtensionFilter("Faf Markers", "fafmapmarkers") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import markers", EnvPaths.GetMapsPath(), extensions, false); /* * OpenFileDialog FileDialog = new OpenFileDialog(); * FileDialog.Title = "Import markers"; * FileDialog.AddExtension = true; * FileDialog.DefaultExt = ".fafmapmarkers"; * FileDialog.Filter = "Faf Markers (*.fafmapmarkers)|*.fafmapmarkers"; * FileDialog.CheckFileExists = true; */ if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0])) { ExportMarkers ImpMarkers = JsonUtility.FromJson <ExportMarkers>(System.IO.File.ReadAllText(paths[0])); bool AnyCreated = false; int mc = 0; MapLua.SaveLua.Marker[] CreatedMarkers = new MapLua.SaveLua.Marker[ImpMarkers.Markers.Length]; for (int m = 0; m < ImpMarkers.Markers.Length; m++) { if (!AnyCreated) { Undo.Current.RegisterMarkersAdd(); } AnyCreated = true; if (SelectionManager.Current.SnapToGrid) { ImpMarkers.Markers[m].Pos = ScmapEditor.SnapToGridCenter(ImpMarkers.Markers[m].Pos, true, SelectionManager.Current.SnapToWater); } MapLua.SaveLua.Marker NewMarker = new MapLua.SaveLua.Marker(ImpMarkers.Markers[m].MarkerType); CreatedMarkers[m] = NewMarker; NewMarker.position = ScmapEditor.WorldPosToScmap(ImpMarkers.Markers[m].Pos); NewMarker.orientation = ImpMarkers.Markers[m].Rot.eulerAngles; MarkersControler.CreateMarker(NewMarker, mc); ChainsList.AddToCurrentChain(NewMarker); MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Add(NewMarker); } for (int m = 0; m < ImpMarkers.Markers.Length; m++) { CreatedMarkers[m].AdjacentToMarker = new List <MapLua.SaveLua.Marker>(); for (int c = 0; c < ImpMarkers.Markers[m].Connected.Length; c++) { CreatedMarkers[m].AdjacentToMarker.Add(CreatedMarkers[ImpMarkers.Markers[m].Connected[c]]); } } RenderMarkersConnections.Current.UpdateConnections(); } }