infer gameswitches from json (#381)

This commit is contained in:
Zeo 2023-04-02 12:15:19 -05:00 committed by GitHub
parent 1f407aae85
commit be78d1567e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 14 deletions

View file

@ -356,7 +356,7 @@ namespace HeavenStudio
if (game == null) if (game == null)
{ {
Debug.LogWarning($"Unknown game {gameName} found in remix.json! Adding game..."); Debug.LogWarning($"Unknown game {gameName} found in remix.json! Adding game...");
game = new Minigames.Minigame(gameName, DisplayName(gameName) + " \n<color=#eb5454>[inferred from remix.json]</color>", "", false, true, new List<Minigames.GameAction>()); game = new Minigames.Minigame(gameName, DisplayName(gameName) + " \n<color=#eb5454>[inferred from remix.json]</color>", "", false, false, new List<Minigames.GameAction>(), inferred: true);
EventCaller.instance.minigames.Add(game); EventCaller.instance.minigames.Add(game);
if (Editor.Editor.instance != null) if (Editor.Editor.instance != null)
Editor.Editor.instance.AddIcon(game); Editor.Editor.instance.AddIcon(game);

View file

@ -709,18 +709,13 @@ namespace HeavenStudio
{ {
if (gameInfo.fxOnly) if (gameInfo.fxOnly)
{ {
var gameEntities = Beatmap.entities.FindAll(c => { var gameInfos = Beatmap.entities
var gameName = c.datamodel.Split(0); .Select(x => x.datamodel.Split(0))
var newGameInfo = GetGameInfo(gameName); .Select(x => GetGameInfo(x))
if (newGameInfo == null) .Where(x => x != null)
return false; .Where(x => !x.fxOnly)
else .Select(x => x.LoadableName);
return !newGameInfo.fxOnly; name = gameInfos.FirstOrDefault() ?? "noGame";
}).ToList();
if (gameEntities.Count != 0)
name = gameEntities[0].datamodel.Split(0);
else
name = "noGame";
} }
else else
{ {
@ -729,6 +724,7 @@ namespace HeavenStudio
//game is packed in an assetbundle, load from that instead //game is packed in an assetbundle, load from that instead
return gameInfo.GetCommonAssetBundle().LoadAsset<GameObject>(name); return gameInfo.GetCommonAssetBundle().LoadAsset<GameObject>(name);
} }
name = gameInfo.LoadableName;
} }
} }
return Resources.Load<GameObject>($"Games/{name}"); return Resources.Load<GameObject>($"Games/{name}");

View file

@ -33,11 +33,13 @@ namespace HeavenStudio
public string defaultLocale = "en"; public string defaultLocale = "en";
public string wantAssetBundle = ""; public string wantAssetBundle = "";
public List<string> supportedLocales; public List<string> supportedLocales;
public bool inferred;
public bool usesAssetBundle => (wantAssetBundle != ""); public bool usesAssetBundle => (wantAssetBundle != "");
public bool hasLocales => (supportedLocales.Count > 0); public bool hasLocales => (supportedLocales.Count > 0);
public bool AssetsLoaded => (((hasLocales && localeLoaded && currentLoadedLocale == defaultLocale) || (!hasLocales)) && commonLoaded); public bool AssetsLoaded => (((hasLocales && localeLoaded && currentLoadedLocale == defaultLocale) || (!hasLocales)) && commonLoaded);
public bool SequencesPreloaded => soundSequences != null; public bool SequencesPreloaded => soundSequences != null;
public string LoadableName => inferred ? "noGame" : name;
private AssetBundle bundleCommon = null; private AssetBundle bundleCommon = null;
private bool commonLoaded = false; private bool commonLoaded = false;
@ -55,7 +57,7 @@ namespace HeavenStudio
set => soundSequences = value; set => soundSequences = value;
} }
public Minigame(string name, string displayName, string color, bool threeD, bool fxOnly, List<GameAction> actions, List<string> tags = null, string assetBundle = "", string defaultLocale = "en", List<string> supportedLocales = null) public Minigame(string name, string displayName, string color, bool threeD, bool fxOnly, List<GameAction> actions, List<string> tags = null, string assetBundle = "", string defaultLocale = "en", List<string> supportedLocales = null, bool inferred = false)
{ {
this.name = name; this.name = name;
this.displayName = displayName; this.displayName = displayName;
@ -68,6 +70,7 @@ namespace HeavenStudio
this.wantAssetBundle = assetBundle; this.wantAssetBundle = assetBundle;
this.defaultLocale = defaultLocale; this.defaultLocale = defaultLocale;
this.supportedLocales = supportedLocales ?? new List<string>(); this.supportedLocales = supportedLocales ?? new List<string>();
this.inferred = inferred;
} }
public AssetBundle GetLocalizedAssetBundle() public AssetBundle GetLocalizedAssetBundle()