public string RelativeCoord(GameObject target, StringStyle s) { int[] coord = RelativeCoord(target); string targetName = GetComponent <ActorData>().GetStringData( target.GetComponent <MetaInfo>().SubTag, DataTag.ActorName); string posWithName; switch (s) { case StringStyle.NameNoBracket: posWithName = targetName + " [ " + coord[0] + ", " + coord[1] + " ]"; break; case StringStyle.NameAndBracket: posWithName = "[ " + targetName + " ]" + " [ " + coord[0] + ", " + coord[1] + " ]"; break; default: posWithName = "[ " + coord[0] + ", " + coord[1] + " ]"; break; } return(posWithName); }
public static void DrawString(Vector2 position, string label, bool centered = true) { var content = new GUIContent(label); var size = StringStyle.CalcSize(content); var upperLeft = centered ? position - size / 2f : position; GUI.Label(new Rect(upperLeft, size), content); }
public static void DrawString(Vector2 position, string label, bool centered = true, int size = 12, FontStyle fontStyle = FontStyle.Bold) { StringStyle.fontSize = size; StringStyle.richText = true; StringStyle.font = Main.Consolas; StringStyle.fontStyle = fontStyle; GUIContent guicontent = new GUIContent(label); if (centered) { position.x -= StringStyle.CalcSize(guicontent).x / 2f; } GUI.Label(new Rect(position.x, position.y, 300f, 25f), guicontent, StringStyle); }
public void Write(string String, StringStyle Style) { switch (Style) { case StringStyle.UCString: case StringStyle.CString: List <byte> Buffer = new List <byte>(this.Encoding.GetBytes(String + "\x0")); base.Write(Buffer.ToArray(), 0, Buffer.Count); break; default: base.Write(String); break; } }
public void Write(FieldInfo Field, dynamic Value, StringStyle Style) { switch (Style) { case StringStyle.UCString: case StringStyle.CString: List <byte> Buffer = new List <byte>(Encoding.GetBytes(Value + "\x0")); base.Write(Buffer.ToArray(), 0, Buffer.Count); break; case StringStyle.PString: WritePString(Field, Value); break; } }
} //END FormatDatabaseURL //-----------------------------// public static string CreateStreamingAssetsPath( string filePath, StringStyle style ) //-----------------------------// { if( style == StringStyle.NoSettings ) { return CreateStreamingAssetsPathWithoutEscapeUriOrSytemPathCombine( filePath ); } else if( style == StringStyle.WithEscapeUriAndSystemPathCombine ) { return CreateStreamingAssetsPathWithAll( filePath ); } return ""; } //END CreateStreamingAssetsPath
public string ReadString(StringStyle Style, FieldInfo Info = null) { List <byte> Buffer = new List <byte>(); switch (Style) { case StringStyle.CString: while (true) { byte Byte = base.ReadByte(); if (Byte < 1) { break; } Buffer.Add(Byte); } return(Encoding.GetString(Buffer.ToArray())); case StringStyle.UCString: while (true) { byte Byte1 = base.ReadByte(), Byte2 = base.ReadByte(); if (Byte1 == 0x00 && Byte2 == 0x00) { break; } Buffer.Add(Byte1); Buffer.Add(Byte2); } return(Encoding.GetString(Buffer.ToArray())); case StringStyle.PString: return(ReadPString(Info)); default: throw new Exception("Unk Value Type"); } }
public string ReadString(StringStyle Style) { List <byte> Buffer = new List <byte>(); switch (Style) { case StringStyle.CString: while (true) { byte Byte = base.ReadByte(); if (Byte < 1) { break; } Buffer.Add(Byte); } return(Encoding.GetString(Buffer.ToArray())); case StringStyle.UCString: while (true) { byte Byte1 = base.ReadByte(); byte Byte2 = base.ReadByte(); if (Byte1 == 0x00 && Byte2 == 0x00) { break; } Buffer.Add(Byte1); Buffer.Add(Byte2); } return(Encoding.GetString(Buffer.ToArray())); default: return(base.ReadString()); } }
public string ReadString(StringStyle Style, FieldInfo Info = null) { List <byte> Buffer = new List <byte>(); switch (Style) { case StringStyle.CString: while (true) { byte Byte = base.ReadByte(); if (Byte < 1) { break; } Buffer.Add(Byte); } return(Encoding.GetString(Buffer.ToArray())); case StringStyle.UCString: while (true) { byte Byte1 = base.ReadByte(); byte Byte2 = base.ReadByte(); if (Byte1 == 0x00 && Byte2 == 0x00) { break; } Buffer.Add(Byte1); Buffer.Add(Byte2); } return(Encoding.GetString(Buffer.ToArray())); case StringStyle.PString: if (Info != null) { long Len; string Prefix = Tools.GetAttributePropertyValue(Info, Const.PSTRING, "PrefixType"); bool UnicodeLength = Tools.GetAttributePropertyValue(Info, Const.PSTRING, "UnicodeLength"); switch (Prefix) { case Const.INT16: if (BigEndian) { Len = Tools.Reverse(ReadInt16()); } else { Len = ReadInt16(); } break; case Const.UINT16: if (BigEndian) { Len = Tools.Reverse(ReadUInt16()); } else { Len = ReadUInt16(); } break; case Const.UINT8: if (BigEndian) { Len = Tools.Reverse(ReadByte()); } else { Len = ReadByte(); } break; case Const.INT8: if (BigEndian) { Len = Tools.Reverse(ReadSByte()); } else { Len = ReadSByte(); } break; case Const.INT32: if (BigEndian) { Len = Tools.Reverse(ReadInt32()); } else { Len = ReadInt32(); } break; case Const.UINT32: if (BigEndian) { Len = Tools.Reverse(ReadUInt32()); } else { Len = ReadUInt32(); } break; case Const.INT64: if (BigEndian) { Len = Tools.Reverse(ReadInt64()); } else { Len = ReadInt64(); } break; default: throw new Exception("Invalid Data Type"); } if (UnicodeLength) { Len *= 2; } if (Len > BaseStream.Length - BaseStream.Position) { throw new Exception("Invalid Length"); } byte[] Buff = new byte[Len]; while (Len > 0) { Len -= BaseStream.Read(Buff, 0, Len > int.MaxValue ? int.MaxValue : (int)Len); } return(Encoding.GetString(Buff)); } else { return(ReadString()); } default: throw new Exception("Unk Value Type"); } }
public void setStringStyle(StringStyle style);
public void Write(FieldInfo Field, dynamic Value, StringStyle Style) { switch (Style) { case StringStyle.UCString: case StringStyle.CString: List <byte> Buffer = new List <byte>(Encoding.GetBytes(Value + "\x0")); base.Write(Buffer.ToArray(), 0, Buffer.Count); break; case StringStyle.PString: byte[] Arr = Encoding.GetBytes(Value); string Prefix = Tools.GetAttributePropertyValue(Field, Const.PSTRING, "PrefixType"); bool UnicodeLength = Tools.GetAttributePropertyValue(Field, Const.PSTRING, "UnicodeLength"); long Length = Arr.LongLength; if (UnicodeLength) { Length /= 2; } switch (Prefix) { case Const.INT16: if (BigEndian) { base.Write((short)Tools.Reverse((short)Length)); } else { base.Write((short)Length); } break; case Const.UINT16: if (BigEndian) { base.Write((ushort)Tools.Reverse((ushort)Length)); } else { base.Write((ushort)Length); } break; case Const.UINT8: if (BigEndian) { base.Write((byte)Tools.Reverse((byte)Length)); } else { base.Write((byte)Length); } break; case Const.INT8: if (BigEndian) { base.Write((sbyte)Tools.Reverse((sbyte)Length)); } else { base.Write((sbyte)Length); } break; case Const.INT32: if (BigEndian) { base.Write((int)Tools.Reverse((int)Length)); } else { base.Write((int)Length); } break; case Const.UINT32: if (BigEndian) { base.Write((uint)Tools.Reverse((uint)Length)); } else { base.Write((uint)Length); } break; case Const.INT64: if (BigEndian) { base.Write((long)Tools.Reverse(Length)); } else { base.Write(Length); } break; default: throw new Exception("Invalid Data Type"); } base.Write(Arr); break; } }