Skip to content

Commit 9e51c11

Browse files
committed
WIP: Moved MapLoader to GameConfig and added map button patches
1 parent ba43b7b commit 9e51c11

35 files changed

Lines changed: 446 additions & 369 deletions

LevelImposter/AssetLoader/AudioLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void LoadAsync(Guid? assetID, Action<AudioClip> onLoad)
2626

2727

2828
// Get Data Store from AssetDB
29-
var soundDataStore = MapLoader.CurrentMap?.mapAssetDB?.Get(assetID);
29+
var soundDataStore = GameConfiguration.CurrentMap?.mapAssetDB?.Get(assetID);
3030
if (soundDataStore == null)
3131
return;
3232

LevelImposter/AssetLoader/FileContainers/GIFFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public void RenderFrame(int frameIndex)
528528
}
529529

530530
// Create frame texture
531-
var pixelArtMode = MapLoader.CurrentMap?.properties.pixelArtMode == true;
531+
var pixelArtMode = GameConfiguration.CurrentMap?.properties.pixelArtMode == true;
532532
var texture = new Texture2D(Width, Height, TextureFormat.RGBA32, false)
533533
{
534534
wrapMode = TextureWrapMode.Clamp,

LevelImposter/AssetLoader/Loaders/WAVLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static class WAVLoader
1919
return null;
2020

2121
// Get data from Map Asset DB
22-
var soundDBElem = MapLoader.CurrentMap?.mapAssetDB?.Get(soundData.dataID);
22+
var soundDBElem = GameConfiguration.CurrentMap?.mapAssetDB?.Get(soundData.dataID);
2323
if (soundDBElem == null)
2424
return null;
2525

LevelImposter/Builders/Generic/MapPropertiesBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public MapPropertiesBuilder()
2828
return;
2929

3030
// Get Map
31-
var map = MapLoader.CurrentMap;
31+
var map = GameConfiguration.CurrentMap;
3232

3333
// Set Map Name
3434
shipStatus.name = map.name;

LevelImposter/Builders/Generic/SpriteBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public class SpriteBuilder : IElemBuilder
1717

1818
public static SpriteLoadEvent? OnSpriteLoad;
1919

20-
private static bool PixelArtMode => MapLoader.CurrentMap?.properties.pixelArtMode ?? false;
21-
private static MapAssetDB? AssetDB => MapLoader.CurrentMap?.mapAssetDB;
20+
private static bool PixelArtMode => GameConfiguration.CurrentMap?.properties.pixelArtMode ?? false;
21+
private static MapAssetDB? AssetDB => GameConfiguration.CurrentMap?.mapAssetDB;
2222

2323
public SpriteBuilder()
2424
{
@@ -98,7 +98,7 @@ public static void LoadSprite(LIElement elem, Action<LoadedSprite> onLoad)
9898
/// <returns>The sprite atlas or null if not found</returns>
9999
private static LISpriteAtlas? FindSpriteAtlasOfID(Guid? id)
100100
{
101-
var allSpriteAtlases = MapLoader.CurrentMap?.spriteAtlases;
101+
var allSpriteAtlases = GameConfiguration.CurrentMap?.spriteAtlases;
102102
return allSpriteAtlases?.FirstOrDefault(atlas => atlas.id == id);
103103
}
104104

LevelImposter/Builders/Util/DisplayBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void OnBuild(LIElement elem, GameObject obj)
5555
meshRenderer.sharedMaterial = minigamePrefab?.DefaultMaterial;
5656

5757
// Render Texture
58-
var pixelArtMode = MapLoader.CurrentMap?.properties.pixelArtMode ?? false;
58+
var pixelArtMode = GameConfiguration.CurrentMap?.properties.pixelArtMode ?? false;
5959
var renderTexture = RenderTexture.GetTemporary(
6060
width,
6161
height,

LevelImposter/Core/Components/LIShipStatus.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class LIShipStatus(IntPtr intPtr) : MonoBehaviour(intPtr)
2626

2727
[Obsolete("Use MapLoader.CurrentMap instead")]
2828
[HideFromIl2Cpp]
29-
public static LIMap? CurrentMap => MapLoader.CurrentMap;
29+
public static LIMap? CurrentMap => GameConfiguration.CurrentMap;
3030

3131
public bool IsReady => !Builder.IsBuilding && !LoadingBar.IsVisible;
3232

@@ -37,8 +37,8 @@ public void Awake()
3737
ShipStatus = GetComponent<ShipStatus>();
3838
_instance = this;
3939

40-
if (MapLoader.CurrentMap != null)
41-
Builder.BuildMap(MapLoader.CurrentMap);
40+
if (GameConfiguration.CurrentMap != null)
41+
Builder.BuildMap(GameConfiguration.CurrentMap);
4242
else
4343
LILogger.Warn("No map content, no LI map will load");
4444
}

LevelImposter/Core/Components/MinigameSprites.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class MinigameSprites(IntPtr intPtr) : MonoBehaviour(intPtr)
4545
private LIMinigameSprite[]? _minigameDataArr;
4646
private LIMinigameProps? _minigameProps;
4747

48-
private static bool PixelArtMode => MapLoader.CurrentMap?.properties.pixelArtMode ?? false;
48+
private static bool PixelArtMode => GameConfiguration.CurrentMap?.properties.pixelArtMode ?? false;
4949

5050
public void OnDestroy()
5151
{
@@ -85,7 +85,7 @@ public void LoadMinigame(Minigame minigame)
8585
var hasPivot = PIVOTS.TryGetValue(minigameData.type, out var pivot);
8686

8787
// Get Sprite Stream
88-
var mapAssetDB = MapLoader.CurrentMap?.mapAssetDB;
88+
var mapAssetDB = GameConfiguration.CurrentMap?.mapAssetDB;
8989
var guid = minigameData.spriteID;
9090
var mapAsset = mapAssetDB?.Get(guid);
9191

LevelImposter/Core/LILogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace LevelImposter.Core;
1111
public static class LILogger
1212
{
1313
// Set to true to log Unity Stack traces to the BepInEx console. Useful when debugging.
14-
private const bool LOG_UNITY_STACK_TRACE = false;
14+
private const bool LOG_UNITY_STACK_TRACE = true;
1515

1616
private static ManualLogSource? _logger;
1717

LevelImposter/Core/Models/LIMetadata.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Text.Json.Serialization;
23

34
namespace LevelImposter.Core;
45

@@ -22,7 +23,13 @@ public class LIMetadata
2223
/// <summary>
2324
/// True if the map has a thumbnail available
2425
/// </summary>
25-
public bool HasThumbnail => !string.IsNullOrEmpty(thumbnailURL);
26+
[JsonIgnore] public bool HasThumbnail => !string.IsNullOrEmpty(thumbnailURL);
27+
28+
/// <summary>
29+
/// True if the map has been uploaded to the workshop.
30+
/// (Only maps with a valid GUID as ID are workshop maps)
31+
/// </summary>
32+
[JsonIgnore] public bool IsInWorkshop => Guid.TryParse(id, out _);
2633

2734
public override string ToString()
2835
{

0 commit comments

Comments
 (0)