Ejemplo n.º 1
0
        public override bool Initialise()
        {
            Input.RegisterKey(Keys.F10);

            Input.ReleaseKey += (sender, keys) =>
            {
                if (keys == Keys.F10)
                {
                    Settings.Enable.Value = !Settings.Enable;
                }
            };

            GameController.LeftPanel.WantUse(() => Settings.Enable);
            CalcXp = new TimeCache <bool>(() =>
            {
                partytime += time;
                time       = 0;
                CalculateXp();
                var areaCurrentArea = GameController.Area.CurrentArea;

                if (areaCurrentArea == null)
                {
                    return(false);
                }

                timeSpan = DateTime.UtcNow - areaCurrentArea.TimeEntered;

                // Time = $"{timeSpan.TotalMinutes:00}:{timeSpan.Seconds:00}";
                Time            = AreaInstance.GetTimeString(timeSpan);
                xpReceivingText = $"{xpRate}  *{levelXpPenalty * partyXpPenalty:p0}";

                xpGetLeft =
                    $"Got: {ConvertHelper.ToShorten(getXp, "0.00")} ({percentGot:P3})  Left: {ConvertHelper.ToShorten(xpLeftQ, "0.00")}";

                maxX = MathHepler.Max(Graphics.MeasureText(fps).X, Graphics.MeasureText(ping).X, Graphics.MeasureText(latency).X,
                                      Graphics.MeasureText(areaName).X, Graphics.MeasureText(xpReceivingText).X) * 1.5f;

                if (partytime > 4900)
                {
                    var levelPenaltyValue = LevelPenalty.Value;
                }

                return(true);
            }, 1000);

            LevelPenalty = new TimeCache <bool>(() =>
            {
                partyXpPenalty = PartyXpPenalty();
                levelXpPenalty = LevelXpPenalty();
                return(true);
            }, 5000);

            GameController.EntityListWrapper.PlayerUpdate += OnEntityListWrapperOnPlayerUpdate;
            OnEntityListWrapperOnPlayerUpdate(this, GameController.Player);

            debugInformation = new DebugInformation("Game FPS", "Collect game fps", false);
            return(true);
        }
Ejemplo n.º 2
0
        public override void Render()
        {
            base.Render();
            if (!Settings.Enable || (GameController.Player != null && GameController.Player.GetComponent <Player>().Level >= 100))
            {
                return;
            }

            DateTime nowTime     = DateTime.Now;
            TimeSpan elapsedTime = nowTime - lastTime;

            if (elapsedTime.TotalSeconds > 1)
            {
                CalculateXp(nowTime);
                lastTime = nowTime;
            }

            Vector2 position = StartDrawPointFunc();
            int     fontSize = Settings.TextSize;

            Size2   xpRateSize   = Graphics.DrawText(xpRate, fontSize, position, FontDrawFlags.Right);
            Vector2 secondLine   = position.Translate(0, xpRateSize.Height);
            Size2   xpLeftSize   = Graphics.DrawText(timeLeft, fontSize, secondLine, FontDrawFlags.Right);
            Vector2 thirdLine    = secondLine.Translate(0, xpLeftSize.Height);
            string  areaName     = GameController.Area.CurrentArea.DisplayName;
            Size2   areaNameSize = Graphics.DrawText(areaName, fontSize, thirdLine, FontDrawFlags.Right);

            string timer     = AreaInstance.GetTimeString(nowTime - GameController.Area.CurrentArea.TimeEntered);
            Size2  timerSize = Graphics.MeasureText(timer, fontSize);

            float boxWidth  = MathHepler.Max(xpRateSize.Width, xpLeftSize.Width, areaNameSize.Width + timerSize.Width + 20) + 15;
            float boxHeight = xpRateSize.Height + xpLeftSize.Height + areaNameSize.Height;
            var   bounds    = new RectangleF(position.X - boxWidth + 5, position.Y - 5, boxWidth, boxHeight + 10);

            string systemTime  = string.Format("{0} ({1})", nowTime.ToShortTimeString(), GameController.Game.IngameState.CurFps);
            Size2  timeFpsSize = Graphics.MeasureText(systemTime, fontSize);
            var    dif         = bounds.Width - (12 + timeFpsSize.Width + xpRateSize.Width);

            if (dif < 0)
            {
                bounds.X     += dif;
                bounds.Width -= dif;
            }

            Graphics.DrawText(systemTime, fontSize, new Vector2(bounds.X + 5, position.Y), Color.White);
            Graphics.DrawText(timer, fontSize, new Vector2(bounds.X + 5, thirdLine.Y), Color.White);

            Graphics.DrawBox(bounds, Settings.BackgroundColor);
            Size   = bounds.Size;
            Margin = new Vector2(0, 5);
        }
Ejemplo n.º 3
0
        public override void Render()
        {
            try
            {
                base.Render();
                if (!Settings.Enable || WinApi.IsKeyDown(Keys.F10))
                {
                    return;
                }

                DateTime nowTime     = DateTime.Now;
                TimeSpan elapsedTime = nowTime - lastTime;
                if (elapsedTime.TotalSeconds > 1)
                {
                    CalculateXp(nowTime);
                    partyXpPenalty = PartyXpPenalty();
                    lastTime       = nowTime;
                }

                bool showInTown =
                    !Settings.ShowInTown && GameController.Area.CurrentArea.IsTown ||
                    !Settings.ShowInTown && GameController.Area.CurrentArea.IsHideout;
                Vector2 position         = StartDrawPointFunc();
                string  fps              = $"fps:({GameController.Game.IngameState.CurFps})";
                string  areaName         = $"{GameController.Area.CurrentArea.DisplayName}";
                Color   hasCorruptedArea = PreloadAlertPlugin.hasCorruptedArea;

                if (Settings.OnlyAreaName)
                {
                    if (!showInTown)
                    {
                        var    areaNameSize = Graphics.MeasureText(areaName, Settings.TextSize);
                        float  boxHeight    = areaNameSize.Height;
                        float  boxWidth     = MathHepler.Max(areaNameSize.Width);
                        var    bounds       = new RectangleF(position.X - 84 - boxWidth, position.Y - 5, boxWidth + 90, boxHeight + 12);
                        string latency      = $"({GameController.Game.IngameState.CurLatency})";
                        Graphics.DrawText(areaName, Settings.TextSize, new Vector2(bounds.X + 84, position.Y), hasCorruptedArea);
                        Graphics.DrawImage("preload-start.png", bounds, Settings.BackgroundColor);
                        Graphics.DrawImage("preload-end.png", bounds, Settings.BackgroundColor);
                        if (Settings.ShowLatency)
                        {
                            Graphics.DrawText(latency, Settings.TextSize, new Vector2(bounds.X + 35, position.Y), Settings.LatencyTextColor);
                        }
                        Size   = bounds.Size;
                        Margin = new Vector2(0, 5);
                    }
                }

                if (!Settings.OnlyAreaName)
                {
                    if (!showInTown)
                    {
                        var     xpReceiving     = levelXpPenalty * partyXpPenalty;
                        var     xpReceivingText = $"{xpRate}  *{xpReceiving:p0}";
                        string  ping            = $"ping:({GameController.Game.IngameState.CurLatency})";
                        Size2   areaNameSize    = Graphics.DrawText(areaName, Settings.TextSize, position - 1, hasCorruptedArea, FontDrawFlags.Right);
                        Vector2 secondLine      = position.Translate(-1, areaNameSize.Height + 2);
                        Size2   xpRateSize      = Graphics.DrawText(timeLeft, Settings.TextSize, secondLine, Settings.TimeLeftColor, FontDrawFlags.Right);
                        Vector2 thirdLine       = secondLine.Translate(-1, xpRateSize.Height + 2);
                        Size2   xpLeftSize      = Graphics.DrawText(xpReceivingText, Settings.TextSize, thirdLine, Settings.TimeLeftColor, FontDrawFlags.Right);
                        string  timer           = AreaInstance.GetTimeString(nowTime - GameController.Area.CurrentArea.TimeEntered);
                        Size2   timerSize       = Graphics.MeasureText(timer, Settings.TextSize);

                        float boxWidth  = MathHepler.Max(xpRateSize.Width + 40, xpLeftSize.Width + 40, areaNameSize.Width + 20, timerSize.Width);
                        float boxHeight = xpRateSize.Height + xpLeftSize.Height + areaNameSize.Height;
                        var   bounds    = new RectangleF(position.X - boxWidth - 104, position.Y - 7, boxWidth + 110, boxHeight + 18);

                        Size2 timeFpsSize = Graphics.MeasureText(fps, Settings.TextSize);
                        var   dif         = bounds.Width - (12 + timeFpsSize.Width + xpRateSize.Width);
                        if (dif < 0)
                        {
                            bounds.X += dif; bounds.Width -= dif;
                        }

                        Graphics.DrawText(timer, Settings.TextSize, new Vector2(bounds.X + 70, position.Y), Settings.TimerTextColor);
                        Graphics.DrawText(fps, Settings.TextSize, new Vector2(bounds.X + 70, secondLine.Y), Settings.FpsTextColor);
                        Graphics.DrawText(ping, Settings.TextSize, new Vector2(bounds.X + 70, thirdLine.Y), Settings.LatencyTextColor);
                        Graphics.DrawImage("preload-start.png", bounds, Settings.BackgroundColor);
                        Graphics.DrawImage("preload-end.png", bounds, Settings.BackgroundColor);
                        Size   = bounds.Size;
                        Margin = new Vector2(0, 5);
                    }
                }
            }
            catch
            {
                // do nothing
            }
        }
Ejemplo n.º 4
0
        public override void Render()
        {
            if (GameController.Game.IngameState.IngameUi.InventoryPanel.IsVisible)
            {
                return;
            }

            try
            {
                var UIHover = GameController.Game.IngameState.UIHover;
                var miniMap = GameController.Game.IngameState.IngameUi.Map.SmallMinimap;

                if (Settings.Enable.Value && UIHover.Address != 0x00 && UIHover.Tooltip.Address != 0x00 &&
                    UIHover.Tooltip.IsVisible && UIHover.Tooltip.GetClientRect().Intersects(miniMap.GetClientRect()))
                {
                    autoHide = true;
                    Settings.Enable.Value = false;
                }
                if (autoHide && (UIHover.Address == 0x00 || UIHover.Tooltip.Address == 0x00 ||
                                 !UIHover.Tooltip.IsVisible))
                {
                    autoHide = false;
                    Settings.Enable.Value = true;
                }
                if (!holdKey && WinApi.IsKeyDown(Keys.F10))
                {
                    holdKey = true;
                    Settings.Enable.Value = !Settings.Enable.Value;
                    SettingsHub.Save(settingsHub);
                }
                else if (holdKey && !WinApi.IsKeyDown(Keys.F10))
                {
                    holdKey = false;
                }
                if (!Settings.Enable)
                {
                    return;
                }

                DateTime nowTime     = DateTime.Now;
                TimeSpan elapsedTime = nowTime - lastTime;
                if (elapsedTime.TotalSeconds > 1)
                {
                    CalculateXp(nowTime);
                    partyXpPenalty = PartyXpPenalty();
                    lastTime       = nowTime;
                }

                bool showInTown =
                    !Settings.ShowInTown && GameController.Area.CurrentArea.IsTown ||
                    !Settings.ShowInTown && GameController.Area.CurrentArea.IsHideout;
                Vector2 position      = StartDrawPointFunc();
                string  fps           = $"fps:({GameController.Game.IngameState.CurFps})";
                string  areaName      = $"{GameController.Area.CurrentArea.DisplayName}";
                Color   AreaNameColor = PreloadAlertPlugin.AreaNameColor;

                if (Settings.OnlyAreaName)
                {
                    if (!showInTown)
                    {
                        var    areaNameSize = Graphics.MeasureText(areaName, Settings.TextSize);
                        float  boxHeight    = areaNameSize.Height;
                        float  boxWidth     = MathHepler.Max(areaNameSize.Width);
                        var    bounds       = new RectangleF(position.X - 84 - boxWidth, position.Y - 5, boxWidth + 90, boxHeight + 12);
                        string latency      = $"({GameController.Game.IngameState.CurLatency})";
                        Graphics.DrawText(areaName, Settings.TextSize, new Vector2(bounds.X + 84, position.Y), AreaNameColor);
                        Graphics.DrawImage("preload-start.png", bounds, Settings.BackgroundColor);
                        Graphics.DrawImage("preload-end.png", bounds, Settings.BackgroundColor);
                        if (Settings.ShowLatency)
                        {
                            Graphics.DrawText(latency, Settings.TextSize, new Vector2(bounds.X + 35, position.Y), Settings.LatencyTextColor);
                        }
                        Size   = bounds.Size;
                        Margin = new Vector2(0, 5);
                    }
                }

                if (!Settings.OnlyAreaName)
                {
                    if (!showInTown)
                    {
                        var     xpReceiving     = levelXpPenalty * partyXpPenalty;
                        var     xpReceivingText = $"{xpRate}  *{xpReceiving:p0}";
                        var     xpGetLeft       = $"Got: {ConvertHelper.ToShorten(getXp, "0.00")}  Left: {ConvertHelper.ToShorten(xpLeftQ, "0.00")}";
                        string  ping            = $"ping:({GameController.Game.IngameState.CurLatency})";
                        Size2   areaNameSize    = Graphics.DrawText(areaName, Settings.TextSize, position - 1, AreaNameColor, FontDrawFlags.Right);
                        Vector2 secondLine      = position.Translate(-1, areaNameSize.Height + 2);
                        Size2   xpRateSize      = Graphics.DrawText(timeLeft, Settings.TextSize, secondLine, Settings.XphTextColor, FontDrawFlags.Right);
                        Vector2 thirdLine       = secondLine.Translate(-1, xpRateSize.Height + 2);
                        Size2   xpLeftSize      = Graphics.DrawText(xpReceivingText, Settings.TextSize, thirdLine, Settings.TimeLeftColor, FontDrawFlags.Right);
                        Vector2 fourLine        = thirdLine.Translate(-1, xpLeftSize.Height + 2);
                        Size2   xpGetLeftSize   = Graphics.DrawText(xpGetLeft, Settings.TextSize, fourLine,
                                                                    Settings.XphTextColor, FontDrawFlags.Right);

                        Size2 delveInfoSize = Size2.Zero;
                        if (GameController.Player.GetComponent <Stats>().StatDictionary.TryGetValue(DelveSulphiteCapacityID, out var sulphiteCapacity))
                        {
                            if (sulphiteCapacity > 0)
                            {
                                string  sulphite  = $"Sulphite: {GameController.Game.IngameState.ServerData.CurrentSulphiteAmount}/{sulphiteCapacity}";
                                string  azurite   = $"Azurite: {GameController.Game.IngameState.ServerData.CurrentAzuriteAmount}";
                                Vector2 fifthLine = fourLine.Translate(-1, xpGetLeftSize.Height + 2);
                                delveInfoSize = Graphics.DrawText($"{sulphite} {azurite}", Settings.TextSize, fifthLine,
                                                                  Settings.DelveInfoTextcolor, FontDrawFlags.Right);
                                delveInfoSize.Width += 40;
                            }
                        }

                        string timer     = AreaInstance.GetTimeString(nowTime - GameController.Area.CurrentArea.TimeEntered);
                        Size2  timerSize = Graphics.MeasureText(timer, Settings.TextSize);

                        float boxWidth  = MathHepler.Max(xpRateSize.Width + 40, xpLeftSize.Width + 40, areaNameSize.Width + 20, timerSize.Width, delveInfoSize.Width);
                        float boxHeight = xpRateSize.Height + xpLeftSize.Height + areaNameSize.Height + delveInfoSize.Height;
                        var   bounds    = new RectangleF(position.X - boxWidth - 104, position.Y - 7, boxWidth + 110, boxHeight + 40);

                        Size2 timeFpsSize = Graphics.MeasureText(fps, Settings.TextSize);
                        var   dif         = bounds.Width - (12 + timeFpsSize.Width + xpRateSize.Width);
                        if (dif < 0)
                        {
                            bounds.X += dif; bounds.Width -= dif;
                        }

                        Graphics.DrawText(timer, Settings.TextSize, new Vector2(bounds.X + 70, position.Y), Settings.TimerTextColor);
                        if (Settings.ShowFps)
                        {
                            Graphics.DrawText(fps, Settings.TextSize, new Vector2(bounds.X + 70, secondLine.Y), Settings.FpsTextColor);
                        }
                        if (Settings.ShowLatency)
                        {
                            Graphics.DrawText(ping, Settings.TextSize, new Vector2(bounds.X + 70, thirdLine.Y), Settings.LatencyTextColor);
                        }
                        Graphics.DrawImage("preload-start.png", bounds, Settings.BackgroundColor);
                        Graphics.DrawImage("preload-end.png", bounds, Settings.BackgroundColor);
                        Size   = bounds.Size;
                        Margin = new Vector2(0, 5);
                    }
                }
            }
            catch
            {
                // do nothing
            }
        }
Ejemplo n.º 5
0
        public override void Render(RenderingContext rc, Dictionary <UiMountPoint, Vec2> mountPoints)
        {
            if (this.model.Player != null && this.model.Player.GetComponent <Player>().Level >= 100)
            {
                return;
            }
            if (!this.hasStarted)
            {
                this.startXp      = this.model.Player.GetComponent <Player>().XP;
                this.startTime    = DateTime.Now;
                this.lastCalcTime = DateTime.Now;
                this.hasStarted   = true;
                return;
            }
            DateTime dtNow = DateTime.Now;
            TimeSpan delta = dtNow - this.lastCalcTime;

            if (delta.TotalSeconds > 1)
            {
                calculateRemainingExp(dtNow);
                this.lastCalcTime = dtNow;
            }

            int fontSize = Settings.FontSize;
            int bgAlpha  = Settings.BgAlpha;

            Vec2 mapWithOffset = mountPoints[UiMountPoint.LeftOfMinimap];

            int  yCursor      = 0;
            Vec2 rateTextSize = rc.AddTextWithHeight(new Vec2(mapWithOffset.X, mapWithOffset.Y), this.curDisplayString, Color.White, fontSize, DrawTextFormat.Right);

            yCursor += rateTextSize.Y;
            Vec2 remainingTextSize = rc.AddTextWithHeight(new Vec2(mapWithOffset.X, mapWithOffset.Y + yCursor), this.curTimeLeftString, Color.White, fontSize, DrawTextFormat.Right);

            yCursor += remainingTextSize.Y;

            int thirdLine = mapWithOffset.Y + yCursor;

            int    textWidth = Math.Max(rateTextSize.X, remainingTextSize.X) + 10;
            string strTimer  = null;

            if (Settings.ShowZoneAndTimeSpent)
            {
                Vec2 areaLevelNote = rc.AddTextWithHeight(new Vec2(mapWithOffset.X, thirdLine), this.model.Area.CurrentArea.DisplayName, Color.White, fontSize, DrawTextFormat.Right);

                strTimer = AreaInstance.GetTimeString(dtNow - this.model.Area.CurrentArea.TimeEntered);
                Vec2 timerSize = rc.MeasureString(strTimer, fontSize, DrawTextFormat.Left);
                yCursor  += areaLevelNote.Y;
                textWidth = Math.Max(textWidth, areaLevelNote.X + timerSize.X + 20 + 10);
            }

            Rect clientRect = model.Internal.IngameState.IngameUi.Minimap.SmallMinimap.GetClientRect();

            int  width = Math.Max(textWidth, Math.Max(clientRect.W, 0 /*this.overlay.PreloadAlert.Bounds.W*/));
            Rect rect  = new Rect(mapWithOffset.X - width + 5, mapWithOffset.Y - 5, width, yCursor + 10);

            if (Settings.ShowClock)
            {
                rc.AddTextWithHeight(new Vec2(rect.X + 5, mapWithOffset.Y), dtNow.ToShortTimeString(), Color.White, fontSize, DrawTextFormat.Left);
            }

            if (Settings.ShowZoneAndTimeSpent)
            {
                rc.AddTextWithHeight(new Vec2(rect.X + 5, thirdLine), strTimer, Color.White, fontSize, DrawTextFormat.Left);
            }

            rc.AddBox(rect, Color.FromArgb(bgAlpha, 1, 1, 1));

            mountPoints[UiMountPoint.LeftOfMinimap] = new Vec2(mapWithOffset.X, mapWithOffset.Y + 5 + rect.H);
        }
Ejemplo n.º 6
0
        public override void Render()
        {
            base.Render();

            if (!holdKey && WinApi.IsKeyDown(Keys.F10))
            {
                holdKey = true;
                Settings.Enable.Value = !Settings.Enable.Value;
            }
            else if (holdKey && !WinApi.IsKeyDown(Keys.F10))
            {
                holdKey = false;
            }

            if (!Settings.Enable || (GameController.Player != null && GameController.Player.GetComponent <Player>().Level >= 100))
            {
                return;
            }

            DateTime nowTime     = DateTime.Now;
            TimeSpan elapsedTime = nowTime - lastTime;

            if (elapsedTime.TotalSeconds > 1)
            {
                CalculateXp(nowTime);
                lastTime = nowTime;
            }

            if (Settings.OnlyAreaName)
            {
                var    position     = StartDrawPointFunc();
                string latency      = $"({GameController.Game.IngameState.CurLatency})";
                string areaName     = $"{GameController.Area.CurrentArea.DisplayName}";
                var    areaNameSize = Graphics.MeasureText(areaName, Settings.FontSize);
                float  boxHeight    = areaNameSize.Height;
                float  boxWidth     = MathHepler.Max(areaNameSize.Width);
                var    bounds       = new RectangleF(position.X - 72 - boxWidth, position.Y - 5, boxWidth + 80, boxHeight + 12);

                Graphics.DrawText(areaName, Settings.FontSize, new Vector2(bounds.X + 74, position.Y), Settings.AreaFontColor);
                Graphics.DrawImage("preload-start.png", bounds, Settings.BackgroundColor);
                Graphics.DrawImage("preload-end.png", bounds, Settings.BackgroundColor);
                if (Settings.ShowLatency)
                {
                    Graphics.DrawText(latency, Settings.FontSize, new Vector2(bounds.X + 25, position.Y), Settings.LatencyFontColor);
                }
                Size   = bounds.Size;
                Margin = new Vector2(0, 5);
            }

            if (!Settings.OnlyAreaName)
            {
                string  xpGain       = XPPenalty();
                Vector2 position     = StartDrawPointFunc();
                string  areaName     = GameController.Area.CurrentArea.DisplayName;
                string  fps          = $"fps:({GameController.Game.IngameState.CurFps})";
                string  ping         = $"ping:({GameController.Game.IngameState.CurLatency})";
                Size2   areaNameSize = Graphics.DrawText(areaName, Settings.FontSize, position, Settings.AreaFontColor, FontDrawFlags.Right);
                Vector2 secondLine   = position.Translate(0, areaNameSize.Height);
                Size2   xpRateSize   = Graphics.DrawText(timeLeft, Settings.FontSize, secondLine, Settings.TimeLeftColor, FontDrawFlags.Right);
                Vector2 thirdLine    = secondLine.Translate(0, xpRateSize.Height);
                Size2   xpLeftSize   = Graphics.DrawText(xpRate + xpGain, Settings.FontSize, thirdLine, Settings.TimeLeftColor, FontDrawFlags.Right);
                string  timer        = AreaInstance.GetTimeString(nowTime - GameController.Area.CurrentArea.TimeEntered);
                Size2   timerSize    = Graphics.MeasureText(timer, Settings.FontSize);

                float boxWidth  = MathHepler.Max(xpRateSize.Width, xpLeftSize.Width, areaNameSize.Width + 85, timerSize.Width);
                float boxHeight = xpRateSize.Height + xpLeftSize.Height + areaNameSize.Height;
                var   bounds    = new RectangleF(position.X - boxWidth - 81, position.Y - 5, boxWidth + 90, boxHeight + 13);

                Size2 timeFpsSize = Graphics.MeasureText(fps, Settings.FontSize);
                var   dif         = bounds.Width - (12 + timeFpsSize.Width + xpRateSize.Width);
                if (dif < 0)
                {
                    bounds.X     += dif;
                    bounds.Width -= dif;
                }
                Graphics.DrawText(ping, Settings.FontSize, new Vector2(bounds.X + 25, position.Y), Settings.LatencyFontColor);
                Graphics.DrawText(timer, Settings.FontSize, new Vector2(bounds.X + 25, secondLine.Y), Settings.TimerFontColor);
                Graphics.DrawText(fps, Settings.FontSize, new Vector2(bounds.X + 25, thirdLine.Y), Settings.FpsFontColor);
                Graphics.DrawImage("preload-start.png", bounds, Settings.BackgroundColor);
                Graphics.DrawImage("preload-end.png", bounds, Settings.BackgroundColor);
                Size   = bounds.Size;
                Margin = new Vector2(0, 5);
            }
        }