Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ToolbarContextBrowserBuildingUIComponent.c
Go to the documentation of this file.
1 class SCR_ToolbarContextBrowserBuildingUIComponent : ScriptedWidgetComponent
3 {
4  [Attribute("BrowserButton")]
5  protected string m_sOpenContentBrowserButtonName;
6 
7  [Attribute()]
8  protected ref SCR_EditorContentBrowserDisplayConfig m_ContentBrowserDisplayConfig;
9 
10  //------------------------------------------------------------------------------------------------
11  protected void OpenAssetBrowserButton(Widget widget, float value, EActionTrigger actionTrigger)
12  {
13  PlayerController playerController = GetGame().GetPlayerController();
14  if (!playerController)
15  return;
16 
17  ChimeraCharacter char = ChimeraCharacter.Cast(playerController.GetControlledEntity());
18  if (!char)
19  return;
20 
21  FactionAffiliationComponent factionComp = FactionAffiliationComponent.Cast(char.FindComponent(FactionAffiliationComponent));
22  if (!factionComp)
23  return;
24 
25  SCR_CampaignFaction faction = SCR_CampaignFaction.Cast(factionComp.GetAffiliatedFaction());
26  if (!faction)
27  return;
28 
29  // Get all display config data from attribute
30  bool saveBrowserState;
31  array<EEditableEntityLabel> alwaysActiveLabels = {}, whitelistLabels = {};
32  m_ContentBrowserDisplayConfig.GetAlwaysActiveLabels(alwaysActiveLabels);
33  m_ContentBrowserDisplayConfig.GetWhiteListeLabels(whitelistLabels);
34  array<EEditableEntityLabelGroup> whitelistLabelGroups = {};
35  m_ContentBrowserDisplayConfig.GetWhiteListeLabelGroups(whitelistLabelGroups);
36 
37  LocalizedString browserHeader = m_ContentBrowserDisplayConfig.GetHeader();
38  saveBrowserState = m_ContentBrowserDisplayConfig.GetSaveContentBrowserState();
39 
40  // Add player's current faction as always active label
41  EEditableEntityLabel factionLabel = faction.GetFactionLabel();
42  alwaysActiveLabels.Insert(factionLabel);
43 
44  SCR_EditorContentBrowserDisplayConfig displayConfig = new SCR_EditorContentBrowserDisplayConfig(whitelistLabelGroups, whitelistLabels, alwaysActiveLabels, saveBrowserState, browserHeader);
45 
47  if (contentBrowserManager)
48  contentBrowserManager.OpenBrowserLabelConfigInstance(displayConfig);
49  }
50 
51  //------------------------------------------------------------------------------------------------
52  override void HandlerAttached(Widget w)
53  {
54  Widget buttonWidget = w.FindAnyWidget(m_sOpenContentBrowserButtonName);
55  if (buttonWidget)
56  ButtonActionComponent.GetOnAction(buttonWidget).Insert(OpenAssetBrowserButton);
57  }
58 }
EEditableEntityLabel
EEditableEntityLabel
Definition: EEditableEntityLabel.c:1
SCR_EditorContentBrowserDisplayConfig
Definition: SCR_EditorContentBrowserDisplayConfig.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ContentBrowserEditorComponent
Definition: SCR_ContentBrowserEditorComponent.c:16
Attribute
typedef Attribute
Post-process effect of scripted camera.
ButtonActionComponent
Component to execute action when the button or its shortcut is pressed.
Definition: ButtonActionComponent.c:2
SCR_CampaignFaction
Definition: SCR_CampaignFaction.c:2
SCR_ToolbarContextBrowserBuildingUIComponent
Load a proper config file for player faction and open an asset browser.
Definition: SCR_ToolbarContextBrowserBuildingUIComponent.c:2
LocalizedString
Definition: LocalizedString.c:21