public SimpleStaticTextWidget(string name, string caption, float width, bool specificColor, ColourValue color, float fontSize = 100) { OverlayManager overlayMgr = OverlayManager.Singleton; element = overlayMgr.CreateOverlayElement("BorderPanel", name); element.MetricsMode = GuiMetricsMode.GMM_RELATIVE; //element.HorizontalAlignment = GuiHorizontalAlignment.GHA_LEFT; element.Height = 0.32f; element.Left = -0.01f; if (width == 0) { element.Width = 1; } mTextArea = overlayMgr.CreateOverlayElement("TextArea", name + "/StaticTextCaption") as TextAreaOverlayElement; mTextArea.MetricsMode = GuiMetricsMode.GMM_RELATIVE; mTextArea.HorizontalAlignment = GuiHorizontalAlignment.GHA_CENTER; mTextArea.SetAlignment(TextAreaOverlayElement.Alignment.Center); mTextArea.Top = 0f; mTextArea.FontName = "EngineFont"; mTextArea.CharHeight = 0.025f * (fontSize / (float)100); mTextArea.SpaceWidth = 0.02f; if (!specificColor) { mTextArea.Colour = new ColourValue(0.9f, 1f, 0.7f); } else { mTextArea.Colour = color; } ((OverlayContainer)element).AddChild(mTextArea); Text = caption; }
public StaticText(string name, string caption, float width, bool specificColor, ColourValue color) { OverlayManager overlayMgr = OverlayManager.Singleton; mElement = overlayMgr.CreateOverlayElement("BorderPanel", name); mElement.MetricsMode = GuiMetricsMode.GMM_PIXELS; mElement.HorizontalAlignment = GuiHorizontalAlignment.GHA_CENTER; mElement.Height = 32; mTextArea = overlayMgr.CreateOverlayElement("TextArea", name + "/StaticTextCaption") as TextAreaOverlayElement; mTextArea.MetricsMode = GuiMetricsMode.GMM_PIXELS; mTextArea.HorizontalAlignment = GuiHorizontalAlignment.GHA_CENTER; mTextArea.SetAlignment(TextAreaOverlayElement.Alignment.Center); mTextArea.Top = 10; mTextArea.FontName = "EngineFont"; mTextArea.CharHeight = 18; mTextArea.SpaceWidth = 9; if (!specificColor) { mTextArea.Colour = new ColourValue(0.9f, 1f, 0.7f); } else { mTextArea.Colour = color; } ((OverlayContainer)mElement).AddChild(mTextArea); SetText(caption); }
public static void AddTextBox(String id, String text, float x, float y, float width, float height, ColourValue colorTop, ColourValue colorBot) { try { OverlayManager overlayMgr = OverlayManager.Singleton; OverlayContainer panel = (OverlayContainer)overlayMgr.CreateOverlayElement("Panel", "_panel_" + id); panel.MetricsMode = GuiMetricsMode.GMM_PIXELS; panel.SetPosition(x, y); panel.SetDimensions(width, height); TextAreaOverlayElement textArea = (TextAreaOverlayElement)overlayMgr.CreateOverlayElement("TextArea", "_area_" + id); textArea.MetricsMode = GuiMetricsMode.GMM_PIXELS; textArea.SetPosition(0, 0); textArea.SetDimensions(width, height); textArea.Caption = text; textArea.CharHeight = 16; textArea.FontName = "Verdana"; textArea.ColourTop = colorTop; textArea.ColourBottom = colorBot; Overlay overlay = overlayMgr.Create("_overlay_" + id); overlay.Add2D(panel); panel.AddChild(textArea); overlay.Show(); } catch (Exception e) { Util.Log("Unable to create text area."); } }
public SimpleStaticTextButton(string name, string caption, ColourValue normalStateColor, ColourValue activeStateColor, bool specificColor = false) { OverlayManager overlayMgr = OverlayManager.Singleton; element = overlayMgr.CreateOverlayElement("BorderPanel", name); element.MetricsMode = GuiMetricsMode.GMM_RELATIVE; element.HorizontalAlignment = GuiHorizontalAlignment.GHA_LEFT; element.Height = 0.32f; mTextArea = overlayMgr.CreateOverlayElement("TextArea", name + "/StaticTextCaption") as TextAreaOverlayElement; mTextArea.MetricsMode = GuiMetricsMode.GMM_RELATIVE; mTextArea.HorizontalAlignment = GuiHorizontalAlignment.GHA_LEFT; mTextArea.SetAlignment(TextAreaOverlayElement.Alignment.Left); mTextArea.Top = 0.01f; mTextArea.FontName = "EngineFont"; mTextArea.CharHeight = 0.025f; mTextArea.SpaceWidth = 0.02f; if (!specificColor) { normalStateColor = new ColourValue(0.9f, 1f, 0.7f); } mTextArea.Colour = normalStateColor; ((OverlayContainer)element).AddChild(mTextArea); Text = caption; AssignListener(UILayer.Instance.Listener); this.normalStateColor = normalStateColor; this.activeStateColor = activeStateColor; mState = ButtonState.BS_UP; }
public Panel(string name, float width = 0, float height = 0, float left = 0, float top = 0) { widgets = new List <Widget>(); OverlayManager overlayMgr = OverlayManager.Singleton; mElement = overlayMgr.CreateOverlayElement("BorderPanel", name); mElement.MetricsMode = GuiMetricsMode.GMM_RELATIVE; mElement.HorizontalAlignment = GuiHorizontalAlignment.GHA_CENTER; if (width == 0 || height == 0) { mElement.Width = float.Parse(GameManager.Instance.videoMode["Width"]) - 20; mElement.Height = float.Parse(GameManager.Instance.videoMode["Height"]) - 20; } else if (width > 0 && height > 0) { mElement.Width = width; mElement.Height = height; } }
public SimpleButtonWidget(string name, string caption, float width, float height, float left = 0, float top = 0) { OverlayManager overlayMgr = OverlayManager.Singleton; element = OverlayManager.Singleton.CreateOverlayElementFromTemplate("SimpleButton", "BorderPanel", name); element.MetricsMode = GuiMetricsMode.GMM_RELATIVE; element.Top = top; element.Left = left; element.Height = height; element.Width = width; borderPanelElement = (BorderPanelOverlayElement)element; textAreaElement = overlayMgr.CreateOverlayElement("TextArea", name + "/StaticTextCaption") as TextAreaOverlayElement; textAreaElement.MetricsMode = GuiMetricsMode.GMM_RELATIVE; textAreaElement.HorizontalAlignment = GuiHorizontalAlignment.GHA_CENTER; textAreaElement.SetAlignment(TextAreaOverlayElement.Alignment.Center); textAreaElement.FontName = "EngineFont"; textAreaElement.CharHeight = 0.025f; textAreaElement.SpaceWidth = 0.02f; textAreaElement.Colour = ColourValue.Black; textAreaElement.Top = height / 45f; ((OverlayContainer)element).AddChild(textAreaElement); textAreaElement.Caption = caption; }
public OverlayGUI() { //setup the colours top = new ColourValue(0.9f, 0.9f, 0.9f); bot = new ColourValue(0.8f, 0.8f, 0.8f); seltop = new ColourValue(0.9f, 0.7f, 0.7f); selbot = new ColourValue(0.8f, 0.6f, 0.6f); //Overlay overlayManager = OverlayManager.Singleton; // Create a panel panel = (OverlayContainer)overlayManager.CreateOverlayElement("Panel", "PanelName"); panel.MetricsMode = GuiMetricsMode.GMM_PIXELS; panel.SetPosition(0, 0); panel.SetDimensions(Program.Instance.rWindow.Width, Program.Instance.rWindow.Height); panel.MaterialName = "fsO/Blank"; // Optional background material // Create a text area messageArea = (TextAreaOverlayElement)overlayManager.CreateOverlayElement("TextArea", "TextArea"); messageArea.MetricsMode = GuiMetricsMode.GMM_PIXELS; messageArea.SetPosition(0, 0); messageArea.SetDimensions(Program.Instance.rWindow.Width, 100); messageArea.CharHeight = 24; messageArea.FontName = "damn"; messageArea.ColourTop = top; messageArea.ColourBottom = bot; messageArea.Caption = ""; // Status text area statArea = (TextAreaOverlayElement)overlayManager.CreateOverlayElement("TextArea", "StatTextArea"); statArea.MetricsMode = GuiMetricsMode.GMM_PIXELS; statArea.SetPosition(0, Program.Instance.rWindow.Height - 50); statArea.SetDimensions(Program.Instance.rWindow.Width, 50); statArea.CharHeight = 24; statArea.FontName = "damn"; statArea.ColourTop = top; statArea.ColourBottom = bot; statArea.Caption = "this is a test" + Environment.NewLine + "This is the test's second line"; //Menus Text Areas titleArea = (TextAreaOverlayElement)overlayManager.CreateOverlayElement("TextArea", "TitleTextArea"); titleArea.MetricsMode = GuiMetricsMode.GMM_PIXELS; titleArea.SetPosition(64, 16); titleArea.SetDimensions(Program.Instance.rWindow.Width, 32); titleArea.CharHeight = 32; titleArea.FontName = "damn"; titleArea.ColourTop = top; titleArea.ColourBottom = bot; titleArea.Caption = "Title"; for (int i = 0; i < 10; i++) { optionAreas[i] = (TextAreaOverlayElement)overlayManager.CreateOverlayElement("TextArea", i+"TextArea"); optionAreas[i].MetricsMode = GuiMetricsMode.GMM_PIXELS; optionAreas[i].SetPosition(32, 64 + (i*26)); optionAreas[i].SetDimensions(Program.Instance.rWindow.Width, 24); optionAreas[i].CharHeight = 24; optionAreas[i].FontName = "damn"; optionAreas[i].ColourTop = top; optionAreas[i].ColourBottom = bot; optionAreas[i].Caption = "Option " + i.ToString(); } maxOptions = 10; // Create an overlay, and add the panel overlay = overlayManager.Create("OverlayName"); overlay.Add2D(panel); // Add the text area to the panel panel.AddChild(messageArea); panel.AddChild(titleArea); panel.AddChild(statArea); for (int i = 0; i < 10; i++) { panel.AddChild(optionAreas[i]); } // Show the overlay overlay.Show(); }
public SdkTrayManager(string name) { Name = name; string nameBase = Name + "/"; nameBase = nameBase.Replace(" ", "_"); for (var i = 0; i < _widgets.Length; i++) { _widgets[i] = new List <Widget>(); } OverlayManager om = OverlayManager.Singleton; _backdropLayer = om.Create(nameBase + "BackdropLayer"); _traysLayer = om.Create(nameBase + "WidgetsLayer"); _priorityLayer = om.Create(nameBase + "PriorityLayer"); _cursorLayer = om.Create(nameBase + "CursorLayer"); _backdropLayer.ZOrder = 100;; _traysLayer.ZOrder = 200; _priorityLayer.ZOrder = 300; _cursorLayer.ZOrder = 400; // make backdrop and cursor overlay containers _cursor = (OverlayContainer)om.CreateOverlayElementFromTemplate("SdkTrays/Cursor", "Panel", nameBase + "Cursor"); _cursorLayer.Add2D(_cursor); _backdrop = (OverlayContainer)om.CreateOverlayElement("Panel", nameBase + "Backdrop"); _backdropLayer.Add2D(_backdrop); _dialogShade = (OverlayContainer)om.CreateOverlayElement("Panel", nameBase + "DialogShade"); _dialogShade.MaterialName = "SdkTrays/Shade"; _dialogShade.Hide(); _priorityLayer.Add2D(_dialogShade); string[] trayNames = new[] { "TopLeft", "Top", "TopRight", "Left", "Center", "Right", "BottomLeft", "Bottom", "BottomRight" }; for (var i = 0; i < 9; i++) // make the real trays { _trays[i] = (OverlayContainer)om.CreateOverlayElementFromTemplate ("SdkTrays/Tray", "BorderPanel", nameBase + trayNames[i] + "Tray"); _traysLayer.Add2D(_trays[i]); _trayWidgetAlign[i] = GuiHorizontalAlignment.GHA_CENTER; // align trays based on location if (i == (int)TrayLocation.Top || i == (int)TrayLocation.Center || i == (int)TrayLocation.Bottom) { _trays[i].HorizontalAlignment = GuiHorizontalAlignment.GHA_CENTER; } if (i == (int)TrayLocation.Left || i == (int)TrayLocation.Center || i == (int)TrayLocation.Right) { _trays[i].VerticalAlignment = GuiVerticalAlignment.GVA_CENTER; } if (i == (int)TrayLocation.TopRight || i == (int)TrayLocation.Right || i == (int)TrayLocation.BottomRight) { _trays[i].HorizontalAlignment = GuiHorizontalAlignment.GHA_RIGHT; } if (i == (int)TrayLocation.BottomLeft || i == (int)TrayLocation.Bottom || i == (int)TrayLocation.BottomRight) { _trays[i].VerticalAlignment = GuiVerticalAlignment.GVA_BOTTOM; } } // create the null tray for free-floating widgets _trays[9] = (OverlayContainer)om.CreateOverlayElement("Panel", nameBase + "NullTray"); _trayWidgetAlign[9] = GuiHorizontalAlignment.GHA_LEFT; _traysLayer.Add2D(_trays[9]); AdjustTrays(); ShowTrays(); ShowCursor(); }