Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TextDrawReader
- {
- private readonly string[,] _textdraw =
- {
- {"TextDrawFont", "PlayerTextDrawFont"},
- {"TextDrawSetOutline", "PlayerTextDrawSetOutline"},
- { "TextDrawSetShadow", "PlayerTextDrawSetShadow"},
- { "TextDrawLetterSize", "PlayerTextDrawLetterSize"},
- { "TextDrawColor", "PlayerTextDrawColor"},
- { "TextDrawBackgroundColor", "PlayerTextDrawBackgroundColor"},
- { "TextDrawBoxColor", "PlayerTextDrawBoxColor"},
- { "TextDrawUseBox", "PlayerTextDrawUseBox"},
- { "TextDrawTextSize", "PlayerTextDrawTextSize"},
- { "TextDrawSetSelectable", "PlayerTextDrawSetSelectable"},
- { "TextDrawAlignment", "PlayerTextDrawAlignment"},
- { "TextDrawSetProportional", "PlayerTextDrawSetProportional"},
- { "TextDrawSetPreviewModel", "PlayerTextDrawSetPreviewModel"},
- { "TextDrawSetPreviewVehCol", "PlayerTextDrawSetPreviewVehCol"},
- { "TextDrawSetPreviewRot", "PlayerTextDrawSetPreviewRot"}
- };
- public TextDraw[] TextDraw(string file)
- {
- List<TextDraw> tdArray = new List<TextDraw>();
- string[] flines = File.ReadAllLines(file);
- int textdrawType = -1;
- TextDraw td = new TextDraw
- {
- LetterSize = new TextDraw.LetterSizeData(),
- TextSize = new TextDraw.TextSizeData(),
- Position = new TextDraw.PositionData(),
- Preview = new TextDraw.PreviewModelData()
- };
- for (int i = 0; i < flines.Length; i++)
- {
- string cline = flines[i].Trim();
- if (string.IsNullOrEmpty(cline) || i == (flines.Length - 1))
- {
- if (textdrawType > -1)
- {
- tdArray.Add(td);
- td = new TextDraw
- {
- LetterSize = new TextDraw.LetterSizeData(),
- TextSize = new TextDraw.TextSizeData(),
- Position = new TextDraw.PositionData(),
- Preview = new TextDraw.PreviewModelData()
- };
- }
- textdrawType = -1;
- continue;
- }
- if (cline.Contains("TextDrawCreate"))
- {
- if (textdrawType > -1)
- {
- tdArray.Add(td);
- td = new TextDraw
- {
- LetterSize = new TextDraw.LetterSizeData(),
- TextSize = new TextDraw.TextSizeData(),
- Position = new TextDraw.PositionData(),
- Preview = new TextDraw.PreviewModelData()
- };
- }
- int idx1 = cline.IndexOf('(');
- int idx2 = cline.IndexOf(',', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out decimal valorDec);
- td.Position.X = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(',', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- td.Position.Y = valorDec;
- idx1 = cline.IndexOf('"', idx2);
- idx2 = cline.IndexOf('"', idx1 + 1);
- if (idx1 > -1 && idx2 > idx1)
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- else
- valor = "_";
- td.Text = valor;
- idx1 = cline.IndexOf('=') - 1;
- if (idx1 > -1)
- {
- int idxChar1 = -1;
- int idxChar2 = -1;
- for (int j = idx1; j > -1; j--)
- {
- if (idxChar1 == -1 && !char.IsWhiteSpace(cline[j]))
- idxChar1 = j + 1;
- if (idxChar2 == -1 && idxChar1 > -1 && (cline[j] == ' ' || j == 0))
- idxChar2 = j;
- if (idxChar1 != -1 && idxChar2 != -1)
- {
- string varName = cline.Substring(idxChar2, idxChar1 - idxChar2).Trim();
- td.VariableName = varName;
- break;
- }
- }
- }
- td.IsPublic = true;
- textdrawType = 0;
- }
- else if (cline.Contains("CreatePlayerTextDraw"))
- {
- int idx1 = cline.IndexOf("CreatePlayerTextDraw", StringComparison.CurrentCulture);
- int idx2 = cline.IndexOf('(', idx1);
- if (idx1 > -1 && (idx1 + 20) != idx2)
- continue;
- if (textdrawType > -1)
- {
- tdArray.Add(td);
- td = new TextDraw
- {
- LetterSize = new TextDraw.LetterSizeData(),
- TextSize = new TextDraw.TextSizeData(),
- Position = new TextDraw.PositionData(),
- Preview = new TextDraw.PreviewModelData()
- };
- }
- idx1 = cline.IndexOf(',');
- idx2 = cline.IndexOf(',', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out decimal valorDec);
- td.Position.X = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(',', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- td.Position.Y = valorDec;
- idx1 = cline.IndexOf('"', idx2);
- idx2 = cline.IndexOf('"', idx1 + 1);
- if (idx1 > -1 && idx2 > idx1)
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- else
- valor = "_";
- td.Text = valor;
- idx1 = cline.IndexOf('=') - 1;
- if (idx1 > -1)
- {
- int idxChar1 = -1;
- int idxChar2 = -1;
- for (int j = idx1; j > -1; j--)
- {
- if (idxChar1 == -1 && !char.IsWhiteSpace(cline[j]))
- idxChar1 = j + 1;
- if (idxChar2 == -1 && idxChar1 > -1 && (cline[j] == ' ' || j == 0))
- idxChar2 = j;
- if (idxChar1 != -1 && idxChar2 != -1)
- {
- string varName = cline.Substring(idxChar2, idxChar1 - idxChar2).Trim();
- td.VariableName = varName;
- break;
- }
- }
- }
- td.IsPublic = false;
- textdrawType = 1;
- }
- if (textdrawType < 0)
- continue;
- if (cline.Contains(_textdraw[0, textdrawType])) // Font
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Int32.TryParse(valor, out Int32 valorInt);
- td.Font = valorInt;
- }
- else if (cline.Contains(_textdraw[1, textdrawType])) // Outline
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Int32.TryParse(valor, out Int32 valorInt);
- td.Outline = valorInt;
- }
- else if (cline.Contains(_textdraw[2, textdrawType])) // Shadow
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Int32.TryParse(valor, out Int32 valorInt);
- td.Shadow = valorInt;
- }
- else if (cline.Contains(_textdraw[3, textdrawType])) // Letter Size
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(',', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out Decimal valorDec);
- td.LetterSize.X = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(')', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- td.LetterSize.Y = valorDec;
- }
- else if (cline.Contains(_textdraw[4, textdrawType])) // Color
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- if (valor.StartsWith("0x"))
- {
- td.Color = Int32.Parse(valor.Substring(2), NumberStyles.HexNumber);
- }
- else
- {
- Int32.TryParse(valor, out int valorInt);
- td.Color = valorInt;
- }
- }
- else if (cline.Contains(_textdraw[5, textdrawType])) // Background Color
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- if (valor.StartsWith("0x"))
- {
- td.BackgroundColor = Int32.Parse(valor.Substring(2), NumberStyles.HexNumber);
- }
- else
- {
- Int32.TryParse(valor, out int valorInt);
- td.BackgroundColor = valorInt;
- }
- }
- else if (cline.Contains(_textdraw[6, textdrawType])) // Box Color
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- if (valor.StartsWith("0x"))
- {
- td.BoxColor = Int32.Parse(valor.Substring(2), NumberStyles.HexNumber);
- }
- else
- {
- Int32.TryParse(valor, out int valorInt);
- td.BoxColor = valorInt;
- }
- }
- else if (cline.Contains(_textdraw[7, textdrawType])) // Use Box
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- td.UseBox = valor == "1";
- }
- else if (cline.Contains(_textdraw[8, textdrawType])) // Text Size
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(',', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out Decimal valorDec);
- td.TextSize.X = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(')', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- td.TextSize.Y = valorDec;
- }
- else if (cline.Contains(_textdraw[9, textdrawType])) // Selectable
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- td.Selectable = valor == "1";
- }
- else if (cline.Contains(_textdraw[10, textdrawType])) // Alignment
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Int32.TryParse(valor, out Int32 valorInt);
- td.Alignment = valorInt;
- }
- else if (cline.Contains(_textdraw[11, textdrawType])) // Proportional
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Int32.TryParse(valor, out Int32 valorInt);
- td.Proportional = valorInt;
- }
- else if (cline.Contains(_textdraw[12, textdrawType])) // Preview Model
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(')', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Int32.TryParse(valor, out Int32 valorInt);
- td.Preview.Model = valorInt;
- }
- else if (cline.Contains(_textdraw[13, textdrawType])) // Preview Veh Col
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(',', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- if (valor.StartsWith("0x"))
- {
- td.Preview.Color1 = Int32.Parse(valor.Substring(2), NumberStyles.HexNumber);
- }
- else
- {
- Int32.TryParse(valor, out Int32 valorInt);
- td.Preview.Color1 = valorInt;
- }
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(')', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- if (valor.StartsWith("0x"))
- {
- td.Preview.Color2 = Int32.Parse(valor.Substring(2), NumberStyles.HexNumber);
- }
- else
- {
- Int32.TryParse(valor, out int valorInt);
- td.Preview.Color2 = valorInt;
- }
- }
- else if (cline.Contains(_textdraw[14, textdrawType])) // Preview Rot
- {
- int idx1 = cline.IndexOf(',');
- if (textdrawType == 1)
- idx1 = cline.IndexOf(',', idx1 + 1);
- int idx2 = cline.IndexOf(',', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out Decimal valorDec);
- td.Preview.X = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(',', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- td.Preview.Y = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(',', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- td.Preview.Z = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(')', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- td.Preview.Zoom = valorDec;
- }
- }
- return tdArray.ToArray();
- }
- }
- public class ProgressBarReader
- {
- public ProgressBar[] ProgressBar(string file)
- {
- List<ProgressBar> pbArray = new List<ProgressBar>();
- string[] flines = File.ReadAllLines(file);
- ProgressBar pb = new ProgressBar();
- for (int i = 0; i < flines.Length; i++)
- {
- string cline = flines[i].Trim();
- if (string.IsNullOrEmpty(cline) || i == (flines.Length - 1))
- continue;
- if (cline.Contains("CreatePlayerProgressBar"))
- {
- int idx1 = cline.IndexOf('(');
- idx1 = cline.IndexOf(',', idx1);
- int idx2 = cline.IndexOf(',', idx1 + 1);
- string valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out Decimal valorDec);
- pb.X = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(',', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- pb.Y = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(',', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- pb.Width = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(',', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- pb.Height = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(',', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- if (valor.StartsWith("0x"))
- {
- pb.Colour = Int32.Parse(valor.Substring(2), NumberStyles.HexNumber);
- }
- else
- {
- Int32.TryParse(valor, out int valorInt1);
- pb.Colour = valorInt1;
- }
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(',', idx1 + 1);
- if (idx2 > -1)
- {
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- Decimal.TryParse(valor.Replace('.', ','), out valorDec);
- pb.Max = valorDec;
- idx1 = cline.IndexOf(',', idx2);
- idx2 = cline.IndexOf(')', idx1 + 1);
- valor = cline.Substring(idx1 + 1, idx2 - idx1 - 1).Trim();
- if (!Int32.TryParse(valor, out Int32 valorInt2))
- {
- switch (valor)
- {
- case "BAR_DIRECTION_RIGHT":
- {
- valorInt2 = 0;
- break;
- }
- case "BAR_DIRECTION_LEFT":
- {
- valorInt2 = 1;
- break;
- }
- case "BAR_DIRECTION_UP":
- {
- valorInt2 = 2;
- break;
- }
- case "BAR_DIRECTION_DOWN":
- {
- valorInt2 = 3;
- break;
- }
- }
- pb.Direction = valorInt2;
- }
- else
- pb.Direction = valorInt2;
- }
- else
- pb.Direction = 0;
- idx1 = cline.IndexOf('=') - 1;
- if (idx1 > -1)
- {
- int idxChar1 = -1;
- int idxChar2 = -1;
- for (int j = idx1; j > -1; j--)
- {
- if (idxChar1 == -1 && !char.IsWhiteSpace(cline[j]))
- idxChar1 = j + 1;
- if (idxChar2 == -1 && idxChar1 > -1 && (cline[j] == ' ' || j == 0))
- idxChar2 = j;
- if (idxChar1 != -1 && idxChar2 != -1)
- {
- string varName = cline.Substring(idxChar2, idxChar1 - idxChar2).Trim();
- pb.VariableName = varName;
- break;
- }
- }
- }
- pbArray.Add(pb);
- pb = new ProgressBar();
- }
- }
- return pbArray.ToArray();
- }
- }
- public class TextDraw
- {
- public class PositionData
- {
- public Decimal X { get; set; }
- public Decimal Y { get; set; }
- }
- public class LetterSizeData
- {
- public Decimal X { get; set; }
- public Decimal Y { get; set; }
- }
- public class TextSizeData
- {
- public Decimal X { get; set; }
- public Decimal Y { get; set; }
- }
- public class PreviewModelData
- {
- public Int32 Model { get; set; }
- public Decimal X { get; set; }
- public Decimal Y { get; set; }
- public Decimal Z { get; set; }
- public Decimal Zoom { get; set; }
- public Int32 Color1 { get; set; }
- public Int32 Color2 { get; set; }
- }
- public Boolean IsPublic { get; set; }
- public PositionData Position { get; set; }
- public String Text { get; set; }
- public Int32 Font { get; set; }
- public Int32 Outline { get; set; }
- public Int32 Shadow { get; set; }
- public LetterSizeData LetterSize { get; set; }
- public Int32 Color { get; set; }
- public Int32 BackgroundColor { get; set; }
- public Int32 BoxColor { get; set; }
- public Boolean UseBox { get; set; }
- public TextSizeData TextSize { get; set; }
- public Boolean Selectable { get; set; }
- public Int32 Alignment { get; set; }
- public Int32 Proportional { get; set; }
- public PreviewModelData Preview { get; set; }
- public String VariableName { get; set; }
- }
- public class ProgressBar
- {
- public Decimal X { get; set; }
- public Decimal Y { get; set; }
- public Decimal Width { get; set; }
- public Decimal Height { get; set; }
- public Int32 Colour { get; set; }
- public Decimal Max { get; set; }
- public Int32 Direction { get; set; }
- public String VariableName { get; set; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement