Skip to content

Commit

Permalink
[MSI] Fix detection messages not working if AutoTranslator is disabled
Browse files Browse the repository at this point in the history
Fixes #47
  • Loading branch information
ManlyMarco committed May 3, 2023
1 parent 94acef8 commit b07420c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
43 changes: 25 additions & 18 deletions src/KKS_MoreStoreItems/Features/EroDetectorFeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,24 @@ public bool ApplyFeature(ref CompositeDisposable disp, MoreShopItemsPlugin inst)
_notifyMast = inst.Config.Bind(itemName, "Notification on masturbation", true, "If the item is purchased, show a notification whenever any NPC starts a masturbation action.");
_notifyLesb = inst.Config.Bind(itemName, "Notification on lesbian", true, "If the item is purchased, show a notification whenever any NPC starts a lesbian action.");

TranslationHelper.TranslateAsync(_infoTextPrefixGeneral, s =>
if (TranslationHelper.AutoTranslatorInstalled)
{
if (s.Contains("{0}")) _infoTextPrefixGeneral = s;
else MoreShopItemsPlugin.Logger.LogWarning($"Invalid format of translation of {_infoTextPrefixGeneral} -> {s}");
});
TranslationHelper.TranslateAsync(_infoTextPrefixMast, s =>
{
if (s.Contains("{0}") && s.Contains("{1}")) _infoTextPrefixMast = s;
else MoreShopItemsPlugin.Logger.LogWarning($"Invalid format of translation of {_infoTextPrefixMast} -> {s}");
});
TranslationHelper.TranslateAsync(_infoTextPrefixLesb, s =>
{
if (s.Contains("{0}") && s.Contains("{1}")) _infoTextPrefixLesb = s;
else MoreShopItemsPlugin.Logger.LogWarning($"Invalid format of translation of {_infoTextPrefixLesb} -> {s}");
});
TranslationHelper.TranslateAsync(_infoTextPrefixGeneral, s =>
{
if (s.Contains("{0}")) _infoTextPrefixGeneral = s;
else MoreShopItemsPlugin.Logger.LogWarning($"Invalid format of translation of {_infoTextPrefixGeneral} -> {s}");
});
TranslationHelper.TranslateAsync(_infoTextPrefixMast, s =>
{
if (s.Contains("{0}") && s.Contains("{1}")) _infoTextPrefixMast = s;
else MoreShopItemsPlugin.Logger.LogWarning($"Invalid format of translation of {_infoTextPrefixMast} -> {s}");
});
TranslationHelper.TranslateAsync(_infoTextPrefixLesb, s =>
{
if (s.Contains("{0}") && s.Contains("{1}")) _infoTextPrefixLesb = s;
else MoreShopItemsPlugin.Logger.LogWarning($"Invalid format of translation of {_infoTextPrefixLesb} -> {s}");
});
}

return true;
}
Expand All @@ -77,13 +80,17 @@ private static void WaitPointDataChangedHook(Base __instance, Base.WaitPointData
//if (ActionScene.initialized && ActionScene.instance.Player.mapNo != mapNo)
if (ActionScene.instance.Map.infoDic.TryGetValue(mapNo, out var param))
{
TranslationHelper.TryTranslate(param.DisplayName, out var locationName);
var locationName = param.DisplayName;
if (TranslationHelper.TryTranslate(locationName, out var tlLoc))
locationName = tlLoc;

if (featureLevel > 1)
{
TranslationHelper.TranslateAsync(
npc.charaData.Name,
s => InformationUI.SetAsync(string.Format(npc.isOnanism ? _infoTextPrefixMast : _infoTextPrefixLesb, s, locationName), InformationUI.Mode.Normal).Forget());
var charaName = npc.charaData.Name?.Trim();
if(TranslationHelper.TryTranslate(charaName, out var tlNam))
charaName = tlNam;

InformationUI.SetAsync(string.Format(npc.isOnanism ? _infoTextPrefixMast : _infoTextPrefixLesb, charaName, locationName), InformationUI.Mode.Normal).Forget();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/KKS_MoreStoreItems/MoreShopItemsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace MoreShopItems
public class MoreShopItemsPlugin : BaseUnityPlugin
{
public const string GUID = "MoreShopItems";
public const string Version = "2.1.1";
public const string Version = "2.1.2";

internal const int DetectorItemId = 3456651;
internal const int TalismanItemId = 3456650;
Expand Down

0 comments on commit b07420c

Please sign in to comment.