Exemplo n.º 1
0
        public static TextModel Create(MapTextBlock textBlock)
        {
            var builder = TextBuilder.NewTextModel();

            builder.SetName(textBlock.Name);
            builder.SetText(textBlock.Value);
            return(builder.Build());
        }
Exemplo n.º 2
0
        /// <summary>
        /// This writes a MAP file text block.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="text">Text to write in to block</param>
        private void WriteTextBlock(MapTextBlock block)
        {
            var text = block.Value;

            text = Other.ConvertLineBreaksCRLFToLF(text) + "\0";
            //Insure division by 2 of block length
            text = text.PadRight(text.Length + text.Length % 2, '\0');

            _binWriter.Write(Encoding.ASCII.GetBytes(block.Name));
            //For some reason each text block has to have length overlapping with start of next block
            _binWriter.Write((UInt32)(text.Length + 4));
            _binWriter.Write(Encoding.ASCII.GetBytes(text));
        }
Exemplo n.º 3
0
        public void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons, Dictionary<Kill, KillDisplayDetails> dicKills, List<BattlemapRoundChange> lstRounds, KillDisplayColours colours, Dictionary<int, Color> teamColours)
        {
            GraphicsPath gpTimelineOutline = new GraphicsPath();

            gpTimelineOutline.AddLines(new Point[] { new Point(5, 0), new Point(0, 5), new Point(0, 15), new Point((int)g.ClipBounds.Width - 280, 15), new Point((int)g.ClipBounds.Width - 280, 5), new Point((int)g.ClipBounds.Width - 275, 0) });
            //gpTimelineOutline.AddLine(new Point(this.m_mtsSeek.SeekerPosition, 15), new Point((int)g.ClipBounds.Width - 280, 15));
            //gpTimelineOutline.AddLines(new Point[] { new Point(235, (int)g.ClipBounds.Height - 55), new Point(230, (int)g.ClipBounds.Height - 50), new Point(230, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 50), new Point((int)g.ClipBounds.Width - 45, (int)g.ClipBounds.Height - 55) });
            gpTimelineOutline.Widen(this.m_pOneWidth);

            this.ObjectPath = gpTimelineOutline;
            RectangleF recBounds = gpTimelineOutline.GetBounds();
            recBounds.Height += 50.0F;
            this.HotSpot = recBounds;

            //string strMouseOverKillList = String.Empty;
            float flMouseOffsetX = 0.0F;

            bool blRoundChanged = false;

            MapTextBlock timeList = new MapTextBlock();

            foreach (BattlemapRoundChange RoundChange in new List<BattlemapRoundChange>(lstRounds)) {
                float flOffsetXs = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - RoundChange.ChangeTime.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
                RectangleF recChangePosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);

                if (flOffsetXs >= 0.0F) {
                    GraphicsPath gpChangeTime = new GraphicsPath();
                    gpChangeTime.AddLine(new PointF(flOffsetXs, 5), new PointF(flOffsetXs, 12));
                    gpChangeTime.Widen(this.m_pOneWidth);

                    this.DrawBwShape(g, gpChangeTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
                    gpChangeTime.Dispose();

                    if (recChangePosition.Contains(new PointF(pntMouseLocation.X, pntMouseLocation.Y)) == true) {
                        //strMouseOverKillList += String.Format("Round change {0}\r\n", RoundChange.Map.PublicLevelName);

                        timeList.Strings.Add(new MapTextBlockString(String.Format("Round change {0}", RoundChange.Map.PublicLevelName), Color.Pink, true));

                        blRoundChanged = true;
                        flMouseOffsetX = flOffsetXs;
                        //flMouseOffsetX = flOffsetXs;
                    }
                }
            }

            foreach (KeyValuePair<Kill, KillDisplayDetails> kvpKill in new Dictionary<Kill, KillDisplayDetails>(dicKills)) {

                float flOffsetXs = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - kvpKill.Key.TimeOfDeath.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
                RectangleF recKillPosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);

                if (recKillPosition.Contains(new PointF(pntMouseLocation.X + 5.0F, pntMouseLocation.Y)) == true) {
                    GraphicsPath gpKillTime = new GraphicsPath();
                    gpKillTime.AddLine(new PointF(flOffsetXs, 10), new PointF(flOffsetXs, 12));
                    gpKillTime.Widen(this.m_pOneWidth);

                    this.DrawBwShape(g, gpKillTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
                    gpKillTime.Dispose();

                    Color killerColour = Color.White;
                    Color victimColour = Color.White;

                    if (colours == KillDisplayColours.EnemyColours) {
                        killerColour = ControlPaint.Light(Color.SeaGreen);
                        victimColour = ControlPaint.LightLight(Color.Black);
                    }
                    else if (colours == KillDisplayColours.TeamColours) {
                        if (teamColours.ContainsKey(kvpKill.Key.Killer.TeamID) == true && teamColours.ContainsKey(kvpKill.Key.Victim.TeamID) == true) {
                            killerColour = ControlPaint.Light(teamColours[kvpKill.Key.Killer.TeamID]);
                            victimColour = ControlPaint.Light(teamColours[kvpKill.Key.Victim.TeamID]);
                        }
                    }

                    if (kvpKill.Key.Killer.ClanTag.Length > 0) {
                        timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Killer.ClanTag), killerColour, false));
                    }

                    timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Killer.SoldierName, killerColour, false));

                    timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.DamageType), Color.WhiteSmoke, false));

                    if (kvpKill.Key.Victim.ClanTag.Length > 0) {
                        timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Victim.ClanTag), victimColour, false));
                    }
                    timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Victim.SoldierName, victimColour, true));

                    flMouseOffsetX = flOffsetXs;
                }
            }

            if (timeList.Strings.Count > 0) {

                RectangleF recText = timeList.GetBounds();

                PointF timeListOffset = new PointF(pntDrawOffset.X + flMouseOffsetX - recText.Width / 2.0F, pntDrawOffset.Y - recText.Height);

                if (timeListOffset.X + recText.Width > g.ClipBounds.Width) {
                    timeListOffset.X = g.ClipBounds.Width - recText.Width;
                }

                timeList.Draw(g, timeListOffset, pntMouseLocation, mbButtons);
            }

            base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);

            this.m_mtsSeek.ButtonOpacity = this.TimelineOpacity;
            this.m_mtsSeek.SeekerBounds = recBounds;
            this.m_mtsSeek.Draw(g, new PointF(pntDrawOffset.X, pntDrawOffset.Y + 13.0F), pntMouseLocation, mbButtons);

            timeList.Dispose();
        }
Exemplo n.º 4
0
        // MapObject is only used in this class as a reference point, nothing in it is really used per se.
        public void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons, Kill kMouseOveredKill, KillDisplayDetails kddDisplayDetails, Image imgDamageType, string strLocalizedDamageType, KillDisplayColours colours, Dictionary <int, Color> teamColours)
        {
            //string killerName = kMouseOveredKill.Killer.ClanTag.Length > 0 ? String.Format("[{0}] {1}", kMouseOveredKill.Killer.ClanTag, kMouseOveredKill.Killer.SoldierName) : kMouseOveredKill.Killer.SoldierName;
            //string victimName = kMouseOveredKill.Victim.ClanTag.Length > 0 ? String.Format("[{0}] {1}", kMouseOveredKill.Victim.ClanTag, kMouseOveredKill.Victim.SoldierName) : kMouseOveredKill.Victim.SoldierName;

            GraphicsPath gpBackground = new GraphicsPath();
            RectangleF   recBackground;

            MapTextBlock textBlock = new MapTextBlock();

            Color killerColour = Color.White;
            Color victimColour = Color.White;

            if (colours == KillDisplayColours.EnemyColours)
            {
                killerColour = ControlPaint.LightLight(Color.SeaGreen);
                victimColour = ControlPaint.LightLight(Color.Red);
            }
            else if (colours == KillDisplayColours.TeamColours)
            {
                if (teamColours.ContainsKey(kMouseOveredKill.Killer.TeamID) == true && teamColours.ContainsKey(kMouseOveredKill.Victim.TeamID) == true)
                {
                    killerColour = ControlPaint.LightLight(teamColours[kMouseOveredKill.Killer.TeamID]);
                    victimColour = ControlPaint.LightLight(teamColours[kMouseOveredKill.Victim.TeamID]);
                }
            }

            if (kMouseOveredKill.Killer.ClanTag.Length > 0)
            {
                textBlock.Strings.Add(new MapTextBlockString(String.Format("Killer: [{0}] ", kMouseOveredKill.Killer.ClanTag), Color.WhiteSmoke, false));
            }
            else
            {
                textBlock.Strings.Add(new MapTextBlockString("Killer: ", Color.WhiteSmoke, false));
            }
            textBlock.Strings.Add(new MapTextBlockString(kMouseOveredKill.Killer.SoldierName, killerColour, true));

            if (kMouseOveredKill.Victim.ClanTag.Length > 0)
            {
                textBlock.Strings.Add(new MapTextBlockString(String.Format("Victim: [{0}] ", kMouseOveredKill.Victim.ClanTag), Color.WhiteSmoke, false));
            }
            else
            {
                textBlock.Strings.Add(new MapTextBlockString("Victim: ", Color.WhiteSmoke, false));
            }
            textBlock.Strings.Add(new MapTextBlockString(kMouseOveredKill.Victim.SoldierName, victimColour, true));

            textBlock.Strings.Add(new MapTextBlockString(String.Format("Weapon: {0}", strLocalizedDamageType), Color.WhiteSmoke, true));
            textBlock.Strings.Add(new MapTextBlockString(String.Format("Distance: {0:0.0} m, {1:0.0} yd", kMouseOveredKill.Distance, kMouseOveredKill.Distance * 1.0936133D), Color.WhiteSmoke, true));

            if (kMouseOveredKill.Headshot == true)
            {
                textBlock.Strings.Add(new MapTextBlockString("... HEADSHOT ...", killerColour, true));
            }

            RectangleF recTextSize = textBlock.GetBounds();

            if (imgDamageType != null)
            {
                recBackground = new RectangleF(new PointF(pntDrawOffset.X, pntDrawOffset.Y - (imgDamageType.Height + recTextSize.Height)), new SizeF(Math.Max(imgDamageType.Width, recTextSize.Width) + 10.0F, imgDamageType.Height + recTextSize.Height));
                gpBackground.AddRectangle(recBackground);

                // DRAWBLOCK: new PointF(recBackground.X + 10.0F, recBackground.Y + imgDamageType.Height)

                //gpKillPopupText.AddString(strText, new FontFamily("Arial"), 0, 12, new PointF(recBackground.X + 10.0F, recBackground.Y + imgDamageType.Height), StringFormat.GenericTypographic);
                //this.DrawText(g, strText, new Point(pntMouseLocation.X + 10, pntMouseLocation.Y - 100 + imgDamageType.Height), 12, 1.0F);
            }
            else
            {
                recBackground = new RectangleF(new PointF(pntDrawOffset.X, pntDrawOffset.Y - recTextSize.Height), new SizeF(recTextSize.Width + 10.0F, recTextSize.Height));

                gpBackground.AddRectangle(recBackground);

                // DRAW BLOCK : new PointF(recBackground.X + 10.0F, recBackground.Y + 1.0F)

                //gpKillPopupText.AddString(strText, new FontFamily("Arial"), 0, 12, new PointF(recBackground.X + 10.0F, recBackground.Y + 1.0F), StringFormat.GenericTypographic);
                //this.DrawText(g, strText, new Point(pntMouseLocation.X + 10, pntMouseLocation.Y - 100), 12, 1.0F);
            }

            // Give it a little bit of a border.

            if (pntDrawOffset.X + recBackground.Width > g.ClipBounds.Width)
            {
                this.m_pntDrawOffset.X = -1 * ((pntDrawOffset.X + recBackground.Width) - g.ClipBounds.Width);
            }

            if (pntDrawOffset.Y - recBackground.Height < 0)
            {
                this.m_pntDrawOffset.Y = -1 * (pntDrawOffset.Y - recBackground.Height);
            }

            this.DrawBwShape(g, gpBackground, 0.8F, 4.0F, Color.Black, Color.White);
            //this.DrawBwShape(g, gpKillPopupText, 1.0F, 4.0F, Color.Black, Color.White);
            textBlock.Draw(g, new PointF(this.m_pntDrawOffset.X + recBackground.X + 5.0F, this.m_pntDrawOffset.Y + recBackground.Y + 10.0F + (imgDamageType != null ? imgDamageType.Height : 0)), pntMouseLocation, mbButtons);
            //textBlock.Draw(g, new PointF(pntDrawOffset.X + 5.0F, pntDrawOffset.Y - recTextSize.Height + 10.0F), pntMouseLocation, mbButtons);

            if (imgDamageType != null)
            {
                g.DrawImage(imgDamageType, new RectangleF((recBackground.X + recBackground.Width / 2) - imgDamageType.Width / 2 + this.m_pntDrawOffset.X, recBackground.Y + this.m_pntDrawOffset.Y + 5.0F, imgDamageType.Width, imgDamageType.Height));
            }

            textBlock.Dispose();
            gpBackground.Dispose();

            /*
             *
             * string strText = String.Format("Killer: {0}\nVictim: {1}\nWeapon: {2}\nDistance: {3:0.0} m, {4:0.0} yd", killerName, victimName, strLocalizedDamageType, kMouseOveredKill.Distance, kMouseOveredKill.Distance * 1.0936133D);
             * SizeF szTextSize = g.MeasureString(strText, new Font("Arial", 10));
             *
             * GraphicsPath gpBackground = new GraphicsPath();
             * GraphicsPath gpKillPopupText = new GraphicsPath();
             * RectangleF recBackground;
             *
             * if (imgDamageType != null) {
             *  recBackground = new RectangleF(new PointF(pntDrawOffset.X, pntDrawOffset.Y - (imgDamageType.Height + szTextSize.Height)), new SizeF(Math.Max(imgDamageType.Width, szTextSize.Width), imgDamageType.Height + szTextSize.Height));
             *  gpBackground.AddRectangle(recBackground);
             *
             *  gpKillPopupText.AddString(strText, new FontFamily("Arial"), 0, 12, new PointF(recBackground.X + 10.0F, recBackground.Y + imgDamageType.Height), StringFormat.GenericTypographic);
             *  //this.DrawText(g, strText, new Point(pntMouseLocation.X + 10, pntMouseLocation.Y - 100 + imgDamageType.Height), 12, 1.0F);
             * }
             * else {
             *  recBackground = new RectangleF(new PointF(pntDrawOffset.X, pntDrawOffset.Y - szTextSize.Height), new SizeF(szTextSize.Width, szTextSize.Height));
             *
             *  gpBackground.AddRectangle(recBackground);
             *
             *  gpKillPopupText.AddString(strText, new FontFamily("Arial"), 0, 12, new PointF(recBackground.X + 10.0F, recBackground.Y + 1.0F), StringFormat.GenericTypographic);
             *  //this.DrawText(g, strText, new Point(pntMouseLocation.X + 10, pntMouseLocation.Y - 100), 12, 1.0F);
             * }
             *
             * //gpBackground.Widen(this.m_pOneWidth);
             * //gpKillPopupText.Widen(this.m_pOneWidth);
             *
             * if (pntDrawOffset.X + recBackground.Width > g.ClipBounds.Width) {
             *  this.m_pntDrawOffset.X = -1 * ((pntDrawOffset.X + recBackground.Width) - g.ClipBounds.Width);
             * }
             *
             * if (pntDrawOffset.Y - recBackground.Height < 0) {
             *  this.m_pntDrawOffset.Y = -1 * (pntDrawOffset.Y - recBackground.Height);
             * }
             *
             * this.DrawBwShape(g, gpBackground, 0.8F, 4.0F, Color.Black, Color.White);
             * this.DrawBwShape(g, gpKillPopupText, 1.0F, 4.0F, Color.Black, Color.White);
             *
             * if (imgDamageType != null) {
             *  g.DrawImage(imgDamageType, new PointF((recBackground.X + recBackground.Width / 2) - imgDamageType.Width / 2 + this.m_pntDrawOffset.X, recBackground.Y + this.m_pntDrawOffset.Y));
             * }
             *
             * gpBackground.Dispose();
             * gpKillPopupText.Dispose();
             */
        }
Exemplo n.º 5
0
        public void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons, Dictionary <Kill, KillDisplayDetails> dicKills, List <BattlemapRoundChange> lstRounds, KillDisplayColours colours, Dictionary <int, Color> teamColours)
        {
            GraphicsPath gpTimelineOutline = new GraphicsPath();

            gpTimelineOutline.AddLines(new Point[] { new Point(5, 0), new Point(0, 5), new Point(0, 15), new Point((int)g.ClipBounds.Width - 280, 15), new Point((int)g.ClipBounds.Width - 280, 5), new Point((int)g.ClipBounds.Width - 275, 0) });
            //gpTimelineOutline.AddLine(new Point(this.m_mtsSeek.SeekerPosition, 15), new Point((int)g.ClipBounds.Width - 280, 15));
            //gpTimelineOutline.AddLines(new Point[] { new Point(235, (int)g.ClipBounds.Height - 55), new Point(230, (int)g.ClipBounds.Height - 50), new Point(230, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 50), new Point((int)g.ClipBounds.Width - 45, (int)g.ClipBounds.Height - 55) });
            gpTimelineOutline.Widen(this.m_pOneWidth);

            this.ObjectPath = gpTimelineOutline;
            RectangleF recBounds = gpTimelineOutline.GetBounds();

            recBounds.Height += 50.0F;
            this.HotSpot      = recBounds;

            //string strMouseOverKillList = String.Empty;
            float flMouseOffsetX = 0.0F;

            bool blRoundChanged = false;

            MapTextBlock timeList = new MapTextBlock();

            foreach (BattlemapRoundChange RoundChange in new List <BattlemapRoundChange>(lstRounds))
            {
                float      flOffsetXs        = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - RoundChange.ChangeTime.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
                RectangleF recChangePosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);

                if (flOffsetXs >= 0.0F)
                {
                    GraphicsPath gpChangeTime = new GraphicsPath();
                    gpChangeTime.AddLine(new PointF(flOffsetXs, 5), new PointF(flOffsetXs, 12));
                    gpChangeTime.Widen(this.m_pOneWidth);

                    this.DrawBwShape(g, gpChangeTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
                    gpChangeTime.Dispose();

                    if (recChangePosition.Contains(new PointF(pntMouseLocation.X, pntMouseLocation.Y)) == true)
                    {
                        //strMouseOverKillList += String.Format("Round change {0}\r\n", RoundChange.Map.PublicLevelName);

                        timeList.Strings.Add(new MapTextBlockString(String.Format("Round change {0}", RoundChange.Map.PublicLevelName), Color.Pink, true));

                        blRoundChanged = true;
                        flMouseOffsetX = flOffsetXs;
                        //flMouseOffsetX = flOffsetXs;
                    }
                }
            }

            foreach (KeyValuePair <Kill, KillDisplayDetails> kvpKill in new Dictionary <Kill, KillDisplayDetails>(dicKills))
            {
                float      flOffsetXs      = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - kvpKill.Key.TimeOfDeath.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
                RectangleF recKillPosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);

                if (recKillPosition.Contains(new PointF(pntMouseLocation.X + 5.0F, pntMouseLocation.Y)) == true)
                {
                    GraphicsPath gpKillTime = new GraphicsPath();
                    gpKillTime.AddLine(new PointF(flOffsetXs, 10), new PointF(flOffsetXs, 12));
                    gpKillTime.Widen(this.m_pOneWidth);

                    this.DrawBwShape(g, gpKillTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
                    gpKillTime.Dispose();

                    Color killerColour = Color.White;
                    Color victimColour = Color.White;

                    if (colours == KillDisplayColours.EnemyColours)
                    {
                        killerColour = ControlPaint.Light(Color.SeaGreen);
                        victimColour = ControlPaint.LightLight(Color.Black);
                    }
                    else if (colours == KillDisplayColours.TeamColours)
                    {
                        if (teamColours.ContainsKey(kvpKill.Key.Killer.TeamID) == true && teamColours.ContainsKey(kvpKill.Key.Victim.TeamID) == true)
                        {
                            killerColour = ControlPaint.Light(teamColours[kvpKill.Key.Killer.TeamID]);
                            victimColour = ControlPaint.Light(teamColours[kvpKill.Key.Victim.TeamID]);
                        }
                    }

                    if (kvpKill.Key.Killer.ClanTag.Length > 0)
                    {
                        timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Killer.ClanTag), killerColour, false));
                    }

                    timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Killer.SoldierName, killerColour, false));

                    timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.DamageType), Color.WhiteSmoke, false));

                    if (kvpKill.Key.Victim.ClanTag.Length > 0)
                    {
                        timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Victim.ClanTag), victimColour, false));
                    }
                    timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Victim.SoldierName, victimColour, true));

                    flMouseOffsetX = flOffsetXs;
                }
            }

            if (timeList.Strings.Count > 0)
            {
                RectangleF recText = timeList.GetBounds();

                PointF timeListOffset = new PointF(pntDrawOffset.X + flMouseOffsetX - recText.Width / 2.0F, pntDrawOffset.Y - recText.Height);

                if (timeListOffset.X + recText.Width > g.ClipBounds.Width)
                {
                    timeListOffset.X = g.ClipBounds.Width - recText.Width;
                }

                timeList.Draw(g, timeListOffset, pntMouseLocation, mbButtons);
            }

            base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);

            this.m_mtsSeek.ButtonOpacity = this.TimelineOpacity;
            this.m_mtsSeek.SeekerBounds  = recBounds;
            this.m_mtsSeek.Draw(g, new PointF(pntDrawOffset.X, pntDrawOffset.Y + 13.0F), pntMouseLocation, mbButtons);

            timeList.Dispose();
        }
Exemplo n.º 6
0
        // MapObject is only used in this class as a reference point, nothing in it is really used per se.
        public void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons, Kill kMouseOveredKill, KillDisplayDetails kddDisplayDetails, Image imgDamageType, string strLocalizedDamageType, KillDisplayColours colours, Dictionary<int, Color> teamColours)
        {
            //string killerName = kMouseOveredKill.Killer.ClanTag.Length > 0 ? String.Format("[{0}] {1}", kMouseOveredKill.Killer.ClanTag, kMouseOveredKill.Killer.SoldierName) : kMouseOveredKill.Killer.SoldierName;
            //string victimName = kMouseOveredKill.Victim.ClanTag.Length > 0 ? String.Format("[{0}] {1}", kMouseOveredKill.Victim.ClanTag, kMouseOveredKill.Victim.SoldierName) : kMouseOveredKill.Victim.SoldierName;

            GraphicsPath gpBackground = new GraphicsPath();
            RectangleF recBackground;

            MapTextBlock textBlock = new MapTextBlock();

            Color killerColour = Color.White;
            Color victimColour = Color.White;

            if (colours == KillDisplayColours.EnemyColours) {
                killerColour = ControlPaint.LightLight(Color.SeaGreen);
                victimColour = ControlPaint.LightLight(Color.Red);
            }
            else if (colours == KillDisplayColours.TeamColours) {
                if (teamColours.ContainsKey(kMouseOveredKill.Killer.TeamID) == true && teamColours.ContainsKey(kMouseOveredKill.Victim.TeamID) == true) {

                    killerColour = ControlPaint.LightLight(teamColours[kMouseOveredKill.Killer.TeamID]);
                    victimColour = ControlPaint.LightLight(teamColours[kMouseOveredKill.Victim.TeamID]);
                }
            }

            if (kMouseOveredKill.Killer.ClanTag.Length > 0) {
                textBlock.Strings.Add(new MapTextBlockString(String.Format("Killer: [{0}] ", kMouseOveredKill.Killer.ClanTag), Color.WhiteSmoke, false));
            }
            else {
                textBlock.Strings.Add(new MapTextBlockString("Killer: ", Color.WhiteSmoke, false));
            }
            textBlock.Strings.Add(new MapTextBlockString(kMouseOveredKill.Killer.SoldierName, killerColour, true));

            if (kMouseOveredKill.Victim.ClanTag.Length > 0) {
                textBlock.Strings.Add(new MapTextBlockString(String.Format("Victim: [{0}] ", kMouseOveredKill.Victim.ClanTag), Color.WhiteSmoke, false));
            }
            else {
                textBlock.Strings.Add(new MapTextBlockString("Victim: ", Color.WhiteSmoke, false));
            }
            textBlock.Strings.Add(new MapTextBlockString(kMouseOveredKill.Victim.SoldierName, victimColour, true));

            textBlock.Strings.Add(new MapTextBlockString(String.Format("Weapon: {0}", strLocalizedDamageType), Color.WhiteSmoke, true));
            textBlock.Strings.Add(new MapTextBlockString(String.Format("Distance: {0:0.0} m, {1:0.0} yd", kMouseOveredKill.Distance, kMouseOveredKill.Distance * 1.0936133D), Color.WhiteSmoke, true));

            if (kMouseOveredKill.Headshot == true)
            {
                textBlock.Strings.Add(new MapTextBlockString("... HEADSHOT ...", killerColour, true));
            }

            RectangleF recTextSize = textBlock.GetBounds();

            if (imgDamageType != null) {
                recBackground = new RectangleF(new PointF(pntDrawOffset.X, pntDrawOffset.Y - (imgDamageType.Height + recTextSize.Height)), new SizeF(Math.Max(imgDamageType.Width, recTextSize.Width) + 10.0F, imgDamageType.Height + recTextSize.Height));
                gpBackground.AddRectangle(recBackground);

                // DRAWBLOCK: new PointF(recBackground.X + 10.0F, recBackground.Y + imgDamageType.Height)

                //gpKillPopupText.AddString(strText, new FontFamily("Arial"), 0, 12, new PointF(recBackground.X + 10.0F, recBackground.Y + imgDamageType.Height), StringFormat.GenericTypographic);
                //this.DrawText(g, strText, new Point(pntMouseLocation.X + 10, pntMouseLocation.Y - 100 + imgDamageType.Height), 12, 1.0F);
            }
            else {
                recBackground = new RectangleF(new PointF(pntDrawOffset.X, pntDrawOffset.Y - recTextSize.Height), new SizeF(recTextSize.Width + 10.0F, recTextSize.Height));

                gpBackground.AddRectangle(recBackground);

                // DRAW BLOCK : new PointF(recBackground.X + 10.0F, recBackground.Y + 1.0F)

                //gpKillPopupText.AddString(strText, new FontFamily("Arial"), 0, 12, new PointF(recBackground.X + 10.0F, recBackground.Y + 1.0F), StringFormat.GenericTypographic);
                //this.DrawText(g, strText, new Point(pntMouseLocation.X + 10, pntMouseLocation.Y - 100), 12, 1.0F);
            }

            // Give it a little bit of a border.

            if (pntDrawOffset.X + recBackground.Width > g.ClipBounds.Width) {
                this.m_pntDrawOffset.X = -1 * ((pntDrawOffset.X + recBackground.Width) - g.ClipBounds.Width);
            }

            if (pntDrawOffset.Y - recBackground.Height < 0) {
                this.m_pntDrawOffset.Y = -1 * (pntDrawOffset.Y - recBackground.Height);
            }

            this.DrawBwShape(g, gpBackground, 0.8F, 4.0F, Color.Black, Color.White);
            //this.DrawBwShape(g, gpKillPopupText, 1.0F, 4.0F, Color.Black, Color.White);
            textBlock.Draw(g, new PointF(this.m_pntDrawOffset.X + recBackground.X + 5.0F, this.m_pntDrawOffset.Y + recBackground.Y + 10.0F + (imgDamageType != null ? imgDamageType.Height : 0)), pntMouseLocation, mbButtons);
            //textBlock.Draw(g, new PointF(pntDrawOffset.X + 5.0F, pntDrawOffset.Y - recTextSize.Height + 10.0F), pntMouseLocation, mbButtons);

            if (imgDamageType != null) {

                g.DrawImage(imgDamageType, new RectangleF((recBackground.X + recBackground.Width / 2) - imgDamageType.Width / 2 + this.m_pntDrawOffset.X, recBackground.Y + this.m_pntDrawOffset.Y + 5.0F, imgDamageType.Width, imgDamageType.Height));
            }

            textBlock.Dispose();
            gpBackground.Dispose();

            /*

            string strText = String.Format("Killer: {0}\nVictim: {1}\nWeapon: {2}\nDistance: {3:0.0} m, {4:0.0} yd", killerName, victimName, strLocalizedDamageType, kMouseOveredKill.Distance, kMouseOveredKill.Distance * 1.0936133D);
            SizeF szTextSize = g.MeasureString(strText, new Font("Arial", 10));

            GraphicsPath gpBackground = new GraphicsPath();
            GraphicsPath gpKillPopupText = new GraphicsPath();
            RectangleF recBackground;

            if (imgDamageType != null) {
                recBackground = new RectangleF(new PointF(pntDrawOffset.X, pntDrawOffset.Y - (imgDamageType.Height + szTextSize.Height)), new SizeF(Math.Max(imgDamageType.Width, szTextSize.Width), imgDamageType.Height + szTextSize.Height));
                gpBackground.AddRectangle(recBackground);

                gpKillPopupText.AddString(strText, new FontFamily("Arial"), 0, 12, new PointF(recBackground.X + 10.0F, recBackground.Y + imgDamageType.Height), StringFormat.GenericTypographic);
                //this.DrawText(g, strText, new Point(pntMouseLocation.X + 10, pntMouseLocation.Y - 100 + imgDamageType.Height), 12, 1.0F);
            }
            else {
                recBackground = new RectangleF(new PointF(pntDrawOffset.X, pntDrawOffset.Y - szTextSize.Height), new SizeF(szTextSize.Width, szTextSize.Height));

                gpBackground.AddRectangle(recBackground);

                gpKillPopupText.AddString(strText, new FontFamily("Arial"), 0, 12, new PointF(recBackground.X + 10.0F, recBackground.Y + 1.0F), StringFormat.GenericTypographic);
                //this.DrawText(g, strText, new Point(pntMouseLocation.X + 10, pntMouseLocation.Y - 100), 12, 1.0F);
            }

            //gpBackground.Widen(this.m_pOneWidth);
            //gpKillPopupText.Widen(this.m_pOneWidth);

            if (pntDrawOffset.X + recBackground.Width > g.ClipBounds.Width) {
                this.m_pntDrawOffset.X = -1 * ((pntDrawOffset.X + recBackground.Width) - g.ClipBounds.Width);
            }

            if (pntDrawOffset.Y - recBackground.Height < 0) {
                this.m_pntDrawOffset.Y = -1 * (pntDrawOffset.Y - recBackground.Height);
            }

            this.DrawBwShape(g, gpBackground, 0.8F, 4.0F, Color.Black, Color.White);
            this.DrawBwShape(g, gpKillPopupText, 1.0F, 4.0F, Color.Black, Color.White);

            if (imgDamageType != null) {
                g.DrawImage(imgDamageType, new PointF((recBackground.X + recBackground.Width / 2) - imgDamageType.Width / 2 + this.m_pntDrawOffset.X, recBackground.Y + this.m_pntDrawOffset.Y));
            }

            gpBackground.Dispose();
            gpKillPopupText.Dispose();
            */
        }