Skip to content

Commit

Permalink
Merge pull request #202 from SpaceWarpDev/v1.1.1
Browse files Browse the repository at this point in the history
Fixed audio and localization issue
  • Loading branch information
cheese3660 authored Apr 5, 2023
2 parents b22e436 + 147271f commit 5b9d441
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<SpaceWarpVersion>1.1.0</SpaceWarpVersion>
<SpaceWarpVersion>1.1.1</SpaceWarpVersion>
<TargetFramework>net472</TargetFramework>
<LangVersion>11</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
2 changes: 1 addition & 1 deletion SpaceWarp/Patching/BootstrapPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static void PatchInitializationsIL(ILContext ilContext, ILLabel endLabel
}
}

// flow.AddAction(new LoadAddressablesLocalizationsAction());
flow.AddAction(new LoadAddressablesLocalizationsAction());
foreach (var action in Loading.GeneralLoadingActions)
{
flow.AddAction(action);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using I2.Loc;
using KSP.Game;
using KSP.Game.Flow;
using UnityEngine;
using UnityEngine.AddressableAssets;

namespace SpaceWarp.Patching.LoadingActions;

internal sealed class LoadAddressablesLocalizationsAction : FlowAction
{
public LoadAddressablesLocalizationsAction() : base("Loading localizations from Addressables")
{
}

public override void DoAction(Action resolve, Action<string> reject)
{
try
{
GameManager.Instance.Game.Assets.LoadByLabel("language_source",
OnLanguageSourceAssetLoaded, delegate(IList<LanguageSourceAsset> languageAssetLocations)
{
if (languageAssetLocations != null)
{
Addressables.Release(languageAssetLocations);
}

resolve();
});
}
catch (Exception e)
{
Debug.LogError(e.ToString());
reject(null);
}
}

private static void OnLanguageSourceAssetLoaded(LanguageSourceAsset asset)
{
if (!asset || LocalizationManager.Sources.Contains(asset.mSource))
{
return;
}

asset.mSource.owner = asset;
LocalizationManager.AddSource(asset.mSource);
}
}
11 changes: 0 additions & 11 deletions SpaceWarp/SpaceWarpManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,9 @@ internal static void CheckKspVersions()
return assets;
}

private static void LoadLanguageSourceAsset(LanguageSourceAsset asset)
{
if (!asset || LocalizationManager.Sources.Contains(asset.mSource))
{
return;
}

asset.mSource.owner = asset;
LocalizationManager.AddSource(asset.mSource);
}
internal static void InitializeSpaceWarpsLoadingActions()
{
Loading.AddAssetLoadingAction("bundles","loading asset bundles",AssetBundleLoadingAction,"bundle");
Loading.AddAssetLoadingAction("images","loading images",ImageLoadingAction);
Loading.AddAddressablesLoadingAction<LanguageSourceAsset>("loading addressable localizations","language_source",LoadLanguageSourceAsset);
}
}
2 changes: 1 addition & 1 deletion SpaceWarpBuildTemplate/swinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Space-Warp is an API for KSP2 mod developers.",
"source": "https://github.com/SpaceWarpDev/SpaceWarp",
"version_check": "https://raw.githubusercontent.com/SpaceWarpDev/SpaceWarp/main/SpaceWarpBuildTemplate/swinfo.json",
"version": "1.1.0",
"version": "1.1.1",
"dependencies": [],
"ksp2_version": {
"min": "0",
Expand Down

0 comments on commit 5b9d441

Please sign in to comment.