void Awake() { controllerCamera = Camera.mainCamera; //Setup Messenger Messenger.AddListener(InputManager.kMegatileCapMet, OnOpenMenu); Messenger<Vector3>.AddListener(InputManager.kRightClickedTile, OnCloseMenu); Messenger.AddListener(kClose, OnCloseMenu); //Setup GUIGroup menuGroup = new GUIContainer(controllerCamera.pixelRect,false); menuGroup.anchor.Set(GUIAnchor.BottomCenter); GameGUIManager.AddGUIObject(menuGroup); //Setup Transitions and State Machine Transition<TileSelectionMenu> goToOptions = new Transition<TileSelectionMenu>(this, states["Options"]); Transition<TileSelectionMenu> closeMenu = new Transition<TileSelectionMenu>(this, states["Waiting"]); states["Waiting"].AddTransition(goToOptions); states["Options"].AddTransition(closeMenu); goToOptions.InitFromExpression ( "{ TransitionBehavior_OnEvent openMenu( OpenMenu ); } openMenu"); closeMenu.InitFromExpression ( "{ TransitionBehavior_OnEvent closeMenu( CloseMenu ); } closeMenu"); behaviour.ChangeState( states["Waiting"], this ); }
public GUIComponent CreateContainer() { GUIComponent component = new GUIContainer(); this.components.Add(component); return component; }
/// <summary> /// Adds a container. /// </summary> /// <param name="container"></param> public static void AddContainer(GUIContainer container) { int index = GUIWindows.BinarySearch(container, containerSorter); if (index < 0) { index = ~index; } GUIWindows.Insert(index, container); }
public void Draw(GUIContainer container, ref Matrix4 projection) { this.matrix = projection; Vector2 _offset = container.Position; Rect _drawableArea = container.Bounds; this.SetSubRectDrawableArea(ref _drawableArea, ref _drawableArea, out _drawableArea); container.Draw(ref _drawableArea, this); this.batch.Draw(ref this.matrix); }
private void NoMouse() { if (newItem != null) { if (newItem is GUIContainer) { container = (GUIContainer)newItem; } activeControlsList.Items.Add(newItem); newItem = null; } }
public override void Click(MouseEventArgs e, GUIContainer container) { if (InGameGUI.Selected == ActionSelected.Chop) { InGameGUI.Selected = ActionSelected.None; this.TextureID = this.GreyTextureIndex; } else { InGameGUI.Selected = ActionSelected.Chop; this.TextureID = this.GoldTextureIndex; } }
public GUIEventSystem(GUIContainer root, MouseDevice mouse, KeyboardDevice keyboard, INativeWindow window) { this.root = root; mouse.Move += new EventHandler<OpenTK.Input.MouseMoveEventArgs>(mouse_Move); mouse.ButtonDown += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(mouse_ButtonDown); mouse.ButtonUp += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(mouse_ButtonUp); mouse.WheelChanged += new EventHandler<OpenTK.Input.MouseWheelEventArgs>(mouse_WheelChanged); this.keyboard = keyboard; keyboard.KeyDown += new EventHandler<KeyboardKeyEventArgs>(keyboard_KeyDown); keyboard.KeyUp += new EventHandler<KeyboardKeyEventArgs>(keyboard_KeyUp); window.KeyPress += new EventHandler<KeyPressEventArgs>(window_KeyPress); }
/* Add a new tab to the TabContainer */ public void addContainer(GUIContainer container) { //Add a new tab to the TabContainer containers.Add(container); //If there is now only one tab, make this tab the main tab. if (containers.Count == 1) { primary = container; children[0] = primary; } //Make it alllll pretty. //performLayout(); }
private static void ContainerDoubleClick(MouseEventArgs clickData) { foreach (GUIContainer item in GUIWindows) { GUIContainer youngest = GetYoungestChild(item); if (youngest.Visible && youngest.DrawingBounds.Contains(clickData.Position)) { DoubleClick(clickData, youngest.Controls, youngest); return; } } //TODO: Make a special map double click handler InputHistory.MapMouseClick(clickData); }
/// <summary> /// Handles container clicks before handling normal UI elements. /// </summary> /// <param name="clickData"></param> /// <returns></returns> private static void ContainerClick(MouseEventArgs clickData) { foreach (GUIContainer item in GUIWindows) { GUIContainer youngest = GetYoungestChild(item); if (youngest.Visible && youngest.DrawingBounds.Contains(clickData.Position)) { Click(clickData, youngest.Controls, youngest); MasterLog.DebugWriteLine("Clicking in menu: " + youngest.GetType().FullName); return; } } //If the click isn't in a GUI, then it must be in the map... InputHistory.MapMouseClick(clickData); }
void Awake() { s_instance = this; if (_tapBlocker != null) { _tapBlocker.SetActive(false); } if (Helper.IsRightUI()) { _guiContainer = _rightUI; } else { _guiContainer = _bottomUI; } }
private static void NullChild(GUIContainer container) { if (container.Child == null) { BoundHandler.GUIWindows.Remove(container); } else { if (container.Child.Child == null) { container.Child = null; } else { NullChild(container.Child); } } }
private static GUIContainer GetYoungestChild(GUIContainer container) { if (container.Child != null) { if (container.Child.Child != null) { return(GetYoungestChild(container.Child)); } else { return(container.Child); } } else { return(container); } }
public override void Click(MouseEventArgs e, GUIContainer container) { World.Mode = MagicalLifeAPI.Networking.EngineMode.ServerAndClient; Server.Load(); ClientSendRecieve.Initialize(new MagicalLifeAPI.Networking.NetworkSettings()); FMODUtil.RaiseEvent(EffectsTable.UIClick); ServerSendRecieve.Initialize(new MagicalLifeAPI.Networking.NetworkSettings()); Client.Load(); NewGameInputHandler a = new NewGameInputHandler(); a.StartNewGame(); Server.StartGame(); BoundHandler.RemoveContainer(NewWorldMenu.NewWorldMenuM); MenuHandler.Clear(); BoundHandler.HideAll(); InGameGUI.Initialize(); BoundHandler.Popup(InGameGUI.InGame); }
private static Rectangle CalculateCarrotBounds(MonoInputBox textbox, GUIContainer container) { Vector2 size = textbox.Font.MeasureString(textbox.Text); Vector2 pos = new Vector2(textbox.DrawingBounds.Center.X, textbox.DrawingBounds.Center.Y); Vector2 origin = size * 0.5f; #pragma warning disable RCS1096 // Use bitwise operation instead of calling 'HasFlag'. if (textbox.TextAlignment.HasFlag(Alignment.Left)) { origin.X += (textbox.DrawingBounds.Width / 2) - (size.X / 2); } if (textbox.TextAlignment.HasFlag(Alignment.Right)) { origin.X -= (textbox.DrawingBounds.Width / 2) - (size.X / 2); } if (textbox.TextAlignment.HasFlag(Alignment.Top)) { origin.Y += (textbox.DrawingBounds.Height / 2) - (size.Y / 2); } if (textbox.TextAlignment.HasFlag(Alignment.Bottom)) { origin.Y -= (textbox.DrawingBounds.Height / 2) - (size.Y / 2); } string TextBeforeCarrot = textbox.Text.Substring(0, textbox.CarrotPosition); int XPos = (int)Math.Round(origin.X + textbox.DrawingBounds.X + textbox.Font.MeasureString(TextBeforeCarrot).X) + container.DrawingBounds.X; int YPos = (int)Math.Round(origin.Y + textbox.DrawingBounds.Y) + container.DrawingBounds.Y; switch (textbox.TextAlignment) { case Alignment.Left: XPos -= (int)Math.Round(origin.X); YPos += (int)Math.Round(origin.Y); break; default: break; } return(new Rectangle(XPos, YPos, textbox.CarrotWidth, textbox.CarrotHeight)); }
private static void RenderYoungestChild(GUIContainer item, SpriteBatch spBatch) { if (item.Child == null) { spBatch.Draw(item.Image, item.DrawingBounds, Color.White); foreach (GUIElement control in item.Controls) { if (control.Visible) { control.Render(spBatch, item.DrawingBounds); } } } else { RenderYoungestChild(item.Child, spBatch); } }
public TabOrientation orientation; //This keeps track of where the tabs are. /*Returns an empty tab container with no tabs or buttons. * TODO: Allow instantiation of orientations other than BOTTOM */ public TabContainer(GUIComponent theInterface, TabOrientation orientation) : base(theInterface) { //Durrrrrrrrrrrrr this.bgImage = theInterface.guiTextures[22]; stretch = true; this.orientation = orientation; this.theInterface = theInterface; //Make the tabs line up properly with the orientation if (orientation == TabOrientation.BOTTOM) { tabs = new ListContainer(guiComponent, ListContainer.Orientation.HORIZONTAL); } //Initialize layout containers = new List <GUIContainer>(); children.Add(null); children.Add(tabs); primary = new ListContainer(theInterface); //Just an empty ListContainer to take up space until you make your own }
/// <summary> /// Sets that container as the visible container, and gives it priority. /// </summary> /// <param name="container"></param> public static void Popup(GUIContainer container) { if (GUIWindows.Contains(container)) { MenuHandler.Clear(); container.Visible = true; container.Priority = RenderingData.GetGUIContainerPriority(); GUIWindows.Remove(container); GUIWindows.Add(container); } else { MenuHandler.Clear(); container.Visible = true; container.Priority = RenderingData.GetGUIContainerPriority(); GUIWindows.Add(container); } }
/* Add a button to the TabContainer. Automatically sets up clickEvent for the new TabButton. */ public void addButton(String text) { TabButton tb = new TabButton(guiComponent, text); //Update a couple variables and put the button in its place tabs.children.Add(tb); tb.index = tabCount; tabCount++; //tb.parent = this; //Made the TabButton conform to the TabContainer's orientation. That's what she said. tb.transform(orientation); //Add a clickEvent that makes the tab switch properly on click. tb.clickEvent += (pos) => { current = tb.index; primary = containers[tb.index]; children[0] = primary; performLayout(); }; }
public override void Click(MouseEventArgs e, GUIContainer container) { int selected = LoadGameMenu.Menu.SaveSelectListBox.SelectedIndex; if (selected != -1) { FMODUtil.RaiseEvent(SoundsTable.UIClick); World.Mode = MagicalLifeAPI.Networking.EngineMode.ServerAndClient; RenderableString selectedItem = (RenderableString)LoadGameMenu.Menu.SaveSelectListBox.Items[selected]; WorldStorage.LoadWorld(selectedItem.Text); Server.Load(); ClientSendRecieve.Initialize(new MagicalLifeAPI.Networking.NetworkSettings(MagicalLifeAPI.Networking.EngineMode.ServerAndClient)); ServerSendRecieve.Initialize(new MagicalLifeAPI.Networking.NetworkSettings(MagicalLifeAPI.Networking.EngineMode.ServerAndClient)); Client.Load(); Server.StartGame(); BoundHandler.RemoveContainer(LoadGameMenu.Menu); MenuHandler.Clear(); BoundHandler.HideAll(); InGameGUI.Initialize(); BoundHandler.Popup(InGameGUI.InGame); } }
ElementMenuTreeNode newNode; // used when building up new menus // Called only for GUIContainer type classes public static ElementMenuTreeNode BuildMenu(ScreenMenuTreeNode screenParent, GUIContainer info) { ElementMenuTreeNode returnNode = new ElementMenuTreeNode(); returnNode.info = info; returnNode.children = new List<ElementMenuTreeNode>(); GUIContainer container = returnNode.info as GUIContainer; foreach (GUIObject obj in container.Elements) { // Containers nest, so deal with it slightly different. if (obj.GetType() == typeof(GUIContainer) || obj.GetType().BaseType == typeof(GUIContainer)) { ElementMenuTreeNode newNode = ElementMenuTreeNode.BuildMenu(screenParent, obj as GUIContainer); if (newNode != null) { newNode.screenParent = screenParent; newNode.containerParent = returnNode; returnNode.children.Add(newNode); } } else { ElementMenuTreeNode newNode = new ElementMenuTreeNode(); newNode.screenParent = screenParent; newNode.containerParent = returnNode; returnNode.children.Add(newNode); } } return returnNode; }
public override void Click(MouseEventArgs e, GUIContainer container) { FMODUtil.RaiseEvent(EffectsTable.UIClick); NewWorldMenu.Initialize(); MainMenu.MainMenuID.PopupChild(NewWorldMenu.NewWorldMenuM); }
/// <summary> /// Handles who gets the double click event. /// </summary> /// <param name="clickData"></param> private static void DoubleClick(MouseEventArgs clickData, List <GUIElement> Options, GUIContainer container) { int focus = -1; int length = Options.Count; GUIElement item = null; for (int i = 0; i < length; i++) { item = Options[i]; if (focus == -1 && item.MouseBounds.Bounds.Contains(clickData.Position.X, clickData.Position.Y)) { item.HasFocus = true; focus = i; } else { item.HasFocus = false; } } if (focus != -1) { Options[focus].DoubleClick(clickData, container); } }
/// <param name="guiContainer">The container which was clicked in.</param> public ClickEventArgs(MouseEventArgs mouseEventArgs, GUIContainer guiContainer) { this.MouseEventArgs = mouseEventArgs; this.GUIContainer = guiContainer; }
/// <summary> /// Handles who gets the single click event from the options provided. /// For use if a container is being used. /// </summary> /// <param name="clickData"></param> private static void Click(MouseEventArgs clickData, List <GUIElement> Options, GUIContainer container) { int focus = -1; int length = Options.Count; GUIElement item = null; for (int i = 0; i < length; i++) { item = Options[i]; if (focus == -1 && item.MouseBounds.Bounds.Contains(clickData.Position.X + container.DrawingBounds.X, clickData.Position.Y - container.DrawingBounds.Y)) { item.HasFocus = true; focus = i; } else { item.HasFocus = false; } } if (focus != -1) { MasterLog.DebugWriteLine("Clicking on item: " + Options[focus].GetType().FullName); Options[focus].Click(clickData, container); } }
public GUIElementSettings(GUIContainer zone, GUIObject obj) { offset = obj.position.Get() - zone.position.Get(); //offset = obj.position.Get();// - zone.bottomLeft; Debug.Log(string.Format("`{0}' Offset: {1}",obj.ToString(),offset)); }
public override void Click(MouseEventArgs e, GUIContainer container) { FMODUtil.RaiseEvent(EffectsTable.UIClick); JoinGameMenu.Initialize(); MainMenu.MainMenuID.PopupChild(JoinGameMenu.menu); }
public override void DoubleClick(MouseEventArgs e, GUIContainer container) { }
//public delegate void FunctionHandler(); //Dictionary<string, FunctionHandler> commands = new Dictionary<string, FunctionHandler>(); void Awake() { //commands.Add("GUISaveAndExit", GUISaveAndExit); pc = GetComponent<PlayerController>(); pi = GetComponent<PlayerInfo>(); vi = GameObject.Find("Vault").GetComponent<VaultInfo>(); foreach (GameObject obj in GameObject.FindGameObjectsWithTag("MyGUI")) { GUIContainer container = obj.GetComponent<GUIContainer>(); if (container) container.playerGUI = this; } // Setup GUI Var Transform _t = GameObject.Find("PlayerGUIContainer").transform; for (int i = 0; i < _t.childCount; i++) { Transform stk = _t.GetChild(i); if (stk.name == "Stack") inventory.Add(stk.GetComponent<GUIBlock>()); } inventoryMenu = _t.FindChild("InventoryMenu").GetComponent<GUIContainer>(); pauseMenu = _t.FindChild("PauseMenu").GetComponent<GUIContainer>(); charBlock = _t.FindChild("Character").GetComponent<GUIBlock>(); exit = _t.FindChild("SaveAndExit").GetComponent<GUIBlock>(); age = _t.FindChild("Age").GetComponent<TextMesh>(); roomHealth = _t.FindChild("RoomHealth").GetComponent<TextMesh>(); hunger = _t.FindChild("Hunger").GetComponent<TextMesh>(); health = _t.FindChild("Health").GetComponent<TextMesh>(); radiation = _t.FindChild("Radiation").GetComponent<TextMesh>(); suitBar = _t.FindChild("Suit"); suitBarStartWidth = suitBar.localScale; // End Setup }
public override void Click(MouseEventArgs e, GUIContainer container) { FMODUtil.RaiseEvent(SoundsTable.UIClick); LoadGameMenu.Initialize(); MainMenu.MainMenuID.PopupChild(LoadGameMenu.Menu); }
public override void DoubleClick(MouseEventArgs e, GUIContainer container) { this.Overwrite(); }
public override void Click(MouseEventArgs e, GUIContainer container) { FMODUtil.RaiseEvent(EffectsTable.UIClick); UniversalEvents.GameExitHandler(); }
public override void Click(MouseEventArgs e, GUIContainer container) { this.Save(); }
public override void DoubleClick(MouseEventArgs e, GUIContainer container) { //Nothing to see here }
/// <summary> /// Removes a container. /// </summary> /// <param name="container"></param> public static void RemoveContainer(GUIContainer container) { GUIWindows.Remove(container); }
public override void DoubleClick(MouseEventArgs e, GUIContainer container) { //Single click is good enough }
public override void DoubleClick(MouseEventArgs e, GUIContainer container) { this.NewSave(); }