Elin Decompiled Documentation EA 23.285 Nightly
Loading...
Searching...
No Matches
UISearchPeople.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine.UI;
3
4public class UISearchPeople : EMono
5{
6 public InputField inputSearch;
7
9
11
13
14 public bool disable;
15
16 public float intervalSearch;
17
18 private int uidFilterZone = -1;
19
20 private float timerSearch;
21
22 private string lastSearch = "";
23
24 public void Init(ListOwner _list)
25 {
26 if (disable)
27 {
28 base.gameObject.SetActive(value: false);
29 return;
30 }
31 this.list = _list;
32 inputSearch.onValueChanged.AddListener(Search);
33 inputSearch.onSubmit.AddListener(Search);
34 List<int> list = new List<int> { -1 };
35 foreach (FactionBranch child in EMono.pc.faction.GetChildren())
36 {
37 list.Add(child.owner.uid);
38 }
39 dropdown.SetList(0, list, delegate(int a, int i)
40 {
41 object obj;
42 if (a != -1)
43 {
44 obj = EMono.game.spatials.Find(a)?.Name;
45 if (obj == null)
46 {
47 return "???";
48 }
49 }
50 else
51 {
52 obj = "all".lang();
53 }
54 return (string)obj;
55 }, delegate(int i, int a)
56 {
57 SE.ClickOk();
58 uidFilterZone = a;
59 this.list.List();
60 });
61 this.list.list.funcFilter = FuncFilter;
62 }
63
64 private void LateUpdate()
65 {
66 if (!disable && timerSearch > 0f)
67 {
69 if (timerSearch <= 0f)
70 {
71 Search(inputSearch.text);
72 }
73 }
74 }
75
76 public bool FuncFilter(object _c)
77 {
78 Chara chara = _c as Chara;
79 if (uidFilterZone != -1 && (chara.homeZone == null || chara.homeZone.uid != uidFilterZone))
80 {
81 return false;
82 }
83 if (!lastSearch.IsEmpty() && !chara.NameBraced.ToLower().Contains(lastSearch))
84 {
85 return false;
86 }
87 return true;
88 }
89
90 public void Search(string s)
91 {
92 s = s.ToLower();
93 if (s.IsEmpty())
94 {
95 s = "";
96 }
97 buttonClearSearch.SetActive(inputSearch.text != "");
98 if (!(s == lastSearch))
99 {
101 lastSearch = s;
102 Redraw();
103 }
104 }
105
106 public void ClearSearch()
107 {
108 inputSearch.text = "";
109 timerSearch = 0f;
110 lastSearch = "";
111 Redraw();
112 }
113
114 public void Redraw()
115 {
116 list.List();
117 }
118}
Definition: Chara.cs:10
Faction faction
Definition: Chara.cs:429
string NameBraced
Definition: Chara.cs:516
Zone homeZone
Definition: Chara.cs:269
Definition: Core.cs:14
static float delta
Definition: Core.cs:17
Definition: EMono.cs:4
static Chara pc
Definition: EMono.cs:13
static Game game
Definition: EMono.cs:7
List< FactionBranch > GetChildren()
Definition: FACTION.cs:202
SpatialManager spatials
Definition: Game.cs:153
virtual void List()
Definition: ListOwner.cs:77
Zone Find(string id)
int uid
Definition: Spatial.cs:70
ListOwner list
UIButton buttonClearSearch
void Search(string s)
void Init(ListOwner _list)
UIDropdown dropdown
bool FuncFilter(object _c)
InputField inputSearch