CrabUI
Loading...
Searching...
No Matches
CUIBool2.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5
6using Barotrauma;
7using Microsoft.Xna.Framework;
8using Microsoft.Xna.Framework.Input;
9using Microsoft.Xna.Framework.Graphics;
10
11namespace CrabUI
12{
13 /// <summary>
14 /// Vector2 but with bools
15 /// </summary>
16 public struct CUIBool2
17 {
18 public bool X;
19 public bool Y;
20
21 public CUIBool2(bool x = false, bool y = false)
22 {
23 X = x;
24 Y = y;
25 }
26
27 public override string ToString() => $"[{X},{Y}]";
28 public static CUIBool2 Parse(string s)
29 {
30 string content = s.Substring(
31 s.IndexOf('[') + 1,
32 s.IndexOf(']') - s.IndexOf('[') - 1
33 );
34
35 var components = content.Split(',').Select(a => a.Trim());
36
37 string sx = components.ElementAtOrDefault(0);
38 string sy = components.ElementAtOrDefault(1);
39
40 bool x = false;
41 bool y = false;
42
43 if (sx != null && sx != "") x = bool.Parse(sx);
44 if (sy != null && sy != "") y = bool.Parse(sy);
45
46 return new CUIBool2(x, y);
47 }
48 }
49}
Vector2 but with bools.
Definition CUIBool2.cs:17