-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathAvatarController.cs
More file actions
122 lines (105 loc) · 4.82 KB
/
Copy pathAvatarController.cs
File metadata and controls
122 lines (105 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using CommunicationData.URLHelpers;
using DCL.AvatarRendering.Wearables;
using DCL.Backpack.BackpackBus;
using DCL.CharacterPreview;
using DCL.UI;
using System;
using DCL.Browser;
using DCL.FeatureFlags;
using DCL.Multiplayer.Connections.DecentralandUrls;
using UnityEngine;
namespace DCL.Backpack
{
public class AvatarController : ISection, IDisposable
{
private readonly AvatarView view;
private readonly RectTransform rectTransform;
private readonly UnityAppWebBrowser webBrowser;
private readonly BackpackSlotsController slotsController;
private readonly CategoriesPresenter categoriesPresenter;
private readonly OutfitsPresenter outfitsPresenter;
private readonly IDecentralandUrlsSource decentralandUrlsSource;
private readonly BackpackCommandBus backpackCommandBus;
private readonly BackpackInfoPanelController backpackInfoPanelController;
private readonly BackpackGridController backpackGridController;
private readonly AvatarTabsManager tabsManager;
private readonly URLBuilder urlBuilder = new ();
// Still "backpack" even though the destination is now the Shop: this names where the click came FROM,
// and keeping it is what lets the web side see this traffic move from the marketplace over to the Shop.
private readonly URLParameter shopSourceParam = new ("utm_source", "backpack");
public AvatarController(AvatarView view,
UnityAppWebBrowser webBrowser,
AvatarSlotView[] slotViews,
NftTypeIconSO rarityBackgrounds,
BackpackCommandBus backpackCommandBus,
IBackpackEventBus backpackEventBus,
BackpackInfoPanelController backpackInfoPanelController,
BackpackGridController backpackGridController,
CategoriesPresenter categoriesPresenter,
OutfitsPresenter outfitsPresenter,
IThumbnailProvider thumbnailProvider,
IDecentralandUrlsSource decentralandUrlsSource)
{
this.view = view;
this.webBrowser = webBrowser;
this.backpackCommandBus = backpackCommandBus;
this.backpackInfoPanelController = backpackInfoPanelController;
this.backpackGridController = backpackGridController;
this.categoriesPresenter = categoriesPresenter;
this.outfitsPresenter = outfitsPresenter;
this.decentralandUrlsSource = decentralandUrlsSource;
rectTransform = view.GetComponent<RectTransform>();
view.marketplaceButton.onClick.AddListener(OnOpenShop);
slotsController = new BackpackSlotsController(slotViews,
backpackCommandBus,
backpackEventBus,
rarityBackgrounds,
thumbnailProvider);
tabsManager = AvatarTabsManager.CreateFromView(
view,
categoriesPresenter,
outfitsPresenter,
(RectTransform) view.transform);
bool isOutfitsEnabled = FeaturesRegistry.Instance.IsEnabled(FeatureId.BackpackOutfits);
if (!isOutfitsEnabled)
tabsManager.SetTabEnabled(AvatarSubSection.Outfits, false);
tabsManager.InitializeAndEnable();
}
// The Shop and not the marketplace: this button lives in the avatar section, so what it is asked for is
// always wearables or emotes, and those are what the Shop sells. LAND keeps pointing at the marketplace
// elsewhere — the Shop carries no parcels or estates.
private void OnOpenShop()
{
urlBuilder.Clear();
urlBuilder.AppendDomain(URLDomain.FromString(decentralandUrlsSource.Url(DecentralandUrl.ShopLink)));
urlBuilder.AppendParameter(shopSourceParam);
webBrowser.OpenUrlMainThreadOnly(urlBuilder.Build());
}
public void Dispose()
{
tabsManager.Dispose();
slotsController?.Dispose();
categoriesPresenter?.Dispose();
outfitsPresenter?.Dispose();
backpackInfoPanelController?.Dispose();
view.marketplaceButton.onClick.RemoveAllListeners();
}
public void Activate()
{
tabsManager.Show();
}
public void Deactivate()
{
tabsManager.DeactivateAll();
backpackCommandBus.SendCommand(new BackpackFilterCommand(string.Empty,
AvatarWearableCategoryEnum.Body, string.Empty));
backpackGridController.Deactivate();
categoriesPresenter.Deactivate();
}
public void Animate(int triggerId) =>
view.gameObject.SetActive(triggerId == UIAnimationHashes.IN);
public void ResetAnimator() { }
public RectTransform GetRectTransform() =>
rectTransform;
}
}