just use reflection
This commit is contained in:
1 parent
5cd1a6698d
commit
83c054253f
2 files changed
+7
-11
No files matched your search
+6
-6
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using CalamityMod.Items.Accessories;
|
||||
using CalamityMod.Items.DifficultyItems;
|
||||
@@ -383,15 +384,14 @@ namespace CalamityMod
|
||||
new("BossRushIFrameCurse", ItemID.Shackle),
|
||||
};
|
||||
|
||||
Mod cal = CalamityMod.Instance;
|
||||
// TODO -- Next month's TML Stable will have this function be public
|
||||
MethodInfo getTrans = typeof(LocalizationLoader).GetMethod("GetOrCreateTranslation", BindingFlags.Static | BindingFlags.NonPublic, new[] { typeof(string), typeof(bool) });
|
||||
foreach (KeyValuePair<string, int> kv in configLabelItemEmbeds)
|
||||
{
|
||||
string localizationKey = $"Mods.CalamityMod.Config.EntryTitle.{kv.Key}";
|
||||
string baseTooltip = Language.GetText(localizationKey).Value;
|
||||
string dynamicKey = $"Config.EntryTitle._{kv.Key}";
|
||||
ModTranslation newDynTrans = LocalizationLoader.CreateTranslation(cal, dynamicKey);
|
||||
newDynTrans.SetDefault(EmbedItem(kv.Value, baseTooltip));
|
||||
LocalizationLoader.AddTranslation(newDynTrans);
|
||||
ModTranslation trans = getTrans.Invoke(null, new object[] { localizationKey, true }) as ModTranslation;
|
||||
var culture = Language.ActiveCulture;
|
||||
trans.AddTranslation(culture, EmbedItem(kv.Value, trans.GetTranslation(culture)));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
+1
-5
@@ -75,7 +75,6 @@ namespace CalamityMod
|
||||
public class CalamityMod : Mod
|
||||
{
|
||||
// CONSIDER -- I have been advised by Jopo that Mods should never contain static variables
|
||||
// TODO -- 1.4 fixes the crit reforge price calculation bug, so GetWeaponCrit everywhere can go.
|
||||
|
||||
// Boss Spawners
|
||||
public static int ghostKillCount = 0;
|
||||
@@ -207,10 +206,7 @@ namespace CalamityMod
|
||||
SetupBossKillTimes();
|
||||
SetupBossVelocityScalingValues();
|
||||
CalamityLocalization.AddLocalizations();
|
||||
// TODO -- Item icons are not visible in config tooltips.
|
||||
// You cannot inject localizations and then RefreshModLanguage without crashing the game instantly.
|
||||
// You cannot display Calamity items in static localizations because their IDs could change.
|
||||
// CalamityConfig.RegisterDynamicLocalization();
|
||||
CalamityConfig.RegisterDynamicLocalization();
|
||||
SchematicManager.Load();
|
||||
CustomLavaManagement.Load();
|
||||
Attunement.Load();
|
||||
|
||||
Reference in new issue
Block a user