Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ namespace DCL.ApplicationVersionGuard
{
public class ApplicationVersionGuard
{
private const string LAUNCHER_EXECUTABLE_NAME = "Decentraland Launcher";
private const string LAUNCHER_EXECUTABLE_NAME = "Decentraland";
private const string LEGACY_LAUNCHER_EXECUTABLE_NAME = "Decentraland Launcher";
private const string LAUNCHER_EXECUTABLE_FILENAME = "dcl_launcher.exe";
private const string LAUNCHER_PATH_MAC = "/Applications/" + LAUNCHER_EXECUTABLE_NAME + ".app";
private const string LAUNCHER_PATH_WIN_MAIN = @"C:\Program Files\Decentraland Launcher\" + LAUNCHER_EXECUTABLE_NAME + ".exe";
private const string LAUNCHER_PATH_WIN_86 = @"C:\Program Files (x86)\Decentraland Launcher\" + LAUNCHER_EXECUTABLE_NAME + ".exe";
private const string LAUNCHER_PATH_WIN_COMBINED = @"Programs\Decentraland Launcher\" + LAUNCHER_EXECUTABLE_NAME + ".exe";
private const string DECENTRALAND_LAUNCHER_WIN_X64_EXE = "Decentraland-Launcher-win-x64.exe";
private const string DECENTRALAND_LAUNCHER_MAC_ARM_64DMG = "Decentraland-Launcher-mac-arm64.dmg";
private const string DECENTRALAND_LAUNCHER_MAC_X_64DMG = "Decentraland-Launcher-mac-x64.dmg";
private const string LEGACY_LAUNCHER_PATH_MAC = "/Applications/" + LEGACY_LAUNCHER_EXECUTABLE_NAME + ".app";
private const string DECENTRALAND_LAUNCHER_WIN_X64_EXE = "Decentraland_x64-setup.exe";
private const string DECENTRALAND_LAUNCHER_MAC_ARM_64DMG = "Decentraland_aarch64.dmg";
//Aga: Rust version of launcher does not support intel macs, until fully deprecating it, we need to keep the old launcher for intel based macs
private const string DECENTRALAND_LEGACY_LAUNCHER_MAC_X_64DMG = "Decentraland Launcher-mac-x64.dmg";

private readonly IWebRequestController webRequestController;
private readonly IWebBrowser webBrowser;
Expand Down Expand Up @@ -58,7 +59,7 @@ public async UniTask LaunchOrDownloadLauncherAsync(CancellationToken ct = defaul

if (string.IsNullOrEmpty(launcherPath))
{
await DownloadLauncherAsync(ct);
DownloadLauncher();
Quit();
}
else
Expand Down Expand Up @@ -90,40 +91,34 @@ private static void Quit()
#endif
}

private async UniTask DownloadLauncherAsync(CancellationToken ct)
private void DownloadLauncher()
{
string downloadUrl = await GetLauncherDownloadUrlAsync(ct);
string assetName = GetLauncherAssetName();
string downloadUrl = $"{GetLauncherDownloadPath()}/{assetName}";

if (!string.IsNullOrEmpty(downloadUrl))
webBrowser.OpenUrl(downloadUrl);
else
ReportHub.LogError(ReportCategory.VERSION_CONTROL, "Failed to get launcher download URL.");
}

return;

async UniTask<string> GetLauncherDownloadUrlAsync(CancellationToken cancellationToken)
private static string GetLauncherAssetName()
{
return Application.platform switch
{
FlatFetchResponse response = await webRequestController.GetAsync<FlatFetchResponse<GenericGetRequest>, FlatFetchResponse>(
IDecentralandUrlsSource.LAUNCHER_LATEST_RELEASE_URL,
new FlatFetchResponse<GenericGetRequest>(),
cancellationToken,
ReportCategory.VERSION_CONTROL,
new WebRequestHeadersInfo());

GitHubRelease latestRelease = JsonUtility.FromJson<GitHubRelease>(response.body);
string version = latestRelease.tag_name.TrimStart('v');

string assetName = GetLauncherAssetName();
return $"{IDecentralandUrlsSource.LAUNCHER_DOWNLOAD_URL}/{version}/{assetName}";
}
RuntimePlatform.WindowsEditor or RuntimePlatform.WindowsPlayer => DECENTRALAND_LAUNCHER_WIN_X64_EXE,
RuntimePlatform.OSXEditor or RuntimePlatform.OSXPlayer => IsAppleSiliconMac ? DECENTRALAND_LAUNCHER_MAC_ARM_64DMG : DECENTRALAND_LEGACY_LAUNCHER_MAC_X_64DMG,
_ => throw new NotSupportedException("Unsupported platform for launcher download."),
};
}

private static string GetLauncherAssetName()

private static string GetLauncherDownloadPath()
{
return Application.platform switch
{
RuntimePlatform.WindowsEditor or RuntimePlatform.WindowsPlayer => DECENTRALAND_LAUNCHER_WIN_X64_EXE,
RuntimePlatform.OSXEditor or RuntimePlatform.OSXPlayer => SystemInfo.processorType.ToLower().Contains("arm") ? DECENTRALAND_LAUNCHER_MAC_ARM_64DMG : DECENTRALAND_LAUNCHER_MAC_X_64DMG,
RuntimePlatform.WindowsEditor or RuntimePlatform.WindowsPlayer => IDecentralandUrlsSource.LAUNCHER_DOWNLOAD_URL,
RuntimePlatform.OSXEditor or RuntimePlatform.OSXPlayer => IsAppleSiliconMac ? IDecentralandUrlsSource.LAUNCHER_DOWNLOAD_URL : IDecentralandUrlsSource.LEGACY_LAUNCHER_DOWNLOAD_URL,
_ => throw new NotSupportedException("Unsupported platform for launcher download."),
};
}
Expand All @@ -138,30 +133,39 @@ private static string GetLauncherAssetName()
case RuntimePlatform.WindowsPlayer:
possiblePaths = new[]
{
LAUNCHER_PATH_WIN_MAIN,
LAUNCHER_PATH_WIN_86,
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), LAUNCHER_PATH_WIN_COMBINED),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), LAUNCHER_EXECUTABLE_NAME, LAUNCHER_EXECUTABLE_FILENAME),
};

break;

case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
possiblePaths = new[]
{
LAUNCHER_PATH_MAC,
$"{Environment.GetFolderPath(Environment.SpecialFolder.Personal)}{LAUNCHER_PATH_MAC}",
};

possiblePaths = IsAppleSiliconMac
? new[]
{
LAUNCHER_PATH_MAC,
$"{Environment.GetFolderPath(Environment.SpecialFolder.Personal)}{LAUNCHER_PATH_MAC}",
}
: new[]
{
LEGACY_LAUNCHER_PATH_MAC,
$"{Environment.GetFolderPath(Environment.SpecialFolder.Personal)}{LEGACY_LAUNCHER_PATH_MAC}",
};
break;

default:
ReportHub.LogError(ReportCategory.VERSION_CONTROL, "Unsupported platform for launching the application.");
return null;
}

return possiblePaths.FirstOrDefault(path => File.Exists(path)
|| (Directory.Exists(path) && (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer)));
return possiblePaths.FirstOrDefault(path =>
File.Exists(path) ||
(Directory.Exists(path) && (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer)));
}

private static bool IsAppleSiliconMac =>
Application.platform is RuntimePlatform.OSXEditor or RuntimePlatform.OSXPlayer &&
SystemInfo.processorType.Contains("apple", StringComparison.OrdinalIgnoreCase);

[Serializable]
private struct GitHubRelease
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ namespace DCL.Multiplayer.Connections.DecentralandUrls
public interface IDecentralandUrlsSource
{
const string EXPLORER_LATEST_RELEASE_URL = "https://api.github.com/repos/decentraland/unity-explorer/releases/latest";
const string LAUNCHER_LATEST_RELEASE_URL = "https://api.github.com/repos/decentraland/launcher/releases/latest";
const string LAUNCHER_DOWNLOAD_URL = "https://github.com/decentraland/launcher/releases/download";
const string LAUNCHER_DOWNLOAD_URL = "https://explorer-artifacts.decentraland.org/launcher-rust";
const string LEGACY_LAUNCHER_DOWNLOAD_URL = "https://explorer-artifacts.decentraland.org/launcher/dcl";

string DecentralandDomain { get; }
DecentralandEnvironment Environment { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,10 @@ await MapRendererContainer
friendsEventBus,
chatMessageFactory,
staticContainer.FeatureFlagsCache,
profileRepositoryWrapper,
friendServiceProxy,
profileRepositoryWrapper),
staticContainer.RealmData,
realmNavigator),
new ExplorePanelPlugin(
assetsProvisioner,
mvcManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ MonoBehaviour:
isEnabled: 1
- eventName: unblock_user
isEnabled: 1
- groupName: MarketplaceCredits
events:
- eventName: marketplace_credits_opened
isEnabled: 1
- groupName: Settings
events:
- eventName: chat-bubbles-visibility-changed
isEnabled: 1
- groupName: FeatureFlags
events:
- eventName: feature_flags
isEnabled: 1
useLocalEnvVariableFallback: 0
flushSize: 20
flushInterval: 60
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ MonoBehaviour:
isEnabled: 1
- eventName: unblock_user
isEnabled: 1
- groupName: MarketplaceCredits
events:
- eventName: marketplace_credits_opened
isEnabled: 1
- groupName: Settings
events:
- eventName: chat-bubbles-visibility-changed
isEnabled: 1
- groupName: FeatureFlags
events:
- eventName: feature_flags
isEnabled: 1
useLocalEnvVariableFallback: 0
flushSize: 20
flushInterval: 30
Expand Down
37 changes: 35 additions & 2 deletions Explorer/Assets/DCL/PluginSystem/Global/ChatPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
using DCL.Utilities;
using MVC;
using System.Threading;
using ECS;
using ECS.SceneLifeCycle.Realm;
using UnityEngine;
using UnityEngine.AddressableAssets;

Expand Down Expand Up @@ -64,7 +66,9 @@ public class ChatPlugin : IDCLGlobalPlugin<ChatPluginSettings>
private readonly ProfileRepositoryWrapper profileRepositoryWrapper;

private ChatController chatController;

private IRealmData realmData;
private IRealmNavigator realmNavigator;

public ChatPlugin(
IMVCManager mvcManager,
IChatMessagesBus chatMessagesBus,
Expand All @@ -90,8 +94,10 @@ public ChatPlugin(
IFriendsEventBus friendsEventBus,
ChatMessageFactory chatMessageFactory,
FeatureFlagsCache featureFlagsCache,
ProfileRepositoryWrapper profileDataProvider,
ObjectProxy<IFriendsService> friendsServiceProxy,
ProfileRepositoryWrapper profileDataProvider)
IRealmData realmData,
IRealmNavigator realmNavigator)
{
this.mvcManager = mvcManager;
this.chatHistory = chatHistory;
Expand Down Expand Up @@ -120,6 +126,8 @@ public ChatPlugin(
this.socialServiceProxy = socialServiceProxy;
this.friendsEventBus = friendsEventBus;
this.profileRepositoryWrapper = profileDataProvider;
this.realmData = realmData;
this.realmNavigator = realmNavigator;
}

public void Dispose()
Expand Down Expand Up @@ -176,6 +184,31 @@ public async UniTask InitializeAsync(ChatPluginSettings settings, CancellationTo
// Log out / log in
web3IdentityCache.OnIdentityCleared += OnIdentityCleared;
web3IdentityCache.OnIdentityChanged += OnIdentityChanged;

realmData.RealmType.OnUpdate += OnRealmChange;
realmNavigator.NavigationExecuted += OnNavigationExecuted;
}

/// <summary>
/// TODO: This is a temporary solution to show the chat when the user navigates to a parcel.
/// NOTE: check this PR for more details:
/// https://github.com/decentraland/unity-explorer/issues/4324
/// </summary>
/// <param name="parcel"></param>
private void OnNavigationExecuted(Vector2Int parcel)
{
sharedSpaceManager.ShowAsync(PanelsSharingSpace.Chat, new ChatControllerShowParams(true,false)).Forget();
}

/// <summary>
/// TODO: This is a temporary solution to show the chat when the user changes realm.
/// NOTE: check this PR for more details:
/// https://github.com/decentraland/unity-explorer/issues/4324
/// </summary>
/// <param name="realmKind"></param>
private void OnRealmChange(RealmKind realmKind)
{
sharedSpaceManager.ShowAsync(PanelsSharingSpace.Chat, new ChatControllerShowParams(true,false)).Forget();
}

private void OnIdentityCleared()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ protected override void OnViewInstantiated()
viewInstance.pointerDetectionArea.OnExitArea += OnPointerExit;
mvcManager.ShowAsync(SidebarController.IssueCommand()).Forget();
mvcManager.ShowAsync(MinimapController.IssueCommand()).Forget();
sharedSpaceManager.ShowAsync(PanelsSharingSpace.Chat, new ChatControllerShowParams(true)).Forget();
mvcManager.ShowAsync(ConnectionStatusPanelController.IssueCommand()).Forget();

if (isFriendsEnabled)
Expand Down