7 protected ref array<ref SCR_ContentBrowserEditorCard> m_aCardPrefabs;
8 [
Attribute(
"4",
desc:
"Speed value passed to WidgetAnimator, 1 = 1sec, higher = faster")]
9 private float m_iCardFadeInSpeed;
12 private ResourceName m_sCardPrefab;
15 private ResourceName m_sEmptyCardPrefab;
18 private ResourceName m_sUndefinedCardPrefab;
21 protected string m_sHeaderWidgetName;
24 private string m_sLabelComponentWidget;
27 protected string m_sNoFilterResultsWidgetName;
29 [
Attribute(defvalue:
"ResetFilterButton")]
30 protected string m_sResetFiltersButtonName;
33 private string m_sSearchEditBoxName;
36 private string m_sScrollLayoutName;
39 private string m_sContentLoadingWidgetName;
41 [
Attribute(defvalue:
"ToggleBetweenCardAndFilter")]
42 protected string m_sToggleCardFilterButton;
45 protected string m_sToggleSearchButton;
48 protected string m_sActiveFiltersName;
51 protected string m_sSelectCardButtonName;
54 protected string m_sToggleFilterdButtonName;
56 [
Attribute(
"SOUND_E_OPENASSETBROWSER", UIWidgets.EditBox,
"")]
57 protected string m_sSfxOnOpenDialog;
59 [
Attribute(
SCR_SoundEvent.CLICK_CANCEL, UIWidgets.EditBox,
"Played when no entity card is selected on close dialog")]
60 protected string m_sSfxOnCloseDialog;
70 protected Widget m_wFocusedCard;
71 protected int m_iCardFocusIndex;
72 protected bool m_bBudgetPreviewUpdateEnabled;
73 protected bool m_bUsingGamePad;
74 protected bool m_bFocusingAssetCard;
75 protected bool m_bSearchIsToggled;
76 protected bool m_bContentLoadingWidgetActive;
77 protected bool m_bAnimateEntries;
81 protected Widget m_wToggleSearchButton;
82 protected Widget m_LastSelectedOnSearch;
83 protected Widget m_NoFilterResultsWidget;
84 protected Widget m_SelectCardButton;
85 protected Widget m_ToggleFilterdButton;
87 protected Widget m_ContentLoadingVisual;
89 protected ScrollLayoutWidget m_ScrollLayout;
90 protected ref array<string> m_aLocalizationKeys = {};
92 private ref ScriptInvoker m_LabelApplyCallback =
new ScriptInvoker();
93 private ref ScriptInvoker m_ShowLoadingCircleCallback =
new ScriptInvoker();
95 protected bool m_bCardSelected;
100 void OnCardLMB(Widget assetWidget)
103 if (!placingManager)
return;
105 int entryIndex = GetEntryIndex(assetWidget);
110 if (placingManager.SetSelectedPrefab(prefab, showBudgetMaxNotification:
true))
113 CloseContentBrowser();
114 m_bCardSelected =
true;
121 void CloseContentBrowser()
123 m_bBudgetPreviewUpdateEnabled =
false;
124 if (m_ContentBrowserDialog)
125 m_ContentBrowserDialog.Close();
128 override void ShowEntries(Widget contentWidget,
int indexStart,
int indexEnd)
130 WorkspaceWidget workspace =
GetGame().GetWorkspace();
133 bool showNoResults = indexEnd == 0 && !m_bContentLoadingWidgetActive;
134 if (m_NoFilterResultsWidget)
135 m_NoFilterResultsWidget.SetVisible(showNoResults);
136 contentWidget.SetVisible(!showNoResults);
138 ResourceName cardPrefab, defaultCardPrefab;
143 defaultCardPrefab = cardPrefabCandidate.m_sPrefab;
150 ScriptCallQueue callQueue =
GetGame().GetCallqueue();
151 for (
int i = indexStart; i < indexEnd; i++)
156 cardPrefab = m_sUndefinedCardPrefab;
159 cardPrefab = defaultCardPrefab;
162 if (cardPrefabCandidate.m_EntityType == entityInfo.GetEntityType())
164 cardPrefab = cardPrefabCandidate.m_sPrefab;
171 Widget assetWidget = workspace.CreateWidgets(cardPrefab, contentWidget);
172 if (!assetWidget)
continue;
177 Print(
"Asset widget is missing SCR_AssetCardFrontUIComponent!", LogLevel.ERROR);
178 assetWidget.RemoveFromHierarchy();
183 array<ref SCR_EntityBudgetValue> budgetCosts = { };
189 if (firstCard ==
null)
190 firstCard = assetCard.GetButtonWidget();
195 assetCard.GetOnHover().Insert(OnCardHover);
196 assetCard.GetOnFocus().Insert(OnCardFocus);
197 assetCard.InitCard(prefabID, entityInfo,
m_ContentBrowserManager.GetResourceNamePrefabID(prefabID), blockingBudgetInfo);
200 if (m_bAnimateEntries)
202 assetWidget.SetOpacity(0);
203 int cardIndexOnPage = (i - indexStart);
205 callQueue.CallLater(AnimateCardFadeIn, cardIndexOnPage * 20,
false, assetWidget);
210 if (m_wFocusedCard ==
null)
211 m_wFocusedCard = firstCard;
222 m_bAnimateEntries =
false;
223 m_bBudgetPreviewUpdateEnabled =
true;
226 override int GetEntryCount()
238 protected void AnimateCardFadeIn(Widget cardWidget)
240 AnimateWidget.Opacity(cardWidget, 1.0, m_iCardFadeInSpeed);
243 protected void ToggleBetweenCardsAndFilters()
245 if (m_bFocusingAssetCard)
248 SwitchToAssetCards();
250 GamepadToggleSelectButtonSwap();
253 protected void SwitchToAssetCards()
258 WorkspaceWidget workspace =
GetGame().GetWorkspace();
262 workspace.SetFocusedWidget(m_wFocusedCard);
265 protected void GamepadToggleSelectButtonSwap()
267 m_SelectCardButton.SetVisible(m_bFocusingAssetCard);
268 m_ToggleFilterdButton.SetVisible(!m_bFocusingAssetCard);
271 protected void SwitchToFilters()
273 WorkspaceWidget workspace =
GetGame().GetWorkspace();
277 if (m_LabelsUIComponent)
278 workspace.SetFocusedWidget(m_LabelsUIComponent.GetLastFocusedLabel());
281 protected void GamePadSwitchToggleSearch()
283 if (m_bSearchIsToggled)
284 GamePadToggleSearch(
false,
false);
286 GamePadToggleSearch(
true,
false);
289 protected void GamePadToggleSearch(
bool toggle,
bool forceToggle =
true)
291 WorkspaceWidget workspace =
GetGame().GetWorkspace();
295 Widget focusedWidget = workspace.GetFocusedWidget();
296 if (!forceToggle && (focusedWidget == m_SearchEditBox.GetRootWidget() || focusedWidget == m_SearchEditBox.m_wEditBox))
298 EditBoxWidget.Cast(m_SearchEditBox.m_wEditBox).ActivateWriteMode();
300 else if (m_bSearchIsToggled != toggle)
302 m_bSearchIsToggled = toggle;
304 if (m_bSearchIsToggled)
306 workspace.SetFocusedWidget(m_SearchEditBox.GetRootWidget());
307 EditBoxWidget.Cast(m_SearchEditBox.m_wEditBox).ActivateWriteMode();
311 workspace.SetFocusedWidget(m_wFocusedCard);
316 protected void ResetSearch()
320 m_SearchEditBox.SetValue(
string.Empty);
327 GamePadToggleSearch(
false);
330 protected void FilterEntries(
bool resetPage =
true,
bool resetSearch =
true,
bool animateEntries =
false)
339 string searchInputText = m_SearchEditBox.GetValue().Trim();
355 m_bAnimateEntries = animateEntries;
360 protected void OnInputDeviceIsGamepadScripted(
bool isGamepad)
362 m_bUsingGamePad = isGamepad;
364 if (m_bFocusingAssetCard)
365 OnCardHover(
null, -1,
true);
367 OnCardHover(
null, -1,
false);
371 GamepadToggleSelectButtonSwap();
375 m_SelectCardButton.SetVisible(
false);
376 m_ToggleFilterdButton.SetVisible(
false);
379 if (!m_SearchEditBox)
382 if (!m_bUsingGamePad)
384 GamePadToggleSearch(
false);
388 WorkspaceWidget workspace =
GetGame().GetWorkspace();
392 workspace.SetFocusedWidget(m_SearchEditBox.GetRootWidget());
396 protected void OnCardHover(Widget card,
int prefabIndex,
bool hover)
404 if (!m_bBudgetPreviewUpdateEnabled || m_bUsingGamePad)
return;
410 protected void OnCardFocus(Widget card,
int prefabIndex,
bool focus)
412 if (!m_bUsingGamePad)
return;
414 m_bFocusingAssetCard = focus;
415 GamepadToggleSelectButtonSwap();
417 if (m_bFocusingAssetCard)
419 m_wToggleCardFilterButton.SetLabel(
"#AR-Editor_ContentBrowser_SwitchToFilters");
423 m_wToggleCardFilterButton.SetLabel(
"#AR-Editor_ContentBrowser_SwitchToCards");
430 m_wFocusedCard = card;
431 m_iCardFocusIndex = prefabIndex;
436 protected void OnSearchFocusChanged(
SCR_EditBoxComponent editBoxComponent, EditBoxWidget editBoxWidget,
bool focus)
438 if (focus != m_bSearchIsToggled)
439 m_bSearchIsToggled = focus
444 string search = text.Trim();
447 FilterEntries(
true,
false,
true);
450 if (m_bUsingGamePad && m_wFocusedCard)
451 GamePadToggleSearch(
false);
455 protected void OnBrowserEntriesFiltered()
459 m_bAnimateEntries =
true;
463 protected void OnMenuClosed()
471 protected void OnResetClicked()
473 m_LabelsUIComponent.OnResetClicked();
477 protected void OnShowLoadingCircle(
bool state =
true)
479 if (m_bContentLoadingWidgetActive == state)
483 m_ContentLoadingVisual.SetVisible(state);
484 m_bContentLoadingWidgetActive = state;
491 protected void OnApplyLabelChanges()
493 OnShowLoadingCircle(
false);
494 FilterEntries(
true,
false,
true);
497 protected void InitializeLabels()
499 Widget labelsWidget =
GetWidget().FindAnyWidget(m_sLabelComponentWidget);
500 if (!labelsWidget)
return;
503 if (!m_LabelsUIComponent)
return;
505 m_LabelsUIComponent.SetContentBrowserCallbacks(m_ShowLoadingCircleCallback, m_LabelApplyCallback);
507 Widget activeFilters =
GetWidget().FindAnyWidget(m_sActiveFiltersName);
512 if (activeFilterComponent)
513 activeFilterComponent.Init(m_LabelsUIComponent);
518 protected SCR_UIInfo GetHighestOrderedLabelUIInfo(notnull array<EEditableEntityLabel> labels)
523 int newLabelGroupOrder;
525 int lowestGroupOrder =
int.MAX;
526 int lowestLabelOrder =
int.MAX;
535 if (newLabelGroupOrder <= lowestGroupOrder)
539 if (newLabelOrder < lowestLabelOrder)
541 lowestGroupOrder = newLabelGroupOrder;
542 lowestLabelOrder = newLabelOrder;
543 highestOrderedLabel = label;
553 protected override bool IsUnique()
558 protected override void OnButtonPrev()
560 if (m_bPlayAudioOnPageChange)
564 if (
SetPage(previousPageIndex))
570 protected override void OnButtonNext()
572 if (m_bPlayAudioOnPageChange)
582 override protected void HandlerAttachedScripted(Widget w)
584 super.HandlerAttachedScripted(w);
586 Widget toggleBetweenCardAndFilter = w.FindAnyWidget(m_sToggleCardFilterButton);
588 if (toggleBetweenCardAndFilter)
590 ButtonActionComponent.GetOnAction(toggleBetweenCardAndFilter,
false, 0).Insert(ToggleBetweenCardsAndFilters);
595 m_bBudgetPreviewUpdateEnabled =
false;
613 m_ContentBrowserDialog.GetOnMenuHide().Insert(OnMenuClosed);
615 m_NoFilterResultsWidget = w.FindAnyWidget(m_sNoFilterResultsWidgetName);
617 m_SelectCardButton = w.FindAnyWidget(m_sSelectCardButtonName);
618 m_ToggleFilterdButton = w.FindAnyWidget(m_sToggleFilterdButtonName);
620 Widget resetFiltersButton = w.FindAnyWidget(m_sResetFiltersButtonName);
621 if (resetFiltersButton)
629 m_SearchEditBox.m_OnConfirm.Insert(OnSearchConfirmed);
630 m_SearchEditBox.m_OnFocusChangedEditBox.Insert(OnSearchFocusChanged);
638 m_ContentLoadingVisual = w.FindAnyWidget(m_sContentLoadingWidgetName);
639 if (!m_ContentLoadingVisual)
640 Print(
"'SCR_ContentBrowserEditorUIComponent' cannot find 'm_ContentLoadingVisual'!", LogLevel.WARNING);
642 m_ShowLoadingCircleCallback.Insert(OnShowLoadingCircle);
643 m_LabelApplyCallback.Insert(OnApplyLabelChanges);
645 m_wToggleSearchButton = w.FindAnyWidget(m_sToggleSearchButton);
646 if (m_wToggleSearchButton)
647 ButtonActionComponent.GetOnAction(m_wToggleSearchButton,
false, 0).Insert(GamePadSwitchToggleSearch);
651 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepadScripted);
659 if (header !=
string.Empty)
661 TextWidget headerWidget = TextWidget.Cast(w.FindAnyWidget(m_sHeaderWidgetName));
664 headerWidget.SetText(header);
674 m_bAnimateEntries =
true;
679 m_BudgetManager.DemandBudgetUpdateFromServer();
682 override protected void HandlerDeattached(Widget w)
684 super.HandlerDeattached(w);
687 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepadScripted);
691 m_ShowLoadingCircleCallback.Remove(OnShowLoadingCircle);
692 m_LabelApplyCallback.Remove(OnApplyLabelChanges);
694 m_ContentBrowserDialog.GetOnMenuHide().Remove(OnMenuClosed);
707 m_SearchEditBox.m_OnConfirm.Remove(OnSearchConfirmed);
710 if (!m_bCardSelected)
722 ResourceName m_sPrefab;