예제 #1
0
        public void RefreshCursor()
        {
            float x = 0f;
            float y = 0f;

            x = inputContext.MouseState.X.abs;
            y = inputContext.MouseState.Y.abs;
            cursor.SetPosition(x, y);
        }
예제 #2
0
        public OverlayScene(Vector screenSize)
        {
            m_ScreenSize = screenSize;

            //note we need to load a font if we want to use a font
            var font = FontManager.Singleton.Create("Arial", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            font.SetParameter("type", "truetype");
            font.SetParameter("source", "Arial.ttf");
            font.SetParameter("size", "16");
            font.SetParameter("resolution", "96");
            font.Load();
            m_Container = (OverlayContainer)OverlayManager.Singleton.CreateOverlayElement("Panel", "PanelName");

            //note positions and sizes are in relative screen space
            m_Container.SetPosition(0.35, 0.3);
            m_Container.SetDimensions(0.3, 0.5);
            m_Container.MaterialName = "triangle/red";


            m_Overlay = OverlayManager.Singleton.Create("bob");

            m_Overlay.Add2D(m_Container);

            m_Overlay.Show();
        }
예제 #3
0
        // Create text area for SkyX parameters
        private void _createTextArea()
        {
            // Create a panel
            OverlayContainer panel = (OverlayContainer)OverlayManager.Singleton.CreateOverlayElement("Panel", "SkyXParametersPanel");

            panel.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            panel.SetPosition(10, 10);
            panel.SetDimensions(400, 400);

            // Create a text area
            _textArea             = OverlayManager.Singleton.CreateOverlayElement("TextArea", "SkyXParametersTextArea");
            _textArea.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            _textArea.SetPosition(0, 0);
            _textArea.SetDimensions(100, 100);
            // _textArea.Text = "MogreLib SkyX plugin demo";
            _textArea._setHeight(16);
            //_textArea.FontName = "BlueHighway";
            // _textArea.ColorBottom = new ColorEx(0.3f, 0.5f, 0.3f);
            //_textArea.ColorTop = new ColorEx(0.5f, 0.7f, 0.5f);

            // Create an overlay, and add the panel
            Overlay overlay = OverlayManager.Singleton.Create("OverlayName");

            overlay.Add2D(panel);

            // Add the text area to the panel
            panel.AddChild(_textArea);

            // Show the overlay
            overlay.Show();
        }
예제 #4
0
        // Create text area for SkyX parameters
        private void CreateTextArea()
        {
            // Create a panel
            OverlayContainer panel = (OverlayContainer)OverlayManager.Singleton.CreateOverlayElement("Panel", "SkyXParametersPanel");

            panel.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            panel.SetPosition(10, 10);
            panel.SetDimensions(400, 400);

            // Create a text area
            textArea             = (TextAreaOverlayElement)OverlayManager.Singleton.CreateOverlayElement("TextArea", "SkyXParametersTextArea");
            textArea.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            textArea.SetPosition(0, 0);
            textArea.SetDimensions(100, 100);
            textArea.Caption      = "SkyX plugin demo";
            textArea.CharHeight   = 16;
            textArea.FontName     = "BlueHighway";
            textArea.ColourBottom = new ColourValue(0.3f, 0.5f, 0.3f);
            textArea.ColourTop    = new ColourValue(0.5f, 0.7f, 0.7f);


            // Create an overlay, and add the panel
            Overlay overlay = OverlayManager.Singleton.Create("OverlayName");

            overlay.Add2D(panel);

            // Add the text area to the panel
            panel.AddChild(textArea);

            // Show the overlay
            overlay.Show();
        }
예제 #5
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.");
            }
        }
예제 #6
0
        void constrainPosition()
        {
            bool offScreen = false;

            mOnRightBorder = false;
            mOnBotBorder   = false;
            mOnTopBorder   = false;
            mOnLeftBorder  = false;

            if (mPosition.x >= (mConstraints.x - 1))
            {
                mPosition.x    = mConstraints.x - 1;
                mOnRightBorder = true;
                offScreen      = true;
            }

            if (mPosition.y >= (mConstraints.y - 1))
            {
                mPosition.y  = mConstraints.y - 1;
                mOnBotBorder = true;
                offScreen    = true;
            }

            if (mPosition.y <= 0)
            {
                mPosition.y  = 0;
                mOnTopBorder = true;
                offScreen    = true;
            }

            if (mPosition.x <= 0)
            {
                mPosition.x   = 0;
                mOnLeftBorder = true;
                offScreen     = true;
            }

            if (offScreen)
            {
                GUIManager.Singleton.injectMouseLeaves();
            }
            // For example, if the user wants the mouse hidden, we shouldn't show it
            // even if its within bounds.
            else
            {
                if (mVisible)
                {
                    show();
                }
                else
                {
                    hide();
                }
            }

            // Perform the actual moving of the mouse overlay
            mMousePointerContainer.SetPosition(mPosition.x, mPosition.y);
        }
예제 #7
0
        private void ConfigureContainer(OverlayContainer container, OverlayElement element, int width, int height,
                                        int posX, int posY)
        {
            container.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            container.SetDimensions(minimapViewport.ActualWidth, minimapViewport.ActualHeight);
            container.SetPosition(posX,
                                  posY);

            container.AddChild(element);
            hudOverlay.Add2D(container);
            container.Show();
        }
예제 #8
0
        public OverlayContainer createOverlay(String N, Vector2 P, Vector2 D,
                                              String M, String C, bool A, Overlay target)
        {
            String t = "Panel";

            if (C != "")
            {
                t = "TextArea";
            }
            OverlayElement e = OverlayManager.Singleton.CreateOverlayElement(t, N + this.name + DateTime.Now.Ticks);

            e.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            e.SetDimensions(D.x, D.y);
            e.SetPosition(0, 0);


            //if (M != "")
            //    e.MaterialName = M;

            if (C != "")
            {
                if (A)
                {
                    e.Top  = OVERLAY_TITLE_MARGIN;
                    e.Left = OVERLAY_TITLE_MARGIN;
                }

                e.Caption = C;
                e.SetParameter("font_name", mFont);
                e.SetParameter("char_height", StringConverter.ToString(mFontSize));
            }


            OverlayContainer c =
                (OverlayContainer)
                OverlayManager.Singleton.CreateOverlayElement("Panel", name + "ContainerHack" + (oc++).ToString());

            c.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            c.SetDimensions(D.x, D.y);
            c.SetPosition(P.x, P.y);

            if (M != "")
            {
                c.MaterialName = M;
            }
            c.AddChild(e);
            if (A)
            {
                target.Add2D(c);
                c.Show();
            }
            return(c);
        }
예제 #9
0
 public SimpleQuad(String name, String materialName,
     float left, float top, float width,
     float height, ColourValue colour)
 {
     Panel = OverlayManager.Singleton.CreateOverlayElement("Panel", name)
       as OverlayContainer;
     Panel.MetricsMode = GuiMetricsMode.GMM_RELATIVE;
     Panel.SetDimensions(width, height);
     Panel.SetPosition(left, top);
     Panel.MaterialName = materialName;
     Panel.Colour = colour;
 }
예제 #10
0
 public SimpleQuad(String name, String materialName,
                   float left, float top, float width,
                   float height, ColourValue colour)
 {
     Panel = OverlayManager.Singleton.CreateOverlayElement("Panel", name)
             as OverlayContainer;
     Panel.MetricsMode = GuiMetricsMode.GMM_RELATIVE;
     Panel.SetDimensions(width, height);
     Panel.SetPosition(left, top);
     Panel.MaterialName = materialName;
     Panel.Colour       = colour;
 }
예제 #11
0
        public void SetRect(Vector4 rect)
        {
            bool changedPos = false;

            if (x != rect.x)
            {
                x          = rect.x;
                changedPos = true;
            }
            if (y != rect.y)
            {
                y          = rect.y;
                changedPos = true;
            }
            if (changedPos)
            {
                mO.SetPosition(x, y);
            }


            bool changedDim = false;

            if (w != rect.z)
            {
                w          = rect.z;
                changedDim = true;
            }
            if (h != rect.w)
            {
                h          = rect.w;
                changedDim = true;
            }

            if (changedDim)
            {
                mO.SetDimensions(w, h);
            }
        }
예제 #12
0
        public int injectMouse(uint x, uint y, bool LMB)
        {
            if (mMP != null)
            {
                if (!mMP.IsVisible)
                {
                    mMP.Show();
                }
                mMP.SetPosition(x, y);
            }

            if (mXW != null)
            {
                int i = 0;
                foreach (Window win in WN)
                {
                    if (mXW == win)
                    {
                        mXW.killWindow();
                        WN.RemoveAt(i);
                        oldMouseX = x;  oldMouseY = y;
                        return(-1);
                    }
                    i++;
                }
            }


            // by Adam - jeœli nie by³o ruchu myszk¹ to nie przekszkadzamy klawiaturze
            if (x == oldMouseX && y == oldMouseY && !LMB)
            {
                //	Console.WriteLine("Mouse did not change" + DateTime.Now);

                return(-1);
            }

            //  Console.WriteLine("Checking for deselection "+x +"=="+ oldMouseX +", "+y+ "=="+ oldMouseY);
            for (int i = 0; i < WN.Count; i++)
            {
                // Console.WriteLine("["+ WN[i].mC +"] Old points: "+oldMouseX+" "+oldMouseY+", new: "+x+" "+y);
                int ret = WN[i].check(x, y, LMB);
                if (ret >= 0)
                {
                    oldMouseX = x; oldMouseY = y;
                    return(ret);
                }
            }
            oldMouseX = x; oldMouseY = y;
            return(-1);
        }
예제 #13
0
        private void Initalize()
        {
            // Create the font resources
            // add the path to your resources.cfg
            // for example:
            // Default   | ../../../Media/fonts     | ../../../Media/fonts.zip
            Load("LiberationSans-Regular.ttf", Font.Default, 10);
            Load("LiberationSans-Bold.ttf", Font.DefaultBold, 15);
            Load("LiberationSans-Italic.ttf", Font.DefaultItalic, 10);
            //Load("LiberationMono-Regular.ttf", Font.Console, 26);

            // Create the overlay panel
            _OverlayPanel             = OverlayManager.Singleton.CreateOverlayElement("Panel", new Guid().ToString()) as OverlayContainer;
            _OverlayPanel.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            _OverlayPanel.SetPosition(0, 0);
            _OverlayPanel.SetDimensions(300, 120);

            _TextOverlay = OverlayManager.Singleton.Create(new Guid().ToString());

            _TextOverlay.Add2D(_OverlayPanel);
        }
        public OverlayScene(Vector screenSize)
        {
            m_ScreenSize = screenSize;

            //note we need to load a font if we want to use a font
            var font = FontManager.Singleton.Create("Arial", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            font.SetParameter("type", "truetype");
            font.SetParameter("source", "Arial.ttf");
            font.SetParameter("size", "16");
            font.SetParameter("resolution", "96");
            font.Load();
            m_Container = (OverlayContainer)OverlayManager.Singleton.CreateOverlayElement("Panel", "PanelName");

            //note positions and sizes are in relative screen space
            m_Container.SetPosition(0.35, 0.3);
            m_Container.SetDimensions(0.3, 0.5);
            m_Container.MaterialName = "triangle/red";

            m_Overlay = OverlayManager.Singleton.Create("bob");

            m_Overlay.Add2D(m_Container);

            m_Overlay.Show();
        }
예제 #15
0
        internal MouseCursor(Vector2 dimensions, string material, int RenderWidthInPixels, int RenderHeightInPixels)
        {
            instance  = this;
            mMaterial = material;
            mRelativeCursorDimensions = dimensions;
            mRenderWidthInPixels      = RenderWidthInPixels;
            mRenderHeightInPixels     = RenderHeightInPixels;
            mVisible           = true;
            mHideWhenOffScreen = true;
            mOnTopBorder       = false;
            mOnBotBorder       = false;
            mOnLeftBorder      = false;
            mOnRightBorder     = false;

            mPixelCursorDimensions.x = mRelativeCursorDimensions.x; // *RenderWidthInPixels; // GDZ: Prefiero al cursor en pixels
            mPixelCursorDimensions.y = mRelativeCursorDimensions.y; // *RenderHeightInPixels; // GDZ: Prefiero al cursor en pixels
            mConstraints.x           = RenderWidthInPixels;
            mConstraints.y           = RenderHeightInPixels;
            mPosition.x = mConstraints.x / 2;
            mPosition.y = mConstraints.y / 2;

            // Create Mouse Overlay
            mMouseOverlay        = OverlayManager.Singleton.Create("simpleGUI_Mouse_Overlay");
            mMouseOverlay.ZOrder = 649;
            mMouseOverlay.Show();

            // Create Mouse Overlay Container
            mMousePointerContainer             = (OverlayContainer)(OverlayManager.Singleton.CreateOverlayElement("Panel", "simpleGUI_Mouse_Container"));
            mMousePointerContainer.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            mMousePointerContainer.SetPosition(mPosition.x, mPosition.y);
            mMousePointerContainer.SetDimensions(Mogre.Math.Ceil(mPixelCursorDimensions.x), Mogre.Math.Ceil(mPixelCursorDimensions.y));
            mMousePointerContainer.MaterialName = mMaterial;

            mMouseOverlay.Add2D(mMousePointerContainer);
            mMousePointerContainer.Show();
        }
예제 #16
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();
        }
예제 #17
0
        private void PrepareMessage()
        {
            messageElement.Hide();

            // icon
            uint   iconFrames            = 1;
            float  iconAnimationDuration = 1.0f;
            string changedIcon           = null;

            if (currentMessage is IconedMessageEntry)
            {
                string  icon = (currentMessage as IconedMessageEntry).Icon;
                Vector2 dim  = (currentMessage as IconedMessageEntry).CustomIconDimensions;
                iconFrames            = (currentMessage as IconedMessageEntry).IconFrames;
                iconAnimationDuration = (currentMessage as IconedMessageEntry).IconAnimationDuration;
                if (lastIconTexture != icon)
                {
                    lastIconTexture = icon;
                    changedIcon     = icon;
                    if (!dim.IsZeroLength)
                    {
                        iconElement.Width  = dim.x;
                        iconElement.Height = dim.y;
                    }
                    else
                    {
                        iconElement.Width  = iconDefaultDimesions.x;
                        iconElement.Height = iconDefaultDimesions.y;
                    }
                }
            }
            else if (lastIconTexture != null)
            {
                changedIcon        = "radio.png";
                lastIconTexture    = null;
                iconElement.Width  = iconDefaultDimesions.x;
                iconElement.Height = iconDefaultDimesions.y;
            }

            if (changedIcon != null)
            {
                try
                {
                    MaterialPtr mat = MaterialManager.Singleton.GetByName("MessageBarIcon");
                    if (iconFrames > 1)
                    {
                        mat.GetBestTechnique().GetPass(0).GetTextureUnitState(0).SetAnimatedTextureName(changedIcon, iconFrames, iconAnimationDuration);
                        //   mat.GetBestTechnique().GetPass(0).GetTextureUnitState(0).SetTextureName(null);
                    }
                    else
                    {
                        //  mat.GetBestTechnique().GetPass(0).GetTextureUnitState(0).SetAnimatedTextureName(null, 1);
                        mat.GetBestTechnique().GetPass(0).GetTextureUnitState(0).SetTextureName(changedIcon);
                    }
                }
                catch (Exception)
                {
                }
            }



            currentMessage.IncreaseX(XMargin);
            currentMessage.IncreaseY(YMargin);

            iconOverlay.Hide();


            if (!iconOverlay.IsVisible)
            {
                float iconYPos = currentMessage.Y - iconElement.Height * 0.5f;                 // ikonka w jedym poziomie z tekstem

                if (iconYPos <= yMargin)
                {
                    iconYPos = currentMessage.Y + currentMessage.CharHeight * 0.25f;     // przyklej ikonke do rogu ekranu
                }
                iconElement.SetPosition((currentMessage.X), iconYPos);
            }

            messageContainer.SetPosition(iconElement.Width + currentMessage.X, currentMessage.Y);
            messageElement.SetParameter("char_height", currentMessage.getCharHeightString());
            messageElement.SetParameter("colour_top", currentMessage.ColourTopString);
            messageElement.SetParameter("colour_bottom", currentMessage.ColourBottomString);


            messageElement.Caption = currentMessage.GetMessageAdjustedByContainerWidth(mainViewport.ActualWidth * 0.8f, OverlayManager.Singleton.ViewportHeight);
            // messageElement.Caption = AbstractScreen.Wrap(currentMessage.Message, currentMessage.CharsPerLine); ;
        }
예제 #18
0
        public void RefreshCursor()
        {
            var position = System.Windows.Forms.Cursor.Position;

            _cursor.SetPosition(position.X, position.Y);
        }
예제 #19
0
 public void SetDimensions(float left, float top, float width, float height)
 {
     Panel.SetDimensions(width, height);
     Panel.SetPosition(left, top);
 }
예제 #20
0
        private void Initalize()
        {
            // Create the font resources
            // add the path to your resources.cfg
            // for example:
            // Default   | ../../../Media/fonts     | ../../../Media/fonts.zip
            Load("LiberationSans-Regular.ttf", Font.Default, 10);
            Load("LiberationSans-Bold.ttf", Font.DefaultBold, 15);
            Load("LiberationSans-Italic.ttf", Font.DefaultItalic, 10);
            //Load("LiberationMono-Regular.ttf", Font.Console, 26);

            // Create the overlay panel
            _OverlayPanel = OverlayManager.Singleton.CreateOverlayElement("Panel", new Guid().ToString()) as OverlayContainer;
            _OverlayPanel.MetricsMode = GuiMetricsMode.GMM_PIXELS;
            _OverlayPanel.SetPosition(0, 0);
            _OverlayPanel.SetDimensions(300, 120);

            _TextOverlay = OverlayManager.Singleton.Create(new Guid().ToString());

            _TextOverlay.Add2D(_OverlayPanel);
        }