| | 1 | | using DCL.Interface; |
| | 2 | | using DCL.NotificationModel; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | public class GraphicCardWarningHUDController : IHUD |
| | 6 | | { |
| 1 | 7 | | private readonly string warningMessage = |
| | 8 | | "Your machine is not using a dedicated graphics card to run Decentraland. " |
| | 9 | | + "This might lead to performance issues. Check your browser and OS configuration " |
| | 10 | | + "and restart " + (Application.platform == RuntimePlatform.WebGLPlayer ? "your browser." : "the experience."); |
| | 11 | |
|
| 1 | 12 | | public void Dispose() { } |
| | 13 | |
|
| | 14 | | public void SetVisibility(bool visible) |
| | 15 | | { |
| 1 | 16 | | CommonScriptableObjects.tutorialActive.OnChange -= TutorialActiveChanged; |
| 1 | 17 | | CommonScriptableObjects.rendererState.OnChange -= RendererStateChanged; |
| | 18 | |
|
| 1 | 19 | | if (!visible) |
| 0 | 20 | | return; |
| | 21 | |
|
| 1 | 22 | | if (!CommonScriptableObjects.tutorialActive.Get() && CommonScriptableObjects.rendererState) |
| 1 | 23 | | TryShowNotification(); |
| | 24 | | else |
| | 25 | | { |
| 0 | 26 | | if (CommonScriptableObjects.tutorialActive) |
| 0 | 27 | | CommonScriptableObjects.tutorialActive.OnChange += TutorialActiveChanged; |
| | 28 | | else |
| 0 | 29 | | CommonScriptableObjects.rendererState.OnChange += RendererStateChanged; |
| | 30 | | } |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | private void TutorialActiveChanged(bool newState, bool _) |
| | 34 | | { |
| 0 | 35 | | if (newState) |
| 0 | 36 | | return; |
| | 37 | |
|
| 0 | 38 | | CommonScriptableObjects.tutorialActive.OnChange -= TutorialActiveChanged; |
| 0 | 39 | | TryShowNotification(); |
| 0 | 40 | | } |
| | 41 | |
|
| | 42 | | private void RendererStateChanged(bool newState, bool _) |
| | 43 | | { |
| 0 | 44 | | if (!newState) |
| 0 | 45 | | return; |
| | 46 | |
|
| 0 | 47 | | CommonScriptableObjects.rendererState.OnChange -= RendererStateChanged; |
| 0 | 48 | | TryShowNotification(); |
| 0 | 49 | | } |
| | 50 | |
|
| | 51 | | private void TryShowNotification() |
| | 52 | | { |
| 1 | 53 | | if (GraphicCardNotification.CanShowGraphicCardPopup() && IsIntegratedGraphicCard()) |
| 0 | 54 | | NotificationsController.i.ShowNotification( |
| | 55 | | new Model |
| | 56 | | { |
| | 57 | | buttonMessage = "Dismiss", |
| | 58 | | destroyOnFinish = true, |
| | 59 | | groupID = "GraphicCard", |
| | 60 | | message = warningMessage, |
| | 61 | | timer = 0, |
| | 62 | | type = Type.GRAPHIC_CARD_WARNING, |
| | 63 | | }); |
| | 64 | |
|
| | 65 | | bool IsIntegratedGraphicCard() => |
| 1 | 66 | | WebInterface.GetGraphicCard().ToLower().Contains("intel"); |
| 1 | 67 | | } |
| | 68 | | } |