Beispiel #1
0
        //public bool Visible { get; protected set; } = true;

        public GuiScreen()
        {
            _backgroundDefault = new GuiTexture(TextureManager.LoadTexture("gui/bg"), Vector2.Zero, Vector2.One * 16, 8);
            Background         = new GuiTexture(TextureManager.LoadTexture("gui/bg_transparent"), Vector2.Zero, Vector2.One * 16, 8);
            //Visible = true;

            DoesGuiPauseGame = true;
        }
        public GuiScreenInventory()
        {
            DoesGuiPauseGame = false;

            for (int i = 0; i < 36; i++)
            {
                Buttons.Add(new GuiItemSlot(i, 0, 0, _guiScale, null));
            }

            _inventoryBackground = new GuiTexture(TextureManager.LoadTexture("gui/inventory_bg"), 0, 0, 318, 163, _guiScale);
        }
        public GuiScreenMainMenu()
        {
            Buttons.Add(new GuiButton(0, 0, -45, 2, @"\{66FF00}SINGLEPLAYER")
            {
                CenteredX = true, CenteredY = true
            });
            Buttons.Add(new GuiButton(1, 0, 0, 2, @"\{DD6600}MULTIPLAYER")
            {
                CenteredX = true, CenteredY = true
            });
            Buttons.Add(new GuiButton(2, 0, 45, 2, @"\{FF0000}EXIT")
            {
                CenteredX = true, CenteredY = true
            });

            var titleTextgure = TextureManager.LoadTexture("gui/title");

            _titleTexture = new GuiTexture(titleTextgure, 0, 0, titleTextgure.TextureSize.Width, titleTextgure.TextureSize.Height, 0.7f);
        }
Beispiel #4
0
        protected virtual void RenderTexture(GuiTexture tex, float x, float y, bool cenetered = false)
        {
            if (tex == null)
            {
                return;
            }

            float width  = tex.Size.X * tex.Scale;
            float height = tex.Size.Y * tex.Scale;

            Vector2 ratio = new Vector2(width / SharpCraft.Instance.ClientSize.Width, height / SharpCraft.Instance.ClientSize.Height);

            Vector2 unit = new Vector2(1f / SharpCraft.Instance.ClientSize.Width, 1f / SharpCraft.Instance.ClientSize.Height);

            Vector2 pos = new Vector2(x, -y);

            if (!cenetered)
            {
                pos.X += width / 2;
                pos.Y -= height / 2;
            }

            Matrix4 mat = MatrixHelper.CreateTransformationMatrix(pos.Ceiling() * unit * 2 + Vector2.UnitY - Vector2.UnitX, ratio);

            Shader.Bind();
            Shader.SetMatrix4("transformationMatrix", mat);
            Shader.SetVector2("UVmin", tex.UVmin);
            Shader.SetVector2("UVmax", tex.UVmax);

            GL.BindVertexArray(GuiRenderer.GuiQuad.VaoID);

            GL.EnableVertexAttribArray(0);

            GL.BindTexture(TextureTarget.Texture2D, tex.ID);
            GL.DrawArrays(PrimitiveType.Triangles, 0, 6);

            GL.DisableVertexAttribArray(0);

            Shader.Unbind();
        }
Beispiel #5
0
        protected virtual void RenderTextureStretchToScreen(GuiTexture tex)
        {
            if (tex == null)
            {
                return;
            }

            Shader.Bind();

            GL.BindVertexArray(GuiRenderer.GuiQuad.VaoID);
            Shader.SetMatrix4("transformationMatrix", Matrix4.Identity);
            Shader.SetVector2("UVmin", tex.UVmin);
            Shader.SetVector2("UVmax", tex.UVmax);

            GL.EnableVertexAttribArray(0);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, tex.ID);
            GL.DrawArrays(PrimitiveType.Triangles, 0, 6);

            GL.DisableVertexAttribArray(0);

            Shader.Unbind();
        }
Beispiel #6
0
        public GuiCrosshair()
        {
            Texture texture = TextureManager.LoadTexture("gui/cross");

            _texture = new GuiTexture(texture, Vector2.Zero, new Vector2(texture.TextureSize.Width, texture.TextureSize.Height), 1.4f);
        }