Aetheria/Assets/Scripts/UI/MenuPanel.cs
Reinier Vens 73651bf16a Game Loop Galaxy Integration
Added sector map in Galaxy tab of in-game menu
Added player flag to Ship (replaces AGM.PlayerEntities)
Refactored sector map to depend on AGM
Moved sector generation to main menu
Main menu now supports resuming previous playthrough
Database and player settings now statically available via AGM
AGM saves current game state in PlayerSettings on exit
Sector generation is now asynchronous
Added progress callbacks to sector gen + progress dialog in menu
Confirmation Dialog / properties panel can now display dynamic text entry
Added zone title to Zone map
Eliminated ZoneData class (properties moved to ZonePack)
Sector, Zone and Entity serialization now fully functional
Entity settings now separate from player settings
Cleaned up old unused networking message classes
Name files now integrated with database cache
Added ability to save/load additive DB cache files in database panel
Cleaned up Wwise sound setup - removed redundant items & fixed spelling errors
Deleted Wwise cache + added to .gitignore
2021-03-15 11:40:46 +00:00

77 lines
No EOL
2 KiB
C#

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections;
using System.Collections.Generic;
using UniRx.Triggers;
using UnityEngine;
public class MenuPanel : MonoBehaviour
{
public ActionGameManager GameManager;
public RectTransform TabButtons;
public Color ActiveTabColor;
public Color InactiveTabColor;
public event Action<MenuTab> TabChanged;
private Dictionary<MenuTab, MenuTabButton> _tabs = new Dictionary<MenuTab, MenuTabButton>();
private MenuTabButton _current;
public MenuTab CurrentTab { get; private set; }
public void ShowTab(MenuTab tab)
{
gameObject.SetActive(true);
if (_current == _tabs[tab]) return;
if(_current != null)
{
_current.TabContents.SetActive(false);
_current.Text.color = InactiveTabColor;
}
CurrentTab = tab;
_current = _tabs[tab];
_current.TabContents.SetActive(true);
_current.Text.color = ActiveTabColor;
TabChanged?.Invoke(tab);
}
private void OnEnable()
{
foreach (var tabButton in _tabs.Values)
{
tabButton.gameObject.SetActive(!tabButton.RequireParent || GameManager.CurrentEntity.Parent != null);
}
}
private void Awake()
{
foreach (var tabButton in TabButtons.GetComponentsInChildren<MenuTabButton>())
{
tabButton.TabContents.SetActive(false);
tabButton.Text.color = InactiveTabColor;
_tabs.Add(tabButton.Tab, tabButton);
tabButton.Button.onClick.AddListener(() => ShowTab(tabButton.Tab));
}
}
// void Start()
// {
// ShowTab(MenuTab.Inventory);
// }
}
public enum MenuTab
{
Map,
Inventory,
Trade,
Galaxy
}