- Added extra source code translation (for CTS).

- Added localization to SettingList.cs display dropdown.
This commit is contained in:
MapleWheels
2026-04-08 08:09:45 -04:00
parent 232f7203e2
commit 4c8e016dea
2 changed files with 10 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.Toolkit.Diagnostics;
@@ -100,10 +101,16 @@ public class SettingList<T> : SettingEntry<T>, ISettingList<T> where T : IEquata
#if CLIENT
public override void AddDisplayComponent(GUILayoutGroup layoutGroup, Vector2 relativeSize, Action<string> onSerializedValue)
{
GUIUtil.Dropdown(layoutGroup, (T val) => val.ToString(), null, Options, Value, (T val) =>
GUIUtil.Dropdown(layoutGroup, (T val) => GetLocalizedString(val.ToString(), val.ToString()), null, Options, Value, (T val) =>
{
onSerializedValue?.Invoke(val.ToString());
}, new Vector2(relativeSize.X, 1f));
string GetLocalizedString(string identifier, string defaultValue)
{
var lstr = TextManager.Get($"{XmlConvert.EncodeLocalName(OwnerPackage.Name)}.{InternalName}.{identifier}.DisplayName");
return lstr.IsNullOrWhiteSpace() ? defaultValue : lstr.Value;
}
}
#endif

View File

@@ -660,7 +660,8 @@ public class PluginManagementService : IAssemblyManagementService
{
return sourceCode
.Replace("GameMain.LuaCs", "LuaCsSetup.Instance")
.Replace("Client.ClientList", "ModUtils.Client.ClientList")
.Replace(" Client.ClientList", " ModUtils.Client.ClientList")
.Replace(" Barotrauma.Networking.Client.ClientList", " ModUtils.Client.ClientList")
.Replace("ItemPrefab.GetItemPrefab", "ModUtils.ItemPrefab.GetItemPrefab");
}