integrate new ActivityContext
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29709.97
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32929.385
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlayerTags", "PlayerTags\PlayerTags.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pilz.Dalamud", "..\Pilz.Dalamud\Pilz.Dalamud\Pilz.Dalamud.csproj", "{A92D2FFC-FDB8-4F28-B5DD-4A1B3EB0B1BB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -15,6 +17,10 @@ Global
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.Build.0 = Debug|x64
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.ActiveCfg = Release|x64
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.Build.0 = Release|x64
|
||||
{A92D2FFC-FDB8-4F28-B5DD-4A1B3EB0B1BB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A92D2FFC-FDB8-4F28-B5DD-4A1B3EB0B1BB}.Debug|x64.Build.0 = Debug|x64
|
||||
{A92D2FFC-FDB8-4F28-B5DD-4A1B3EB0B1BB}.Release|x64.ActiveCfg = Release|x64
|
||||
{A92D2FFC-FDB8-4F28-B5DD-4A1B3EB0B1BB}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Dalamud.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using Pilz.Dalamud.ActivityContexts;
|
||||
using PlayerTags.Data;
|
||||
using PlayerTags.Inheritables;
|
||||
using System;
|
||||
@@ -19,11 +20,24 @@ namespace PlayerTags.Configuration
|
||||
private const NameplateTitlePosition DefaultNameplateTitlePosition = Data.NameplateTitlePosition.AlwaysAboveName;
|
||||
private const bool DefaultIsApplyTagsToAllChatMessagesEnabled = true;
|
||||
|
||||
public Dictionary<ActivityContext, GeneralOptionsClass> GeneralOptions = new Dictionary<ActivityContext, GeneralOptionsClass>()
|
||||
[Obsolete]
|
||||
[JsonProperty("GeneralOptions")]
|
||||
private Dictionary<Data.ActivityContext, GeneralOptionsClass> GeneralOptionsV1
|
||||
{
|
||||
{ ActivityContext.None, new GeneralOptionsClass() },
|
||||
{ ActivityContext.PveDuty, new GeneralOptionsClass() },
|
||||
{ ActivityContext.PvpDuty, new GeneralOptionsClass() }
|
||||
set
|
||||
{
|
||||
GeneralOptions.Clear();
|
||||
foreach (var kvp in value)
|
||||
GeneralOptions.Add((ActivityType)kvp.Key, kvp.Value);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty("GeneralOptionsV2")]
|
||||
public Dictionary<ActivityType, GeneralOptionsClass> GeneralOptions = new()
|
||||
{
|
||||
{ ActivityType.None, new GeneralOptionsClass() },
|
||||
{ ActivityType.PveDuty, new GeneralOptionsClass() },
|
||||
{ ActivityType.PvpDuty, new GeneralOptionsClass() }
|
||||
};
|
||||
|
||||
public bool IsPlayerNameRandomlyGenerated = false;
|
||||
|
||||
@@ -5,6 +5,7 @@ using Dalamud.Interface;
|
||||
using Dalamud.Logging;
|
||||
using ImGuiNET;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Pilz.Dalamud.ActivityContexts;
|
||||
using PlayerTags.Data;
|
||||
using PlayerTags.Inheritables;
|
||||
using PlayerTags.PluginStrings;
|
||||
@@ -1233,7 +1234,7 @@ namespace PlayerTags.Configuration
|
||||
applyChanges(GetActivityContext(CurrentActivityContext));
|
||||
}
|
||||
|
||||
void applyChanges(ActivityContext key)
|
||||
void applyChanges(ActivityType key)
|
||||
{
|
||||
pluginConfig.GeneralOptions[key].NameplateFreeCompanyVisibility = NameplateFreeCompanyVisibility;
|
||||
pluginConfig.GeneralOptions[key].NameplateTitleVisibility = NameplateTitleVisibility;
|
||||
@@ -1242,22 +1243,22 @@ namespace PlayerTags.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
private ActivityContext GetActivityContext(ActivityContextSelection selection)
|
||||
private ActivityType GetActivityContext(ActivityContextSelection selection)
|
||||
{
|
||||
ActivityContext result;
|
||||
ActivityType result;
|
||||
|
||||
switch (selection)
|
||||
{
|
||||
case ActivityContextSelection.PveDuty:
|
||||
result = ActivityContext.PveDuty;
|
||||
result = ActivityType.PveDuty;
|
||||
break;
|
||||
case ActivityContextSelection.PvpDuty:
|
||||
result = ActivityContext.PvpDuty;
|
||||
result = ActivityType.PvpDuty;
|
||||
break;
|
||||
case ActivityContextSelection.All:
|
||||
case ActivityContextSelection.None:
|
||||
default:
|
||||
result = ActivityContext.None;
|
||||
result = ActivityType.None;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
|
||||
namespace PlayerTags.Data
|
||||
{
|
||||
[Obsolete]
|
||||
[Flags]
|
||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||
public enum ActivityContext
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
namespace PlayerTags.Data
|
||||
using Pilz.Dalamud.ActivityContexts;
|
||||
|
||||
namespace PlayerTags.Data
|
||||
{
|
||||
public static class ActivityContextHelper
|
||||
{
|
||||
public static bool GetIsVisible(ActivityContext playerContext, bool desiredPveDutyVisibility, bool desiredPvpDutyVisibility, bool desiredOthersVisibility)
|
||||
public static bool GetIsVisible(ActivityType playerContext, bool desiredPveDutyVisibility, bool desiredPvpDutyVisibility, bool desiredOthersVisibility)
|
||||
{
|
||||
bool isVisible = false;
|
||||
|
||||
if (playerContext.HasFlag(ActivityContext.PveDuty))
|
||||
{
|
||||
if (playerContext.HasFlag(ActivityType.PveDuty))
|
||||
isVisible |= desiredPveDutyVisibility;
|
||||
}
|
||||
|
||||
if (playerContext.HasFlag(ActivityContext.PvpDuty))
|
||||
{
|
||||
if (playerContext.HasFlag(ActivityType.PvpDuty))
|
||||
isVisible |= desiredPvpDutyVisibility;
|
||||
}
|
||||
|
||||
if (playerContext == ActivityContext.None)
|
||||
{
|
||||
if (playerContext == ActivityType.None)
|
||||
isVisible |= desiredOthersVisibility;
|
||||
}
|
||||
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
using Dalamud.Plugin;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlayerTags.Data
|
||||
{
|
||||
public class ActivityContextManager : IDisposable
|
||||
{
|
||||
private ActivityContext m_CurrentActivityContext;
|
||||
|
||||
public ActivityContext CurrentActivityContext => m_CurrentActivityContext;
|
||||
|
||||
public ActivityContextManager()
|
||||
{
|
||||
m_CurrentActivityContext = ActivityContext.None;
|
||||
PluginServices.ClientState.TerritoryChanged += ClientState_TerritoryChanged;
|
||||
}
|
||||
|
||||
private void ClientState_TerritoryChanged(object? sender, ushort e)
|
||||
{
|
||||
m_CurrentActivityContext = ActivityContext.None;
|
||||
|
||||
var contentFinderConditionsSheet = PluginServices.DataManager.GameData.GetExcelSheet<ContentFinderCondition>();
|
||||
if (contentFinderConditionsSheet != null)
|
||||
{
|
||||
var foundContentFinderCondition = contentFinderConditionsSheet.FirstOrDefault(contentFinderCondition => contentFinderCondition.TerritoryType.Row == PluginServices.ClientState.TerritoryType);
|
||||
if (foundContentFinderCondition != null)
|
||||
{
|
||||
if (foundContentFinderCondition.PvP)
|
||||
{
|
||||
m_CurrentActivityContext = ActivityContext.PvpDuty;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CurrentActivityContext = ActivityContext.PveDuty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
PluginServices.ClientState.TerritoryChanged -= ClientState_TerritoryChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace PlayerTags.Features
|
||||
|
||||
private void Chat_ChatMessage(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled)
|
||||
{
|
||||
if (m_PluginConfiguration.GeneralOptions[ActivityContextManager.CurrentActivityContext].IsApplyTagsToAllChatMessagesEnabled || Enum.IsDefined(type))
|
||||
if (m_PluginConfiguration.GeneralOptions[ActivityContextManager.CurrentActivityContext.ActivityType].IsApplyTagsToAllChatMessagesEnabled || Enum.IsDefined(type))
|
||||
{
|
||||
AddTagsToChat(sender, type, true);
|
||||
AddTagsToChat(message, type, false);
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace PlayerTags.Features
|
||||
{
|
||||
var beforeTitleBytes = args.Title.Encode();
|
||||
AddTagsToNameplate(args.PlayerCharacter, args.Name, args.Title, args.FreeCompany);
|
||||
var generalOptions = m_PluginConfiguration.GeneralOptions[ActivityContextManager.CurrentActivityContext];
|
||||
var generalOptions = m_PluginConfiguration.GeneralOptions[ActivityContextManager.CurrentActivityContext.ActivityType];
|
||||
|
||||
if (generalOptions.NameplateTitlePosition == NameplateTitlePosition.AlwaysAboveName)
|
||||
args.IsTitleAboveName = true;
|
||||
|
||||
@@ -4,6 +4,7 @@ using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Pilz.Dalamud.ActivityContexts;
|
||||
using PlayerTags.Configuration.GameConfig;
|
||||
using PlayerTags.Data;
|
||||
using PlayerTags.Inheritables;
|
||||
@@ -44,7 +45,7 @@ namespace PlayerTags.Features
|
||||
|
||||
protected bool IsTagVisible(Tag tag, GameObject? gameObject)
|
||||
{
|
||||
bool isVisibleForActivity = ActivityContextHelper.GetIsVisible(ActivityContextManager.CurrentActivityContext,
|
||||
bool isVisibleForActivity = ActivityContextHelper.GetIsVisible(ActivityContextManager.CurrentActivityContext.ActivityType,
|
||||
tag.IsVisibleInPveDuties.InheritedValue ?? false,
|
||||
tag.IsVisibleInPvpDuties.InheritedValue ?? false,
|
||||
tag.IsVisibleInOverworld.InheritedValue ?? false);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dalamud.ContextMenu" Version="1.2.1" />
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.8" />
|
||||
<ProjectReference Include="..\..\Pilz.Dalamud\Pilz.Dalamud\Pilz.Dalamud.csproj" />
|
||||
<Reference Include="FFXIVClientStructs">
|
||||
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
"requested": "[2.1.8, )",
|
||||
"resolved": "2.1.8",
|
||||
"contentHash": "YqagNXs9InxmqkXzq7kLveImxnodkBEicAhydMXVp7dFjC7xb76U6zGgAax4/BWIWfZeWzr5DJyQSev31kj81A=="
|
||||
},
|
||||
"pilz.dalamud": {
|
||||
"type": "Project"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user