Elin Decompiled Documentation EA 23.276 Nightly Patch 2
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.AddButton("colorBG", delegate
76 {
77 EMono.ui.AddLayer<LayerColorPicker>().SetColor(bgColor, Color.white, delegate(PickerState state, Color _c)
78 {
79 bgColor = _c;
81 });
82 });
84 }
85
86 public void Refresh()
87 {
88 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));
89 }
90
91 public override void OnChangeResolution()
92 {
93 base.OnChangeResolution();
94 RectTransform rectTransform = this.Rect();
95 float x = 0.01f * (float)Screen.width * (float)extra.width / EMono.core.uiScale + 50f;
96 float y = (float)Screen.height / EMono.core.uiScale + 50f;
97 rectTransform.sizeDelta = new Vector2(x, y);
98 if (extra.reverse)
99 {
100 rectTransform.SetAnchor(0f, 0.5f, 0f, 0.5f);
101 rectTransform.anchoredPosition = new Vector2(rectTransform.sizeDelta.x * 0.5f, 0f);
102 }
103 else
104 {
105 rectTransform.SetAnchor(1f, 0.5f, 1f, 0.5f);
106 rectTransform.anchoredPosition = new Vector2(rectTransform.sizeDelta.x * -0.5f, 0f);
107 }
108 Refresh();
109 imagePic.SetActive(enable: false);
110 if (extra.alignUI)
111 {
112 if (extra.reverse)
113 {
114 EMono.ui.rectLayers.anchoredPosition = new Vector2(rectTransform.sizeDelta.x / 2f, 0f);
115 EMono.ui.rectLayers.sizeDelta = new Vector2(0f - rectTransform.sizeDelta.x, 0f);
116 SlideMiniGame(rectTransform.sizeDelta.x);
117 }
118 else
119 {
120 EMono.ui.rectLayers.anchoredPosition = new Vector2((0f - rectTransform.sizeDelta.x) / 2f, 0f);
121 EMono.ui.rectLayers.sizeDelta = new Vector2(0f - rectTransform.sizeDelta.x, 0f);
122 SlideMiniGame(0f - rectTransform.sizeDelta.x);
123 }
124 }
125 else
126 {
127 EMono.ui.rectLayers.anchoredPosition = Vector2.zero;
128 EMono.ui.rectLayers.sizeDelta = Vector2.zero;
129 SlideMiniGame(0f);
130 }
131 }
132
133 public void SlideMiniGame(float w)
134 {
135 if ((bool)LayerMiniGame.Instance)
136 {
138 }
139 }
140
141 private void OnEnable()
142 {
144 }
145
146 private void OnDisable()
147 {
148 EMono.scene.cam.rect = new Rect(0f, 0f, 1f, 1f);
149 EMono.ui.rectLayers.anchoredPosition = Vector2.zero;
150 EMono.ui.rectLayers.sizeDelta = Vector2.zero;
151 SlideMiniGame(0f);
152 }
153}
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