13 public override object CreateExtra()
34 return EMono.player.hotbars.bars[this.idHotbar];
45 return this.extra.visible;
49 this.extra.visible = value;
55 public override bool ShowInBuildMode
59 return this.extra.alwaysShow;
65 public bool IsHotbarSpeed
69 return this.idHotbar == 7;
75 public bool CanRegisterItem
79 return this.hotbar.IsUserHotbar;
84 public override bool CanShowContextMenu()
86 if (this.hotbar.IsUserHotbar)
89 if (componentOf && componentOf.item !=
null)
94 return base.CanShowContextMenu();
98 public override void OnActivate()
100 this.mold = this.layout.CreateMold(
null);
101 if (this.idHotbar == 2)
103 WidgetHotbar.HotBarMainMenu =
this;
105 if (this.idHotbar == 3)
107 WidgetHotbar.HotbarBuild =
this;
109 if (this.idHotbar == 5)
111 WidgetHotbar.HotbarExtra =
this;
113 if (this.extra.rows == 0)
115 this.extra.rows = this.hotbar.itemsPerPage;
117 this.hotbar.actor =
this;
122 public override void OnChangeActionMode()
124 base.OnChangeActionMode();
125 if (this.hotbar.dirty)
127 this.hotbar.dirty =
false;
130 this.RefreshHighlight();
134 public void Rebuild()
136 this.buttons.Clear();
137 this.layout.cellSize =
EMono.setting.ui.iconSizes[this.extra.iconSize];
138 this.layout.constraintCount = this.extra.width;
139 this.layout.constraint = (this.extra.vertical ? GridLayoutGroup.Constraint.FixedColumnCount : GridLayoutGroup.Constraint.FixedRowCount);
140 this.layout.startCorner = (this.extra.reverse ? GridLayoutGroup.Corner.LowerRight : GridLayoutGroup.Corner.UpperLeft);
141 int num = this.extra.rows;
142 if (this.extra.autoSize)
146 while (num2 < this.hotbar.CurrentPage.items.Count &&
this.hotbar.CurrentPage.items[num2] !=
null)
152 int num3 = (num - 1) / this.extra.width + 1;
153 int num4 = this.extra.vertical ? this.extra.width : num3;
154 int num5 = this.extra.vertical ? num3 : this.extra.width;
155 this.imageGrid.uvRect =
new Rect(1f, 1f, (
float)num4, (
float)num5);
156 this.layout.DestroyChildren(
false,
true);
157 for (
int i = 0; i < num; i++)
160 buttonHotItem.index = i;
161 buttonHotItem.mainText.text = ((i > 10) ?
"" : ((i + 1).ToString() ??
""));
162 buttonHotItem.widget =
this;
163 this.buttons.Add(buttonHotItem);
166 buttonHotItem.gameObject.AddComponent<RectMask2D>();
169 this.layout.RebuildLayout(
false);
170 this.RebuildLayout(
false);
171 this.RebuildPage(-1);
175 public void RebuildPage(
int page = -1)
177 this.hotbar.SetPage((page == -1) ? this.hotbar.currentPage : page);
180 HotItem item = this.hotbar.GetItem(buttonHotItem.index, -1);
181 buttonHotItem.SetItem(item);
184 this.RefreshHighlight();
188 public static void RebuildPages()
195 widgetHotbar.RebuildPage(-1);
201 public void SwitchPage()
204 this.RebuildPage((this.hotbar.currentPage == 0) ? 1 : 0);
208 public HotItem GetItem(
int index)
210 return this.hotbar.CurrentPage.items.TryGet(index,
true);
214 public void TryUse(
int index)
216 HotItem item = this.GetItem(index);
222 item.OnClick(item.button,
this.hotbar);
228 UIContextMenu uicontextMenu =
EMono.ui.CreateContextMenu(
"ContextMenu");
229 this.SetShortcutMenu(b, uicontextMenu);
230 uicontextMenu.Show();
234 public override void OnSetContextMenu(UIContextMenu m)
237 if (this.showThisWidget || !b || b.item ==
null || base.IsSealed || b.widget.hotbar.IsLocked)
239 this.showThisWidget =
false;
240 SkinSet skin = base.config.skin.Skin;
241 UIContextMenu uicontextMenu = m.AddChild(
"setting");
242 UIContextMenu uicontextMenu2 = m.AddChild(
"style");
245 uicontextMenu.AddSlider(
"numSlot", (
float n) => n.ToString() ??
"", (
float)
this.extra.rows, delegate(
float a)
247 this.extra.rows = (int)a;
248 this.hotbar.SetSlotNum((
int)a);
250 this.ClampToScreen();
251 }, 1f, 20f,
true,
false,
false);
253 uicontextMenu2.AddSlider(
"iconSize", (
float n) => n.ToString() ??
"", (
float)
this.extra.iconSize, delegate(
float a)
255 this.extra.iconSize = (int)a;
257 this.ClampToScreen();
258 }, 0f, (float)(EMono.setting.ui.iconSizes.Count - 1),
true,
true,
false);
259 base.SetGridContextMenu(uicontextMenu2);
260 uicontextMenu.AddToggle(
"vertical", this.extra.vertical, delegate(
bool a)
262 this.extra.vertical = a;
264 this.ClampToScreen();
266 uicontextMenu.AddToggle(
"doubleBar", this.extra.width == 2, delegate(
bool a)
268 this.extra.width = (a ? 2 : 1);
270 this.ClampToScreen();
272 uicontextMenu.AddToggle(
"reverseOrder", this.extra.reverse, delegate(
bool a)
274 this.extra.reverse = a;
276 this.ClampToScreen();
280 uicontextMenu.AddToggle(
"alwaysShow2", this.extra.alwaysShow, delegate(
bool a)
282 this.extra.alwaysShow = a;
285 base.SetBaseContextMenu(m);
289 m.AddButton(
"resetHotbar", delegate()
291 string langDetail =
"dialogResetHotbar";
293 if ((actionYes = <>9__12) ==
null)
295 actionYes = (<>9__12 = delegate()
297 EMono.player.hotbars.ResetHotbar(this.hotbar.id);
301 Dialog.YesNo(langDetail, actionYes,
null,
"yes",
"no");
308 m.AddButton(
"removeHotItem", delegate()
310 this.hotbar.SetItem(
null, b.index, -1,
false);
311 this.RebuildPage(-1);
313 b.item.OnShowContextMenu(m);
314 m.AddToggle(
"alwaysShow", b.item.always, delegate(
bool on)
319 m.AddButton(
"thisWidget", delegate()
321 this.showThisWidget =
true;
322 List<Action> actionsNextFrame =
EMono.core.actionsNextFrame;
324 if ((item = <>9__13) ==
null)
326 item = (<>9__13 = delegate()
328 this.ShowContextMenu();
331 actionsNextFrame.Add(item);
337 public void SetShortcutMenu(
ButtonHotItem b, UIContextMenu m)
339 Action<UIContextMenu, HotItem> action = delegate(UIContextMenu _m,
HotItem i)
341 _m.AddButton(i.Name, delegate()
346 UIContextMenu arg = m.AddChild(
"layerShortcuts");
391 arg = m.AddChild(
"utilShortcuts");
394 type = HotItemToggle.Type.ToggleNoRoof
398 type = HotItemToggle.Type.muteBGM
402 type = HotItemToggle.Type.showBalloon
405 if (
EMono.core.config.test.unsealWidgets)
407 arg = m.AddChild(
"menuShortcuts");
412 if (
this == this.IsHotbarSpeed)
414 arg = m.AddChild(
"uniqueShortcuts");
433 arg = m.AddChild(
"specialShortcuts");
436 m.AddButton(
"registerPos".lang(), delegate()
440 zone =
EMono.game.activeZone,
445 m.AddButton(
"hotActionEQSet".lang(), delegate()
449 m.AddButton(
"hotActionSleep".lang(), delegate()
458 item = this.hotbar.SetItem(item, b.index, -1,
false);
460 this.RefreshHighlight();
465 public static void RefreshHighlights()
472 widgetHotbar.RefreshHighlight();
478 public static void RefreshButtons()
485 foreach (
ButtonHotItem buttonHotItem
in widgetHotbar.buttons)
487 buttonHotItem.RefreshItem();
494 public bool RefreshHighlight()
499 if (buttonHotItem.item !=
null)
501 if (buttonHotItem.item.UseIconForHighlight)
503 if (buttonHotItem.item.ShouldHighlight())
506 buttonHotItem.icon.sprite = buttonHotItem.item.GetSprite(
true);
510 buttonHotItem.icon.sprite = buttonHotItem.item.GetSprite();
513 else if (buttonHotItem.item.ShouldHighlight())
516 buttonHotItem.image.sprite = buttonHotItem.item.SpriteHighlight;
517 if (!this.Visible && buttonHotItem.item.KeepVisibleWhenHighlighted)
519 this.ToggleVisible();
524 buttonHotItem.image.sprite =
EMono.core.refs.spritesHighlight[0];
532 public void _OnDirtyInventory()
536 if (buttonHotItem.item !=
null)
538 buttonHotItem.Refresh();
544 public void SetVisible()
546 UIButton componentOf = InputModuleEX.GetComponentOf<UIButton>();
552 bool flag3 = this.Visible || flag2 || (buttonHotItem.item !=
null && buttonHotItem.item.always);
553 buttonHotItem.image.enabled = flag3;
554 buttonHotItem.mainText.enabled = flag3;
555 buttonHotItem.icon.SetActive(flag3);
556 if (!flag2 && buttonHotItem != componentOf)
558 buttonHotItem.DoNormalTransition(
true);
569 if (num == 0 && !this.Visible)
574 base.CancelInvoke(
"CheckAutoHide");
577 this.timeSinceBecomeVisible = 0f;
578 base.InvokeRepeating(
"CheckAutoHide", 0.1f, 0.2f);
580 this.imageBG.enabled = (this.imageGrid.enabled = this.extra.visible);
581 this.dragPanel.SetActive(this.extra.visible);
585 public void ToggleVisible()
587 this.extra.visible = !this.extra.visible;
591 this.imageBG.transform.localScale =
new Vector3(0.6f, 0.6f, 1f);
592 this.imageBG.transform.DOScale(1f, 0.12f).SetEase(Ease.Linear);
593 this.imageGrid.transform.localScale =
new Vector3(0.6f, 0.6f, 1f);
594 this.imageGrid.transform.DOScale(1f, 0.12f).SetEase(Ease.Linear);
597 if (!(buttonHotItem.item is
HotItemToggleVisible) && (buttonHotItem.item ==
null || !buttonHotItem.item.always))
599 buttonHotItem.transform.localScale =
new Vector3(0.6f, 0.6f, 1f);
600 buttonHotItem.transform.DOScale(1f, 0.12f).SetEase(Ease.Linear);
603 this.imageBG.SetAlpha(0f);
604 this.imageGrid.SetAlpha(0f);
605 SkinConfig skin = base.config.skin;
606 this.imageBG.DOFade(skin.bgColor.a, 0.4f).SetEase(Ease.OutQuint);
607 this.imageGrid.DOFade(skin.gridColor.a, 0.4f).SetEase(Ease.OutQuint);
612 public void CheckAutoHide()
618 this.timeSinceBecomeVisible += 0.2f;
619 if (this.timeSinceBecomeVisible < 1f)
623 if (Input.GetMouseButton(0) ||
EMono.ui.contextMenu.currentMenu !=
null ||
WidgetHotbar.registering)
625 this.timeSinceBecomeVisible = 0f;
628 if (InputModuleEX.IsPointerOver(base.transform))
630 this.timeSinceBecomeVisible = 0f;
635 if (buttonHotItem.item !=
null && buttonHotItem.item.KeepVisibleWhenHighlighted && buttonHotItem.item.ShouldHighlight())
640 this.ToggleVisible();
644 public void OnStartDrag(UIButton b)
646 EMono.ui.hud.SetDragImage(b.icon,
null,
null);
650 public void OnDrag(UIButton b)
653 if (this.GetSwapButton(b))
655 text =
"hotitemSwap";
657 else if (!
EMono.ui.isPointerOverUI)
659 text =
"hotitemTrash";
661 EMono.ui.hud.SetDragText(text,
null);
670 if (!(widgetHotbar ==
null))
672 foreach (
ButtonHotItem buttonHotItem
in widgetHotbar.buttons)
674 if (InputModuleEX.IsPointerOver(buttonHotItem) && b != buttonHotItem)
676 return buttonHotItem;
685 public void OnEndDrag(UIButton b,
bool cancel =
false)
687 EMono.ui.hud.imageDrag.SetActive(
false);
695 Hotbar hotbar = swapButton.widget.hotbar;
696 Hotbar hotbar2 = buttonHotItem.widget.hotbar;
697 hotbar.actor.SetItem(swapButton, hotItem2);
698 hotbar2.actor.SetItem(buttonHotItem, hotItem);
701 hotItem.button = buttonHotItem;
702 hotItem.hotbar = hotbar2;
704 if (hotItem2 !=
null)
706 hotItem2.button = swapButton;
707 hotItem2.hotbar = hotbar;
712 if (
EMono.ui.isPointerOverUI)
723 public static bool registering;
726 public static bool dirtyCurrentItem;
729 public static HotItem registeringItem;
744 public GridLayoutGroup layout;
750 public RawImage imageGrid;
753 public Image imageSelect;
756 public Hotbar.Type type;
763 public List<ButtonHotItem> buttons =
new List<ButtonHotItem>();
766 private bool showThisWidget;
769 private float timeSinceBecomeVisible;
775 public int iconSize = 2;
778 public int width = 1;
784 public bool showShortcut;
787 public bool vertical;
793 public bool alwaysShow;
799 public bool autoSize;