94 lines
2.6 KiB
C#
94 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using Audio;
|
|
using ConsoleConnection;
|
|
using Localization;
|
|
|
|
using Online;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Start
|
|
{
|
|
public class LandingScreen : MonoBehaviour
|
|
{
|
|
public GameObject topContainer;
|
|
[Header("Settings button")]
|
|
public Button SettingsBtn;
|
|
|
|
[Header("Help and settings button")]
|
|
public Button PlayBtn;
|
|
|
|
[Header("Help and settings button")]
|
|
public Button HardwareBackButton;
|
|
|
|
private void Start()
|
|
{
|
|
UI.PopupManager.OnPopupDisplayed += OnPopupDisplayed;
|
|
|
|
if (SettingsBtn == null)
|
|
return;
|
|
|
|
SettingsBtn.onClick.AddListener(() => {
|
|
OpenSettings();
|
|
Analytics.Statistics.LaunchWizardSession("SettingsButton");
|
|
});
|
|
|
|
HardwareBackButton.onClick.AddListener(ShowAppExitConfirmPopup);
|
|
|
|
ConnectionManager.Instance.StartBackgroundDiscovery();
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
UI.PopupManager.OnPopupDisplayed -= OnPopupDisplayed;
|
|
}
|
|
|
|
public void OpenSettings()
|
|
{
|
|
AudioManager.Instance.Play(AudioManager.SoundIds.ConfigPanelOpen);
|
|
|
|
var newScreen = UiBuilder.Instance.BuildSettingsScreen(false);
|
|
UiManager.Instance.DisplayAppPopupScreen(newScreen, 0, true, AudioManager.SoundIds.NoSound, true);
|
|
}
|
|
|
|
public void ShowAppExitConfirmPopup()
|
|
{
|
|
string confirm = LocalizationManager.Instance.GetLocalizedString(12912);
|
|
|
|
// instantiate screen
|
|
var errorPopup = UiBuilder.Instance.BuildErrorPopup(confirm);
|
|
|
|
errorPopup.GetComponent<ErrorPopupController>().setConfirmationHandler(validation =>
|
|
{
|
|
if (validation)
|
|
Application.Quit();
|
|
else
|
|
{
|
|
UiManager.Instance.DisplayAppPopupScreen(null);
|
|
}
|
|
});
|
|
|
|
UiManager.Instance.DisplayAppPopupScreen(errorPopup, .0f);
|
|
}
|
|
|
|
public void OnPopupDisplayed(bool popupDisplayed)
|
|
{
|
|
if (!popupDisplayed)
|
|
{
|
|
// Stopping first the automatic discovery process to avoid issues
|
|
ConnectionManager.Instance.StartBackgroundDiscovery();
|
|
}
|
|
}
|
|
|
|
private void OnApplicationPause(bool pauseStatus)
|
|
{
|
|
if (!pauseStatus)
|
|
{
|
|
ConnectionManager.Instance.StartBackgroundDiscovery();
|
|
}
|
|
}
|
|
}
|
|
}
|