mirror of
https://github.com/LazyDuchess/OpenTS2.git
synced 2025-01-22 16:21:47 -05:00
Add in-game main menu.
This commit is contained in:
parent
fc0e857470
commit
46c6210764
3 changed files with 25 additions and 6 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue