Skip to content

Commit

Permalink
Fix Manager Version and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Osmodium committed Feb 13, 2025
1 parent 68c01e4 commit 051ed22
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 45 deletions.
18 changes: 9 additions & 9 deletions SpeechMod/Info.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"Id": "SpeechMod",
"DisplayName": "W40K - SpeechMod",
"Author": "Osmodium",
"ManagerVersion": "0.31.1",
"Requirements": [],
"AssemblyName": "W40KRTSpeechMod.dll",
"EntryMethod": "SpeechMod.Main.Load",
"HomePage": "https://www.nexusmods.com/warhammer40kroguetrader/mods/75",
"Version": "1.0.0"
"Id": "SpeechMod",
"DisplayName": "W40K - SpeechMod",
"Author": "Osmodium",
"ManagerVersion": "0.25.0",
"Requirements": [],
"AssemblyName": "W40KRTSpeechMod.dll",
"EntryMethod": "SpeechMod.Main.Load",
"HomePage": "https://www.nexusmods.com/warhammer40kroguetrader/mods/75",
"Version": "1.0.0"
}
20 changes: 8 additions & 12 deletions SpeechMod/Keybinds/PlaybackStop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@
using Kingmaker.Localization;
using SpeechMod.Configuration.Settings;
using System;

#if DEBUG
using UnityEngine;
#endif

namespace SpeechMod.Keybinds;
namespace SpeechMod.KeyBinds;

public class PlaybackStop : ModHotkeySettingEntry
public class PlaybackStop() : ModHotkeySettingEntry(KEY, TITLE, TOOLTIP, DEFAULT_VALUE)
{
private const string _key = "playback.stop";
private const string _title = "Stop playback";
private const string _tooltip = "Stops playback of SpeechMod TTS.";
private const string _defaultValue = "%S;;All;false";
private const string BIND_NAME = $"{Constants.SETTINGS_PREFIX}.newcontrols.ui.{_key}";

public PlaybackStop() : base(_key, _title, _tooltip, _defaultValue)
{ }
private const string KEY = "playback.stop";
private const string TITLE = "Stop playback";
private const string TOOLTIP = "Stops playback of SpeechMod TTS.";
private const string DEFAULT_VALUE = "%S;;All;false";
private const string BIND_NAME = $"{Constants.SETTINGS_PREFIX}.newcontrols.ui.{KEY}";

public override SettingStatus TryEnable() => TryEnableAndPatch(typeof(Patches));

Expand Down Expand Up @@ -67,4 +63,4 @@ private static void StopPlayback(CommonPCView instance)
Main.Speech?.Stop();
}
}
}
}
30 changes: 14 additions & 16 deletions SpeechMod/Keybinds/ToggleBarks.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
using System;
using HarmonyLib;
using HarmonyLib;
using Kingmaker;
using Kingmaker.Code.UI.MVVM.View.Common.PC;
using Kingmaker.Code.UI.MVVM.VM.WarningNotification;
using Kingmaker.Localization;
using Owlcat.Runtime.Core;
using SpeechMod.Configuration.Settings;
using System;
#if DEBUG
using UnityEngine;
#endif

namespace SpeechMod.Keybinds;
namespace SpeechMod.KeyBinds;

public class ToggleBarks : ModHotkeySettingEntry
public class ToggleBarks() : ModHotkeySettingEntry(KEY, TITLE, TOOLTIP, DEFAULT_VALUE)
{
private const string _key = "barks.toggle";
private const string _title = "Toggle Barks";
private const string _tooltip = "Toggles playback of Barks";
private const string _defaultValue = "%B;;All;false";
private const string BIND_NAME = $"{Constants.SETTINGS_PREFIX}.newcontrols.ui.{_key}";

public ToggleBarks() : base(_key, _title, _tooltip, _defaultValue)
{ }
private const string KEY = "barks.toggle";
private const string TITLE = "Toggle Barks";
private const string TOOLTIP = "Toggles playback of Barks";
private const string DEFAULT_VALUE = "%B;;All;false";
private const string BIND_NAME = $"{Constants.SETTINGS_PREFIX}.newcontrols.ui.{KEY}";

public override SettingStatus TryEnable() => TryEnableAndPatch(typeof(Patches));

Expand All @@ -36,6 +32,7 @@ private static class Patches
[HarmonyPostfix]
private static void AddToggleBarksHotkey(CommonPCView __instance)
{

#if DEBUG
Debug.Log($"{nameof(CommonPCView)}_{nameof(CommonPCView.BindViewImplementation)}_Postfix : {BIND_NAME}");
#endif
Expand Down Expand Up @@ -70,15 +67,16 @@ private static void ToggleBarks(CommonPCView instance)
#endif
if (instance == null || instance.m_WarningsTextView == null)
return;
#if DEBUG

var text = Main.Settings.PlaybackBarks ? _barksTurnedOnText : _barksTurnedOffText;
#endif
#if DEBUG
Debug.Log(text);
#endif

if (Main.Settings!.ShowNotificationOnPlaybackStop)
{
instance.m_WarningsTextView?.Show(text, WarningNotificationFormat.Common);
}
}
}
}
}
14 changes: 7 additions & 7 deletions SpeechMod/Localization/ModLocalizationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ namespace SpeechMod.Localization;

internal class ModLocalizationManager
{
private static ModLocalizationPack m_EnPack;
private static ModLocalizationPack _enPack;

public static void Init()
{
m_EnPack = LoadPack(Locale.enGB);
_enPack = LoadPack(Locale.enGB);

ApplyLocalization(LocalizationManager.Instance!.CurrentLocale);

Expand All @@ -25,7 +25,7 @@ public static void ApplyLocalization(Locale currentLocale)
{
var currentPack = LocalizationManager.Instance.CurrentPack;
if (currentPack == null) return;
foreach (var entry in m_EnPack.Strings)
foreach (var entry in _enPack.Strings)
{
currentPack.PutString(entry.Key, entry.Value.Text);
}
Expand All @@ -44,7 +44,7 @@ public static void ApplyLocalization(Locale currentLocale)
using StreamWriter file = new(packFile);
using JsonWriter jsonReader = new JsonTextWriter(file);
JsonSerializer serializer = new();
serializer.Serialize(jsonReader, m_EnPack);
serializer.Serialize(jsonReader, _enPack);
#endif
}

Expand Down Expand Up @@ -76,22 +76,22 @@ private static ModLocalizationPack LoadPack(Locale locale)

public static LocalizedString CreateString(string key, string value)
{
if (m_EnPack.Strings.ContainsKey(key))
if (_enPack.Strings.ContainsKey(key))
{
return new LocalizedString { m_ShouldProcess = false, m_Key = key };
}
else
{
ModConfigurationManager.Instance?.ModEntry?.Logger?.Log($"Missing localization string {key}");
#if DEBUG
m_EnPack.Strings[key] = new() { Text = value };
_enPack.Strings[key] = new() { Text = value };
#endif
return new LocalizedString { m_ShouldProcess = false, m_Key = key };
}
}
}

public record class ModLocalizationPack
public record ModLocalizationPack
{
[JsonProperty]
public Dictionary<string, ModLocalizationEntry> Strings;
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Main.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using HarmonyLib;
using SpeechMod.Configuration;
using SpeechMod.Configuration.Settings;
using SpeechMod.Keybinds;
using SpeechMod.KeyBinds;
using SpeechMod.Unity;
using SpeechMod.Unity.Extensions;
using SpeechMod.Voice;
Expand Down

0 comments on commit 051ed22

Please sign in to comment.