Skip to content

Commit

Permalink
Merge pull request #414 from Aragas/dev
Browse files Browse the repository at this point in the history
v5.8.0
  • Loading branch information
Aragas authored Jul 10, 2023
2 parents 7e8df4c + cc9bc48 commit c5b05cb
Show file tree
Hide file tree
Showing 16 changed files with 279 additions and 62 deletions.
27 changes: 12 additions & 15 deletions .github/workflows/verify-unex-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ env:
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
verify-unex-data:
name: Verify UNEX Data
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: '3.1.x'
- name: Check
env:
UNEX_APIKEY: ${{ secrets.NEXUSMODS_APIKEY }}
UNEX_COOKIES: ${{ secrets.NEXUSMODS_COOKIES }}
run: |
dotnet tool install -g NexusUploader
unex check
#verify-nexusmods:
# uses: BUTR/workflows/.github/workflows/verify-nexusmods.yml@master
# secrets:
# NEXUSMODS_API_KEY: ${{ secrets.NEXUSMODS_APIKEY }}
# NEXUSMODS_COOKIE_NEXUSID: ${{ secrets.ARAGAS_NEXUSMOD_COOKIE_NEXUSID }}
# NEXUSMODS_COOKIE_SID_DEVELOP: ${{ secrets.ARAGAS_NEXUSMOD_COOKIE_SID_DEVELOP }}

unex-verify-nexusmods:
uses: BUTR/workflows/.github/workflows/verify-unex-nexusmods.yml@master
secrets:
NEXUSMODS_API_KEY: ${{ secrets.NEXUSMODS_APIKEY }}
NEXUSMODS_COOKIES: ${{ secrets.NEXUSMODS_COOKIES }}
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnexusmods-downloads-ayuqql60xfxb.runkit.sh%2F%3Ftype%3Dviews%26gameId%3D3174%26modId%3D612" />
</a>
</br>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859238197">
<img alt="Steam Mod Configuration Menu" src="https://img.shields.io/badge/Steam-Mod%20Configuration%20Menu-blue.svg" />
</a>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859238197">
<img alt="Steam Downloads" src="https://img.shields.io/steam/downloads/2859238197?label=Downloads&color=blue">
</a>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859238197">
<img alt="Steam Views" src="https://img.shields.io/steam/views/2859238197?label=Views&color=blue">
</a>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859238197">
<img alt="Steam Subscriptions" src="https://img.shields.io/steam/subscriptions/2859238197?label=Subscriptions&color=blue">
</a>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859238197">
<img alt="Steam Favorites" src="https://img.shields.io/steam/favorites/2859238197?label=Favorites&color=blue">
</a>
</br>
<img src="https://staticdelivery.nexusmods.com/mods/3174/images/headers/612_1592411190.jpg" width="800">
</br>
<img src="https://github.com/Aragas/Bannerlord.MBOptionScreen/blob/dev/resources/main.png?raw=true" width="800">
Expand Down
8 changes: 4 additions & 4 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

<PropertyGroup>
<GameVersion>1.0.0</GameVersion>
<Version>5.7.2</Version>
<Version>5.8.0</Version>
<HarmonyVersion>2.2.2</HarmonyVersion>
<ButterLibVersion>2.8.0</ButterLibVersion>
<ButterLibVersion>2.8.8</ButterLibVersion>
<UIExtenderExVersion>2.8.0</UIExtenderExVersion>
<BuildResourcesVersion>1.1.0.102</BuildResourcesVersion>
<BUTRSharedVersion>3.0.0.136</BUTRSharedVersion>
<BUTRSharedVersion>3.0.0.137</BUTRSharedVersion>
<BUTRDependencyInjectionVersion>2.0.0.52</BUTRDependencyInjectionVersion>
<BUTRModuleManagerVersion>5.0.209</BUTRModuleManagerVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
<HarmonyAnalyzerVersion>1.0.1.44</HarmonyAnalyzerVersion>
<HarmonyAnalyzerVersion>1.0.1.50</HarmonyAnalyzerVersion>
<LightInjectVersion>6.6.4</LightInjectVersion>
<LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable>
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---------------------------------------------------------------------------------------------------
Version: 5.8.0
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.2.0
* Added the ability to save custom Presets
* Fluent Settings now capture correctly the 'Default' preset state when building the settings
* Added Japanese support by Gedevan-Aleksizde
---------------------------------------------------------------------------------------------------
Version: 5.7.2
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.2.0
* Adapted UI to v1.2.0
Expand Down
4 changes: 4 additions & 0 deletions src/MCM.Abstractions/Presets/JsonSettingsPreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ sealed class JsonSettingsPreset : ISettingsPreset
{
private class PresetContainerDefinition
{
[JsonProperty(Order = 1)]
public string Id { get; set; } = string.Empty;

[JsonProperty(Order = 2)]
public string Name { get; set; } = string.Empty;
}
private sealed class PresetContainer : PresetContainerDefinition
{
[JsonProperty(Order = 3)]
public BaseSettings? Settings { get; set; }
}

Expand Down
4 changes: 1 addition & 3 deletions src/MCM.Abstractions/Providers/BaseSettingsProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using BUTR.DependencyInjection;

using MCM.Abstractions.Base;
using MCM.Abstractions.Base;

using System.Collections.Generic;

Expand Down
7 changes: 3 additions & 4 deletions src/MCM.Implementation/Containers/BaseSettingsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@ public IEnumerable<ISettingsPreset> GetPresets(string settingsId)
if (GenericServiceProvider.GetService<IFileSystemProvider>() is not { } fileSystemProvider)
yield break;

var folderDirectory = fileSystemProvider.GetOrCreateDirectory(RootFolder, settings.FolderName);
var folderWithSubFolderDirectory = string.IsNullOrEmpty(settings.SubFolder) ? folderDirectory : fileSystemProvider.GetOrCreateDirectory(folderDirectory, settings.SubFolder);
var directory = fileSystemProvider.GetOrCreateDirectory(folderWithSubFolderDirectory, "Presets");
var presetsDirectory = fileSystemProvider.GetOrCreateDirectory(fileSystemProvider.GetModSettingsDirectory(), "Presets");
var settingsDirectory = fileSystemProvider.GetOrCreateDirectory(presetsDirectory, settingsId);

foreach (var filePath in fileSystemProvider.GetFiles(directory, "*.json"))
foreach (var filePath in fileSystemProvider.GetFiles(settingsDirectory, "*.json"))
{
if (JsonSettingsPreset.FromFile(settings, filePath) is { } preset)
yield return preset;
Expand Down
47 changes: 41 additions & 6 deletions src/MCM.Implementation/FluentBuilder/DefaultSettingsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,49 @@ public override ISettingsBuilder WithoutDefaultPreset()
}

/// <inheritdoc/>
public override FluentGlobalSettings BuildAsGlobal() => new(
Id, DisplayName, FolderName, SubFolder, Format, UIVersion, SubGroupDelimiter, OnPropertyChanged, GetSettingPropertyGroups(), Presets.Values);
public override FluentGlobalSettings BuildAsGlobal()
{
// Capture the default state
if (Presets.TryGetValue(BaseSettings.DefaultPresetId, out var preset))
{
foreach (var property in GetSettingProperties())
preset.SetPropertyValue(property.Id, property.PropertyReference.Value);
}

return new FluentGlobalSettings(
Id, DisplayName, FolderName, SubFolder, Format, UIVersion, SubGroupDelimiter, OnPropertyChanged,
GetSettingPropertyGroups(), Presets.Values);
}

/// <inheritdoc/>
public override FluentPerSaveSettings BuildAsPerSave() => new(
Id, DisplayName, FolderName, SubFolder, UIVersion, SubGroupDelimiter, OnPropertyChanged, GetSettingPropertyGroups(), Presets.Values);
public override FluentPerSaveSettings BuildAsPerSave()
{
// Capture the default state
if (Presets.TryGetValue(BaseSettings.DefaultPresetId, out var preset))
{
foreach (var property in GetSettingProperties())
preset.SetPropertyValue(property.Id, property.PropertyReference.Value);
}

return new FluentPerSaveSettings(
Id, DisplayName, FolderName, SubFolder, UIVersion, SubGroupDelimiter, OnPropertyChanged,
GetSettingPropertyGroups(), Presets.Values);
}

/// <inheritdoc/>
public override FluentPerCampaignSettings BuildAsPerCampaign() => new(
Id, DisplayName, FolderName, SubFolder, UIVersion, SubGroupDelimiter, OnPropertyChanged, GetSettingPropertyGroups(), Presets.Values);
public override FluentPerCampaignSettings BuildAsPerCampaign()
{
// Capture the default state
if (Presets.TryGetValue(BaseSettings.DefaultPresetId, out var preset))
{
foreach (var property in GetSettingProperties())
preset.SetPropertyValue(property.Id, property.PropertyReference.Value);
}

return new FluentPerCampaignSettings(
Id, DisplayName, FolderName, SubFolder, UIVersion, SubGroupDelimiter, OnPropertyChanged,
GetSettingPropertyGroups(), Presets.Values);
}

private IEnumerable<SettingsPropertyGroupDefinition> GetSettingPropertyGroups() =>
SettingsUtils.GetSettingsPropertyGroups(SubGroupDelimiter, GetSettingProperties());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ public ISettingsPresetBuilder SetPropertyValue(string property, object? value)
/// <inheritdoc />
public ISettingsPreset Build(BaseSettings settings) => new MemorySettingsPreset(settings.Id, Id, Name, () =>
{
var props = settings.GetAllSettingPropertyDefinitions().ToList();
foreach (var kv in PropertyValues)
var settingsProperties = settings.GetAllSettingPropertyDefinitions().ToList();
foreach (var overridePropertyKeyValue in PropertyValues)
{
if (props.Find(x => x.Id == kv.Key) is { } property)
property.PropertyReference.Value = kv.Value;
var overridePropertyId = overridePropertyKeyValue.Key;
var overridePropertyValue = overridePropertyKeyValue.Value;

if (settingsProperties.Find(x => x.Id == overridePropertyId) is { } property)
property.PropertyReference.Value = overridePropertyValue;
}
return settings;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,10 @@
<string id="ButterLibSettings_Name_Logging" text="Logging"/>
<string id="ButterLibSettings_Name_LogLevel" text="Log Level"/>
<string id="ButterLibSettings_Name_LogLevelDesc" text="Level of logs to write."/>

<string id="ModOptionsVM_SaveAsPreset" text="Save As Preset"/>
<string id="ModOptionsVM_SaveAsPresetDesc" text="Choose the name of the preset"/>
<string id="ModOptionsVM_OverridePreset" text="Preset Already Exists"/>
<string id="ModOptionsVM_OverridePresetDesc" text="Preset already exists! Do you want to override it?"/>
</strings>
</base>
41 changes: 41 additions & 0 deletions src/MCM.Publish/_Module/ModuleData/Languages/JP/sta_strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<base xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/BUTR/Bannerlord.XmlSchemas/master/ModuleLanguage.xsd">
<tags>
<tag language="日本語"/>
</tags>
<strings>
<string id="MCMSettings_Name" text="Mod Configuration Menu {VERSION}"/>
<string id="BaseSettings_Default" text="デフォルト"/>
<string id="SettingsPropertyGroupDefinition_Misc" text="その他"/>
<!-- UI -->
<string id="dzeWx4xSfR" text="MCM からの警告!"/>
<string id="FE6ya1gzZR" text="モジュール {REQUIRED_MODULE} が見つかりません!"/>
<string id="EvI6KPAqTT" text="互換性のないモジュール {DENIED_MODULE} が検出されました!"/>
<string id="5G9zffrgMh" text="{MODULE} が {DEPENDENT_MODULE} より前に読み込まれています!{NL}{MODULE} が後に読み込まれるように確認してください!"/>
<string id="UZ8zfvudMs" text="{MODULE} が {DEPENDENT_MODULE} より後に読み込まれています!{NL}{MODULE} が先に読み込まれるように確認してください!"/>
<string id="FcR4BXnhx8" text="{MODULE} は {REQUIRED_MODULE} に対して互いに矛盾するロード順が指定されています!"/>
<string id="eXs6FLm5DP" text="すぐにゲームを終了することを強く推奨します。今すぐ終了しますか?"/>
<string id="fGt6Gthg5y" text="このバージョンの MCM は本体のバージョン v1.0.0 以降の想定しています! 現在起動しているバージョンは {GAMEVERSION} です!"/>

<string id="MCMUISettings_Name" text="MCM UI {VERSION}"/>
<string id="ModOptionsVM_NotSpecified" text="Mod 名が指定されていません"/>
<string id="ModOptionsVM_Name" text="Mod オプション"/>
<string id="ModOptionsVM_ChangeToPreset" text="プリセットを '{PRESET}' へ変更"/>
<string id="ModOptionsVM_Discard" text="本当に {NAME} の現在の設定から '{ITEM}' を削除しますか?"/>
<string id="ModOptionsVM_RestartTitle" text="ゲームの再起動が必要です"/>
<string id="ModOptionsVM_RestartDesc" text="Mod の設定変更を適用するにはゲームの再起動が必要です。今すぐゲームを終了しますか?"/>
<string id="SettingsPropertyGroupVM_Disabled" text="{GROUPNAME} (無効)"/>
<string id="SettingsVM_Custom" text="カスタム"/>
<string id="ModOptionsPageView_Mods" text="Mod"/>
<string id="MainMenu_ModOptions" text="Mod オプション"/>
<string id="EscapeMenu_ModOptions" text="Mod オプション"/>
<string id="MCMUISettings_Name" text="MCM UI Impl. {VERSION}"/>
<string id="MCMUISettings_Name_General" text="全般"/>
<string id="MCMUISettings_Name_HideMainMenuEntry" text="メインメニューの項目を隠す"/>
<string id="MCMUISettings_Name_HideMainMenuEntryDesc" text="メインメニューからMCM の「Mod オプション」の項目を隠します。"/>
<string id="ButterLibSettings_Name" text="ButterLib {VERSION}"/>
<string id="ButterLibSettings_Name_Logging" text="ロギング"/>
<string id="ButterLibSettings_Name_LogLevel" text="ログレベル"/>
<string id="ButterLibSettings_Name_LogLevelDesc" text="出力するログのレベルです"/>
</strings>
</base>
21 changes: 20 additions & 1 deletion src/MCM.UI/GUI/Prefabs/ModOptionsView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<Children>
<!-- Dropdown Presets -->
<Widget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="300" SuggestedHeight="42" HorizontalAlignment="Left"
VerticalAlignment="Center" MarginLeft="20" MarginRight="40" IsVisible="@IsPresetsSelectorVisible">
VerticalAlignment="Center" MarginLeft="20" MarginRight="40" IsVisible="@IsPresetsSelectorVisible">
<Children>
<Standard.DropdownWithHorizontalControl HorizontalAlignment="Center" Parameter.SelectorDataSource="{PresetsSelectorCopy}"
Parameter.ShowNextAndPrevious="false" />
Expand All @@ -127,6 +127,25 @@

</Children>
</ListPanel>

<!-- Preset Section -->
<ListPanel WidthSizePolicy="StretchToParent" HeightSizePolicy="Fixed" SuggestedHeight="80" LayoutImp.LayoutMethod="HorizontalLeftToRight"
HorizontalAlignment="Center" VerticalAlignment="Top" MarginBottom="-20" MarginTop="-30" >
<Children>

<!-- Save As Preset -->
<ButtonWidget SuggestedWidth="200" SuggestedHeight="64" HorizontalAlignment="Left" VerticalAlignment="Center"
MarginLeft="10" DoNotPassEventsToChildren="true" Brush="MCM.Cancel.Button" Command.Click="ExecuteSaveAsPreset"
IsVisible="@CanSaveAsPreset" >
<Children>
<TextWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" VerticalAlignment="Center" HorizontalAlignment="Center"
Text="@SaveAsPreset" Brush="MCM.Button.Text" />
</Children>
</ButtonWidget>

</Children>
</ListPanel>

<!-- Separator -->
<BrushWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="Fixed" SuggestedHeight="2" VerticalAlignment="Top" Brush="MCM.Divider.Yellow" MarginLeft="15" MarginRight="15"/>

Expand Down
Loading

0 comments on commit c5b05cb

Please sign in to comment.