Fix main menu ordering

This commit is contained in:
Nahuel Rocchetti 2023-06-24 20:34:21 -03:00
parent 46c6210764
commit fa072d3688
3 changed files with 149 additions and 13 deletions

View file

@ -149,11 +149,11 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 19247258}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1755469747}
m_Father: {fileID: 1118021355}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
@ -365,8 +365,110 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1118021351
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1118021355}
- component: {fileID: 1118021354}
- component: {fileID: 1118021353}
- component: {fileID: 1118021352}
m_Layer: 5
m_Name: Initial Load Screen Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1118021352
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1118021351}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1118021353
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1118021351}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &1118021354
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1118021351}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 1
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 1
m_TargetDisplay: 0
--- !u!224 &1118021355
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1118021351}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 19247259}
- {fileID: 1690878378}
- {fileID: 1334026408}
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1334026407
GameObject:
m_ObjectHideFlags: 0
@ -393,11 +495,11 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1334026407}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1755469747}
m_Father: {fileID: 1118021355}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
@ -559,11 +661,11 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1690878377}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: -1, z: 1}
m_Children: []
m_Father: {fileID: 1755469747}
m_Father: {fileID: 1118021355}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
@ -710,10 +812,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 19247259}
- {fileID: 1690878378}
- {fileID: 1334026408}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View file

@ -29,6 +29,13 @@ namespace OpenTS2.UI.Layouts
private const uint PreviousButtonID = 0x1004;
private const uint NextButtonID = 0x1005;
private const uint QuitButtonID = 0xA5;
private const uint NeighborhoodQuitButtonID = 0xA4;
private const uint NeighborhoodCloseButtonID = 0xA3;
private const uint OnInitialLoadID = 0x8DC06B6A;
private const uint FromNeighborhoodID = 0x3000;
public Action OnClose;
private UIComponent _shade;
private NeighborhoodPreview _neighborhoodPreview;
private List<Neighborhood> _neighborHoods;
@ -45,7 +52,7 @@ namespace OpenTS2.UI.Layouts
{
var root = Components[0];
root.SetAnchor(UIComponent.AnchorType.Center);
root.transform.SetAsFirstSibling();
//root.transform.SetAsFirstSibling();
if (!fromNeighborhood)
{
@ -53,6 +60,19 @@ namespace OpenTS2.UI.Layouts
background.gameObject.SetActive(true);
background.SetAnchor(UIComponent.AnchorType.Center);
background.transform.SetAsFirstSibling();
var quitButton = Components[0].GetChildByID<UIButtonComponent>(QuitButtonID);
quitButton.OnClick += OnQuit;
}
else
{
var onInitialLoadUI = root.GetChildByID(OnInitialLoadID);
var fromNeighborhoodUI = root.GetChildByID(FromNeighborhoodID);
onInitialLoadUI.gameObject.SetActive(false);
fromNeighborhoodUI.gameObject.SetActive(true);
var quitButton = Components[0].GetChildByID<UIButtonComponent>(NeighborhoodQuitButtonID);
quitButton.OnClick += OnQuit;
var closeButton = Components[0].GetChildByID<UIButtonComponent>(NeighborhoodCloseButtonID);
closeButton.OnClick += DoClose;
}
var upperLeftSim = root.GetChildByID<UIBMPComponent>(UpperLeftSimBMPID);
@ -161,10 +181,9 @@ namespace OpenTS2.UI.Layouts
var previousButton = Components[0].GetChildByID<UIButtonComponent>(PreviousButtonID);
var nextButton = Components[0].GetChildByID<UIButtonComponent>(NextButtonID);
var quitButton = Components[0].GetChildByID<UIButtonComponent>(QuitButtonID);
previousButton.OnClick += OnPrevPage;
nextButton.OnClick += OnNextPage;
quitButton.OnClick += OnQuit;
}
// Creates a clickable neighborhood icon, displays preview on click.
@ -194,6 +213,18 @@ namespace OpenTS2.UI.Layouts
Application.Quit();
}
void DoClose()
{
OnClose?.Invoke();
UnityEngine.Object.Destroy(_shade.gameObject);
UnityEngine.Object.Destroy(_neighborhoodPreview.Components[0].gameObject);
foreach(var icon in _neighborhoodIcons)
{
UnityEngine.Object.Destroy(icon.Components[0].gameObject);
}
UnityEngine.Object.Destroy(Components[0].gameObject);
}
void OnPrevPage()
{
_currentPage--;

View file

@ -51,7 +51,13 @@ namespace OpenTS2.UI.Layouts
if (_mainMenu != null)
return;
_mainMenu = new MainMenu(true);
_mainMenu.OnClose += OnMainMenuClose;
CursorController.Cursor = CursorController.CursorType.Default;
}
void OnMainMenuClose()
{
_mainMenu = null;
}
}
}