private bool ApplyClicked(GUIButton button, object userData) { SaveNewPlayerConfig(); settingsFrame.Flash(Color.Green); if (GameMain.WindowMode != GameMain.Config.WindowMode) { GameMain.Instance.ApplyGraphicsSettings(); } if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight) { #if OSX if (GameMain.Config.WindowMode != WindowMode.BorderlessWindowed) { #endif new GUIMessageBox(TextManager.Get("RestartRequiredLabel"), TextManager.Get("RestartRequiredResolution")); #if OSX } #endif } if (Screen.Selected != GameMain.MainMenuScreen) { GUI.SettingsMenuOpen = false; } return(true); }
public void AddMessage(ChatMessage message) { while (chatBox.Content.CountChildren > 20) { chatBox.RemoveChild(chatBox.Content.Children.First()); } float prevSize = chatBox.BarSize; string displayedText = message.TranslatedText; string senderName = ""; Color senderColor = Color.White; if (!string.IsNullOrWhiteSpace(message.SenderName)) { senderName = (message.Type == ChatMessageType.Private ? "[PM] " : "") + message.SenderName; } if (message.Sender?.Info?.Job != null) { senderColor = Color.Lerp(message.Sender.Info.Job.Prefab.UIColor, Color.White, 0.25f); } var msgHolder = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.0f), chatBox.Content.RectTransform, Anchor.TopCenter), style: null, color: ((chatBox.Content.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f); GUITextBlock senderNameBlock = null; if (!string.IsNullOrEmpty(senderName)) { senderNameBlock = new GUITextBlock(new RectTransform(new Vector2(0.98f, 0.0f), msgHolder.RectTransform) { AbsoluteOffset = new Point((int)(5 * GUI.Scale), 0) }, senderName, textColor: senderColor, font: GUI.SmallFont, textAlignment: Alignment.TopLeft, style: null) { CanBeFocused = true }; } new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), msgHolder.RectTransform) { AbsoluteOffset = new Point((int)(10 * GUI.Scale), senderNameBlock == null ? 0 : senderNameBlock.Rect.Height) }, displayedText, textColor: message.Color, font: GUI.SmallFont, textAlignment: Alignment.TopLeft, style: null, wrap: true, color: ((chatBox.Content.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f) { UserData = message.SenderName, CanBeFocused = true }; if (message is OrderChatMessage orderChatMsg && Character.Controlled != null && orderChatMsg.TargetCharacter == Character.Controlled) { msgHolder.Flash(Color.OrangeRed * 0.6f, flashDuration: 5.0f); }
private bool ApplyClicked(GUIButton button, object userData) { Save("config.xml"); settingsFrame.Flash(Color.Green); if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight) { new GUIMessageBox("Restart required", "You need to restart the game for the resolution changes to take effect."); } return(true); }
private bool ApplyClicked(GUIButton button, object userData) { Save("config.xml"); settingsFrame.Flash(Color.Green); if (GameMain.WindowMode != GameMain.Config.WindowMode) { GameMain.Instance.SetWindowMode(GameMain.Config.WindowMode); } if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight) { new GUIMessageBox(TextManager.Get("RestartRequiredLabel"), TextManager.Get("RestartRequiredText")); } return(true); }
public override void Flash(Color?color = null, float flashDuration = 1.5f, bool useRectangleFlash = false, bool useCircularFlash = false, Vector2?flashRectOffset = null) { frame.Flash(color, flashDuration, useRectangleFlash, useCircularFlash, flashRectOffset); }
public GUITextBox(RectTransform rectT, string text = "", Color?textColor = null, ScalableFont font = null, Alignment textAlignment = Alignment.Left, bool wrap = false, string style = "", Color?color = null, bool createClearButton = false) : base(style, rectT) { HoverCursor = CursorState.IBeam; CanBeFocused = true; this.color = color ?? Color.White; frame = new GUIFrame(new RectTransform(Vector2.One, rectT, Anchor.Center), style, color); GUI.Style.Apply(frame, style == "" ? "GUITextBox" : style); textBlock = new GUITextBlock(new RectTransform(Vector2.One, frame.RectTransform, Anchor.CenterLeft), text, textColor, font, textAlignment, wrap, playerInput: true); GUI.Style.Apply(textBlock, "", this); CaretEnabled = true; caretPosDirty = true; new GUICustomComponent(new RectTransform(Vector2.One, frame.RectTransform), onDraw: DrawCaretAndSelection); int clearButtonWidth = 0; if (createClearButton) { var clearButton = new GUIButton(new RectTransform(new Vector2(0.6f, 0.6f), frame.RectTransform, Anchor.CenterRight, scaleBasis: ScaleBasis.BothHeight) { AbsoluteOffset = new Point(5, 0) }, style: "GUICancelButton") { OnClicked = (bt, userdata) => { Text = ""; frame.Flash(Color.White); return(true); } }; textBlock.RectTransform.MaxSize = new Point(frame.Rect.Width - clearButton.Rect.Height - clearButton.RectTransform.AbsoluteOffset.X * 2, int.MaxValue); clearButtonWidth = (int)(clearButton.Rect.Width * 1.2f); } if (this.style != null && this.style.ChildStyles.ContainsKey("textboxicon")) { icon = new GUIImage(new RectTransform(new Vector2(0.6f, 0.6f), frame.RectTransform, Anchor.CenterRight, scaleBasis: ScaleBasis.BothHeight) { AbsoluteOffset = new Point(5 + clearButtonWidth, 0) }, null, scaleToFit: true); icon.ApplyStyle(this.style.ChildStyles["textboxicon"]); textBlock.RectTransform.MaxSize = new Point(frame.Rect.Width - icon.Rect.Height - clearButtonWidth - icon.RectTransform.AbsoluteOffset.X * 2, int.MaxValue); } Font = textBlock.Font; Enabled = true; rectT.SizeChanged += () => { if (icon != null) { textBlock.RectTransform.MaxSize = new Point(frame.Rect.Width - icon.Rect.Height - icon.RectTransform.AbsoluteOffset.X * 2, int.MaxValue); } caretPosDirty = true; }; rectT.ScaleChanged += () => { if (icon != null) { textBlock.RectTransform.MaxSize = new Point(frame.Rect.Width - icon.Rect.Height - icon.RectTransform.AbsoluteOffset.X * 2, int.MaxValue); } caretPosDirty = true; }; }