public static void FormatMenu(MenuBase menu) { menu.HeaderFont = 0; menu.ItemFont = 0; menu.HeaderColor = Color.FromArgb(140,6,6,6); menu.HeaderTextColor = Color.White; menu.SelectedItemColor = Color.White; menu.SelectedTextColor = Color.Black; menu.UnselectedItemColor = Color.FromArgb(120, 8, 8, 8); menu.UnselectedTextColor = Color.White; menu.HeaderCentered = false; menu.ItemTextCentered = false; menu.ItemTextScale = 0.36f; menu.HeaderTextScale = 0.4f; var m = menu as Menu; if(m != null) { m.ItemHeight = 25; m.HeaderHeight = 28; m.HasFooter = false; m.Width = 300; m.TextOffset = new Point(4,0); m.HeaderHeight = 0; } var mb = menu as MessageBox; if(mb != null) { mb.Width = 300; mb.TextOffset = new Point(4, 0); } }
public virtual void Initialize(MenuBase parent) { m_pParent = parent; MenuButton[] buttons = gameObject.GetComponentsInChildren<MenuButton>(); for (int i = 0; i < buttons.Length; i++) { buttons[i].Initialize(ButtonClicked); } }
public override bool OnNavigatedFrom(MenuBase menu) { if (base.OnNavigatedFrom(menu)) { InstrumentClusterElectronics.SpeedLimitChanged -= InstrumentClusterElectronics_SpeedLimitChanged; return true; } return false; }
public override bool OnNavigatedTo(MenuBase menu) { if (base.OnNavigatedTo(menu)) { InstrumentClusterElectronics.SpeedLimitChanged += InstrumentClusterElectronics_SpeedLimitChanged; UpdateLimit(); return true; } return false; }
public override bool OnNavigatedFrom(MenuBase menu) { if (base.OnNavigatedFrom(menu)) { DigitalDieselElectronics.MessageReceived -= DigitalDieselElectronics_MessageReceived; //if (refreshTimer != null) //{ // refreshTimer.Dispose(); // refreshTimer = null; //} return(true); } return(false); }
public override bool OnNavigatedTo(MenuBase menu) { if (base.OnNavigatedTo(menu)) { DigitalDieselElectronics.MessageReceived += DigitalDieselElectronics_MessageReceived; //refreshRate = 1000; //refreshTimer = new Timer(delegate //{ // DBusManager.Instance.EnqueueMessage(DigitalDieselElectronics.QueryMessage); //}, null, 500, refreshRate); return(true); } return(false); }
public override void Draw(MenuBase context) { var item = (MenuItemEntry)context; var pos = context.Position; var size = context.RenderSize; var activeStyle = context.MenuConfig.GeneralConfig.ActiveStyle.Value; var styleConfig = activeStyle.StyleConfig; var border = styleConfig.Border; context.Renderer.DrawTexture(activeStyle.Item, new RectangleF(pos.X, pos.Y, size.X, size.Y)); pos += new Vector2(border.Thickness[0], border.Thickness[1]); var font = styleConfig.Font; context.Renderer.DrawText(pos, context.Name, styleConfig.Font.Color, font.Size, font.Family); var propValue = item.ValueBinding.GetValue <ISlider>(); var rightSide = (context.Position.X + size.X) - border.Thickness[2]; pos.X = rightSide - item.ValueSize.X - styleConfig.TextSpacing; var rect = new RectangleF(); rect.X = pos.X; rect.Y = pos.Y; rect.Right = rightSide; rect.Bottom = context.Position.Y + size.Y; context.Renderer.DrawText(rect, propValue.ToString(), styleConfig.Font.Color, RendererFontFlags.Right, font.Size, font.Family); pos = context.Position; switch (propValue) { case ISlider <int> intSlider: pos.X += ((float)(intSlider.Value - intSlider.MinValue) / (intSlider.MaxValue - intSlider.MinValue)) * size.X; break; case ISlider <float> floatSlider: pos.X += ((floatSlider.Value - floatSlider.MinValue) / (floatSlider.MaxValue - floatSlider.MinValue)) * size.X; break; case ISlider <double> doubleSlider: pos.X += (float)((doubleSlider.Value - doubleSlider.MinValue) / (doubleSlider.MaxValue - doubleSlider.MinValue)) * size.X; break; } context.Renderer.DrawLine(pos, pos + new Vector2(0, size.Y), styleConfig.Slider.LineColor, styleConfig.Slider.LineWidth); }
public override void update(MenuBase m) { data.menu = m; data.tarIP = ipNumber; foreach (Button b in buttons) { b.calculate(data); } if (Connections.GetInstance().isConnected) { m.setCurrent(MenuStates.LOBBY_CONNECTED); } }
public override Vector2 GetSize(MenuBase context) { var totalSize = base.GetSize(context); var styleConfig = context.MenuConfig.GeneralConfig.ActiveStyle.Value.StyleConfig; var item = (MenuItemEntry)context; var font = styleConfig.Font; // get size of longest possible hotkey item.ValueSize = context.Renderer.MessureText(MouseButtons.XButton2Down.ToString(), font.Size, font.Family); totalSize.X += styleConfig.TextSpacing + 10 + item.ValueSize.X + 10; return(totalSize); }
public void AddButton(MenuBase menu, string label) { var instance = UIUtility.Add <UIMenuButton>(transform, Prototype.gameObject); instance.Label = label; instance.Pressed += Button_Pressed; if (_current == null) { _current = instance; } _buttons.Add(instance, menu); }
public void CloseMenu(MenuBase menu) { if (_menuStack.Count == 0) { Debug.Log("MenuStack is empty"); return; } if (_menuStack.Peek() != menu) { Debug.LogErrorFormat(menu, "{0} cannot be closed because it is not on top of stack", menu.GetType()); } CloseTopMenu(); }
public override Vector2 GetSize(MenuBase context) { var totalSize = base.GetSize(context); var styleConfig = context.MenuConfig.GeneralConfig.ActiveStyle.Value.StyleConfig; var item = (MenuItemEntry)context; var propValue = item.ValueBinding.GetValue <ISlider <Vector2> >(); var font = styleConfig.Font; item.ValueSize = context.Renderer.MessureText($"<{(int)propValue.MaxValue.X}, {(int)propValue.MaxValue.Y}>", font.Size, font.Family); totalSize.X += styleConfig.TextSpacing + item.ValueSize.X; return(totalSize); }
public override bool OnNavigatedTo(MenuBase menu) { if (base.OnNavigatedTo(menu)) { if (VolumeInfo.GetVolumes().Length > 0 && VolumeInfo.GetVolumes()[0].IsFormatted) { InitFilesEnumerator(); GeneratePage(); } return(true); } return(false); }
public override bool OnNavigatedFrom(MenuBase menu) { if (base.OnNavigatedFrom(menu)) { BodyModule.BatteryVoltageChanged -= BodyModule_BatteryVoltageChanged; InstrumentClusterElectronics.SpeedRPMChanged -= InstrumentClusterElectronics_SpeedRPMChanged; InstrumentClusterElectronics.TemperatureChanged -= InstrumentClusterElectronics_TemperatureChanged; InstrumentClusterElectronics.AverageSpeedChanged -= InstrumentClusterElectronics_AverageSpeedChanged; InstrumentClusterElectronics.Consumption1Changed -= InstrumentClusterElectronics_Consumption1Changed; InstrumentClusterElectronics.Consumption2Changed -= InstrumentClusterElectronics_Consumption2Changed; InstrumentClusterElectronics.RangeChanged -= InstrumentClusterElectronics_RangeChanged; InstrumentClusterElectronics.SpeedLimitChanged -= InstrumentClusterElectronics_SpeedLimitChanged; return(true); } return(false); }
public override bool OnNavigatedFrom(MenuBase menu) { if (base.OnNavigatedFrom(menu)) { ClearItems(); NavigationModule.BatteryVoltageChanged -= NavigationModule_BatteryVoltageChanged; IntegratedHeatingAndAirConditioning.AirConditioningCompressorStatusChanged -= IntegratedHeatingAndAirConditioning_AirConditioningCompressorStatusChanged; //HeadlightVerticalAimControl.FrontSensorVoltageChanged -= HeadlightVerticalAimControl_SensorsVoltageChanged; //HeadlightVerticalAimControl.RearSensorVoltageChanged -= HeadlightVerticalAimControl_SensorsVoltageChanged; //DigitalDieselElectronics.MessageReceived -= DigitalDieselElectronics_MessageReceived; return(true); } return(false); }
// Start is called before the first frame update void Start() { playerUI = transform.GetChild(6).gameObject; menuBase = new MenuBase(this, transform.GetChild(2).gameObject); confirmSave = new ConfirmSave(this, transform.GetChild(4).gameObject); confirmClose = new ConfirmClose(this, transform.GetChild(3).gameObject); optionMenu = new OptionMenu(this, transform.GetChild(5).gameObject); menuBase.lootPanel.SetActive(false); confirmSave.lootPanel.SetActive(false); confirmClose.lootPanel.SetActive(false); optionMenu.lootPanel.SetActive(false); // 레이어용. MappingInfo mapping = new MappingInfo("MenuUI"); mapping.Enroll("MenuUI"); }
public override bool OnClick(MenuBase context, MouseButtons buttons, Vector2 clickPosition) { if ((buttons & MouseButtons.LeftUp) == MouseButtons.LeftUp) { var state = this.GetItemUnderMouse(context, clickPosition); if (state.HasValue) { var item = (MenuItemEntry)context; var propValue = item.ValueBinding.GetValue <ImageToggler>(); propValue.PictureStates[state.Value.Key] = !state.Value.Value; return(true); } } return(false); }
public override Vector2 GetSize(MenuBase context) { var totalSize = base.GetSize(context); var styleConfig = context.MenuConfig.GeneralConfig.ActiveStyle.Value.StyleConfig; totalSize.X += styleConfig.TextSpacing + styleConfig.ArrowSize.X + (styleConfig.TextSpacing * 2); totalSize.Y = Math.Max(Math.Max(totalSize.Y, styleConfig.ArrowSize.Y), styleConfig.PicturePicker.PictureSize.Y); var item = (MenuItemEntry)context; var propValue = item.ValueBinding.GetValue <ImageToggler>(); var picturePickerStyle = styleConfig.PicturePicker; totalSize.X += propValue.PictureStates.Count * (styleConfig.PicturePicker.PictureSize.X + (2 * picturePickerStyle.LineWidth)); return(totalSize); }
public override bool OnNavigatedFrom(MenuBase menu) { if (base.OnNavigatedFrom(menu)) { BodyModule.BatteryVoltageChanged -= BodyModule_BatteryVoltageChanged; InstrumentClusterElectronics.SpeedRPMChanged -= InstrumentClusterElectronics_SpeedRPMChanged; InstrumentClusterElectronics.TemperatureChanged -= InstrumentClusterElectronics_TemperatureChanged; InstrumentClusterElectronics.AverageSpeedChanged -= InstrumentClusterElectronics_AverageSpeedChanged; InstrumentClusterElectronics.Consumption1Changed -= InstrumentClusterElectronics_Consumption1Changed; InstrumentClusterElectronics.Consumption2Changed -= InstrumentClusterElectronics_Consumption2Changed; InstrumentClusterElectronics.RangeChanged -= InstrumentClusterElectronics_RangeChanged; InstrumentClusterElectronics.SpeedLimitChanged -= InstrumentClusterElectronics_SpeedLimitChanged; return true; } return false; }
public void OnRightButtonPressed() { this.m_SelectionIdx++; if (this.m_Cyclic && this.m_SelectionIdx >= this.m_Options.Count) { this.m_SelectionIdx = 0; } this.m_SelectionIdx = Mathf.Clamp(this.m_SelectionIdx, 0, this.m_Options.Count - 1); this.UpdateEverything(); MenuBase target = this.m_Target; if (target != null) { target.OnSelectionChanged(this, this.m_Options.Keys.ElementAt(this.m_SelectionIdx)); } this.PlaySound(); }
public static void FormatMenuFooter(MenuBase menu) { var m = menu as Menu; if (m != null) { m.HasFooter = true; m.FooterHeight = 25; } menu.FooterCentered = true; menu.FooterColor = Color.FromArgb(120, 25, 25, 25); menu.FooterFont = 0; menu.FooterCentered = false; menu.FooterTextColor = Color.White; menu.FooterTextScale = 0.25f; }
public override Vector2 GetSize(MenuBase context) { var totalSize = base.GetSize(context); var styleConfig = context.MenuConfig.GeneralConfig.ActiveStyle.Value.StyleConfig; totalSize.X += styleConfig.TextSpacing + (styleConfig.ArrowSize.X * 2); // TODO: use own bool view style options totalSize.Y = Math.Max(totalSize.Y, styleConfig.ArrowSize.Y); // border missing for y if (!string.IsNullOrEmpty(context.TextureKey)) { var textureSize = context.Renderer.GetTextureSize(context.TextureKey); var scale = totalSize.Y / textureSize.Y; totalSize.X += styleConfig.TextSpacing + (textureSize.X * scale); } return(totalSize); }
public void UpdateMenu() //更新预设体实例 { if (obj == null) { return; } MenuBase iMenu = obj.GetComponent <MenuBase>(); if (iMenu != null) { iMenu.UpdateMenu(); } else { Debug.LogWarningFormat("not found IMenu componet.({0})", obj); } }
public void Open(MenuBase _prevMenu = null) { Debug.Assert(m_PrevMenu == null, "The menu (" + gameObject.name + ") is already opened"); if (m_PrevMenu != null) { return; } if (_prevMenu) { _prevMenu.Hide(); } m_PrevMenu = _prevMenu; Show(); }
// Use this for initialization void Start() { if (!Menu) { Menu = GetComponent <MenuBase>(); if (!Menu) { print("I need a menu"); return; } } for (int i = 0; i < InitialItems; i++) { Menu.AddToEnd(currentIndex.ToString()); currentIndex++; } }
public void SetMenu(MenuBase menu) { if (!_menuInput.InputEnabled) { return; } if (_menus.Contains(menu) && CurrentMenu != null && menu != CurrentMenu) { _menuButtons.Select(menu); _menuInput.InputEnabled = false; _menuTransitionAnimation.Transition(CurrentMenu, menu, (newMenu) => { CurrentMenu = newMenu; _menuInput.InputEnabled = true; }); } }
public void SwitchToMenu(MenuBase baseMenu, bool playEffect = true) { if (NextMenu != null && NextMenu.Item1 != null) { Debug.LogWarningFormat ( "Changed menu twice in this frame! From '{0}' to '{1}' and now to '{2}'", CurrentMenu, NextMenu.Item1, baseMenu ); } if (Verbose) { Debug.LogFormat("{0}: Switch from '{1}' to '{2}'", this, CurrentMenu, baseMenu); } NextMenu = new Tuple <MenuBase, bool>(baseMenu, playEffect); }
public void Show(MenuBase menu, bool hidePrev = true) { if (currMenu.Count > 0) { if (hidePrev) { currMenu.Pop().Hide(false); } else { currMenu.Peek().SaveLastButton(); currMenu.Peek().DisableAllSelectable(); } } currMenu.Push(menu); menu.Show(false); }
void Start() { currMenu = Menus[FirstMenuId]; foreach (var menu in Menus) { if (menu != currMenu) { menu.Hide(); } else { menu.Show(); } menu.MenuManager = this; } }
public bool CheckBackMenuAvailable() //检查是否激活 { if (obj == null) { return(true); } MenuBase iMenu = obj.GetComponent <MenuBase>(); if (iMenu != null) { return(iMenu.CheckBackMenuAvailable()); } else { Debug.LogWarningFormat("not found IMenu componet.({0})", obj); } return(true); }
public MenuBase Create(MenuData data, MenuBase parent) { var _mTypes = Assembly.GetExecutingAssembly().GetTypes().Where( t => { return(t != typeof(MenuBase) && typeof(MenuBase).IsAssignableFrom(t)); } ); foreach (var _mType in _mTypes) { if (_TypeReg.Match(_mType.ToString()).Value == "M" + data.Type.ToString()) { return((MenuBase)Activator.CreateInstance(_mType, data, parent)); } } return(null); }
public override void Draw(MenuBase context) { var item = (MenuItemEntry)context; var pos = context.Position; var size = context.RenderSize; var activeStyle = context.MenuConfig.GeneralConfig.ActiveStyle.Value; var styleConfig = activeStyle.StyleConfig; var border = styleConfig.Border; context.Renderer.DrawTexture(activeStyle.Item, new RectangleF(pos.X, pos.Y, size.X, size.Y)); var sliderPos = Vector2.Zero; sliderPos.X = (pos.X + size.X) - border.Thickness[2] - (styleConfig.ArrowSize.X * 2); sliderPos.Y = pos.Y + border.Thickness[1]; context.Renderer.DrawTexture(activeStyle.Slider, new RectangleF(sliderPos.X, sliderPos.Y, styleConfig.ArrowSize.X * 2, styleConfig.ArrowSize.Y)); pos += new Vector2(border.Thickness[0] + styleConfig.LineWidth, border.Thickness[1]); if (!string.IsNullOrEmpty(context.TextureKey)) { var textureSize = context.Renderer.GetTextureSize(context.TextureKey); var scale = (size.Y - border.Thickness[1] - border.Thickness[3]) / textureSize.Y; textureSize *= scale; context.Renderer.DrawTexture(context.TextureKey, new RectangleF(pos.X, pos.Y, textureSize.X, textureSize.Y)); pos.X += textureSize.X + styleConfig.TextSpacing; } var font = styleConfig.Font; context.Renderer.DrawText(pos, context.Name, font.Color, font.Size, font.Family); if (item.ValueBinding.GetValue <bool>()) { sliderPos.X += styleConfig.ArrowSize.X; context.Renderer.DrawTexture(activeStyle.Checked, new RectangleF(sliderPos.X, sliderPos.Y, styleConfig.ArrowSize.X, styleConfig.ArrowSize.Y)); } else { context.Renderer.DrawTexture(activeStyle.Unchecked, new RectangleF(sliderPos.X, sliderPos.Y, styleConfig.ArrowSize.X, styleConfig.ArrowSize.Y)); } }
public void Transition(MenuBase from, MenuBase to, Action <MenuBase> onComplete) { _out = from; _in = to; _in.SetVisibility(true); _outCanvas = from.gameObject.GetOrAddComponent <CanvasGroup>(); _inCanvas = to.gameObject.GetOrAddComponent <CanvasGroup>(); _onComplete = onComplete; _tweenAlphaIn.Duration = TransitionTime; _tweenAlphaOut.Duration = TransitionTime; _tweenAlphaIn.Play(); _tweenAlphaOut.Play(); _transitioning = true; }
public MList(MenuData data, MenuBase parent) : base(data, parent) { ItemHeight = FloatFromString(data.GetDataProperty("ItemHeight").ToString(), false); ItemSpacing = FloatFromString(data.GetDataProperty("ItemSpacing").ToString(), false); ListItems = new List <MListItem>(); for (int _index = 0; _index < Items.Count; _index++) { var _item = Items[_index]; if (_item is MListItem) { var _listItem = (MListItem)_item; _listItem.Depth = Depth; _listItem.SetList(this, _index); ListItems.Add(_listItem); } } }
/// <summary> /// Add standard application Cut, Copy, Paste, and Deleete menu entries. /// </summary> /// <param name="menu"></param> protected void AddCopyCutPasteMenuItems(MenuBase menu) { menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Cut, Icon = IconImageFactory.Get(IconCommand.Cut) }); menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Copy, Icon = IconImageFactory.Get(IconCommand.Copy) }); menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Paste, Icon = IconImageFactory.Get(IconCommand.Paste) }); menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Delete, Icon = IconImageFactory.Get(IconCommand.Delete) }); }
private void TransitionEnd() { if( nNextMenu >= 0 ) { SetInput(false); MenuBase result = null; if( m_pMenus.TryGetValue(nNextMenu, out result) == true) { result.SetState(true, TransitionEnd); m_pCurrentMenu = result; m_pMenuList.Push(nNextMenu); } nNextMenu = -1; } else { SetInput(true); } }
internal static LUCAMenuStrip FindLUCAMenuStrip(MenuBase source) { if (source is LUCAMenuStrip) { return source as LUCAMenuStrip; } if (source.ParentMenuElement != null) { return FindLUCAMenuStrip(source.ParentMenuElement); } return null; }
public void OpenMenuWithHeirarchy(MenuDefinitions.Menus[] menuList) { if( m_pCurrentMenu != null) m_pCurrentMenu.SetState(false); m_pCurrentMenu = null; m_pMenuList.Clear(); for (int i = 0; i < menuList.Length; i++) { m_pMenuList.Push( (int)menuList[i] ); } OpenMenu( (MenuDefinitions.Menus)m_pMenuList.Peek() ); }
private void OnChangeMenuRequest(object s, MenuBase sm) { ChangeMenuRequestEvent?.Invoke(s, sm); }
public void Draw(MenuBase menuBase) { menuBase.ScreenManager.SpriteBatch.Draw(backgroundComponent.Background, new Vector2((int)Position.X, (int)Position.Y), backgroundComponent.Color); menuBase.ScreenManager.SpriteBatch.DrawString(SpriteFontHelper.GetMenuItemFont(menuBase.ScreenManager.Content), text, GetTextPosition(menuBase.ScreenManager.Content), ColorHelper.White); }
private bool IsOpen(MenuBase menu) { var items = (List<MenuBase>)typeof(Viewport).GetField("mMenuStack", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(View); return items.Contains(menu); }
/// <summary> /// Closes all menus currently open from the LUCAMenuStrip that the given source MenuBase is associated with. /// </summary> /// <param name="source"></param> internal static void ResetLUCAMenuStrip(MenuBase source) { var LUCAMenuStrip = FindLUCAMenuStrip(source); LUCAMenuStrip._hoverShow = false; LUCAMenuStrip.HideAllMenus(); }
public static void FormatMenuWithFooter(MenuBase menuBase) { FormatMenu(menuBase); FormatMenuFooter(menuBase); }