public void ExportWaves() { var extensions = new[] { new ExtensionFilter("Waves settings", format) }; var path = StandaloneFileBrowser.SaveFilePanel("Export waves", EnvPaths.GetMapsPath(), "", extensions); if (string.IsNullOrEmpty(path)) return; Debug.Log(ScmapEditor.Current.map.WaveGenerators.Count); WaveData Wave = new WaveData(); Wave.AllWaves = new WaveGenerator[ScmapEditor.Current.map.WaveGenerators.Count]; ScmapEditor.Current.map.WaveGenerators.CopyTo(Wave.AllWaves); string data = JsonUtility.ToJson(Wave); data = data.Replace(",", ",\n"); data = data.Replace("{", "{\n"); data = data.Replace("}", "\n}"); File.WriteAllText(path, data); }
public void CreateMap() { if (string.IsNullOrEmpty(Name.text)) { GenericPopup.ShowPopup(GenericPopup.PopupTypes.OneButton, "Warning", "Name must not be empty!", "OK", null); return; } MapPath = EnvPaths.GetMapsPath(); string Error = ""; if (!System.IO.Directory.Exists(MapPath)) { Error = "Maps folder not exist: " + MapPath; Debug.LogError(Error); GenericPopup.ShowPopup(GenericPopup.PopupTypes.OneButton, "Warning", "The map folder does not exist:\n" + MapPath, "OK", null); return; } FolderName = Name.text.Replace(" ", "_") + ".v0001"; string path = MapPath + FolderName; Debug.Log(path); if (Directory.Exists(path)) { Error = "Map folder already exist: " + path; Debug.LogError(Error); GenericPopup.ShowPopup(GenericPopup.PopupTypes.OneButton, "Warning", "Map already exist: \n" + path, "OK", null); return; } StartCoroutine(CreateFiles()); }
public void ExportLightingData() { var extensions = new[] { new ExtensionFilter("Lighting settings", "scmlighting") }; var path = StandaloneFileBrowser.SaveFilePanel("Export Lighting", EnvPaths.GetMapsPath(), "", extensions); if (string.IsNullOrEmpty(path)) { return; } LightingData Data = new LightingData(); Data.LightingMultiplier = Scmap.map.LightingMultiplier; Data.SunDirection = Scmap.map.SunDirection; Data.SunAmbience = Scmap.map.SunAmbience; Data.SunColor = Scmap.map.SunColor; Data.ShadowFillColor = Scmap.map.ShadowFillColor; Data.SpecularColor = Scmap.map.SpecularColor; Data.Bloom = Scmap.map.Bloom; Data.FogColor = Scmap.map.FogColor; Data.FogStart = Scmap.map.FogStart; Data.FogEnd = Scmap.map.FogEnd; string DataString = JsonUtility.ToJson(Data); File.WriteAllText(path, DataString); }
public void ImportWater() { var extensions = new[] { new ExtensionFilter("Water settings", "scmwtr") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import water", EnvPaths.GetMapsPath(), extensions, false); if (paths.Length <= 0 || string.IsNullOrEmpty(paths[0])) { return; } string data = File.ReadAllText(paths[0]); float WaterLevel = ScmapEditor.Current.map.Water.Elevation; float AbyssLevel = ScmapEditor.Current.map.Water.ElevationAbyss; float DeepLevel = ScmapEditor.Current.map.Water.ElevationDeep; ScmapEditor.Current.map.Water = JsonUtility.FromJson <WaterShader>(data); ScmapEditor.Current.map.Water.Elevation = WaterLevel; ScmapEditor.Current.map.Water.ElevationAbyss = AbyssLevel; ScmapEditor.Current.map.Water.ElevationDeep = DeepLevel; ReloadValues(); UpdateScmap(true); }
public void ImportLightingData() { var extensions = new[] { new ExtensionFilter("Lighting settings", "scmlighting") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import Lighting", EnvPaths.GetMapsPath(), extensions, false); if (paths.Length == 0 || string.IsNullOrEmpty(paths[0])) { return; } string data = File.ReadAllText(paths[0]); LightingData LightingData = UnityEngine.JsonUtility.FromJson <LightingData>(data); Scmap.map.LightingMultiplier = LightingData.LightingMultiplier; Scmap.map.SunDirection = LightingData.SunDirection; Scmap.map.SunAmbience = LightingData.SunAmbience; Scmap.map.SunColor = LightingData.SunColor; Scmap.map.ShadowFillColor = LightingData.ShadowFillColor; Scmap.map.SpecularColor = LightingData.SpecularColor; Scmap.map.Bloom = LightingData.Bloom; Scmap.map.FogColor = LightingData.FogColor; Scmap.map.FogStart = LightingData.FogStart; Scmap.map.FogEnd = LightingData.FogEnd; LoadValues(); }
public void SaveMapAs() { if (!MapLuaParser.IsMapLoaded) { return; } LateUpdate(); var paths = StandaloneFileBrowser.OpenFolderPanel("Save map as...", EnvPaths.GetMapsPath(), false); if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0])) { if (System.IO.Directory.GetDirectories(paths[0]).Length > 0 || System.IO.Directory.GetFiles(paths[0]).Length > 0) { Debug.LogError("Selected directory is not empty! " + paths[0]); GenericPopup.ShowPopup(GenericPopup.PopupTypes.Error, "Error", "Selected folder is not empty! Select empty folder.", "OK", null); return; } string[] PathSeparation = paths[0].Replace("\\", "/").Split("/".ToCharArray()); string FileBeginName = PathSeparation[PathSeparation.Length - 1].ToLower(); //MapLuaParser.Current.ScenarioFileName = FileBeginName + "_scenario"; string NewFolderName = PathSeparation[PathSeparation.Length - 1]; SaveAsNewFolder(NewFolderName, FileBeginName); } }
public void ExportSelectedMarkers() { var extensions = new[] { new ExtensionFilter("Faf Markers", "fafmapmarkers") }; var paths = StandaloneFileBrowser.SaveFilePanel("Export markers", EnvPaths.GetMapsPath(), "", extensions); /* * SaveFileDialog FileDialog = new SaveFileDialog(); * FileDialog.Title = "Export markers"; * FileDialog.AddExtension = true; * * FileDialog.DefaultExt = ".fafmapmarkers"; * FileDialog.Filter = "Faf Markers (*.fafmapmarkers)|*.fafmapmarkers"; */ //System.Windows.Forms.FolderBrowserDialog FolderDialog = new FolderBrowserDialog(); //FolderDialog.ShowNewFolderButton = false; //FolderDialog.Description = "Select 'Maps' folder."; //if (FileDialog.ShowDialog() == DialogResult.OK) if (!string.IsNullOrEmpty(paths)) { ExportMarkers ExpMarkers = new ExportMarkers(); ExpMarkers.MapWidth = ScmapEditor.Current.map.Width; ExpMarkers.MapHeight = ScmapEditor.Current.map.Height; List <MapLua.SaveLua.Marker> SelectedObjects = new List <MapLua.SaveLua.Marker>(); for (int i = 0; i < SelectionManager.Current.Selection.Ids.Count; i++) { SelectedObjects.Add(SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]].GetComponent <MarkerObject>().Owner); } ExpMarkers.Markers = new ExportMarkers.ExportMarker[SelectedObjects.Count]; for (int i = 0; i < ExpMarkers.Markers.Length; i++) { ExpMarkers.Markers[i] = new ExportMarkers.ExportMarker(); ExpMarkers.Markers[i].MarkerType = SelectedObjects[i].MarkerType; ExpMarkers.Markers[i].Pos = SelectedObjects[i].MarkerObj.Tr.localPosition; ExpMarkers.Markers[i].Rot = SelectedObjects[i].MarkerObj.Tr.localRotation; List <int> Connected = new List <int>(); for (int c = 0; c < SelectedObjects[i].AdjacentToMarker.Count; c++) { if (SelectedObjects.Contains(SelectedObjects[i].AdjacentToMarker[c])) { Connected.Add(SelectedObjects.IndexOf(SelectedObjects[i].AdjacentToMarker[c])); } } ExpMarkers.Markers[i].Connected = Connected.ToArray(); } System.IO.File.WriteAllText(paths, JsonUtility.ToJson(ExpMarkers)); } }
void OnEnable() { PathField.text = EnvPaths.GetInstalationPath(); MapsPathField.text = EnvPaths.GetMapsPath(); BackupPathField.text = EnvPaths.GetBackupPath(); PlayAs.value = GetFaction(); FogOfWar.isOn = GetFogOfWar(); }
public void BrowseMapPath() { var paths = StandaloneFileBrowser.OpenFolderPanel("Select 'Maps' folder.", EnvPaths.GetMapsPath(), false); if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0])) { MapsPathField.text = paths[0]; } }
void OnEnable() { PathField.text = EnvPaths.GetInstalationPath(); MapsPathField.text = EnvPaths.GetMapsPath(); BackupPathField.text = EnvPaths.GetBackupPath(); PlayAs.value = GetFaction(); FogOfWar.isOn = GetFogOfWar(); Markers2D.isOn = GetMarkers2D(); HeightmapClamp.isOn = GetHeightmapClamp(); }
public void SaveMapAs() { if (!MapLuaParser.IsMapLoaded) { return; } LateUpdate(); var paths = StandaloneFileBrowser.OpenFolderPanel("Save map as...", EnvPaths.GetMapsPath(), false); if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0])) { if (System.IO.Directory.GetDirectories(paths[0]).Length > 0 || System.IO.Directory.GetFiles(paths[0]).Length > 0) { Debug.LogWarning("Selected directory is not empty! " + paths[0]); GenericPopup.ShowPopup(GenericPopup.PopupTypes.Error, "Error", "Selected folder is not empty! Select empty folder.", "OK", null); return; } string[] PathSeparation = paths[0].Replace("\\", "/").Split("/".ToCharArray()); string FileBeginName = PathSeparation[PathSeparation.Length - 1].Replace(" ", "_"); //MapLuaParser.Current.ScenarioFileName = FileBeginName + "_scenario"; string NewFolderName = PathSeparation[PathSeparation.Length - 1]; NewFolderName = NewFolderName.Replace(" ", "_"); if (!NewFolderName.Contains(".v")) { NewFolderName += ".v0001"; MapLuaParser.Current.ScenarioLuaFile.Data.map_version = 1; } else { int MapVersion = 1; if (int.TryParse(NewFolderName.Remove(0, NewFolderName.Length - 4), out MapVersion)) { } MapLuaParser.Current.ScenarioLuaFile.Data.map_version = MapVersion; } SaveAsNewFolder(NewFolderName, FileBeginName); } }
public void ExportProceduralSkybox() { var extensions = new[] { new ExtensionFilter("Procedural skybox", "scmskybox") }; var path = StandaloneFileBrowser.SaveFilePanel("Export skybox", EnvPaths.GetMapsPath(), "", extensions); if (string.IsNullOrEmpty(path)) { return; } string DataString = JsonUtility.ToJson(Scmap.map.AdditionalSkyboxData); File.WriteAllText(path, DataString); }
public void ExportWater() { var extensions = new[] { new ExtensionFilter("Water settings", "scmwtr") }; var path = StandaloneFileBrowser.SaveFilePanel("Export water", EnvPaths.GetMapsPath(), "", extensions); if (string.IsNullOrEmpty(path)) { return; } string data = JsonUtility.ToJson(ScmapEditor.Current.map.Water); File.WriteAllText(path, data); }
public void ImportWaves() { var extensions = new[] { new ExtensionFilter("Waves settings", format) }; var paths = StandaloneFileBrowser.OpenFilePanel("Import waves", EnvPaths.GetMapsPath(), extensions, false); if (paths.Length <= 0 || string.IsNullOrEmpty(paths[0])) return; string data = File.ReadAllText(paths[0]); ScmapEditor.Current.map.WaveGenerators = JsonUtility.FromJson<List<WaveGenerator>>(data); }
public void ExportPropsSet() { var extensions = new[] { new ExtensionFilter("Props paint set", "proppaintset") }; var path = StandaloneFileBrowser.SaveFilePanel("Export props paint set", EnvPaths.GetMapsPath(), "", extensions); if (string.IsNullOrEmpty(path)) { return; } PaintButtonsSet PaintSet = new PaintButtonsSet(); PaintSet.PaintProps = new PaintButtonsSet.PaintProp[PaintButtons.Count]; for (int i = 0; i < PaintSet.PaintProps.Length; i++) { if (PaintPropObjects[i].BP == null) { Debug.Log("Prop object is empty!"); } PaintSet.PaintProps[i] = new PaintButtonsSet.PaintProp(); PaintSet.PaintProps[i].Blueprint = PaintPropObjects[i].BP.Path; PaintSet.PaintProps[i].ScaleMin = PaintButtons[RandomProp].ScaleMin.value; PaintSet.PaintProps[i].ScaleMax = PaintButtons[RandomProp].ScaleMin.value; PaintSet.PaintProps[i].RotationMin = PaintButtons[RandomProp].RotationMin.intValue; PaintSet.PaintProps[i].RotationMax = PaintButtons[RandomProp].RotationMax.intValue; PaintSet.PaintProps[i].Chance = PaintButtons[RandomProp].Chance.intValue; } string data = JsonUtility.ToJson(PaintSet); File.WriteAllText(path, data); }
public const uint HeightConversion = 256 * (256 + 64); //0xFFFF public void ExportHeightmap() { //string Filename = EnvPaths.GetMapsPath() + MapLuaParser.Current.FolderName + "/heightmap.raw"; //string Filename = EnvPaths.GetMapsPath() + MapLuaParser.Current.FolderName + "/heightmap.raw"; var extensions = new[] { new ExtensionFilter("Heightmap", new string[] { "raw" }), new ExtensionFilter("WM Heightmap", new string[] { "r16" }) //new ExtensionFilter("Stratum mask", "raw, bmp") }; var paths = StandaloneFileBrowser.SaveFilePanel("Import stratum mask", EnvPaths.GetMapsPath() + MapLuaParser.Current.FolderName, "heightmap", extensions); if (paths == null || string.IsNullOrEmpty(paths)) { return; } int h = ScmapEditor.Current.Teren.terrainData.heightmapHeight; int w = ScmapEditor.Current.Teren.terrainData.heightmapWidth; float[,] data = ScmapEditor.Current.Teren.terrainData.GetHeights(0, 0, w, h); using (BinaryWriter writer = new BinaryWriter(new System.IO.FileStream(paths, System.IO.FileMode.Create))) { for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { uint ThisPixel = (uint)(data[h - (y + 1), x] * HeightConversion); writer.Write(System.BitConverter.GetBytes(System.BitConverter.ToUInt16(System.BitConverter.GetBytes(ThisPixel), 0))); } } writer.Close(); } }
public void OpenMapProcess() { LateUpdate(); if (string.IsNullOrEmpty(StoreSelectedFile)) { var extensions = new[] { new ExtensionFilter("Scenario", "lua") }; var paths = StandaloneFileBrowser.OpenFilePanel("Open map", EnvPaths.GetMapsPath(), extensions, false); if (paths.Length > 0 && IsLuaFilePath(paths[0])) // && !string.IsNullOrEmpty(paths[0]) && IsScenarioPath(paths[0])) { StoreSelectedFile = paths[0]; } } LoadMapAtPath(StoreSelectedFile); }
public void ImportProceduralSkybox() { var extensions = new[] { new ExtensionFilter("Procedural skybox", "scmskybox") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import skybox", EnvPaths.GetMapsPath(), extensions, false); if (paths.Length == 0 || string.IsNullOrEmpty(paths[0])) { return; } string data = File.ReadAllText(paths[0]); Scmap.map.AdditionalSkyboxData = UnityEngine.JsonUtility.FromJson <SkyboxData>(data); Scmap.map.AdditionalSkyboxData.Data.UpdateSize(); Scmap.Skybox.LoadSkybox(); }
private static extern void SaveFileDialog(); //in your case : OpenFileDialog public void BrowseGamedataPath() { var paths = StandaloneFileBrowser.OpenFolderPanel("Select Forged Alliance instalation path", EnvPaths.GetMapsPath(), false); if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0])) { PathField.text = paths[0]; } }
public void SetMapFolderClicked() { var extensions = new[] { new ExtensionFilter("Scenario", "lua") }; var paths = StandaloneFileBrowser.OpenFilePanel("Select Scenario.lua of map to upload", EnvPaths.GetMapsPath(), extensions, false); if (paths.Length != 0 && paths[0] != null) { MapFolderPathInputField.SetValue(Path.GetDirectoryName(paths[0])); } }
public void ImportHeightmap() { var extensions = new[] { new ExtensionFilter("Heightmap", new string[] { "raw", "r16", "bmp" }) //new ExtensionFilter("Stratum mask", "raw, bmp") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import stratum mask", EnvPaths.GetMapsPath() + MapLuaParser.Current.FolderName, extensions, false); if (paths == null || paths.Length == 0 || string.IsNullOrEmpty(paths[0])) { return; } int h = ScmapEditor.Current.Teren.terrainData.heightmapHeight; int w = ScmapEditor.Current.Teren.terrainData.heightmapWidth; ScmapEditor.GetAllHeights(ref beginHeights); MapLuaParser.Current.History.RegisterTerrainHeightmapChange(beginHeights); float[,] data = new float[h, w]; //float[,] old = ScmapEditor.Current.Teren.terrainData.GetHeights(0, 0, w, h); if (paths[0].ToLower().EndsWith("bmp")) { BMPLoader loader = new BMPLoader(); BMPImage img = loader.LoadBMP(paths[0]); Debug.Log(img.info.compressionMethod + ", " + img.info.nBitsPerPixel + ", " + img.rMask + ", " + img.imageData[0].r); Texture2D ImportedImage = img.ToTexture2D(); if (ImportedImage.width != h || ImportedImage.height != w) { Debug.Log("Wrong size"); TextureScale.Bilinear(ImportedImage, h, w); ImportedImage.Apply(false); } Color[] ImportedColors = ImportedImage.GetPixels(); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { data[y, x] = (float)ImportedColors[x + y * w].r / 0.567f; // 0.58 } } } else { using (var file = System.IO.File.OpenRead(paths[0])) using (var reader = new System.IO.BinaryReader(file)) { for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { float v = (float)reader.ReadUInt16() / (float)HeightConversion; data[h - (y + 1), x] = v; } } } } //ScmapEditor.Current.Teren.terrainData.SetHeights(0, 0, data); ScmapEditor.SetAllHeights(data); RegenerateMaps(); OnTerrainChanged(); }
public void ExportWithSizeHeightmap() { int scale = int.Parse(TerrainScale.text); scale = Mathf.Clamp(scale, 129, 2049); //string Filename = EnvPaths.GetMapsPath() + MapLuaParser.Current.FolderName + "/heightmap.raw"; var extensions = new[] { new ExtensionFilter("Heightmap", new string[] { "raw" }) //new ExtensionFilter("Stratum mask", "raw, bmp") }; var paths = StandaloneFileBrowser.SaveFilePanel("Import stratum mask", EnvPaths.GetMapsPath() + MapLuaParser.Current.FolderName, "heightmap", extensions); if (paths == null || string.IsNullOrEmpty(paths)) { return; } float h = ScmapEditor.Current.Teren.terrainData.heightmapHeight; float w = ScmapEditor.Current.Teren.terrainData.heightmapWidth; float[,] data = ScmapEditor.Current.Teren.terrainData.GetHeights(0, 0, (int)w, (int)h); ExportAs = new Texture2D((int)w, (int)h, TextureFormat.RGB24, false, true); Debug.Log(w + ", " + h); float HeightValue = 1; HeightValue = float.Parse(TerrainScale_HeightValue.text); if (HeightValue < 0) { HeightValue = 1; } for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { float Value = data[y, x]; // / HeightConversion; if (TerrainScale_Height.isOn) { Value *= HeightValue; } //float ColorR = (Mathf.Floor(Value) * (1f / 255f)); //float ColorG = (Value - Mathf.Floor(Value)); ExportAs.SetPixel((int)(h - (y + 1)), x, new Color(Value, 0, 0)); } } ExportAs.Apply(); bool differentSize = w != scale || h != scale; h = scale; w = scale; using (BinaryWriter writer = new BinaryWriter(new System.IO.FileStream(paths, System.IO.FileMode.Create))) { Color pixel = Color.black; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { if (differentSize) { pixel = ExportAs.GetPixelBilinear(y / h, x / w); } else { pixel = ExportAs.GetPixel(y, x); } //float value = (pixel.r + pixel.g * (1f / 255f)); float value = pixel.r; uint ThisPixel = (uint)(value * HeightConversion); writer.Write(System.BitConverter.GetBytes(System.BitConverter.ToUInt16(System.BitConverter.GetBytes(ThisPixel), 0))); } } writer.Close(); } //ExportAs = null; }
public void SaveMapAs() { if (!MapLuaParser.IsMapLoaded) { return; } LateUpdate(); var paths = StandaloneFileBrowser.OpenFolderPanel("Save map as...", EnvPaths.GetMapsPath(), false); if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0])) { // If its the same folder, then its the same map if (paths[0].Replace("\\", "/") + "/" == MapLuaParser.LoadedMapFolderPath) { MapLuaParser.Current.SaveMap(); return; } string[] PathSeparation = paths[0].Replace("\\", "/").Split("/".ToCharArray()); string ChosenFolderName = PathSeparation[PathSeparation.Length - 1]; string NewFolderName = ChosenFolderName; NewFolderName = NewFolderName.Replace(" ", "_"); int ReplaceVersion = GetVersionControll(NewFolderName); if (ReplaceVersion <= 0) { ReplaceVersion = 1; // Map without versioning should always be v1 } //ReplaceVersion = (int)MapLuaParser.Current.ScenarioLuaFile.Data.map_version; NewFolderName = ForceVersionControllValue(NewFolderName, ReplaceVersion); string ChosenPath = ""; if (ChosenFolderName != NewFolderName) { // Combine system path using old separation and new folder name ChosenPath = ""; for (int i = 0; i < PathSeparation.Length - 1; i++) { ChosenPath += PathSeparation[i] + "/"; } ChosenPath += NewFolderName; // If selected folder does not exist, then remove wrong folder, and make a new, proper one if (!Directory.Exists(ChosenPath)) { Directory.CreateDirectory(ChosenPath); // Remove only when folder is empty if (Directory.GetFiles(paths[0]).Length <= 0 && System.IO.Directory.GetFiles(paths[0]).Length <= 0) { Directory.Delete(paths[0]); } } } else { ChosenPath = paths[0]; } string[] FilePaths = System.IO.Directory.GetFiles(ChosenPath); if (System.IO.Directory.GetDirectories(ChosenPath).Length > 0 || System.IO.Directory.GetFiles(ChosenPath).Length > 0) { Debug.LogWarning("Selected directory is not empty! " + ChosenPath); // Check if its a map folder foreach (string path in FilePaths) { // If contains any of the map files, then it need to be a map if (path.EndsWith("_scenario.lua") || path.EndsWith("_save.lua") || path.EndsWith(".scmap")) { OverwritePath = ChosenPath; GenericPopup.ShowPopup(GenericPopup.PopupTypes.TwoButton, "Folder is not empty!", "Overwrite map " + NewFolderName + "?\nThis can't be undone!", "Overwrite", OverwriteYes, "Cancel", null); return; } } // Not a map folder, return error to prevent data lose GenericPopup.ShowPopup(GenericPopup.PopupTypes.Error, "Error!", "Selected " + NewFolderName + " folder is not empty and it's not a map folder!", "OK", null); return; } System.IO.DirectoryInfo Dir = new DirectoryInfo(ChosenPath); MapLuaParser.Current.FolderParentPath = Dir.Parent.FullName.Replace("\\", "/") + "/"; Debug.Log(MapLuaParser.Current.FolderParentPath); if (SaveAsNewFolder(NewFolderName, NonVersionControlledName(NewFolderName))) { // Inform user, that map was saved into different folder than he chose if (ChosenFolderName != NewFolderName) { string LogText = "Wrong folder name: " + ChosenFolderName + "\n Instead saved as: " + NewFolderName; Debug.Log(LogText); GenericInfoPopup.ShowInfo(LogText); } } } }
public void ImportPropsSet() { var extensions = new[] { new ExtensionFilter("Props paint set", "proppaintset") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import props paint set", EnvPaths.GetMapsPath(), extensions, false); if (paths.Length <= 0 || string.IsNullOrEmpty(paths[0])) { return; } string data = File.ReadAllText(paths[0]); PaintButtonsSet PaintSet = JsonUtility.FromJson <PaintButtonsSet>(data); bool[] Exist = new bool[PaintPropObjects.Count]; for (int i = 0; i < PaintSet.PaintProps.Length; i++) { bool Found = false; int o = 0; for (o = 0; i < PaintPropObjects.Count; o++) { if (PaintPropObjects[i].BP.Path == PaintSet.PaintProps[i].Blueprint) { if (o < Exist.Length) { Exist[o] = true; } Found = true; break; } } if (!Found) { // Load if (!LoadProp(GetGamedataFile.LoadProp(PaintSet.PaintProps[i].Blueprint))) { Debug.LogWarning("Can't load prop at path: " + PaintSet.PaintProps[i].Blueprint); continue; } o = PaintButtons.Count - 1; } PaintButtons[o].ScaleMin.SetValue(PaintSet.PaintProps[i].ScaleMin); PaintButtons[o].ScaleMax.SetValue(PaintSet.PaintProps[i].ScaleMax); PaintButtons[o].RotationMin.SetValue(PaintSet.PaintProps[i].RotationMin); PaintButtons[o].RotationMax.SetValue(PaintSet.PaintProps[i].RotationMax); PaintButtons[o].Chance.SetValue(PaintSet.PaintProps[i].Chance); } for (int i = Exist.Length - 1; i >= 0; i--) { if (!Exist[i]) { RemoveProp(i); } } }
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(); } }