// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Standard Library
using System;
// Unity
using UnityEditor;
using UnityEngine;
// GameKit
using AWS.GameKit.Common.Models;
using AWS.GameKit.Editor.Core;
using AWS.GameKit.Editor.GUILayoutExtensions;
using AWS.GameKit.Editor.Models;
using AWS.GameKit.Editor.Windows.Settings.Pages.AllFeatures;
namespace AWS.GameKit.Editor.Windows.Settings
{
///
/// The base class for all Feature pages displayed in the AWS GameKit Settings window.
///
[Serializable]
public abstract class FeaturePage : AllFeaturesPage
{
public static string DeploymentTabName => L10n.Tr("Deployment");
public static string TestingTabName => L10n.Tr("Testing");
public override string DisplayName => FeatureType.GetDisplayName();
///
/// The feature this page is for.
///
public abstract FeatureType FeatureType { get; }
[SerializeField] private TabWidget _tabViewWidget;
///
/// Change the currently selected tab to the named tab.
///
///
/// If the named tab does not exist, then an Error will be logged and the page's currently selected tab will not change.
///
/// The name of the tab to select. All 's should have tabs named and at minimum.
public override void SelectTab(string tabName)
{
_tabViewWidget.SelectTab(tabName);
}
///
/// Create a new FeaturePage with an arbitrary set of tabs.
///
protected void Initialize(Tab[] tabs, SettingsDependencyContainer dependencies)
{
GUI.ToolbarButtonSize tabSelectorButtonSize = GUI.ToolbarButtonSize.FitToContents;
_tabViewWidget.Initialize(tabs, tabSelectorButtonSize);
base.Initialize(dependencies);
}
///
/// Get the default set of tabs that every should have.
///
protected static Tab[] GetDefaultTabs(FeatureSettingsTab settingsTab, FeatureExamplesTab examplesTab)
{
return new Tab[]
{
CreateSettingsTab(settingsTab),
CreateExamplesTab(examplesTab)
};
}
///
/// Create a . This should only be used during the constructor to build a Tab[] when not using .
///
protected static Tab CreateSettingsTab(FeatureSettingsTab settingsTab)
{
return new Tab(DeploymentTabName, settingsTab);
}
///
/// Create a . This should only be used during the constructor to build a Tab[] when not using .
///
protected static Tab CreateExamplesTab(FeatureExamplesTab examplesTab)
{
return new Tab(TestingTabName, examplesTab);
}
protected override void DrawContent()
{
// Feature Description
EditorGUILayout.LabelField(FeatureType.GetDescription(withEndingPeriod: true), SettingsGUIStyles.FeaturePage.Description);
// Tab View
_tabViewWidget.OnGUI(SettingsGUIStyles.FeaturePage.TabSelector);
}
}
}