Skip to content

Commit

Permalink
trying to implement opening mod's menu
Browse files Browse the repository at this point in the history
  • Loading branch information
TAImatem committed Jan 16, 2020
1 parent 4f06b3e commit 864d3ee
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion MenuTries/MenuTries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using System;
using System.Security.AccessControl;

namespace MenuTries
{
Expand All @@ -16,7 +17,7 @@ public class MenuTries : ModBehaviour
public static GameObject extramenu, canvas, toggle, rebinder;
public static Transform content;
public static Button menubutton;
public static Menu cusMenu;
public static Menu cusMenu, somemenu;
public static Selectable first=null;

private void Start()
Expand All @@ -30,6 +31,7 @@ private void Start()
ModHelper.Console.WriteLine("copying menu");
canvas = GameObject.Find("KeyboardRebindingCanvas");
extramenu = canvas.transform.GetChild(0).gameObject;
somemenu = extramenu.GetComponent<Menu>();
extramenu = GameObject.Instantiate(extramenu,canvas.transform);
cusMenu = extramenu.GetComponent<Menu>();

Expand Down Expand Up @@ -62,6 +64,9 @@ private void Start()
{
newins = GameObject.Instantiate(toggle, content);
cur = newins.GetComponent<Button>();

(cur as Button).onClick.AddListener(() => ButtonClicked(somemenu, (cur as Button)));

newins.GetComponent<TwoButtonToggleElement>().Initialize(false);
Navigation nav = cur.navigation, nav2;
nav.mode = Navigation.Mode.Explicit;
Expand Down Expand Up @@ -96,6 +101,17 @@ private void Start()
ModHelper.Console.WriteLine("MenuTry done!");
}

private void ButtonClicked(Menu toopen, Button clicked)
{
FieldInfo sel = typeof(UIStyleApplier).GetField("_currentState", BindingFlags.NonPublic | BindingFlags.Instance);
ModHelper.Console.WriteLine($"{clicked.name} {(UIElementState)sel.GetValue(clicked.GetComponent<UIStyleApplier>())}");
if ((UIElementState)sel.GetValue(clicked.gameObject.GetComponent<UIStyleApplier>()) == UIElementState.HIGHLIGHTED)
{
ModHelper.Console.WriteLine("opening menu");
//toopen.EnableMenu(true);
}
}

private void OnLogMessageReceived(string message, string stackTrace, LogType type)
{
if (stackTrace != null)
Expand Down

0 comments on commit 864d3ee

Please sign in to comment.