14 return ELayer.player.hoard;
19 public override void OnAfterInit()
21 if (this.hoard.items.Count == 0)
23 this.hoard.Add(
"gold", 1,
false);
32 this.list.callbacks =
new UIList.Callback<
Hoard.
Item, UIButton>
34 onClick = delegate(
Hoard.
Item a, UIButton b)
37 if (this.onClick !=
null)
45 UIContextMenu uicontextMenu =
ELayer.ui.contextMenu.Create(
"ContextHoard",
true);
47 if (max > 1 && a.IsUnique)
51 uicontextMenu.AddSlider(
"display", (
float n) => n.ToString() +
" / " + max.ToString(), (
float)a.show, delegate(
float v)
55 this.RefreshInfo(b,
true);
56 }, 0f, (float)max,
true,
false,
false);
57 uicontextMenu.AddToggle(
"displayRandom", a.random, delegate(
bool on)
61 uicontextMenu.Show(EInput.uiMousePosition +
this.contextFix);
63 onInstantiate = delegate(
Hoard.
Item a, UIButton b)
70 if (this.hoard.items.ContainsKey(row.id))
72 this.list.Add(this.hoard.items[row.id]);
75 this.list.Refresh(
false);
76 this.selected = (this.list.buttons[0].component as UIButton);
77 this.RefreshInfo(this.selected,
false);
83 UIButton componentOf = InputModuleEX.GetComponentOf<UIButton>();
84 if (componentOf && componentOf.refObj is
Hoard.
Item)
86 this.RefreshInfo(componentOf,
false);
89 this.RefreshInfo(this.selected,
false);
93 public void SetButton(
Hoard.
Item a, UIButton b)
95 string text = a.num.ToString() ??
"";
98 text = text +
" (" + a.show.ToString() +
")";
100 b.mainText.text = text;
101 b.icon.sprite = this.hoard.GetSprite(a.id);
102 b.icon.SetNativeSize();
107 public void RefreshInfo(UIButton button,
bool force =
false)
109 if (!force && (this.lastShown == button || !button))
114 string text =
"collectibleTitle".lang(item.Source.GetName(), item.num.ToString() ??
"", item.show.ToString() ??
"",
null,
null);
119 this.textName.text = text;
120 this.textDetail.text = item.Source.GetText(
"detail",
true).IsEmpty(
"none".lang());
121 this.imageItem.sprite = this.hoard.GetSprite(item.id);
122 this.imageItem.SetNativeSize();
123 this.lastShown = button;
130 public UIText textName;
133 public UIText textDetail;
136 public UIButton selected;
139 public UIButton lastShown;
142 public Image imageItem;
145 public Vector3 contextFix;