public static void AlignTextAreaHorzRight(OverlayElement textArea, Viewport viewport, float rMargin) { string fontName = textArea.GetParameter("font_name"); Font font = (Font)(FontManager.Singleton.GetByName(fontName).Target); Vector2 dim = ViewHelper.GetTextDimensions(textArea.Caption, font, viewport); textArea.SetPosition((1 - dim.x) - rMargin, textArea.Top); }
private void CreateMessageContainer() { // BetaGUI.GUI gui = new GUI(); // Window w = gui.createWindow(); // w.createStaticImage() backgroundElement.Hide(); iconOverlay = OverlayManager.Singleton.GetByName("Wof/MessageBar"); iconElement = OverlayManager.Singleton.GetOverlayElement("Wof/MessageBarIcon"); iconElement.MetricsMode = GuiMetricsMode.GMM_RELATIVE; iconElement.SetDimensions(radioIconWidth, radioIconWidth); iconElement.Show(); iconOverlay.Hide(); // zewnetrzny kontener ukryje wszystko iconDefaultDimesions.x = Mogre.StringConverter.ParseReal(iconElement.GetParameter("width")); iconDefaultDimesions.y = Mogre.StringConverter.ParseReal(iconElement.GetParameter("height")); messageElement = OverlayManager.Singleton.CreateOverlayElement( "TextArea", "messageElement " + DateTime.Now.Ticks); messageContainer = (OverlayContainer)OverlayManager.Singleton.CreateOverlayElement( "Panel", "messageContainer " + DateTime.Now.Ticks); messageElement.SetDimensions(mainViewport.ActualWidth, mainViewport.ActualHeight); messageElement.MetricsMode = GuiMetricsMode.GMM_PIXELS; messageElement.SetParameter("font_name", FontManager.CurrentFont); messageElement.MetricsMode = GuiMetricsMode.GMM_RELATIVE; messageElement.SetParameter("char_height", StringConverter.ToString(EngineConfig.CurrentFontSize)); messageElement.SetParameter("colour_top", "0.1 0.1 0.1"); messageElement.SetParameter("colour_bottom", "0.5 0.1 0.1"); messageElement.Caption = ""; messageContainer.MetricsMode = GuiMetricsMode.GMM_RELATIVE; messageContainer.SetDimensions(1.0f, 0.05f); // messageContainer.SetPosition(0.055f, 0.015f); messageContainer.AddChild(messageElement); messageOverlay.Add2D(messageContainer); messageContainer.Show(); }