private void OnNamePlateUpdate(NamePlateUpdateEventArgs args)
        {
            try
            {
                // check if nameplates should be used
                if (this.plugin.Configuration.RestrictNamePlatesInCombat &&
                    PlayerTrackPlugin.Condition.InCombat())
                {
                    return;
                }

                var restrict =
                    ContentRestrictionType.GetContentRestrictionTypeByIndex(this.plugin.Configuration.ShowNamePlates);
                if (restrict == ContentRestrictionType.Never ||
                    !(restrict == ContentRestrictionType.Always ||
                      (restrict == ContentRestrictionType.ContentOnly && PlayerTrackPlugin.DataManager.InContent(PlayerTrackPlugin.ClientState.TerritoryType)) ||
                      (restrict == ContentRestrictionType.HighEndDutyOnly && PlayerTrackPlugin.DataManager.InHighEndDuty(PlayerTrackPlugin.ClientState.TerritoryType))))
                {
                    return;
                }

                // check if any nameplate features enabled
                if (!this.plugin.Configuration.ChangeNamePlateTitle &&
                    !this.plugin.Configuration.UseNamePlateColors)
                {
                    return;
                }

                // check if plugin started
                if (!this.plugin.IsDoneLoading)
                {
                    return;
                }

                // check if valid
                if (args.Type != PlateType.Player || args.ObjectId == 0)
                {
                    return;
                }

                // get actor
                var actorGameObject = PlayerTrackPlugin.ObjectTable.SearchById(args.ObjectId);
                if (actorGameObject == null || actorGameObject is not PlayerCharacter actorPlayer)
                {
                    return;
                }

                var player = this.plugin.PlayerService.GetPlayer(actorPlayer.Name.ToString(), (ushort)actorPlayer.HomeWorld.Id);
                if (player == null)
                {
                    return;
                }

                // set category
                var category = this.plugin.CategoryService.GetCategory(player.CategoryId);

                // force consistent nameplate style
                if (this.plugin.Configuration.ForceNamePlateStyle)
                {
                    args.Type = PlateType.LowTitleNoFc;
                }

                // set title
                if (this.plugin.Configuration.ChangeNamePlateTitle)
                {
                    // set title by player
                    if (player.SeTitle != null)
                    {
                        args.Title = player.SeTitle;
                    }

                    // set title by category
                    else if (category.IsNamePlateTitleEnabled)
                    {
                        if (category.IsNamePlateTitleEnabled && category.SeName != null)
                        {
                            args.Title = category.SeName;
                        }
                    }
                }

                // set color
                if (this.plugin.Configuration.DisableNamePlateColorIfDead && actorPlayer.IsDead())
                {
                    return;
                }
                if (this.plugin.Configuration.UseNamePlateColors)
                {
                    // set color by player
                    if (player.NamePlateColor != null)
                    {
                        args.Colour = ((Vector4)player.NamePlateColor).ToByteColor();
                    }

                    // set color by category
                    else if (category.IsNamePlateColorEnabled && category.NamePlateColor != null)
                    {
                        args.Colour = ((Vector4)category.NamePlateColor).ToByteColor();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Failed to update nameplate.");
            }
        }
Exemple #2
0
        private void ProcessingConfig()
        {
            // restrict in combat
            var restrictInCombat = this.Plugin.Configuration.RestrictInCombat;

            if (ImGui.Checkbox(
                    Loc.Localize("RestrictInCombat", "Don't process in combat") +
                    "###PlayerTrack_RestrictInCombat_Checkbox",
                    ref restrictInCombat))
            {
                this.Plugin.Configuration.RestrictInCombat = restrictInCombat;
                this.Plugin.SaveConfig();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "RestrictInCombat_HelpMarker",
                                           "stop processing players while in combat"));
            ImGui.Spacing();

            // add / update players
            ImGui.Text(Loc.Localize("RestrictAddUpdatePlayers", "Add / Update Players"));
            var restrictAddUpdatePlayersIndex = this.plugin.Configuration.RestrictAddUpdatePlayers;

            ImGui.SetNextItemWidth(180f * ImGuiHelpers.GlobalScale);
            if (ImGui.Combo(
                    "###PlayerTrack_RestrictAddUpdatePlayers_Combo",
                    ref restrictAddUpdatePlayersIndex,
                    ContentRestrictionType.RestrictionTypeNames.ToArray(),
                    ContentRestrictionType.RestrictionTypeNames.Count))
            {
                this.plugin.Configuration.RestrictAddUpdatePlayers = ContentRestrictionType.GetContentRestrictionTypeByIndex(restrictAddUpdatePlayersIndex).Index;
                this.plugin.SaveConfig();
                this.plugin.PlayerService.ResetViewPlayers();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "RestrictAddUpdatePlayers_HelpMarker",
                                           "when to add or update players in your area"));
            ImGui.Spacing();

            // add encounters
            ImGui.Text(Loc.Localize("RestrictAddEncounters", "Add New Encounters"));
            var restrictAddEncountersIndex = this.plugin.Configuration.RestrictAddEncounters;

            ImGui.SetNextItemWidth(180f * ImGuiHelpers.GlobalScale);
            if (ImGui.Combo(
                    "###PlayerTrack_RestrictAddEncounters_Combo",
                    ref restrictAddEncountersIndex,
                    ContentRestrictionType.RestrictionTypeNames.ToArray(),
                    ContentRestrictionType.RestrictionTypeNames.Count))
            {
                this.plugin.Configuration.RestrictAddEncounters = ContentRestrictionType.GetContentRestrictionTypeByIndex(restrictAddEncountersIndex).Index;
                this.plugin.SaveConfig();
                this.plugin.PlayerService.ResetViewPlayers();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "RestrictAddEncounters_HelpMarker",
                                           "when to add new encounters (new row in the encounters tab). " +
                                           "don't recommend using always as this will significantly increase file size."));
            ImGui.Spacing();

            // encounters threshold
            ImGui.Text(Loc.Localize("NewEncounterThreshold", "New Encounter Threshold (minutes)"));
            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "NewEncounterThreshold_HelpMarker",
                                           "threshold for creating new encounter for player in same location"));
            var newEncounterThreshold =
                this.plugin.Configuration.CreateNewEncounterThreshold.FromMillisecondsToMinutes();

            if (ImGui.SliderInt("###PlayerTrack_NewEncounterThreshold_Slider", ref newEncounterThreshold, 0, 240))
            {
                this.plugin.Configuration.CreateNewEncounterThreshold =
                    newEncounterThreshold.FromMinutesToMilliseconds();
                this.plugin.SaveConfig();
            }

            ImGui.Spacing();
        }
Exemple #3
0
        private void NamePlateConfig()
        {
            // warning about compatability
            ImGui.TextColored(ImGuiColors.DalamudYellow, Loc.Localize(
                                  "NamePlateCompatabilityWarning",
                                  "Warning: Not all of these settings will work if you are using other plugins that modify nameplates."));
            ImGui.Spacing();

            // restrict nameplate use
            ImGui.Text(Loc.Localize("ShowNamePlates", "Show Nameplates"));
            var showNamePlatesIndex = this.plugin.Configuration.ShowNamePlates;

            ImGui.SetNextItemWidth(180f * ImGuiHelpers.GlobalScale);
            if (ImGui.Combo(
                    "###PlayerTrack_ShowNamePlates_Combo",
                    ref showNamePlatesIndex,
                    ContentRestrictionType.RestrictionTypeNames.ToArray(),
                    ContentRestrictionType.RestrictionTypeNames.Count))
            {
                this.plugin.Configuration.ShowNamePlates = ContentRestrictionType.GetContentRestrictionTypeByIndex(showNamePlatesIndex).Index;
                this.plugin.SaveConfig();
                this.plugin.PlayerService.ResetViewPlayers();
                this.plugin.NamePlateManager.ForceRedraw();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "ShowNamePlates_HelpMarker",
                                           "when to show custom nameplates"));
            ImGui.Spacing();

            // restrict in combat
            var restrictNamePlatesInCombat = this.Plugin.Configuration.RestrictNamePlatesInCombat;

            if (ImGui.Checkbox(
                    Loc.Localize("RestrictNamePlatesInCombat", "Don't show nameplates in combat") +
                    "###PlayerTrack_RestrictNamePlatesInCombat_Checkbox",
                    ref restrictNamePlatesInCombat))
            {
                this.Plugin.Configuration.RestrictNamePlatesInCombat = restrictNamePlatesInCombat;
                this.Plugin.SaveConfig();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "RestrictNamePlatesInCombat_HelpMarker",
                                           "stop showing nameplates in combat regardless of other settings"));
            ImGui.Spacing();

            // use nameplate colors
            var useNamePlateColors = this.Plugin.Configuration.UseNamePlateColors;

            if (ImGui.Checkbox(
                    Loc.Localize($"UseNamePlateColors", "Use nameplate color"),
                    ref useNamePlateColors))
            {
                this.Plugin.Configuration.UseNamePlateColors = useNamePlateColors;
                this.Plugin.SaveConfig();
                this.plugin.NamePlateManager.ForceRedraw();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "UseNamePlateColors_HelpMarker",
                                           "override normal nameplate color with category/player colors"));
            ImGui.Spacing();

            // disable name plate color change if player is dead
            var disableNamePlateColorIfDead = this.Plugin.Configuration.DisableNamePlateColorIfDead;

            if (ImGui.Checkbox(
                    Loc.Localize("DisableNamePlateColorIfDead", "Disable nameplate color if player is dead") +
                    "###PlayerTrack_DisableNamePlateColorIfDead_Checkbox",
                    ref disableNamePlateColorIfDead))
            {
                this.Plugin.Configuration.DisableNamePlateColorIfDead = disableNamePlateColorIfDead;
                this.Plugin.SaveConfig();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "DisableNamePlateColorIfDead_HelpMarker",
                                           "don't update nameplate for dead players so easier to see they are dead"));
            ImGui.Spacing();

            // default the nameplate color to the list color unless changed
            var defaultNamePlateColorToListColor = this.Plugin.Configuration.DefaultNamePlateColorToListColor;

            if (ImGui.Checkbox(
                    Loc.Localize("DefaultNamePlateColorToListColor", "Default nameplate color to list color") +
                    "###PlayerTrack_DefaultNamePlateColorToListColor_Checkbox",
                    ref defaultNamePlateColorToListColor))
            {
                this.Plugin.Configuration.DefaultNamePlateColorToListColor = defaultNamePlateColorToListColor;
                this.Plugin.SaveConfig();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "DefaultNamePlateColorToListColor_HelpMarker",
                                           "default the nameplate color to the list color unless changed"));
            ImGui.Spacing();

            // use nameplate titles
            var changeNamePlateTitle = this.Plugin.Configuration.ChangeNamePlateTitle;

            if (ImGui.Checkbox(
                    Loc.Localize($"ChangeNamePlateTitle", "Change nameplate title"),
                    ref changeNamePlateTitle))
            {
                this.Plugin.Configuration.ChangeNamePlateTitle = changeNamePlateTitle;
                this.Plugin.SaveConfig();
                this.plugin.NamePlateManager.ForceRedraw();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "ChangeNamePlateTitle_HelpMarker",
                                           "override normal nameplate to use title or category name"));
            ImGui.Spacing();

            // force nameplate style
            var forceNamePlateStyle = this.Plugin.Configuration.ForceNamePlateStyle;

            if (ImGui.Checkbox(
                    Loc.Localize($"ForceNamePlateStyle", "Force consistent nameplate style"),
                    ref forceNamePlateStyle))
            {
                this.Plugin.Configuration.ForceNamePlateStyle = forceNamePlateStyle;
                this.Plugin.SaveConfig();
                this.plugin.NamePlateManager.ForceRedraw();
            }

            ImGuiComponents.HelpMarker(Loc.Localize(
                                           "ForceNamePlateStyle_HelpMarker",
                                           "force LowTitleNoFc nameplate style which looks more " +
                                           "consistent \nbut hides FC and doesn't play nicely with other plugins"));
            ImGui.Spacing();
        }