Add in-game main menu.

This commit is contained in:
Nahuel Rocchetti 2023-06-24 20:09:30 -03:00
parent fc0e857470
commit 46c6210764
3 changed files with 25 additions and 6 deletions

View file

@ -35,6 +35,8 @@ namespace OpenTS2.Content
{
CursorController.Cursor = CursorController.CursorType.Hourglass;
ContentProvider.Get().Changes.SaveChanges();
if (CurrentNeighborhood != null)
ContentLoading.UnloadNeighborhoodContentSync();
ContentLoading.LoadNeighborhoodContentSync(neighborhood);
MusicController.FadeOutMusic();
CurrentNeighborhood = neighborhood;

View file

@ -36,21 +36,24 @@ namespace OpenTS2.UI.Layouts
private int _currentPage = 0;
protected override ResourceKey UILayoutResourceKey => new ResourceKey(0x49001017, 0xA99D8A11, TypeIDs.UI);
public MainMenu() : this(MainCanvas)
public MainMenu(bool fromNeighborhood = false) : this(MainCanvas, fromNeighborhood)
{
}
public MainMenu(Transform canvas) : base(canvas)
public MainMenu(Transform canvas, bool fromNeighborhood = false) : base(canvas)
{
var root = Components[0];
root.SetAnchor(UIComponent.AnchorType.Center);
root.transform.SetAsFirstSibling();
var background = root.GetChildByID(BackgroundID);
background.gameObject.SetActive(true);
background.SetAnchor(UIComponent.AnchorType.Center);
background.transform.SetAsFirstSibling();
if (!fromNeighborhood)
{
var background = root.GetChildByID(BackgroundID);
background.gameObject.SetActive(true);
background.SetAnchor(UIComponent.AnchorType.Center);
background.transform.SetAsFirstSibling();
}
var upperLeftSim = root.GetChildByID<UIBMPComponent>(UpperLeftSimBMPID);
var lowerRightSim = root.GetChildByID<UIBMPComponent>(LowerRightSimBMPID);

View file

@ -19,8 +19,10 @@ namespace OpenTS2.UI.Layouts
private const uint MediumCityNameTextID = 0xB3;
private const uint SmallCityNameTextID = 0xA3;
private const uint PrimaryOptionsID = 0x4BE6ED7E;
private const uint MainMenuID = 0x2;
private const uint PuckID = 0x4BE6ED7D;
protected override ResourceKey UILayoutResourceKey => new ResourceKey(0x49000000, 0xA99D8A11, TypeIDs.UI);
private MainMenu _mainMenu = null;
public NeighborhoodHUD() : this(MainCanvas)
{
@ -36,8 +38,20 @@ namespace OpenTS2.UI.Layouts
var primaryOptions = root.GetChildByID(PrimaryOptionsID, false);
var mainMenu = root.GetChildByID<UIButtonComponent>(MainMenuID, false);
mainMenu.OnClick += OnMainMenu;
var largeCityName = primaryOptions.GetChildByID<UITextComponent>(LargeCityNameTextID);
largeCityName.Text = NeighborhoodManager.CurrentNeighborhood.GetLocalizedName();
}
void OnMainMenu()
{
CursorController.Cursor = CursorController.CursorType.Hourglass;
if (_mainMenu != null)
return;
_mainMenu = new MainMenu(true);
CursorController.Cursor = CursorController.CursorType.Default;
}
}
}