90 protected Widget m_ItemCardPanel;
92 protected Widget m_ToolbarPanel;
94 protected bool m_IsMenuClosing;
95 protected int m_CurrentCategory;
97 const string TEXT_ITEM_NAME =
"ItemName";
98 const string TEXT_ITEM_TITLE =
"ItemTitle";
100 protected Widget m_SelectedItem;
104 static RadialQuickbarMenu instance;
109 void RadialQuickbarMenu()
122 void ~RadialQuickbarMenu()
126 GetGame().GetMission().RemoveActiveInputExcludes({
"radialmenu"},
false);
130 static void SetItemToAssign(
EntityAI item )
132 m_ItemToAssign = item;
137 return m_ItemToAssign;
140 static RadialQuickbarMenu GetMenuInstance()
147 #ifdef PLATFORM_CONSOLE
160 static void CloseMenu()
162 GetGame().GetUIManager().Back();
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);
178 RadialMenu.GetInstance().SetWidgetInitialized(
false);
181 RadialMenu.GetInstance().SetWidgetProperties(
"gui/layouts/radial_menu/radial_quickbar/radial_quickbar_delimiter.layout");
189 m_ToolbarPanel = layoutRoot.FindAnyWidget(
"toolbar_bg" );
190 m_ToolbarPanel.Show(
true );
202 IngameHud hud = IngameHud.Cast(
mission.GetHud());
205 hud.ShowQuickbarUI(
false);
210 m_IsMenuClosing =
false;
220 IngameHud hud = IngameHud.Cast(
mission.GetHud());
223 hud.ShowQuickbarUI(
true);
228 RadialQuickbarMenu.SetItemToAssign(NULL);
229 m_IsMenuClosing =
true;
234 super.OnController( w, control, value );
243 super.OnMouseEnter( w,
x,
y );
250 override bool UseMouse()
255 override bool UseGamepad()
266 int selected_item_id = -1;
267 if ( !reset_selection )
270 if ( instance.m_SelectedItem )
272 instance.m_SelectedItem.GetUserData( quickbar_item );
273 selected_item_id = quickbar_item.GetId();
279 CreateContent( selected_item_id );
290 int size = player.GetQuickBarSize();
293 for (
int i = 0; i < size; ++i )
295 entity = player.GetQuickBarEntity( i );
300 CheckForLightsAndNVG(m_Items,i);
308 ItemBase headgear =
ItemBase.Cast(player.FindAttachmentBySlotName(
"Headgear"));
309 ItemBase eyewear =
ItemBase.Cast(player.FindAttachmentBySlotName(
"Eyewear"));
314 entity = headgear.FindAttachmentBySlotName(
"NVG");
324 entity = eyewear.FindAttachmentBySlotName(
"NVG");
330 else if ( eyewear.IsLightSource() && eyewear.HasEnergyManager() && eyewear.GetCompEM().CanWork() )
340 if ( headgear.GetInventory().AttachmentCount() > 0 )
343 for (
int i = 0; i < headgear.GetInventory().AttachmentCount(); i++)
345 attachment =
ItemBase.Cast(headgear.GetInventory().GetAttachmentFromIndex(i));
346 if ( attachment && attachment.IsLightSource() && attachment.HasEnergyManager() && attachment.GetCompEM().CanWork() )
367 protected void CreateContent(
int selected_item_id = -1 )
372 int category_item_count;
374 for (
int i = 0; i < m_Items.Count(); ++i )
378 if (quickbar_item.GetItemCategory() == m_CurrentCategory)
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 );
385 UpdateQuickbarItemCard( quickbar_item );
388 item_card_widget.SetUserData( quickbar_item );
391 if ( quickbar_item.GetId() == selected_item_id )
393 MarkSelected( quickbar_item.GetRadialItemCard() );
395 category_item_count++;
400 if ( category_item_count > 0 )
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 );
416 Widget item_card_widget = quickbar_item.GetRadialItemCard();
419 Widget item_details = item_card_widget.FindAnyWidget(
"ItemDetails" );
424 EntityAI item = quickbar_item.GetItem();
426 Widget quantity_panel = item_card_widget.FindAnyWidget(
"QuantityPanel" );
430 text_widget.SetText( quickbar_item.GetItem().GetDisplayName() );
434 item_preview.SetItem( item );
435 item_preview.SetView( item.GetViewIndex() );
436 item_preview.SetModelOrientation(
Vector( 0,0,0 ) );
439 Widget quantity_stack = quantity_panel.FindAnyWidget(
"QuantityStackPanel" );
440 ProgressBarWidget quantity_bar = ProgressBarWidget.Cast( quantity_panel.FindAnyWidget(
"QuantityBar" ) );
445 quantity_panel.Show(
false );
450 quantity_bar.Show(
false );
455 quantity_stack.Show(
true );
460 quantity_stack.Show(
false );
463 float progress_max = quantity_bar.GetMax();
464 int max = item.ConfigGetInt(
"varQuantityMax" );
465 int count = item.ConfigGetInt(
"count" );
475 float value =
Math.Round( ( quantity / max ) * 100 );
476 quantity_bar.SetCurrent( value );
479 quantity_bar.Show(
true );
483 item_details.Show(
true );
484 item_title.Show(
false );
486 else if ( quickbar_item.GetCategorySwitchID() != -1 )
488 item_title.SetText( quickbar_item.GetItemName() );
490 item_details.Show(
false );
491 item_title.Show(
true );
495 item_title.SetText(
"#container_empty" );
498 item_details.Show(
false );
499 item_title.Show(
true );
504 protected void DeleteItems()
509 child = m_ItemCardPanel.GetChildren();
512 child_to_destroy = child;
513 child = child.GetSibling();
515 delete child_to_destroy;
519 protected void ChangeCurrentCategory(
int category)
521 m_CurrentCategory = category;
535 void OnMouseSelect(
Widget w )
540 void OnMouseDeselect(
Widget w )
545 void OnMouseExecute(
Widget w )
550 void OnMousePressLeft(
Widget w )
556 void OnMousePressRight(
Widget w )
562 void OnControllerSelect(
Widget w )
567 void OnControllerDeselect(
Widget w )
572 void OnControllerPressSelect(
Widget w )
577 void OnControllerPressBack(
Widget w )
584 protected void MarkSelected(
Widget w )
591 w.GetUserData( quickbar_item );
594 if (quickbar_item &&
Class.CastTo(item,quickbar_item.GetItem()))
623 protected void UnmarkSelected(
Widget w )
625 m_SelectedItem = NULL;
653 protected void PrimaryAction(
Widget w )
655 if ( instance.m_SelectedItem )
657 if ( !
GetGame().IsDedicatedServer() )
660 instance.m_SelectedItem.GetUserData( quickbar_item );
667 if ( GetItemToAssign() )
670 if ( quickbar_item.GetItem() == GetItemToAssign() )
672 player.RemoveQuickBarEntityShortcut( GetItemToAssign() );
676 player.SetQuickBarEntityShortcut( GetItemToAssign(), quickbar_item.GetId() );
680 else if (m_CurrentCategory ==
RadialQuickbarCategory.SPECIALIZED_LIGHTS && quickbar_item.IsLightSourceExtra())
682 HandleLights(quickbar_item);
687 HandleNVG(quickbar_item);
690 else if (quickbar_item.GetCategorySwitchID() != -1)
692 ChangeCurrentCategory(quickbar_item.GetCategorySwitchID());
698 EntityAI item = quickbar_item.GetItem();
703 player.RadialQuickBarSingleUse( quickbar_item.GetId() + 1 );
713 protected void SecondaryAction(
Widget w )
717 if ( !
GetGame().IsDedicatedServer() )
720 instance.m_SelectedItem.GetUserData( quickbar_item );
725 EntityAI item = quickbar_item.GetItem();
729 player.RadialQuickBarCombine( quickbar_item.GetId() + 1 );
738 protected void BackOneLevel()
756 if ( Headtorch_ColorBase.Cast(item) )
761 mngr_client.PerformActionStart(player.GetActionManager().GetAction(
ActionTurnOnHeadtorch),atrg,
null);
768 else if ( Mich2001Helmet.Cast(item.GetHierarchyParent()) )
788 atrg =
new ActionTarget(quickbar_item.GetItem().GetHierarchyParent(),
null,-1,
vector.Zero,-1.0);
791 mngr_client.PerformActionStart(player.GetActionManager().GetAction(
ActionToggleNVG),atrg,
null);
797 return m_IsMenuClosing;
800 void SetMenuClosing(
bool state)
802 m_IsMenuClosing = state;
807 Widget toolbarBackSpacer = layoutRoot.FindAnyWidget(
"BackSpacer");
818 selectAction =
"UAMenuSelect";
819 backAction =
"UAMenuBack";
820 controllerID = EUAINPUT_DEVICE_KEYBOARDMOUSE;
824 selectAction =
"UAUISelect";
825 backAction =
"UAUIBack";
826 controllerID = EUAINPUT_DEVICE_CONTROLLER;
829 toolbarSelectIcon.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(selectAction,
"", controllerID,
InputUtils.ICON_SCALE_TOOLBAR));
830 toolbarBackIcon.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(backAction,
"", controllerID,
InputUtils.ICON_SCALE_TOOLBAR));