Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerSkinDeco.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class LayerSkinDeco : ELayer
6{
7 [NonSerialized]
8 public Widget widget;
9
10 public Transform widgetHolder;
11
12 public List<SkinDeco> decos => widget.config.skin.decos;
13
15
16 public override void OnInit()
17 {
18 base.OnInit();
19 }
20
21 public void SetWidget(Widget _widget)
22 {
23 widget = _widget;
24 foreach (SkinDeco deco in decos)
25 {
26 Activate(deco.actor);
27 }
28 widget.transform.SetParent(widgetHolder, worldPositionStays: false);
29 }
30
31 public override void OnUpdateInput()
32 {
34 {
36 {
37 return;
38 }
39 SkinDecoActor selected = InputModuleEX.GetComponentOf<SkinDecoActor>();
40 Vector3 clickPos = Input.mousePosition;
41 UIContextMenu i = ELayer.ui.CreateContextMenu();
42 if ((bool)selected)
43 {
44 SkinDeco deco = selected.owner;
45 i.AddButton("editColor", delegate
46 {
47 ELayer.ui.AddLayer<LayerColorPicker>().SetColor(deco.color, Color.white, delegate(PickerState state, Color _c)
48 {
49 deco.color = _c;
50 selected.Refresh();
51 });
52 });
53 i.AddButton("bringToTop", delegate
54 {
55 decos.Remove(deco);
56 decos.Add(deco);
57 selected.transform.SetAsLastSibling();
58 });
59 i.AddSlider("rotation", (float n) => (n * 45f).ToString() ?? "", deco.rz, delegate(float a)
60 {
61 deco.rz = (int)a;
62 selected.Refresh();
63 }, 0f, 7f, isInt: true);
64 i.AddSlider("size", (float n) => n.ToString() ?? "", Mathf.Abs(deco.sx), delegate(float a)
65 {
66 deco.sx = (int)a * ((deco.sx > 0) ? 1 : (-1));
67 deco.sy = (int)a * ((deco.sy > 0) ? 1 : (-1));
68 selected.Refresh();
69 }, 10f, 400f, isInt: true);
70 i.AddToggle("shadow", deco.shadow, delegate(bool a)
71 {
72 deco.shadow = a;
73 selected.Refresh();
74 });
75 i.AddToggle("reverse", deco.reverse, delegate(bool a)
76 {
77 deco.reverse = a;
78 selected.Refresh();
79 });
80 i.AddToggle("placeBeforeWidget", deco.bottom, delegate(bool a)
81 {
82 deco.bottom = a;
83 selected.Refresh();
84 });
85 i.AddButton("removeDeco", delegate
86 {
87 widget.RemoveDeco(selected.owner);
88 });
89 }
90 else
91 {
92 UIContextMenu uIContextMenu = i.AddChild("addDeco");
93 UIList uIList = Util.Instantiate<UIList>("UI/Element/List/ListImageGrid", uIContextMenu);
94 uIList.callbacks = new UIList.Callback<Sprite, UIButton>
95 {
96 onInstantiate = delegate(Sprite a, UIButton _b)
97 {
98 _b.icon.sprite = a;
99 },
100 onClick = delegate(Sprite a, UIButton _b)
101 {
102 SkinDeco skinDeco = new SkinDeco
103 {
104 sx = 100,
105 sy = 100,
106 color = Color.white
107 };
108 skinDeco.id = int.Parse(a.name.Remove(0, 4));
109 widget.AddDeco(skinDeco);
110 SkinDecoActor actor = skinDeco.actor;
111 Activate(actor);
112 actor.transform.position = clickPos;
113 EInput.Consume();
114 i.Hide();
115 }
116 };
117 Sprite[] array = Resources.LoadAll<Sprite>("Media/Graphics/Deco/");
118 foreach (Sprite o in array)
119 {
120 uIList.Add(o);
121 }
122 uIList.Refresh();
123 }
124 i.Show();
125 }
127 {
128 UIContextMenu uIContextMenu2 = ELayer.ui.CreateContextMenu();
129 uIContextMenu2.AddButton("quitEdit", delegate
130 {
131 Close();
132 });
133 uIContextMenu2.Show();
134 }
135 }
136
137 public void Activate(SkinDecoActor actor)
138 {
139 actor.image.raycastTarget = true;
140 actor.transform.SetParent(base.transform, worldPositionStays: true);
141 UIDragPanel uIDragPanel = actor.gameObject.AddComponent<UIDragPanel>();
142 uIDragPanel.target = actor.Rect();
143 uIDragPanel.bound = actor.Rect();
144 uIDragPanel.clamp = false;
145 }
146
147 public override void OnKill()
148 {
149 widget.transform.SetParent(ELayer.ui.widgets.transform, worldPositionStays: false);
151 foreach (SkinDeco deco in decos)
152 {
153 SkinDecoActor actor = deco.actor;
154 actor.image.raycastTarget = false;
155 UnityEngine.Object.DestroyImmediate(actor.gameObject.GetComponent<UIDragPanel>());
156 actor.transform.SetParent(widget.transform, worldPositionStays: true);
157 deco.x = (int)actor.Rect().anchoredPosition.x;
158 deco.y = (int)actor.Rect().anchoredPosition.y;
159 actor.Refresh();
160 }
161 }
162}
PickerState
Definition: PickerState.cs:2
bool dragging
Definition: ButtonState.cs:43
bool clicked
Definition: ButtonState.cs:37
Definition: EInput.cs:8
static void Consume(int _skipFrame)
Definition: EInput.cs:656
static ButtonState leftMouse
Definition: EInput.cs:349
static ButtonState rightMouse
Definition: EInput.cs:351
Definition: ELayer.cs:4
static UI ui
Definition: ELayer.cs:21
SkinConfig cfg
void Activate(SkinDecoActor actor)
Transform widgetHolder
override void OnKill()
void SetWidget(Widget _widget)
override void OnUpdateInput()
override void OnInit()
List< SkinDeco > decos
virtual void Close()
Definition: Layer.cs:463
List< SkinDeco > decos
Definition: SkinConfig.cs:9
SkinDeco owner
Definition: SkinDecoActor.cs:6
int sy
Definition: SkinDeco.cs:64
int rz
Definition: SkinDeco.cs:88
Color color
Definition: SkinDeco.cs:76
SkinDecoActor actor
Definition: SkinDeco.cs:8
bool bottom
Definition: SkinDeco.cs:136
bool reverse
Definition: SkinDeco.cs:124
int sx
Definition: SkinDeco.cs:52
bool shadow
Definition: SkinDeco.cs:112
UIContextMenuItem AddToggle(string idLang="", bool isOn=false, UnityAction< bool > action=null)
void Show(UIItem i)
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)
Definition: UIList.cs:9
SkinConfig skin
Definition: Widget.cs:61
Definition: Widget.cs:7
void RemoveDeco(SkinDeco deco)
Definition: Widget.cs:590
void AddDeco(SkinDeco deco)
Definition: Widget.cs:584
Config config
Definition: Widget.cs:180
void RefreshOrder()
Definition: Widget.cs:272