public bool TypingChatMessage(GUITextBox textBox, string text) { string tempStr; string command = ChatMessage.GetChatMessageCommand(text, out tempStr); switch (command) { case "r": case "radio": textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Radio]; break; case "d": case "dead": textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Dead]; break; default: if (command != "") //PMing { textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Private]; } else { textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Default]; } break; } return(true); }
public NetworkMember() { inGameHUD = new GUIFrame(new Rectangle(0, 0, 0, 0), null, null); inGameHUD.CanBeFocused = false; int width = (int)MathHelper.Clamp(GameMain.GraphicsWidth * 0.35f, 350, 500); int height = (int)MathHelper.Clamp(GameMain.GraphicsHeight * 0.15f, 100, 200); chatBox = new GUIListBox(new Rectangle( GameMain.GraphicsWidth - 20 - width, GameMain.GraphicsHeight - 40 - 25 - height, width, height), Color.White * 0.5f, "", inGameHUD); chatBox.Padding = Vector4.Zero; chatMsgBox = new GUITextBox( new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25), Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, "", inGameHUD); chatMsgBox.Font = GUI.SmallFont; chatMsgBox.MaxTextLength = ChatMessage.MaxLength; chatMsgBox.Padding = Vector4.Zero; chatMsgBox.OnEnterPressed = EnterChatMessage; chatMsgBox.OnTextChanged = TypingChatMessage; Voting = new Voting(); }
public bool EnterChatMessage(GUITextBox textBox, string message) { textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Default]; if (string.IsNullOrWhiteSpace(message)) { if (textBox == chatBox.InputBox) { textBox.Deselect(); } return(false); } if (this == GameMain.Server) { GameMain.Server.SendChatMessage(message, null, null); } else if (this == GameMain.Client) { GameMain.Client.SendChatMessage(message); } textBox.Deselect(); textBox.Text = ""; return(true); }
public void CreateKickReasonPrompt(string clientName, bool ban, bool rangeBan = false) { var banReasonPrompt = new GUIMessageBox(ban ? "Reason for the ban?" : "Reason for kicking?", "", new string[] { "OK", "Cancel" }, 400, 300); var banReasonBox = new GUITextBox(new Rectangle(0, 30, 0, 50), Alignment.TopCenter, "", banReasonPrompt.children[0]); banReasonBox.Wrap = true; banReasonBox.MaxTextLength = 100; GUINumberInput durationInputDays = null, durationInputHours = null; GUITickBox permaBanTickBox = null; if (ban) { new GUITextBlock(new Rectangle(0, 80, 0, 0), "Duration:", "", banReasonPrompt.children[0]); permaBanTickBox = new GUITickBox(new Rectangle(0, 110, 15, 15), "Permanent", Alignment.TopLeft, banReasonPrompt.children[0]); permaBanTickBox.Selected = true; var durationContainer = new GUIFrame(new Rectangle(0, 130, 0, 40), null, banReasonPrompt.children[0]); durationContainer.Visible = false; permaBanTickBox.OnSelected += (tickBox) => { durationContainer.Visible = !tickBox.Selected; return(true); }; new GUITextBlock(new Rectangle(0, 0, 30, 20), "Days:", "", Alignment.TopLeft, Alignment.CenterLeft, durationContainer); durationInputDays = new GUINumberInput(new Rectangle(40, 0, 50, 20), "", GUINumberInput.NumberType.Int, durationContainer); durationInputDays.MinValueInt = 0; durationInputDays.MaxValueFloat = 1000; new GUITextBlock(new Rectangle(100, 0, 30, 20), "Hours:", "", Alignment.TopLeft, Alignment.CenterLeft, durationContainer); durationInputHours = new GUINumberInput(new Rectangle(150, 0, 50, 20), "", GUINumberInput.NumberType.Int, durationContainer); durationInputDays.MinValueInt = 0; durationInputDays.MaxValueFloat = 24; } banReasonPrompt.Buttons[0].OnClicked += (btn, userData) => { if (ban) { if (!permaBanTickBox.Selected) { TimeSpan banDuration = new TimeSpan(durationInputDays.IntValue, durationInputHours.IntValue, 0, 0); BanPlayer(clientName, banReasonBox.Text, ban, banDuration); } else { BanPlayer(clientName, banReasonBox.Text, ban); } } else { KickPlayer(clientName, banReasonBox.Text); } return(true); }; banReasonPrompt.Buttons[0].OnClicked += banReasonPrompt.Close; banReasonPrompt.Buttons[1].OnClicked += banReasonPrompt.Close; }
/// <summary> /// Stops a rename operation over the entry, hiding the rename input box. /// </summary> public void StopRename() { if (renameTextBox != null) { renameTextBox.Destroy(); renameTextBox = null; } }
/// <summary> /// Destroys all inspector GUI elements. /// </summary> internal void Clear() { for (int i = 0; i < inspectorComponents.Count; i++) { inspectorComponents[i].foldout.Destroy(); inspectorComponents[i].removeBtn.Destroy(); inspectorComponents[i].inspector.Destroy(); } inspectorComponents.Clear(); if (inspectorResource != null) { inspectorResource.inspector.Destroy(); inspectorResource = null; } if (inspectorScrollArea != null) { inspectorScrollArea.Destroy(); inspectorScrollArea = null; } if (scrollAreaHighlight != null) { scrollAreaHighlight.Destroy(); scrollAreaHighlight = null; } if (highlightPanel != null) { highlightPanel.Destroy(); highlightPanel = null; } activeSO = null; soNameInput = null; soActiveToggle = null; soMobility = null; soPrefabLayout = null; soHasPrefab = false; soPosX = null; soPosY = null; soPosZ = null; soRotX = null; soRotY = null; soRotZ = null; soScaleX = null; soScaleY = null; soScaleZ = null; dropAreas = new Rect2I[0]; activeResourcePath = null; currentType = InspectorType.None; }
public override void OnLoad() { tb_ComparisonsDes = new GUITextBox("Comparisons:", new Vector2(850, 50), new Vector2(125, 20), "tbComparisonsDes"); tb_Comparisons = new GUITextBox("0", new Vector2(850, 70), new Vector2(80, 20), "tbComparisons", true); tb_ParticleCountDes = new GUITextBox("Particle Count", new Vector2(850, 90), new Vector2(120, 45), "tbParticleCountDes"); tb_ParticleCount = new GUITextBox("0", new Vector2(850, 135), new Vector2(120, 20), "tbParticleCount", true); tb_KinematicsDes = new GUITextBox("Kinematic energy:", new Vector2(850, 200), new Vector2(120, 45), "tbKinematicsDes"); tb_Kinematics = new GUITextBox("0", new Vector2(850, 245), new Vector2(80, 20), "tbKinematics", true); Border1 = new Border(new Vector2(50, 50), new Vector2(800, 500), "Border"); }
public void UpdateHUD(float deltaTime) { GUITextBox msgBox = (Screen.Selected == GameMain.GameScreen ? chatBox.InputBox : GameMain.NetLobbyScreen.TextBox); if (gameStarted && Screen.Selected == GameMain.GameScreen) { if (!GUI.DisableHUD) { inGameHUD.UpdateManually(deltaTime); chatBox.Update(deltaTime); if (Character.Controlled == null) { myCharacterFrameOpenState = GameMain.NetLobbyScreen.MyCharacterFrameOpen ? myCharacterFrameOpenState + deltaTime * 5 : myCharacterFrameOpenState - deltaTime * 5; myCharacterFrameOpenState = MathHelper.Clamp(myCharacterFrameOpenState, 0.0f, 1.0f); var myCharFrame = GameMain.NetLobbyScreen.MyCharacterFrame; int padding = GameMain.GraphicsWidth - myCharFrame.Parent.Rect.Right; myCharFrame.RectTransform.AbsoluteOffset = Vector2.SmoothStep(new Vector2(-myCharFrame.Rect.Width - padding, 0.0f), new Vector2(-padding, 0), myCharacterFrameOpenState).ToPoint(); } } if (Character.Controlled == null || Character.Controlled.IsDead) { GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; GameMain.LightManager.LosEnabled = false; } } //tab doesn't autoselect the chatbox when debug console is open, //because tab is used for autocompleting console commands if ((PlayerInput.KeyHit(InputType.Chat) || PlayerInput.KeyHit(InputType.RadioChat)) && !DebugConsole.IsOpen && (Screen.Selected != GameMain.GameScreen || msgBox.Visible)) { if (msgBox.Selected) { msgBox.Text = ""; msgBox.Deselect(); } else { msgBox.Select(); if (Screen.Selected == GameMain.GameScreen && PlayerInput.KeyHit(InputType.RadioChat)) { msgBox.Text = "r; "; } } } if (ServerLog.LogFrame != null) ServerLog.LogFrame.AddToGUIUpdateList(); }
partial void InitProjSpecific(XElement element) { var layoutGroup = new GUILayoutGroup(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center) { AbsoluteOffset = GUIStyle.ItemFrameOffset }) { ChildAnchor = Anchor.TopCenter, RelativeSpacing = 0.02f, Stretch = true }; historyBox = new GUIListBox(new RectTransform(new Vector2(1, .9f), layoutGroup.RectTransform), style: null) { AutoHideScrollBar = false }; // Create fillerBlock to cover historyBox so new values appear at the bottom of historyBox // This could be removed if GUIListBox supported aligning its children fillerBlock = new GUITextBlock(new RectTransform(new Vector2(1, 1), historyBox.Content.RectTransform, anchor: Anchor.TopCenter), string.Empty) { CanBeFocused = false }; new GUIFrame(new RectTransform(new Vector2(0.9f, 0.01f), layoutGroup.RectTransform), style: "HorizontalLine"); inputBox = new GUITextBox(new RectTransform(new Vector2(1, .1f), layoutGroup.RectTransform), textColor: Color.LimeGreen) { MaxTextLength = MaxMessageLength, OverflowClip = true, OnEnterPressed = (GUITextBox textBox, string text) => { if (GameMain.NetworkMember == null) { SendOutput(text); } else { item.CreateClientEvent(this, new object[] { text }); } textBox.Text = string.Empty; return(true); } }; }
public void initializeInfoBox() { Engine.GUI tempGUI = engine.graphicsComponent.gui; playerInfoLabel = new GUILabel(tempGUI, new Handle(engine.resourceComponent, "GUI\\PlayerInfoBg.png")); playerInfoOutlineLabel = new GUILabel(tempGUI, new Handle(engine.resourceComponent, "GUI\\PlayerInfoOutline.png")); healthInfoBox = new GUITextBox(tempGUI, ""); attackInfoBox = new GUITextBox(tempGUI, ""); levelInfoBox = new GUITextBox(tempGUI, ""); tempGUI.add(playerInfoOutlineLabel); tempGUI.add(playerInfoLabel); tempGUI.add(healthInfoBox); tempGUI.add(attackInfoBox); tempGUI.add(levelInfoBox); teamBox = new GUILabel(tempGUI); tempGUI.add(teamBox); }
public virtual void Update(float deltaTime) { #if CLIENT GUITextBox msgBox = (Screen.Selected == GameMain.GameScreen ? chatMsgBox : GameMain.NetLobbyScreen.TextBox); if (gameStarted && Screen.Selected == GameMain.GameScreen) { msgBox.Visible = Character.Controlled == null || Character.Controlled.CanSpeak; if (!GUI.DisableHUD) { inGameHUD.Update(deltaTime); GameMain.GameSession.CrewManager.Update(deltaTime); } if (Character.Controlled == null || Character.Controlled.IsDead) { GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; GameMain.LightManager.LosEnabled = false; } } //tab doesn't autoselect the chatbox when debug console is open, //because tab is used for autocompleting console commands if ((PlayerInput.KeyHit(InputType.Chat) || PlayerInput.KeyHit(InputType.RadioChat)) && !DebugConsole.IsOpen && (Screen.Selected != GameMain.GameScreen || msgBox.Visible)) { if (msgBox.Selected) { msgBox.Text = ""; msgBox.Deselect(); } else { msgBox.Select(); if (Screen.Selected == GameMain.GameScreen && PlayerInput.KeyHit(InputType.RadioChat)) { msgBox.Text = "r; "; msgBox.OnTextChanged?.Invoke(msgBox, msgBox.Text); } } } #endif }
private void InitProjSpecific() { inGameHUD = new GUIFrame(new Rectangle(0, 0, 0, 0), null, null); inGameHUD.CanBeFocused = false; showLogButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170, 20, 150, 20), "Server Log", Alignment.TopLeft, "", inGameHUD) { OnClicked = (GUIButton button, object userData) => { if (ServerLog.LogFrame == null) { ServerLog.CreateLogFrame(); } else { ServerLog.LogFrame = null; GUIComponent.KeyboardDispatcher.Subscriber = null; } return(true); } }; int width = (int)MathHelper.Clamp(GameMain.GraphicsWidth * 0.35f, 350, 500); int height = (int)MathHelper.Clamp(GameMain.GraphicsHeight * 0.15f, 100, 200); chatBox = new GUIListBox(new Rectangle( GameMain.GraphicsWidth - 20 - width, GameMain.GraphicsHeight - 40 - 25 - height, width, height), Color.White * 0.5f, "", inGameHUD); chatBox.Padding = Vector4.Zero; chatMsgBox = new GUITextBox( new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25), Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, "", inGameHUD); chatMsgBox.Font = GUI.SmallFont; chatMsgBox.MaxTextLength = ChatMessage.MaxLength; chatMsgBox.Padding = Vector4.Zero; chatMsgBox.OnEnterPressed = EnterChatMessage; chatMsgBox.OnTextChanged = TypingChatMessage; }
public DialogoAyuda() : base(new Size(330, 380)) { Title = "Controles"; BackColor = Color.FromArgb(240, Color.DarkGreen); TitleColor = Color.FromArgb(240, Color.Green); guiTextBox = new GUITextBox(new Size(InnerBounds.Size.Width - 10, InnerBounds.Size.Height - 40)); AddChildWindow(guiTextBox, new Point(InnerBounds.Location.X + 5, InnerBounds.Location.Y + 5)); AgregarTextoAyuda("F1 - Controles"); AgregarTextoAyuda(""); AgregarTextoAyuda("FLECHA ARRIBA - Avanzar"); AgregarTextoAyuda("FLECHA ABAJO - Retroceder"); AgregarTextoAyuda("FLECHA DERECHA - Girar a la Derecha"); AgregarTextoAyuda("FLECHA IZQUIERDA - Girar a la Izquierda"); AgregarTextoAyuda("BARRA ESPACIADORA - Disparar"); AgregarTextoAyuda(""); AgregarTextoAyuda("+/- del Teclado Numerico - Zoom In / Out"); AgregarTextoAyuda("D - No Dibujar / Dibujar separacion de Sectores"); AgregarTextoAyuda("N - No dibujar / Dibujar la capa de las nebulosas"); AgregarTextoAyuda("M - Ocultar / Mostrar el mini mapa"); AgregarTextoAyuda(""); AgregarTextoAyuda("Tambien se puede controlar con el joystick, usandolo en modo digital y con los botones 1 y 2."); AgregarTextoAyuda("El joystick debe estar conectado antes de iniciar el juego."); AgregarTextoAyuda(""); AgregarTextoAyuda("ESCAPE - Salir o Cerrar dialogos"); GUIButton btnAceptar = new GUIButton(new Size(60, 24)); btnAceptar.Text = "Aceptar"; btnAceptar.ButtonPressed += new GUIButton.ButtonPressedHandler(btnAceptar_ButtonPressed); AddChildWindow(btnAceptar, new Point(InnerBounds.Location.X + (InnerBounds.Width - btnAceptar.Size.Width) / 2, InnerBounds.Location.Y + (InnerBounds.Height - btnAceptar.Size.Height - 5))); FocusNextChild(); }
public bool TypingChatMessage(GUITextBox textBox, string text) { // Do we need this kind of check here? // Had to remove this from the chatbox.TextBox.OnTextChanged delegate property, because the delegate was refactored as event and it cannot be accessed like that anymore. //if (chatBox.IsSinglePlayer) //{ // DebugConsole.ThrowError("Cannot access chat input box in single player!\n" + Environment.StackTrace); // return false; //} string command = ChatMessage.GetChatMessageCommand(text, out _); switch (command) { case "r": case "radio": textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Radio]; break; case "d": case "dead": textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Dead]; break; default: if (Character.Controlled != null && (Character.Controlled.IsDead || Character.Controlled.SpeechImpediment >= 100.0f)) { textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Dead]; } else if (command != "") //PMing { textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Private]; } else { textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Default]; } break; } return true; }
public DialogoIntroduccion() : base(new Size(600, 470)) { Title = "Introducción"; BackColor = Color.FromArgb(240, Color.DarkGreen); TitleColor = Color.FromArgb(240, Color.Green); guiTextBox = new GUITextBox(new Size(InnerBounds.Size.Width - 10, InnerBounds.Size.Height - 10)); AddChildWindow(guiTextBox, new Point(InnerBounds.Location.X + 5, InnerBounds.Location.Y + 5)); AgregarTextoAyuda("Esto es lo que se podria considerar una versión inicial de lo que espero se convierta en un juego al estilo NetHack y toda la familia de juegos con niveles generados al azar, y un arcade de naves."); AgregarTextoAyuda("Por el momento, si bien todo se genera al azar, no se salva en ningun momento, debido a lo cual es dificil continuar jugando :-), eso sin tener en cuenta que no hay \"puntos\", ni nada mas interesante que hacer que matar naves a lo loco hasta ser destruido."); AgregarTextoAyuda("Lo que se ve abajo a la derecha es un mapa de los sectores que rodean a la nave del jugador, en el espacio se pueden encontrar con:"); AgregarTextoAyuda(""); AgregarTextoAyuda("Soles (estrellas): Tienen leve atracción gravitatoria, si chocan con ellos son historia, pero los pueden destruir si disparan contra ellos, aunque aconsejo hacerlo de lejos :-)"); AgregarTextoAyuda(""); AgregarTextoAyuda("Agujeros Negros: Fuerte atracción gravitatoria, si te absorven te destruyen o te llevan a otro sector al azar"); AgregarTextoAyuda(""); AgregarTextoAyuda("Agujeros de Gusano: Comunican 2 sectors, tienen entrada y salida estable"); AgregarTextoAyuda(""); AgregarTextoAyuda("Planeta y Estaciones: Por el momento no hacen nada salvo estar por ahi :-)"); AgregarTextoAyuda(""); AgregarTextoAyuda("Otras Naves (NPC): Hay de 3 tipos, los que andan por ahi recolectando recursos de las nebulosas, los que patrullan al azar, y los que si te ven te empiezan a disparar a lo loco.. cuidado con estos."); AgregarTextoAyuda(""); AgregarTextoAyuda(""); AgregarTextoAyuda("Tienen que presionar ESCAPE para cerrar este dialogo, y con F1 pueden ver una ayuda de las teclas que controlan el juego, espero que les guste y se aceptan criticas de todo tipo :-), mandenlas a [email protected]"); GUIButton btnAceptar = new GUIButton(new Size(60, 24)); btnAceptar.Text = "Aceptar"; btnAceptar.ButtonPressed += new GUIButton.ButtonPressedHandler(btnAceptar_ButtonPressed); AddChildWindow(btnAceptar, new Point(InnerBounds.Location.X + (InnerBounds.Width - btnAceptar.Size.Width) / 2, InnerBounds.Location.Y + (InnerBounds.Height - btnAceptar.Size.Height - 5))); FocusNextChild(); }
/// <summary> /// Starts a rename operation over the entry, displaying the rename input box. /// </summary> public void StartRename() { if (renameTextBox != null) { return; } renameTextBox = new GUITextBox(true); Rect2I renameBounds = label.Bounds; // Rename box allows for less space for text than label, so adjust it slightly so it's more likely to be able // to display all visible text. renameBounds.x -= 4; renameBounds.width += 8; renameBounds.height += 8; renameTextBox.Bounds = renameBounds; owner.RenameOverlay.AddElement(renameTextBox); string name = Path.GetFileNameWithoutExtension(PathEx.GetTail(path)); renameTextBox.Text = name; renameTextBox.Focus = true; }
public GUIComponent CreateWhiteListFrame(GUIComponent parent) { if (whitelistFrame != null) { whitelistFrame.Parent.ClearChildren(); whitelistFrame = null; } whitelistFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), parent.RectTransform, Anchor.Center)) { Stretch = true, RelativeSpacing = 0.02f }; var enabledTick = new GUITickBox(new RectTransform(new Vector2(0.1f, 0.1f), whitelistFrame.RectTransform), TextManager.Get("WhiteListEnabled")) { Selected = localEnabled, UpdateOrder = 1, OnSelected = (GUITickBox box) => { nameBox.Enabled = box.Selected; ipBox.Enabled = box.Selected; addNewButton.Enabled = box.Selected; localEnabled = box.Selected; return(true); } }; localEnabled = Enabled; var listBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.7f), whitelistFrame.RectTransform)); foreach (WhiteListedPlayer wlp in whitelistedPlayers) { if (localRemoved.Contains(wlp.UniqueIdentifier)) { continue; } string blockText = wlp.Name; if (!string.IsNullOrWhiteSpace(wlp.IP)) { blockText += " (" + wlp.IP + ")"; } GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), listBox.Content.RectTransform), blockText) { UserData = wlp }; var removeButton = new GUIButton(new RectTransform(new Vector2(0.3f, 0.8f), textBlock.RectTransform, Anchor.CenterRight), TextManager.Get("WhiteListRemove"), style: "GUIButtonSmall") { UserData = wlp, OnClicked = RemoveFromWhiteList }; } foreach (LocalAdded lad in localAdded) { string blockText = lad.Name; if (!string.IsNullOrWhiteSpace(lad.IP)) { blockText += " (" + lad.IP + ")"; } GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), listBox.Content.RectTransform), blockText) { UserData = lad }; var removeButton = new GUIButton(new RectTransform(new Vector2(0.3f, 0.8f), textBlock.RectTransform, Anchor.CenterRight), TextManager.Get("WhiteListRemove"), style: "GUIButtonSmall") { UserData = lad, OnClicked = RemoveFromWhiteList }; } foreach (GUIComponent c in listBox.Content.Children) { c.RectTransform.MinSize = new Point(0, Math.Max((int)(20 * GUI.Scale), c.RectTransform.Children.Max(c2 => c2.MinSize.Y))); } var nameArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), whitelistFrame.RectTransform), isHorizontal: true) { Stretch = true, RelativeSpacing = 0.05f }; new GUITextBlock(new RectTransform(new Vector2(0.3f, 1.0f), nameArea.RectTransform), TextManager.Get("WhiteListName")); nameBox = new GUITextBox(new RectTransform(new Vector2(0.7f, 1.0f), nameArea.RectTransform), ""); nameBox.OnTextChanged += (textBox, text) => { addNewButton.Enabled = !string.IsNullOrEmpty(ipBox.Text) && !string.IsNullOrEmpty(nameBox.Text); return(true); }; nameArea.RectTransform.MinSize = new Point(0, nameBox.RectTransform.MinSize.Y); var ipArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), whitelistFrame.RectTransform), isHorizontal: true) { Stretch = true, RelativeSpacing = 0.05f }; new GUITextBlock(new RectTransform(new Vector2(0.3f, 1.0f), ipArea.RectTransform), TextManager.Get("WhiteListIP")); ipBox = new GUITextBox(new RectTransform(new Vector2(0.7f, 1.0f), ipArea.RectTransform), ""); ipBox.OnTextChanged += (textBox, text) => { addNewButton.Enabled = !string.IsNullOrEmpty(ipBox.Text) && !string.IsNullOrEmpty(nameBox.Text); return(true); }; ipBox.RectTransform.MinSize = new Point(0, ipBox.RectTransform.MinSize.Y); addNewButton = new GUIButton(new RectTransform(new Vector2(0.5f, 0.1f), whitelistFrame.RectTransform), TextManager.Get("WhiteListAdd"), style: "GUIButtonSmall") { OnClicked = AddToWhiteList }; GUITextBlock.AutoScaleAndNormalize(addNewButton.TextBlock); nameBox.Enabled = localEnabled; ipBox.Enabled = localEnabled; addNewButton.Enabled = false; return(parent); }
protected override void CreateGUI() { var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter); // === LABEL === // new GUITextBlock(new RectTransform(new Vector2(1f, 0.05f), paddedFrame.RectTransform), item.Name, font: GUI.SubHeadingFont) { TextAlignment = Alignment.Center, AutoScaleVertical = true }; var mainFrame = new GUILayoutGroup(new RectTransform(new Vector2(1f, 1f), paddedFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter) { RelativeSpacing = 0.02f }; // === TOP AREA === var topFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.65f), mainFrame.RectTransform), style: "InnerFrameDark"); // === ITEM LIST === var itemListFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), topFrame.RectTransform), childAnchor: Anchor.Center); var paddedItemFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), itemListFrame.RectTransform)) { Stretch = true, RelativeSpacing = 0.03f }; var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), paddedItemFrame.RectTransform), isHorizontal: true) { Stretch = true, RelativeSpacing = 0.03f, UserData = "filterarea" }; new GUITextBlock(new RectTransform(new Vector2(0.2f, 1f), filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.SubHeadingFont) { Padding = Vector4.Zero, AutoScaleVertical = true }; itemFilterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), createClearButton: true); itemFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return(true); }; filterArea.RectTransform.MaxSize = new Point(int.MaxValue, itemFilterBox.Rect.Height); itemList = new GUIListBox(new RectTransform(new Vector2(1f, 0.9f), paddedItemFrame.RectTransform), style: null) { OnSelected = (component, userdata) => { selectedItem = userdata as FabricationRecipe; if (selectedItem != null) { SelectItem(Character.Controlled, selectedItem); } return(true); } }; // === SEPARATOR === // new GUIFrame(new RectTransform(new Vector2(0.01f, 0.9f), topFrame.RectTransform, Anchor.Center), style: "VerticalLine"); // === OUTPUT AREA === // var outputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1f), topFrame.RectTransform, Anchor.TopRight), childAnchor: Anchor.Center); var paddedOutputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), outputArea.RectTransform)); var outputTopArea = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.5F), paddedOutputArea.RectTransform, Anchor.Center), isHorizontal: true); // === OUTPUT SLOT === // outputSlot = new GUIFrame(new RectTransform(new Vector2(0.4f, 1f), outputTopArea.RectTransform), style: null); outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1f, 1.2f), outputSlot.RectTransform, Anchor.BottomCenter), style: null); new GUICustomComponent(new RectTransform(Vector2.One, outputInventoryHolder.RectTransform), DrawOutputOverLay) { CanBeFocused = false }; // === DESCRIPTION === // selectedItemFrame = new GUIFrame(new RectTransform(new Vector2(0.6f, 1f), outputTopArea.RectTransform), style: null); // === REQUIREMENTS === // selectedItemReqsFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.5f), paddedOutputArea.RectTransform), style: null); // === BOTTOM AREA === // var bottomFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.3f), mainFrame.RectTransform), style: null); // === SEPARATOR === // var separatorArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.15f), bottomFrame.RectTransform, Anchor.TopCenter), childAnchor: Anchor.CenterLeft, isHorizontal: true) { Stretch = true, RelativeSpacing = 0.03f }; var inputLabel = new GUITextBlock(new RectTransform(Vector2.One, separatorArea.RectTransform), TextManager.Get("uilabel.input"), font: GUI.SubHeadingFont) { Padding = Vector4.Zero }; inputLabel.RectTransform.Resize(new Point((int)inputLabel.Font.MeasureString(inputLabel.Text).X, inputLabel.RectTransform.Rect.Height)); new GUIFrame(new RectTransform(Vector2.One, separatorArea.RectTransform), style: "HorizontalLine"); // === INPUT AREA === // var inputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 1f), bottomFrame.RectTransform, Anchor.BottomCenter), isHorizontal: true, childAnchor: Anchor.BottomLeft); // === INPUT SLOTS === // inputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.7f, 1f), inputArea.RectTransform), style: null); new GUICustomComponent(new RectTransform(Vector2.One, inputInventoryHolder.RectTransform), DrawInputOverLay) { CanBeFocused = false }; // === ACTIVATE BUTTON === // var buttonFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.3f, 0.8f), inputArea.RectTransform), childAnchor: Anchor.CenterRight); activateButton = new GUIButton(new RectTransform(new Vector2(1f, 0.6f), buttonFrame.RectTransform), TextManager.Get("FabricatorCreate"), style: "DeviceButton") { OnClicked = StartButtonClicked, UserData = selectedItem, Enabled = false }; // === POWER WARNING === // inSufficientPowerWarning = new GUITextBlock(new RectTransform(Vector2.One, activateButton.RectTransform), TextManager.Get("FabricatorNoPower"), textColor: GUI.Style.Orange, textAlignment: Alignment.Center, color: Color.Black, style: "OuterGlow", wrap: true) { HoverColor = Color.Black, IgnoreLayoutGroups = true, Visible = false, CanBeFocused = false }; CreateRecipes(); }
public void AssignLogFrame(GUIButton inReverseButton, GUIListBox inListBox, GUIComponent tickBoxContainer, GUITextBox searchBox) { searchBox.OnTextChanged += (textBox, text) => { msgFilter = text; FilterMessages(); return(true); }; tickBoxContainer.ClearChildren(); List <GUITickBox> tickBoxes = new List <GUITickBox>(); foreach (MessageType msgType in Enum.GetValues(typeof(MessageType))) { var tickBox = new GUITickBox(new RectTransform(new Point(tickBoxContainer.Rect.Width, (int)(25 * GUI.Scale)), tickBoxContainer.RectTransform), TextManager.Get("ServerLog." + messageTypeName[msgType]), font: GUI.SmallFont) { Selected = true, TextColor = messageColor[msgType], OnSelected = (GUITickBox tb) => { msgTypeHidden[(int)msgType] = !tb.Selected; FilterMessages(); return(true); } }; tickBox.TextBlock.SelectedTextColor = tickBox.TextBlock.TextColor; tickBox.Selected = !msgTypeHidden[(int)msgType]; tickBoxes.Add(tickBox); } tickBoxes.Last().TextBlock.RectTransform.SizeChanged += () => { GUITextBlock.AutoScaleAndNormalize(tickBoxes.Select(t => t.TextBlock), defaultScale: 1.0f); }; inListBox.ClearChildren(); listBox = inListBox; reverseButton = inReverseButton; reverseButton.Children.ForEach(c => c.SpriteEffects = reverseOrder ? SpriteEffects.FlipVertically : SpriteEffects.None); reverseButton.OnClicked = OnReverseClicked; var currLines = lines.ToList(); foreach (LogMessage line in currLines) { AddLine(line); } FilterMessages(); listBox.UpdateScrollBarSize(); }
private void OnInitialize() { GUILabel title = new GUILabel(new LocEdString("Banshee Engine v0.4"), EditorStyles.TitleLabel); GUILabel subTitle = new GUILabel(new LocEdString("A modern open-source game development toolkit"), EditorStyles.LabelCentered); GUILabel license = new GUILabel(new LocEdString( "This program is licensed under the GNU Lesser General Public License V3"), EditorStyles.LabelCentered); GUILabel copyright = new GUILabel(new LocEdString("Copyright (C) 2015 Marko Pintera. All rights reserved."), EditorStyles.LabelCentered); GUILabel authorLabel = new GUILabel(new LocEdString("Banshee was created, and is being actively developed by Marko Pintera.")); GUILabel emailTitle = new GUILabel(new LocEdString("E-mail"), GUIOption.FixedWidth(150)); emailLabel = new GUITextBox(); GUILabel linkedInTitle = new GUILabel(new LocEdString("LinkedIn"), GUIOption.FixedWidth(150)); GUIButton linkedInBtn = new GUIButton(new LocEdString("Profile")); GUIToggleGroup foldoutGroup = new GUIToggleGroup(true); GUIToggle contactFoldout = new GUIToggle(new LocEdString("Author"), foldoutGroup, EditorStyles.Foldout); GUIToggle thirdPartyFoldout = new GUIToggle(new LocEdString("Used third party libraries"), foldoutGroup, EditorStyles.Foldout); GUIToggle noticesFoldout = new GUIToggle(new LocEdString("Third party notices"), foldoutGroup, EditorStyles.Foldout); GUIToggle collaboratorsFoldout = new GUIToggle(new LocEdString("Collaborators"), foldoutGroup, EditorStyles.Foldout); contactFoldout.AcceptsKeyFocus = false; thirdPartyFoldout.AcceptsKeyFocus = false; noticesFoldout.AcceptsKeyFocus = false; collaboratorsFoldout.AcceptsKeyFocus = false; GUILabel freeTypeNotice = new GUILabel(new LocEdString( "Portions of this software are copyright (C) 2015 The FreeType Project (www.freetype.org). " + "All rights reserved."), EditorStyles.MultiLineLabelCentered, GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380)); GUILabel fbxSdkNotice = new GUILabel(new LocEdString( "This software contains Autodesk(R) FBX(R) code developed by Autodesk, Inc. Copyright 2013 Autodesk, Inc. " + "All rights, reserved. Such code is provided \"as is\" and Autodesk, Inc. disclaims any and all warranties, " + "whether express or implied, including without limitation the implied warranties of merchantability, " + "fitness for a particular purpose or non-infringement of third party rights. In no event shall Autodesk, " + "Inc. be liable for any direct, indirect, incidental, special, exemplary, or consequential damages " + "(including, but not limited to, procurement of substitute goods or services; loss of use, data, or " + "profits; or business interruption) however caused and on any theory of liability, whether in contract, " + "strict liability, or tort (including negligence or otherwise) arising in any way out of such code."), EditorStyles.MultiLineLabelCentered, GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380)); GUILayoutY mainLayout = GUI.AddLayoutY(); mainLayout.AddSpace(10); mainLayout.AddElement(title); mainLayout.AddElement(subTitle); mainLayout.AddSpace(10); mainLayout.AddElement(license); mainLayout.AddElement(copyright); mainLayout.AddSpace(10); mainLayout.AddElement(contactFoldout); GUILayoutY contactLayout = mainLayout.AddLayoutY(); contactLayout.AddSpace(15); GUILayout authorLayout = contactLayout.AddLayoutX(); authorLayout.AddFlexibleSpace(); authorLayout.AddElement(authorLabel); authorLayout.AddFlexibleSpace(); contactLayout.AddSpace(15); GUILayout emailLayout = contactLayout.AddLayoutX(); emailLayout.AddSpace(10); emailLayout.AddElement(emailTitle); emailLayout.AddElement(emailLabel); emailLayout.AddSpace(10); GUILayout linkedInLayout = contactLayout.AddLayoutX(); linkedInLayout.AddSpace(10); linkedInLayout.AddElement(linkedInTitle); linkedInLayout.AddElement(linkedInBtn); linkedInLayout.AddSpace(10); mainLayout.AddSpace(5); mainLayout.AddElement(thirdPartyFoldout); GUILayoutY thirdPartyLayout = mainLayout.AddLayoutY(); CreateThirdPartyGUI(thirdPartyLayout, "Autodesk FBX SDK", "http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=10775847"); CreateThirdPartyGUI(thirdPartyLayout, "FreeImage", "http://freeimage.sourceforge.net/"); CreateThirdPartyGUI(thirdPartyLayout, "FreeType", "http://www.freetype.org/"); CreateThirdPartyGUI(thirdPartyLayout, "Mono", "http://www.mono-project.com/"); CreateThirdPartyGUI(thirdPartyLayout, "NVIDIA Texture Tools", "https://github.com/castano/nvidia-texture-tools"); CreateThirdPartyGUI(thirdPartyLayout, "libFLAC", "https://xiph.org/flac/"); CreateThirdPartyGUI(thirdPartyLayout, "libOgg", "https://www.xiph.org/ogg/"); CreateThirdPartyGUI(thirdPartyLayout, "libVorbis", "http://www.vorbis.com/"); CreateThirdPartyGUI(thirdPartyLayout, "OpenAL Soft", "http://kcat.strangesoft.net/openal.html"); mainLayout.AddSpace(5); mainLayout.AddElement(noticesFoldout); GUILayout noticesLayout = mainLayout.AddLayoutY(); noticesLayout.AddElement(freeTypeNotice); noticesLayout.AddSpace(10); noticesLayout.AddElement(fbxSdkNotice); mainLayout.AddSpace(5); mainLayout.AddElement(collaboratorsFoldout); GUILayoutY collaboratorsLayout = mainLayout.AddLayoutY(); CreateCollaboratorGUI(collaboratorsLayout, "Danijel Ribic", "Logo, UI icons, 3D models & textures"); CreateCollaboratorGUI(collaboratorsLayout, "Marco Bellan", "Bugfixes, editor enhancements"); mainLayout.AddFlexibleSpace(); contactLayout.Active = false; contactFoldout.OnToggled += x => { contactLayout.Active = x; }; thirdPartyLayout.Active = false; thirdPartyFoldout.OnToggled += x => thirdPartyLayout.Active = x; noticesLayout.Active = false; noticesFoldout.OnToggled += x => noticesLayout.Active = x; collaboratorsLayout.Active = false; collaboratorsFoldout.OnToggled += x => collaboratorsLayout.Active = x; emailLabel.Text = "*****@*****.**"; linkedInBtn.OnClick += () => { System.Diagnostics.Process.Start("http://hr.linkedin.com/in/markopintera"); }; }
public bool TypingChatMessage(GUITextBox textBox, string text) { return(chatBox.TypingChatMessage(textBox, text)); }
// Use this for initialization void Start() { Dialog = GetComponentInChildren<GUITextBox>(); System = GetComponentInChildren<SystemMessage>(); }
/// <summary> /// Creates GUI elements required for displaying <see cref="SceneObject"/> fields like name, prefab data and /// transform (position, rotation, scale). Assumes that necessary inspector scroll area layout has already been /// created. /// </summary> private void CreateSceneObjectFields() { GUIPanel sceneObjectPanel = inspectorLayout.AddPanel(); sceneObjectPanel.SetHeight(GetTitleBounds().height); GUILayoutY sceneObjectLayout = sceneObjectPanel.AddLayoutY(); sceneObjectLayout.SetPosition(PADDING, PADDING); GUIPanel sceneObjectBgPanel = sceneObjectPanel.AddPanel(1); GUILayoutX nameLayout = sceneObjectLayout.AddLayoutX(); soActiveToggle = new GUIToggle(""); soActiveToggle.OnToggled += OnSceneObjectActiveStateToggled; GUILabel nameLbl = new GUILabel(new LocEdString("Name"), GUIOption.FixedWidth(50)); soNameInput = new GUITextBox(false, GUIOption.FlexibleWidth(180)); soNameInput.Text = activeSO.Name; soNameInput.OnChanged += OnSceneObjectRename; soNameInput.OnConfirmed += OnModifyConfirm; soNameInput.OnFocusLost += OnModifyConfirm; nameLayout.AddElement(soActiveToggle); nameLayout.AddSpace(3); nameLayout.AddElement(nameLbl); nameLayout.AddElement(soNameInput); nameLayout.AddFlexibleSpace(); GUILayoutX mobilityLayout = sceneObjectLayout.AddLayoutX(); GUILabel mobilityLbl = new GUILabel(new LocEdString("Mobility"), GUIOption.FixedWidth(50)); soMobility = new GUIEnumField(typeof(ObjectMobility), "", 0, GUIOption.FixedWidth(85)); soMobility.Value = (ulong)activeSO.Mobility; soMobility.OnSelectionChanged += value => activeSO.Mobility = (ObjectMobility)value; mobilityLayout.AddElement(mobilityLbl); mobilityLayout.AddElement(soMobility); soPrefabLayout = sceneObjectLayout.AddLayoutX(); GUILayoutX positionLayout = sceneObjectLayout.AddLayoutX(); GUILabel positionLbl = new GUILabel(new LocEdString("Position"), GUIOption.FixedWidth(50)); soPosX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60)); soPosY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60)); soPosZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60)); soPosX.OnChanged += (x) => OnPositionChanged(0, x); soPosY.OnChanged += (y) => OnPositionChanged(1, y); soPosZ.OnChanged += (z) => OnPositionChanged(2, z); soPosX.OnConfirmed += OnModifyConfirm; soPosY.OnConfirmed += OnModifyConfirm; soPosZ.OnConfirmed += OnModifyConfirm; soPosX.OnFocusLost += OnModifyConfirm; soPosY.OnFocusLost += OnModifyConfirm; soPosZ.OnFocusLost += OnModifyConfirm; positionLayout.AddElement(positionLbl); positionLayout.AddElement(soPosX); positionLayout.AddSpace(10); positionLayout.AddFlexibleSpace(); positionLayout.AddElement(soPosY); positionLayout.AddSpace(10); positionLayout.AddFlexibleSpace(); positionLayout.AddElement(soPosZ); positionLayout.AddFlexibleSpace(); GUILayoutX rotationLayout = sceneObjectLayout.AddLayoutX(); GUILabel rotationLbl = new GUILabel(new LocEdString("Rotation"), GUIOption.FixedWidth(50)); soRotX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60)); soRotY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60)); soRotZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60)); soRotX.OnChanged += (x) => OnRotationChanged(0, x); soRotY.OnChanged += (y) => OnRotationChanged(1, y); soRotZ.OnChanged += (z) => OnRotationChanged(2, z); soRotX.OnConfirmed += OnModifyConfirm; soRotY.OnConfirmed += OnModifyConfirm; soRotZ.OnConfirmed += OnModifyConfirm; soRotX.OnFocusLost += OnModifyConfirm; soRotY.OnFocusLost += OnModifyConfirm; soRotZ.OnFocusLost += OnModifyConfirm; rotationLayout.AddElement(rotationLbl); rotationLayout.AddElement(soRotX); rotationLayout.AddSpace(10); rotationLayout.AddFlexibleSpace(); rotationLayout.AddElement(soRotY); rotationLayout.AddSpace(10); rotationLayout.AddFlexibleSpace(); rotationLayout.AddElement(soRotZ); rotationLayout.AddFlexibleSpace(); GUILayoutX scaleLayout = sceneObjectLayout.AddLayoutX(); GUILabel scaleLbl = new GUILabel(new LocEdString("Scale"), GUIOption.FixedWidth(50)); soScaleX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60)); soScaleY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60)); soScaleZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60)); soScaleX.OnChanged += (x) => OnScaleChanged(0, x); soScaleY.OnChanged += (y) => OnScaleChanged(1, y); soScaleZ.OnChanged += (z) => OnScaleChanged(2, z); soScaleX.OnConfirmed += OnModifyConfirm; soScaleY.OnConfirmed += OnModifyConfirm; soScaleZ.OnConfirmed += OnModifyConfirm; soScaleX.OnFocusLost += OnModifyConfirm; soScaleY.OnFocusLost += OnModifyConfirm; soScaleZ.OnFocusLost += OnModifyConfirm; scaleLayout.AddElement(scaleLbl); scaleLayout.AddElement(soScaleX); scaleLayout.AddSpace(10); scaleLayout.AddFlexibleSpace(); scaleLayout.AddElement(soScaleY); scaleLayout.AddSpace(10); scaleLayout.AddFlexibleSpace(); scaleLayout.AddElement(soScaleZ); scaleLayout.AddFlexibleSpace(); sceneObjectLayout.AddFlexibleSpace(); GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg); sceneObjectBgPanel.AddElement(titleBg); }
protected override void CreateGUI() { uiElements.Clear(); var visibleElements = customInterfaceElementList.Where(ciElement => !string.IsNullOrEmpty(ciElement.Label)); uiElementContainer = new GUILayoutGroup(new RectTransform(GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center) { AbsoluteOffset = GUIStyle.ItemFrameOffset }, childAnchor: customInterfaceElementList.Count > 1 ? Anchor.TopCenter : Anchor.Center) { RelativeSpacing = 0.05f, Stretch = visibleElements.Count() > 2, }; float elementSize = Math.Min(1.0f / visibleElements.Count(), 1); foreach (CustomInterfaceElement ciElement in visibleElements) { if (!string.IsNullOrEmpty(ciElement.PropertyName)) { var layoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, elementSize), uiElementContainer.RectTransform), isHorizontal: true) { RelativeSpacing = 0.02f, UserData = ciElement }; new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform), TextManager.Get(ciElement.Label, returnNull: true) ?? ciElement.Label); var textBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform), "", style: "GUITextBoxNoIcon") { OverflowClip = true, UserData = ciElement }; //reset size restrictions set by the Style to make sure the elements can fit the interface textBox.RectTransform.MinSize = textBox.Frame.RectTransform.MinSize = new Point(0, 0); textBox.RectTransform.MaxSize = textBox.Frame.RectTransform.MaxSize = new Point(int.MaxValue, int.MaxValue); textBox.OnDeselected += (tb, key) => { if (GameMain.Client == null) { TextChanged(tb.UserData as CustomInterfaceElement, textBox.Text); } else { item.CreateClientEvent(this); } }; textBox.OnEnterPressed += (tb, text) => { tb.Deselect(); return(true); }; uiElements.Add(textBox); } else if (ciElement.ContinuousSignal) { var tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, elementSize), uiElementContainer.RectTransform) { MaxSize = ElementMaxSize }, TextManager.Get(ciElement.Label, returnNull: true) ?? ciElement.Label) { UserData = ciElement }; tickBox.OnSelected += (tBox) => { if (GameMain.Client == null) { TickBoxToggled(tBox.UserData as CustomInterfaceElement, tBox.Selected); } else { item.CreateClientEvent(this); } return(true); }; //reset size restrictions set by the Style to make sure the elements can fit the interface tickBox.RectTransform.MinSize = new Point(0, 0); tickBox.RectTransform.MaxSize = new Point(int.MaxValue, int.MaxValue); uiElements.Add(tickBox); } else { var btn = new GUIButton(new RectTransform(new Vector2(1.0f, elementSize), uiElementContainer.RectTransform), TextManager.Get(ciElement.Label, returnNull: true) ?? ciElement.Label, style: "DeviceButton") { UserData = ciElement }; btn.OnClicked += (_, userdata) => { if (GameMain.Client == null) { ButtonClicked(userdata as CustomInterfaceElement); } else { GameMain.Client.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.ComponentState, item.GetComponentIndex(this), userdata as CustomInterfaceElement }); } return(true); }; //reset size restrictions set by the Style to make sure the elements can fit the interface btn.RectTransform.MinSize = btn.Frame.RectTransform.MinSize = new Point(0, 0); btn.RectTransform.MaxSize = btn.Frame.RectTransform.MaxSize = ElementMaxSize; uiElements.Add(btn); } } }
public void CreateLogFrame() { LogFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker") { OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) { LogFrame = null; } return(true); } }; new GUIButton(new RectTransform(Vector2.One, LogFrame.RectTransform), "", style: null).OnClicked += (btn, userData) => { LogFrame = null; return(true); }; GUIFrame innerFrame = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.4f), LogFrame.RectTransform, Anchor.Center) { MinSize = new Point(600, 420) }); GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.85f), innerFrame.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, -0.03f) }, style: null); new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.05f), paddedFrame.RectTransform, Anchor.TopRight), "Filter", font: GUI.SmallFont); GUITextBox searchBox = new GUITextBox(new RectTransform(new Vector2(0.6f, 0.05f), paddedFrame.RectTransform, Anchor.TopRight), font: GUI.SmallFont); searchBox.OnTextChanged += (textBox, text) => { msgFilter = text; FilterMessages(); return(true); }; GUI.KeyboardDispatcher.Subscriber = searchBox; var clearButton = new GUIButton(new RectTransform(new Vector2(0.05f, 0.05f), paddedFrame.RectTransform, Anchor.TopRight), "x") { OnClicked = ClearFilter, UserData = searchBox }; listBox = new GUIListBox(new RectTransform(new Vector2(0.75f, 0.95f), paddedFrame.RectTransform, Anchor.BottomRight)); var tickBoxContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.2f, 0.95f), paddedFrame.RectTransform, Anchor.BottomLeft)); int y = 30; foreach (MessageType msgType in Enum.GetValues(typeof(MessageType))) { var tickBox = new GUITickBox(new RectTransform(new Point(20, 20), tickBoxContainer.RectTransform), messageTypeName[(int)msgType], font: GUI.SmallFont) { Selected = true, TextColor = messageColor[(int)msgType] }; tickBox.OnSelected += (GUITickBox tb) => { msgTypeHidden[(int)msgType] = !tb.Selected; FilterMessages(); return(true); }; tickBox.Selected = !msgTypeHidden[(int)msgType]; y += 20; } var currLines = lines.ToList(); foreach (LogMessage line in currLines) { AddLine(line); } FilterMessages(); listBox.UpdateScrollBarSize(); if (listBox.BarScroll == 0.0f || listBox.BarScroll == 1.0f) { listBox.BarScroll = 1.0f; } GUIButton closeButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.05f), innerFrame.RectTransform, Anchor.BottomRight) { RelativeOffset = new Vector2(0.02f, 0.03f) }, "Close"); closeButton.OnClicked = (button, userData) => { LogFrame = null; return(true); }; msgFilter = ""; }
private void CreateNewControl() { int left, top, width, height; GetSelectionRectangle(out left, out top, out width, out height); left = _state.WindowXToGUI(left); top = _state.WindowYToGUI(top); width = _state.WindowSizeToGUI(width); height = _state.WindowSizeToGUI(height); if ((width < 2) || (height < 2)) { return; } GUIControl newControl = null; switch (_controlAddMode) { case GUIAddType.Button: newControl = new GUIButton(left, top, width, height); break; case GUIAddType.Label: newControl = new GUILabel(left, top, width, height); break; case GUIAddType.TextBox: newControl = new GUITextBox(left, top, width, height); break; case GUIAddType.ListBox: newControl = new GUIListBox(left, top, width, height); break; case GUIAddType.Slider: newControl = new GUISlider(left, top, width, height); break; case GUIAddType.InvWindow: newControl = new GUIInventory(left, top, width, height); break; default: throw new AGSEditorException("Unknown control type added: " + _controlAddMode.ToString()); } newControl.Name = Factory.AGSEditor.GetFirstAvailableScriptName(newControl.ControlType); newControl.ZOrder = _gui.Controls.Count; newControl.ID = _gui.Controls.Count; _gui.Controls.Add(newControl); _selectedControl = newControl; _selected.Clear(); _selected.Add(newControl); RaiseOnControlsChanged(); Factory.AGSEditor.CurrentGame.NotifyClientsGUIControlAddedOrRemoved(_gui, newControl); Factory.GUIController.SetPropertyGridObject(newControl); bgPanel.Invalidate(); UpdateCursorImage(); // Revert back to Select cursor OnCommandClick(Components.GuiComponent.MODE_SELECT_CONTROLS); }
partial void InitProjSpecific() { var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter) { Stretch = true, RelativeSpacing = 0.02f }; itemList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.5f), paddedFrame.RectTransform)) { OnSelected = (GUIComponent component, object userdata) => { selectedItem = userdata as FabricationRecipe; if (selectedItem != null) { SelectItem(Character.Controlled, selectedItem); } return(true); } }; var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.06f), paddedFrame.RectTransform), isHorizontal: true) { Stretch = true, UserData = "filterarea" }; new GUITextBlock(new RectTransform(new Vector2(0.25f, 1.0f), filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.Font); itemFilterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.Font); itemFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return(true); }; var clearButton = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), filterArea.RectTransform), "x") { OnClicked = (btn, userdata) => { ClearFilter(); itemFilterBox.Flash(Color.White); return(true); } }; inputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.7f, 0.15f), paddedFrame.RectTransform), style: null); inputInventoryOverlay = new GUICustomComponent(new RectTransform(Vector2.One, inputInventoryHolder.RectTransform), DrawInputOverLay, null) { CanBeFocused = false }; var outputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.25f), paddedFrame.RectTransform), isHorizontal: true); selectedItemFrame = new GUIFrame(new RectTransform(new Vector2(0.75f, 1.0f), outputArea.RectTransform), style: "InnerFrame"); outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), outputArea.RectTransform), style: null); outputInventoryOverlay = new GUICustomComponent(new RectTransform(Vector2.One, outputArea.RectTransform), DrawOutputOverLay, null) { CanBeFocused = false }; CreateRecipes(); activateButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.07f), paddedFrame.RectTransform), TextManager.Get("FabricatorCreate"), style: "GUIButtonLarge") { OnClicked = StartButtonClicked, UserData = selectedItem, Enabled = false }; inSufficientPowerWarning = new GUITextBlock(new RectTransform(Vector2.One, activateButton.RectTransform), TextManager.Get("FabricatorNoPower"), textColor: Color.Orange, textAlignment: Alignment.Center, color: Color.Black, style: "OuterGlow") { HoverColor = Color.Black, IgnoreLayoutGroups = true, Visible = false, CanBeFocused = false }; }
/// <summary> /// Creates GUI elements required for displaying <see cref="SceneObject"/> fields like name, prefab data and /// transform (position, rotation, scale). Assumes that necessary inspector scroll area layout has already been /// created. /// </summary> private void CreateSceneObjectFields() { GUIPanel sceneObjectPanel = inspectorLayout.AddPanel(); sceneObjectPanel.SetHeight(GetTitleBounds().height); GUILayoutY sceneObjectLayout = sceneObjectPanel.AddLayoutY(); sceneObjectLayout.SetPosition(PADDING, PADDING); GUIPanel sceneObjectBgPanel = sceneObjectPanel.AddPanel(1); GUILayoutX nameLayout = sceneObjectLayout.AddLayoutX(); soActiveToggle = new GUIToggle(""); soActiveToggle.OnToggled += OnSceneObjectActiveStateToggled; GUILabel nameLbl = new GUILabel(new LocEdString("Name"), GUIOption.FixedWidth(50)); soNameInput = new GUITextBox(false, GUIOption.FlexibleWidth(180)); soNameInput.Text = activeSO.Name; soNameInput.OnChanged += OnSceneObjectRename; soNameInput.OnConfirmed += OnModifyConfirm; soNameInput.OnFocusLost += OnModifyConfirm; nameLayout.AddElement(soActiveToggle); nameLayout.AddSpace(3); nameLayout.AddElement(nameLbl); nameLayout.AddElement(soNameInput); nameLayout.AddFlexibleSpace(); GUILayoutX mobilityLayout = sceneObjectLayout.AddLayoutX(); GUILabel mobilityLbl = new GUILabel(new LocEdString("Mobility"), GUIOption.FixedWidth(50)); soMobility = new GUIEnumField(typeof(ObjectMobility), "", 0, GUIOption.FixedWidth(85)); soMobility.Value = (ulong)activeSO.Mobility; soMobility.OnSelectionChanged += value => activeSO.Mobility = (ObjectMobility)value; mobilityLayout.AddElement(mobilityLbl); mobilityLayout.AddElement(soMobility); soPrefabLayout = sceneObjectLayout.AddLayoutX(); soPos = new GUIVector3Field(new LocEdString("Position"), 50); sceneObjectLayout.AddElement(soPos); soPos.OnChanged += OnPositionChanged; soPos.OnConfirmed += OnModifyConfirm; soPos.OnFocusLost += OnModifyConfirm; soRot = new GUIVector3Field(new LocEdString("Rotation"), 50); sceneObjectLayout.AddElement(soRot); soRot.OnChanged += OnRotationChanged; soRot.OnConfirmed += OnModifyConfirm; soRot.OnFocusLost += OnModifyConfirm; soScale = new GUIVector3Field(new LocEdString("Scale"), 50); sceneObjectLayout.AddElement(soScale); soScale.OnChanged += OnScaleChanged; soScale.OnConfirmed += OnModifyConfirm; soScale.OnFocusLost += OnModifyConfirm; sceneObjectLayout.AddFlexibleSpace(); GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg); sceneObjectBgPanel.AddElement(titleBg); }
public void CreateKickReasonPrompt(string clientName, bool ban, bool rangeBan = false) { var banReasonPrompt = new GUIMessageBox( TextManager.Get(ban ? "BanReasonPrompt" : "KickReasonPrompt"), "", new string[] { TextManager.Get("OK"), TextManager.Get("Cancel") }, 400, 300); var content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.6f), banReasonPrompt.InnerFrame.RectTransform, Anchor.Center)); var banReasonBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.3f), content.RectTransform)) { Wrap = true, MaxTextLength = 100 }; GUINumberInput durationInputDays = null, durationInputHours = null; GUITickBox permaBanTickBox = null; if (ban) { new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.15f), content.RectTransform), TextManager.Get("BanDuration")); permaBanTickBox = new GUITickBox(new RectTransform(new Vector2(0.8f, 0.15f), content.RectTransform) { RelativeOffset = new Vector2(0.05f, 0.0f) }, TextManager.Get("BanPermanent")) { Selected = true }; var durationContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.15f), content.RectTransform), isHorizontal: true) { Visible = false }; permaBanTickBox.OnSelected += (tickBox) => { durationContainer.Visible = !tickBox.Selected; return(true); }; durationInputDays = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), durationContainer.RectTransform), GUINumberInput.NumberType.Int) { MinValueInt = 0, MaxValueFloat = 1000 }; new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), durationContainer.RectTransform), TextManager.Get("Days")); durationInputHours = new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), durationContainer.RectTransform), GUINumberInput.NumberType.Int) { MinValueInt = 0, MaxValueFloat = 24 }; new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), durationContainer.RectTransform), TextManager.Get("Hours")); } banReasonPrompt.Buttons[0].OnClicked += (btn, userData) => { if (ban) { if (!permaBanTickBox.Selected) { TimeSpan banDuration = new TimeSpan(durationInputDays.IntValue, durationInputHours.IntValue, 0, 0); BanPlayer(clientName, banReasonBox.Text, ban, banDuration); } else { BanPlayer(clientName, banReasonBox.Text, ban); } } else { KickPlayer(clientName, banReasonBox.Text); } return(true); }; banReasonPrompt.Buttons[0].OnClicked += banReasonPrompt.Close; banReasonPrompt.Buttons[1].OnClicked += banReasonPrompt.Close; }
public void CreateLogFrame() { LogFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null) { OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) { LogFrame = null; } return(true); } }; new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, LogFrame.RectTransform, Anchor.Center), style: "GUIBackgroundBlocker"); new GUIButton(new RectTransform(Vector2.One, LogFrame.RectTransform), "", style: null).OnClicked += (btn, userData) => { LogFrame = null; return(true); }; GUIFrame innerFrame = new GUIFrame(new RectTransform(new Vector2(0.5f, 0.5f), LogFrame.RectTransform, Anchor.Center) { MinSize = new Point(700, 500) }); GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.9f), innerFrame.RectTransform, Anchor.Center), style: null); // left column ---------------- var tickBoxContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.25f, 1.0f), paddedFrame.RectTransform, Anchor.BottomLeft)); int y = 30; List <GUITickBox> tickBoxes = new List <GUITickBox>(); foreach (MessageType msgType in Enum.GetValues(typeof(MessageType))) { var tickBox = new GUITickBox(new RectTransform(new Point(tickBoxContainer.Rect.Width, 30), tickBoxContainer.RectTransform), TextManager.Get("ServerLog." + messageTypeName[msgType]), font: GUI.SmallFont) { Selected = true, TextColor = messageColor[msgType], OnSelected = (GUITickBox tb) => { msgTypeHidden[(int)msgType] = !tb.Selected; FilterMessages(); return(true); } }; tickBox.TextBlock.SelectedTextColor = tickBox.TextBlock.TextColor; tickBox.Selected = !msgTypeHidden[(int)msgType]; tickBoxes.Add(tickBox); y += 20; } tickBoxes.Last().TextBlock.RectTransform.SizeChanged += () => { GUITextBlock.AutoScaleAndNormalize(tickBoxes.Select(t => t.TextBlock), defaultScale: 1.0f); }; // right column ---------------- var rightColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.75f, 1.0f), paddedFrame.RectTransform, Anchor.CenterRight), childAnchor: Anchor.TopRight) { Stretch = true, RelativeSpacing = 0.02f }; GUILayoutGroup filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), rightColumn.RectTransform, Anchor.TopRight), isHorizontal: true, childAnchor: Anchor.CenterLeft); new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), filterArea.RectTransform), TextManager.Get("ServerLog.Filter"), font: GUI.SubHeadingFont); GUITextBox searchBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.SmallFont, createClearButton: true); searchBox.OnTextChanged += (textBox, text) => { msgFilter = text; FilterMessages(); return(true); }; GUI.KeyboardDispatcher.Subscriber = searchBox; filterArea.RectTransform.MinSize = new Point(0, filterArea.RectTransform.Children.Max(c => c.MinSize.Y)); GUILayoutGroup listBoxLayout = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.95f), rightColumn.RectTransform)) { Stretch = true, RelativeSpacing = 0.0f }; reverseButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.05f), listBoxLayout.RectTransform), style: "UIToggleButtonVertical"); reverseButton.Children.ForEach(c => c.SpriteEffects = reverseOrder ? SpriteEffects.FlipVertically : SpriteEffects.None); reverseButton.OnClicked = OnReverseClicked; listBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.95f), listBoxLayout.RectTransform)); GUIButton closeButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.05f), rightColumn.RectTransform), TextManager.Get("Close")) { OnClicked = (button, userData) => { LogFrame = null; return(true); } }; rightColumn.Recalculate(); var currLines = lines.ToList(); foreach (LogMessage line in currLines) { AddLine(line); } FilterMessages(); listBox.UpdateScrollBarSize(); if (listBox.BarScroll == 0.0f || listBox.BarScroll == 1.0f) { listBox.BarScroll = 1.0f; } msgFilter = ""; }
public void CreateLogFrame() { LogFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f); GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 600, 420), null, Alignment.Center, "", LogFrame); innerFrame.Padding = new Vector4(10.0f, 20.0f, 10.0f, 20.0f); new GUITextBlock(new Rectangle(-200, 0, 100, 15), "Filter", "", Alignment.TopRight, Alignment.CenterRight, innerFrame, false, GUI.SmallFont); GUITextBox searchBox = new GUITextBox(new Rectangle(-20, 0, 180, 15), Alignment.TopRight, "", innerFrame); searchBox.Font = GUI.SmallFont; searchBox.OnTextChanged = (textBox, text) => { msgFilter = text; FilterMessages(); return(true); }; GUIComponent.KeyboardDispatcher.Subscriber = searchBox; var clearButton = new GUIButton(new Rectangle(0, 0, 15, 15), "x", Alignment.TopRight, "", innerFrame); clearButton.OnClicked = ClearFilter; clearButton.UserData = searchBox; listBox = new GUIListBox(new Rectangle(0, 30, 450, 340), "", Alignment.TopRight, innerFrame); int y = 30; foreach (MessageType msgType in Enum.GetValues(typeof(MessageType))) { var tickBox = new GUITickBox(new Rectangle(0, y, 20, 20), messageTypeName[(int)msgType], Alignment.TopLeft, GUI.SmallFont, innerFrame); tickBox.Selected = !msgTypeHidden[(int)msgType]; tickBox.TextColor = messageColor[(int)msgType]; tickBox.OnSelected += (GUITickBox tb) => { if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) | PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl)) { foreach (MessageType checkedMsgType in Enum.GetValues(typeof(MessageType))) { msgTypeHidden[(int)checkedMsgType] = true; } foreach (GUIComponent chkBox in innerFrame.children) { if (chkBox is GUITickBox) { GUITickBox chkBox2 = (GUITickBox)chkBox; chkBox2.Selected = false; } } tickBox.Selected = true; msgTypeHidden[(int)msgType] = false; } else { msgTypeHidden[(int)msgType] = !tb.Selected; } FilterMessages(); return(true); }; y += 20; } var currLines = lines.ToList(); foreach (LogMessage line in currLines) { AddLine(line); } listBox.UpdateScrollBarSize(); if (listBox.BarScroll == 0.0f || listBox.BarScroll == 1.0f) { listBox.BarScroll = 1.0f; } GUIButton closeButton = new GUIButton(new Rectangle(-100, 10, 100, 15), "Close", Alignment.BottomRight, "", innerFrame); closeButton.OnClicked = (button, userData) => { LogFrame = null; return(true); }; msgFilter = ""; FilterMessages(); }