Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ContentGallery.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using UnityEngine;
4using UnityEngine.UI;
5
6public class ContentGallery : EContent
7{
8 public class Page : UIBook.Page
9 {
10 public class Item
11 {
12 public int id;
13
14 public Sprite sprite;
15 }
16
17 public List<string> ids = new List<string>();
18
19 public override void BuildNote(UINote n, string idTopic)
20 {
21 foreach (string id in ids)
22 {
23 UIItem uIItem = n.AddItem("ItemGallery");
24 int num = id.ToInt();
25 Sprite sprite = Resources.Load<Sprite>("Media/Gallery/" + CoreRef.GetArtDir(num) + "/" + EClass.core.refs.dictSketches[num]);
26 uIItem.image1.sprite = sprite;
27 uIItem.text1.text = "#" + id;
28 uIItem.button1.SetOnClick(delegate
29 {
30 SE.Play("click_recipe");
31 EClass.ui.AddLayer<LayerImage>().SetImage(sprite);
32 });
33 }
34 }
35 }
36
37 public static int lastPage;
38
39 public static bool listMode;
40
41 public Transform transBig;
42
43 public Image imageBig;
44
45 public UIBook book;
46
48
49 public GridLayoutGroup[] grids;
50
51 public Vector2[] gridSize;
52
53 private bool first = true;
54
55 public override void OnSwitchContent(int idTab)
56 {
57 if (!first)
58 {
59 return;
60 }
62 {
63 EClass.player.sketches.Clear();
64 foreach (int key in EClass.core.refs.dictSketches.Keys)
65 {
66 EClass.player.sketches.Add(key);
67 }
68 }
69 Refresh();
70 first = false;
71 }
72
73 public void Refresh()
74 {
75 book.pages.Clear();
76 GridLayoutGroup[] array = grids;
77 for (int i = 0; i < array.Length; i++)
78 {
79 array[i].cellSize = gridSize[listMode ? 1 : 0];
80 }
81 Page page = new Page();
82 List<int> list = EClass.player.sketches.ToList();
83 list.Sort((int a, int b) => a - b);
84 foreach (int item in list)
85 {
86 page.ids.Add(item.ToString() ?? "");
87 if (page.ids.Count >= (listMode ? 8 : 2))
88 {
89 book.AddPage(page);
90 page = new Page();
91 }
92 }
93 if (page.ids.Count > 0)
94 {
95 book.AddPage(page);
96 }
97 book.currentPage = lastPage;
98 book.Show();
99 textCollected.SetText("sketch_collected".lang((list.Count * 100 / EClass.core.refs.dictSketches.Count()).ToString() ?? ""));
100 }
101
102 public void OnClickHelp()
103 {
104 LayerHelp.Toggle("other", "gallery");
105 }
106
107 public void ToggleMode()
108 {
110 lastPage = (listMode ? (book.currentPage / 4) : (book.currentPage * 4));
111 SE.Tab();
112 Refresh();
113 }
114
115 private void OnDestroy()
116 {
118 }
119}
List< string > ids
override void BuildNote(UINote n, string idTopic)
static bool listMode
Vector2[] gridSize
static int lastPage
Transform transBig
override void OnSwitchContent(int idTab)
GridLayoutGroup[] grids
UIText textCollected
bool allArt
Definition: CoreDebug.cs:196
UD_Int_String dictSketches
Definition: CoreRef.cs:397
static string GetArtDir(int a)
Definition: CoreRef.cs:473
CoreRef refs
Definition: Core.cs:51
Definition: EClass.cs:5
static Core core
Definition: EClass.cs:6
static Player player
Definition: EClass.cs:12
static CoreDebug debug
Definition: EClass.cs:48
static UI ui
Definition: EClass.cs:16
static void Toggle(string idFile, string idTopic=null)
Definition: LayerHelp.cs:32
HashSet< int > sketches
Definition: Player.cs:871
ICollection< TKey > Keys
Definition: UDictionary.cs:25
Definition: UIBook.cs:9
int currentPage
Definition: UIBook.cs:264
void AddPage(Page page)
Definition: UIBook.cs:538
void Show(string _idFile=null, string _idTopic=null, string title=null, BookList.Item _bookItem=null)
Definition: UIBook.cs:457
List< Page > pages
Definition: UIBook.cs:266
Definition: UIItem.cs:5
UIButton button1
Definition: UIItem.cs:18
Definition: UINote.cs:6
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:159