} // @ internal static bool IsSet(UInt32 value, UInt32 bit) internal static bool IsSet(LineSettings value, LineSettings bit) { if (value == bit) { return(true); } return(((UInt32)value & (UInt32)bit) != 0); } // @ internal static bool IsSet(LineSettings value, LineSettings bit)
///<summary> /// Returns a class containing the dialog text ///</summary> public DialogText GetDialogText (LineSettings lineSettings) { if (DialogID == 0) return new DialogText(String.Empty); int size = 4096; byte[] buffer = new byte[size]; GetDialogStrings(_InstanceID, buffer, ref size); if (size <= 3) return new DialogText(String.Empty); return new DialogText(System.Text.Encoding.GetEncoding(1252).GetString(buffer, 0, size - 3).Trim(), lineSettings); }
internal void Update(Parameters parameters, ChartSettings settings, Quotes quotes) { if (m_grid.BackgroundColor != settings.BackgroundColor) { m_grid.BackgroundColor = settings.BackgroundColor; } Quote quote = quotes.Last.Quote; int count = (null == quote) ? 0 : settings.Lines.Count; Update(count); for (int index = 0; index < count; ++index) { LineSettings line = settings.Lines[index]; Color volumeColor = CalculateColor(line.BidColor, line.AskColor, settings.ForegroundColor); Update(settings, index, 0, (float)line.Volume, volumeColor); double volume = line.Volume * parameters.LotSize; float? bid = MathEx.CalculateWAVP(volume, quote.Bids); float? ask = MathEx.CalculateWAVP(volume, quote.Asks); if (bid.HasValue) { bid = (float)MathEx.RoundDown(bid.Value, parameters.PricePip); } if (ask.HasValue) { ask = (float)MathEx.RoundUp(ask.Value, parameters.PricePip); } Update(settings, index, 1, bid, line.BidColor); Update(settings, index, 2, ask, line.AskColor); float?spread = null; if (bid.HasValue && ask.HasValue) { spread = (float)Math.Round(parameters.PriceFactor * (ask.Value - bid.Value)); } Color spreadColor = CalculateColor(line.BidColor, line.AskColor, settings.ForegroundColor); Update(settings, index, 3, spread, spreadColor); } Size size = m_grid.PreferredSize; if (this.Size != size) { this.Size = size; } //if (!this.Visible) //{ // this.Visible = true; //} }
public void Draw(LineSettings currentSetting) { settings = currentSetting; if (!enabled || settings.paths.Length <= 0 || settings.paths.Any(t => t == null)) { return; } IReadOnlyList <Vector3> vecPaths = settings.paths.Select(t => t.position).ToList(); InitMaterial(); lineMaterial.SetPass(0); GL.PushMatrix(); { GL.Begin(GL.QUADS); { GL.Color(settings.color); if (_settings.Equals(settings) && _paths.SequenceEqual(vecPaths)) { Debug.Log("nonUpdated"); DotVertexes(currentPaths.ToArray()); } else { Debug.Log("Updated"); currentPaths.Clear(); _settings = settings; _paths = vecPaths; Vector3 v0, v1, o; relativeWidth = 1.0f / Screen.width * settings.width * 0.5f; for (int index = 0; index < _paths.Count - 1; index++) { v0 = _paths[index]; v1 = _paths[index + 1]; o = (new Vector3(v1.y, v0.x, 0.0f) - new Vector3(v0.y, v1.x, 0.0f)).normalized; DrawLine2D(v0, v1, o); DrawMark2D(v0, v1, o); } } } GL.End(); } GL.PopMatrix(); }
public DialogText(string RawText, LineSettings lineSettings) { _RawText = RawText; if (RawText == String.Empty) { _Question = String.Empty; _Options = new string[0]; } else { _Question = FFACE.ChatTools.CleanLine(RawText.Substring(0, RawText.IndexOf("\v") - 1), lineSettings); string buffer = RawText.Substring(RawText.IndexOf("\v") + 1); _Options = CleanLine(buffer.Split(new string[] { "\a" }, StringSplitOptions.RemoveEmptyEntries), lineSettings); } }
private string[] CleanLine(string[] lines, LineSettings lineSettings) { System.Collections.ArrayList ret = new System.Collections.ArrayList(); for (int i = 0; i < lines.Length; i++) { // CleanLine(lines[i]); string x = FFACE.ChatTools.CleanLine(lines[i], lineSettings); if (x == ".") { continue; } ret.Add(x); } string[] returnList = (string[])ret.ToArray(typeof(string)); return(returnList); }
private void Update(ChartSettings settings, int row, int column, float?value, Color color) { DataGridViewCell cell = m_grid.Rows[row].Cells[column]; if (settings.BackgroundColor != cell.Style.BackColor) { cell.Style.BackColor = settings.BackgroundColor; } LineSettings line = settings.Lines[row]; if (cell.Style.ForeColor != color) { cell.Style.ForeColor = color; } string st = cell.Value as string; string text = value.HasValue ? value.Value.ToString(CultureInfo.InvariantCulture) : cNA; if (st != text) { cell.Value = text; } }
public DialogText (string RawText, LineSettings lineSettings) { _RawText = RawText; if (RawText == String.Empty) { _Question = String.Empty; _Options = new string[0]; } else { _Question = FFACE.ChatTools.CleanLine(RawText.Substring(0, RawText.IndexOf("\v") - 1), lineSettings); string buffer = RawText.Substring(RawText.IndexOf("\v") + 1); _Options = CleanLine(buffer.Split(new string[] { "\a" }, StringSplitOptions.RemoveEmptyEntries), lineSettings); } }
private string[] CleanLine (string[] lines, LineSettings lineSettings) { System.Collections.ArrayList ret = new System.Collections.ArrayList(); for (int i = 0; i < lines.Length; i++) { // CleanLine(lines[i]); string x = FFACE.ChatTools.CleanLine(lines[i], lineSettings); if (x == ".") continue; ret.Add(x); } string[] returnList = (string[])ret.ToArray(typeof(string)); return returnList; }
public PenLine(LineSettings settings) { this.settings = settings; //this.settings is the Line Settings (on line 13) -> passingthe asset that we've created in DrawManager to the PenLine }
/// <summary> /// Will strip/convert requested items based on LineSettings passed. /// </summary> /// <param name="line">line to clean (left intact)</param> /// <param name="lineSettings">LineSettings to apply to the line for cleaning/converting.</param> /// <returns>string containing the modified line, original is left unharmed</returns> public static String CleanLine(String line, LineSettings lineSettings) { String cleanedString = line; // Duh. If we managed to get here, I'm not bothering. if (IsSet(lineSettings, LineSettings.RawText)) { return cleanedString; } if (IsSet(lineSettings, LineSettings.CleanTimeStamp)) { cleanedString = CleanTimeStamp(cleanedString); // if all we're doing is pulling the TimeStamp, just return. if (lineSettings == LineSettings.CleanTimeStamp) return cleanedString; } Byte[] bytearray1252 = System.Text.Encoding.GetEncoding(1252).GetBytes(cleanedString); Int32 i = 0, len = bytearray1252.Length; const String sEF = "\xFF\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\xFF"; // 1f 20 21 22 23 24 25 26 27 28 const String rep = "<FIAETWLD{}>"; // Turns out \x1E is the start code for color changes/resets in log/dialog text. //const String s1E = "\x01\x02\x03\xFC\xFD"; const String s1F = "\x0E\x0F\x2F\x7F\x79\x7B\x7C\x8D\x88\x8A\xA1\xD0"; //\r\n\x07 const String sExtra = "\r\n\x07\x7F\x81\x87"; List<Byte> cleaned = new List<Byte>(); Int32 ndx = -1; bool inItemCode = false; bool inKeyItemCode = false; bool inObjectCode = false; // Sanity checks for (Int32 c = 0; c < len; ++c) { if (( bytearray1252[c] == '\xEF' ) && ( ( ( c + 1 ) < len ) && ( ( ndx = sEF.IndexOf((Char)bytearray1252[c + 1]) ) >= 0 ) )) { // 3C < 3E > // 7B { 7D } bool isOpenBrace = ( sEF[ndx] == '\x27' ); bool isCloseBrace = ( sEF[ndx] == '\x28' ); bool isElementIcon = ( !isOpenBrace && !isCloseBrace ); if (!isCloseBrace) // Not closing brace? Needs starter char { if (( isOpenBrace && IsSet(lineSettings, LineSettings.ConvertATBrackets) ) || ( isElementIcon && IsSet(lineSettings, LineSettings.ConvertElementIcons) )) cleaned.Add((Byte)rep[0]); } if (( !isElementIcon && IsSet(lineSettings, LineSettings.ConvertATBrackets) ) || ( isElementIcon && IsSet(lineSettings, LineSettings.ConvertElementIcons) )) cleaned.Add((Byte)rep[ndx]); // add rep.char based on Index if (!isOpenBrace) // Not opening brace? Needs closer char { if (( isCloseBrace && IsSet(lineSettings, LineSettings.ConvertATBrackets) ) || ( isElementIcon && IsSet(lineSettings, LineSettings.ConvertElementIcons) )) cleaned.Add((Byte)rep[rep.Length - 1]); // > Final: <{ and }> for Auto-translate braces } if (IsSet(lineSettings, LineSettings.ConvertATBrackets | LineSettings.ConvertElementIcons | LineSettings.CleanElementIcons | LineSettings.CleanATBrackets)) ++c; else cleaned.Add(bytearray1252[c]); } else if (( bytearray1252[c] == '\x1F' ) && ( ( ( c + 1 ) < len ) && ( ( ndx = s1F.IndexOf((char)bytearray1252[c + 1]) ) >= 0 ) )) { if (IsSet(lineSettings, LineSettings.CleanOthers)) ++c; else cleaned.Add(bytearray1252[c]); } else if (( bytearray1252[c] == '\x1E' ) && ( ( ( c + 1 ) < len ) )) { byte nextByte = bytearray1252[c + 1]; if (( nextByte == '\x03' ) && IsSet(lineSettings, LineSettings.ConvertKIBytes | LineSettings.CleanKIBytes)) { if (IsSet(lineSettings, LineSettings.ConvertKIBytes)) { cleaned.Add((Byte)'['); inKeyItemCode = true; } ++c; } else if (( nextByte == '\x02' ) && IsSet(lineSettings, LineSettings.ConvertItemBytes | LineSettings.CleanItemBytes)) { if (IsSet(lineSettings, LineSettings.ConvertItemBytes)) { cleaned.Add((Byte)'{'); inItemCode = true; } ++c; } else if (( nextByte == '\x05' ) && IsSet(lineSettings, LineSettings.ConvertObjectBytes | LineSettings.CleanObjectBytes)) { if (IsSet(lineSettings, LineSettings.ConvertObjectBytes)) { cleaned.Add((Byte)'('); inObjectCode = true; } ++c; } else if (inItemCode && ( nextByte == '\x01' ) && IsSet(lineSettings, LineSettings.ConvertItemBytes | LineSettings.CleanItemBytes)) { if (IsSet(lineSettings, LineSettings.ConvertItemBytes)) { cleaned.Add((Byte)'}'); inItemCode = false; } ++c; } else if (inKeyItemCode && ( nextByte == '\x01' ) && IsSet(lineSettings, LineSettings.ConvertKIBytes | LineSettings.CleanKIBytes)) { if (IsSet(lineSettings, LineSettings.ConvertKIBytes)) { cleaned.Add((Byte)']'); inKeyItemCode = false; } ++c; } else if (inObjectCode && ( nextByte == '\x01' ) && IsSet(lineSettings, LineSettings.ConvertObjectBytes | LineSettings.CleanObjectBytes)) { if (IsSet(lineSettings, LineSettings.ConvertObjectBytes)) { cleaned.Add((Byte)')'); inObjectCode = false; } ++c; } else if (IsSet(lineSettings, LineSettings.CleanOthers)) { ++c; } else { cleaned.Add(bytearray1252[c]); } } else { i = sExtra.IndexOf((char)bytearray1252[c]); if (i >= 3) // \r\n\07 are singles, others are doubles { if (( ( bytearray1252[c] == '\x7F' ) && ( ( ( c + 1 ) < len ) && bytearray1252[c + 1] == '\x31' ) ) || ( ( bytearray1252[c] == '\x81' ) && ( ( ( c + 1 ) < len ) && bytearray1252[c + 1] == '\xA1' ) ) || ( ( bytearray1252[c] == '\x81' ) && ( ( ( c + 1 ) < len ) && bytearray1252[c + 1] == '\x40' ) ) || ( ( bytearray1252[c] == '\x87' ) && ( ( ( c + 1 ) < len ) && bytearray1252[c + 1] == '\xB2' ) ) || ( ( bytearray1252[c] == '\x87' ) && ( ( ( c + 1 ) < len ) && bytearray1252[c + 1] == '\xB3' ) )) { if (IsSet(lineSettings, LineSettings.CleanOthers)) ++c; else i = -1; } else { i = -1; // not a target, so "wasn't found" } } else if (i != -1) { // Target character at this point is either a \r\n or \x07 if (( sExtra[i] == '\r' ) || ( sExtra[i] == '\n' )) { // ++c; for Double-Byte combinations, this is not one. // if we are NOT doing CleanNewLine // then say we didn't find it. if (!IsSet(lineSettings, LineSettings.CleanNewLine)) i = -1; } else if (!IsSet(lineSettings, LineSettings.CleanOthers)) { // At this point, it's a \x07 // if we are NOT doing CleanOthers // then say we didn't find it. i = -1; // ++c; for Double-Byte combinations, \x07 is not one } } // If the byte was not in a previous if/else, // and we didn't find it in our "exceptions" // then add it to the list. if (( i < 0 ) && ( bytearray1252[c] != '\0' )) { cleaned.Add(bytearray1252[c]); } } } // got to end and didn't close an item/keyitem/object code? if (inKeyItemCode && IsSet(lineSettings, LineSettings.ConvertKIBytes)) { cleaned.Add((Byte)']'); } else if (inObjectCode && IsSet(lineSettings, LineSettings.ConvertObjectBytes)) { cleaned.Add((Byte)')'); } else if (inItemCode && IsSet(lineSettings, LineSettings.ConvertItemBytes)) { cleaned.Add((Byte)'}'); } cleaned.Add(0); #region The above code done with all line.Replace() instead. /* if (cleanedString.IndexOf('\xEF') >= 0) { cleanedString = cleanedString.Replace("\xEF\x1F", ""); // Fire cleanedString = cleanedString.Replace("\xEF\x20", ""); // Ice cleanedString = cleanedString.Replace("\xEF\x21", ""); // Wind (Air) cleanedString = cleanedString.Replace("\xEF\x22", ""); // Earth cleanedString = cleanedString.Replace("\xEF\x23", ""); // Lightning (Thunder) cleanedString = cleanedString.Replace("\xEF\x24", ""); // Water cleanedString = cleanedString.Replace("\xEF\x25", ""); // Light cleanedString = cleanedString.Replace("\xEF\x26", ""); // Darkness cleanedString = cleanedString.Replace("\xEF\x27", ""); // Opening Brace cleanedString = cleanedString.Replace("\xEF\x28", ""); // Closing Brace } if (cleanedString.IndexOf('\x1E') >= 0) { cleanedString = cleanedString.Replace("\x1E\x01", ""); cleanedString = cleanedString.Replace("\x1E\x02", ""); cleanedString = cleanedString.Replace("\x1E\x03", ""); cleanedString = cleanedString.Replace("\x1E\xFC", ""); cleanedString = cleanedString.Replace("\x1E\xFD", ""); } if (cleanedString.IndexOf('\x1F') >= 0) { cleanedString = cleanedString.Replace("\x1F\x0E", ""); cleanedString = cleanedString.Replace("\x1F\x0F", ""); cleanedString = cleanedString.Replace("\x1F\x2F", ""); cleanedString = cleanedString.Replace("\x1F\x7F", ""); cleanedString = cleanedString.Replace("\x1F\x79", ""); cleanedString = cleanedString.Replace("\x1F\x7B", ""); cleanedString = cleanedString.Replace("\x1F\x7C", ""); cleanedString = cleanedString.Replace("\x1F\x8D", ""); cleanedString = cleanedString.Replace("\x1F\x88", ""); cleanedString = cleanedString.Replace("\x1F\x8A", ""); cleanedString = cleanedString.Replace("\x1F\xA1", ""); cleanedString = cleanedString.Replace("\x1F\xD0", ""); cleanedString = cleanedString.Replace("\x1F\r", ""); cleanedString = cleanedString.Replace("\x1F\n", ""); cleanedString = cleanedString.Replace("\x1F\x07", ""); } if (cleanedString.IndexOfAny(new char[] { '\r', '\n', '\x7F', '\x81', '\x87', '\x07' }) >= 0) { cleanedString = cleanedString.Replace("\r", ""); cleanedString = cleanedString.Replace("\n", ""); cleanedString = cleanedString.Replace("\x7F\x31", ""); cleanedString = cleanedString.Replace("\x81\xA1", ""); cleanedString = cleanedString.Replace("\x87\xB2", ""); cleanedString = cleanedString.Replace("\x87\xB3", ""); cleanedString = cleanedString.Replace("\x07", ""); } */ #endregion #region Original code (fail) /* // change the dot to a [ for start of string string startingChars = System.Text.Encoding.GetEncoding(1252).GetString(new byte[2] { 0x1e, 0xfc }); if (cleanedString.StartsWith(startingChars)) cleanedString = "[" + cleanedString.Substring(2); cleanedString = cleanedString.Replace("y", String.Empty); if (cleanedString.Contains(" ")) { cleanedString = cleanedString.Replace(" ", "**&*&!!@#$@$#$"); cleanedString = cleanedString.Replace("**&*&!!@#$@$#$", " "); } cleanedString = cleanedString.Replace("1", ""); cleanedString = cleanedString.Replace(" ", " "); // green start cleanedString = cleanedString.Replace("", ""); // green end cleanedString = cleanedString.Replace("Ð", ""); cleanedString = cleanedString.Replace("{", ""); cleanedString = cleanedString.Replace("ミ", ""); cleanedString = cleanedString.Replace("", ""); cleanedString = cleanedString.Replace("・", "E"); cleanedString = cleanedString.Replace("・", "["); cleanedString = cleanedString.Replace("・", ""); cleanedString = cleanedString.Replace("巧", "I"); // Yellow colored lines, JP cleanedString = cleanedString.Replace("。", ""); // Super Kupowers, JP cleanedString = cleanedString.Replace("垢", "C"); // Change job text. // trim the 1 that occasionally shows up at the end if (cleanedString.EndsWith("1")) cleanedString = cleanedString.TrimEnd('1'); cleanedString = cleanedString.TrimStart(''); */ #endregion if (cleaned[0] != 0) { byte[] arr = cleaned.ToArray(); cleanedString = System.Text.Encoding.GetEncoding(932).GetString(arr, 0, arr.Length); } else cleanedString = String.Empty; //if (IsSet(ls, LineSettings.CleanTimeStamp) && cleanedString.StartsWith("[")) // Detect and remove Windower Timestamp plugin text. //{ // cleanedString = CleanTimeStamp(cleanedString); // C#/.Net Strings can have \0 at the end and it f***s with Windows RichTextBox cleanedString = cleanedString.TrimEnd('\0'); //} // Detect and remove Windower Timestamp plugin text. if (!IsSet(lineSettings, LineSettings.CleanNewLine)) { // if it doesn't end with \r\n and we weren't supposed to CleanNewLine // add it back on. if (!cleanedString.EndsWith("\r\n")) cleanedString += Environment.NewLine; } return cleanedString; }
internal ChatLine GetCurrentLine(LineSettings lineSettings) { ChatLine line = null; /* new ChatLine() { Color = Color.Empty, NowDate = DateTime.Now, Now = "[" + DateTime.Now.ToString("HH:mm:ss") + "] ", Text = String.Empty, Type = ChatMode.Error };*/ // update our local cache of chat lines Update(); // if we have a new line if (NumberOfUnparsedLines() != 0) { line = new ChatLine(); // get the next chat line line.Type = _ChatLog.Peek().LineType; line.Text = _ChatLog.Peek().LineText; line.Index = _ChatLog.Peek().Index; line.RawString = _ChatLog.Peek().RawString; try { line.Color = ColorTranslator.FromHtml("#" + _ChatLog.Peek().LineColor.Trim('#')); } catch { line.Color = _ChatLog.Peek().ActualLineColor; } // if user wanted to strip off color characters, do so line.Text = FFACE.ChatTools.CleanLine(line.Text, lineSettings); } // @ if (!NumberOfUnparsedLines().Equals(0)) return line; }
} // @ internal static bool IsSet(UInt32 value, UInt32 bit) internal static bool IsSet (LineSettings value, LineSettings bit) { if (value == bit) return true; return ( ( (UInt32)value & (UInt32)bit ) != 0 ); } // @ internal static bool IsSet(LineSettings value, LineSettings bit)
///<summary> /// Returns a class containing the dialog text ///</summary> public DialogText GetDialogText(LineSettings lineSettings) { if (DialogID == 0) return new DialogText(String.Empty); int size = 4096; byte[] buffer = new byte[size]; GetDialogStrings(_InstanceID, buffer, ref size); if (size <= 3) return new DialogText(String.Empty); return new DialogText(System.Text.Encoding.GetEncoding(1252).GetString(buffer, 0, size - 3).Trim(), lineSettings); }
public ARLine(LineSettings settings) { this.settings = settings; }
public HomeController(IOptions <LineSettings> options) { lineSettings = options.Value; }