Skip to content

Commit ed6bd99

Browse files
committed
Add option to hide overlays outside combat
1 parent b969c5e commit ed6bd99

10 files changed

+598
-485
lines changed

OverlayPlugin.Common/IOverlayConfig.cs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public interface IOverlayConfig
2121
string Name { get; set; }
2222
bool IsVisible { get; set; }
2323
bool IsClickThru { get; set; }
24+
bool HideOutOfCombat { get; set; }
2425
Point Position { get; set; }
2526
Size Size { get; set; }
2627
string Url { get; set; }

OverlayPlugin.Core/Controls/WSConfigPanel.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ public WSConfigPanel(TinyIoCContainer container)
6969
UpdateTunnelStatus(TunnelStatus.Inactive);
7070

7171
lblUrlConfidentWarning.Visible = false;
72-
container.Resolve<PluginMain>().OverlaysChanged += (o, e) =>
73-
{
74-
RebuildOverlayOptions();
75-
};
7672
}
7773

7874
public void Stop()
@@ -316,7 +312,7 @@ private void ipTxt_Leave(object sender, EventArgs e)
316312
}
317313
}
318314

319-
private void RebuildOverlayOptions()
315+
public void RebuildOverlayOptions()
320316
{
321317
cbOverlay.Items.Clear();
322318

OverlayPlugin.Core/EventSources/EnmityEventSource.cs

+5
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ protected override void Update()
151151

152152
// Handle optional "end encounter of combat" logic.
153153
bool inGameCombat = memory.GetInCombat();
154+
if (inGameCombat != lastInGameCombat)
155+
{
156+
logger.Log(LogLevel.Debug, inGameCombat ? "Entered combat" : "Left combat");
157+
}
158+
154159
// If we've transitioned to being out of combat, start a delayed task to end the ACT encounter.
155160
if (Config.EndEncounterOutOfCombat && lastInGameCombat && !inGameCombat)
156161
{

OverlayPlugin.Core/EventSources/MiniParseEventSource.cs

+3-9
Original file line numberDiff line numberDiff line change
@@ -664,15 +664,9 @@ internal JObject CreateCombatData()
664664
Dictionary<string, string> encounter = null;
665665
List<KeyValuePair<CombatantData, Dictionary<string, string>>> combatant = null;
666666

667-
var encounterTask = Task.Run(() =>
668-
{
669-
encounter = GetEncounterDictionary(allies);
670-
});
671-
var combatantTask = Task.Run(() =>
672-
{
673-
combatant = GetCombatantList(allies);
674-
});
675-
Task.WaitAll(encounterTask, combatantTask);
667+
668+
encounter = GetEncounterDictionary(allies);
669+
combatant = GetCombatantList(allies);
676670

677671
if (encounter == null || combatant == null) return new JObject();
678672

OverlayPlugin.Core/OverlayConfigBase.cs

+18
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public abstract class OverlayConfigBase : IOverlayConfig
1818
public event EventHandler GlobalHotkeyChanged;
1919
public event EventHandler<LockStateChangedEventArgs> LockChanged;
2020
public event EventHandler LogConsoleMessagesChanged;
21+
public event EventHandler HideOutOfCombatChanged;
2122

2223
public string Name { get; set; }
2324

@@ -203,6 +204,23 @@ public bool LogConsoleMessages
203204
}
204205
}
205206

207+
private bool hideOutOfCombat = false;
208+
public bool HideOutOfCombat
209+
{
210+
get
211+
{
212+
return this.hideOutOfCombat;
213+
}
214+
set
215+
{
216+
if (this.hideOutOfCombat != value)
217+
{
218+
this.hideOutOfCombat = value;
219+
HideOutOfCombatChanged?.Invoke(this, new EventArgs());
220+
}
221+
}
222+
}
223+
206224
protected OverlayConfigBase(string name)
207225
{
208226
this.Name = name;

OverlayPlugin.Core/OverlayHider.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class OverlayHider
1414
{
1515
private bool gameActive = true;
1616
private bool inCutscene = false;
17+
private bool inCombat = false;
1718
private IPluginConfig config;
1819
private ILogger logger;
1920
private PluginMain main;
@@ -30,6 +31,7 @@ public OverlayHider(TinyIoCContainer container)
3031

3132
container.Resolve<NativeMethods>().ActiveWindowChanged += ActiveWindowChangedHandler;
3233
container.Resolve<NetworkParser>().OnOnlineStatusChanged += OnlineStatusChanged;
34+
container.Resolve<EventSources.EnmityEventSource>().CombatStatusChanged += CombatStatusChanged;
3335
repository.RegisterProcessChangedHandler(UpdateFFXIVProcess);
3436

3537
focusTimer = new Timer();
@@ -61,7 +63,10 @@ public void UpdateOverlays()
6163
{
6264
foreach (var overlay in main.Overlays)
6365
{
64-
if (overlay.Config.IsVisible) overlay.Visible = gameActive && !inCutscene;
66+
if (overlay.Config.IsVisible)
67+
{
68+
overlay.Visible = gameActive && !inCutscene && (!overlay.Config.HideOutOfCombat || inCombat);
69+
}
6570
}
6671
} catch (Exception ex)
6772
{
@@ -121,5 +126,11 @@ private void OnlineStatusChanged(object sender, OnlineStatusChangedArgs e)
121126
inCutscene = e.Status == 15;
122127
UpdateOverlays();
123128
}
129+
130+
private void CombatStatusChanged(object sender, EventSources.CombatStatusChangedArgs e)
131+
{
132+
inCombat = e.InCombat;
133+
UpdateOverlays();
134+
}
124135
}
125136
}

0 commit comments

Comments
 (0)