Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AttributesEditorUIComponent.c
Go to the documentation of this file.
1 
4 {
5  [Attribute()]
6  protected ref SCR_ArsenalItemTypeUIConfig m_ArsenalItemTypeConfig;
7 
8  [Attribute(defvalue: "4", desc: "If more then this amount tabs are shown then the text will be hidden and only icon will be shown")]
9  protected int m_iMaxTabsUntilImageOnly;
10 
11  [Attribute("200")]
12  protected int m_iTabTextAndImageWidth;
13 
14  [Attribute("64")]
15  protected int m_iTabImageOnlyWidth;
16 
17  [Attribute()]
18  protected string m_sTabWidgetName;
19 
20  [Attribute()]
21  protected string m_sContentHolderWidgetName;
22 
23  [Attribute("NoAttributeNote")]
24  protected string m_sNoAttributeNoteName;
25 
26  [Attribute("ButtonClose")]
27  protected string m_sButtonCloseButtonName;
28 
29  [Attribute("ButtonCloseAndSave")]
30  protected string m_sButtonCloseAndSaveButtonName;
31 
32  [Attribute()]
33  protected string m_sButtonResetWidgetName;
34 
35  [Attribute()]
36  protected string m_sOutsideWindowCloseButtonName;
37 
38  [Attribute()]
39  protected string m_sButtonEndGameCloseName;
40 
41  [Attribute()]
42  protected string m_sButtonEndGameAcceptName;
43 
44  [Attribute("ButtonLockUnlock")]
45  protected string m_sGamepadToggleAttributeButtonName;
46 
47  [Attribute("CustomTitlePage")]
48  protected string m_sTitleHeaderWidgetName;
49 
50  [Attribute("#AR-AttributesDialog_TitlePage_Photo_Text")]
51  protected LocalizedString m_sPhotoModeTitle;
52 
53  [Attribute("#AR-AttributesDialog_TitlePage_Admin_Text")]
54  protected LocalizedString m_sAdminModeTitle;
55 
56  [Attribute("#AR-AttributesDialog_TitlePage_FactionOnly_Text")]
57  protected LocalizedString m_sFactionOnlyTitle;
58 
59  [Attribute("#AR-Tasks_Objective")]
60  protected LocalizedString m_sTaskTitle;
61 
62  [Attribute("")]
63  protected LocalizedString m_sEndGameTitle;
64 
65  [Attribute("#AR-AttributesDialog_TitlePage_Entity_Text")]
66  protected LocalizedString m_sMultiEntitiesTitle;
67 
68  [Attribute("#AR-AttributesDialog_TitlePage_Editing_Text")]
69  protected LocalizedString m_sEditingTitlePart;
70 
71  [Attribute("2", "If more types then given type, m_sMultiEntitiesTitle will be used as text")]
72  protected int m_iEntityTypesUntilMulti;
73 
74  [Attribute(desc: "A List of translated names for entity types which is also used to display the order of entity types (Eg if multiple which one to show first)")]
75  protected ref array<ref SCR_EntityAttributeTitleType> m_aEntityTypeNames;
76 
77  [Attribute("{E2CBA6F76AAA42AF}UI/Fonts/Roboto/Roboto_Regular.fnt")]
78  protected string m_sFontForHeaderEntityAmount;
79 
80  //End game
81  [Attribute()]
82  protected LocalizedString m_sEndGamePopUpTitle;
83 
84  [Attribute()]
85  protected LocalizedString m_sEndGamePopUpMessage;
86 
87  [Attribute()]
88  protected LocalizedString m_sEndGamePopUpConfirm;
89 
90  [Attribute(SCR_SoundEvent.CLICK, UIWidgets.EditBox, "")]
91  protected string m_sSfxClickedOutsideWindow_Comfirm;
92 
93  [Attribute(SCR_SoundEvent.CLICK_CANCEL, UIWidgets.EditBox, "")]
94  protected string m_sSfxClickedOutsideWindow_Cancel;
95 
96  [Attribute(SCR_SoundEvent.CLICK, UIWidgets.EditBox, "")]
97  protected string m_sSfxOnOpenDialog;
98 
99  //~ Set to comfirm or cancel depending if a setting is changed
100  protected string m_sSfxOnCloseDialog;
101 
102  protected bool m_bIsEndGame;
103 
104  //Tab saving
105  protected bool m_bIsGlobalAttribute;
106  protected EEditorMode m_ActiveEditorMode;
107 
108  //Widget Refs
109  protected SCR_TabViewComponent m_TabViewComponent;
110  protected Widget m_ContentHolder;
111  protected Widget m_ButtonCloseAndSaveButton;
112  protected Widget m_ButtonCloseButton;
113  protected SCR_InputButtonComponent m_ResetButton;
114  protected SCR_InputButtonComponent m_GamepadToggleEnableButton;
115  protected SCR_BaseEditorAttributeUIComponent m_GamepadFocusAttribute;
116 
117  //Ref
118  protected SCR_AttributesManagerEditorComponent m_AttributesManager;
119 
120  protected int m_iCurrentTab = -1;
121  protected ref array<ResourceName> m_CategoryConfigs;
122  protected ResourceName m_currentCategory;
123  protected bool m_bTabImageOnly;
124 
125  //State
126  protected bool m_bHasConflictingAttributes;
127 
128  protected void ButtonClose()
129  {
131  if (menu)
132  {
133  menu.RemoveAutoClose();
134  menu.CloseSelf();
135  }
136 
137  if (m_AttributesManager)
138  m_AttributesManager.ConfirmEditing();
139  }
140 
141  protected void OnCancelEndGame()
142  {
144  if (menu)
145  {
146  menu.RemoveAutoClose();
147  menu.CloseSelf();
148  }
149 
150  if (m_AttributesManager)
151  m_AttributesManager.CancelEditing();
152  }
153 
154  protected void EndGamePopupComfirm()
155  {
156  if (m_AttributesManager)
157  m_AttributesManager.ConfirmEditing();
158  }
159 
160  protected void OnAcceptEndGame()
161  {
162  SCR_ConfigurableDialogUi dlg = SCR_CommonDialogs.CreateDialog("session_end");
163  if (!dlg)
164  return;
165 
166  dlg.m_OnConfirm.Insert(EndGamePopupComfirm);
167 
168  }
169 
170  protected void ButtonReset()
171  {
172  if (m_AttributesManager)
173  m_AttributesManager.Reset(true);
174  }
175 
176  protected void OnReset()
177  {
178  if (m_ResetButton)
179  m_ResetButton.SetEnabled(false);
180 
181  if (m_ButtonCloseAndSaveButton && m_ButtonCloseButton)
182  {
183  m_ButtonCloseButton.SetVisible(true);
184  m_ButtonCloseAndSaveButton.SetVisible(false);
185  m_sSfxOnCloseDialog = m_sSfxClickedOutsideWindow_Cancel;
186  }
187  }
188 
189  //To toggle the enable/disable of a conflicted attribute
190  protected void ButtonAttributeEnableToggle()
191  {
192  if (m_GamepadFocusAttribute)
193  m_GamepadFocusAttribute.ToggleEnableAttributeTickbox();
194  }
195 
196 
198  void OnAttributeChanged()
199  {
200  if (m_ResetButton)
201  m_ResetButton.SetEnabled(true);
202 
203  if (m_ButtonCloseAndSaveButton && m_ButtonCloseButton)
204  {
205  m_ButtonCloseButton.SetVisible(false);
206  m_ButtonCloseAndSaveButton.SetVisible(true);
207  m_sSfxOnCloseDialog = m_sSfxClickedOutsideWindow_Comfirm;
208  }
209  }
210 
211  protected void RefreshAttributes()
212  {
213  SetHasConflictingAttribute(false);
214 
215  Widget widget = GetWidget();
216  if (!widget) return;
217 
218  WorkspaceWidget workspace = GetGame().GetWorkspace();
219  if (!workspace) return;
220 
221  if (!m_ContentHolder) return;
222 
223  if (!m_AttributesManager) return;
224 
225  //--- Delete current attributes
226  while (m_ContentHolder.GetChildren())
227  {
228  delete m_ContentHolder.GetChildren();
229  }
230 
231  if (m_currentCategory != string.Empty)
232  {
233  //--- Add new attributes
234  array<SCR_BaseEditorAttribute> attributes = new array<SCR_BaseEditorAttribute>;
235  m_AttributesManager.GetEditedAttributes(attributes);
236 
237  foreach (SCR_BaseEditorAttribute attribute: attributes)
238  {
239  if (attribute.GetCategoryConfig() != m_currentCategory) continue;
240 
241  ResourceName layout = attribute.GetLayout();
242  if (layout.IsEmpty()) continue;
243 
244  Widget attributeWidget = workspace.CreateWidgets(layout, m_ContentHolder); //~Todo: Spawn attribute base and add attribute to AttributeHolder
245  if (!attributeWidget) continue;
246 
248  if (attributesUI)
249  {
250  attributesUI.Init(attributeWidget, attribute);
251  attributesUI.SetFromVar(attribute.GetVariable());
252 
253  //Subscribe to events
254  if (attribute.GetHasConflictingValues())
255  attributesUI.GetOnAttributeUIFocusChanged().Insert(SetGamepadAttributeFocus);
256 
257  attributesUI.GetOnAttributeChanged().Insert(OnAttributeChanged);
258  }
259 
260  //So UI knows that values are conflicted and adds indents to all
261  if (!m_bHasConflictingAttributes && attribute.GetHasConflictingValues())
262  SetHasConflictingAttribute(true);
263  }
264  }
265  }
266 
267  protected void OnCurrentTabChanged(SCR_TabViewComponent tabView, Widget w, int tabIndex)
268  {
269  //Set text active of selected
270  if (m_bTabImageOnly && m_iCurrentTab > -1)
271  {
272  m_TabViewComponent.ShowTabText(m_iCurrentTab, false, m_iTabImageOnlyWidth);
273  m_TabViewComponent.ShowTabText(tabIndex, true, m_iTabTextAndImageWidth);
274  }
275 
276  if (m_CategoryConfigs.Count() == 0)
277  return;
278 
279  if (m_iCurrentTab != tabIndex)
280  {
281  m_iCurrentTab = tabIndex;
282 
283  m_currentCategory = m_CategoryConfigs[tabIndex];
284  RefreshAttributes();
285 
286  if (m_bIsGlobalAttribute)
287  m_AttributesManager.SetCurrentCategory(m_currentCategory);
288  }
289  }
290 
291  ResourceName GetCurrentCategory()
292  {
293  return m_currentCategory;
294  }
295  void SetWidgetVisible(bool visible)
296  {
297  Widget widget = GetWidget();
298  if (!widget) return;
299 
300  if (visible) RefreshAttributes();
301 
302  widget.SetVisible(visible);
303  widget.SetEnabled(visible);
304  }
305 
306  //Set which attribute is on focus
307  protected void SetGamepadAttributeFocus(SCR_BaseEditorAttributeUIComponent attributeUI)
308  {
309  m_GamepadFocusAttribute = attributeUI;
310  m_GamepadToggleEnableButton.SetEnabled(m_GamepadFocusAttribute != null && m_GamepadFocusAttribute.GetTickboxEnabled());
311  }
312 
313  protected void SetHasConflictingAttribute(bool hasConflicting)
314  {
315  m_bHasConflictingAttributes = hasConflicting;
316 
317  if (m_GamepadToggleEnableButton)
318  m_GamepadToggleEnableButton.GetRootWidget().SetVisible(m_bHasConflictingAttributes && !GetGame().GetInputManager().IsUsingMouseAndKeyboard());
319  }
320 
321  void InitWidget(array<ResourceName> categoryConfigs, array<ref SCR_EditorAttributeCategory> categories)
322  {
323  SCR_UISoundEntity.SoundEvent(m_sSfxOnOpenDialog, true);
324 
325  m_AttributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
326  if (!m_AttributesManager) return;
327 
328  Widget widget = GetWidget();
329  if (!widget) return;
330 
331  WorkspaceWidget workspace = GetGame().GetWorkspace();
332  if (!workspace) return;
333 
334  Widget tabWidget = widget.FindAnyWidget(m_sTabWidgetName);
335  if (!tabWidget) return;
336 
337  m_TabViewComponent = SCR_TabViewComponent.Cast(tabWidget.FindHandler(SCR_TabViewComponent));
338  if (!m_TabViewComponent) return;
339  m_TabViewComponent.GetOnChanged().Insert(OnCurrentTabChanged);
340 
341  m_ContentHolder = widget.FindAnyWidget(m_sContentHolderWidgetName);
342  if (!m_ContentHolder) return;
343 
344  ScriptInvoker onReset = ButtonActionComponent.GetOnAction(widget, m_sButtonResetWidgetName);
345  if (onReset) onReset.Insert(ButtonReset);
346 
347  Widget resetButton = widget.FindAnyWidget(m_sButtonResetWidgetName);
348  if (resetButton)
349  m_ResetButton = SCR_InputButtonComponent.Cast(resetButton.FindHandler(SCR_InputButtonComponent));
350  if (m_ResetButton)
351  m_ResetButton.SetEnabled(false);
352 
353  //Toggle attribute
354  ScriptInvoker onToggle = ButtonActionComponent.GetOnAction(widget, m_sGamepadToggleAttributeButtonName);
355  if (onToggle) onToggle.Insert(ButtonAttributeEnableToggle);
356 
357  Widget gamePadToggle = widget.FindAnyWidget(m_sGamepadToggleAttributeButtonName);
358  if (gamePadToggle)
359  {
360  m_GamepadToggleEnableButton = SCR_InputButtonComponent.Cast(gamePadToggle.FindHandler(SCR_InputButtonComponent));
361 
362  if (m_GamepadToggleEnableButton)
363  m_GamepadToggleEnableButton.SetEnabled(false);
364  }
365 
366  //Show toggle lock button
367  SetHasConflictingAttribute(m_bHasConflictingAttributes);
368 
369  GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
370 
371  m_CategoryConfigs = categoryConfigs;
372 
373  //--- Get current category (must be done before tabs are added, they'll rewrite it)
374  ResourceName currentCategory = m_AttributesManager.GetCurrentCategory();
375 
376  if (categoryConfigs.IsEmpty())
377  {
378  Widget noAttributes = widget.FindAnyWidget(m_sNoAttributeNoteName);
379  if (noAttributes)
380  noAttributes.SetVisible(true);
381  }
382 
383  bool globalAttributesSet = false;
384 
385  //Add tabs
386  foreach (int i, ResourceName categoryConfig: categoryConfigs)
387  {
388  m_TabViewComponent.AddTab(string.Empty, categories[i].GetInfo().GetName(), true, categories[i].GetInfo().GetIconPath());
389 
390  if (!globalAttributesSet)
391  {
392  globalAttributesSet = true;
393  m_bIsGlobalAttribute = categories[i].GetIsGlobalAttributeCategory();
394  }
395  }
396 
397  array<Managed> editedItems = new array<Managed>;
398  int count = m_AttributesManager.GetEditedItems(editedItems);
399 
400  InputManager inputManager = GetGame().GetInputManager();
401 
402  //~ Default sfx is cancel unless a setting is changed
403  m_sSfxOnCloseDialog = m_sSfxClickedOutsideWindow_Cancel;
404 
405  //End game
406  if (count == 1 && SCR_RespawnComponent.Cast(editedItems[0]))
407  {
408  m_bIsEndGame = true;
409 
410  Widget closeButton = widget.FindAnyWidget(m_sButtonEndGameCloseName);
411  Widget acceptButton = widget.FindAnyWidget(m_sButtonEndGameAcceptName);
412 
413  if (closeButton)
414  {
415  closeButton.SetVisible(true);
416 
417  ScriptInvoker onClose = ButtonActionComponent.GetOnAction(widget, m_sButtonEndGameCloseName);
418  if (onClose)
419  onClose.Insert(OnCancelEndGame);
420  }
421  if (acceptButton)
422  {
423  acceptButton.SetVisible(true);
424 
425  ScriptInvoker onAccept = ButtonActionComponent.GetOnAction(widget, m_sButtonEndGameAcceptName);
426  if (onAccept)
427  onAccept.Insert(OnAcceptEndGame);
428  }
429 
430  ScriptInvoker onWindowClose = ButtonActionComponent.GetOnAction(widget, m_sOutsideWindowCloseButtonName);
431  if (onWindowClose)
432  onWindowClose.Insert(OnCancelEndGame);
433 
434  if (m_ResetButton)
435  m_ResetButton.SetVisible(false);
436 
437  inputManager.AddActionListener("EditorAttributeClose", EActionTrigger.DOWN, OnCancelEndGame);
438  }
439  else
440  {
441  m_ButtonCloseButton = widget.FindAnyWidget(m_sButtonCloseButtonName);
442  m_ButtonCloseAndSaveButton = widget.FindAnyWidget(m_sButtonCloseAndSaveButtonName);
443 
444  if (m_ButtonCloseButton)
445  {
446  m_ButtonCloseButton.SetVisible(true);
447 
448  ScriptInvoker onClose = ButtonActionComponent.GetOnAction(widget, m_sButtonCloseButtonName);
449  if (onClose)
450  onClose.Insert(ButtonClose);
451  }
452  if (m_ButtonCloseAndSaveButton)
453  {
454  ScriptInvoker onClose = ButtonActionComponent.GetOnAction(widget, m_sButtonCloseAndSaveButtonName);
455  if (onClose)
456  onClose.Insert(ButtonClose);
457 
458  m_ButtonCloseAndSaveButton.SetVisible(false);
459  }
460 
461  ScriptInvoker onWindowClose = ButtonActionComponent.GetOnAction(widget, m_sOutsideWindowCloseButtonName);
462  if (onWindowClose)
463  onWindowClose.Insert(ButtonClose);
464 
465  inputManager.AddActionListener("EditorAttributeClose", EActionTrigger.DOWN, ButtonClose);
466  }
467 
468  //Init
469  m_TabViewComponent.Init();
470 
471  //Check if only show images
472  if (m_TabViewComponent.GetTabCount() > m_iMaxTabsUntilImageOnly)
473  {
474  m_bTabImageOnly = true;
475  m_TabViewComponent.ShowAllTabsText(false, m_iTabImageOnlyWidth);
476  }
477 
478  //Set active tab
479  if (m_bIsGlobalAttribute)
480  {
481  int currentIndex = Math.Max(m_CategoryConfigs.Find(currentCategory), 0);
482  m_TabViewComponent.ShowTab(currentIndex, true, false);
483  }
484 
485  m_AttributesManager.GetOnResetAttributes().Insert(OnReset);
486 
487  SetHeaderText(RichTextWidget.Cast(widget.FindAnyWidget(m_sTitleHeaderWidgetName)));
488 
489  if (m_bIsEndGame)
490  {
492  if (gameMode)
493  gameMode.GetOnGameModeEnd().Insert(OnCancelEndGame);
494  }
495  }
496 
497  //~Todo: Clean up set header script
498  protected void SetHeaderText(RichTextWidget header)
499  {
500  if (!header)
501  return;
502 
503  string titleText;
504  array<Managed> editedItems = new array<Managed>;
505  int count = m_AttributesManager.GetEditedItems(editedItems);
506 
507  //Check if multiple entites are selected
508  if (count > 1)
509  {
510  header.SetTextFormat("%1", m_sEditingTitlePart);
511 
512  SCR_EditableEntityComponent editableEntity;
513  array<EEditableEntityType> types = new array<EEditableEntityType>;
514  array<int> typeCounts = new array<int>;
515  SCR_EditableEntityComponent groupEntity;
516 
517 
518  bool showTypes = true;
519  bool sameNames = true;
520  bool oneGroup = true;
521  string name = string.Empty;
522 
523  //Add multiple players
524 
525  foreach (Managed item: editedItems)
526  {
527  editableEntity = SCR_EditableEntityComponent.Cast(item);
528 
529  if (sameNames)
530  {
531  //If player never display name
532  if (SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(editableEntity.GetOwner()) > 0)
533  {
534  sameNames = false;
535  }
536  else
537  {
538  if (name == string.Empty)
539  {
540  if (editableEntity.GetEntityType() != EEditableEntityType.TASK)
541  name = editableEntity.GetDisplayName();
542  else
543  name = m_sTaskTitle;
544  }
545  else if ((name != editableEntity.GetDisplayName() && editableEntity.GetEntityType() != EEditableEntityType.TASK) || (editableEntity.GetEntityType() == EEditableEntityType.TASK && name != m_sTaskTitle))
546  {
547  sameNames = false;
548 
549  if (!showTypes)
550  break;
551  }
552  }
553  }
554 
555  //Logic to show types of entity types instead of names when editing
556  if (showTypes)
557  {
558  EEditableEntityType entityType = editableEntity.GetEntityType();
559 
560  if (entityType == EEditableEntityType.CHARACTER)
561  {
562  //Is Player so set entity type -1
563  if (SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(editableEntity.GetOwner()) > 0)
564  {
565  oneGroup = false;
566  entityType = -1;
567  }
568  else if (oneGroup)
569  {
570  if (groupEntity == null)
571  groupEntity = editableEntity.GetParentEntity();
572  else if (groupEntity != null && groupEntity != editableEntity.GetParentEntity())
573  oneGroup = false;
574  }
575  }
576  else if (entityType == EEditableEntityType.GROUP && oneGroup)
577  {
578  if (groupEntity != null && groupEntity != editableEntity)
579  oneGroup = false;
580  else
581  groupEntity = editableEntity;
582  }
583  else
584  {
585  oneGroup = false;
586  }
587 
588  int index = types.Find(entityType);
589 
590  if(index < 0)
591  {
592  types.Insert(entityType);
593  typeCounts.Insert(1);
594 
595  if (types.Count() > m_iEntityTypesUntilMulti)
596  {
597  showTypes = false;
598 
599  if (!sameNames)
600  break;
601  }
602  }
603  else
604  {
605  typeCounts[index] = typeCounts[index] +1;
606  }
607  }
608  }
609 
610  //If all entities have the same name, so display that name
611  if (sameNames)
612  {
613  SetHeaderPart(header, name, count, false);
614  }
615  //If single group with all characters of same parent then show group name and character amount
616  else if (oneGroup)
617  {
618  int characterIndex = types.Find(EEditableEntityType.CHARACTER);
619 
620  SetHeaderPart(header, groupEntity.GetDisplayName(), 0 , false);
621  SetHeaderPart(header, TranslateEntityType(types[characterIndex]), typeCounts[characterIndex], true);
622  }
623  //If multiple selected of a type so display those types
624  else if (showTypes)
625  {
626  bool firstShown = false;
627  int indexHighestPriority;
628  int typeNameCount = m_aEntityTypeNames.Count();
629 
630  while (types.Count() > 0)
631  {
632  int typesCount = types.Count();
633  int currentPriority = int.MAX;
634 
635  for(int i = 0; i < typesCount; i++)
636  {
637  //Is player so always show first
638  if (types[i] == -1)
639  {
640  currentPriority = -1;
641  indexHighestPriority = i;
642  break;
643  }
644 
645  //Check the priority of the type
646  for(int t = 0; t < typeNameCount; t++)
647  {
648  if (m_aEntityTypeNames[t].GetType() == types[i])
649  {
650  if (t < currentPriority)
651  {
652  currentPriority = t;
653  indexHighestPriority = i;
654  }
655 
656  break;
657  }
658  }
659  }
660 
661  SetHeaderPart(header, TranslateEntityType(types[indexHighestPriority]), typeCounts[indexHighestPriority], firstShown);
662  types.Remove(indexHighestPriority);
663  typeCounts.Remove(indexHighestPriority);
664  firstShown = true;
665  }
666  }
667  //If too many types selected show just "entity"
668  else
669  {
670  SetHeaderPart(header, m_sMultiEntitiesTitle, count, false);
671  }
672  }
673  //If editing only 1
674  else if (count == 1)
675  {
676  //Check if gamemode that is being edited
677  if (SCR_GameModeEditor.Cast(editedItems[0]))
678  {
679  SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
680  if (!editorManager)
681  return;
682 
683  SCR_EditorModeEntity modeEntity = editorManager.GetCurrentModeEntity();
684  if (!modeEntity)
685  return;
686 
687  if (modeEntity.GetModeType() == EEditorMode.ADMIN)
688  {
689  header.SetText(m_sAdminModeTitle);
690  return;
691  }
692 
693  //Not admin
694  return;
695  }
696 
697  //Factions only being edited
698  SCR_BaseTaskManager taskManager = SCR_BaseTaskManager.Cast(editedItems[0]);
699  if (taskManager)
700  {
701  header.SetText(m_sFactionOnlyTitle);
702  return;
703  }
704 
705  if (m_bIsEndGame)
706  {
707  header.SetText(m_sEndGameTitle);
708  return;
709  }
710 
711  //Camera attributes (Check if Armavision)
712  SCR_ManualCamera camera = SCR_ManualCamera.Cast(editedItems[0]);
713  if (camera)
714  {
715  SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
716  if (!editorManager)
717  return;
718 
719  SCR_EditorModeEntity modeEntity = editorManager.GetCurrentModeEntity();
720  if (!modeEntity)
721  return;
722 
723  //Is arma vision
724  if (modeEntity.GetModeType() == EEditorMode.PHOTO)
725  {
726  header.SetText(m_sPhotoModeTitle);
727  return;
728  }
729  }
730 
731  //If player delegate show player name
732  SCR_EditablePlayerDelegateComponent playerDelegate = SCR_EditablePlayerDelegateComponent.Cast(editedItems[0]);
733  if (playerDelegate)
734  {
735  header.SetTextFormat("%1", m_sEditingTitlePart);
736  SetHeaderPart(header, GetGame().GetPlayerManager().GetPlayerName(playerDelegate.GetPlayerID()), 0, false);
737  return;
738  }
739 
740  //Single entity
741  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(editedItems[0]);
742  if (editableEntity)
743  {
744  header.SetTextFormat("%1", m_sEditingTitlePart);
745 
746  //Check if player, if true display player name
747  if (editableEntity.GetEntityType() == EEditableEntityType.CHARACTER)
748  {
749  //Check is player and set name
750  int playerID = SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(editableEntity.GetOwner());
751  if (playerID > 0)
752  {
753  SetHeaderPart(header, GetGame().GetPlayerManager().GetPlayerName(playerID), 0, false);
754  return;
755  }
756  }
757  //One task is being edited
758  else if (editableEntity.GetEntityType() == EEditableEntityType.TASK)
759  {
760  SetHeaderPart(header, m_sTaskTitle, 1, false);
761  return;
762  }
763  else if (editableEntity.GetEntityType() == EEditableEntityType.FACTION)
764  {
765  SetHeaderPart(header, editableEntity.GetDisplayName(), 0, false);
766  return;
767  }
768  SetHeaderPart(header, editableEntity.GetDisplayName(), 1, false);
769  }
770  }
771  }
772 
773  protected void SetHeaderPart(RichTextWidget textWidget, string name, int count, bool showSeperator)
774  {
775  if (showSeperator)
776  textWidget.SetTextFormat("%1 -", textWidget.GetText());
777 
778  textWidget.SetTextFormat("%1 %2", textWidget.GetText(), name);
779 
780  if (count != 0)
781  textWidget.SetTextFormat("%2 <font name=\"%3\"><color rgba=\"226,168,79,255\">#AR-ValueUnit_Short_Times</color></font>", count.ToString(), textWidget.GetText(), m_sFontForHeaderEntityAmount);
782  }
783 
784  protected LocalizedString TranslateEntityType(EEditableEntityType type)
785  {
786  if (type == -1)
787  {
788  return "#AR-AttributesDialog_TitlePage_Player_Text";
789  }
790  else
791  {
792  foreach (SCR_EntityAttributeTitleType titleType: m_aEntityTypeNames)
793  {
794  if (titleType.GetType() == type)
795  return titleType.GetTypeName();
796  }
797  }
798 
799  Print(string.Format("Couldn't find type: %1 in m_aEntityTypeNames", typename.EnumToString(EEditableEntityType, type)), LogLevel.ERROR);
800  return typename.EnumToString(EEditableEntityType, type);
801  }
802 
803  protected void OnInputDeviceIsGamepad(bool isGamepad)
804  {
805  //Show toggle lock button
806  SetHasConflictingAttribute(m_bHasConflictingAttributes);
807  }
808 
809  override void HandlerDeattached(Widget w)
810  {
811  if (m_AttributesManager)
812  {
813  m_AttributesManager.GetOnResetAttributes().Remove(OnReset);
814  }
815 
816  if (m_TabViewComponent)
817  m_TabViewComponent.GetOnChanged().Remove(OnCurrentTabChanged);
818 
819 
820  InputManager inputManager = GetGame().GetInputManager();
821  if (inputManager)
822  {
823  if (m_bIsEndGame)
824  inputManager.RemoveActionListener("EditorAttributeClose", EActionTrigger.DOWN, OnCancelEndGame);
825  else
826  inputManager.RemoveActionListener("EditorAttributeClose", EActionTrigger.DOWN, ButtonClose);
827  }
828 
829  if (m_bIsEndGame)
830  {
832  if (gameMode)
833  gameMode.GetOnGameModeEnd().Remove(OnCancelEndGame);
834  }
835 
836  SCR_UISoundEntity.SoundEvent(m_sSfxOnCloseDialog, true);
837 
838  }
839 };
840 
841 
844 {
845  [Attribute("0", UIWidgets.ComboBox, "Type", "", ParamEnumArray.FromEnum(EEditableEntityType))]
846  protected EEditableEntityType m_type;
847 
848  [Attribute("")]
849  protected ref SCR_UIInfo m_UiInfo;
850 
851  EEditableEntityType GetType()
852  {
853  return m_type;
854  }
855 
856  string GetTypeName()
857  {
858  return m_UiInfo.GetName();
859  }
860 };
861 
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
SCR_ManualCamera
Definition: SCR_ManualCamera.c:16
SCR_RespawnComponent
void SCR_RespawnComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_RespawnComponent.c:576
GetType
override EGadgetType GetType()
Definition: SCR_CampaignBuildingGadgetToolComponent.c:52
GetName
string GetName()
Definition: SCR_ScenarioFrameworkLayerBase.c:85
MenuRootSubComponent
Definition: MenuRootSubComponent.c:5
SCR_UISoundEntity
Definition: SCR_UISoundEntity.c:7
SCR_BaseContainerCustomTitleEnum
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
Definition: SCR_CampaignHintStorage.c:22
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CommonDialogs
Definition: CommonDialogs.c:5
SCR_SoundEvent
Definition: SCR_SoundEvent.c:1
GetInfo
override SCR_UIInfo GetInfo(IEntity owner=null)
Definition: SCR_EditablePlayerDelegateComponent.c:140
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_EditorModeEntity
Definition: SCR_EditorModeEntity.c:22
SCR_TabViewComponent
Definition: SCR_TabViewComponent.c:13
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
EditorAttributesDialogUI
Definition: EditorAttributesDialogUI.c:3
GetMenu
SCR_RadialMenu GetMenu()
Definition: SCR_RadialMenuGameModeComponent.c:41
Attribute
typedef Attribute
Post-process effect of scripted camera.
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
SCR_BaseTaskManager
Definition: SCR_BaseTaskManager.c:25
SCR_BaseEditorAttribute
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
Definition: SCR_BaseEditorAttribute.c:3
SCR_ArsenalItemTypeUIConfig
Definition: SCR_ArsenalItemTypeUIConfig.c:2
ButtonActionComponent
Component to execute action when the button or its shortcut is pressed.
Definition: ButtonActionComponent.c:2
SCR_AttributesEditorUIComponent
Definition: SCR_AttributesEditorUIComponent.c:3
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_BaseEditorAttributeUIComponent
Definition: SCR_BaseEditorAttributeUIComponent.c:3
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
EEditorMode
EEditorMode
Editor mode that defines overall functionality.
Definition: EEditorMode.c:5
layout
UI layouts HUD CampaignMP CampaignMainHUD layout
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:20
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
SCR_ConfigurableDialogUi
Definition: SCR_ConfigurableDialogUI.c:13
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
SCR_EntityAttributeTitleType
Definition: SCR_AttributesEditorUIComponent.c:843
LocalizedString
Definition: LocalizedString.c:21
GetWidget
protected Widget GetWidget()
Definition: SCR_VonDisplay.c:155
SCR_GameModeEditor
Definition: SCR_GameModeEditor.c:7
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26