2using System.Collections.Generic;
33 public List<Transform>
listAttach =
new List<Transform>();
58 public T
Attach<T>(
string id,
bool rightAttach =
true) where T : Component
60 return Attach(
id, rightAttach).GetComponent<T>();
63 public Transform
Attach(
string id,
bool rightAttach =
true)
65 Transform transform =
PoolManager.
Spawn<Transform>(
"attach_" + id,
"UI/Element/Grid/Attach/" + id, base.transform);
69 RectTransform rectTransform = transform.Rect();
70 rectTransform.anchoredPosition =
new Vector2(rectTransform.anchoredPosition.x, -8 - 8 *
rightAttachCount);
71 transform.tag =
"RightAttach";
80 listAttach.ForeachReverse(delegate(Transform t)
84 if (t.tag.Contains(
"RightAttach"))
96 base.image.color =
Color.white;
97 if (listAttach.Count > 0)
99 foreach (Transform
item in listAttach)
109 rightAttachCount = 0;
114 if (listAttach.Count > 0)
118 rightAttachCount = 0;
123 SetCardGrid(b.
thing, owner);
125 imageCheck.SetNativeSize();
126 imageCheck.SetAlpha((b.
thing ==
null) ? 1f : 0.4f);
135 subText.SetActive(enable:
false);
142 SetCardGrid(
card, invOwner);
153 base.interactable =
true;
157 invOwner?.OnWriteNote(
this, n);
159 onRightClick = delegate
161 if (
EClass.
ui.AllowInventoryInteractions && invOwner !=
null)
163 InvOwner.clickTimer = 0f;
164 invOwner.OnRightClick(
this);
165 UIButton.onPressed = delegate
167 invOwner.OnRightPressed(
this);
173 this.SetOnClick(delegate
175 if (
EClass.
ui.AllowInventoryInteractions)
177 invOwner?.OnClick(this);
179 UIButton.TryShowTip();
189 bool showNew = invOwner?.ShowNew ??
false;
192 if (mode !=
Mode.Ingredient)
206 icon.SetNativeSize();
207 if (invOwner ==
null || !invOwner.AlwaysShowTooltip || onWriteNote ==
null)
209 SetTooltip(
null, enable:
false);
229 t.
note.
AddText(
"mark_ing".lang() + (ing.optional ?
"opIngredient" :
"reqIng").lang(ing.GetName()));
239 Attach<Image>(
"target_self").sprite = (c.trait as
TraitAbility).act.TargetType.IconType;
244 if (refElement !=
null)
248 Image image = Attach<Image>(
"reficon", rightAttach:
false);
257 Image obj = Attach<Image>(
"reficon", rightAttach:
false);
258 obj.sprite = refSprite;
259 obj.color =
Color.white;
267 if (c.
c_equippedSlot != 0 && invOwner !=
null && invOwner.owner.isChara && !invOwner.owner.IsPC)
269 Attach(
"equip", rightAttach:
false);
273 Attach(
"npcProperty");
275 if (mode !=
Mode.Search)
291 if (blessedState2 != 0)
293 Attach(
"status_" + blessedState2);
298 Attach(
"status_unidentified");
309 if (mode ==
Mode.Search)
314 Attach((rootCard == c) ?
"searched" :
"searched_container", rightAttach:
false);
320 Color c2 = Colors.Skin.textUnidentified;
323 c2 = c.blessedState
switch
325 BlessedState.Blessed => Colors.Skin.textBlessed,
326 BlessedState.Doomed => Colors.Skin.textDoomed,
327 BlessedState.Cursed => Colors.Skin.textCursed,
328 _ => Colors.Skin.textIdentified,
331 mainText.SetText(c.
Name, c2);
338 case Mode.Ingredient:
342 if (blessedState != 0)
344 Attach(
"status_" + blessedState);
349 Attach(
"status_unidentified");
380 else if (showNew && c.
isNew && c.
invY != 1)
384 base.image.sprite = sprite;
394 icon.SetNativeSize();
395 mainText.SetActive(enable:
false);
401 mainText.SetActive(enable:
true);
420 icon.enabled =
false;
421 mainText.SetActive(enable:
false);
422 base.onClick.RemoveAllListeners();
423 base.onClick.AddListener(delegate
427 tooltip.enable =
false;
428 base.image.color =
new Color(1f, 1f, 1f, 0.3f);
437 if (_ing.id.IsEmpty())
442 mainText.SetActive(enable:
true);
443 base.image.color =
Color.white;
445 if (ing.thing !=
null && (ing.thing.isDestroyed || ing.thing.Num == 0))
449 Thing thing = ing.thing;
450 SetCard(thing,
Mode.Ingredient);
453 Attach(
"ing_color", rightAttach:
false);
457 UIButton componentInChildren = Attach(
"ing_option", rightAttach:
false).GetComponentInChildren<
UIButton>(includeInactive:
true);
458 componentInChildren.SetActive(ing.thing !=
null);
459 componentInChildren.SetOnClick(delegate
463 SetIngredient(r, _ing);
473 int num = thing?.
Num ?? 0;
480 if (ing.optional && num == 0)
484 bool flag = num < num2 && !ing.optional;
485 string text = (num.ToString() ??
"").TagColor(Colors.colorIngPredict) + (
" -" + num2).TagColor(flag ? Colors.colorIngCost : Colors.colorIngReq);
486 mainText.text = text;
489 SetTooltip(
"note", delegate(
UITooltip tt)
493 tt.
note.
AddText(
"mark_ing".lang() + (ing.optional ?
"opIngredient" :
"noIngredient").lang(_ing.GetName()), ing.optional ?
FontColor.Good :
FontColor.Bad);
501 Attach(
"pcInv", rightAttach:
false);
507 SetCard(t,
Mode.Ingredient);
509 mainText.text = num.ToString() ??
"";
510 mainText.SetActive(enable:
true);
514 Attach(
"pcInv", rightAttach:
false);
530 mainText.SetActive(enable:
false);
543 icon.SetNativeSize();
544 mainText.SetActive(enable:
false);
554 Thing thing = recipe.ingredients[0].thing;
572 Attach(
"pcInv", rightAttach:
false);
579 bool flag = recipe.IsCraftable();
581 subText.text = thingStack.
count.ToString() ??
"";
582 recipe.SetTextDifficulty(subText2);
589 if (mode ==
Mode.Recipe)
595 mainText.SetActive(enable:
false);
614 r.BuildIngredientList();
617 Dettach(
"recipe_new");
620 if (mode ==
Mode.RecipeGrid && rCard.
_mold ==
null)
622 CardBlueprint.SetNormalRarity();
623 rCard._mold = ThingGen.Create(r.id);
640 WriteReqMat(note, r);
655 string text =
"<color=" + c.ToHex() +
">" + ingredient.GetName() +
" x " + ingredient.req +
" (" + count +
")</color>";
656 if (ingredient.optional)
658 text =
"opIngredient".lang(text);
666 if (invOwner !=
null &&
card !=
null)
668 if (!invOwner.CanShiftClick(
this) && !invOwner.CanCtrlClick(
this))
670 return invOwner.CanAltClick(
this);
679 if (!invOwner.CanShiftClick(
this))
681 if (!invOwner.CanCtrlClick(
this))
683 if (!invOwner.CanAltClick(
this))
687 return invOwner.GetTextAltClick(
this);
689 return invOwner.GetTextCtrlClick(
this);
691 return invOwner.GetTextShiftClick(
this);
696 if (invOwner !=
null &&
card !=
null)
698 return invOwner.AllowAutouse;
705 return invOwner.GetAutoUseLang(
this) ??
"";
720 return card.sourceCard;
722 return recipe.renderRow;
729 renderRow.SetImage(icon,
null, 0, setNativeSize:
false);
735 else if (
card !=
null)
743 if (invOwner !=
null &&
card !=
null)
745 return EClass.
ui.AllowInventoryInteractions;
758 EInput.middleMouse.pressedLongAction = delegate
764 HotItemHeld.disableTool =
true;
768 EClass.
ui.contextMenu.currentMenu.Hide();
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
BaseTileSelector tileSelector
SourceElement.Row element
bool IsEquipmentOrRangedOrAmmo
override string ToString()
virtual void WriteNote(UINote n, Action< UINote > onWriteNote=null, IInspect.NoteMode mode=IInspect.NoteMode.Default, Recipe recipe=null)
BlessedState blessedState
void SetImage(Image image, int dir, int idSkin=0)
int ChildrenAndSelfWeight
void SetBodyIndexText(BodySlot b, UIText t)
bool holdMiddleButtonToHold
List< Sprite > spritesContainerIcon
ButtonAssets buttonAssets
static SourceManager sources
virtual void SetButton(ButtonGrid b)
void ShowContextMenu(ButtonGrid button)
virtual bool AllowContext
static string _weight(int a, int b, bool showUnit=true, int unitSize=0)
void OnChangeIngredient()
static LayerCraft Instance
static void Despawn(Component c)
static Transform Spawn(string id, string path, Transform parent)
ThingStack ListThingStack(Recipe.Ingredient ing, StockSearchMode searchMode)
HashSet< string > hoveredRecipes
void WriteReqSkill(UINote n)
void WriteReqFactory(UINote n, bool hasFactory=true)
virtual RenderRow renderRow
void SaveLastIngredients()
List< Ingredient > ingredients
virtual void OnChangeIngredient()
virtual string GetDetail()
virtual void SetImage(Image icon)
virtual SourceMaterial.Row GetColorMaterial()
int GetColorInt(SourceMaterial.Row mat)
void SetImage(Image image, Sprite sprite=null, int matCol=0, bool setNativeSize=true, int dir=0, int idSkin=0)
static SkinColorProfile CurrentColors
Dictionary< string, CardRow > map
void SetImage(Image image)
static Sprite Get(string id)
ThingStack GetThingStack(string id, int refVal=-1)
override bool CanUse(Chara c)
virtual void SetMainText(UIText t, bool hotitem)
virtual void OnSetCardGrid(ButtonGrid b)
virtual Sprite GetRefSprite()
virtual SourceElement.Row GetRefElement()
UIItem AddHeaderCard(string text, Sprite sprite=null)
UIItem AddHeaderTopic(string text, Sprite sprite=null)
UIItem AddText(string text, FontColor color=FontColor.DontChange)
void Space(int sizeY=0, int sizeX=1)