using System; using UnityEngine; namespace COM3D2.MeidoPhotoStudio.Plugin { public class MessageWindow : BaseWindow { MessageWindowManager messageWindowManager; TextField nameTextField; Slider fontSizeSlider; TextArea messageTextArea; Button okButton; private int fontSize = 25; private bool showingMessage = false; public MessageWindow(MessageWindowManager messageWindowManager) : base() { this.messageWindowManager = messageWindowManager; nameTextField = new TextField(); Controls.Add(nameTextField); fontSizeSlider = new Slider(25, 60); fontSizeSlider.ControlEvent += ChangeFontSize; Controls.Add(fontSizeSlider); messageTextArea = new TextArea(); Controls.Add(messageTextArea); okButton = new Button("OK"); okButton.ControlEvent += ShowMessage; Controls.Add(okButton); } public void ToggleVisibility() { if (showingMessage) { messageWindowManager.CloseMessagePanel(); showingMessage = false; } else { Visible = !Visible; } } private void ChangeFontSize(object sender, EventArgs args) { fontSize = (int)fontSizeSlider.Value; messageWindowManager.SetFontSize(fontSize); } private void ShowMessage(object sender, EventArgs args) { Visible = false; showingMessage = true; messageWindowManager.ShowMessage(nameTextField.Value, messageTextArea.Value); } public override void Draw(params GUILayoutOption[] layoutOptions) { GUILayout.BeginHorizontal(); GUILayout.Label("Name", GUILayout.ExpandWidth(false)); nameTextField.Draw(GUILayout.Width(120)); GUILayout.Space(30); GUILayout.Label("Font Size", GUILayout.ExpandWidth(false)); fontSizeSlider.Draw(GUILayout.Width(120), GUILayout.ExpandWidth(false)); GUILayout.Label($"{(int)fontSize}pt"); GUILayout.EndHorizontal(); messageTextArea.Draw(GUILayout.MinHeight(90)); okButton.Draw(GUILayout.ExpandWidth(false), GUILayout.Width(30)); } } }