Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerPixelPaint.cs
Go to the documentation of this file.
1using System;
3using UnityEngine;
4using UnityEngine.UI;
5
6public class LayerPixelPaint : ELayer
7{
9
10 public GridLayoutGroup layoutColors;
11
13
14 public Action onApply;
15
16 public override void OnInit()
17 {
18 UIItem t = layoutColors.CreateMold<UIItem>();
19 for (int i = 0; i < 8; i++)
20 {
21 UIItem item = Util.Instantiate(t, layoutColors);
22 int _i = i;
23 item.button1.icon.color = IntColor.FromInt(ELayer.core.config.colors[_i]);
24 item.button1.SetOnClick(delegate
25 {
26 picker.SelectColor(item.button1.icon.color);
27 });
28 item.button2.SetOnClick(delegate
29 {
30 item.button1.icon.color = picker.SelectedColor;
32 SE.Tab();
33 });
34 }
35 layoutColors.RebuildLayout();
36 windows[0].AddBottomButton("apply", delegate
37 {
38 onApply?.Invoke();
39 });
40 windows[0].AddBottomButton("cancel", delegate
41 {
42 Close();
43 });
44 paint.Init();
45 }
46
47 public void SetCanvas(TraitCanvas c)
48 {
49 onApply = delegate
50 {
51 c.owner.PlaySound(c.owner.material.GetSoundImpact());
53 Thing thing = c.owner.Split(1);
54 thing.c_textureData = paint.tex.EncodeToPNG();
55 thing.isModified = true;
56 thing.ClearPaintSprite();
57 thing.GetPaintSprite();
58 thing.renderer.RefreshSprite();
59 Close();
60 };
61 if (c.owner.c_textureData != null)
62 {
63 paint.tex.LoadImage(c.owner.c_textureData);
64 }
65 paint.imageMask.texture = c.owner.GetSprite().texture;
66 paint.imageMask.SetNativeSize();
67 paint.imagePreview.SetNativeSize();
68 }
69}
AnimeID
Definition: AnimeID.cs:2
void PlayAnime(AnimeID id, bool force)
void RefreshSprite()
Thing Split(int a)
Definition: Card.cs:3231
SourceMaterial.Row material
Definition: Card.cs:1927
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
Sprite GetPaintSprite()
Definition: Card.cs:6280
virtual Sprite GetSprite(int dir=0)
Definition: Card.cs:5341
byte[] c_textureData
Definition: Card.cs:1805
CardRenderer renderer
Definition: Card.cs:57
void ClearPaintSprite()
Definition: Card.cs:6270
int[] colors
Definition: CoreConfig.cs:616
CoreConfig config
Definition: Core.cs:70
Definition: ELayer.cs:4
static Core core
Definition: ELayer.cs:7
void SelectColor(Color newColor)
Definition: ColorPicker.cs:218
static int ToInt(ref Color c)
Definition: IntColor.cs:24
static Color32 FromInt(int i)
Definition: IntColor.cs:15
PixelPaint paint
GridLayoutGroup layoutColors
ColorPicker picker
override void OnInit()
void SetCanvas(TraitCanvas c)
List< Window > windows
Definition: Layer.cs:116
virtual void Close()
Definition: Layer.cs:463
RawImage imagePreview
Definition: PixelPaint.cs:11
void Init()
Definition: PixelPaint.cs:92
Texture2D tex
Definition: PixelPaint.cs:23
RawImage imageMask
Definition: PixelPaint.cs:13
Definition: Thing.cs:8
Card owner
Definition: Trait.cs:26
Definition: UIItem.cs:5