Skip to content

Commit a20ca0e

Browse files
committed
Merge branch 'beta'
2 parents a192de5 + 10754af commit a20ca0e

File tree

257 files changed

+993
-13127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+993
-13127
lines changed

Assets/Facepunch/RustWorldSDK/WorldSerialization.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ public void Save(string fileName)
186186
binaryWriter.Write(Version);
187187

188188
using (var compressionStream = new LZ4Stream(fileStream, LZ4StreamMode.Compress))
189-
{
190189
Serializer.Serialize(compressionStream, world);
191-
}
192190
}
193191
}
194192
}
@@ -209,13 +207,10 @@ public void Load(string fileName)
209207
Version = binaryReader.ReadUInt32();
210208

211209
if (Version != CurrentVersion)
212-
{
213210
Debug.LogWarning("Map Version is: " + Version + " whilst Rust is on: " + CurrentVersion);
214-
}
211+
215212
using (var compressionStream = new LZ4Stream(fileStream, LZ4StreamMode.Decompress))
216-
{
217213
world = Serializer.Deserialize<WorldData>(compressionStream);
218-
}
219214
}
220215
}
221216
}

Assets/MapEditor/Editor/API/Functions.cs

Lines changed: 28 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,13 @@
11
using System;
2-
using Rotorz.ReorderableList;
32
using UnityEngine;
43
using UnityEditor;
54
using RustMapEditor.Variables;
6-
using static RustMapEditor.Data.TerrainManager;
5+
using static TerrainManager;
76

87
namespace RustMapEditor.UI
98
{
109
public static class Functions
1110
{
12-
#region Menu Items
13-
[MenuItem("Rust Map Editor/Main Menu", false, 0)]
14-
public static void OpenMainMenu()
15-
{
16-
MapManagerWindow window = (MapManagerWindow)EditorWindow.GetWindow(typeof(MapManagerWindow), false, "Rust Map Editor");
17-
}
18-
19-
[MenuItem("Rust Map Editor/Hierachy/Prefabs", false, 1)]
20-
static void OpenPrefabHierachy()
21-
{
22-
PrefabHierachyWindow window = (PrefabHierachyWindow)EditorWindow.GetWindow(typeof(PrefabHierachyWindow), false, "Prefab Hierachy");
23-
}
24-
25-
[MenuItem("Rust Map Editor/Hierachy/Paths", false, 1)]
26-
static void OpenPathHierachy()
27-
{
28-
PathHierachyWindow window = (PathHierachyWindow)EditorWindow.GetWindow(typeof(PathHierachyWindow), false, "Path Hierachy");
29-
}
30-
31-
[MenuItem("Rust Map Editor/Prefabs", false, 1)]
32-
static void OpenPrefabsList()
33-
{
34-
PrefabsListWindow window = (PrefabsListWindow)EditorWindow.GetWindow(typeof(PrefabsListWindow), false, "Prefabs List");
35-
}
36-
37-
[MenuItem("Rust Map Editor/Terrain Tools", false, 2)]
38-
public static void OpenTerrainTools()
39-
{
40-
Selection.activeGameObject = Land.gameObject;
41-
}
42-
43-
[MenuItem("Rust Map Editor/Links/Wiki", false, 10)]
44-
public static void OpenWiki()
45-
{
46-
Application.OpenURL("https://github.com/RustMapMaking/Editor/wiki");
47-
}
48-
49-
[MenuItem("Rust Map Editor/Links/Discord", false, 10)]
50-
public static void OpenDiscord()
51-
{
52-
Application.OpenURL("https://discord.gg/HPmTWVa");
53-
}
54-
55-
[MenuItem("Rust Map Editor/Links/RoadMap", false, 10)]
56-
public static void OpenRoadMap()
57-
{
58-
Application.OpenURL("https://github.com/RustMapMaking/Editor/projects/1");
59-
}
60-
61-
[MenuItem("Rust Map Editor/Links/Report Bug", false, 10)]
62-
public static void OpenReportBug()
63-
{
64-
Application.OpenURL("https://github.com/RustMapMaking/Editor/issues/new?assignees=Adsito&labels=bug&template=bug-report.md&title=%5BBUG%5D+Bug+name+goes+here");
65-
}
66-
67-
[MenuItem("Rust Map Editor/Links/Request Feature", false, 10)]
68-
public static void OpenRequestFeature()
69-
{
70-
Application.OpenURL("https://github.com/RustMapMaking/Editor/issues/new?assignees=Adsito&labels=enhancement&template=feature-request.md&title=%5BREQUEST%5D+Request+name+goes+here");
71-
}
72-
#endregion
73-
7411
#region MainMenu
7512
public static void EditorIO(string mapName = "custommap")
7613
{
@@ -151,20 +88,21 @@ public static void EditorLinks()
15188

15289
Elements.BeginToolbarHorizontal();
15390
if (Elements.ToolbarButton(ToolTips.reportBug))
154-
OpenReportBug();
91+
ShortcutManager.OpenReportBug();
15592
if (Elements.ToolbarButton(ToolTips.requestFeature))
156-
OpenRequestFeature();
93+
ShortcutManager.OpenRequestFeature();
15794
if (Elements.ToolbarButton(ToolTips.roadMap))
158-
OpenRoadMap();
95+
ShortcutManager.OpenRoadMap();
15996
Elements.EndToolbarHorizontal();
16097

16198
Elements.BeginToolbarHorizontal();
16299
if (Elements.ToolbarButton(ToolTips.wiki))
163-
OpenWiki();
100+
ShortcutManager.OpenWiki();
164101
if (Elements.ToolbarButton(ToolTips.discord))
165-
OpenDiscord();
102+
ShortcutManager.OpenDiscord();
166103
Elements.EndToolbarHorizontal();
167104
}
105+
168106
public static void EditorSettings()
169107
{
170108
Elements.BoldLabel(ToolTips.editorSettingsLabel);
@@ -199,15 +137,15 @@ public static void EditorSettings()
199137
SettingsManager.PathRenderDistance = Elements.ToolbarSlider(ToolTips.pathRenderDistance, SettingsManager.PathRenderDistance, 0, 5000f);
200138

201139
if (EditorGUI.EndChangeCheck())
202-
MapManager.SetCullingDistances(SceneView.GetAllSceneCameras(), SettingsManager.PrefabRenderDistance, SettingsManager.PathRenderDistance);
140+
SceneManager.SetCullingDistances(SceneView.GetAllSceneCameras(), SettingsManager.PrefabRenderDistance, SettingsManager.PathRenderDistance);
203141

204142
EditorGUI.BeginChangeCheck();
205143
SettingsManager.WaterTransparency = Elements.ToolbarSlider(ToolTips.waterTransparency, SettingsManager.WaterTransparency, 0f, 0.5f);
206144
if (EditorGUI.EndChangeCheck())
207145
SetWaterTransparency(SettingsManager.WaterTransparency);
208146

209147
Elements.BeginToolbarHorizontal();
210-
SettingsManager.LoadBundleOnProjectLoad = Elements.ToolbarCheckBox(ToolTips.loadBundleOnProjectLoad, SettingsManager.LoadBundleOnProjectLoad);
148+
SettingsManager.LoadBundleOnLaunch = Elements.ToolbarCheckBox(ToolTips.loadBundleOnProjectLoad, SettingsManager.LoadBundleOnLaunch);
211149
Elements.EndToolbarHorizontal();
212150

213151
}
@@ -238,27 +176,6 @@ public static void AssetBundle()
238176
}
239177
#endregion
240178

241-
#region Generation Tools
242-
public static void NodePresets(Vector2 presetScrollPos)
243-
{
244-
Elements.BoldLabel(ToolTips.presetsLabel);
245-
246-
Elements.BeginToolbarHorizontal();
247-
if (Elements.ToolbarButton(ToolTips.refreshPresets))
248-
MapManager.RefreshPresetsList();
249-
Elements.EndToolbarHorizontal();
250-
251-
presetScrollPos = GUILayout.BeginScrollView(presetScrollPos);
252-
ReorderableListGUI.Title("Node Presets");
253-
ReorderableListGUI.ListField(MapManager.generationPresetList, NodePresetDrawer, DrawEmpty);
254-
GUILayout.EndScrollView();
255-
}
256-
public static void DrawEmpty()
257-
{
258-
Elements.MiniLabel(ToolTips.noPresets);
259-
}
260-
#endregion
261-
262179
#region MapTools
263180
#region HeightMap
264181
public static void TerraceMap(ref float terraceErodeFeatureSize, ref float terraceErodeInteriorCornerWeight)
@@ -739,24 +656,6 @@ public static void BreakPrefab(PrefabDataHolder target)
739656
#endregion
740657

741658
#region Functions
742-
public static string NodePresetDrawer(Rect position, string itemValue)
743-
{
744-
position.width -= 39;
745-
GUI.Label(position, itemValue);
746-
position.x = position.xMax;
747-
position.width = 39;
748-
if (GUI.Button(position, ToolTips.openPreset, EditorStyles.toolbarButton))
749-
{
750-
MapManager.RefreshPresetsList();
751-
MapManager.nodePresetLookup.TryGetValue(itemValue, out UnityEngine.Object preset);
752-
if (preset != null)
753-
AssetDatabase.OpenAsset(preset.GetInstanceID());
754-
else
755-
Debug.LogError("The preset you are trying to open is null.");
756-
}
757-
return itemValue;
758-
}
759-
760659
/// <summary>Sets the active landLayer to the index.</summary>
761660
/// <param name="landIndex">The landLayer to change to.</param>
762661
/// <param name="topology">The Topology layer to set.</param>
@@ -785,55 +684,43 @@ public static HeightsInfo ClampValues(HeightsInfo info)
785684

786685
public static void ReloadTreeViews()
787686
{
788-
PrefabHierachyWindow.ReloadTree();
789-
PathHierachyWindow.ReloadTree();
687+
PrefabHierarchyWindow.ReloadTree();
688+
PathHierarchyWindow.ReloadTree();
790689
}
791-
#endregion
792690

793-
#region NodeGraph
794-
public static void NodeGraphToolbar(XNode.NodeGraph nodeGraph)
691+
public static void CopyText(string text)
795692
{
796-
Elements.BeginToolbarHorizontal();
797-
if (Elements.ToolbarButton(ToolTips.runPreset))
798-
NodeAsset.Parse(nodeGraph);
799-
if (Elements.ToolbarButton(ToolTips.deletePreset))
800-
{
801-
if (EditorUtility.DisplayDialog("Delete Preset", "Are you sure you wish to delete this preset? Once deleted it can't be undone.", "Ok", "Cancel"))
802-
{
803-
XNodeEditor.NodeEditorWindow.focusedWindow.Close();
804-
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(nodeGraph));
805-
MapManager.RefreshPresetsList();
806-
}
807-
}
808-
if (Elements.ToolbarButton(ToolTips.renamePreset))
809-
XNodeEditor.RenamePreset.Show(nodeGraph);
810-
if (Elements.ToolbarButton(ToolTips.presetWiki))
811-
Application.OpenURL("https://github.com/RustMapMaking/Rust-Map-Editor-Unity/wiki/Node-System");
812-
Elements.EndToolbarHorizontal();
693+
TextEditor editor = new TextEditor();
694+
editor.text = text;
695+
editor.SelectAll();
696+
editor.Copy();
813697
}
814698
#endregion
815699

816700
#region TreeViews
817701
public static void DisplayPrefabName(string name)
818702
{
819703
Elements.BeginToolbarHorizontal();
820-
Elements.ToolbarLabel(ToolTips.prefabName);
704+
if (Elements.ToolbarButton(ToolTips.prefabName))
705+
CopyText(name);
821706
Elements.ToolbarLabel(new GUIContent(name, name));
822707
Elements.EndToolbarHorizontal();
823708
}
824709

825710
public static void DisplayPrefabID(WorldSerialization.PrefabData prefab)
826711
{
827712
Elements.BeginToolbarHorizontal();
828-
Elements.ToolbarLabel(ToolTips.prefabID);
713+
if (Elements.ToolbarButton(ToolTips.prefabID))
714+
CopyText(prefab.id.ToString());
829715
Elements.ToolbarLabel(new GUIContent(prefab.id.ToString(), prefab.id.ToString()));
830716
Elements.EndToolbarHorizontal();
831717
}
832718

833719
public static void DisplayPrefabPath(WorldSerialization.PrefabData prefab)
834720
{
835721
Elements.BeginToolbarHorizontal();
836-
Elements.ToolbarLabel(ToolTips.prefabPath);
722+
if (Elements.ToolbarButton(ToolTips.prefabPath))
723+
CopyText(AssetManager.ToPath(prefab.id));
837724
Elements.ToolbarLabel(new GUIContent(AssetManager.ToPath(prefab.id), AssetManager.ToPath(prefab.id)));
838725
Elements.EndToolbarHorizontal();
839726
}
@@ -856,8 +743,14 @@ public static void HierachyOptions(PrefabDataHolder[] prefabs, ref string name)
856743

857744
Elements.BeginToolbarHorizontal();
858745
name = Elements.ToolbarTextField(name);
746+
Elements.EndToolbarHorizontal();
747+
748+
Elements.BeginToolbarHorizontal();
859749
if (Elements.ToolbarButton(ToolTips.hierachyRename))
750+
{
860751
PrefabManager.RenamePrefabs(prefabs, name);
752+
ReloadTreeViews();
753+
}
861754
Elements.EndToolbarHorizontal();
862755

863756
Elements.BeginToolbarHorizontal();

0 commit comments

Comments
 (0)