void LoadFor() { Debug.Log("CustomMenuButton.LoadFor", "object = " + name); string collection = ""; for (int i = 0; i < MenuButtonInfo.DataBase?.Count; i++) { MenuButtonInfo info = (MenuButtonInfo)MenuButtonInfo.DataBase[i]; if (info != null) { if (string.IsNullOrEmpty(info.name) || info.name == name) { Debug.Log("CustomMenuButton.LoadFor", "Matched name = " + info.name + " to object name = " + name); if (string.IsNullOrEmpty(collection) || collection == info.collection) { Debug.Log("CustomMenuButton.LoadFor", "Matched collection = " + info.collection + " to current collection = " + collection); // Collection collection = info.collection; // Colors normalColor = normalColor ?? info.normalColor; hoverColor = hoverColor ?? info.hoverColor; downColor = downColor ?? info.downColor; // Text if (string.IsNullOrEmpty(text)) { text = info.text; } // Vectors position = position ?? info.position; rotation = rotation ?? info.rotation; scale = scale ?? info.scale; } } } } }
public void SetInfo(MenuButtonInfo buttonInfo) { ButtonInfo = buttonInfo; SetToggle(ButtonInfo.InitialToggleState); gameObject.SetActive(HololensHelper.IsDeviceHololens() || buttonInfo.VisibleOnPC); }
/// <summary> /// Handle the facade message /// </summary> /// <param name="message">Message sent from client</param> /// <param name="server">Instance of the socket server</param> /// <param name="client">Socket that sent the message (for return messages)</param> internal static void HandleFacadeMessage(Newtonsoft.Json.Linq.JObject message, SocketServer server, AsyncSocket client) { String action = (string)message["FacadeAction"]; GUIWindow currentPlugin = GUIWindowManager.GetWindow(GUIWindowManager.ActiveWindow); if (action.Equals("get")) { MessageFacade returnMessage = new MessageFacade(); if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50); List <FacadeItem> items = MpFacadeHelper.GetHomeItems(menu); returnMessage.FacadeItems = items; returnMessage.ViewType = "Home"; } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); if (facade != null) { List <FacadeItem> items = MpFacadeHelper.GetFacadeItems(currentPlugin.GetID, 50); returnMessage.ViewType = facade.CurrentLayout.ToString(); returnMessage.FacadeItems = items; } } returnMessage.WindowId = currentPlugin.GetID; server.SendMessageToClient(returnMessage, client); } else if (action.Equals("setselected")) { if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); int selected = (int)message["SelectedIndex"]; facade.SelectedListItemIndex = selected; } } else if (action.Equals("getselected")) { if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { //TODO: find a way to retrieve the currently selected home button } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); int selected = facade.SelectedListItemIndex; } } else if (action.Equals("getcount")) { if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50); int count = menu.ButtonInfos.Count; } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); int count = facade.Count; } } else if (action.Equals("select")) { int selected = (int)message["SelectedIndex"]; if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50); MenuButtonInfo info = menu.ButtonInfos[selected]; GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, info.PluginID, 0, null); GUIWindowManager.SendThreadMessage(msg); } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); //TODO: is there a better way to select a list item facade.SelectedListItemIndex = selected; new Communication().SendCommand("ok"); } } else if (action.Equals("context")) { int selected = (int)message["SelectedIndex"]; if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50); MenuButtonInfo info = menu.ButtonInfos[selected]; GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, info.PluginID, 0, null); GUIWindowManager.SendThreadMessage(msg); } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); //TODO: is there a better way to select a list item facade.SelectedListItemIndex = selected; new Communication().SendCommand("info"); } } }