Elin Decompiled Documentation EA 23.153 Nightly
Loading...
Searching...
No Matches
SpriteData Class Reference

Public Member Functions

void Init ()
 
Sprite[] GetSprites ()
 
Sprite GetSprite (bool snow=false)
 
void Validate ()
 
void Load (bool dateMatched, ref Texture2D tex, ref Sprite[] sprites, string suffix)
 

Public Attributes

DateTime date
 
Texture2D tex
 
Texture2D texSnow
 
string path
 
Sprite[] sprites
 
Sprite[] spritesSnow
 
int frame = 1
 
int scale = 50
 
float time = 0.2f
 

Detailed Description

Definition at line 9 of file SpriteData.cs.

Member Function Documentation

◆ GetSprite()

Sprite SpriteData.GetSprite ( bool  snow = false)
inline

Definition at line 56 of file SpriteData.cs.

57 {
58 Validate();
59 if (!snow || spritesSnow == null)
60 {
61 return sprites[0];
62 }
63 return spritesSnow[0];
64 }
Sprite[] sprites
Definition: SpriteData.cs:19
Sprite[] spritesSnow
Definition: SpriteData.cs:21
void Validate()
Definition: SpriteData.cs:66

References sprites, spritesSnow, and Validate().

Referenced by Chara.GetSprite(), RenderRow.GetSprite(), LayerEditSkin.RefreshList(), and SpriteReplacerAnimation.SetData().

◆ GetSprites()

Sprite[] SpriteData.GetSprites ( )
inline

Definition at line 50 of file SpriteData.cs.

51 {
52 Validate();
53 return sprites;
54 }

References sprites, and Validate().

Referenced by CardActor.OnRender(), and SpriteReplacerAnimation.Refresh().

◆ Init()

void SpriteData.Init ( )
inline

Definition at line 29 of file SpriteData.cs.

30 {
31 try
32 {
33 if (File.Exists(path + ".ini"))
34 {
35 IniData iniData = new FileIniDataParser().ReadFile(path + ".ini", Encoding.UTF8);
36 frame = int.Parse(iniData.GetKey("frame") ?? "1");
37 scale = int.Parse(iniData.GetKey("scale") ?? "50");
38 time = float.Parse(iniData.GetKey("time") ?? "0.2", CultureInfo.InvariantCulture);
39 }
40 }
41 catch (Exception message)
42 {
43 Debug.Log(message);
44 Debug.Log("exception: Failed to parse:" + path + ".ini");
45 time = 0.2f;
46 scale = 50;
47 }
48 }
string path
Definition: SpriteData.cs:17
float time
Definition: SpriteData.cs:27

References Debug, frame, path, scale, and time.

Referenced by SpriteReplacer.HasSprite(), SpriteReplacer.ListSkins(), LayerEditSkin.RefreshList(), and SpriteReplacerAnimation.SetData().

◆ Load()

void SpriteData.Load ( bool  dateMatched,
ref Texture2D  tex,
ref Sprite[]  sprites,
string  suffix 
)
inline

Definition at line 81 of file SpriteData.cs.

82 {
83 if (dateMatched && (bool)tex)
84 {
85 return;
86 }
87 if ((bool)tex)
88 {
89 Texture2D texture2D = IO.LoadPNG(path + suffix + ".png");
90 if (texture2D.width != tex.width || texture2D.height != tex.height)
91 {
92 Debug.Log(texture2D.width + "/" + texture2D.height + "/" + path);
93 tex.Reinitialize(texture2D.width, texture2D.height);
94 }
95 tex.SetPixels32(texture2D.GetPixels32());
96 tex.Apply();
97 UnityEngine.Object.Destroy(texture2D);
98 }
99 else
100 {
101 tex = IO.LoadPNG(path + suffix + ".png");
102 int num = tex.width / frame;
103 int height = tex.height;
104 sprites = new Sprite[frame];
105 for (int i = 0; i < frame; i++)
106 {
107 sprites[i] = Sprite.Create(tex, new Rect(i * num, 0f, num, height), new Vector2(0.5f, 0.5f), 100f, 0u, SpriteMeshType.FullRect);
108 }
109 }
110 }
Definition: IO.cs:11
static Texture2D LoadPNG(string _path, FilterMode filter=FilterMode.Point)
Definition: IO.cs:421
Texture2D tex
Definition: SpriteData.cs:13

References Debug, frame, path, sprites, and tex.

Referenced by Validate().

◆ Validate()

void SpriteData.Validate ( )
inline

Definition at line 66 of file SpriteData.cs.

67 {
68 DateTime lastWriteTime = File.GetLastWriteTime(path + ".png");
69 bool flag = date.Year != 1 && date == lastWriteTime;
70 if (!flag)
71 {
72 Load(flag, ref tex, ref sprites, "");
73 if (File.Exists(path + "_snow.png"))
74 {
75 Load(flag, ref texSnow, ref spritesSnow, "_snow");
76 }
77 date = lastWriteTime;
78 }
79 }
DateTime date
Definition: SpriteData.cs:11
Texture2D texSnow
Definition: SpriteData.cs:15
void Load(bool dateMatched, ref Texture2D tex, ref Sprite[] sprites, string suffix)
Definition: SpriteData.cs:81

References date, Load(), path, sprites, spritesSnow, tex, and texSnow.

Referenced by GetSprite(), and GetSprites().

Member Data Documentation

◆ date

DateTime SpriteData.date

Definition at line 11 of file SpriteData.cs.

Referenced by Validate().

◆ frame

int SpriteData.frame = 1

Definition at line 23 of file SpriteData.cs.

Referenced by Init(), Load(), CardActor.OnRender(), and SpriteReplacerAnimation.Refresh().

◆ path

string SpriteData.path

Definition at line 17 of file SpriteData.cs.

Referenced by Init(), Load(), LayerEditSkin.RefreshList(), and Validate().

◆ scale

int SpriteData.scale = 50

Definition at line 25 of file SpriteData.cs.

Referenced by Init().

◆ sprites

Sprite [] SpriteData.sprites

Definition at line 19 of file SpriteData.cs.

Referenced by GetSprite(), GetSprites(), Load(), CardActor.OnRender(), and Validate().

◆ spritesSnow

Sprite [] SpriteData.spritesSnow

Definition at line 21 of file SpriteData.cs.

Referenced by GetSprite(), CardActor.OnRender(), and Validate().

◆ tex

Texture2D SpriteData.tex

Definition at line 13 of file SpriteData.cs.

Referenced by Load(), and Validate().

◆ texSnow

Texture2D SpriteData.texSnow

Definition at line 15 of file SpriteData.cs.

Referenced by Validate().

◆ time

float SpriteData.time = 0.2f

Definition at line 27 of file SpriteData.cs.

Referenced by Init(), CardActor.OnRender(), and SpriteReplacerAnimation.SetData().


The documentation for this class was generated from the following file: