コード例 #1
0
        public void DrawPlayerLine(Graphics g, Rectangle bounds, Color foreColor, Color backColor, bool grayedOut, bool isBattle)
        {
            g.TextRenderingHint = TextRenderingHint.SystemDefault;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;

            var x = 0;

            if (grayedOut)
            {
                foreColor = Program.Conf.FadeColor;
            }

            Action <Image> drawImage = image =>
            {
                g.DrawImage(image, bounds.Left + x, bounds.Top, 16, 16);
                x += 19;
            };

            Action <string, Color, Color> drawText = (text, fore, back) =>
            {
                TextRenderer.DrawText(g, text, font, new Point(bounds.Left + x, bounds.Top), fore, back);
                x += TextRenderer.MeasureText(g, text, font).Width;
            };

            // is section header
            if (Title != null)
            {
                font = boldFont;
                if (Title == "Search results:")
                {
                    drawImage(ZklResources.search);
                }
                TextRenderer.DrawText(g, Title, font, bounds, foreColor, backColor, TextFormatFlags.HorizontalCenter);
                return;
            }

            // is button
            if (Button != null)
            {
                font = boldFont;
                ButtonRenderer.DrawButton(g, bounds, Button, font, false, PushButtonState.Normal);
                return;
            }

            // is player slot
            if (SlotButton != null)
            {
                var slotText = string.Format("Empty Slot: {0} {1}", MissionSlot.TeamName, MissionSlot.IsRequired ? "(Required)" : String.Empty);
                var color    = ((MyCol)MissionSlot.Color);
                if (!IsZeroKBattle)
                {
                    using (var brush = new SolidBrush(Color.FromArgb(color.R, color.G, color.B)))
                    {
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                        g.FillEllipse(brush, x, bounds.Top, bounds.Bottom - bounds.Top, bounds.Bottom - bounds.Top);
                    }
                }
                x += bounds.Bottom - bounds.Top + 2;
                drawText(slotText, foreColor, backColor);
                return;
            }

            // is bot
            if (BotBattleStatus != null)
            {
                var bot = BotBattleStatus;
                x += 19;
                drawImage(ZklResources.robot);
                var botDisplayName = MissionSlot == null ? bot.aiLib : MissionSlot.TeamName;
                drawText(botDisplayName + " (" + bot.owner + ")", foreColor, backColor);
                return;
            }

            // is player
            var user       = User;
            var userStatus = UserBattleStatus;

            if (UserName != null && user == null)
            {
                drawText(UserName + " has left.", foreColor, backColor);
                return;
            }

            if (isBattle)
            {
                if (userStatus.IsSpectator && (Program.TasClient.MyBattle == null || !Program.TasClient.MyBattle.IsQueue || Program.TasClient.MyBattle.Founder.Name == userStatus.Name))
                {
                    drawImage(ZklResources.spec);
                }
                else if (userStatus.SyncStatus == SyncStatuses.Synced)
                {
                    drawImage(ZklResources.ready);
                }
                else
                {
                    drawImage(ZklResources.unready);
                }
            }

            drawImage(TextImage.GetUserImage(user.Name));

            Image flag;

            if (Images.CountryFlags.TryGetValue(user.Country, out flag) && flag != null)
            {
                g.DrawImageUnscaled(flag, bounds.Left + x, bounds.Top + 4);
            }
            x += 16;
            x += 2; // margin

            if (!user.IsBot)
            {
                drawImage(Images.GetRank(user.Level));

                var clan = ServerImagesHandler.GetClanOrFactionImage(user);
                if (clan.Item1 != null)
                {
                    drawImage(clan.Item1);
                }
            }

            var userDisplayName = MissionSlot == null ? user.Name : String.Format("{1}: {0}", MissionSlot.TeamName, user.Name);

            drawText(userDisplayName, foreColor, backColor);
            var top10 = Program.SpringieServer.GetTop10Rank(user.Name);

            if (top10 > 0)
            {
                var oldProgression = x;
                drawImage(ZklResources.cup);
                x = oldProgression;
                TextRenderer.DrawText(g, top10.ToString(), boldFont, new Point(bounds.Left + x + 1, bounds.Top), Color.Black, Color.Transparent);
                x += 16;
            }

            if (user.IsInGame)
            {
                drawImage(ZklResources.ingame);
            }
            else if (!isBattle && user.IsInBattleRoom)
            {
                drawImage(ZklResources.battle);
            }

            if (user.IsAway)
            {
                drawImage(ZklResources.away);
            }

            if (isBattle && !userStatus.IsSpectator)
            {
                if (MissionSlot != null)
                {
                    if (userStatus.AllyNumber != MissionSlot.AllyID)
                    {
                        drawText(string.Format("Wrong alliance ({0} instead of {1}).", userStatus.AllyNumber, MissionSlot.AllyID),
                                 Color.Red,
                                 backColor);
                    }
                }
            }

            if (user.SteamID != null)
            {
                bool isEnabled;
                bool isTalking;
                Program.SteamHandler.Voice.GetUserVoiceInfo(user.SteamID.Value, out isEnabled, out isTalking);
                if (isEnabled)
                {
                    drawImage(isTalking ? ZklResources.voice_talking : ZklResources.voice_off);
                }
            }
        }
コード例 #2
0
        public void DrawPlayerLine(Graphics g, Rectangle bounds, Color textColor, bool grayedOut, bool isBattle)
        {
            g.TextRenderingHint = TextRenderingHint.SystemDefault;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;

            var x = 0;

            if (grayedOut)
            {
                textColor = Program.Conf.FadeColor;
            }

            Action <Image> drawImage = image =>
            {
                g.DrawImage(image, bounds.Left + x, bounds.Top, 16, 16);
                x += 19;
            };

            Action <string, Color> drawText = (text, color) =>
            {
                TextRenderer.DrawText(g, text, font, new Point(bounds.Left + x, bounds.Top - 2), color, TextFormatFlags.PreserveGraphicsTranslateTransform);
                x += TextRenderer.MeasureText(g, text, font).Width;
            };

            // is section header
            if (Title != null)
            {
                font = boldFont;
                if (Title == "Search results:")
                {
                    drawImage(ZklResources.search);
                }
                TextRenderer.DrawText(g, Title, font, bounds, textColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.PreserveGraphicsTranslateTransform);
                return;
            }

            // is button
            if (Button != null)
            {
                font = boldFont;
                FrameBorderRenderer.Instance.RenderToGraphics(g, bounds, FrameBorderRenderer.StyleType.DarkHive);
                TextRenderer.DrawText(g, Button, font, bounds, textColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.PreserveGraphicsTranslateTransform);
                return;
            }


            // is bot
            if (BotBattleStatus != null)
            {
                var bot = BotBattleStatus;
                x += 19;
                drawImage(ZklResources.robot);
                var botDisplayName = bot.aiLib;
                drawText(botDisplayName + " (" + bot.owner + ")", textColor);
                return;
            }

            // is player
            var user       = User;
            var userStatus = UserBattleStatus;

            if (UserName != null && user == null)
            {
                drawText(UserName + " has left.", textColor);
                return;
            }

            if (isBattle)
            {
                if (userStatus.IsSpectator && (Program.TasClient.MyBattle == null || Program.TasClient.MyBattle.FounderName == userStatus.Name))
                {
                    drawImage(ZklResources.spec);
                }
                else if (userStatus.SyncStatus == SyncStatuses.Synced)
                {
                    drawImage(ZklResources.ready);
                }
                else
                {
                    drawImage(ZklResources.unready);
                }
            }

            drawImage(TextImage.GetUserImage(user.Name));

            Image flag;

            if (Images.CountryFlags.TryGetValue(user.Country, out flag) && flag != null)
            {
                g.DrawImageUnscaled(flag, bounds.Left + x, bounds.Top + 4);
            }
            x += 16;
            x += 2; // margin

            if (!user.IsBot)
            {
                drawImage(Images.GetRank(user.Level, user.EffectiveMmElo));

                var clan = ServerImagesHandler.GetClanOrFactionImage(user);
                if (clan.Item1 != null)
                {
                    drawImage(clan.Item1);
                }
            }

            var userDisplayName = user.Name;

            drawText(userDisplayName, textColor);

            if (user.IsInGame)
            {
                drawImage(Buttons.fight);
            }
            else if (!isBattle && user.IsInBattleRoom)
            {
                drawImage(Buttons.game);
            }

            if (user.IsAway)
            {
                drawImage(ZklResources.away);
            }


            if (user.SteamID != null)
            {
                bool isEnabled;
                bool isTalking;
                Program.SteamHandler.Voice.GetUserVoiceInfo(ulong.Parse(user.SteamID), out isEnabled, out isTalking);
                if (isEnabled)
                {
                    drawImage(isTalking ? ZklResources.voice_talking : ZklResources.voice_off);
                }
            }
        }