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; }
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; }
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); }
public MethodEnumeration Wrap(WrapMethod before) { foreach (Amendment.Method method in this) { method.BeforeMethod = before.Method; } return(this); }
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); }
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); }
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]); } }
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); }
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); } } } } }