Skip to content

Commit

Permalink
Update, part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Jan 16, 2021
1 parent e9de0a4 commit 4e80b37
Show file tree
Hide file tree
Showing 26 changed files with 77 additions and 541 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,4 @@ MigrationBackup/
.ionide/
/docfx/*
/bannerlord/*
/test/*
3 changes: 2 additions & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<!--Microsoft Extension Libraries Version-->
<ExtensionVersion>2.0.0</ExtensionVersion>
<!--BuildResources Version-->
<BuildResourcesVersion>1.0.0.32</BuildResourcesVersion>
<BuildResourcesVersion>1.0.0.33</BuildResourcesVersion>
<BUTRSharedVersion>1.6.1.19</BUTRSharedVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.ButterLib.CampaignIdentifier;
using Bannerlord.BUTR.Shared.Helpers;
using Bannerlord.ButterLib.CampaignIdentifier;
using Bannerlord.ButterLib.Common.Extensions;

using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -81,13 +82,13 @@ private void AddDescriptorToExistingCampaign()
true,
string.Join(" - ", existingDescriptor.Descriptor, existingDescriptor.KeyValue)));

var newIdTextObject = new TextObject("{=wF4qRrhmEu}Assign new ID");
var inquiryBody = $"{new TextObject(InquiryUpperBody)}\n \n{new TextObject(InquiryLowerBody, new Dictionary<string, TextObject> {["NEW_ID"] = newIdTextObject})}";
var newIdTextObject = TextObjectHelper.Create("{=wF4qRrhmEu}Assign new ID");
var inquiryBody = $"{TextObjectHelper.Create(InquiryUpperBody)}\n \n{TextObjectHelper.Create(InquiryLowerBody, new Dictionary<string, TextObject> {["NEW_ID"] = newIdTextObject})}";
inquiryElements.Add(new InquiryElement(null, newIdTextObject.ToString(),
new ImageIdentifier(), true,
new TextObject("{=25Ts3iQnv6}This is a standalone campaign and must be assigned a new ID.").ToString()));
TextObjectHelper.Create("{=25Ts3iQnv6}This is a standalone campaign and must be assigned a new ID.").ToString()));
InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData(
new TextObject("{=4BuIRaILsb}Select identified ongoing campaign").ToString(),
TextObjectHelper.Create("{=4BuIRaILsb}Select identified ongoing campaign").ToString(),
inquiryBody, inquiryElements, true, 1, GameTexts.FindText("str_done").ToString(), "",
OnDescriptorSelectionOver,
OnDescriptorSelectionOver));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.ButterLib.CampaignIdentifier;
using Bannerlord.BUTR.Shared.Helpers;
using Bannerlord.ButterLib.CampaignIdentifier;
using Bannerlord.ButterLib.Implementation.CampaignIdentifier.Helpers;

using System;
Expand Down Expand Up @@ -168,11 +169,11 @@ private string GetLocalizableValue()
var cultureName = (string) _attributes[DescriptorAttribute.HeroCulture];
cultureName = Regex.Replace(cultureName, @"\{[\\?=][^}]*\}", string.Empty);

var resultTextObject = new TextObject(LocalizableValue);
var parentsInfoTextObject = new TextObject(LocalizableParentsInfo);
var resultTextObject = TextObjectHelper.Create(LocalizableValue);
var parentsInfoTextObject = TextObjectHelper.Create(LocalizableParentsInfo);

//BASE_DESCRIPTOR_HERO
var baseHeroTextObject = new TextObject();
var baseHeroTextObject = TextObjectHelper.Create("");
baseHeroTextObject.SetTextVariable("NAME", (string) _attributes[DescriptorAttribute.HeroName]);
baseHeroTextObject.SetTextVariable("CLAN", familyName.Length > 0 ? 1 : 0);
baseHeroTextObject.SetTextVariable("CLAN_NAME", familyName);
Expand Down Expand Up @@ -202,7 +203,7 @@ private string GetLocalizableValue()
MBTextManager.SetTextVariable("BASE_DESCRIPTOR_HERO", baseHeroTextObject);

//BASE_DESCRIPTOR_HERO_PARENTS
var parentsTextObject = new TextObject(fatherName.Length > 0 || motherName.Length > 0 ? 1 : 0);
var parentsTextObject = TextObjectHelper.Create(fatherName.Length > 0 || motherName.Length > 0 ? 1 : 0);
parentsTextObject.SetTextVariable("INFO", parentsInfoTextObject);
resultTextObject.SetTextVariable("BASE_DESCRIPTOR_HERO_PARENTS", parentsTextObject);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private Dictionary<ulong, float> CalculateDistanceMatrix()
}
if (typeof(Clan).IsAssignableFrom(typeof(T)))
{
var clans = Clan.All.Where(c => c.IsInitialized && c.Fortifications.Count > 0).ToList();
var clans = Clan.All.Where(c => c.IsInitialized && c.Fiefs.Count > 0).ToList();
var settlementDistanceMatrix = Campaign.Current.GetCampaignBehavior<GeopoliticsCachingBehavior>().SettlementDistanceMatrix ?? new DistanceMatrixImplementation<Settlement>();
var lst = GetSettlementOwnersPairedList(settlementDistanceMatrix);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void UpdateOnSettlementOwnerChanged(Settlement settlement, bool openToCl

if ((newOwner.Clan is not null || oldOwner.Clan is not null) && newOwner.Clan != oldOwner.Clan)
{
var clans = Clan.All.Where(c => c.IsInitialized && c.Fortifications.Count > 0).ToList();
var clans = Clan.All.Where(c => c.IsInitialized && c.Fiefs.Count > 0).ToList();

if (oldOwner.Clan is not null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* Authors: sirdoombox, BUTR.
*/

using Bannerlord.BUTR.Shared.Helpers;
using Bannerlord.ButterLib.HotKeys;

using System.Collections.Generic;

using TaleWorlds.Core;
using TaleWorlds.InputSystem;
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;

namespace Bannerlord.ButterLib.Implementation.HotKeys
Expand All @@ -26,8 +26,8 @@ public HotKeyCategoryContainer(string categoryId, IEnumerable<HotKeyBase> keys)
var variationString = $"{categoryId}_";
foreach (var key in keys)
{
keyName.AddVariationWithId($"{variationString}{key.Id}", new TextObject(key.DisplayName), new List<GameTextManager.ChoiceTag>());
keyDesc.AddVariationWithId($"{variationString}{key.Id}", new TextObject(key.Description), new List<GameTextManager.ChoiceTag>());
keyName.AddVariationWithId($"{variationString}{key.Id}", TextObjectHelper.Create(key.DisplayName), new List<GameTextManager.ChoiceTag>());
keyDesc.AddVariationWithId($"{variationString}{key.Id}", TextObjectHelper.Create(key.Description), new List<GameTextManager.ChoiceTag>());
RegisterGameKey(new GameKey(key.Id, key.Uid, categoryId, key.DefaultKey, key.Category));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static void OnApplicationTick(float dt)
hotKey.OnPressedInternal();
if (hotKey.GameKey.PrimaryKey.InputKey.IsReleased())
hotKey.OnReleasedInternal();
#elif e155 || e156
#else
if (hotKey.GameKey.KeyboardKey?.InputKey.IsDown() == true || hotKey.GameKey.ControllerKey?.InputKey.IsDown() == true)
hotKey.IsDownInternal();
if (hotKey.GameKey.KeyboardKey?.InputKey.IsPressed() == true || hotKey.GameKey.ControllerKey?.InputKey.IsPressed() == true)
Expand Down
2 changes: 2 additions & 0 deletions src/Bannerlord.ButterLib.Implementation/_Module/SubModule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
<!--Helper libraries-->
<Assembly value="System.Runtime.CompilerServices.Unsafe.dll" />
<Assembly value="Microsoft.Bcl.HashCode.dll" />
<Assembly value="System.Reflection.Metadata.dll" />
<Assembly value="System.Collections.Immutable.dll" />
</Assemblies>
<Tags />
</SubModule>
Expand Down
5 changes: 5 additions & 0 deletions src/Bannerlord.ButterLib/Bannerlord.ButterLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<BUTRUploadUrl>$(BANNERLORD_BUTR_UPLOAD_URL)</BUTRUploadUrl>
<DefineConstants>$(DefineConstants);BANNERLORDBUTRSHARED_BUTTERLIB</DefineConstants>
</PropertyGroup>

<!--NuGet Package-->
Expand Down Expand Up @@ -36,6 +37,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Bannerlord.BUTR.Shared" Version="$(BUTRSharedVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="IsExternalInit" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
21 changes: 11 additions & 10 deletions src/Bannerlord.ButterLib/ButterLibSubModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Bannerlord.ButterLib.CampaignIdentifier;
using Bannerlord.BUTR.Shared.Helpers;
using Bannerlord.ButterLib.CampaignIdentifier;
using Bannerlord.ButterLib.Common.Extensions;
using Bannerlord.ButterLib.Common.Helpers;
using Bannerlord.ButterLib.CrashUploader;
using Bannerlord.ButterLib.DelayedSubModule;
using Bannerlord.ButterLib.ExceptionHandler;
Expand All @@ -17,9 +17,10 @@

using TaleWorlds.CampaignSystem;
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;

using ModuleInfoHelper = Bannerlord.ButterLib.Common.Helpers.ModuleInfoHelper;

namespace Bannerlord.ButterLib
{
/// <summary>
Expand Down Expand Up @@ -194,7 +195,7 @@ private static void CheckLoadOrder()
if (harmonyModuleIndex == -1)
{
if (sb.Length != 0) sb.AppendLine();
sb.AppendLine(new TextObject(SErrorHarmonyNotFound).ToString());
sb.AppendLine(TextObjectHelper.Create(SErrorHarmonyNotFound).ToString());
}

// TODO: Keep it optional for now
Expand All @@ -204,7 +205,7 @@ private static void CheckLoadOrder()
if (moduleLoaderIndex == -1)
{
if (sb.Length != 0) sb.AppendLine();
sb.AppendLine(new TextObject(SErrorModuleLoaderNotFound).ToString());
sb.AppendLine(TextObjectHelper.Create(SErrorModuleLoaderNotFound).ToString());
}
*/

Expand All @@ -213,26 +214,26 @@ private static void CheckLoadOrder()
if (butterLibModuleIndex == -1)
{
if (sb.Length != 0) sb.AppendLine();
sb.AppendLine(new TextObject(SErrorButterLibNotFound).ToString());
sb.AppendLine(TextObjectHelper.Create(SErrorButterLibNotFound).ToString());
}

var officialModules = loadedModules.Where(x => x.IsOfficial).Select(x => (Module: x, Index: loadedModules.IndexOf(x)));
var modulesLoadedBeforeButterLib = officialModules.Where(tuple => tuple.Index < butterLibModuleIndex).ToList();
if (modulesLoadedBeforeButterLib.Count > 0)
{
if (sb.Length != 0) sb.AppendLine();
sb.AppendLine(new TextObject(SErrorOfficialModulesLoadedBeforeButterLib).ToString());
sb.AppendLine(new TextObject(SErrorOfficialModules).ToString());
sb.AppendLine(TextObjectHelper.Create(SErrorOfficialModulesLoadedBeforeButterLib).ToString());
sb.AppendLine(TextObjectHelper.Create(SErrorOfficialModules).ToString());
foreach (var (module, _) in modulesLoadedBeforeButterLib)
sb.AppendLine(module.Id);
}

if (sb.Length > 0)
{
sb.AppendLine();
sb.AppendLine(new TextObject(SMessageContinue).ToString());
sb.AppendLine(TextObjectHelper.Create(SMessageContinue).ToString());

switch (MessageBox.Show(sb.ToString(), new TextObject(SWarningTitle).ToString(), MessageBoxButtons.YesNo))
switch (MessageBox.Show(sb.ToString(), TextObjectHelper.Create(SWarningTitle).ToString(), MessageBoxButtons.YesNo))
{
case DialogResult.Yes:
Environment.Exit(1);
Expand Down
2 changes: 0 additions & 2 deletions src/Bannerlord.ButterLib/ExceptionHandler/HtmlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,7 @@ void AppendAdditionalAssemblies(ExtendedModuleInfo module)
.AppendLine($"<div id='{module.Id}' style='display: none'>")
.Append("Id: ").Append(module.Id).AppendLine("</br>")
.Append("Name: ").Append(module.Name).AppendLine("</br>")
.Append("Alias: ").Append(module.Alias).AppendLine("</br>")
.Append("Version: ").Append(module.Version.ToString()).AppendLine("</br>")
//.Append("Selected: ").Append(module.IsSelected.ToString()).AppendLine("</br>")
.Append("Official: ").Append(module.IsOfficial.ToString()).AppendLine("</br>")
.Append("Singleplayer: ").Append(module.IsSingleplayerModule.ToString()).AppendLine("</br>")
.Append("Multiplayer: ").Append(module.IsMultiplayerModule.ToString()).AppendLine("</br>")
Expand Down
24 changes: 0 additions & 24 deletions src/Bannerlord.ButterLib/Extensions/DictionaryExtensions.cs

This file was deleted.

Loading

0 comments on commit 4e80b37

Please sign in to comment.