예제 #1
0
        public static string[] GetWrappedText(string text, WrapMethod method)
        {
            List<string> lines;

            switch (method)
            {
                case WrapMethod.None:
                    lines = new List<string>(new string[] { text });
                    break;
                case WrapMethod.Default:
                    lines = GetDefaultText(text);
                    break;
                case WrapMethod.Chat:
                    lines = GetChatText(text);
                    break;
                case WrapMethod.Spaced:
                    lines = GetSpacedText(text);
                    break;
                case WrapMethod.FixedSpace:
                    lines = GetFixedSpaceText(text);
                    break;
                default:
                    throw new ArgumentException( "Unknown wrapping method" );
            }

            string[] r = lines.ToArray();
            lines.Clear();
            lines = null;
            return r;
        }
예제 #2
0
        public void Resize(int width, int height)
        {
            WrapMethod originalWrapMethod = wrapMethod;

            if (wrapMethod == WrapMethod.Error)
            {
                wrapMethod = WrapMethod.Default;
            }

            int      newWidth  = width;
            int      newHeight = height;
            List <T> newArray  = new List <T>(width * height);

            for (int y = 0; y < height; ++y)
            {
                for (int x = 0; x < width; ++x)
                {
                    newArray.Add(Get(x, y));
                }
            }
            this.array  = newArray;
            this.width  = width;
            this.height = height;

            wrapMethod = originalWrapMethod;
        }
예제 #3
0
        public static string[] GetWrappedText(string text, WrapMethod method)
        {
            List <string> lines;

            switch (method)
            {
            case WrapMethod.None:
                lines = new List <string>(new string[] { text });
                break;

            case WrapMethod.Default:
                lines = GetDefaultText(text);
                break;

            case WrapMethod.Chat:
                lines = GetChatText(text);
                break;

            case WrapMethod.Spaced:
                lines = GetSpacedText(text);
                break;

            case WrapMethod.FixedSpace:
                lines = GetFixedSpaceText(text);
                break;

            default:
                throw new ArgumentException("Unknown wrapping method");
            }

            string[] r = lines.ToArray();
            lines.Clear();
            lines = null;
            return(r);
        }
예제 #4
0
 public MethodEnumeration Wrap(WrapMethod before)
 {
     foreach (Amendment.Method method in this)
     {
         method.BeforeMethod = before.Method;
     }
     return(this);
 }
예제 #5
0
        public LogicArray2(int width, int height, T defaultValue)
        {
            this.width        = width;
            this.height       = height;
            array             = new List <T>(width * height);
            wrapMethod        = WrapMethod.Error;
            this.defaultValue = defaultValue;

            Init(width, height);
        }
예제 #6
0
 public void SendMessage(string message, WrapMethod method, params object[] args)
 {
     if (method == WrapMethod.None)
         SendMessageInternal(string.Format(this.MessageAdditions(message), args));
     else
         SendMessage(string.Format(this.MessageAdditions(message), args), method);
 }
예제 #7
0
 public void SendMessage(string message, WrapMethod method)
 {
     string[] lines = WordWrap.GetWrappedText(this.MessageAdditions(message), method);
     for (int i = 0; i < lines.Length; i++)
     {
         SendMessageInternal(lines[i]);
     }
 }
예제 #8
0
 public static void GlobalMessage(string message, WrapMethod method, params object[] args)
 {
     if (method == WrapMethod.None)
         GlobalMessage(string.Format(message, args));
     else
         GlobalMessage(string.Format(message, args), method);
 }
예제 #9
0
        public static void GlobalMessage(string message, WrapMethod method)
        {
            string[] lines = WordWrap.GetWrappedText(message, method);
            for (int i = 0; i < lines.Length; i++)
            {
                //somebody check if this is right please :s
                //LooksGood to me ~Merlin33069
                byte[] bytes = new byte[(lines[i].Length * 2) + 2];
                util.EndianBitConverter.Big.GetBytes((ushort)lines[i].Length).CopyTo(bytes, 0);
                Encoding.BigEndianUnicode.GetBytes(lines[i]).CopyTo(bytes, 2);

                for (int j = 0; j < players.Count; j++)
                {
                    if (!players[j].disconnected)
                    {
                        if (!players[j].DoNotDisturb)
                        {
                            players[j].SendRaw((byte)KnownPackets.ChatMessage, bytes);
                        }
                    }
                }
            }
        }