Пример #1
0
        internal static void DrawChatBubble(int index)
        {
            List <string> theArray = default(List <string>);
            int           x        = 0;
            int           y        = 0;
            int           i        = 0;
            int           maxWidth = 0;
            int           x2       = 0;
            int           y2       = 0;

            if (C_Variables.ChatBubble[index].TargetType == (byte)Enums.TargetType.Player)
            {
                // it's a player
                if (C_Player.GetPlayerMap((C_Variables.ChatBubble[index].Target)) == C_Player.GetPlayerMap(C_Variables.Myindex))
                {
                    // it's on our map - get co-ords
                    x = C_Graphics.ConvertMapX((C_Types.Player[C_Variables.ChatBubble[index].Target].X * 32) + C_Types.Player[C_Variables.ChatBubble[index].Target].XOffset) + 16;
                    y = C_Graphics.ConvertMapY((C_Types.Player[C_Variables.ChatBubble[index].Target].Y * 32) + C_Types.Player[C_Variables.ChatBubble[index].Target].YOffset) - 40;
                }
            }
            else if (C_Variables.ChatBubble[index].TargetType == (byte)Enums.TargetType.Npc)
            {
                // it's on our map - get co-ords
                x = C_Graphics.ConvertMapX((C_Maps.MapNpc[C_Variables.ChatBubble[index].Target].X * 32) + C_Maps.MapNpc[C_Variables.ChatBubble[index].Target].XOffset) + 16;
                y = C_Graphics.ConvertMapY((C_Maps.MapNpc[C_Variables.ChatBubble[index].Target].Y * 32) + C_Maps.MapNpc[C_Variables.ChatBubble[index].Target].YOffset) - 40;
            }
            else if (C_Variables.ChatBubble[index].TargetType == (byte)Enums.TargetType.Event)
            {
                x = C_Graphics.ConvertMapX((C_Maps.Map.MapEvents[C_Variables.ChatBubble[index].Target].X * 32) + C_Maps.Map.MapEvents[C_Variables.ChatBubble[index].Target].XOffset) + 16;
                y = C_Graphics.ConvertMapY((C_Maps.Map.MapEvents[C_Variables.ChatBubble[index].Target].Y * 32) + C_Maps.Map.MapEvents[C_Variables.ChatBubble[index].Target].YOffset) - 40;
            }
            // word wrap the text
            theArray = WordWrap(System.Convert.ToString(C_Variables.ChatBubble[index].Msg), C_Constants.ChatBubbleWidth, WrapMode.Font, WrapType.Smart, 13);
            // find max width
            for (i = 0; i <= theArray.Count - 1; i++)
            {
                if (GetTextWidth(theArray[i]) > maxWidth)
                {
                    maxWidth = GetTextWidth(theArray[i]);
                }
            }
            // calculate the new position
            x2 = x - (maxWidth / 2);
            y2 = y - (theArray.Count * 12);

            // render bubble - top left
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 - 9, y2 - 5, 0, 0, 9, 5, 9, 5);
            // top right
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 + maxWidth, y2 - 5, 119, 0, 9, 5, 9, 5);
            // top
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2, y2 - 5, 10, 0, maxWidth, 5, 5, 5);
            // bottom left
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 - 9, y, 0, 19, 9, 6, 9, 6);
            // bottom right
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 + maxWidth, y, 119, 19, 9, 6, 9, 6);
            // bottom - left half
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2, y, 10, 19, System.Convert.ToSingle((maxWidth / 2) - 5), 6, 9, 6);
            // bottom - right half
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 + (maxWidth / 2) + 6, y, 10, 19, System.Convert.ToSingle((maxWidth / 2) - 5), 6, 9, 6);
            // left
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 - 9, y2, 0, 6, 9, theArray.Count * 12, 9, 1);
            // right
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2 + maxWidth, y2, 119, 6, 9, theArray.Count * 12, 9, 1);
            // center
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x2, y2, 9, 5, maxWidth, theArray.Count * 12, 1, 1);
            // little pointy bit
            C_Graphics.RenderTextures(C_Graphics.ChatBubbleGfx, C_Graphics.GameWindow, x - 5, y, 58, 19, 11, 11, 11, 11);

            // render each line centralised
            for (i = 0; i <= theArray.Count - 1; i++)
            {
                DrawText((int)(x - ((double)GetTextWidth(theArray[i]) / 2)), y2, theArray[i], C_Graphics.ToSfmlColor(System.Drawing.ColorTranslator.FromOle(Information.QBColor((int)(C_Variables.ChatBubble[index].Colour)))), Color.Black, C_Graphics.GameWindow);
                y2 = y2 + 12;
            }
            // check if it's timed out - close it if so
            if (C_Variables.ChatBubble[index].Timer + 5000 < C_General.GetTickCount())
            {
                C_Variables.ChatBubble[index].Active = false;
            }
        }