Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
WidgetCurrentTool Class Reference
Inheritance diagram for WidgetCurrentTool:
Widget EMono IChangeResolution ISkinRoot

Classes

class  Extra
 

Public Member Functions

override object CreateExtra ()
 
override void OnActivate ()
 
void RebuildSlots ()
 
void CheckDirty ()
 
void SwitchPage ()
 
void _RefreshCurrentHotItem ()
 
void OnClickButtonHotItem ()
 
void ModSelected (int a)
 
int GetNextSelectableIndex ()
 
int GetPrevSelectableIndex ()
 
void Reselect ()
 
void Select (int index, bool fromHotkey=false)
 
void RefreshHighlight ()
 
override bool CanShowContextMenu ()
 
override void OnSetContextMenu (UIContextMenu m)
 
- Public Member Functions inherited from Widget
void Test ()
 
bool IsInRightMode ()
 
void Activate ()
 
void RefreshOrder ()
 
virtual void OnActivate ()
 
virtual object CreateExtra ()
 
void Deactivate ()
 
virtual void OnDeactivate ()
 
void Close ()
 
void Reactivate ()
 
virtual void OnManagerActivate ()
 
virtual void OnManagerDeactivate ()
 
void SetAnchor (RectPosition p)
 
void SetPivot (RectPosition p)
 
virtual void OnChangePivot ()
 
void UpdateConfig ()
 
virtual void OnUpdateConfig ()
 
void ClampToScreen ()
 
virtual void OnChangeResolution ()
 
void OnChangePosition ()
 
virtual void OnChangeActionMode ()
 
virtual void OnFlip ()
 
bool IsAlignTop ()
 
Layer AddLayer (Layer l, Transform trans)
 
void RefreshTipPivotPosition ()
 
SkinSet GetSkin ()
 
SkinConfig GetSkinConfig ()
 
void SetSkin (int id, int v=0)
 
void TestSkin ()
 
virtual void ApplySkin ()
 
virtual void OnApplySkin ()
 
void InstantiateDeco (SkinDeco deco)
 
void AddDeco (SkinDeco deco)
 
void RemoveDeco (SkinDeco deco)
 
virtual bool CanShowContextMenu ()
 
void ShowContextMenu ()
 
void SetBaseContextMenu (UIContextMenu m)
 
virtual void OnSetContextMenu (UIContextMenu m)
 
void SetGridContextMenu (UIContextMenu m)
 
void SoundActivate ()
 
void OnChangeResolution ()
 
SkinSet GetSkin ()
 
SkinConfig GetSkinConfig ()
 

Static Public Member Functions

static void RefreshCurrentHotItem ()
 
- Static Public Member Functions inherited from EMono
static int rnd (int a)
 

Public Attributes

ButtonHotItem buttonHotItem
 
UIButton buttonSwitchPage
 
Image iconHeld
 
Image imageHighlight
 
UIList list
 
int maxSlots = 9
 
List< Thinggrid = new List<Thing>(new Thing[20])
 
UIPlaceHelper placer
 
GridLayoutGroup layout
 
Transform transHighlightSwitch
 
int selected = -1
 
int selectedPage
 
- Public Attributes inherited from Widget
Image imageBG
 
SoundData soundActivate
 
UIDragPanel dragPanel
 
RectTransform tipPivotLeft
 
RectTransform tipPivotRight
 

Static Public Attributes

const int SlotsPerPage = 10
 
const int MaxPage = 2
 
static WidgetCurrentTool Instance
 
static bool dirty
 
- Static Public Attributes inherited from EMono
static Core core
 

Properties

Extra extra [get]
 
int page [get, set]
 
ButtonGrid selectedButton [get]
 
- Properties inherited from Widget
string ID [get]
 
Config config [get]
 
SkinRoot skinRoot [get]
 
bool IsSealed [get]
 
virtual bool ShowStyleMenu [get]
 
virtual bool AlwaysTop [get]
 
virtual bool IsStaticPosition [get]
 
virtual bool AlwaysBottom [get]
 
virtual Type SetSiblingAfter [get]
 
virtual bool ShowInBuildMode [get]
 
virtual bool RightClickToClose [get]
 
virtual bool AllowRightClickToClose [get]
 
- Properties inherited from EMono
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SoundManager Sound [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static CoreDebug debug [get]
 

Private Member Functions

void Update ()
 

Additional Inherited Members

- Public Types inherited from Widget
enum  WidgetType { Default , ZoomMenu }
 
enum  State { Active , Inactive }
 
- Protected Member Functions inherited from Widget
void ClampToScreenEnsured (Component c, Vector2 anchoredPos)
 
void ClampToScreen (RectTransform rect, float margin=10f)
 
- Protected Attributes inherited from Widget
bool flip
 

Detailed Description

Definition at line 5 of file WidgetCurrentTool.cs.

Member Function Documentation

◆ _RefreshCurrentHotItem()

void WidgetCurrentTool._RefreshCurrentHotItem ( )
inline

Definition at line 189 of file WidgetCurrentTool.cs.

190 {
192 if (hotItem == null)
193 {
194 hotItem = EMono.player.hotItemNoItem;
195 }
196 buttonHotItem.item = hotItem;
197 buttonHotItem.icon.material = (hotItem.UseUIObjMaterial ? EMono.core.refs.matUIObj : null);
198 hotItem.SetImage(buttonHotItem.icon);
199 buttonHotItem.interactable = true;
201 iconHeld.SetActive(hotItem is HotItemHeld);
203 }
Definition: EMono.cs:4
static Player player
Definition: EMono.cs:11
virtual void SetImage(Image icon)
Definition: HotItem.cs:91
HotItem currentHotItem
Definition: Player.cs:901
HotItemNoItem hotItemNoItem
Definition: Player.cs:1030
Image icon
Definition: UIButton.cs:110
ButtonHotItem buttonHotItem

References buttonHotItem, Player.currentHotItem, Player.hotItemNoItem, UIButton.icon, iconHeld, EMono.player, ButtonHotItem.Refresh(), RefreshHighlight(), and HotItem.SetImage().

Referenced by CheckDirty(), OnActivate(), RefreshCurrentHotItem(), and SwitchPage().

◆ CanShowContextMenu()

override bool WidgetCurrentTool.CanShowContextMenu ( )
inlinevirtual

Reimplemented from Widget.

Definition at line 308 of file WidgetCurrentTool.cs.

309 {
310 ButtonGrid componentOf = InputModuleEX.GetComponentOf<ButtonGrid>();
311 if ((bool)componentOf && componentOf != buttonHotItem)
312 {
313 return false;
314 }
315 return base.CanShowContextMenu();
316 }

References buttonHotItem.

◆ CheckDirty()

void WidgetCurrentTool.CheckDirty ( )
inline

Definition at line 161 of file WidgetCurrentTool.cs.

162 {
163 if (dirty)
164 {
165 list.Redraw();
167 }
168 dirty = false;
169 }
override void Redraw()
Definition: UIList.cs:740

References _RefreshCurrentHotItem(), dirty, list, and UIList.Redraw().

Referenced by LayerInventory.SetDirtyAll(), SwitchPage(), and Update().

◆ CreateExtra()

override object WidgetCurrentTool.CreateExtra ( )
inlinevirtual

Reimplemented from Widget.

Definition at line 64 of file WidgetCurrentTool.cs.

65 {
66 return new Extra();
67 }

◆ GetNextSelectableIndex()

int WidgetCurrentTool.GetNextSelectableIndex ( )
inline

Definition at line 225 of file WidgetCurrentTool.cs.

226 {
227 int num = selected + 1;
228 if (num >= maxSlots)
229 {
230 num = -1;
231 }
232 return num;
233 }

References maxSlots, and selected.

Referenced by ModSelected().

◆ GetPrevSelectableIndex()

int WidgetCurrentTool.GetPrevSelectableIndex ( )
inline

Definition at line 235 of file WidgetCurrentTool.cs.

236 {
237 int num = selected - 1;
238 if (num <= -2)
239 {
240 num = maxSlots - 1;
241 }
242 return num;
243 }

References maxSlots, and selected.

Referenced by ModSelected().

◆ ModSelected()

void WidgetCurrentTool.ModSelected ( int  a)
inline

Definition at line 218 of file WidgetCurrentTool.cs.

219 {
220 SE.SelectHotitem();
221 int index = ((a > 0) ? GetNextSelectableIndex() : GetPrevSelectableIndex());
222 Select(index);
223 }
void Select(int index, bool fromHotkey=false)

References GetNextSelectableIndex(), GetPrevSelectableIndex(), and Select().

Referenced by AM_Adv._OnUpdateInput().

◆ OnActivate()

override void WidgetCurrentTool.OnActivate ( )
inlinevirtual

Reimplemented from Widget.

Definition at line 69 of file WidgetCurrentTool.cs.

70 {
72 Instance = this;
74 buttonHotItem.onClick.AddListener(OnClickButtonHotItem);
75 buttonSwitchPage.SetOnClick(delegate
76 {
78 {
79 EMono.player.flags.toggleHotbarHighlightDisabled = true;
80 transHighlightSwitch.SetActive(enable: false);
81 }
82 SwitchPage();
83 });
85 dirty = true;
87 ApplySkin();
88 }
bool toggleHotbarHighlightDisabled
Definition: Player.cs:378
Flags flags
Definition: Player.cs:895
static WidgetCurrentTool Instance
Transform transHighlightSwitch
UIPlaceHelper placer
virtual void ApplySkin()
Definition: Widget.cs:556

References _RefreshCurrentHotItem(), Widget.ApplySkin(), buttonHotItem, buttonSwitchPage, dirty, Player.flags, Instance, OnClickButtonHotItem(), page, placer, EMono.player, RebuildSlots(), UIPlaceHelper.Refresh(), SwitchPage(), Player.Flags.toggleHotbarHighlightDisabled, and transHighlightSwitch.

◆ OnClickButtonHotItem()

void WidgetCurrentTool.OnClickButtonHotItem ( )
inline

Definition at line 205 of file WidgetCurrentTool.cs.

206 {
207 SE.SelectHotitem();
209 {
210 Select(-1);
211 return;
212 }
213 int index = selected;
214 selected = -1;
215 Select(index);
216 }
Card card
Definition: ButtonGrid.cs:24
virtual Thing Thing
Definition: HotItem.cs:38
ButtonGrid selectedButton

References ButtonGrid.card, Player.currentHotItem, EMono.player, Select(), selected, selectedButton, and HotItem.Thing.

Referenced by OnActivate().

◆ OnSetContextMenu()

override void WidgetCurrentTool.OnSetContextMenu ( UIContextMenu  m)
inlinevirtual

Reimplemented from Widget.

Definition at line 318 of file WidgetCurrentTool.cs.

319 {
320 InputModuleEX.GetComponentOf<ButtonHotItem>();
321 UIContextMenu uIContextMenu = m.AddChild("setting");
322 UIContextMenu uIContextMenu2 = m.AddChild("style");
323 uIContextMenu2.AddSlider("iconSize", (float n) => n.ToString() ?? "", extra.iconSize, delegate(float a)
324 {
325 extra.iconSize = (int)a;
326 RebuildSlots();
327 }, 0f, EMono.setting.ui.iconSizes.Count - 1, isInt: true);
328 SetGridContextMenu(uIContextMenu2);
329 uIContextMenu.AddToggle("showShortcut", extra.showShortcut, delegate(bool a)
330 {
331 extra.showShortcut = a;
332 RebuildSlots();
333 });
335 }
UIContextMenuItem AddSlider(string text, Func< float, string > textFunc, float value, Action< float > action, float min=0f, float max=1f, bool isInt=false, bool hideOther=true, bool useInput=false)
UIContextMenu AddChild(string idLang, TextAnchor anchor)
void SetBaseContextMenu(UIContextMenu m)
Definition: Widget.cs:608
void SetGridContextMenu(UIContextMenu m)
Definition: Widget.cs:709

References UIContextMenu.AddChild(), UIContextMenu.AddSlider(), extra, WidgetCurrentTool.Extra.iconSize, RebuildSlots(), Widget.SetBaseContextMenu(), Widget.SetGridContextMenu(), and WidgetCurrentTool.Extra.showShortcut.

◆ RebuildSlots()

void WidgetCurrentTool.RebuildSlots ( )
inline

Definition at line 90 of file WidgetCurrentTool.cs.

91 {
92 imageHighlight.transform.SetParent(base.transform, worldPositionStays: false);
93 layout.cellSize = EMono.setting.ui.iconSizes[extra.iconSize];
94 SkinConfig skin = base.config.skin;
95 list.Clear();
96 list.callbacks = new UIList.Callback<Thing, ButtonGridDrag>
97 {
98 onRedraw = delegate(Thing a, ButtonGridDrag b, int i)
99 {
100 int num = i + 1;
101 b.subText2.SetText((num % 10).ToString() ?? "");
102 b.subText2.SetActive(extra.showShortcut);
103 b.index = i % 10 + 10 * page;
105 {
106 index = i % 10 + 10 * page
107 });
108 }
109 };
110 for (int j = 0; j < maxSlots; j++)
111 {
112 list.Add(null);
113 }
114 list.onBeforeRedraw = delegate
115 {
116 dirty = false;
117 for (int k = 0; k < grid.Count; k++)
118 {
119 grid[k] = null;
120 }
121 foreach (Thing thing in EMono.pc.things)
122 {
123 if (thing.invY == 1 && thing.invX >= page * 10 && thing.invX < (page + 1) * 10)
124 {
125 if (thing.invX < 0 || thing.invX >= grid.Count)
126 {
127 Debug.Log(thing.Name + "/" + thing.invX);
128 }
129 else
130 {
131 grid[thing.invX] = thing;
132 }
133 }
134 }
135 for (int l = 0; l < list.buttons.Count; l++)
136 {
137 UIList.ButtonPair value = list.buttons[l];
138 value.obj = grid[l + page * 10];
139 list.buttons[l] = value;
140 }
141 buttonSwitchPage.mainText.text = (page + 1).ToString() ?? "";
142 };
143 list.onAfterRedraw = delegate
144 {
146 };
147 list.Refresh();
148 list.Redraw();
149 UIRawImage obj = list.bgGrid as UIRawImage;
150 obj.skinRoot = GetComponent<SkinRoot>();
151 obj.color = skin.gridColor;
154 }
void SetCardGrid(Card c, InvOwner owner=null)
Definition: ButtonGrid.cs:145
int invY
Definition: Card.cs:1831
string Name
Definition: Card.cs:2013
ThingContainer things
Definition: Card.cs:34
int invX
Definition: Card.cs:1819
static GameSetting setting
Definition: EMono.cs:31
static Chara pc
Definition: EMono.cs:13
List< Vector2 > iconSizes
Definition: GameSetting.cs:28
UISetting ui
Definition: GameSetting.cs:307
static void TryShowGuide(UIList list)
Color gridColor
Definition: SkinConfig.cs:79
Definition: Thing.cs:8
UIText subText2
Definition: UIButton.cs:106
Definition: UIList.cs:9
List< ButtonPair > buttons
Definition: UIList.cs:244
override void Clear()
Definition: UIList.cs:349
override void Add(object item)
Definition: UIList.cs:302
virtual void Refresh(bool highlightLast=false)
Definition: UIList.cs:424
void SetText(string s)
Definition: UIText.cs:159
List< Thing > grid
void ClampToScreen()
Definition: Widget.cs:437

References UIList.Add(), UIList.buttons, Widget.ClampToScreen(), UIList.Clear(), Debug, dirty, extra, grid, SkinConfig.gridColor, WidgetCurrentTool.Extra.iconSize, GameSetting.UISetting.iconSizes, imageHighlight, Card.invX, Card.invY, list, maxSlots, Card.Name, page, EMono.pc, UIList.Redraw(), UIList.Refresh(), RefreshHighlight(), ButtonGrid.SetCardGrid(), UIText.SetText(), EMono.setting, WidgetCurrentTool.Extra.showShortcut, UIButton.subText2, Card.things, LayerInventory.TryShowGuide(), and GameSetting.ui.

Referenced by OnActivate(), and OnSetContextMenu().

◆ RefreshCurrentHotItem()

static void WidgetCurrentTool.RefreshCurrentHotItem ( )
inlinestatic

◆ RefreshHighlight()

void WidgetCurrentTool.RefreshHighlight ( )
inline

Definition at line 294 of file WidgetCurrentTool.cs.

295 {
296 bool flag = selected != -1;
297 imageHighlight.SetActive(flag);
298 if (flag)
299 {
300 imageHighlight.transform.SetParent(selectedButton.transform, worldPositionStays: false);
301 imageHighlight.transform.position = selectedButton.transform.position;
302 imageHighlight.Rect().sizeDelta = selectedButton.Rect().sizeDelta;
303 imageHighlight.transform.SetAsFirstSibling();
305 }
306 }

References ButtonGrid.card, Player.currentHotItem, imageHighlight, EMono.player, selected, selectedButton, and HotItem.Thing.

Referenced by _RefreshCurrentHotItem(), RebuildSlots(), and Select().

◆ Reselect()

void WidgetCurrentTool.Reselect ( )
inline

Definition at line 245 of file WidgetCurrentTool.cs.

246 {
248 }

References Select(), and selected.

Referenced by InvOwnerHotbar.OnProcess().

◆ Select()

void WidgetCurrentTool.Select ( int  index,
bool  fromHotkey = false 
)
inline

Definition at line 250 of file WidgetCurrentTool.cs.

251 {
252 if (index != -1 && fromHotkey && EMono.core.config.game.useAbilityOnHotkey)
253 {
254 ButtonGrid buttonGrid = list.buttons[index].component as ButtonGrid;
255 TraitAbility traitAbility = ((buttonGrid.card != null) ? (buttonGrid.card.trait as TraitAbility) : null);
256 if (traitAbility != null && traitAbility.CanUse(EMono.pc))
257 {
258 if (EMono.player.CanAcceptInput() && traitAbility.OnUse(EMono.pc))
259 {
261 }
262 return;
263 }
264 }
265 if (fromHotkey)
266 {
267 SE.SelectHotitem();
268 }
269 if (selected == index && selectedPage == page)
270 {
271 index = -1;
272 }
273 selected = index;
275 if (selected >= maxSlots)
276 {
277 selected = -1;
278 }
279 if (selected == -1 || selectedButton.card == null)
280 {
282 }
283 else
284 {
286 }
288 {
290 }
292 }
void UpdatePlans()
Definition: AM_Adv.cs:410
bool IsActive
Definition: ActionMode.cs:121
static AM_Adv Adv
Definition: ActionMode.cs:15
Trait trait
Definition: Card.cs:49
new GameConfig game
Definition: CoreConfig.cs:596
CoreConfig config
Definition: Core.cs:70
static Core core
Definition: EMono.cs:5
void ResetCurrentHotItem()
Definition: Player.cs:2039
void EndTurn(bool consume=true)
Definition: Player.cs:1866
bool CanAcceptInput()
Definition: Player.cs:2212
void SetCurrentHotItem(HotItem item)
Definition: Player.cs:2046
override bool CanUse(Chara c)
override bool OnUse(Chara c)
virtual HotItem GetHotItem()
Definition: Trait.cs:914

References ActionMode.Adv, UIList.buttons, Player.CanAcceptInput(), TraitCatalyst.CanUse(), ButtonGrid.card, Core.config, EMono.core, Player.EndTurn(), CoreConfig.game, Trait.GetHotItem(), ActionMode.IsActive, list, maxSlots, TraitCatalyst.OnUse(), page, EMono.pc, EMono.player, RefreshHighlight(), Player.ResetCurrentHotItem(), selected, selectedButton, selectedPage, Player.SetCurrentHotItem(), Card.trait, AM_Adv.UpdatePlans(), and CoreConfig.GameConfig.useAbilityOnHotkey.

Referenced by AM_Adv._OnUpdateInput(), ModSelected(), InvOwnerHotbar.OnClick(), OnClickButtonHotItem(), InvOwnerHotbar.OnRightClick(), Reselect(), and ActionMode.UpdateInput().

◆ SwitchPage()

void WidgetCurrentTool.SwitchPage ( )
inline

Definition at line 179 of file WidgetCurrentTool.cs.

180 {
181 page = ((page == 0) ? 1 : 0);
183 dirty = true;
184 CheckDirty();
185 placer.Refresh();
186 SE.Play("switch_hotbar");
187 }

References _RefreshCurrentHotItem(), CheckDirty(), dirty, page, placer, and UIPlaceHelper.Refresh().

Referenced by ActionMode.DoFunc(), OnActivate(), and ActionMode.UpdateInput().

◆ Update()

void WidgetCurrentTool.Update ( )
inlineprivate

Definition at line 156 of file WidgetCurrentTool.cs.

157 {
158 CheckDirty();
159 }

References CheckDirty().

Member Data Documentation

◆ buttonHotItem

ButtonHotItem WidgetCurrentTool.buttonHotItem

◆ buttonSwitchPage

UIButton WidgetCurrentTool.buttonSwitchPage

Definition at line 24 of file WidgetCurrentTool.cs.

Referenced by OnActivate().

◆ dirty

bool WidgetCurrentTool.dirty
static

Definition at line 32 of file WidgetCurrentTool.cs.

Referenced by CheckDirty(), OnActivate(), RebuildSlots(), and SwitchPage().

◆ grid

List<Thing> WidgetCurrentTool.grid = new List<Thing>(new Thing[20])

Definition at line 36 of file WidgetCurrentTool.cs.

Referenced by RebuildSlots().

◆ iconHeld

Image WidgetCurrentTool.iconHeld

Definition at line 26 of file WidgetCurrentTool.cs.

Referenced by _RefreshCurrentHotItem().

◆ imageHighlight

Image WidgetCurrentTool.imageHighlight

Definition at line 28 of file WidgetCurrentTool.cs.

Referenced by RebuildSlots(), and RefreshHighlight().

◆ Instance

◆ layout

GridLayoutGroup WidgetCurrentTool.layout

Definition at line 40 of file WidgetCurrentTool.cs.

◆ list

UIList WidgetCurrentTool.list

◆ MaxPage

const int WidgetCurrentTool.MaxPage = 2
static

Definition at line 18 of file WidgetCurrentTool.cs.

◆ maxSlots

int WidgetCurrentTool.maxSlots = 9

◆ placer

UIPlaceHelper WidgetCurrentTool.placer

◆ selected

◆ selectedPage

int WidgetCurrentTool.selectedPage

Definition at line 46 of file WidgetCurrentTool.cs.

Referenced by Select().

◆ SlotsPerPage

const int WidgetCurrentTool.SlotsPerPage = 10
static

Definition at line 16 of file WidgetCurrentTool.cs.

◆ transHighlightSwitch

Transform WidgetCurrentTool.transHighlightSwitch

Definition at line 42 of file WidgetCurrentTool.cs.

Referenced by OnActivate(), and InvOwnerHotbar.OnProcess().

Property Documentation

◆ extra

Extra WidgetCurrentTool.extra
get

Definition at line 48 of file WidgetCurrentTool.cs.

Referenced by OnSetContextMenu(), and RebuildSlots().

◆ page

int WidgetCurrentTool.page
getset

Definition at line 50 of file WidgetCurrentTool.cs.

51 {
52 get
53 {
54 return EMono.player.hotbarPage;
55 }
56 set
57 {
58 EMono.player.hotbarPage = value;
59 }
60 }
int hotbarPage
Definition: Player.cs:730

Referenced by OnActivate(), RebuildSlots(), Select(), and SwitchPage().

◆ selectedButton

ButtonGrid WidgetCurrentTool.selectedButton
get

The documentation for this class was generated from the following file: