Skip to content

Commit

Permalink
WIP2 v0.602
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonexo3 committed Jul 5, 2018
1 parent 7445054 commit 8a02f02
Show file tree
Hide file tree
Showing 14 changed files with 386 additions and 256 deletions.
69 changes: 32 additions & 37 deletions Assets/MapEditor.unity
Original file line number Diff line number Diff line change
Expand Up @@ -31959,11 +31959,6 @@ Prefab:
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 114411632476451918, guid: 0ff6c6aab7f2d344db85e67f50ac652a,
type: 2}
propertyPath: SearchForNew
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 0ff6c6aab7f2d344db85e67f50ac652a, type: 2}
m_IsPrefabParent: 0
Expand Down Expand Up @@ -39554,7 +39549,7 @@ Camera:
serializedVersion: 2
m_Bits: 2560
m_RenderingPath: 1
m_TargetTexture: {fileID: 661924484}
m_TargetTexture: {fileID: 1441693371}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
Expand Down Expand Up @@ -47621,37 +47616,6 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 661218095}
--- !u!84 &661924484
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 &662120011
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -103546,6 +103510,37 @@ RectTransform:
m_PrefabParentObject: {fileID: 224414395284792190, guid: 0cbe5a6c3afdfd147a4011b19eead070,
type: 2}
m_PrefabInternal: {fileID: 1439314567}
--- !u!84 &1441693371
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 &1444107165
GameObject:
m_ObjectHideFlags: 0
Expand Down
7 changes: 4 additions & 3 deletions Assets/Prefabs/UI/Background.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "Thanks to: HazardX, duck_42, Rogueleader89, partytime, Visionik, \ncookienoob,
morax, svenni_badbwoi, speed2, MarLo, Sid"
m_Text: "Thanks to: HazardX, duck_42, Rogueleader89, partytime, Visionik, \nmorax,
svenni_badbwoi, speed2, MarLo, Sid"
--- !u!114 &114371249506239228
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -387,6 +387,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 77dae3e9d1d43134494f50e13c246809, type: 3}
m_Name:
m_EditorClassIdentifier:
SearchForNew: 1
url: https://github.com/ozonexo3/FAForeverMapEditor/releases/latest
--- !u!114 &114458297912229174
MonoBehaviour:
Expand Down Expand Up @@ -744,7 +745,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: 0, y: 6}
m_AnchoredPosition: {x: 0, y: 10}
m_SizeDelta: {x: -480, y: 80}
m_Pivot: {x: 0.5, y: 0}
--- !u!224 &224625258359089646
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.601-Alpha";
public const float VersionOffset = 0f; // Release
//public const float VersionOffset = -0.001f; // Prerelease
public const string EditorBuildVersion = "v0.602-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
207 changes: 2 additions & 205 deletions Assets/Scripts/UI/AppMenu/AppMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using B83.Win32;
using System.IO;

public class AppMenu : MonoBehaviour
public partial class AppMenu : MonoBehaviour
{

public GameObject Symmetry;
Expand All @@ -31,6 +31,7 @@ public class AppMenu : MonoBehaviour
UnityDragAndDropHook hook;
void OnEnable()
{
Application.targetFrameRate = 60;
// must be created on the main thread to get the right thread id.
hook = new UnityDragAndDropHook();
hook.InstallHook();
Expand Down Expand Up @@ -488,209 +489,5 @@ public void OpenNewMapCancel()
}
#endregion

#region SaveAs
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 SaveAsNewVersion()
{
int NextVersion = (int)MapLuaParser.Current.ScenarioLuaFile.Data.map_version + 1;

GenericPopup.ShowPopup(GenericPopup.PopupTypes.TwoButton, "Create new version", "Create version " + NextVersion + " of this map?", "Yes", SaveAsNewVersionYes, "No", null);
}

public void SaveAsNewVersionYes()
{
MapLuaParser.Current.ScenarioLuaFile.Data.map_version++;

string DeltaFolderName = MapLuaParser.Current.FolderName;
string NewFolderName = "";
if (DeltaFolderName.ToLower().Contains(".v"))
{
for (int i = 0; i < DeltaFolderName.Length; i++)
{
if (DeltaFolderName.ToLower().StartsWith(".v"))
{
break;
}
else
{
NewFolderName += DeltaFolderName[i];
DeltaFolderName = DeltaFolderName.Remove(0, 1);
i--;
}
}
}
else
{
NewFolderName = MapLuaParser.Current.FolderName;
}

NewFolderName += ".v" + ((int)MapLuaParser.Current.ScenarioLuaFile.Data.map_version).ToString("0000");

if (SaveAsNewFolder(NewFolderName))
{

}
else
{
// Error! Revert changes
MapLuaParser.Current.ScenarioLuaFile.Data.map_version--;
}

}

bool SaveAsNewFolder(string NewFolderName, string FileBeginName = "")
{
string SystemPath = MapLuaParser.Current.FolderParentPath + NewFolderName;

if (!System.IO.Directory.Exists(SystemPath))
{
System.IO.Directory.CreateDirectory(SystemPath);
}
else if(System.IO.Directory.GetFiles(SystemPath + "/").Length <= 0)
{

}
else
{
GenericPopup.ShowPopup(GenericPopup.PopupTypes.Error, "Error", "Next map version folder already exist.\nRemove it or load never version.", "OK", null);

return false;
}

string OldFolderName = MapLuaParser.Current.FolderName;

MapLuaParser.Current.FolderName = NewFolderName;


string OldScript = MapLuaParser.Current.ScenarioLuaFile.Data.script.Replace("/maps/", MapLuaParser.Current.FolderParentPath);
string OldOptionsFile = OldScript.Replace("_script.lua", "_options.lua");

if (string.IsNullOrEmpty(FileBeginName))
{
FileBeginName = MapLuaParser.Current.ScenarioFileName.Replace("_scenario", "");
}
else
{
MapLuaParser.Current.ScenarioFileName = FileBeginName + "_scenario";
}

MapLuaParser.Current.ScenarioLuaFile.Data.map = "/maps/" + MapLuaParser.Current.FolderName + "/" + FileBeginName + ".scmap";
MapLuaParser.Current.ScenarioLuaFile.Data.save = "/maps/" + MapLuaParser.Current.FolderName + "/" + FileBeginName + "_save.lua";
MapLuaParser.Current.ScenarioLuaFile.Data.script = "/maps/" + MapLuaParser.Current.FolderName + "/" + FileBeginName + "_script.lua";
MapLuaParser.Current.ScenarioLuaFile.Data.preview = "";

LoadRecentMaps.MoveLastMaps(MapLuaParser.Current.ScenarioFileName, MapLuaParser.Current.FolderName, MapLuaParser.Current.FolderParentPath);

string EnvPath = MapLuaParser.Current.FolderParentPath + OldFolderName + "/env";
if (System.IO.Directory.Exists(EnvPath))
{
DirectoryCopy(EnvPath, MapLuaParser.Current.FolderParentPath + NewFolderName + "/env", true);
}

MapLuaParser.Current.SaveMap(false);

string LoadScript = System.IO.File.ReadAllText(OldScript);
//Replace old folder name to new one
LoadScript = LoadScript.Replace(OldFolderName + "/", NewFolderName + "/");
System.IO.File.WriteAllText(MapLuaParser.Current.ScenarioLuaFile.Data.script.Replace("/maps/", MapLuaParser.Current.FolderParentPath), LoadScript);

//System.IO.File.Copy(OldScript, MapLuaParser.Current.ScenarioLuaFile.Data.script.Replace("/maps/", MapLuaParser.Current.FolderParentPath));

if (System.IO.File.Exists(OldOptionsFile))
{ // Found options, copy it
System.IO.File.Copy(OldOptionsFile, MapLuaParser.Current.ScenarioLuaFile.Data.script.Replace("/maps/", MapLuaParser.Current.FolderParentPath).Replace("_script.lua", "_options.lua"));
}

EditingMenu.MapInfoMenu.UpdateFields();
WindowStateSever.WindowStateSaver.ChangeWindowName(NewFolderName);

return true;
}

private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourceDirName);

if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
+ sourceDirName);
}

DirectoryInfo[] dirs = dir.GetDirectories();
// If the destination directory doesn't exist, create it.
if (!Directory.Exists(destDirName))
{
Directory.CreateDirectory(destDirName);
}

// Get the files in the directory and copy them to the new location.
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
string temppath = Path.Combine(destDirName, file.Name);
file.CopyTo(temppath, false);
}

// If copying subdirectories, copy them and their contents to new location.
if (copySubDirs)
{
foreach (DirectoryInfo subdir in dirs)
{
string temppath = Path.Combine(destDirName, subdir.Name);
DirectoryCopy(subdir.FullName, temppath, copySubDirs);
}
}
}
#endregion
}
Loading

0 comments on commit 8a02f02

Please sign in to comment.