plish up & don't use sub items in context menu

This commit is contained in:
2022-06-17 12:43:08 +02:00
parent 7e28f028d1
commit 08ddc9a440
5 changed files with 200 additions and 236 deletions

View File

@@ -27,7 +27,6 @@ namespace PlayerTags.Configuration
private PluginData m_PluginData;
private InheritableValue<ushort>? m_ColorPickerPopupDataContext;
public static int asdfasdfasdf = 0;
public PluginConfigurationUI(PluginConfiguration config, PluginData pluginData)
{
@@ -44,7 +43,7 @@ namespace PlayerTags.Configuration
ImGui.SetNextWindowSize(new Vector2(400, 500), ImGuiCond.FirstUseEver);
if (ImGui.Begin(Strings.Loc_Static_PluginName + asdfasdfasdf.ToString(), ref m_PluginConfiguration.IsVisible))
if (ImGui.Begin(Strings.Loc_Static_PluginName, ref m_PluginConfiguration.IsVisible))
{
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 0.8f, 0.5f, 1));
ImGui.TextWrapped(Strings.Loc_Static_WarningMessage);

View File

@@ -281,13 +281,12 @@ namespace PlayerTags.Data
public Identity? GetIdentity(GameObjectContextMenuOpenArgs contextMenuOpenedArgs)
{
if (!string.IsNullOrEmpty(contextMenuOpenedArgs.Text?.TextValue)
|| contextMenuOpenedArgs.ObjectWorld != 0
|| contextMenuOpenedArgs.ObjectWorld != 65535)
if (string.IsNullOrEmpty(contextMenuOpenedArgs.Text?.TextValue)
|| contextMenuOpenedArgs.ObjectWorld == 0
|| contextMenuOpenedArgs.ObjectWorld == 65535)
{
return null;
}
return GetIdentity(contextMenuOpenedArgs.Text?.TextValue ?? string.Empty, contextMenuOpenedArgs.ObjectWorld);
}

View File

@@ -42,7 +42,6 @@ namespace PlayerTags.Features
m_ContextMenu = new DalamudContextMenuBase();
m_ContextMenu.Functions.ContextMenu.OnOpenGameObjectContextMenu += ContextMenuHooks_ContextMenuOpened;
PluginConfigurationUI.asdfasdfasdf = 1;
}
public void Dispose()
@@ -57,57 +56,44 @@ namespace PlayerTags.Features
private void ContextMenuHooks_ContextMenuOpened(GameObjectContextMenuOpenArgs contextMenuOpenedArgs)
{
PluginConfigurationUI.asdfasdfasdf = 2;
if (!m_PluginConfiguration.IsCustomTagsContextMenuEnabled
|| !SupportedAddonNames.Contains(contextMenuOpenedArgs.ParentAddonName))
{
return;
}
PluginConfigurationUI.asdfasdfasdf = 3;
Identity? identity = m_PluginData.GetIdentity(contextMenuOpenedArgs);
PluginConfigurationUI.asdfasdfasdf = 4;
if (identity != null)
{
PluginConfigurationUI.asdfasdfasdf = 5;
var notAddedTags = m_PluginData.CustomTags.Where(customTag => !identity.CustomTagIds.Contains(customTag.CustomId.Value));
if (notAddedTags.Any())
var allTags = new Dictionary<Tag, bool>();
foreach (var customTag in m_PluginData.CustomTags)
{
contextMenuOpenedArgs.AddCustomItem(
new GameObjectContextMenuItem(Strings.Loc_Static_ContextMenu_AddTag, subContextMenuOpenedArgs =>
{
//foreach (var notAddedTag in notAddedTags)
//{
// subContextMenuOpenedArgs.AddCustomItem(notAddedTag.Text.Value, args =>
// {
// m_PluginData.AddCustomTagToIdentity(notAddedTag, identity);
// m_PluginConfiguration.Save(m_PluginData);
// });
//}
})
{
IsSubMenu = true
});
var isAdded = identity.CustomTagIds.Contains(customTag.CustomId.Value);
allTags.Add(customTag, isAdded);
}
var addedTags = m_PluginData.CustomTags.Where(customTag => identity.CustomTagIds.Contains(customTag.CustomId.Value));
if (addedTags.Any())
var sortedTags = allTags.OrderBy(n => n.Value);
foreach (var tag in sortedTags)
{
string menuItemText;
if (tag.Value)
menuItemText = Strings.Loc_Static_ContextMenu_RemoveTag;
else
menuItemText = Strings.Loc_Static_ContextMenu_AddTag;
menuItemText = string.Format(menuItemText, tag.Key.Text.Value);
contextMenuOpenedArgs.AddCustomItem(
new GameObjectContextMenuItem(Strings.Loc_Static_ContextMenu_RemoveTag, subContextMenuOpenedArgs =>
{
//foreach (var addedTag in addedTags)
//{
// subContextMenuOpenedArgs.AddCustomItem(addedTag.Text.Value, args =>
// {
// m_PluginData.RemoveCustomTagFromIdentity(addedTag, identity);
// m_PluginConfiguration.Save(m_PluginData);
// });
//}
})
{
IsSubMenu = true
});
new GameObjectContextMenuItem(menuItemText, openedEventArgs =>
{
if (tag.Value)
m_PluginData.RemoveCustomTagFromIdentity(tag.Key, identity);
else
m_PluginData.AddCustomTagToIdentity(tag.Key, identity);
m_PluginConfiguration.Save(m_PluginData);
})
{
IsSubMenu = false
});
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -136,10 +136,10 @@
<value>Player</value>
</data>
<data name="Loc_Static_ContextMenu_AddTag" xml:space="preserve">
<value>Add tag</value>
<value>Add tag: {0}</value>
</data>
<data name="Loc_Static_ContextMenu_RemoveTag" xml:space="preserve">
<value>Remove tag</value>
<value>Remove tag: {0}</value>
</data>
<data name="Loc_Static_Nameplates" xml:space="preserve">
<value>Nameplates</value>
@@ -363,7 +363,6 @@
<data name="Loc_IsIconVisibleInNameplates_Description" xml:space="preserve">
<value>Whether the icon will be shown in nameplates.</value>
</data>
<data name="Loc_Text" xml:space="preserve">
<value>Text</value>
</data>
@@ -384,7 +383,7 @@
</data>
<data name="Loc_IsTextItalic" xml:space="preserve">
<value>Italic</value>
</data>
</data>
<data name="Loc_IsTextItalic_Description" xml:space="preserve">
<value>Whether the text will be italic.</value>
</data>
@@ -400,7 +399,6 @@
<data name="Loc_IsTextVisibleInNameplates_Description" xml:space="preserve">
<value>Whether the text will be shown in nameplates.</value>
</data>
<data name="Loc_TagPositionInChat" xml:space="preserve">
<value>Position in chat</value>
</data>
@@ -419,14 +417,12 @@
<data name="Loc_TagTargetInNameplates_Description" xml:space="preserve">
<value>The element that the tag should target in nameplates.</value>
</data>
<data name="Loc_GameObjectNamesToApplyTo" xml:space="preserve">
<value>Add to players</value>
</data>
<data name="Loc_GameObjectNamesToApplyTo_Description" xml:space="preserve">
<value>A list of players to add tags to, separated by commas or semi-colons. E.g. "Cloud Strife, Tifa Lockhart".</value>
</data>
<data name="Loc_TagPosition_After" xml:space="preserve">
<value>After</value>
</data>
@@ -445,15 +441,12 @@
<data name="Loc_TagPosition_Replace_Description" xml:space="preserve">
<value>Replace the target element with the tag.</value>
</data>
<data name="Loc_IsEnabled" xml:space="preserve">
<value>Enabled</value>
</data>
<data name="Loc_CustomId" xml:space="preserve">
<value>Custom id</value>
</data>
<data name="Loc_GeneralCategory" xml:space="preserve">
<value>General properties</value>
</data>
@@ -472,7 +465,6 @@
<data name="Loc_PlayerCategory" xml:space="preserve">
<value>Player properties</value>
</data>
<data name="Loc_IsVisibleInPveDuties" xml:space="preserve">
<value>Show in pve duties</value>
</data>
@@ -491,7 +483,6 @@
<data name="Loc_IsVisibleInOverworld_Description" xml:space="preserve">
<value>Whether the tag should be visible in other circumstances for which there is no specific option.</value>
</data>
<data name="Loc_IsVisibleForSelf" xml:space="preserve">
<value>Show for self</value>
</data>
@@ -528,77 +519,66 @@
<data name="Loc_IsVisibleForOtherPlayers_Description" xml:space="preserve">
<value>Whether the tag should be visible for players in other circumstances for which there is no specific option.</value>
</data>
<data name="Loc_IsPlayersTabOrderedByProximity" xml:space="preserve">
<value>Order by proximity</value>
</data>
<data name="Loc_IsPlayersTabOrderedByProximity_Description" xml:space="preserve">
<value>Players that are closer to you will be ordered towards the top.</value>
</data>
<data name="Loc_IsPlayersTabSelfVisible" xml:space="preserve">
<value>Show self</value>
</data>
<data name="Loc_IsPlayersTabSelfVisible_Description" xml:space="preserve">
<value>Show yourself in the players list.</value>
</data>
<data name="Loc_IsPlayersTabFriendsVisible" xml:space="preserve">
<value>Show friends</value>
</data>
<data name="Loc_IsPlayersTabFriendsVisible_Description" xml:space="preserve">
<value>Show friends in the players list.</value>
</data>
<data name="Loc_IsPlayersTabPartyVisible" xml:space="preserve">
<value>Show party members</value>
</data>
<data name="Loc_IsPlayersTabPartyVisible_Description" xml:space="preserve">
<value>Show party members in the players list.</value>
</data>
<data name="Loc_IsPlayersTabAllianceVisible" xml:space="preserve">
<value>Show alliance members</value>
</data>
<data name="Loc_IsPlayersTabAllianceVisible_Description" xml:space="preserve">
<value>Show alliance members in the players list.</value>
</data>
<data name="Loc_IsPlayersTabEnemiesVisible" xml:space="preserve">
<value>Show enemies</value>
</data>
<data name="Loc_IsPlayersTabEnemiesVisible_Description" xml:space="preserve">
<value>Show enemies in the players list.</value>
</data>
<data name="Loc_IsPlayersTabOthersVisible" xml:space="preserve">
<value>Show others</value>
</data>
<data name="Loc_IsPlayersTabOthersVisible_Description" xml:space="preserve">
<value>Show others in the players list.</value>
</data>
<data name="Loc_IsTextColorAppliedToChatName" xml:space="preserve">
<value>Apply color to chat name</value>
</data>
<data name="Loc_IsTextColorAppliedToChatName_Description" xml:space="preserve">
<value>Whether the color will be applied to the name in chat.</value>
</data>
<data name="Loc_IsTextColorAppliedToNameplateName" xml:space="preserve">
<value>Apply color to nameplate name</value>
</data>
<data name="Loc_IsTextColorAppliedToNameplateName_Description" xml:space="preserve">
<value>Whether the color will be applied to the name in nameplates.</value>
</data>
<data name="Loc_IsTextColorAppliedToNameplateTitle" xml:space="preserve">
<value>Apply color to nameplate title</value>
</data>
<data name="Loc_IsTextColorAppliedToNameplateTitle_Description" xml:space="preserve">
<value>Whether the color will be applied to title in nameplates.</value>
</data>
<data name="Loc_IsTextColorAppliedToNameplateFreeCompany" xml:space="preserve">
<value>Apply color to nameplate free company</value>
</data>