Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Apr 25, 2024
1 parent 287bbe4 commit 2132414
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 83 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ jobs:
###########################
publish-on-nexusmods:
if: github.ref == 'refs/heads/master'
needs: ["get-changelog", "build"]
needs: [get-changelog, build]
uses: BUTR/workflows/.github/workflows/release-nexusmods.yml@master
with:
nexusmods_game_id: mountandblade2bannerlord
nexusmods_mod_id: 1
mod_filename: 'Bannerlord Software Extender (BLSE)'
mod_version: ${{ needs.build-changelog.outputs.mod_version }}
mod_version: ${{ needs.get-changelog.outputs.mod_version }}
mod_description: ${{ needs.build.outputs.mod_description }}
artifact_name: bannerlord
secrets:
Expand All @@ -94,11 +94,11 @@ jobs:
###########################
publish-on-github:
if: github.ref == 'refs/heads/master'
needs: ["get-changelog", "build"]
needs: [get-changelog, build]
uses: BUTR/workflows/.github/workflows/release-github.yml@master
with:
mod_id: Bannerlord.BLSE
mod_version: ${{ needs.build-changelog.outputs.mod_version }}
mod_version: ${{ needs.get-changelog.outputs.mod_version }}
mod_description: ${{ needs.build.outputs.mod_description }}
artifact_name: bannerlord

Expand All @@ -107,7 +107,7 @@ jobs:
###########################
publish-on-steam:
if: github.ref == 'refs/heads/master'
needs: ["get-changelog", "build"]
needs: [get-changelog, build]
runs-on: ubuntu-latest
steps:
- name: Download Module artifact
Expand All @@ -123,7 +123,7 @@ jobs:
ssfnFileName: ${{ secrets.STEAM_SSFN_FILE_NAME }}
ssfnFileContents: ${{ secrets.STEAM_SSFN_FILE_CONTENTS }}
appId: ${{ secrets.STEAM_APPID }}
buildDescription: ${{ needs.build-changelog.outputs.mod_version }}
buildDescription: ${{ needs.get-changelog.outputs.mod_version }}
rootPath: build
depot1Path: ./artifact
releaseBranch: prerelease
4 changes: 2 additions & 2 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<PropertyGroup>
<Version>1.5.0</Version>
<HarmonyVersion>2.2.2</HarmonyVersion>
<BUTRSharedVersion>3.0.0.138</BUTRSharedVersion>
<BUTRSharedVersion>3.0.0.139</BUTRSharedVersion>
<BUTRModuleManagerVersion>5.0.222</BUTRModuleManagerVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
<HarmonyAnalyzerVersion>1.0.1.50</HarmonyAnalyzerVersion>
<LauncherManagerVersion>1.0.100</LauncherManagerVersion>
<LauncherManagerVersion>1.0.107</LauncherManagerVersion>
<DebugType>full</DebugType>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>winexe</OutputType>
<PlatformTarget>x64</PlatformTarget>
<TargetFramework>net472</TargetFramework>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ApplicationIcon>../../resources/BLSE_SMALL.ico</ApplicationIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>winexe</OutputType>
<PlatformTarget>x64</PlatformTarget>
<TargetFramework>net472</TargetFramework>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ApplicationIcon>../../resources/BLSE_SMALL.ico</ApplicationIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>winexe</OutputType>
<PlatformTarget>x64</PlatformTarget>
<TargetFramework>net472</TargetFramework>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ApplicationIcon>../../resources/BLSE_SMALL.ico</ApplicationIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
6 changes: 3 additions & 3 deletions src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<OutputType>library</OutputType>
Expand Down Expand Up @@ -79,8 +79,8 @@
</PropertyGroup>
<Message Text="dotnet clean $(LauncherExProjectFull) -p:Configuration=$(Configuration)_%(GameAPIVersion.Flat)" Importance="High" />
<Exec Command="dotnet clean $(LauncherExProjectFull) -p:Configuration=$(Configuration)_%(GameAPIVersion.Flat)" />
<Message Text="dotnet build $(LauncherExProjectFull) --force -p:GameVersion=%(GameAPIVersion.GameVersion) -p:Configuration=$(Configuration)_%(GameAPIVersion.Flat)" Importance="High" />
<Exec Command="dotnet build $(LauncherExProjectFull) --force -p:GameVersion=%(GameAPIVersion.GameVersion) -p:Configuration=$(Configuration)_%(GameAPIVersion.Flat)" />
<Message Text="dotnet build $(LauncherExProjectFull) -p:Configuration=$(Configuration)_%(GameAPIVersion.Flat) -p:GameVersion=%(GameAPIVersion.GameVersion)" Importance="High" />
<Exec Command="dotnet build $(LauncherExProjectFull) -p:Configuration=$(Configuration)_%(GameAPIVersion.Flat) -p:GameVersion=%(GameAPIVersion.GameVersion)" />
</Target>
<Target Condition="$(Configuration) == 'Release'" Name="BeforeBuildCompress" AfterTargets="BeforeBuildLauncherEx">
<GZip Files="@(EmbeddedResource)">
Expand Down
2 changes: 1 addition & 1 deletion src/Bannerlord.BLSE/Bannerlord.BLSE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Version>$(Version).$(GITHUB_RUN_NUMBER)</Version>

<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ public void WriteFileContent(string filePath, byte[]? data)

public string[]? ReadDirectoryFileList(string directoryPath) => Directory.Exists(directoryPath) ? Directory.GetFiles(directoryPath) : null;

public string[]? ReadDirectoryList(string directoryPath) => Directory.Exists(directoryPath) ? Directory.GetFiles(directoryPath) : null;
public string[]? ReadDirectoryList(string directoryPath) => Directory.Exists(directoryPath) ? Directory.GetDirectories(directoryPath) : null;
}
5 changes: 2 additions & 3 deletions src/Bannerlord.LauncherEx/BUTRLauncherManagerHandler.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Bannerlord.LauncherManager.Models;

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Bannerlord.LauncherEx;
Expand All @@ -16,8 +15,6 @@ partial class BUTRLauncherManagerHandler

public override int GetChangeset() => typeof(TaleWorlds.Library.ApplicationVersion).GetField("DefaultChangeSet")?.GetValue(null) as int? ?? 0;

protected override IEnumerable<ModuleInfoExtendedWithPath> ReloadModules() => ModuleInfoHelper.GetModules().Select(x => new ModuleInfoExtendedWithPath(x, x.Path));


// More of a reminder how the callbacks should be handled if needed in C#
public Task<bool> ShowWarning(string title, string contentPrimary, string contentSecondary)
Expand All @@ -42,4 +39,6 @@ public Task<string> ShowFileSave(string title, string fileName, IReadOnlyList<Di
}

public new LoadOrder LoadLoadOrder() => base.LoadLoadOrder();

public new IReadOnlyList<ModuleInfoExtendedWithMetadata> GetAllModules() => base.GetAllModules();
}
5 changes: 4 additions & 1 deletion src/Bannerlord.LauncherEx/Bannerlord.LauncherEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<Version>1.25.0</Version>
Expand All @@ -24,6 +24,9 @@

<PropertyGroup Condition="$(Configuration) == 'Debug'">
<GameVersion>1.2.0</GameVersion>
</PropertyGroup>

<PropertyGroup>
<GameVersionFlat>$([System.String]::Copy('$(GameVersion)').Replace('.',''))</GameVersionFlat>
<GameVersionConstant>v$(GameVersionFlat)</GameVersionConstant>
<DefineConstants>$(DefineConstants);$(GameVersionConstant)</DefineConstants>
Expand Down
63 changes: 24 additions & 39 deletions src/Bannerlord.LauncherEx/Helpers/Input/BUTRInputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,33 @@ public bool IsKeyDownImmediate(InputKey key) =>
public void UpdateKeyData(byte[] keyData) => InputManager.UpdateKeyData(keyData);

public bool IsControllerConnected() => InputManager.IsControllerConnected();
#if v100 || v101 || v102 || v103 || v110 || v111 || v112 || v113 || v114 || v115

#if v100 || v110
public InputKey GetControllerClickKey() => InputManager.GetControllerClickKey();
#endif

#if v110 || v111
public void SetRumbleEffect(float[] lowFrequencyLevels, float[] lowFrequencyDurations, int numLowFrequencyElements, float[] highFrequencyLevels,
float[] highFrequencyDurations, int numHighFrequencyElements) =>
InputManager.SetRumbleEffect(lowFrequencyLevels, lowFrequencyDurations, numLowFrequencyElements, highFrequencyLevels, highFrequencyDurations, numHighFrequencyElements);
public void SetTriggerFeedback(byte leftTriggerPosition, byte leftTriggerStrength, byte rightTriggerPosition, byte rightTriggerStrength) =>
InputManager.SetTriggerFeedback(leftTriggerPosition, leftTriggerStrength, rightTriggerPosition, rightTriggerStrength);
public void SetTriggerWeaponEffect(byte leftStartPosition, byte leftEnd_position, byte leftStrength, byte rightStartPosition, byte rightEndPosition, byte rightStrength) =>
InputManager.SetTriggerWeaponEffect(leftStartPosition, leftEnd_position, leftStrength, rightStartPosition, rightEndPosition, rightStrength);
public void SetTriggerVibration(float[] leftTriggerAmplitudes, float[] leftTriggerFrequencies, float[] leftTriggerDurations, int numLeftTriggerElements,
float[] rightTriggerAmplitudes, float[] rightTriggerFrequencies, float[] rightTriggerDurations, int numRightTriggerElements) =>
InputManager.SetTriggerVibration(leftTriggerAmplitudes, leftTriggerFrequencies, leftTriggerDurations, numLeftTriggerElements, rightTriggerAmplitudes,
rightTriggerFrequencies, rightTriggerDurations, numRightTriggerElements);
public void SetLightbarColor(float red, float green, float blue) => InputManager.SetLightbarColor(red, green, blue);
#if v110 || v120
public void SetRumbleEffect(float[] lowFrequencyLevels, float[] lowFrequencyDurations, int numLowFrequencyElements, float[] highFrequencyLevels, float[] highFrequencyDurations, int numHighFrequencyElements) =>
InputManager.SetRumbleEffect(lowFrequencyLevels, lowFrequencyDurations, numLowFrequencyElements, highFrequencyLevels, highFrequencyDurations, numHighFrequencyElements);
public void SetTriggerFeedback(byte leftTriggerPosition, byte leftTriggerStrength, byte rightTriggerPosition, byte rightTriggerStrength) =>
InputManager.SetTriggerFeedback(leftTriggerPosition, leftTriggerStrength, rightTriggerPosition, rightTriggerStrength);
public void SetTriggerWeaponEffect(byte leftStartPosition, byte leftEnd_position, byte leftStrength, byte rightStartPosition, byte rightEndPosition, byte rightStrength) =>
InputManager.SetTriggerWeaponEffect(leftStartPosition, leftEnd_position, leftStrength, rightStartPosition, rightEndPosition, rightStrength);
public void SetTriggerVibration(float[] leftTriggerAmplitudes, float[] leftTriggerFrequencies, float[] leftTriggerDurations, int numLeftTriggerElements, float[] rightTriggerAmplitudes, float[] rightTriggerFrequencies, float[] rightTriggerDurations, int numRightTriggerElements) =>
InputManager.SetTriggerVibration(leftTriggerAmplitudes, leftTriggerFrequencies, leftTriggerDurations, numLeftTriggerElements, rightTriggerAmplitudes, rightTriggerFrequencies, rightTriggerDurations, numRightTriggerElements);
public void SetLightbarColor(float red, float green, float blue) => InputManager.SetLightbarColor(red, green, blue);
#endif

#if v120
public TaleWorlds.InputSystem.Input.ControllerTypes GetControllerType() => InputManager.GetControllerType();

public float GetGyroX() => InputManager.GetGyroX();
public float GetGyroY() => InputManager.GetGyroY();
public float GetGyroZ() => InputManager.GetGyroZ();

public InputKey[] GetClickKeys() => InputManager.GetClickKeys();

public bool IsAnyTouchActive() => InputManager.IsAnyTouchActive();
#endif

private static TReturn IsAction<TReturn>(InputKey key, Func<Keys, TReturn> action, Func<InputKey, TReturn> fallback)
Expand Down Expand Up @@ -138,31 +148,6 @@ private static TReturn IsAction<TReturn>(InputKey key, Func<Keys, TReturn> actio
return action(rawKey);
}

#if v120
public TaleWorlds.InputSystem.Input.ControllerTypes GetControllerType() => InputManager.GetControllerType();

public float GetGyroX() => InputManager.GetGyroX();
public float GetGyroY() => InputManager.GetGyroY();
public float GetGyroZ() => InputManager.GetGyroZ();

public InputKey[] GetClickKeys() => InputManager.GetClickKeys();

public void SetRumbleEffect(float[] lowFrequencyLevels, float[] lowFrequencyDurations, int numLowFrequencyElements, float[] highFrequencyLevels, float[] highFrequencyDurations, int numHighFrequencyElements) =>
InputManager.SetRumbleEffect(lowFrequencyLevels, lowFrequencyDurations, numLowFrequencyElements, highFrequencyLevels, highFrequencyDurations, numHighFrequencyElements);

public void SetTriggerFeedback(byte leftTriggerPosition, byte leftTriggerStrength, byte rightTriggerPosition, byte rightTriggerStrength) =>
InputManager.SetTriggerFeedback(leftTriggerPosition, leftTriggerStrength, rightTriggerPosition, rightTriggerStrength);

public void SetTriggerWeaponEffect(byte leftStartPosition, byte leftEnd_position, byte leftStrength, byte rightStartPosition, byte rightEndPosition, byte rightStrength) =>
InputManager.SetTriggerWeaponEffect(leftStartPosition, leftEnd_position, leftStrength, rightStartPosition, rightEndPosition, rightStrength);

public void SetTriggerVibration(float[] leftTriggerAmplitudes, float[] leftTriggerFrequencies, float[] leftTriggerDurations, int numLeftTriggerElements, float[] rightTriggerAmplitudes, float[] rightTriggerFrequencies, float[] rightTriggerDurations, int numRightTriggerElements) =>
InputManager.SetTriggerVibration(leftTriggerAmplitudes, leftTriggerFrequencies, leftTriggerDurations, numLeftTriggerElements, rightTriggerAmplitudes, rightTriggerFrequencies, rightTriggerDurations, numRightTriggerElements);

public void SetLightbarColor(float red, float green, float blue) => InputManager.SetLightbarColor(red, green, blue);

public bool IsAnyTouchActive() => InputManager.IsAnyTouchActive();
#endif

public void Dispose()
{
Expand Down
10 changes: 1 addition & 9 deletions src/Bannerlord.LauncherEx/Helpers/ModuleChecker.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Bannerlord.BUTR.Shared.Helpers;
using Bannerlord.LauncherManager.Extensions;
using Bannerlord.LauncherManager.Models;
using Bannerlord.ModuleManager;

using Mono.Cecil;
using Mono.Cecil.Rocks;

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

Expand All @@ -18,13 +16,7 @@ namespace Bannerlord.LauncherEx.Helpers;
// TODO: NativeAOT won't cover that?
internal static class ModuleChecker
{
private static readonly HashSet<string> MainModules = ModuleInfoHelper.GetPhysicalModules().Select(x => x.Id).ToHashSet();
private static readonly HashSet<string> ExternalModules = ModuleInfoHelper.GetPlatformModules().Select(x => x.Id).ToHashSet();

public static bool IsInstalledInMainAndExternalModuleDirectory(ModuleInfoExtendedWithPath moduleInfoExtended) =>
MainModules.Contains(moduleInfoExtended.Id) && ExternalModules.Contains(moduleInfoExtended.Id);

public static bool IsObfuscated(ModuleInfoExtendedWithPath moduleInfoExtended)
public static bool IsObfuscated(ModuleInfoExtendedWithMetadata moduleInfoExtended)
{
static bool CanBeLoaded(SubModuleInfoExtended x) =>
ModuleInfoHelper.CheckIfSubModuleCanBeLoaded(x, ApplicationPlatform.CurrentPlatform, ApplicationPlatform.CurrentRuntimeLibrary, TaleWorlds.MountAndBlade.DedicatedServerType.None, false);
Expand Down
22 changes: 20 additions & 2 deletions src/Bannerlord.LauncherEx/Mixins/LauncherModsVMMixin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ internal sealed class LauncherModsVMMixin : ViewModelMixin<LauncherModsVMMixin,
private readonly BUTRLauncherManagerHandler _launcherManagerHandler = BUTRLauncherManagerHandler.Default;
private readonly MBBindingList<BUTRLauncherModuleVM> _modules = new();
private readonly Dictionary<string, BUTRLauncherModuleVM> _modulesLookup = new();
private IReadOnlyList<ModuleInfoExtendedWithMetadata> _allModuleInfos;

[BUTRDataSourceProperty]
public bool GlobalCheckboxState { get => _checkboxState; set => SetField(ref _checkboxState, value); }
Expand Down Expand Up @@ -96,9 +97,10 @@ public LauncherModsVMMixin(LauncherModsVM launcherModsVM) : base(launcherModsVM)
_launcherManagerHandler.RegisterModuleViewModelProvider(() => _modules, () => Modules2, SetViewModels);

_launcherManagerHandler.RefreshModules();
foreach (var moduleInfoExtended in _launcherManagerHandler.ExtendedModuleInfoCache.Values.OfType<ModuleInfoExtendedWithPath>())
_allModuleInfos = _launcherManagerHandler.GetAllModules();
foreach (var moduleInfoExtended in _launcherManagerHandler.ExtendedModuleInfoCache.Values.OfType<ModuleInfoExtendedWithMetadata>())
{
var moduleVM = new BUTRLauncherModuleVM(moduleInfoExtended, ToggleModuleSelection, ValidateModule);
var moduleVM = new BUTRLauncherModuleVM(moduleInfoExtended, ToggleModuleSelection, ValidateModule, GetPossibleProviders);
_modules.Add(moduleVM);
_modulesLookup[moduleVM.ModuleInfoExtended.Id] = moduleVM;
}
Expand Down Expand Up @@ -144,9 +146,15 @@ private void SetViewModels(IEnumerable<IModuleViewModel> orderedModuleViewModels
foreach (var viewModel in orderedModuleViewModels.OfType<BUTRLauncherModuleVM>())
Modules2.Add(viewModel);

_launcherManagerHandler.RefreshModules();
_allModuleInfos = _launcherManagerHandler.GetAllModules();

// Validate all VM's after they were selected and ordered
foreach (var modules in Modules2)
{
modules.Validate();
modules.Refresh();
}

_launcherManagerHandler.SetGameParametersLoadOrder(Modules2);
}
Expand All @@ -157,6 +165,10 @@ private void ToggleModuleSelection(BUTRLauncherModuleVM moduleVM)
SortHelper.ToggleModuleSelection(Modules2, _modulesLookup, moduleVM);
_launcherManagerHandler.SetGameParametersLoadOrder(Modules2);
}
private ICollection<ModuleProviderType> GetPossibleProviders(ModuleInfoExtendedWithMetadata moduleInfo) => _allModuleInfos
.Where(x => x.Id == moduleInfo.Id && x.ModuleProviderType != moduleInfo.ModuleProviderType)
.Select(x => x.ModuleProviderType)
.ToList();

private void ChangeModulePosition(BUTRLauncherModuleVM targetModuleVM, int insertIndex, Action<IReadOnlyCollection<string>>? onIssues = null)
{
Expand Down Expand Up @@ -201,6 +213,12 @@ static IEnumerable<ModuleInfoExtended> Sort(IEnumerable<ModuleInfoExtended> sour
Modules2.Sort(new ByIndexComparer<BUTRLauncherModuleVM>(x => sorted.TryGetValue(x.ModuleInfoExtended.Id, out var idx) ? idx : -1));
//var sorted = Sort(Modules2.Select(x => x.ModuleInfoExtended)).Select(x => x.Id).ToList();
//SortBy(sorted);

_launcherManagerHandler.RefreshModules();
_allModuleInfos = _launcherManagerHandler.GetAllModules();
foreach (var moduleVM in Modules2)
moduleVM.Refresh();

_launcherManagerHandler.SetGameParametersLoadOrder(Modules2);
}

Expand Down
Loading

0 comments on commit 2132414

Please sign in to comment.