Skip to content

Commit

Permalink
WIP1 v0.603
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonexo3 committed Jul 7, 2018
1 parent cf7f411 commit 31de9df
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 72 deletions.
64 changes: 32 additions & 32 deletions Assets/MapEditor.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Assets/Prefabs/UI/Background.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/Common/EditorVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
108 changes: 81 additions & 27 deletions Assets/Scripts/UI/AppMenu/AppMenu_SaveAs.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 10 additions & 2 deletions Assets/Scripts/UI/ResourceBrowser/ResourceBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/UI/Tools/Decals/DecalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ public void DropTex1()
Loaded.UpdateMaterial();
Load(Loaded);
DecalsInfo.Current.DecalsList.OnTexturesChanged();
ResourceBrowser.ClearDrag();
}
}

Expand All @@ -362,6 +363,7 @@ public void DropTex2()
Loaded.UpdateMaterial();
Load(Loaded);
DecalsInfo.Current.DecalsList.OnTexturesChanged();
ResourceBrowser.ClearDrag();
}
}

Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/UI/Tools/Decals/DecalsInfo_UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/UI/Tools/PropsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ public void DropProp()
if (ResourceBrowser.SelectedCategory == 3)
{
LoadProp(ResourceBrowser.Current.LoadedProps[ResourceBrowser.DragedObject.InstanceId]);
ResourceBrowser.ClearDrag();
}
}
}
Expand Down
19 changes: 13 additions & 6 deletions Assets/Scripts/UI/Tools/Stratum/StratumInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand All @@ -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);
Expand All @@ -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]);
Expand All @@ -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);
Expand Down Expand Up @@ -993,11 +1005,6 @@ void SetChannelByLayer(int layer, ref Color color, float channel)

#endregion

#region Reorder


#endregion


#region Import/Export

Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/UI/Tools/Units/UnitsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void GoToSelection()
{

PlacementManager.Clear();

SelectionManager.Current.CleanSelection();

int[] AllTypes;
AllObjects = UnitInstance.GetAllUnitGo(out AllTypes);
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/UI/Tools/Units/UnitsInfo_Units.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GameObject> MarkerObjects, bool RegisterUndo = true)
Expand Down

0 comments on commit 31de9df

Please sign in to comment.