Some fixes and tweaks regarding textures.

This commit is contained in:
Bas
2020-12-14 21:33:49 +01:00
parent bc3342b819
commit 69f48ddfce
16 changed files with 186 additions and 250 deletions

View File

@@ -25,7 +25,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Wall:
m_Texture: {fileID: 2800000, guid: 82bfab83fdf1f9a45ad41b3a55036bdc, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseMap:

View File

@@ -10,6 +10,8 @@ GameObject:
m_Component:
- component: {fileID: 4881190563108725489}
- component: {fileID: 4510758288248945009}
- component: {fileID: 8891683890991230830}
- component: {fileID: 2076936050456593542}
m_Layer: 0
m_Name: SmallScenery
m_TagString: Untagged
@@ -27,8 +29,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 3436706900042224624}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -45,88 +46,50 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 0.7, y: 1, z: 0.7}
m_Center: {x: 0, y: 0.5, z: 0}
--- !u!1001 &7695269097637886186
PrefabInstance:
--- !u!33 &8891683890991230830
MeshFilter:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 4881190563108725489}
m_Modifications:
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalPosition.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalRotation.x
value: 0.6532815
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalRotation.y
value: -0.27059802
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalRotation.z
value: 0.27059808
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.65328145
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -1504981713932161579, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 9405b3275a6527e448a1122260745f9d, type: 2}
- target: {fileID: -927199367670048503, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_Name
value: CrossShape
objectReference: {fileID: 0}
- target: {fileID: -927199367670048503, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
propertyPath: m_StaticEditorFlags
value: 4294967295
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 334eee2ab21182249a574cd672a35807, type: 3}
--- !u!4 &3436706900042224624 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -4216859302048453862, guid: 334eee2ab21182249a574cd672a35807,
type: 3}
m_PrefabInstance: {fileID: 7695269097637886186}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4881190563108725493}
m_Mesh: {fileID: 6677062280192487409, guid: 334eee2ab21182249a574cd672a35807, type: 3}
--- !u!23 &2076936050456593542
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4881190563108725493}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 9405b3275a6527e448a1122260745f9d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0

View File

@@ -9,6 +9,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 8066037642481970818}
- component: {fileID: 2658238295191841746}
- component: {fileID: 2520377533842412944}
m_Layer: 0
m_Name: Wall
m_TagString: Untagged
@@ -26,93 +28,54 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2546421845808257625}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &7362261569040527683
PrefabInstance:
--- !u!33 &2658238295191841746
MeshFilter:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 8066037642481970818}
m_Modifications:
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalPosition.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -1504981713932161579, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: dcd74c535e88cff4dae46d097efe2d58, type: 2}
- target: {fileID: -927199367670048503, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_Name
value: Wall
objectReference: {fileID: 0}
- target: {fileID: -927199367670048503, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
propertyPath: m_StaticEditorFlags
value: 4294967295
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: fecac2db4ca269d48ad3260b1f999c28, type: 3}
--- !u!4 &2546421845808257625 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -4216859302048453862, guid: fecac2db4ca269d48ad3260b1f999c28,
type: 3}
m_PrefabInstance: {fileID: 7362261569040527683}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6613264330481197744}
m_Mesh: {fileID: -462981019419857548, guid: fecac2db4ca269d48ad3260b1f999c28, type: 3}
--- !u!23 &2520377533842412944
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6613264330481197744}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: dcd74c535e88cff4dae46d097efe2d58, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0

View File

@@ -1496,7 +1496,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 79be679884da2154dacd80be9669d5dc, type: 3}
m_Name:
m_EditorClassIdentifier:
selectedPark: Magic_Towers_94.sv6
selectedPark: My test park/Test park with house.sv6
--- !u!4 &1347800243
Transform:
m_ObjectHideFlags: 0

View File

@@ -65,7 +65,7 @@ namespace EditorExtensions
}
else
{
Texture2D texture = graphic.GetTexture();
Texture2D texture = graphic.GetTexture(makeTextureReadable: true);
GUIContent icon = EditorGUIUtility.IconContent("SavePassive", "Save sprite");
GUILayout.BeginHorizontal();

View File

@@ -89,10 +89,14 @@ namespace Graphics
/// <summary>
/// Gets the texture for this graphic.
/// </summary>
public Texture2D GetTexture(TextureWrapMode wrapMode = TextureWrapMode.Clamp)
public Texture2D GetTexture(TextureWrapMode wrapMode = TextureWrapMode.Clamp, bool makeTextureReadable = false)
{
if (_texture != null)
if (_texture != null
// if caller requires a readable texture, but cached is not; do not return the cached.
&& (!makeTextureReadable || _texture.isReadable))
{
return _texture;
}
uint imageIndex = ImageIndex;
int pixelCount = PixelCount;
@@ -112,12 +116,12 @@ namespace Graphics
// Export as Texture2D image.
_texture = new Texture2D(width, height, TextureFormat.RGBA32, mipChain: false)
{
name = $"i:{imageIndex}",
name = $"sprite{imageIndex & 0x7FFFF}(unmasked{imageIndex})",
filterMode = FilterMode.Point,
wrapMode = wrapMode
};
_texture.SetPixels32(colors);
_texture.Apply(updateMipmaps: false, makeNoLongerReadable: true);
_texture.Apply(updateMipmaps: false, makeNoLongerReadable: !makeTextureReadable);
return _texture;
}
}

View File

@@ -35,7 +35,7 @@ namespace Lib
if (!ArePathSettingsValid())
return false;
StartGame(openrctDataPath, rct2Path, rct1Path);
StartGame(_openrctDataPath, _rct2Path, _rct1Path);
return true;
}
@@ -77,10 +77,10 @@ namespace Lib
/// </summary>
static void LoadPathSettings()
{
openrctDataPath = Configuration.OpenRCT2DataPath;
rct2Path = Configuration.RCT2Path;
rct1Path = Configuration.RCT1Path;
parkPath = Configuration.ParkPath;
_openrctDataPath = Configuration.OpenRCT2DataPath;
_rct2Path = Configuration.RCT2Path;
_rct1Path = Configuration.RCT1Path;
_parkPath = Configuration.ParkPath;
}
@@ -89,19 +89,19 @@ namespace Lib
/// </summary>
static bool ArePathSettingsValid()
{
if (!Directory.Exists(openrctDataPath))
if (!Directory.Exists(_openrctDataPath))
{
Debug.LogError($"Could not load OpenRCT2: openrct path is invalid. ({openrctDataPath})");
Debug.LogError($"Could not load OpenRCT2: openrct path is invalid. ({_openrctDataPath})");
return false;
}
if (!Directory.Exists(rct2Path))
if (!Directory.Exists(_rct2Path))
{
Debug.LogError($"Could not load OpenRCT2: rct2 path is invalid. ({rct2Path})");
Debug.LogError($"Could not load OpenRCT2: rct2 path is invalid. ({_rct2Path})");
return false;
}
if (!string.IsNullOrWhiteSpace(rct1Path) && !Directory.Exists(rct1Path))
if (!string.IsNullOrWhiteSpace(_rct1Path) && !Directory.Exists(_rct1Path))
{
Debug.LogError($"Could not load OpenRCT2: rct1 path is invalid. ({rct1Path})");
Debug.LogError($"Could not load OpenRCT2: rct1 path is invalid. ({_rct1Path})");
return false;
}
return true;

View File

@@ -12,10 +12,10 @@ namespace Lib
public string selectedPark;
// Configuration for data paths
static string openrctDataPath;
static string rct2Path;
static string rct1Path;
static string parkPath;
static string _openrctDataPath;
static string _rct2Path;
static string _rct1Path;
static string _parkPath;
/// <summary>
@@ -73,6 +73,6 @@ namespace Lib
/// Gets the file path to the park file.
/// </summary>
string GetParkFilePath()
=> Path.Combine(parkPath, selectedPark);
=> Path.Combine(_parkPath, selectedPark);
}
}

View File

@@ -16,48 +16,48 @@ namespace Lib
const string DefaultOpenRCT2Path = @"bin\data"; // from repo root
const string DefaultParkPath = @"Parks"; // from unity project/executable root
static readonly string[] ValidParkExtensions = { ".sv6", ".sc6", ".sv4", ".sc4" };
static readonly string[] _validParkExtensions = { ".sv6", ".sc6", ".sv4", ".sc4" };
bool groupToggleDataPaths = true;
string openrct2DataPath;
string rct2Path;
string rct1Path;
string parkPath;
bool _groupToggleDataPaths = true;
string _openrct2DataPath;
string _rct2Path;
string _rct1Path;
string _parkPath;
bool groupToggleSelectedPark = true;
string[] allDiscoveredParks;
int selectedParkIndex = -1;
bool _groupToggleSelectedPark = true;
string[] _allDiscoveredParks;
int _selectedParkIndex = -1;
void OnEnable()
{
openrct2DataPath = Configuration.OpenRCT2DataPath;
_openrct2DataPath = Configuration.OpenRCT2DataPath;
// If openrct2 path is null, take the default bin folder in the project.
if (string.IsNullOrWhiteSpace(openrct2DataPath))
openrct2DataPath = GetDefaultOpenRCT2DataPath();
if (string.IsNullOrWhiteSpace(_openrct2DataPath))
_openrct2DataPath = GetDefaultOpenRCT2DataPath();
rct2Path = Configuration.RCT2Path;
rct1Path = Configuration.RCT1Path;
_rct2Path = Configuration.RCT2Path;
_rct1Path = Configuration.RCT1Path;
parkPath = Configuration.ParkPath;
_parkPath = Configuration.ParkPath;
// If park path is null, take the default park folder in the project.
if (string.IsNullOrWhiteSpace(parkPath))
if (string.IsNullOrWhiteSpace(_parkPath))
{
DirectoryInfo unityRoot = FindUnityRootFolder();
parkPath = Path.Combine(unityRoot.FullName, DefaultParkPath);
_parkPath = Path.Combine(unityRoot.FullName, DefaultParkPath);
}
}
void OnDisable()
{
Configuration.OpenRCT2DataPath = openrct2DataPath;
Configuration.RCT2Path = rct2Path;
Configuration.RCT1Path = rct1Path;
Configuration.ParkPath = parkPath;
Configuration.OpenRCT2DataPath = _openrct2DataPath;
Configuration.RCT2Path = _rct2Path;
Configuration.RCT1Path = _rct1Path;
Configuration.ParkPath = _parkPath;
}
@@ -66,64 +66,68 @@ namespace Lib
/// </summary>
public override void OnInspectorGUI()
{
groupToggleDataPaths = EditorGUILayout.BeginFoldoutHeaderGroup(groupToggleDataPaths, "Source paths");
_groupToggleDataPaths = EditorGUILayout.BeginFoldoutHeaderGroup(_groupToggleDataPaths, "Source paths");
if (groupToggleDataPaths)
if (_groupToggleDataPaths)
{
// OpenRCT2
openrct2DataPath = EditorGUILayout.TextField("OpenRCT2 data path", openrct2DataPath);
_openrct2DataPath = EditorGUILayout.TextField("OpenRCT2 data path", _openrct2DataPath);
if (string.IsNullOrWhiteSpace(openrct2DataPath))
if (string.IsNullOrWhiteSpace(_openrct2DataPath))
EditorGUILayout.HelpBox("The OpenRCT2 data path is not specified! Point it to the 'data' folder for OpenRCT2.", MessageType.Error);
else if (!Directory.Exists(openrct2DataPath))
else if (!Directory.Exists(_openrct2DataPath))
{
string defaultPath = GetDefaultOpenRCT2DataPath();
if (openrct2DataPath == defaultPath)
EditorGUILayout.HelpBox($"The default OpenRCT2 data path does not exist:\n'{openrct2DataPath}'\n\nYou need to succesfully build the C++ OpenRCT2 project at least one to use this data folder.", MessageType.Error);
if (_openrct2DataPath == defaultPath)
EditorGUILayout.HelpBox($"The default OpenRCT2 data path does not exist:\n'{_openrct2DataPath}'\n\nYou need to succesfully build the C++ OpenRCT2 project at least one to use this data folder.", MessageType.Error);
else
EditorGUILayout.HelpBox($"The specified OpenRCT2 data path does not exist:\n'{openrct2DataPath}'\n\nPoint it to the 'data' folder for OpenRCT2.", MessageType.Error);
EditorGUILayout.HelpBox($"The specified OpenRCT2 data path does not exist:\n'{_openrct2DataPath}'\n\nPoint it to the 'data' folder for OpenRCT2.", MessageType.Error);
}
// RCT2 path
rct2Path = EditorGUILayout.TextField("RCT2 path", rct2Path);
_rct2Path = EditorGUILayout.TextField("RCT2 path", _rct2Path);
if (string.IsNullOrWhiteSpace(rct2Path))
if (string.IsNullOrWhiteSpace(_rct2Path))
EditorGUILayout.HelpBox("The RCT2 path is not specified! Point it to the folder where RCT2 is installed.", MessageType.Error);
else if (!Directory.Exists(rct2Path))
EditorGUILayout.HelpBox($"The specified RCT2 path does not exist:\n'{rct2Path}'\n\nPoint it to the folder where RCT2 is installed.", MessageType.Error);
else if (!Directory.Exists(_rct2Path))
EditorGUILayout.HelpBox($"The specified RCT2 path does not exist:\n'{_rct2Path}'\n\nPoint it to the folder where RCT2 is installed.", MessageType.Error);
// RCT1 path
rct1Path = EditorGUILayout.TextField("RCT1 path (optional)", rct1Path);
_rct1Path = EditorGUILayout.TextField("RCT1 path (optional)", _rct1Path);
if (!string.IsNullOrWhiteSpace(rct1Path) && !Directory.Exists(rct1Path))
EditorGUILayout.HelpBox($"The specified RCT1 path does not exist:\n{rct1Path}\n\nPoint it to the folder where RCT1 is installed or leave it empty.", MessageType.Error);
if (!string.IsNullOrWhiteSpace(_rct1Path) && !Directory.Exists(_rct1Path))
EditorGUILayout.HelpBox($"The specified RCT1 path does not exist:\n{_rct1Path}\n\nPoint it to the folder where RCT1 is installed or leave it empty.", MessageType.Error);
// Parks path
parkPath = EditorGUILayout.TextField("Parks path", parkPath);
_parkPath = EditorGUILayout.TextField("Parks path", _parkPath);
if (string.IsNullOrWhiteSpace(parkPath))
if (string.IsNullOrWhiteSpace(_parkPath))
EditorGUILayout.HelpBox("The parks path is not specified! Point it to a folder where your parks are located.", MessageType.Error);
else if (!Directory.Exists(parkPath))
EditorGUILayout.HelpBox($"The specified parks path does not exist:\n'{parkPath}'\n\nPoint it to the folder where your parks are located.", MessageType.Error);
else if (!Directory.Exists(_parkPath))
EditorGUILayout.HelpBox($"The specified parks path does not exist:\n'{_parkPath}'\n\nPoint it to the folder where your parks are located.", MessageType.Error);
}
EditorGUILayout.EndFoldoutHeaderGroup();
// Select a park
groupToggleSelectedPark = EditorGUILayout.BeginFoldoutHeaderGroup(groupToggleSelectedPark, "Selected park");
_groupToggleSelectedPark = EditorGUILayout.BeginFoldoutHeaderGroup(_groupToggleSelectedPark, "Selected park");
if (groupToggleSelectedPark)
if (_groupToggleSelectedPark)
{
bool parkFoundError = false;
if (allDiscoveredParks == null)
if (_allDiscoveredParks == null)
{
// Search for all park files in the specified park folder...
DirectoryInfo parkDirectory = new DirectoryInfo(parkPath);
if (parkDirectory.Exists)
DirectoryInfo parkDirectory = new DirectoryInfo(_parkPath);
if (!parkDirectory.Exists)
{
parkFoundError = true;
}
else
{
int cutoff = parkDirectory.FullName.Length + 1;
allDiscoveredParks = parkDirectory
_allDiscoveredParks = parkDirectory
.EnumerateFiles("*.*", SearchOption.AllDirectories)
.Where(HasValidParkExtension)
.Select(e => e
@@ -135,27 +139,29 @@ namespace Lib
OpenRCT2 game = (OpenRCT2)target;
string selected = game.selectedPark;
selectedParkIndex = Array.IndexOf(allDiscoveredParks, selected);
_selectedParkIndex = Array.IndexOf(_allDiscoveredParks, selected);
if (selectedParkIndex != -1)
game.selectedPark = allDiscoveredParks[selectedParkIndex];
if (_selectedParkIndex != -1)
{
game.selectedPark = _allDiscoveredParks[_selectedParkIndex];
}
}
else
parkFoundError = true;
}
// Set the current selected park + update if another is selected
if (!parkFoundError)
{
int currentSelection = selectedParkIndex;
currentSelection = EditorGUILayout.Popup(currentSelection, allDiscoveredParks);
int currentSelection = _selectedParkIndex;
currentSelection = EditorGUILayout.Popup(currentSelection, _allDiscoveredParks);
if (currentSelection != selectedParkIndex)
if (currentSelection != _selectedParkIndex)
{
selectedParkIndex = currentSelection;
_selectedParkIndex = currentSelection;
OpenRCT2 game = (OpenRCT2)target;
game.selectedPark = allDiscoveredParks[currentSelection];
Undo.RecordObject(game, "Select park");
game.selectedPark = _allDiscoveredParks[currentSelection];
}
}
}
@@ -199,6 +205,6 @@ namespace Lib
/// Returns whether the file entry has a valid extension.
/// </summary>
bool HasValidParkExtension(FileSystemInfo fileSystemInfo)
=> ValidParkExtensions.Any(e => string.Equals(e, fileSystemInfo.Extension, StringComparison.InvariantCultureIgnoreCase));
=> _validParkExtensions.Any(e => string.Equals(e, fileSystemInfo.Extension, StringComparison.InvariantCultureIgnoreCase));
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.