diff --git a/Assets/MapEditor.unity b/Assets/MapEditor.unity index c031f0d9..252370e1 100644 --- a/Assets/MapEditor.unity +++ b/Assets/MapEditor.unity @@ -12574,37 +12574,6 @@ MonoBehaviour: TitleDescPrefab: {fileID: 2105485392} ArmyTooglePivot: {fileID: 2105995003} CustomTablesPivot: {fileID: 1982893595} ---- !u!84 &173196709 -RenderTexture: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: - m_ImageContentsHash: - serializedVersion: 2 - Hash: 00000000000000000000000000000000 - m_ForcedFallbackFormat: 4 - m_DownscaleFallback: 0 - m_Width: 256 - m_Height: 256 - m_AntiAliasing: 1 - m_DepthFormat: 1 - m_ColorFormat: 0 - m_MipMap: 0 - m_GenerateMips: 1 - m_SRGB: 0 - m_UseDynamicScale: 0 - m_BindMS: 0 - m_TextureSettings: - serializedVersion: 2 - m_FilterMode: 1 - m_Aniso: 0 - m_MipBias: 0 - m_WrapU: 1 - m_WrapV: 1 - m_WrapW: 1 - m_Dimension: 2 - m_VolumeDepth: 1 --- !u!1 &173528956 GameObject: m_ObjectHideFlags: 0 @@ -39764,7 +39733,7 @@ Camera: serializedVersion: 2 m_Bits: 2560 m_RenderingPath: 1 - m_TargetTexture: {fileID: 173196709} + m_TargetTexture: {fileID: 1650333357} m_TargetDisplay: 0 m_TargetEye: 3 m_HDR: 0 @@ -119236,6 +119205,37 @@ MonoBehaviour: m_FlexibleWidth: -1 m_FlexibleHeight: -1 m_LayoutPriority: 1 +--- !u!84 &1650333357 +RenderTexture: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + m_Width: 256 + m_Height: 256 + m_AntiAliasing: 1 + m_DepthFormat: 1 + m_ColorFormat: 0 + m_MipMap: 0 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 --- !u!1 &1652382937 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/UI/Background.prefab b/Assets/Prefabs/UI/Background.prefab index b2671833..6189e266 100644 --- a/Assets/Prefabs/UI/Background.prefab +++ b/Assets/Prefabs/UI/Background.prefab @@ -320,7 +320,7 @@ MonoBehaviour: m_VerticalOverflow: 0 m_LineSpacing: 1 m_Text: "Thanks to: HazardX, duck_42, Rogueleader89, partytime, Visionik, \nmorax, - svenni_badbwoi, speed2, MarLo, Sid" + svenni_badbwoi, speed2, MarLo, Sid, Spy Emanciator" --- !u!114 &114371249506239228 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Assets/Scripts/Common/EditorVersion.cs b/Assets/Scripts/Common/EditorVersion.cs index 5c04552a..b257f8a6 100644 --- a/Assets/Scripts/Common/EditorVersion.cs +++ b/Assets/Scripts/Common/EditorVersion.cs @@ -6,9 +6,9 @@ public class EditorVersion : MonoBehaviour { - public const string EditorBuildVersion = "v0.602-Alpha"; - public const float VersionOffset = 0f; // Release - //public const float VersionOffset = -0.001f; // Prerelease + public const string EditorBuildVersion = "v0.603-Alpha"; + //public const float VersionOffset = 0f; // Release + public const float VersionOffset = -0.001f; // Prerelease //public const float VersionOffset = 0.523f - 0.600f; // Prerelease v0600 public static string LatestTag = ""; public static string FoundUrl; diff --git a/Assets/Scripts/UI/AppMenu/AppMenu_SaveAs.cs b/Assets/Scripts/UI/AppMenu/AppMenu_SaveAs.cs index 9037a1d2..12d3a740 100644 --- a/Assets/Scripts/UI/AppMenu/AppMenu_SaveAs.cs +++ b/Assets/Scripts/UI/AppMenu/AppMenu_SaveAs.cs @@ -1,13 +1,5 @@ using UnityEngine; -using UnityEngine.UI; -using System.Collections; -using System.Collections.Generic; -using EditMap; -using System.Text; -using System.Runtime.InteropServices; using SFB; -using System.Linq; -using B83.Win32; using System.IO; public partial class AppMenu : MonoBehaviour @@ -26,50 +18,112 @@ public void SaveMapAs() 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) + // If its the same folder, then its the same map + if (paths[0].Replace("\\", "/") + "/" == MapLuaParser.LoadedMapFolderPath) { - 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); + 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) + 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) { - Debug.Log("Replace version: " + ReplaceVersion); - MapLuaParser.Current.ScenarioLuaFile.Data.map_version = ReplaceVersion; + // 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 { - MapLuaParser.Current.ScenarioLuaFile.Data.map_version = 1; + ChosenPath = paths[0]; } - NewFolderName = ForceVersionControllValue(NewFolderName, (int)MapLuaParser.Current.ScenarioLuaFile.Data.map_version); - string FileBeginName = NonVersionControlledName(NewFolderName); + 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; + } - if(SaveAsNewFolder(NewFolderName, FileBeginName)) + if(SaveAsNewFolder(NewFolderName, NonVersionControlledName(NewFolderName))) { - if(ChosenFolderName != 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; + string LogText = "Wrong folder name: " + ChosenFolderName + "\n Instead saved as: " + NewFolderName; Debug.Log(LogText); GenericInfoPopup.ShowInfo(LogText); - } - } } } + static string OverwritePath = ""; + void OverwriteYes() + { + Debug.Log("Overwrite path: " + OverwritePath); + + // Remove files from folder + string[] FilePaths = System.IO.Directory.GetFiles(OverwritePath); + foreach (string path in FilePaths) + { + File.Delete(path); + } + + // Remove directories from folder + string[] DirPaths = System.IO.Directory.GetDirectories(OverwritePath); + foreach (string path in DirPaths) + { + Directory.Delete(path, true); + } + + // Now we can save to clean folder + SaveAsNewFolder(OverwritePath, NonVersionControlledName(OverwritePath)); + } + + public void SaveAsNewVersion() { int NextVersion = (int)MapLuaParser.Current.ScenarioLuaFile.Data.map_version + 1; @@ -111,7 +165,7 @@ bool SaveAsNewFolder(string NewFolderName, string FileBeginName = "") } else { - GenericPopup.ShowPopup(GenericPopup.PopupTypes.Error, "Error", "Next map version folder already exist.\nRemove it or load never version.", "OK", null); + GenericPopup.ShowPopup(GenericPopup.PopupTypes.Error, "Error", "Trying to save map, but folder " + NewFolderName + " is not empty!\nSave as can be only used for empty folders.", "OK", null); return false; } diff --git a/Assets/Scripts/UI/ResourceBrowser/ResourceBrowser.cs b/Assets/Scripts/UI/ResourceBrowser/ResourceBrowser.cs index e4f5b7a1..f42fda26 100644 --- a/Assets/Scripts/UI/ResourceBrowser/ResourceBrowser.cs +++ b/Assets/Scripts/UI/ResourceBrowser/ResourceBrowser.cs @@ -80,15 +80,23 @@ public static bool IsProp() #region UI - void Update() + void LateUpdate() { if (Input.GetMouseButtonUp(0)) { if (DragedObject) - Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); + { + ResourceBrowser.ClearDrag(); + } } } + public static void ClearDrag() + { + Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); + DragedObject = null; + } + public void OnDropdownChanged() { if (!gameObject.activeSelf || CustomLoading) diff --git a/Assets/Scripts/UI/Tools/Decals/DecalSettings.cs b/Assets/Scripts/UI/Tools/Decals/DecalSettings.cs index a49e93f6..b5b0fbf4 100644 --- a/Assets/Scripts/UI/Tools/Decals/DecalSettings.cs +++ b/Assets/Scripts/UI/Tools/Decals/DecalSettings.cs @@ -345,6 +345,7 @@ public void DropTex1() Loaded.UpdateMaterial(); Load(Loaded); DecalsInfo.Current.DecalsList.OnTexturesChanged(); + ResourceBrowser.ClearDrag(); } } @@ -362,6 +363,7 @@ public void DropTex2() Loaded.UpdateMaterial(); Load(Loaded); DecalsInfo.Current.DecalsList.OnTexturesChanged(); + ResourceBrowser.ClearDrag(); } } diff --git a/Assets/Scripts/UI/Tools/Decals/DecalsInfo_UI.cs b/Assets/Scripts/UI/Tools/Decals/DecalsInfo_UI.cs index 585d2ee6..f359fa61 100644 --- a/Assets/Scripts/UI/Tools/Decals/DecalsInfo_UI.cs +++ b/Assets/Scripts/UI/Tools/Decals/DecalsInfo_UI.cs @@ -22,6 +22,7 @@ public void DropAtDecals() { return; string DropPath = ResourceBrowser.Current.LoadedPaths[ResourceBrowser.DragedObject.InstanceId]; + ResourceBrowser.ClearDrag(); if (!DropPath.StartsWith("/")) { DropPath = DropPath.ToLower().Replace("env", "/env"); diff --git a/Assets/Scripts/UI/Tools/PropsInfo.cs b/Assets/Scripts/UI/Tools/PropsInfo.cs index 68e961da..769a84d1 100644 --- a/Assets/Scripts/UI/Tools/PropsInfo.cs +++ b/Assets/Scripts/UI/Tools/PropsInfo.cs @@ -392,6 +392,7 @@ public void DropProp() if (ResourceBrowser.SelectedCategory == 3) { LoadProp(ResourceBrowser.Current.LoadedProps[ResourceBrowser.DragedObject.InstanceId]); + ResourceBrowser.ClearDrag(); } } } diff --git a/Assets/Scripts/UI/Tools/Stratum/StratumInfo.cs b/Assets/Scripts/UI/Tools/Stratum/StratumInfo.cs index 4c5b9e4e..d3f8dffe 100644 --- a/Assets/Scripts/UI/Tools/Stratum/StratumInfo.cs +++ b/Assets/Scripts/UI/Tools/Stratum/StratumInfo.cs @@ -885,6 +885,12 @@ public void SelectAlbedo() return; if (ResourceBrowser.SelectedCategory == 0 || ResourceBrowser.SelectedCategory == 1) { + if (ResourceBrowser.Current.LoadedPaths[ResourceBrowser.DragedObject.InstanceId].ToLower().Contains("normal")) + { + GenericInfoPopup.ShowInfo("Can't assign normal map as albedo!"); + return; + } + Undo.RegisterUndo(new UndoHistory.HistoryStratumChange(), new UndoHistory.HistoryStratumChange.StratumChangeHistoryParameter(Selected)); Debug.Log(ResourceBrowser.Current.LoadedPaths[ResourceBrowser.DragedObject.InstanceId]); @@ -893,7 +899,7 @@ public void SelectAlbedo() //Map.map.Layers [Selected].PathTexture = Map.Textures [Selected].AlbedoPath; - + ResourceBrowser.ClearDrag(); ScmapEditor.Current.SetTextures(Selected); ReloadStratums(); SelectStratum(Selected); @@ -909,6 +915,11 @@ public void SelectNormal() return; if (ResourceBrowser.SelectedCategory == 0 || ResourceBrowser.SelectedCategory == 1) { + if (!ResourceBrowser.Current.LoadedPaths[ResourceBrowser.DragedObject.InstanceId].ToLower().Contains("normal")) + { + GenericInfoPopup.ShowInfo("Can't assign albedo as normal map!"); + return; + } Undo.RegisterUndo(new UndoHistory.HistoryStratumChange(), new UndoHistory.HistoryStratumChange.StratumChangeHistoryParameter(Selected)); Debug.Log(ResourceBrowser.Current.LoadedPaths[ResourceBrowser.DragedObject.InstanceId]); @@ -920,6 +931,7 @@ public void SelectNormal() //Map.map.Layers [Selected].PathNormalmap = Map.Textures [Selected].NormalPath; + ResourceBrowser.ClearDrag(); ScmapEditor.Current.SetTextures(Selected); ReloadStratums(); SelectStratum(Selected); @@ -993,11 +1005,6 @@ void SetChannelByLayer(int layer, ref Color color, float channel) #endregion - #region Reorder - - - #endregion - #region Import/Export diff --git a/Assets/Scripts/UI/Tools/Units/UnitsInfo.cs b/Assets/Scripts/UI/Tools/Units/UnitsInfo.cs index f733beea..f221cff3 100644 --- a/Assets/Scripts/UI/Tools/Units/UnitsInfo.cs +++ b/Assets/Scripts/UI/Tools/Units/UnitsInfo.cs @@ -99,7 +99,7 @@ public void GoToSelection() { PlacementManager.Clear(); - + SelectionManager.Current.CleanSelection(); int[] AllTypes; AllObjects = UnitInstance.GetAllUnitGo(out AllTypes); diff --git a/Assets/Scripts/UI/Tools/Units/UnitsInfo_Units.cs b/Assets/Scripts/UI/Tools/Units/UnitsInfo_Units.cs index 518497bf..f1fc9869 100644 --- a/Assets/Scripts/UI/Tools/Units/UnitsInfo_Units.cs +++ b/Assets/Scripts/UI/Tools/Units/UnitsInfo_Units.cs @@ -40,6 +40,7 @@ public void OnDropUnit() UnitBg.texture = UnitBrowser.IconBackgrounds[SelectedUnit.Icon]; UnitIcon.texture = UnitBrowser.GetDragUnitIcon(); UnitIcon.enabled = UnitIcon.texture != Texture2D.whiteTexture; + ResourceBrowser.ClearDrag(); } public void DestroyUnits(List MarkerObjects, bool RegisterUndo = true)