Example #1
0
        public Vector4 GetBarBackgroundColor(MonitorDisplay display, DisplayTimer timer)
        {
            if (!timer.IsComplete)
            {
                return(display.BarBackgroundColor);
            }
            if (!display.PulseReady)
            {
                return(timer.FinishedColor);
            }
            var s = (float)Math.Abs((Math.Abs((timer.TimerRemaining - display.CacheAge.TotalSeconds) / (2.5f - display.PulseSpeed)) - (float)Math.Floor(Math.Abs((timer.TimerRemaining - display.CacheAge.TotalSeconds) / (2.5f - display.PulseSpeed))) - 0.5f) / 2) * display.PulseIntensity;

            if (timer.FinishedColor.W < 0.75)
            {
                return(timer.FinishedColor + new Vector4(0, 0, 0, s));
            }
            return(timer.FinishedColor - new Vector4(0, 0, 0, s));
        }
Example #2
0
        private List <DisplayTimer> GetTimerList(MonitorDisplay display)
        {
            var timerList = new List <DisplayTimer>();

            if (InPvP)
            {
                return(timerList);
            }
            try {
                if (display.Cooldowns.Count > 0)
                {
                    foreach (var cd in display.Cooldowns.Where(cd => {
                        if (cd.ClassJob != PluginInterface.ClientState.LocalPlayer.ClassJob.Id)
                        {
                            return(false);
                        }
                        var action = ActionManager.GetAction(cd.ActionId, true);
                        if (action == null || !action.ClassJobCategory.Value.HasClass(PluginInterface.ClientState.LocalPlayer.ClassJob.Id))
                        {
                            return(false);
                        }
                        if (action.ClassJobLevel > PluginInterface.ClientState.LocalPlayer.Level)
                        {
                            return(false);
                        }
                        if (action.ClassJob.Row == 36 && !BlueMagicSpellbook.Contains(action.RowId))
                        {
                            return(false);
                        }
                        var cooldown = ActionManager.GetActionCooldown(action);
                        if (display.OnlyShowReady && cooldown.IsOnCooldown)
                        {
                            return(false);
                        }
                        if (display.OnlyShowCooldown && !cooldown.IsOnCooldown)
                        {
                            return(false);
                        }
                        if (display.LimitDisplayTime && cooldown.Countdown > display.LimitDisplayTimeSeconds)
                        {
                            return(false);
                        }
                        if (display.LimitDisplayReadyTime && cooldown.CompleteFor > display.LimitDisplayReadyTimeSeconds)
                        {
                            return(false);
                        }
                        if (actionSpecialChecks.ContainsKey(action.RowId))
                        {
                            if (!actionSpecialChecks[action.RowId](display, cd, PluginInterface))
                            {
                                return(false);
                            }
                        }
                        return(true);
                    }))
                    {
                        var action = ActionManager.GetAction(cd.ActionId);

                        if (action != null)
                        {
                            var cooldown = ActionManager.GetActionCooldown(action);
                            timerList.Add(new DisplayTimer {
                                TimerMax      = cooldown.CooldownTotal,
                                TimerCurrent  = cooldown.CooldownElapsed + cooldown.CompleteFor,
                                FinishedColor = display.AbilityReadyColor,
                                ProgressColor = display.AbilityCooldownColor,
                                IconId        = IconManager.GetActionIconId(action),
                                Name          = action.Name
                            });
                        }
                    }
                }
            } catch (Exception ex) {
                PluginLog.LogError("Error parsing cooldowns.");
                PluginLog.Log(ex.ToString());
            }

            try {
                if (display.StatusMonitors.Count > 0)
                {
                    var localPlayerAsList = new List <Actor>()
                    {
                        PluginInterface.ClientState.LocalPlayer
                    };

                    foreach (var sd in display.StatusMonitors.Where(sm => sm.ClassJob == PluginInterface.ClientState.LocalPlayer.ClassJob.Id))
                    {
                        foreach (var sid in sd.StatusIDs)
                        {
                            var status = PluginInterface.Data.Excel.GetSheet <Status>().GetRow(sid);
                            if (status == null)
                            {
                                continue;
                            }

                            if (!ActorsWithStatus.ContainsKey(status.RowId))
                            {
                                continue;
                            }

                            foreach (var a in sd.SelfOnly ? localPlayerAsList : ActorsWithStatus[status.RowId])
                            {
                                if (a != null)
                                {
                                    foreach (var se in a.StatusEffects)
                                    {
                                        if (sd.IsRaid == false && se.OwnerId != PluginInterface.ClientState.LocalPlayer.ActorId)
                                        {
                                            continue;
                                        }
                                        if (sd.LimitedZone > 0 && sd.LimitedZone != PluginInterface.ClientState.TerritoryType)
                                        {
                                            continue;
                                        }
                                        if (display.LimitDisplayTime && se.Duration > display.LimitDisplayTimeSeconds)
                                        {
                                            continue;
                                        }
                                        if (se.EffectId == (short)status.RowId)
                                        {
                                            var t = new DisplayTimer {
                                                TimerMax       = sd.MaxDuration,
                                                TimerCurrent   = sd.MaxDuration <= 0 ? (1 + generalStopwatch.ElapsedMilliseconds / 1000f) : (sd.MaxDuration - se.Duration),
                                                FinishedColor  = display.AbilityReadyColor,
                                                ProgressColor  = display.StatusEffectColor,
                                                IconId         = (ushort)(status.Icon + (sd.Stacking ? se.StackCount - 1 : 0)),
                                                Name           = status.Name,
                                                AllowCountdown = sd.MaxDuration > 0,
                                                StackCount     = sd.Stacking ? se.StackCount : -1,
                                            };

                                            if (!sd.SelfOnly)
                                            {
                                                t.TargetName     = a.Name;
                                                t.TargetNameOnly = display.StatusOnlyShowTargetName;
                                                t.ClickAction    = sd.ClickHandler;
                                                t.ClickParam     = a;
                                            }

                                            timerList.Add(t);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                PluginLog.LogError("Error parsing statuses.");
                PluginLog.Log(ex.ToString());
            }

            timerList.Sort((a, b) => {
                var diff = a.TimerRemaining - b.TimerRemaining;
                if (Math.Abs(diff) < 0.1)
                {
                    return(string.CompareOrdinal(a.Name, b.Name));                      // Equal
                }
                if (diff < 0)
                {
                    return(-1);
                }
                return(1);
            });

            foreach (var reminder in display.GeneralReminders)
            {
                if (reminder.ShouldShow(PluginInterface, this, display))
                {
                    timerList.Insert(0, new DisplayTimer {
                        TimerMax       = 1,
                        TimerCurrent   = 1 + generalStopwatch.ElapsedMilliseconds / 1000f,
                        FinishedColor  = display.AbilityReadyColor,
                        ProgressColor  = display.StatusEffectColor,
                        IconId         = reminder.GetIconID(PluginInterface, this, display),
                        Name           = reminder.GetText(PluginInterface, this, display),
                        AllowCountdown = false
                    });
                }
            }

            return(timerList);
        }