Skip to content

Commit

Permalink
DTR updates
Browse files Browse the repository at this point in the history
  • Loading branch information
slotthhy committed Sep 30, 2023
1 parent 9247674 commit e687538
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Orchestrion/BGMSystem/BGMController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class BGMController
public unsafe BGMController()
{
_addDisableRestartId = Marshal.GetDelegateForFunctionPointer<AddDisableRestartIdPrototype>(BGMAddressResolver.AddRestartId);
_getSpecialModeForSceneHook = DalamudApi.Hooker.HookFromAddress<GetSpecialModeByScenePrototype>(BGMAddressResolver.GetSpecialMode, GetSpecialModeBySceneDetour);
_getSpecialModeForSceneHook = DalamudApi.Hooks.HookFromAddress<GetSpecialModeByScenePrototype>(BGMAddressResolver.GetSpecialMode, GetSpecialModeBySceneDetour);
_getSpecialModeForSceneHook.Enable();
}

Expand Down
54 changes: 27 additions & 27 deletions Orchestrion/DalamudApi.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Dalamud.Game;
using Dalamud.Game.ClientState.Objects;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
Expand All @@ -10,30 +9,31 @@ public class DalamudApi
{
public static void Initialize(DalamudPluginInterface pluginInterface) => pluginInterface.Create<DalamudApi>();

[PluginService][RequiredVersion("1.0")] public static IAetheryteList AetheryteList { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IBuddyList BuddyList { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IChatGui ChatGui { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IClientState ClientState { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static ICommandManager CommandManager { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static ICondition Condition { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static DalamudPluginInterface PluginInterface { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IDataManager DataManager { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IDtrBar DtrBar { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IFateTable FateTable { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IFlyTextGui FlyTextGui { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IFramework Framework { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IGameGui GameGui { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IGameNetwork GameNetwork { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IGamepadState GamePadState { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IJobGauges JobGauges { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IKeyState KeyState { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static ILibcFunction LibcFunction { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IObjectTable ObjectTable { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IPartyFinderGui PartyFinderGui { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IPartyList PartyList { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static ISigScanner SigScanner { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static ITargetManager TargetManager { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IToastGui ToastGui { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IGameInteropProvider Hooker { get; private set; } = null;
[PluginService][RequiredVersion("1.0")] public static IPluginLog PluginLog { get; private set; } = null;
// [PluginService] public static IAetheryteList AetheryteList { get; private set; } = null;
// [PluginService] public static IBuddyList BuddyList { get; private set; } = null;
[PluginService] public static IChatGui ChatGui { get; private set; } = null;
[PluginService] public static IClientState ClientState { get; private set; } = null;
[PluginService] public static ICommandManager CommandManager { get; private set; } = null;
// [PluginService] public static ICondition Condition { get; private set; } = null;
[PluginService] public static DalamudPluginInterface PluginInterface { get; private set; } = null;
[PluginService] public static IDataManager DataManager { get; private set; } = null;
[PluginService] public static IDtrBar DtrBar { get; private set; } = null;
// [PluginService] public static IFateTable FateTable { get; private set; } = null;
// [PluginService] public static IFlyTextGui FlyTextGui { get; private set; } = null;
[PluginService] public static IFramework Framework { get; private set; } = null;
[PluginService] public static IGameGui GameGui { get; private set; } = null;
// [PluginService] public static IGameNetwork GameNetwork { get; private set; } = null;
// [PluginService] public static IGamepadState GamePadState { get; private set; } = null;
// [PluginService] public static IJobGauges JobGauges { get; private set; } = null;
// [PluginService] public static IKeyState KeyState { get; private set; } = null;
// [PluginService] public static ILibcFunction LibcFunction { get; private set; } = null;
// [PluginService] public static IObjectTable ObjectTable { get; private set; } = null;
// [PluginService] public static IPartyFinderGui PartyFinderGui { get; private set; } = null;
// [PluginService] public static IPartyList PartyList { get; private set; } = null;
[PluginService] public static ISigScanner SigScanner { get; private set; } = null;
// [PluginService] public static ITargetManager TargetManager { get; private set; } = null;
// [PluginService] public static IToastGui ToastGui { get; private set; } = null;
[PluginService] public static IGameInteropProvider Hooks { get; private set; } = null;
[PluginService] public static IPluginLog PluginLog { get; private set; } = null;
// [PluginService] public static ITitleScreenMenu TitleScreenMenu { get; private set; } = null;
}
34 changes: 27 additions & 7 deletions Orchestrion/OrchestrionPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,11 @@ public class OrchestrionPlugin : IDalamudPlugin

private SeString _songEchoMsg;

public OrchestrionPlugin([RequiredVersion("1.0")] DalamudPluginInterface pluginInterface)
public OrchestrionPlugin(DalamudPluginInterface pi)
{
DalamudApi.Initialize(pluginInterface);
LanguageChanged(pluginInterface.UiLanguage);
DalamudApi.Initialize(pi);
LanguageChanged(DalamudApi.PluginInterface.UiLanguage);

_dtrEntry = DalamudApi.DtrBar.Get(ConstName);
_dtrEntry.Shown = Configuration.Instance.ShowSongInNative;

BGMAddressResolver.Init();
BGMManager.OnSongChanged += OnSongChanged;

Expand All @@ -62,6 +59,10 @@ public OrchestrionPlugin([RequiredVersion("1.0")] DalamudPluginInterface pluginI
_windowSystem.AddWindow(_mainWindow);
_windowSystem.AddWindow(_settingsWindow);
_windowSystem.AddWindow(_miniPlayerWindow);

_dtrEntry = DalamudApi.DtrBar.Get(ConstName);
_dtrEntry.Shown = Configuration.Instance.ShowSongInNative;
_dtrEntry.OnClick = _mainWindow.Toggle;

DalamudApi.CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
{
Expand Down Expand Up @@ -376,7 +377,15 @@ private void UpdateDtr(int songId, bool playedByOrch = false)
{
if (_dtrEntry == null) return;
if (!SongList.Instance.TryGetSong(songId, out var song)) return;
var songName = GetClientSongName(songId);
var songName = Configuration.Instance.UseClientLangInServerInfo
? song.Strings[Util.ClientLangCode()].Name
: song.Name;
var locations = Configuration.Instance.UseClientLangInServerInfo
? song.Strings[Util.ClientLangCode()].Locations
: song.Locations;
var info = Configuration.Instance.UseClientLangInServerInfo
? song.Strings[Util.ClientLangCode()].AdditionalInfo
: song.AdditionalInfo;
if (string.IsNullOrEmpty(songName)) return;

var suffix = "";
Expand All @@ -392,6 +401,17 @@ private void UpdateDtr(int songId, bool playedByOrch = false)
text = playedByOrch ? $"{NativeNowPlayingPrefix} [{text}]" : $"{NativeNowPlayingPrefix} {text}";

_dtrEntry.Text = text;

var locEmpty = string.IsNullOrEmpty(locations);
var infoEmpty = string.IsNullOrEmpty(info);
if (locEmpty && infoEmpty)
_dtrEntry.Tooltip = "";
if (!locEmpty && infoEmpty)
_dtrEntry.Tooltip = $"{locations}";
if (locEmpty && !infoEmpty)
_dtrEntry.Tooltip = $"{info}";
if (!locEmpty && !infoEmpty)
_dtrEntry.Tooltip = $"{locations}\n{info}";
}

private void UpdateChat(int songId, bool playedByOrch = false)
Expand Down

0 comments on commit e687538

Please sign in to comment.