2using System.Collections.Generic;
133 public List<Tab>
tabs =
new List<Tab>();
180 case Mode.HoldFurniture:
193 CurrencyType.Medal =>
"medal",
194 CurrencyType.Ecopo =>
"ecopo",
201 for (
int i = 0; i < componentsInChildren.Length; i++)
209 window.SetCaption(s.lang());
214 return AddTab(
new InvOwner(c, container), mode);
232 foreach (
Tab t
in tabs)
245 tab.customTab = moldSmallTab;
248 if ((
bool)layer.mini)
250 layer.mini.SetActive(owner.Container.isChara);
251 if (owner.Container.isChara)
253 layer.mini.SetChara(owner.Container.Chara);
258 uiMagic.SetActive(IsMagicChest);
266 TooltipManager.Instance.disableTimer = 0.1f;
272 if (window.saveData ==
null)
276 useBG = EMono.core.config.game.showInvBG
279 window.setting.allowMove = !window.saveData.
fixedPos;
280 window.bgCollider.raycastTarget = !window.saveData.fixedPos || window.saveData.useBG;
281 window.imageBG.SetActive(UseBG);
285 window.imageBG.sprite = inventoryStyle.
bg;
286 window.imageBG.rectTransform.anchoredPosition = inventoryStyle.
posFix;
287 window.imageBG.rectTransform.sizeDelta = inventoryStyle.
sizeDelta;
288 window.imageBG.alphaHitTestMinimumThreshold = 1f;
292 window.cgFloatMenu.SetActive(enable:
false);
293 window.cgFloatMenu =
null;
294 window.bgCollider.rectTransform.anchoredPosition =
new Vector2(-2.5f, 0f);
295 window.bgCollider.rectTransform.sizeDelta =
new Vector2(-20f, -20f);
299 window.cgFloatMenu.alpha = 1f;
300 window.cgFloatMenu.enabled =
false;
301 window.cgFloatMenu.SetActive(enable:
true);
315 if (currentTab == tab)
321 destNum = (lastNum = (DestNumIsMax() ? (-1) : 0));
330 if (IsShop || window.saveData.alwaysSort)
334 if ((
bool)layer.uiCurrency)
338 layer.TryShowHint(
"h_inv" + tab.
mode);
341 UIHeader[] componentsInChildren = headerRow.GetComponentsInChildren<
UIHeader>(includeInactive:
true);
342 componentsInChildren[0].
SetText(
"headerItem");
348 componentsInChildren[1].
SetText(
"headerPrice".lang(IDCurrency.lang()));
351 componentsInChildren[1].
SetText(
"headerWeight");
354 componentsInChildren[1].
SetText(
"headerRecycle");
373 currentAct = act as
AIAct;
384 if (owner.Container.isDestroyed)
393 buttonTakeAll.onClick.Invoke();
395 if ((IsMagicChest || window.saveData.alwaysSort) && wasDirty && (Input.GetMouseButtonUp(1) || Input.GetKeyUp(KeyCode.LeftShift) || Input.GetKeyUp(KeyCode.RightShift)))
398 if (!Input.GetMouseButton(1) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift))
404 if (Input.GetMouseButtonDown(1))
406 firstMouseRightDown =
true;
432 if (destNum != lastNum)
442 Mode mode = currentTab.mode;
443 if ((uint)(mode - 2) <= 1u)
456 b2.onClick.RemoveAllListeners();
457 b2.onClick.AddListener(delegate
460 uIContextMenu.layoutGroup.childAlignment = TextAnchor.UpperLeft;
461 uIContextMenu.alwaysPopLeft =
true;
466 UIList.SortMode _sort = sortMode;
467 uIContextMenu2.AddButton((((IsShop ? EMono.player.pref.sortInvShop : (IsAdvSort ? data.sortMode : EMono.player.pref.sortInv)) == _sort) ?
"context_checker".lang() :
"") + _sort.ToString().lang(), delegate
471 EMono.player.pref.sortInvShop = _sort;
475 EMono.player.pref.sortInv = _sort;
477 data.sortMode = _sort;
486 EMono.player.pref.sort_ascending_shop = a;
490 EMono.player.pref.sort_ascending = a;
492 data.sort_ascending = a;
498 uIContextMenu2.AddToggle(
"sort_always", data.
alwaysSort, delegate(
bool a)
514 uIContextMenu3.
AddButton(((data.
category ==
item) ?
"context_checker".lang() :
"") + (
"catFilterType_" + _c2).lang(), delegate
523 Card con2 = owner.Container;
538 dis2 = uIContextMenu.
AddChild(
"distribution", TextAnchor.UpperRight);
539 dis2.
AddSlider(
"priority_hint", (
float a) => a.ToString() ??
"", data.
priority, delegate(
float a)
541 data.priority = (int)a;
542 }, -5f, 20f, isInt:
true, hideOther:
false);
543 dist2 = ShowDistribution(dis2, data);
544 distAdv2 = ShowAdvDistribution(dis2, data);
550 data.onlyRottable = a;
561 data.advDistribution = a;
573 data._filterStrs =
null;
587 dis = uIContextMenu.
AddChild(
"autopick", TextAnchor.UpperRight);
588 dist = ShowDistribution(dis, data2);
589 distAdv = ShowAdvDistribution(dis, data2);
598 data2.advDistribution = a;
610 data2._filterStrs =
null;
628 string text2 = ((data.autodump == item2) ?
"context_checker".lang() :
"");
630 UIButton uIButton = uIContextMenu4.AddButton(text2 + (
"dump_" + item2).lang(), delegate
646 data.excludeCraft = a;
653 data.excludeDump = a;
663 data.noRightClickClose = a;
682 data.shiftToShowMenu = a;
691 EMono.player.openContainerCenter = a;
697 uIContextMenu5.
AddButton(
"changeName", delegate
703 con2.c_altName = text;
710 uIContextMenu5.
AddButton(
"copyContainer", delegate
713 EMono.player.windowDataCopy = IO.DeepCopy(data);
714 EMono.player.windowDataName = con2.
Name;
732 data.color = InvStyle.gridColor;
737 uIContextMenu6.
AddSlider(
"size", (
float a) => a.ToString() ??
"", data.
size, delegate(
float b)
741 }, -25f, 25f, isInt:
true, hideOther:
false);
744 uIContextMenu6.
AddSlider(
"columns", (
float a) => a.ToString() ??
"", data.
columns, delegate(
float b)
746 data.columns = (int)b;
748 }, 0f, 20f, isInt:
true, hideOther:
false);
750 uIContextMenu6.
AddButton(
"colorGrid", delegate
755 list.bgGrid.color = _c;
756 if (data.
color.a == 0)
758 list.bgGrid.color = InvStyle.gridColor;
764 uIContextMenu6.
AddButton(
"changeIcon", delegate
766 EMono.
ui.contextMenu.currentMenu.Hide();
773 UIButton uIButton2 =
Util.Instantiate<
UIButton>(
"UI/Element/Button/ButtonContainerIcon", parent);
776 uIButton2.SetOnClick(delegate
779 owner.Container.c_indexContainerIcon = _i;
781 EMono.
ui.contextMenu.currentMenu.Hide();
785 uIContextMenu9.Show();
795 data.customAnchor = p;
796 window.UpdateSaveData();
806 EMono.core.config.game.useGrid = a;
809 item4.
invs[0].RefreshWindow();
810 item4.
invs[0].RefreshGrid();
815 EMono.game.config.gridIconSize = (int)b;
817 }, 100f, 150f, isInt:
true, hideOther:
false);
819 uIContextMenu.Show();
820 uIContextMenu.hideOnMouseLeave =
false;
835 b2 = window.buttonQuickSort;
838 b2.onClick.RemoveAllListeners();
839 b2.onClick.AddListener(delegate
845 b2 = window.buttonExtra;
848 b2.SetActive(owner.Container.IsPC);
849 b2.onClick.RemoveAllListeners();
850 b2.onClick.AddListener(delegate
855 b2 = window.buttonShared;
858 Card con = owner.Container;
863 RefreshShareButton();
864 b2.SetOnClick(delegate
868 Msg.
Say(
"changePermission", con, (flag3 ?
"stPersonal" :
"stShared").lang());
870 RefreshShareButton();
874 Mode mode = currentTab.mode;
880 if (owner.Container.isNPCProperty || owner.Container.isChara || IsMagicChest)
886 owner.Container.things.ForeachReverse(delegate(
Thing t)
890 EMono.pc.Pick(t, msg: false);
893 if (owner.Container.things.Count > 0)
899 SE.Play(
"pick_thing");
906 Card _owner = owner.owner;
912 menuBottom.
AddButton(
"rerollShop".lang(cost.ToString() ??
""), delegate
917 Msg.
Say(
"notEnoughInfluence");
922 EMono._zone.influence -= cost;
923 _owner.c_dateStockExpire = 0;
927 SE.Play(
"shop_open");
933 void RefreshShareButton()
937 b2.tooltip.lang = (flag2 ?
"hintShared" :
"hintPrivate");
944 List<UIContextMenuItem> items =
new List<UIContextMenuItem>();
948 GridLayoutGroup gridLayoutGroup = dis.
AddGridLayout(
"Context_LayoutDistribution");
949 itemAll = dis.
AddToggle(
"all", isOn:
false, delegate(
bool a)
953 item.toggle.isOn = a;
961 items.Add(dis.AddToggle(row.GetName(), !data.
flag.HasFlag(f2), delegate(
bool a)
968 itemAll.transform.SetParent(gridLayoutGroup.transform);
969 itemAll.GetComponentInChildren<
UIText>().SetText(
"all".lang(),
FontColor.Topic);
972 item2.transform.SetParent(gridLayoutGroup.transform);
975 return gridLayoutGroup.transform;
978 bool isOnWithoutNotify =
true;
983 isOnWithoutNotify =
false;
986 itemAll.toggle.SetIsOnWithoutNotify(isOnWithoutNotify);
990 if (!on && data.flag.HasFlag(f))
994 else if (on && !data.flag.HasFlag(f))
1005 return dis.AddGameObject(uIDistribution).transform;
1008 public void Sort(
bool redraw =
true)
1017 if (thing.
invY == 1)
1023 if (thing != thing2 && thing2.
invY != 1 && thing.
TryStackTo(thing2))
1038 if (thing3.
invY != 1)
1050 Vector2 sizeDelta = list.Rect().sizeDelta;
1055 if (thing4.
invY != 0)
1059 thing4.posInvX = num2 + 30;
1060 thing4.posInvY = (int)sizeDelta.y - num3 + 30;
1062 if ((
float)num2 > sizeDelta.x)
1066 if ((
float)num3 > sizeDelta.y)
1081 Mode mode = currentTab.mode;
1082 _ = currentTab.subMode;
1100 if (actionClick !=
null)
1114 bool flag = mode == Mode.Buy || mode == Mode.Sell || mode ==
Mode.Identify;
1115 int num2 = ((destNum != -1) ? 1 : a.
Num);
1118 if (mode ==
Mode.Identify)
1125 if ((uint)(mode2 - 2) <= 1u)
1141 List<Thing> list =
new List<Thing>();
1142 foreach (
Thing thing
in owner.Things)
1144 if (thing !=
null && (funcList ==
null || funcList(thing)) && !thing.
HasTag(
CTAG.noDrop) && (thing.
c_equippedSlot == 0 || mode ==
Mode.Equip || mode ==
Mode.Identify) && (!(thing.
category.id ==
"currency") || (mode !=
Mode.Buy && mode !=
Mode.Sell)))
1153 num +=
item.ChildrenAndSelfWeight;
1154 this.list.Add(
item);
1157 text =
"statsInv".lang(owner.Container.things.Count.ToString() ??
"",
this.list.ItemCount.ToString() ??
"",
Lang.
_weight(num));
1158 layer.windows[0].textStats.SetText(text);
1162 list.callbacks = callbacks;
1168 if (!imageHighlight)
1172 imageHighlight.SetActive(enable:
false);
1176 if (currentTab.mode ==
Mode.All && thing !=
null && !thing.
isDestroyed)
1179 _ = owner.Container;
1186 _ = currentTab.mode;
1187 _ = currentTab.subMode;
1190 GridLayoutGroup g = list.GetComponent<GridLayoutGroup>();
1191 ContentSizeFitter component = list.GetComponent<ContentSizeFitter>();
1194 g.constraintCount = ((window.saveData.columns == 0) ? owner.Container.things.width : window.saveData.columns);
1195 Vector2 cellSize = style.gridSize * (100 + window.saveData.size) / 100f;
1196 g.cellSize = cellSize;
1197 GridLayoutGroup gridLayoutGroup = g;
1198 bool flag2 = (component.enabled =
true);
1199 gridLayoutGroup.enabled = flag2;
1203 GridLayoutGroup gridLayoutGroup2 = g;
1204 bool flag2 = (component.enabled =
false);
1205 gridLayoutGroup2.enabled = flag2;
1209 int maxCapacity = (IsMagicChest ? owner.Container.things.MaxCapacity : 0);
1215 bool flag4 = i >= owner.Things.Count;
1218 flag4 = uiMagic.page * uiMagic.GridSize + i >= maxCapacity;
1232 b.
icon.Rect().localScale =
new Vector3(num3, num3, 1f);
1233 b.Rect().sizeDelta = b.
icon.rectTransform.sizeDelta;
1237 b.interactable =
false;
1238 b.image.sprite =
null;
1239 b.image.color =
new Color32(
byte.MaxValue,
byte.MaxValue,
byte.MaxValue, 120);
1240 b.image.raycastTarget =
true;
1244 b.image.raycastTarget =
true;
1249 list.bgType = (UseGrid ? UIList.BGType.grid :
UIList.
BGType.none);
1250 if ((
bool)list.bgGrid)
1252 list.bgGrid.SetActive(UseGrid);
1254 if (window.saveData.color.a != 0)
1256 list.bgGrid.color = window.saveData.color;
1261 owner.Container.things.RefreshGrid(uiMagic, window.saveData);
1265 owner.Container.things.RefreshGrid();
1271 for (
int k = 0; k < owner.Container.things.GridSize; k++)
1273 list.Add(owner.Things[k]);
1278 int count = owner.Things.Count;
1279 int num2 = (int)Mathf.Ceil(count / g.constraintCount + ((count % g.constraintCount != 0) ? 1 : 0)) * g.constraintCount;
1280 for (
int l = 0; l < num2; l++)
1282 list.Add((l < count) ? owner.Things[l] :
null);
1288 Vector2 sizeDelta2 = list.Rect().sizeDelta;
1289 foreach (
Thing thing2
in owner.Things)
1296 thing2.posInvX =
EMono.
rnd((
int)sizeDelta2.x - 60) + 30;
1297 thing2.posInvY =
EMono.
rnd((
int)sizeDelta2.y - 60) + 30;
1304 window.setting.tabs[0].idLang =
"captionInvFloat".lang(owner.Container.IsPC ?
"" : owner.Container.Name, ((
float)owner.Container.ChildrenWeight / 1000f).ToString(
"F1") +
"/" + ((float)owner.Container.WeightLimit / 1000f).ToString(
"F1"));
1308 bool sorted =
false;
1309 list.callbacks = callback;
1310 list.onBeforeRedraw = delegate
1314 if (firstMouseRightDown || (!Input.GetMouseButton(1) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift)))
1316 Sort(redraw:
false);
1317 firstMouseRightDown =
false;
1318 owner.Container.things.RefreshGrid(uiMagic, window.saveData);
1323 if (window.saveData.alwaysSort && !sorted && (firstMouseRightDown || (!Input.GetMouseButton(1) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift))))
1328 firstMouseRightDown =
false;
1330 owner.Container.things.RefreshGrid();
1336 for (
int j = 0; j < uIList.
buttons.Count; j++)
1339 value.obj = ((j < owner.Container.things.grid.Count) ? owner.Container.things.grid[j] :
null);
1344 list.onAfterRedraw = delegate
1346 if (!layer.floatInv)
1353 num += thing.ChildrenAndSelfWeight;
1357 text =
"statsInv2".lang(owner.Container.things.Count.ToString() ??
"", list.ItemCount.ToString() ??
"",
Lang.
_weight(num) +
"/" +
Lang.
_weight(owner.Container.WeightLimit));
1358 layer.windows[0].textStats.SetText(text);
1360 if (owner.Container.things.IsOverflowing())
1364 transOverflow =
Util.Instantiate(
"UI/Element/Other/InvOverflow", window.transform);
1367 else if ((
bool)transOverflow)
1369 UnityEngine.Object.Destroy(transOverflow.gameObject);
1372 if ((
bool)layer.mini)
1374 layer.mini.Refresh(layer.mini.window.idTab);
1378 uiMagic.OnAfterRedraw();
1382 callback.mold = (UseGrid ? moldButtonGrid : moldButtonGridless);
1383 if (!UseGrid && !window.saveData.firstSorted)
1385 Vector2 sizeDelta = list.Rect().sizeDelta;
1386 foreach (
Thing thing3
in owner.Things)
1390 thing3.posInvX =
EMono.
rnd((
int)sizeDelta.x - 60) + 30;
1391 thing3.posInvY =
EMono.
rnd((
int)sizeDelta.y - 60) + 30;
1394 window.saveData.firstSorted =
true;
1397 g.RebuildLayoutTo<
Layer>();
1398 list.onAfterRedraw();
1399 if ((
bool)list.bgGrid)
1402 if (window.saveData.color.a != 0)
1404 list.bgGrid.color = window.saveData.color;
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
void SetTurbo(int mtp=-1)
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
int GetCurrency(string id="money")
bool TryStackTo(Thing to)
SourceCategory.Row category
void HoldCard(Card t, int num=-1)
List< Sprite > spritesContainerIcon
static Dialog InputName(string langDetail, string text, Action< bool, string > onClose, InputType inputType=InputType.Default)
static SourceManager sources
virtual void BuildUICurrency(UICurrency uiCurrency, bool canReroll=false)
static string _weight(int a, int b, bool showUnit=true, int unitSize=0)
static string _currency(object a, string IDCurrency)
static InvOwner highlightInv
static void SetDirty(Thing t)
static void SetDirtyAll(bool immediate=false)
static List< LayerInventory > listInv
static void TryShowGuide(UIList list)
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
UIInventory.InteractMode interactMode
Window.SaveData windowDataCopy
SourceCategory categories
static Sprite Get(string id)
virtual string IDInvStyle
void OnBarter(bool reroll=false)
virtual int CostRerollShop
virtual bool IsSpecialContainer
bool TryGetValue(TKey key, out TValue value)
void SetContainer(Card t, Window.SaveData d)
CoreRef.InventoryStyle InvStyle
static void RefreshAllList()
Transform ShowAdvDistribution(UIContextMenu dis, Window.SaveData data)
void Sort(bool redraw=true)
ButtonGrid moldButtonGrid
Transaction lastTransaction
Tab AddTab(InvOwner owner, Mode mode=Mode.All)
Func< Thing, bool > funcList
InteractMode interactMode
ButtonGrid moldButtonGridless
Transform ShowDistribution(UIContextMenu dis, Window.SaveData data)
Tab AddTab(Card c, Mode mode, Thing container=null)
Action< Thing > actionClick
List< ButtonPair > buttons
void Space(int sizeY=0, int sizeX=1)
RectPosition customAnchor
static Dictionary< string, SaveData > dictData