Exemple #1
0
        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.");
            }
        }
Exemple #2
0
        public void Init(string name, Mogre.RenderWindow window, InputContext inputContext, UIListener listener)
        {
            Name              = name;
            this.window       = window;
            this.inputContext = inputContext;
            this.listener     = listener;
            cursorWasVisible  = false;

            OverlayManager om       = Mogre.OverlayManager.Singleton;
            string         nameBase = Name + "/";

            cursorLayer        = om.Create(nameBase + "CursorLayer");
            cursorLayer.ZOrder = 1;

            // make backdrop and cursor overlay containers
            cursor = (Mogre.OverlayContainer)om.CreateOverlayElementFromTemplate("SdkTrays/Cursor", "Panel", nameBase + "Cursor");
            cursorLayer.Add2D(cursor);
            cursorLayer.ZOrder = 400;

            ShowCursor();
            gameCursor = new GameCursor();
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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();
        }