Fix Combat End and split combat + performance. (#30)
Co-authored-by: defnotken <itsdefnotken@gmail.com> Reviewed-on: #30 Reviewed-by: cake <cake@noreply.git.lightless-sync.org>
This commit was merged in pull request #30.
This commit is contained in:
@@ -14,4 +14,6 @@ public class PlayerPerformanceConfig : ILightlessConfiguration
|
|||||||
public int TrisAutoPauseThresholdThousands { get; set; } = 250;
|
public int TrisAutoPauseThresholdThousands { get; set; } = 250;
|
||||||
public List<string> UIDsToIgnore { get; set; } = new();
|
public List<string> UIDsToIgnore { get; set; } = new();
|
||||||
public bool PauseInInstanceDuty { get; set; } = false;
|
public bool PauseInInstanceDuty { get; set; } = false;
|
||||||
|
public bool PauseWhilePerforming { get; set; } = true;
|
||||||
|
public bool PauseInCombat { get; set; } = true;
|
||||||
}
|
}
|
||||||
@@ -88,11 +88,19 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
|||||||
_redrawOnNextApplication = true;
|
_redrawOnNextApplication = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Mediator.Subscribe<CombatOrPerformanceEndMessage>(this, (msg) =>
|
Mediator.Subscribe<CombatEndMessage>(this, (msg) =>
|
||||||
{
|
{
|
||||||
EnableSync();
|
EnableSync();
|
||||||
});
|
});
|
||||||
Mediator.Subscribe<CombatOrPerformanceStartMessage>(this, _ =>
|
Mediator.Subscribe<CombatStartMessage>(this, _ =>
|
||||||
|
{
|
||||||
|
DisableSync();
|
||||||
|
});
|
||||||
|
Mediator.Subscribe<PerformanceEndMessage>(this, (msg) =>
|
||||||
|
{
|
||||||
|
EnableSync();
|
||||||
|
});
|
||||||
|
Mediator.Subscribe<PerformanceStartMessage>(this, _ =>
|
||||||
{
|
{
|
||||||
DisableSync();
|
DisableSync();
|
||||||
});
|
});
|
||||||
@@ -137,11 +145,21 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
public void ApplyCharacterData(Guid applicationBase, CharacterData characterData, bool forceApplyCustomization = false)
|
public void ApplyCharacterData(Guid applicationBase, CharacterData characterData, bool forceApplyCustomization = false)
|
||||||
{
|
{
|
||||||
if (_dalamudUtil.IsInCombatOrPerforming)
|
if (_dalamudUtil.IsInCombat)
|
||||||
{
|
{
|
||||||
Mediator.Publish(new EventMessage(new Event(PlayerName, Pair.UserData, nameof(PairHandler), EventSeverity.Warning,
|
Mediator.Publish(new EventMessage(new Event(PlayerName, Pair.UserData, nameof(PairHandler), EventSeverity.Warning,
|
||||||
"Cannot apply character data: you are in combat or performing music, deferring application")));
|
"Cannot apply character data: you are in combat, deferring application")));
|
||||||
Logger.LogDebug("[BASE-{appBase}] Received data but player is in combat or performing", applicationBase);
|
Logger.LogDebug("[BASE-{appBase}] Received data but player is in combat", applicationBase);
|
||||||
|
_dataReceivedInDowntime = new(applicationBase, characterData, forceApplyCustomization);
|
||||||
|
SetUploading(isUploading: false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_dalamudUtil.IsPerforming)
|
||||||
|
{
|
||||||
|
Mediator.Publish(new EventMessage(new Event(PlayerName, Pair.UserData, nameof(PairHandler), EventSeverity.Warning,
|
||||||
|
"Cannot apply character data: you are performing music, deferring application")));
|
||||||
|
Logger.LogDebug("[BASE-{appBase}] Received data but player is performing", applicationBase);
|
||||||
_dataReceivedInDowntime = new(applicationBase, characterData, forceApplyCustomization);
|
_dataReceivedInDowntime = new(applicationBase, characterData, forceApplyCustomization);
|
||||||
SetUploading(isUploading: false);
|
SetUploading(isUploading: false);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_charaDataConfigService.Current.NearbyDrawWisps && !_dalamudUtilService.IsInGpose && !_dalamudUtilService.IsInCombatOrPerforming)
|
if (_charaDataConfigService.Current.NearbyDrawWisps && !_dalamudUtilService.IsInGpose && !_dalamudUtilService.IsInCombat && !_dalamudUtilService.IsPerforming && !_dalamudUtilService.IsInInstance)
|
||||||
await _dalamudUtilService.RunOnFrameworkThread(() => ManageWispsNearby(previousPoses)).ConfigureAwait(false);
|
await _dalamudUtilService.RunOnFrameworkThread(() => ManageWispsNearby(previousPoses)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_charaDataConfigService.Current.NearbyDrawWisps || _dalamudUtilService.IsInGpose || _dalamudUtilService.IsInCombatOrPerforming)
|
if (!_charaDataConfigService.Current.NearbyDrawWisps || _dalamudUtilService.IsInGpose || _dalamudUtilService.IsInCombat || _dalamudUtilService.IsPerforming || _dalamudUtilService.IsInInstance)
|
||||||
ClearAllVfx();
|
ClearAllVfx();
|
||||||
|
|
||||||
var camera = CameraManager.Instance()->CurrentCamera;
|
var camera = CameraManager.Instance()->CurrentCamera;
|
||||||
|
|||||||
@@ -162,7 +162,8 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
public bool IsLoggedIn { get; private set; }
|
public bool IsLoggedIn { get; private set; }
|
||||||
public bool IsOnFrameworkThread => _framework.IsInFrameworkUpdateThread;
|
public bool IsOnFrameworkThread => _framework.IsInFrameworkUpdateThread;
|
||||||
public bool IsZoning => _condition[ConditionFlag.BetweenAreas] || _condition[ConditionFlag.BetweenAreas51];
|
public bool IsZoning => _condition[ConditionFlag.BetweenAreas] || _condition[ConditionFlag.BetweenAreas51];
|
||||||
public bool IsInCombatOrPerforming { get; private set; } = false;
|
public bool IsInCombat { get; private set; } = false;
|
||||||
|
public bool IsPerforming { get; private set; } = false;
|
||||||
public bool IsInInstance { get; private set; } = false;
|
public bool IsInInstance { get; private set; } = false;
|
||||||
public bool HasModifiedGameFiles => _gameData.HasModifiedGameDataFiles;
|
public bool HasModifiedGameFiles => _gameData.HasModifiedGameDataFiles;
|
||||||
public uint ClassJobId => _classJobId!.Value;
|
public uint ClassJobId => _classJobId!.Value;
|
||||||
@@ -670,19 +671,33 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
Mediator.Publish(new GposeEndMessage());
|
Mediator.Publish(new GposeEndMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((_condition[ConditionFlag.Performing] || _condition[ConditionFlag.InCombat]) && !IsInCombatOrPerforming && (_condition[ConditionFlag.BoundByDuty] && !_playerPerformanceConfigService.Current.PauseInInstanceDuty))
|
if ((_condition[ConditionFlag.InCombat]) && !IsInCombat && !IsInInstance && _playerPerformanceConfigService.Current.PauseInCombat)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Combat/Performance start");
|
_logger.LogDebug("Combat start");
|
||||||
IsInCombatOrPerforming = true;
|
IsInCombat = true;
|
||||||
Mediator.Publish(new CombatOrPerformanceStartMessage());
|
Mediator.Publish(new CombatStartMessage());
|
||||||
Mediator.Publish(new HaltScanMessage(nameof(IsInCombatOrPerforming)));
|
Mediator.Publish(new HaltScanMessage(nameof(IsInCombat)));
|
||||||
}
|
}
|
||||||
else if ((!_condition[ConditionFlag.Performing] && !_condition[ConditionFlag.InCombat]) && IsInCombatOrPerforming && (_condition[ConditionFlag.BoundByDuty] && !_playerPerformanceConfigService.Current.PauseInInstanceDuty))
|
else if ((!_condition[ConditionFlag.InCombat]) && IsInCombat && !IsInInstance && _playerPerformanceConfigService.Current.PauseInCombat)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Combat/Performance end");
|
_logger.LogDebug("Combat end");
|
||||||
IsInCombatOrPerforming = false;
|
IsInCombat = false;
|
||||||
Mediator.Publish(new CombatOrPerformanceEndMessage());
|
Mediator.Publish(new CombatEndMessage());
|
||||||
Mediator.Publish(new ResumeScanMessage(nameof(IsInCombatOrPerforming)));
|
Mediator.Publish(new ResumeScanMessage(nameof(IsInCombat)));
|
||||||
|
}
|
||||||
|
if (_condition[ConditionFlag.Performing] && !IsPerforming && _playerPerformanceConfigService.Current.PauseWhilePerforming)
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Performance start");
|
||||||
|
IsInCombat = true;
|
||||||
|
Mediator.Publish(new PerformanceStartMessage());
|
||||||
|
Mediator.Publish(new HaltScanMessage(nameof(IsPerforming)));
|
||||||
|
}
|
||||||
|
else if (!_condition[ConditionFlag.Performing] && IsPerforming && _playerPerformanceConfigService.Current.PauseWhilePerforming)
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Performance end");
|
||||||
|
IsInCombat = false;
|
||||||
|
Mediator.Publish(new PerformanceEndMessage());
|
||||||
|
Mediator.Publish(new ResumeScanMessage(nameof(IsPerforming)));
|
||||||
}
|
}
|
||||||
if ((_condition[ConditionFlag.BoundByDuty]) && !IsInInstance && _playerPerformanceConfigService.Current.PauseInInstanceDuty)
|
if ((_condition[ConditionFlag.BoundByDuty]) && !IsInInstance && _playerPerformanceConfigService.Current.PauseInInstanceDuty)
|
||||||
{
|
{
|
||||||
@@ -752,7 +767,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
_classJobId = localPlayer.ClassJob.RowId;
|
_classJobId = localPlayer.ClassJob.RowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsInCombatOrPerforming)
|
if (!IsInCombat || !IsPerforming || !IsInInstance)
|
||||||
Mediator.Publish(new FrameworkUpdateMessage());
|
Mediator.Publish(new FrameworkUpdateMessage());
|
||||||
|
|
||||||
Mediator.Publish(new PriorityFrameworkUpdateMessage());
|
Mediator.Publish(new PriorityFrameworkUpdateMessage());
|
||||||
@@ -781,7 +796,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
IsLodEnabled = lodEnabled;
|
IsLodEnabled = lodEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsInCombatOrPerforming)
|
if (IsInCombat || IsPerforming || IsInInstance)
|
||||||
Mediator.Publish(new FrameworkUpdateMessage());
|
Mediator.Publish(new FrameworkUpdateMessage());
|
||||||
|
|
||||||
Mediator.Publish(new DelayedFrameworkUpdateMessage());
|
Mediator.Publish(new DelayedFrameworkUpdateMessage());
|
||||||
|
|||||||
@@ -79,8 +79,10 @@ public record OpenPermissionWindow(Pair Pair) : MessageBase;
|
|||||||
public record DownloadLimitChangedMessage() : SameThreadMessage;
|
public record DownloadLimitChangedMessage() : SameThreadMessage;
|
||||||
public record CensusUpdateMessage(byte Gender, byte RaceId, byte TribeId) : MessageBase;
|
public record CensusUpdateMessage(byte Gender, byte RaceId, byte TribeId) : MessageBase;
|
||||||
public record TargetPairMessage(Pair Pair) : MessageBase;
|
public record TargetPairMessage(Pair Pair) : MessageBase;
|
||||||
public record CombatOrPerformanceStartMessage : MessageBase;
|
public record CombatStartMessage : MessageBase;
|
||||||
public record CombatOrPerformanceEndMessage : MessageBase;
|
public record CombatEndMessage : MessageBase;
|
||||||
|
public record PerformanceStartMessage : MessageBase;
|
||||||
|
public record PerformanceEndMessage : MessageBase;
|
||||||
public record InstanceOrDutyStartMessage : MessageBase;
|
public record InstanceOrDutyStartMessage : MessageBase;
|
||||||
public record InstanceOrDutyEndMessage : MessageBase;
|
public record InstanceOrDutyEndMessage : MessageBase;
|
||||||
public record EventMessage(Event Event) : MessageBase;
|
public record EventMessage(Event Event) : MessageBase;
|
||||||
|
|||||||
@@ -1377,16 +1377,32 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
bool autoPause = _playerPerformanceConfigService.Current.AutoPausePlayersExceedingThresholds;
|
bool autoPause = _playerPerformanceConfigService.Current.AutoPausePlayersExceedingThresholds;
|
||||||
bool autoPauseEveryone = _playerPerformanceConfigService.Current.AutoPausePlayersWithPreferredPermissionsExceedingThresholds;
|
bool autoPauseEveryone = _playerPerformanceConfigService.Current.AutoPausePlayersWithPreferredPermissionsExceedingThresholds;
|
||||||
bool autoPauseInDuty = _playerPerformanceConfigService.Current.PauseInInstanceDuty;
|
bool autoPauseInDuty = _playerPerformanceConfigService.Current.PauseInInstanceDuty;
|
||||||
|
bool autoPauseInCombat = _playerPerformanceConfigService.Current.PauseInCombat;
|
||||||
|
bool autoPauseWhilePerforming = _playerPerformanceConfigService.Current.PauseWhilePerforming;
|
||||||
|
|
||||||
if (_uiShared.MediumTreeNode("Auto Pause", UIColors.Get("LightlessPurple")))
|
if (_uiShared.MediumTreeNode("Auto Pause", UIColors.Get("LightlessPurple")))
|
||||||
{
|
{
|
||||||
|
if (ImGui.Checkbox("Auto pause sync while combat", ref autoPauseInCombat))
|
||||||
|
{
|
||||||
|
_playerPerformanceConfigService.Current.PauseInCombat = autoPauseInCombat;
|
||||||
|
_playerPerformanceConfigService.Save();
|
||||||
|
}
|
||||||
|
_uiShared.DrawHelpText("AUTO-ENABLED: Your risk of crashing during a fight increases when this is disabled. For example: VFX mods Loading mid fight can cause a crash." + Environment.NewLine
|
||||||
|
+ UiSharedService.TooltipSeparator + "WARNING: DISABLE AT YOUR OWN RISK.");
|
||||||
|
if (ImGui.Checkbox("Auto pause sync while in Perfomance as Bard", ref autoPauseWhilePerforming))
|
||||||
|
{
|
||||||
|
_playerPerformanceConfigService.Current.PauseWhilePerforming = autoPauseWhilePerforming;
|
||||||
|
_playerPerformanceConfigService.Save();
|
||||||
|
}
|
||||||
|
_uiShared.DrawHelpText("AUTO-ENABLED: Your risk of crashing during a performance increases when this is disabled. For example: Some mods can crash you mid performance" + Environment.NewLine
|
||||||
|
+ UiSharedService.TooltipSeparator + "WARNING: DISABLE AT YOUR OWN RISK.");
|
||||||
if (ImGui.Checkbox("Auto pause sync while in instances and duties", ref autoPauseInDuty))
|
if (ImGui.Checkbox("Auto pause sync while in instances and duties", ref autoPauseInDuty))
|
||||||
{
|
{
|
||||||
_playerPerformanceConfigService.Current.PauseInInstanceDuty = autoPauseInDuty;
|
_playerPerformanceConfigService.Current.PauseInInstanceDuty = autoPauseInDuty;
|
||||||
_playerPerformanceConfigService.Save();
|
_playerPerformanceConfigService.Save();
|
||||||
}
|
}
|
||||||
_uiShared.DrawHelpText("When enabled, it will automatically pause all players while you are in an instance, such as a dungeon or raid." + Environment.NewLine
|
_uiShared.DrawHelpText("When enabled, it will automatically pause all players while you are in an instance, such as a dungeon or raid." + Environment.NewLine
|
||||||
+ UiSharedService.TooltipSeparator + "Warning: You many have to leave the dungeon to resync with people again");
|
+ UiSharedService.TooltipSeparator + "Warning: You may have to leave the dungeon to resync with people again");
|
||||||
|
|
||||||
if (ImGui.Checkbox("Automatically pause players exceeding thresholds", ref autoPause))
|
if (ImGui.Checkbox("Automatically pause players exceeding thresholds", ref autoPause))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user