Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
WidgetSideScreen.cs
Go to the documentation of this file.
1using UnityEngine;
2using UnityEngine.UI;
3
4public class WidgetSideScreen : Widget
5{
6 public class Extra
7 {
8 public int width;
9
10 public int height;
11
12 public int idImage;
13
14 public int bgColor;
15
16 public bool reverse;
17
18 public bool alignUI;
19 }
20
22
23 public Sprite[] sprites;
24
25 public Image imagePic;
26
27 public override bool AlwaysBottom => true;
28
29 public Extra extra => base.config.extra as Extra;
30
32 {
33 get
34 {
36 }
37 set
38 {
39 extra.bgColor = IntColor.ToInt(ref value);
40 }
41 }
42
43 public override object CreateExtra()
44 {
45 return new Extra();
46 }
47
48 public override void OnActivate()
49 {
50 Layer.blurStopInstance = base.transform;
51 Refresh();
53 Instance = this;
54 }
55
56 public override void OnSetContextMenu(UIContextMenu m)
57 {
58 _ = base.config.skin;
59 UIContextMenu uIContextMenu = m.AddChild("setting");
60 uIContextMenu.AddToggle("alignUI", extra.alignUI, delegate
61 {
62 extra.alignUI = !extra.alignUI;
63 OnChangeResolution();
64 });
65 uIContextMenu.AddToggle("reverse", extra.reverse, delegate
66 {
67 extra.reverse = !extra.reverse;
68 OnChangeResolution();
69 });
70 uIContextMenu.AddSlider("width", (float a) => a.ToString() ?? "", extra.width, delegate(float a)
71 {
72 extra.width = (int)a;
74 }, 10f, 50f, isInt: true);
75 uIContextMenu.AddSlider("image", (float a) => a.ToString() ?? "", extra.idImage, delegate(float a)
76 {
77 extra.idImage = (int)a;
79 }, 0f, sprites.Length - 1, isInt: true);
80 uIContextMenu.AddButton("colorBG", delegate
81 {
82 EMono.ui.AddLayer<LayerColorPicker>().SetColor(bgColor, Color.white, delegate(PickerState state, Color _c)
83 {
84 bgColor = _c;
86 });
87 });
89 }
90
91 public void Refresh()
92 {
93 EMono.scene.cam.rect = (extra.reverse ? new Rect(0.01f * (float)extra.width, 0f, 1f + 0.01f * (float)extra.width, 1f) : new Rect(-0.01f * (float)extra.width, 0f, 1f, 1f));
94 }
95
96 public override void OnChangeResolution()
97 {
98 base.OnChangeResolution();
99 RectTransform rectTransform = this.Rect();
100 float x = 0.01f * (float)Screen.width * (float)extra.width / EMono.core.uiScale + 50f;
101 float num = (float)Screen.height / EMono.core.uiScale + 50f;
102 rectTransform.sizeDelta = new Vector2(x, num);
103 if (extra.reverse)
104 {
105 rectTransform.SetAnchor(0f, 0.5f, 0f, 0.5f);
106 rectTransform.anchoredPosition = new Vector2(rectTransform.sizeDelta.x * 0.5f, 0f);
107 }
108 else
109 {
110 rectTransform.SetAnchor(1f, 0.5f, 1f, 0.5f);
111 rectTransform.anchoredPosition = new Vector2(rectTransform.sizeDelta.x * -0.5f, 0f);
112 }
113 Refresh();
114 imagePic.SetActive(extra.idImage > 0);
115 Sprite sprite = sprites[extra.idImage];
116 if ((bool)sprite)
117 {
118 imagePic.sprite = sprite;
119 imagePic.rectTransform.sizeDelta = new Vector2(num * (float)sprite.texture.width / (float)sprite.texture.height, num);
120 imagePic.color = bgColor;
121 }
122 if (extra.alignUI)
123 {
124 if (extra.reverse)
125 {
126 EMono.ui.rectLayers.anchoredPosition = new Vector2(rectTransform.sizeDelta.x / 2f, 0f);
127 EMono.ui.rectLayers.sizeDelta = new Vector2(0f - rectTransform.sizeDelta.x, 0f);
128 SlideMiniGame(rectTransform.sizeDelta.x);
129 }
130 else
131 {
132 EMono.ui.rectLayers.anchoredPosition = new Vector2((0f - rectTransform.sizeDelta.x) / 2f, 0f);
133 EMono.ui.rectLayers.sizeDelta = new Vector2(0f - rectTransform.sizeDelta.x, 0f);
134 SlideMiniGame(0f - rectTransform.sizeDelta.x);
135 }
136 }
137 else
138 {
139 EMono.ui.rectLayers.anchoredPosition = Vector2.zero;
140 EMono.ui.rectLayers.sizeDelta = Vector2.zero;
141 SlideMiniGame(0f);
142 }
143 }
144
145 public void SlideMiniGame(float w)
146 {
147 if ((bool)LayerMiniGame.Instance)
148 {
150 }
151 }
152
153 private void OnEnable()
154 {
155 Refresh();
156 }
157
158 private void OnDisable()
159 {
160 EMono.scene.cam.rect = new Rect(0f, 0f, 1f, 1f);
161 EMono.ui.rectLayers.anchoredPosition = Vector2.zero;
162 EMono.ui.rectLayers.sizeDelta = Vector2.zero;
163 SlideMiniGame(0f);
164 }
165}
PickerState
Definition: PickerState.cs:2
override float uiScale
Definition: Core.cs:95
Definition: EMono.cs:4
static Core core
Definition: EMono.cs:5
static UI ui
Definition: EMono.cs:15
static int ToInt(ref Color c)
Definition: IntColor.cs:24
static Color32 FromInt(int i)
Definition: IntColor.cs:15
MiniGame mini
Definition: LayerMiniGame.cs:7
static LayerMiniGame Instance
Definition: LayerMiniGame.cs:5
virtual void SlidePosition(float w)
Definition: MiniGame.cs:80
UIContextMenuItem AddToggle(string idLang="", bool isOn=false, UnityAction< bool > action=null)
UIContextMenuItem AddSlider(string text, Func< float, string > textFunc, float value, Action< float > action, float min=0f, float max=1f, bool isInt=false, bool hideOther=true, bool useInput=false)
void AddButton(Func< string > funcText, UnityAction action=null)
UIContextMenu AddChild(string idLang, TextAnchor anchor)
static WidgetSideScreen Instance
override void OnChangeResolution()
void SlideMiniGame(float w)
override void OnSetContextMenu(UIContextMenu m)
override object CreateExtra()
override void OnActivate()
override bool AlwaysBottom
Definition: Widget.cs:7
void SetBaseContextMenu(UIContextMenu m)
Definition: Widget.cs:608