Example #1
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            var partialTicks = (float)(_updateTimer.Elapsed.TotalMilliseconds / (TargetUpdatePeriod * 1000f));

            _trashEntity?.SetShown(_holding != null && _trashEntity.MouseOverDestination && !_inventoryGui.IsShown());
            _trashEntity?.Render(partialTicks);

            for (var index = 0; index < _elementEntities.Count; index++)
            {
                var entity = _elementEntities[index];

                if (entity != _holding)
                {
                    entity?.Render(partialTicks);
                }
            }

            _holding?.Render(partialTicks);

            var offsetY = 0f;

            if (_toastQueue.Count > 0)
            {
                var toast = _toastQueue.First();

                if (toast != null)
                {
                    toast.Render(partialTicks);
                    offsetY = toast.CurrentY;
                }
            }

            var baseCount = ElementRegistry.GetBaseElements().Length;

            FontRenderer.DrawTextCentered(Width / 2f, 16 - offsetY, $"DISCOVERED {_learntElements.Count - baseCount}/{ElementRegistry.GetTotalCount() - baseCount}");

            _inventoryGui?.SetShown(_holding == null && (_inventoryGui.MouseOverTrigger || _inventoryGui.IsShown() && _inventoryGui.MouseOverRectangle));
            _inventoryGui?.Render(partialTicks);

            SwapBuffers();
        }
Example #2
0
        public void Render(float partialTicks)
        {
            var partialTick = _ticksLast + (_ticks - _ticksLast) * partialTicks;
            var progress    = Math.Min(partialTick, _maxTicks) / _maxTicks;

            GL.Translate(X, Y, 0);
            GL.Scale(ElementIconSize, ElementIconSize, 1);

            GL.BindTexture(TextureTarget.Texture2D, Element.TextureId);

            GL.Begin(PrimitiveType.Quads);
            GL.Color4(1f, 1, 1, progress);
            VertexUtil.PutQuad();
            GL.End();

            GL.Scale(1f / ElementIconSize, 1f / ElementIconSize, 1);
            GL.Translate(-X, -Y, 0);

            FontRenderer.DrawTextCentered(X, Y + ElementIconSize / 1.5f + 5, Element.ToString());
        }
Example #3
0
        public void Render(float partialTicks)
        {
            var partialAngle = Math.Min(_ticksMax, _ticksLast + (_ticks - _ticksLast) * partialTicks) / _ticksMax * MathHelper.PiOver2;

            if (partialAngle <= 0.1)
            {
                return;
            }

            var x = _game.Width - (float)Math.Sin(partialAngle) * _size;

            GL.BindTexture(TextureTarget.Texture2D, 0);

            GL.Translate(x, 32, 0);
            GL.Scale(_size, _game.Height, 1);

            //render background
            GL.Begin(PrimitiveType.Quads);
            GL.Color4(0, 0.75, 1, 0.15f);
            VertexUtil.PutQuad(false);
            GL.End();

            GL.Begin(PrimitiveType.LineLoop);
            GL.Color4(0, 0.75, 1, 0.5f);
            VertexUtil.PutQuad(false);
            GL.End();
            GL.Scale(1 / _size, 1f / _game.Height, 1);

            //render elements
            var count = (int)(_size / _iconSize);

            _lastOver = null;

            for (int i = 0; i < _elementEntities.Count; i++)
            {
                var e = _elementEntities[i];

                var x1 = i % count * _iconSize;
                var y1 = i / count * _iconSize;

                if (IsPointInRectangle(x + x1, y1 + 32, _iconSize, _iconSize, _lastMouse.X, _lastMouse.Y))
                {
                    _lastOver = e;
                }

                GL.BindTexture(TextureTarget.Texture2D, e.TextureId);

                var newSize = _iconSize - _iconGap * 2;

                GL.Translate(x1 + _iconSize / 2, y1 + _iconSize / 2, 0);
                GL.Scale(newSize, newSize, 1);

                GL.Translate(2 / newSize, 2 / newSize, 0);
                GL.Color3(0, 0, 0);
                GL.Begin(PrimitiveType.Quads);
                VertexUtil.PutQuad();
                GL.End();
                GL.Translate(-2 / newSize, -2 / newSize, 0);

                GL.Color3(1, 1, 1f);
                GL.Begin(PrimitiveType.Quads);
                VertexUtil.PutQuad();
                GL.End();

                GL.Scale(1f / newSize, 1f / newSize, 1);
                GL.Translate(-x1 - _iconSize / 2, -y1 - _iconSize / 2, 0);
            }

            FontRenderer.DrawTextCentered(128, -16, "DISCOVERED");

            GL.Translate(-x, -32, 0);
        }