2using System.Collections.Generic;
135 public List<Tab>
tabs =
new List<Tab>();
182 case Mode.HoldFurniture:
195 CurrencyType.Medal =>
"medal",
196 CurrencyType.Ecopo =>
"ecopo",
197 CurrencyType.Money3 =>
"money3",
204 for (
int i = 0; i < componentsInChildren.Length; i++)
212 window.SetCaption(s.lang());
217 return AddTab(
new InvOwner(c, container), mode);
235 foreach (
Tab t
in tabs)
248 tab.customTab = moldSmallTab;
251 if ((
bool)layer.mini)
253 layer.mini.SetActive(owner.Container.isChara);
254 if (owner.Container.isChara)
256 layer.mini.SetChara(owner.Container.Chara);
261 uiMagic.SetActive(IsMagicChest);
269 TooltipManager.Instance.disableTimer = 0.1f;
275 if (window.saveData ==
null)
279 useBG = EMono.core.config.game.showInvBG
282 window.setting.allowMove = !window.saveData.
fixedPos;
283 window.bgCollider.raycastTarget = !window.saveData.fixedPos || window.saveData.useBG;
284 window.imageBG.SetActive(UseBG);
288 window.imageBG.sprite = inventoryStyle.
bg;
289 window.imageBG.rectTransform.anchoredPosition = inventoryStyle.
posFix;
290 window.imageBG.rectTransform.sizeDelta = inventoryStyle.
sizeDelta;
291 window.imageBG.alphaHitTestMinimumThreshold = 1f;
295 window.cgFloatMenu.SetActive(enable:
false);
296 window.cgFloatMenu =
null;
297 window.bgCollider.rectTransform.anchoredPosition =
new Vector2(-2.5f, 0f);
298 window.bgCollider.rectTransform.sizeDelta =
new Vector2(-20f, -20f);
302 window.cgFloatMenu.alpha = 1f;
303 window.cgFloatMenu.enabled =
false;
304 window.cgFloatMenu.SetActive(enable:
true);
318 if (currentTab == tab)
324 destNum = (lastNum = (DestNumIsMax() ? (-1) : 0));
333 if (IsShop || window.saveData.alwaysSort)
337 if ((
bool)layer.uiCurrency)
343 UIHeader[] componentsInChildren = headerRow.GetComponentsInChildren<
UIHeader>(includeInactive:
true);
344 componentsInChildren[0].
SetText(
"headerItem");
350 componentsInChildren[1].
SetText(
"headerPrice".lang(IDCurrency.lang()));
353 componentsInChildren[1].
SetText(
"headerWeight");
356 componentsInChildren[1].
SetText(
"headerRecycle");
375 currentAct = act as
AIAct;
386 if (owner.Container.isDestroyed)
395 buttonTakeAll.onClick.Invoke();
397 if ((IsMagicChest || window.saveData.alwaysSort) && wasDirty && (Input.GetMouseButtonUp(1) || Input.GetKeyUp(KeyCode.LeftShift) || Input.GetKeyUp(KeyCode.RightShift)))
400 if (!Input.GetMouseButton(1) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift))
406 if (Input.GetMouseButtonDown(1))
408 firstMouseRightDown =
true;
434 if (destNum != lastNum)
444 Mode mode = currentTab.mode;
445 if ((uint)(mode - 2) <= 1u)
458 b.onClick.RemoveAllListeners();
459 b.onClick.AddListener(delegate
462 uIContextMenu.layoutGroup.childAlignment = TextAnchor.UpperLeft;
463 uIContextMenu.alwaysPopLeft =
true;
468 UIList.SortMode _sort = sortMode;
469 uIContextMenu2.AddButton((((IsShop ? EMono.player.pref.sortInvShop : (IsAdvSort ? data.sortMode : EMono.player.pref.sortInv)) == _sort) ?
"context_checker".lang() :
"") + _sort.ToString().lang(), delegate
473 EMono.player.pref.sortInvShop = _sort;
477 EMono.player.pref.sortInv = _sort;
479 data.sortMode = _sort;
488 EMono.player.pref.sort_ascending_shop = a;
492 EMono.player.pref.sort_ascending = a;
494 data.sort_ascending = a;
500 uIContextMenu2.AddToggle(
"sort_always", data.
alwaysSort, delegate(
bool a)
516 uIContextMenu3.
AddButton(((data.
category ==
item) ?
"context_checker".lang() :
"") + (
"catFilterType_" + _c).lang(), delegate
525 Card con2 = owner.Container;
540 dis = uIContextMenu.
AddChild(
"distribution", TextAnchor.UpperRight);
541 dis.
AddSlider(
"priority_hint", (
float a) => a.ToString() ??
"", data.
priority, delegate(
float a)
543 data.priority = (int)a;
544 }, -5f, 20f, isInt:
true, hideOther:
false);
545 dist = ShowDistribution(dis, data);
546 distAdv = ShowAdvDistribution(dis, data);
552 data.onlyRottable = a;
563 data.advDistribution = a;
575 data._filterStrs =
null;
589 dis2 = uIContextMenu.
AddChild(
"autopick", TextAnchor.UpperRight);
590 dist2 = ShowDistribution(dis2, data2);
591 distAdv2 = ShowAdvDistribution(dis2, data2);
600 data2.advDistribution = a;
612 data2._filterStrs =
null;
630 string text = ((data.autodump == item2) ?
"context_checker".lang() :
"");
632 UIButton uIButton = uIContextMenu4.AddButton(text + (
"dump_" + item2).lang(), delegate
648 data.excludeCraft = a;
655 data.excludeDump = a;
665 data.noRightClickClose = a;
684 data.shiftToShowMenu = a;
693 EMono.player.openContainerCenter = a;
699 uIContextMenu5.
AddButton(
"changeName", delegate
705 con2.c_altName = c_altName;
712 uIContextMenu5.
AddButton(
"copyContainer", delegate
715 EMono.player.windowDataCopy = IO.DeepCopy(data);
716 EMono.player.windowDataName = con2.
Name;
734 data.color = InvStyle.gridColor;
739 uIContextMenu6.
AddSlider(
"size", (
float a) => a.ToString() ??
"", data.
size, delegate(
float num)
741 data.size = (int)num;
743 }, -25f, 25f, isInt:
true, hideOther:
false);
746 uIContextMenu6.
AddSlider(
"columns", (
float a) => a.ToString() ??
"", data.
columns, delegate(
float num)
748 data.columns = (int)num;
752 uIContextMenu6.
AddButton(
"colorGrid", delegate
757 list.bgGrid.color = color;
758 if (data.
color.a == 0)
760 list.bgGrid.color = InvStyle.gridColor;
766 uIContextMenu6.
AddButton(
"changeIcon", delegate
768 EMono.
ui.contextMenu.currentMenu.Hide();
775 UIButton uIButton2 =
Util.Instantiate<
UIButton>(
"UI/Element/Button/ButtonContainerIcon", parent);
778 uIButton2.SetOnClick(delegate
781 owner.Container.c_indexContainerIcon = _i;
783 EMono.
ui.contextMenu.currentMenu.Hide();
787 uIContextMenu9.Show();
797 data.customAnchor = p;
798 window.UpdateSaveData();
808 EMono.core.config.game.useGrid = a;
811 item4.
invs[0].RefreshWindow();
812 item4.
invs[0].RefreshGrid();
817 EMono.game.config.gridIconSize = (int)num;
819 }, 100f, 150f, isInt:
true, hideOther:
false);
821 uIContextMenu.Show();
822 uIContextMenu.hideOnMouseLeave =
false;
837 b = window.buttonQuickSort;
840 b.onClick.RemoveAllListeners();
841 b.onClick.AddListener(delegate
847 b = window.buttonExtra;
850 b.SetActive(owner.Container.IsPC);
851 b.onClick.RemoveAllListeners();
852 b.onClick.AddListener(delegate
857 b = window.buttonShared;
860 Card con = owner.Container;
865 RefreshShareButton();
866 b.SetOnClick(delegate
870 Msg.
Say(
"changePermission", con, (flag2 ?
"stPersonal" :
"stShared").lang());
872 RefreshShareButton();
876 Mode mode = currentTab.mode;
882 if (owner.Container.isNPCProperty || owner.Container.isChara || IsMagicChest)
888 owner.Container.things.ForeachReverse(delegate(
Thing t)
892 EMono.pc.Pick(t, msg: false);
895 if (owner.Container.things.Count > 0)
901 SE.Play(
"pick_thing");
908 Card _owner = owner.owner;
931 Msg.
Say(
"notEnoughInfluence");
934 EMono._zone.influence -= cost;
937 _owner.c_dateStockExpire = 0;
941 SE.Play(
"shop_open");
943 },
null,
"DefaultContentFit").RebuildLayout();
947 void RefreshShareButton()
951 b.tooltip.lang = (flag2 ?
"hintShared" :
"hintPrivate");
958 List<UIContextMenuItem> items =
new List<UIContextMenuItem>();
962 GridLayoutGroup gridLayoutGroup = dis.
AddGridLayout(
"Context_LayoutDistribution");
963 itemAll = dis.
AddToggle(
"all", isOn:
false, delegate(
bool a)
967 item.toggle.isOn = a;
975 items.Add(dis.AddToggle(row.GetName(), !data.
flag.HasFlag(f), delegate(
bool a)
982 itemAll.transform.SetParent(gridLayoutGroup.transform);
983 itemAll.GetComponentInChildren<
UIText>().SetText(
"all".lang(),
FontColor.Topic);
986 item2.transform.SetParent(gridLayoutGroup.transform);
989 return gridLayoutGroup.transform;
992 bool isOnWithoutNotify =
true;
997 isOnWithoutNotify =
false;
1000 itemAll.toggle.SetIsOnWithoutNotify(isOnWithoutNotify);
1004 if (!on && data.flag.HasFlag(containerFlag))
1006 data.flag &= ~containerFlag;
1008 else if (on && !data.flag.HasFlag(containerFlag))
1010 data.flag |= containerFlag;
1019 return dis.AddGameObject(uIDistribution).transform;
1022 public void Sort(
bool redraw =
true)
1030 Dictionary<string, List<Thing>> dict =
new Dictionary<string, List<Thing>>();
1031 foreach (
Thing t
in owner.Container.
things.Copy())
1037 List<Thing> orCreate = dict.GetOrCreate(t.
id + t.
GetStr(53));
1039 for (
int num = 0; num < orCreate.Count; num++)
1041 if (orCreate[num].TryStackTo(t))
1066 if (thing.
invY != 1)
1078 Vector2 sizeDelta = list.Rect().sizeDelta;
1083 if (thing2.
invY != 0)
1087 thing2.posInvX = num3 + 30;
1088 thing2.posInvY = (int)sizeDelta.y - num4 + 30;
1090 if ((
float)num3 > sizeDelta.x)
1094 if ((
float)num4 > sizeDelta.y)
1110 Mode mode = currentTab.mode;
1111 _ = currentTab.subMode;
1129 if (actionClick !=
null)
1143 bool flag = mode == Mode.Buy || mode == Mode.Sell || mode ==
Mode.Identify;
1144 int num = ((destNum != -1) ? 1 : a.
Num);
1147 if (mode ==
Mode.Identify)
1154 if ((uint)(mode2 - 2) <= 1u)
1170 List<Thing> list =
new List<Thing>();
1171 foreach (
Thing thing
in owner.Things)
1173 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)))
1182 num +=
item.ChildrenAndSelfWeight;
1183 this.list.Add(
item);
1186 text =
"statsInv".lang(owner.Container.things.Count.ToString() ??
"",
this.list.ItemCount.ToString() ??
"",
Lang.
_weight(num));
1187 layer.windows[0].textStats.SetText(text);
1191 list.callbacks = callbacks;
1197 if (!imageHighlight)
1201 imageHighlight.SetActive(enable:
false);
1205 if (currentTab.mode ==
Mode.All && thing !=
null && !thing.
isDestroyed)
1208 _ = owner.Container;
1215 _ = currentTab.mode;
1216 _ = currentTab.subMode;
1219 GridLayoutGroup g = list.GetComponent<GridLayoutGroup>();
1220 ContentSizeFitter component = list.GetComponent<ContentSizeFitter>();
1223 g.constraintCount = ((window.saveData.columns == 0) ? owner.Container.things.width : window.saveData.columns);
1224 Vector2 cellSize = style.gridSize * (100 + window.saveData.size) / 100f;
1225 g.cellSize = cellSize;
1226 GridLayoutGroup gridLayoutGroup = g;
1227 bool flag = (component.enabled =
true);
1228 gridLayoutGroup.enabled = flag;
1232 GridLayoutGroup gridLayoutGroup2 = g;
1233 bool flag = (component.enabled =
false);
1234 gridLayoutGroup2.enabled = flag;
1238 int maxCapacity = (IsMagicChest ? owner.Container.things.MaxCapacity : 0);
1244 bool flag4 = i >= owner.Things.Count;
1247 flag4 = uiMagic.page * uiMagic.GridSize + i >= maxCapacity;
1261 b.
icon.Rect().localScale =
new Vector3(num, num, 1f);
1262 b.Rect().sizeDelta = b.
icon.rectTransform.sizeDelta;
1266 b.interactable =
false;
1267 b.image.sprite =
null;
1268 b.image.color =
new Color32(
byte.MaxValue,
byte.MaxValue,
byte.MaxValue, 120);
1269 b.image.raycastTarget =
true;
1273 b.image.raycastTarget =
true;
1278 list.bgType = (UseGrid ? UIList.BGType.grid :
UIList.
BGType.none);
1279 if ((
bool)list.bgGrid)
1281 list.bgGrid.SetActive(UseGrid);
1283 if (window.saveData.color.a != 0)
1285 list.bgGrid.color = window.saveData.color;
1290 owner.Container.things.RefreshGrid(uiMagic, window.saveData);
1294 owner.Container.things.RefreshGrid();
1300 for (
int i = 0; i < owner.Container.things.GridSize; i++)
1302 list.Add(owner.Things[i]);
1307 int count = owner.Things.Count;
1308 int num = (int)Mathf.Ceil(count / g.constraintCount + ((count % g.constraintCount != 0) ? 1 : 0)) * g.constraintCount;
1309 for (
int j = 0; j < num; j++)
1311 list.Add((j < count) ? owner.Things[j] :
null);
1317 Vector2 sizeDelta2 = list.Rect().sizeDelta;
1318 foreach (
Thing thing2
in owner.Things)
1325 thing2.posInvX =
EMono.
rnd((
int)sizeDelta2.x - 60) + 30;
1326 thing2.posInvY =
EMono.
rnd((
int)sizeDelta2.y - 60) + 30;
1333 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"));
1337 bool sorted =
false;
1338 list.callbacks = callback;
1339 list.onBeforeRedraw = delegate
1343 if (firstMouseRightDown || (!Input.GetMouseButton(1) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift)))
1347 Sort(redraw:
false);
1349 firstMouseRightDown =
false;
1350 owner.Container.things.RefreshGrid(uiMagic, window.saveData);
1355 if (window.saveData.alwaysSort && sortDirty && !sorted && (firstMouseRightDown || (!Input.GetMouseButton(1) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift))))
1360 firstMouseRightDown =
false;
1362 owner.Container.things.RefreshGrid();
1368 for (
int i = 0; i < uIList.
buttons.Count; i++)
1371 value.obj = ((i < owner.Container.things.grid.Count) ? owner.Container.things.grid[i] :
null);
1376 list.onAfterRedraw = delegate
1378 if (!layer.floatInv)
1389 text =
"statsInv2".lang(owner.Container.things.Count.ToString() ??
"", list.ItemCount.ToString() ??
"",
Lang.
_weight(num) +
"/" +
Lang.
_weight(owner.Container.WeightLimit));
1390 layer.windows[0].textStats.SetText(text);
1392 if (owner.Container.things.IsOverflowing())
1396 transOverflow =
Util.Instantiate(
"UI/Element/Other/InvOverflow", window.transform);
1399 else if ((
bool)transOverflow)
1401 UnityEngine.Object.Destroy(transOverflow.gameObject);
1404 if ((
bool)layer.mini)
1406 layer.mini.Refresh(layer.mini.window.idTab);
1410 uiMagic.OnAfterRedraw();
1414 callback.mold = (UseGrid ? moldButtonGrid : moldButtonGridless);
1415 if (!UseGrid && !window.saveData.firstSorted)
1417 Vector2 sizeDelta = list.Rect().sizeDelta;
1418 foreach (
Thing thing3
in owner.Things)
1422 thing3.posInvX =
EMono.
rnd((
int)sizeDelta.x - 60) + 30;
1423 thing3.posInvY =
EMono.
rnd((
int)sizeDelta.y - 60) + 30;
1426 window.saveData.firstSorted =
true;
1429 g.RebuildLayoutTo<
Layer>();
1430 list.onAfterRedraw();
1431 if ((
bool)list.bgGrid)
1434 if (window.saveData.color.a != 0)
1436 list.bgGrid.color = window.saveData.color;
void SetTurbo(int mtp=-1)
int GetCurrency(string id="money")
string GetStr(string id, string defaultStr=null)
void ModCurrency(int a, string id="money")
bool TryStackTo(Thing to)
int ChildrenAndSelfWeight
Thing Add(string id, int num=1, int lv=1)
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)
List< ButtonGrid > buttons
static LayerDragGrid Instance
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)
override int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
virtual string IDInvStyle
virtual int CostRerollShop
virtual void OnBarter(bool reroll=false)
virtual CurrencyType CurrencyRerollShop
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