mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-10 14:44:17 +00:00
windows can be sorted in main menu
This commit is contained in:
parent
f400009bcf
commit
5b472d673b
3 changed files with 13 additions and 7 deletions
|
@ -18,11 +18,11 @@ namespace SanAndreasUnity.UI
|
|||
public Color backgroundColor = Color.black;
|
||||
public bool drawLogo = false;
|
||||
|
||||
private static List<System.Action> s_registeredMenuItems = new List<System.Action>();
|
||||
|
||||
private static GUILayoutOption[] s_buttonOptions = new GUILayoutOption[0];
|
||||
public static GUILayoutOption[] ButtonLayoutOptions { get { return s_buttonOptions; } }
|
||||
|
||||
static MenuEntry s_rootMenuEntry = new MenuEntry();
|
||||
|
||||
|
||||
|
||||
void Start ()
|
||||
|
@ -69,9 +69,10 @@ namespace SanAndreasUnity.UI
|
|||
GUILayout.FlexibleSpace ();
|
||||
|
||||
// draw registered menu items
|
||||
foreach (var item in s_registeredMenuItems)
|
||||
foreach (var item in s_rootMenuEntry.children)
|
||||
{
|
||||
item ();
|
||||
if (item.drawAction != null)
|
||||
item.drawAction();
|
||||
GUILayout.Space (this.spaceBetweenButtons);
|
||||
}
|
||||
|
||||
|
@ -92,9 +93,9 @@ namespace SanAndreasUnity.UI
|
|||
|
||||
}
|
||||
|
||||
public static void RegisterMenuItem (System.Action action)
|
||||
public static void RegisterMenuItem (MenuEntry menuEntry)
|
||||
{
|
||||
s_registeredMenuItems.AddIfNotPresent (action);
|
||||
s_rootMenuEntry.AddChild (menuEntry);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace SanAndreasUnity.UI
|
|||
public string name = "";
|
||||
public int sortPriority = 0;
|
||||
public List<MenuEntry> children = new List<MenuEntry>();
|
||||
public System.Action drawAction = null;
|
||||
|
||||
public void AddChild(MenuEntry entry)
|
||||
{
|
||||
|
|
|
@ -68,6 +68,7 @@ namespace SanAndreasUnity.UI {
|
|||
|
||||
[SerializeField] private bool m_registerInMainMenuOnStart = false;
|
||||
public bool IsRegisteredInMainMenu { get; private set; }
|
||||
[SerializeField] int m_sortPriorityForMainMenu = 0;
|
||||
|
||||
private static GameObject s_windowsContainer;
|
||||
|
||||
|
@ -258,7 +259,10 @@ namespace SanAndreasUnity.UI {
|
|||
return;
|
||||
|
||||
this.IsRegisteredInMainMenu = true;
|
||||
MainMenu.RegisterMenuItem ( () => this.OnMainMenuGUI() );
|
||||
|
||||
MenuEntry menuEntry = new MenuEntry(){name = this.windowName, sortPriority = m_sortPriorityForMainMenu,
|
||||
drawAction = () => this.OnMainMenuGUI()};
|
||||
MainMenu.RegisterMenuItem (menuEntry);
|
||||
}
|
||||
|
||||
private void OnMainMenuGUI ()
|
||||
|
|
Loading…
Reference in a new issue