Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
radialquickbarmenu.c
Go to the documentation of this file.
6
8{
9 protected bool m_IsLightSourceExtra;
10 protected bool m_IsNVG;
11 protected int m_Id;
12 protected int m_Category;
13 protected int m_CategorySwitchID;
14 protected EntityAI m_Item;
15 protected string m_ItemName;
16
17 //radial menu
18 protected Widget m_RadialMenuSelector;
19 protected Widget m_RadialMenuItemCard;
20
21 void RadialQuickbarItem( int id, EntityAI item, string item_name, int category = RadialQuickbarCategory.DEFAULT, int category_switch = -1 )
22 {
23 m_Id = id;
24 m_Item = item;
25 m_ItemName = item_name;
26 m_Category = category;
27 m_CategorySwitchID = category_switch;
28
29 //
30 if (ItemBase.Cast(m_Item))
31 {
32 m_IsNVG = ItemBase.Cast(m_Item).IsNVG();
33 m_IsLightSourceExtra = ItemBase.Cast(m_Item).IsLightSource();
34 }
35 }
36
38 {
39 return m_Item;
40 }
41
42 void SetItem( EntityAI item )
43 {
44 m_Item = item;
45 }
46
48 {
50 }
51
53 {
54 return m_IsNVG;
55 }
56
57 int GetId()
58 {
59 return m_Id;
60 }
61
63 {
64 return m_Category;
65 }
66
68 {
69 return m_CategorySwitchID;
70 }
71
73 {
75 }
76
77 void SetRadialItemCard( Widget widget )
78 {
79 m_RadialMenuItemCard = widget;
80 }
81
82 string GetItemName()
83 {
84 return m_ItemName;
85 }
86}
87
88class RadialQuickbarMenu extends UIScriptedMenu
89{
90 protected Widget m_ItemCardPanel;
92 protected Widget m_ToolbarPanel;
93
94 protected bool m_IsMenuClosing;
95 protected int m_CurrentCategory;
96 //
97 const string TEXT_ITEM_NAME = "ItemName";
98 const string TEXT_ITEM_TITLE = "ItemTitle";
99 //selections
100 protected Widget m_SelectedItem;
102
103 //instance
104 static RadialQuickbarMenu instance;
105
106 //============================================
107 // RadialQuickbarMenu
108 //============================================
110 {
112 m_CurrentCategory = RadialQuickbarCategory.DEFAULT;
113
114 if ( !instance )
115 {
116 instance = this;
117 }
118
119 GetGame().GetMission().GetOnInputPresetChanged().Insert(OnInputPresetChanged);
120 }
121
123 {
124 if (GetGame() && GetGame().GetMission())
125 {
126 GetGame().GetMission().RemoveActiveInputExcludes({"radialmenu"},false);
127 }
128 }
129
130 static void SetItemToAssign( EntityAI item )
131 {
132 m_ItemToAssign = item;
133 }
134
136 {
137 return m_ItemToAssign;
138 }
139
140 static RadialQuickbarMenu GetMenuInstance()
141 {
142 return instance;
143 }
144
145 protected void OnInputPresetChanged()
146 {
147 #ifdef PLATFORM_CONSOLE
149 #endif
150 }
151
152 //============================================
153 // Menu Controls
154 //============================================
155 static void OpenMenu( UIScriptedMenu parent = NULL )
156 {
157 GetGame().GetUIManager().EnterScriptedMenu( MENU_RADIAL_QUICKBAR, parent );
158 }
159
160 static void CloseMenu()
161 {
162 GetGame().GetUIManager().Back();
163 //GetGame().GetMission().RemoveActiveInputExcludes({"radialmenu"},false);
164 }
165
166 //============================================
167 // Init & Widget Events
168 //============================================
169 override Widget Init()
170 {
171 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/radial_menu/radial_quickbar/radial_quickbar_menu.layout");
172 m_ItemCardPanel = layoutRoot.FindAnyWidget(RadialMenu.RADIAL_ITEM_CARD_CONTAINER);
173
174 //register gestures menu
175 RadialMenu.GetInstance().RegisterClass(this);
176
177 //delay updates until fully initialized
178 RadialMenu.GetInstance().SetWidgetInitialized(false);
179
180 //set radial menu properties
181 RadialMenu.GetInstance().SetWidgetProperties("gui/layouts/radial_menu/radial_quickbar/radial_quickbar_delimiter.layout");
182
183 //create content (widgets) for items
185
186 //set controller toolbar icons
188
189 m_ToolbarPanel = layoutRoot.FindAnyWidget( "toolbar_bg" );
190 m_ToolbarPanel.Show( true );
191
192 return layoutRoot;
193 }
194
195 override void OnShow()
196 {
197 super.OnShow();
198
199 Mission mission = GetGame().GetMission();
200 if (mission)
201 {
202 IngameHud hud = IngameHud.Cast(mission.GetHud());
203 if (hud)
204 {
205 hud.ShowQuickbarUI(false);
206 }
207 }
208
209 SetFocus(layoutRoot);
210 m_IsMenuClosing = false;
211 }
212
213 override void OnHide()
214 {
215 super.OnHide();
216
217 Mission mission = GetGame().GetMission();
218 if (mission)
219 {
220 IngameHud hud = IngameHud.Cast(mission.GetHud());
221 if (hud)
222 {
223 hud.ShowQuickbarUI(true);
224 }
225 }
226
227 //reset item to assign
228 RadialQuickbarMenu.SetItemToAssign(NULL);
229 m_IsMenuClosing = true;
230 }
231
232 override bool OnController( Widget w, int control, int value )
233 {
234 super.OnController( w, control, value );
235
236 RadialMenu.GetInstance().SetControlType( RadialMenuControlType.CONTROLLER );
237
238 return false;
239 }
240
241 override bool OnMouseEnter( Widget w, int x, int y )
242 {
243 super.OnMouseEnter( w, x, y );
244
245 RadialMenu.GetInstance().SetControlType( RadialMenuControlType.MOUSE );
246
247 return false;
248 }
249
250 override bool UseMouse()
251 {
252 return true;
253 }
254
255 override bool UseGamepad()
256 {
257 return true;
258 }
259
260 //============================================
261 // Content
262 //============================================
263 //reset_selection - if false, selected quick bar item will be remembered after content refresh
264 protected void RefreshQuickbar( bool reset_selection = true )
265 {
266 int selected_item_id = -1;
267 if ( !reset_selection )
268 {
269 RadialQuickbarItem quickbar_item;
270 if ( instance.m_SelectedItem )
271 {
272 instance.m_SelectedItem.GetUserData( quickbar_item );
273 selected_item_id = quickbar_item.GetId();
274 }
275 }
276
277 GetItems( m_Items );
278 //CheckForLightsAndNVG( m_Items );
279 CreateContent( selected_item_id );
280 }
281
282 //
283 // ITEMS
284 //
285 protected void GetItems( out array<ref RadialQuickbarItem> items )
286 {
287 items.Clear();
288
289 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
290 int size = player.GetQuickBarSize();
291 EntityAI entity;
292
293 for ( int i = 0; i < size; ++i )
294 {
295 entity = player.GetQuickBarEntity( i );
296
297 items.Insert( new RadialQuickbarItem( i, entity, "" ) );
298 }
299
300 CheckForLightsAndNVG(m_Items,i);
301 }
302
303 protected void CheckForLightsAndNVG( out array<ref RadialQuickbarItem> items, int last_idx )
304 {
305 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
306 int count = 0;
307 EntityAI entity;
308 ItemBase headgear = ItemBase.Cast(player.FindAttachmentBySlotName("Headgear"));
309 ItemBase eyewear = ItemBase.Cast(player.FindAttachmentBySlotName("Eyewear"));
310
311 //nvg - headgear check
312 if ( headgear )
313 {
314 entity = headgear.FindAttachmentBySlotName("NVG");
315 if (entity)
316 {
317 items.Insert( new RadialQuickbarItem( count, entity, "", RadialQuickbarCategory.SPECIALIZED_LIGHTS ) );
318 count++;
319 }
320 }
321 //nvg/light - eyewear check
322 if ( eyewear )
323 {
324 entity = eyewear.FindAttachmentBySlotName("NVG");
325 if (entity)
326 {
327 items.Insert( new RadialQuickbarItem( count, entity, "", RadialQuickbarCategory.SPECIALIZED_LIGHTS ) );
328 count++;
329 }
330 else if ( eyewear.IsLightSource() && eyewear.HasEnergyManager() && eyewear.GetCompEM().CanWork() )
331 {
332 entity = eyewear;
333 items.Insert( new RadialQuickbarItem( count, entity, "", RadialQuickbarCategory.SPECIALIZED_LIGHTS ) );
334 count++;
335 }
336 }
337 //light
338 if ( headgear )
339 {
340 if ( headgear.GetInventory().AttachmentCount() > 0 )
341 {
342 ItemBase attachment;
343 for (int i = 0; i < headgear.GetInventory().AttachmentCount(); i++)
344 {
345 attachment = ItemBase.Cast(headgear.GetInventory().GetAttachmentFromIndex(i));
346 if ( attachment && attachment.IsLightSource() && attachment.HasEnergyManager() && attachment.GetCompEM().CanWork() )
347 {
348 entity = attachment;
349 items.Insert( new RadialQuickbarItem( count, entity, "", RadialQuickbarCategory.SPECIALIZED_LIGHTS ) );
350 count++;
351 }
352 }
353 }
354 }
355
356 //Add a category switchers
357 if (m_CurrentCategory == RadialQuickbarCategory.DEFAULT && count > 0)
358 {
359 items.InsertAt( new RadialQuickbarItem(32,null,"#toggle_lights",RadialQuickbarCategory.DEFAULT,RadialQuickbarCategory.SPECIALIZED_LIGHTS),0 );
360 }
361 else if (m_CurrentCategory == RadialQuickbarCategory.SPECIALIZED_LIGHTS)
362 {
363 items.InsertAt( new RadialQuickbarItem(32,null,"#menu_back",RadialQuickbarCategory.SPECIALIZED_LIGHTS,RadialQuickbarCategory.DEFAULT),0 );
364 }
365 }
366
367 protected void CreateContent( int selected_item_id = -1 )
368 {
369 //delete existing content
370 DeleteItems();
371
372 int category_item_count;
373
374 for ( int i = 0; i < m_Items.Count(); ++i )
375 {
376 RadialQuickbarItem quickbar_item = m_Items.Get( i );
377
378 if (quickbar_item.GetItemCategory() == m_CurrentCategory)
379 {
380 //create item card
381 Widget item_card_widget = Widget.Cast( GetGame().GetWorkspace().CreateWidgets( "gui/layouts/radial_menu/radial_quickbar/radial_quickbar_item_card.layout", m_ItemCardPanel ) );
382 quickbar_item.SetRadialItemCard( item_card_widget );
383
384 //update item card widget
385 UpdateQuickbarItemCard( quickbar_item );
386
387 //set data
388 item_card_widget.SetUserData( quickbar_item );
389
390 //set selection
391 if ( quickbar_item.GetId() == selected_item_id )
392 {
393 MarkSelected( quickbar_item.GetRadialItemCard() );
394 }
395 category_item_count++;
396 }
397 }
398
399 //adjust radial parameters for content
400 if ( /*m_Items.Count()*/category_item_count > 0 )
401 {
402 RadialMenu radial_menu = RadialMenu.GetInstance();
403 radial_menu.SetRadiusOffset( 0 );
404 radial_menu.SetExecuteDistOffset( 0.5 );
405 radial_menu.SetOffsetFromTop( 0 );
406 radial_menu.SetItemCardRadiusOffset( 0.25 );
407 radial_menu.ActivateControllerTimeout( false );
408 }
409
410 //refresh radial menu
411 RadialMenu.GetInstance().Refresh( false );
412 }
413
414 protected void UpdateQuickbarItemCard( RadialQuickbarItem quickbar_item )
415 {
416 Widget item_card_widget = quickbar_item.GetRadialItemCard();
417
418 //get content panels
419 Widget item_details = item_card_widget.FindAnyWidget( "ItemDetails" );
420 TextWidget item_title = TextWidget.Cast( item_card_widget.FindAnyWidget( "ItemTitle" ) );
421
422 //set text
423 TextWidget text_widget = TextWidget.Cast( item_card_widget.FindAnyWidget( TEXT_ITEM_NAME ) );
424 EntityAI item = quickbar_item.GetItem();
425
426 Widget quantity_panel = item_card_widget.FindAnyWidget( "QuantityPanel" );
427 if ( item )
428 {
429 //item text
430 text_widget.SetText( quickbar_item.GetItem().GetDisplayName() );
431
432 //item preview
433 ItemPreviewWidget item_preview = ItemPreviewWidget.Cast( item_card_widget.FindAnyWidget( "ItemPreview" ) );
434 item_preview.SetItem( item );
435 item_preview.SetView( item.GetViewIndex() );
436 item_preview.SetModelOrientation( Vector( 0,0,0 ) );
437
438 //item quantity
439 Widget quantity_stack = quantity_panel.FindAnyWidget( "QuantityStackPanel" );
440 ProgressBarWidget quantity_bar = ProgressBarWidget.Cast( quantity_panel.FindAnyWidget( "QuantityBar" ) );
441 int has_quantity = QuantityConversions.HasItemQuantity( item );
442 //calculate and set quantity
443 if ( has_quantity == QUANTITY_HIDDEN )
444 {
445 quantity_panel.Show( false );
446 }
447 else if ( has_quantity == QUANTITY_COUNT )
448 {
449 //hide bar
450 quantity_bar.Show( false );
451
452 //show stack
453 TextWidget quantity_text = TextWidget.Cast( quantity_stack.FindAnyWidget( "Quantity" ) );
454 quantity_text.SetText( QuantityConversions.GetItemQuantityText( item ) );
455 quantity_stack.Show( true );
456 }
457 else if ( has_quantity == QUANTITY_PROGRESS )
458 {
459 //hide stack
460 quantity_stack.Show( false );
461
462 //show bar
463 float progress_max = quantity_bar.GetMax();
464 int max = item.ConfigGetInt( "varQuantityMax" );
465 int count = item.ConfigGetInt( "count" );
466 float quantity = QuantityConversions.GetItemQuantity( ItemBase.Cast( item ) );
467
468 if ( count > 0 )
469 {
470 max = count;
471 }
472 if ( max > 0 )
473 {
474
475 float value = Math.Round( ( quantity / max ) * 100 );
476 quantity_bar.SetCurrent( value );
477 }
478
479 quantity_bar.Show( true );
480 }
481
482 //display content panels
483 item_details.Show( true );
484 item_title.Show( false );
485 }
486 else if ( quickbar_item.GetCategorySwitchID() != -1 )
487 {
488 item_title.SetText( quickbar_item.GetItemName() );
489
490 item_details.Show( false );
491 item_title.Show( true );
492 }
493 else
494 {
495 item_title.SetText( "#container_empty" );
496
497 //display content panels
498 item_details.Show( false );
499 item_title.Show( true );
500 }
501 }
502
503 //Common
504 protected void DeleteItems()
505 {
506 Widget child;
507 Widget child_to_destroy;
508
509 child = m_ItemCardPanel.GetChildren();
510 while ( child )
511 {
512 child_to_destroy = child;
513 child = child.GetSibling();
514
515 delete child_to_destroy;
516 }
517 }
518
519 protected void ChangeCurrentCategory(int category)
520 {
521 m_CurrentCategory = category;
522 RefreshQuickbar(false);
524 }
525
526 //============================================
527 // Radial Menu Events
528 //============================================
529 //Common
531 {
532 }
533
534 //Mouse
535 void OnMouseSelect( Widget w )
536 {
537 MarkSelected( w );
538 }
539
540 void OnMouseDeselect( Widget w )
541 {
542 UnmarkSelected( w );
543 }
544
545 void OnMouseExecute( Widget w )
546 {
547 }
548
550 void OnMousePressLeft( Widget w )
551 {
552 PrimaryAction( w );
553 }
554
556 void OnMousePressRight( Widget w )
557 {
558 BackOneLevel();
559 }
560
561 //Controller
562 void OnControllerSelect( Widget w )
563 {
564 MarkSelected( w );
565 }
566
567 void OnControllerDeselect( Widget w )
568 {
569 UnmarkSelected( w );
570 }
571
572 void OnControllerPressSelect( Widget w )
573 {
574 PrimaryAction( w );
575 }
576
577 void OnControllerPressBack( Widget w )
578 {
579 //SecondaryAction( w );
580 BackOneLevel();
581 }
582
583 //Actions
584 protected void MarkSelected( Widget w )
585 {
586 m_SelectedItem = w;
587
588 if (w)
589 {
590 RadialQuickbarItem quickbar_item;
591 w.GetUserData( quickbar_item );
592 ItemBase item;
593
594 if (quickbar_item && Class.CastTo(item,quickbar_item.GetItem()))
595 {
596 w.SetFlags(WidgetFlags.DISABLED);
597 }
598 else
599 {
600 w.ClearFlags(WidgetFlags.DISABLED);
601 }
602/*
603 //is not category
604 if ( quickbar_item )
605 {
606 if ( quickbar_item.GetItem() )
607 {
608 //alter item visual
609 TextWidget text_widget = TextWidget.Cast( quickbar_item.GetRadialItemCard().FindAnyWidget( TEXT_ITEM_NAME ) );
610 text_widget.SetColor( ARGB( 255, 66, 175, 95 ) );
611 }
612 else
613 {
614 //alter item visual
615 TextWidget title_widget = TextWidget.Cast( quickbar_item.GetRadialItemCard().FindAnyWidget( TEXT_ITEM_TITLE ) );
616 title_widget.SetColor( ARGB( 255, 66, 175, 95 ) );
617 }
618 }
619*/
620 }
621 }
622
623 protected void UnmarkSelected( Widget w )
624 {
625 m_SelectedItem = NULL;
626
627 /*
628 if ( w )
629 {
630 RadialQuickbarItem quickbar_item;
631 w.GetUserData( quickbar_item );
632
633 //is not category
634 if ( quickbar_item )
635 {
636 if ( quickbar_item.GetItem() )
637 {
638 //alter item visual
639 TextWidget text_widget = TextWidget.Cast( quickbar_item.GetRadialItemCard().FindAnyWidget( TEXT_ITEM_NAME ) );
640 text_widget.SetColor( ARGB( 255, 255, 255, 255 ) );
641 }
642 else
643 {
644 //alter item visual
645 TextWidget title_widget = TextWidget.Cast( quickbar_item.GetRadialItemCard().FindAnyWidget( TEXT_ITEM_TITLE ) );
646 title_widget.SetColor( ARGB( 255, 255, 255, 255 ) );
647 }
648 }
649 }
650 */
651 }
652
653 protected void PrimaryAction( Widget w )
654 {
655 if ( instance.m_SelectedItem )
656 {
657 if ( !GetGame().IsDedicatedServer() )
658 {
659 RadialQuickbarItem quickbar_item;
660 instance.m_SelectedItem.GetUserData( quickbar_item );
661
662 if ( quickbar_item )
663 {
664 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
665
666 //ASSIGN ACTION
667 if ( GetItemToAssign() )
668 {
669 //assign item to slot
670 if ( quickbar_item.GetItem() == GetItemToAssign() )
671 {
672 player.RemoveQuickBarEntityShortcut( GetItemToAssign() );
673 }
674 else
675 {
676 player.SetQuickBarEntityShortcut( GetItemToAssign(), quickbar_item.GetId() );
677 }
678 }
679 //LIGHTS
680 else if (m_CurrentCategory == RadialQuickbarCategory.SPECIALIZED_LIGHTS && quickbar_item.IsLightSourceExtra())
681 {
682 HandleLights(quickbar_item);
683 }
684 //NVG
685 else if (m_CurrentCategory == RadialQuickbarCategory.SPECIALIZED_LIGHTS && quickbar_item.IsNVGExtra())
686 {
687 HandleNVG(quickbar_item);
688 }
689 //change quickbar category
690 else if (quickbar_item.GetCategorySwitchID() != -1)
691 {
692 ChangeCurrentCategory(quickbar_item.GetCategorySwitchID());
693 return;
694 }
695 //SWAP
696 else
697 {
698 EntityAI item = quickbar_item.GetItem();
699
700 if ( item )
701 {
702 //swap
703 player.RadialQuickBarSingleUse( quickbar_item.GetId() + 1 ); //id must begin with 1 (simulating key press 1-9)
704 }
705 }
706
707 RefreshQuickbar( false );
708 }
709 }
710 }
711 }
712
713 protected void SecondaryAction( Widget w )
714 {
715 if ( instance.m_SelectedItem && m_CurrentCategory == RadialQuickbarCategory.DEFAULT )
716 {
717 if ( !GetGame().IsDedicatedServer() )
718 {
719 RadialQuickbarItem quickbar_item;
720 instance.m_SelectedItem.GetUserData( quickbar_item );
721
722 if ( quickbar_item )
723 {
724 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
725 EntityAI item = quickbar_item.GetItem();
726
727 if ( item )
728 {
729 player.RadialQuickBarCombine( quickbar_item.GetId() + 1 ); //id must begin with 1 (simulating key press 1-9)
730 RefreshQuickbar( false );
731 }
732 }
733 }
734 }
735 }
736
737 // returns to default, missing hierarchy to properly traverse ATM
738 protected void BackOneLevel()
739 {
740 if (m_CurrentCategory != RadialQuickbarCategory.DEFAULT)
741 {
742 ChangeCurrentCategory(RadialQuickbarCategory.DEFAULT);
743 }
744 }
745
746 //-------------------------------------------
747 //NVG/Light handling extension
748 //-------------------------------------------
750 {
751 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
752 ItemBase item = ItemBase.Cast(quickbar_item.GetItem());
753 ActionManagerClient mngr_client = ActionManagerClient.Cast(player.GetActionManager());
754 ActionTarget atrg;
755
756 if ( Headtorch_ColorBase.Cast(item) )
757 {
758 atrg = new ActionTarget(item,null,-1,vector.Zero,-1.0);
759 if ( mngr_client.GetAction(ActionTurnOnHeadtorch).Can(player,atrg,null) )
760 {
761 mngr_client.PerformActionStart(player.GetActionManager().GetAction(ActionTurnOnHeadtorch),atrg,null);
762 }
763 else if ( mngr_client.GetAction(ActionTurnOffHeadtorch).Can(player,atrg,null) )
764 {
765 mngr_client.PerformActionStart(player.GetActionManager().GetAction(ActionTurnOffHeadtorch),atrg,null);
766 }
767 }
768 else if ( Mich2001Helmet.Cast(item.GetHierarchyParent()) )
769 {
770 atrg = new ActionTarget(item.GetHierarchyParent(),null,-1,vector.Zero,-1.0);
771 if ( mngr_client.GetAction(ActionTurnOnHelmetFlashlight).Can(player,atrg,null) )
772 {
773 mngr_client.PerformActionStart(player.GetActionManager().GetAction(ActionTurnOnHelmetFlashlight),atrg,null);
774 }
775 else if ( mngr_client.GetAction(ActionTurnOffHelmetFlashlight).Can(player,atrg,null) )
776 {
777 mngr_client.PerformActionStart(player.GetActionManager().GetAction(ActionTurnOffHelmetFlashlight),atrg,null);
778 }
779 }
780 }
781
782 void HandleNVG(RadialQuickbarItem quickbar_item)
783 {
784 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
785 ActionManagerClient mngr_client = ActionManagerClient.Cast(player.GetActionManager());
786 ActionTarget atrg;
787
788 atrg = new ActionTarget(quickbar_item.GetItem().GetHierarchyParent(),null,-1,vector.Zero,-1.0);
789 if ( mngr_client.GetAction(ActionToggleNVG).Can(player,atrg,null) )
790 {
791 mngr_client.PerformActionStart(player.GetActionManager().GetAction(ActionToggleNVG),atrg,null);
792 }
793 }
794
796 {
797 return m_IsMenuClosing;
798 }
799
800 void SetMenuClosing(bool state)
801 {
802 m_IsMenuClosing = state;
803 }
804
805 protected void UpdateControlsElements()
806 {
807 Widget toolbarBackSpacer = layoutRoot.FindAnyWidget("BackSpacer");
808
809 RichTextWidget toolbarSelectIcon = RichTextWidget.Cast(layoutRoot.FindAnyWidget("SelectIcon"));
810 RichTextWidget toolbarBackIcon = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
811
812 string selectAction;
813 string backAction;
814 int controllerID;
815
816 if (GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer() && GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.MOUSE_AND_KEYBOARD)
817 {
818 selectAction = "UAMenuSelect";
819 backAction = "UAMenuBack";
820 controllerID = EUAINPUT_DEVICE_KEYBOARDMOUSE;
821 }
822 else
823 {
824 selectAction = "UAUISelect";
825 backAction = "UAUIBack";
826 controllerID = EUAINPUT_DEVICE_CONTROLLER;
827 }
828
829 toolbarSelectIcon.SetText(InputUtils.GetRichtextButtonIconFromInputAction(selectAction, "", controllerID, InputUtils.ICON_SCALE_TOOLBAR));
830 toolbarBackIcon.SetText(InputUtils.GetRichtextButtonIconFromInputAction(backAction, "", controllerID, InputUtils.ICON_SCALE_TOOLBAR));
831 toolbarBackSpacer.Show(m_CurrentCategory != RadialQuickbarCategory.DEFAULT);
832 }
833
834 override void OnPlayerDeath()
835 {
836 super.OnPlayerDeath();
837
838 // Close inventory menu when this menu got closed by the character death event as player could be assigning a item to the quickbar
839 // in the moment he dies and the inventory menu is opened too.
840 MissionGameplay missionGameplay = MissionGameplay.Cast(g_Game.GetMission());
841 if (missionGameplay && missionGameplay.GetInventory())
842 {
843 missionGameplay.HideInventory();
844 }
845 }
846}
void OnInputPresetChanged()
Definition inventory.c:168
DetachActionData m_ItemName
ItemBase m_Item
Definition actioninput.c:16
class ServerBrowserHelperFunctions m_Id
void PerformActionStart(ActionBase action, ActionTarget target, ItemBase item, Param extra_data=NULL)
Super root of all classes in Enforce script.
Definition enscript.c:11
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Definition inpututils.c:167
static const float ICON_SCALE_TOOLBAR
Definition inpututils.c:15
Definition enmath.c:7
Mission class.
Definition gameplay.c:687
void CreateContent(int selected_item_id=-1)
override bool OnMouseEnter(Widget w, int x, int y)
override void OnShow()
static EntityAI m_ItemToAssign
void UpdateQuickbarItemCard(RadialQuickbarItem quickbar_item)
static void CloseMenu()
override bool UseMouse()
void MarkSelected(Widget w)
static void SetItemToAssign(EntityAI item)
void OnControllerPressSelect(Widget w)
void CheckForLightsAndNVG(out array< ref RadialQuickbarItem > items, int last_idx)
ref array< ref RadialQuickbarItem > m_Items
void RefreshQuickbar(bool reset_selection=true)
override void OnHide()
void OnControlsChanged(RadialMenuControlType type)
void OnMousePressRight(Widget w)
RMB.
void OnMouseExecute(Widget w)
void OnControllerDeselect(Widget w)
override bool UseGamepad()
void UnmarkSelected(Widget w)
void OnControllerSelect(Widget w)
static RadialQuickbarMenu GetMenuInstance()
void GetItems(out array< ref RadialQuickbarItem > items)
void HandleLights(RadialQuickbarItem quickbar_item)
void PrimaryAction(Widget w)
void HandleNVG(RadialQuickbarItem quickbar_item)
void OnMouseDeselect(Widget w)
Widget m_SelectedItem
void OnControllerPressBack(Widget w)
override Widget Init()
override bool OnController(Widget w, int control, int value)
void SetMenuClosing(bool state)
void OnMousePressLeft(Widget w)
LMB.
void OnMouseSelect(Widget w)
override void OnPlayerDeath()
static void OpenMenu(UIScriptedMenu parent=NULL)
Widget m_ToolbarPanel
static EntityAI GetItemToAssign()
static RadialQuickbarMenu instance
void ChangeCurrentCategory(int category)
void SecondaryAction(Widget w)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3868
Mission mission
proto native CGame GetGame()
Widget m_RadialMenuSelector
void SetRadialItemCard(Widget widget)
Widget m_RadialMenuItemCard
Widget GetRadialItemCard()
const int QUANTITY_PROGRESS
Definition constants.c:518
const int QUANTITY_COUNT
Definition constants.c:517
const int QUANTITY_HIDDEN
Definition constants.c:516
string m_Category
folder structure eg. StaticEntities/Walls
Definition enentity.c:846
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
const int MENU_RADIAL_QUICKBAR
Definition constants.c:198
WidgetFlags
Definition enwidgets.c:58
Icon x
Icon y
EInputDeviceType
Definition input.c:3
void RefreshQuickbar()
void UpdateControlsElements()
PlayerBase GetPlayer()
RadialMenuControlType
Definition radialmenu.c:2
void RadialMenu()
Definition radialmenu.c:84
RadialQuickbarCategory
@ DEFAULT
@ SPECIALIZED_LIGHTS
bool IsNVGExtra()
string GetItemName()
bool IsLightSourceExtra()
enum RadialQuickbarCategory m_IsLightSourceExtra
void RadialQuickbarItem(int id, EntityAI item, string item_name, int category=RadialQuickbarCategory.DEFAULT, int category_switch=-1)
void SetItem(EntityAI item)
int GetItemCategory()
int m_CategorySwitchID
EntityAI GetItem()
int GetCategorySwitchID()
int GetId()
bool m_IsNVG
ItemBase m_Items[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:28