Beispiel #1
0
    public void DrawRectangle(
        float x, float y, float width, float height,
        ITexture texture,
        PackedLinearColorA color,
        SamplerType2d samplerType = SamplerType2d.CLAMP
        )
    {
        // Generate the vertex data
        Span <Vertex2d> vertices = stackalloc Vertex2d[4];

        // Upper Left
        vertices[0].pos     = new Vector4(x, y, 0.5f, 1);
        vertices[0].uv      = new Vector2(0, 0);
        vertices[0].diffuse = color;

        // Upper Right
        vertices[1].pos     = new Vector4(x + width, y, 0.5f, 1);
        vertices[1].uv      = new Vector2(1, 0);
        vertices[1].diffuse = color;

        // Lower Right
        vertices[2].pos     = new Vector4(x + width, y + height, 0.5f, 1);
        vertices[2].uv      = new Vector2(1, 1);
        vertices[2].diffuse = color;

        // Lower Left
        vertices[3].pos     = new Vector4(x, y + height, 0.5f, 1);
        vertices[3].uv      = new Vector2(0, 1);
        vertices[3].diffuse = color;

        DrawRectangle(vertices, texture, null, samplerType);
    }
    public void TestBorderAndBackground()
    {
        var backgroundAndBorder = Style(new StyleDefinition()
        {
            BackgroundColor = PackedLinearColorA.FromHex("#666666"),
            BorderColor     = PackedLinearColorA.FromHex("#AAAAAA"),
            BorderWidth     = 2
        });
        var backgroundOnly = Style(new StyleDefinition()
        {
            BackgroundColor = PackedLinearColorA.FromHex("#666666"),
            BorderColor     = PackedLinearColorA.FromHex("#AAAAAA")
        });
        var borderOnly = Style(new StyleDefinition()
        {
            BorderColor = PackedLinearColorA.FromHex("#AAAAAA"),
            BorderWidth = 1
        });
        var thickBorder = Style(new StyleDefinition()
        {
            BorderColor = PackedLinearColorA.FromHex("#AAAAAA"),
            BorderWidth = 4
        });

        Device.BeginDraw();
        Device.TextEngine.RenderBackgroundAndBorder(25, 75, 100, 50, backgroundAndBorder);
        Device.TextEngine.RenderBackgroundAndBorder(25, 275, 100, 50, borderOnly);
        Device.TextEngine.RenderBackgroundAndBorder(225, 275, 100, 50, thickBorder);
        Device.TextEngine.RenderBackgroundAndBorder(225, 75, 100, 50, backgroundOnly);
        Device.EndDraw();

        var screenshot = TakeScreenshot();

        ImageComparison.AssertImagesEqual(screenshot, "Core/GFX/TextRendering/BackgroundAndBorder.png");
    }
    private PackedLinearColorA GetColorFromLosFlags(byte flags)
    {
        var color = new PackedLinearColorA(0, 0, 0, 0);

        /*if ((flags & LineOfSightBuffer.BLOCKING) != 0)
         * {
         *  color.R = 255;
         *  color.A = 255;
         * }
         *
         * if ((flags & LineOfSightBuffer.UNK) != 0)
         * {
         *  color.G = 255;
         *  color.A = 255;
         * }
         *
         * if ((flags & LineOfSightBuffer.UNK1) != 0)
         * {
         *  color.B = 255;
         *  color.A = 255;
         * }*/

        if ((flags & LineOfSightBuffer.ARCHWAY) != 0)
        {
            color.G = 255;
            color.A = 255;
        }

        return(color);
    }
    public void Render(WorldCamera camera, int elapsedMs, Vector3 target)
    {
        // Increasing the line segment length here will essentially increase the frequency,
        // which leads to a better look compared to vanilla. We can't replicate the original 1:1
        // because we actually draw the lightning in screen space
        CalculateLineJitter(elapsedMs, LineSegments, LineSegmentLength * 1.5f, 0);

        // Call lightning ramps alpha from 1->0 in 127 millisecond intervals using cosine to create quick
        // "flashes" of lightning.
        // You can visualize the ramp in Wolfram Alpha:
        // https://www.wolframalpha.com/input/?i=plot+cos%28%28x+mod+127%29+%2F+254+*+PI%29+from+x%3D0+to+768
        var alphaRamp = MathF.Cos(elapsedMs % 127 / 127f * 0.5f * MathF.PI);
        var alpha     = (byte)(alphaRamp * 255);
        var color     = new PackedLinearColorA(alpha, alpha, alpha, alpha);

        // These are normals for screen-space pixels
        var(right, up) = camera.GetBillboardNormals();

        // Vector used to extrude the line to it's intended screen-space width
        var extrudeVec = ArcWidth / 2 * right;

        for (var i = 0; i < LineSegments; i++)
        {
            ref var leftVertex  = ref Vertices[i * 2];
            ref var rightVertex = ref Vertices[i * 2 + 1];
 public ColorRect(PackedLinearColorA fill)
 {
     topLeft     = fill;
     topRight    = fill;
     bottomLeft  = fill;
     bottomRight = fill;
 }
Beispiel #6
0
    /*
     *  occludedOnly means that the circle will only draw
     *  in already occluded areas (based on depth buffer)
     */
    public void DrawFilledCircle(IGameViewport viewport,
                                 Vector3 center,
                                 float radius,
                                 PackedLinearColorA borderColor,
                                 PackedLinearColorA fillColor,
                                 bool occludedOnly = false)
    {
        // The positions array contains the following:
        // 0 . The center of the circle
        // 1 - (sCircleSegments + 1) . Positions on the diameter of the circle
        // sCircleSegments + 2 . The first position again to close the circle
        Span <Vector3> positions = stackalloc Vector3[CircleSegments + 3];

        // A full rotation divided by the number of segments
        var rotPerSegment = 2 * MathF.PI / CircleSegments;

        positions[0] = center;
        for (var i = 1; i < CircleSegments + 3; ++i)
        {
            var rot = (CircleSegments - i) * rotPerSegment;
            positions[i].X = center.X + MathF.Cos(rot) * radius - MathF.Sin(rot) * 0.0f;
            positions[i].Y = center.Y;
            positions[i].Z = center.Z + MathF.Cos(rot) * 0.0f + MathF.Sin(rot) * radius;
        }

        positions[^ 1] = positions[1];
Beispiel #7
0
    private static void RenderCurrentGoalPath(IGameViewport viewport, GameObject obj)
    {
        var slot = GameSystems.Anim.GetSlot(obj);

        if (slot == null || !slot.path.IsComplete)
        {
            return;
        }

        var renderer3d = Tig.ShapeRenderer3d;

        var color             = PackedLinearColorA.OfFloats(1.0f, 1.0f, 1.0f, 0.5f);
        var circleBorderColor = PackedLinearColorA.OfFloats(1.0f, 1.0f, 1.0f, 1.0f);
        var circleFillColor   = PackedLinearColorA.OfFloats(0.0f, 0.0f, 0.0f, 0.0f);

        var currentPos = obj.GetLocationFull().ToInches3D();

        for (int i = slot.path.currentNode; i + 1 < slot.path.nodeCount; i++)
        {
            var nextPos = slot.path.nodes[i].ToInches3D();
            renderer3d.DrawLineWithoutDepth(viewport, currentPos, nextPos, color);
            renderer3d.DrawFilledCircle(viewport, nextPos, 4, circleBorderColor, circleFillColor, false);
            renderer3d.DrawFilledCircle(viewport, nextPos, 4, circleBorderColor, circleFillColor, true);
            currentPos = nextPos;
        }

        // Draw the last path node
        var pathTo = slot.path.to.ToInches3D();

        renderer3d.DrawLineWithoutDepth(viewport, currentPos, pathTo, color);
        renderer3d.DrawFilledCircle(viewport, pathTo, 4, circleBorderColor, circleFillColor, false);
        renderer3d.DrawFilledCircle(viewport, pathTo, 4, circleBorderColor, circleFillColor, true);
    }
    public override void Render()
    {
        var buttonState = ForceVisible ? LgcyButtonState.Hovered : ButtonState;

        if (buttonState != _lastButtonState)
        {
            _lastButtonState = buttonState;
            if (buttonState == LgcyButtonState.Hovered)
            {
                if (float.IsNaN(_animationPhase))
                {
                    _time           = TimePoint.Now;
                    _time          -= TimeSpan.FromMilliseconds(1);
                    _animationPhase = 0;
                }
                else
                {
                    _time  = TimePoint.Now;
                    _time += TimeSpan.FromMilliseconds((int)(_animationPhase * -1000.0f));
                    _trend = 1;
                }
            }
            else if (buttonState == LgcyButtonState.Normal)
            {
                _time += TimeSpan.FromMilliseconds((int)(_animationPhase * -333.3f));
                _trend = -1;
                _time  = TimePoint.Now;
            }
        }

        if (_animationPhase >= 0.0f)
        {
            if (_trend == 1)
            {
                _animationPhase = (float)(TimePoint.Now - _time).TotalMilliseconds / 333.3f;
            }
            else
            {
                _animationPhase = (1000.0f - (float)(TimePoint.Now - _time).TotalMilliseconds)
                                  * 0.001f;
            }

            _animationPhase = Math.Clamp(_animationPhase, 0, 1);
        }

        var currentSize   = (int)(_animationPhase * 2 * _radius);
        var currentOffset = (int)((1.0f - _animationPhase) * _radius);

        _ringImage.X         = currentOffset;
        _ringImage.Y         = currentOffset;
        _ringImage.FixedSize = new Size(currentSize, currentSize);

        if (_animationPhase > 0)
        {
            _ringImage.Color = PackedLinearColorA.OfFloats(1.0f, 1.0f, 1.0f, _animationPhase);
        }

        base.Render();
    }
 public MovieSubtitleLine(int startTime, int duration, string fontName, PackedLinearColorA color, string text)
 {
     StartTime = startTime;
     Duration  = duration;
     FontName  = fontName;
     Color     = color;
     Text      = text;
 }
Beispiel #10
0
 public void DrawRectangle(
     Rectangle rectangle,
     ITexture texture,
     PackedLinearColorA color,
     SamplerType2d samplerType = SamplerType2d.CLAMP
     )
 {
     DrawRectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, texture, color, samplerType);
 }
Beispiel #11
0
    private void BindQuadMaterial(IGameViewport viewport, PackedLinearColorA color, ITexture texture)
    {
        _device.SetMaterial(_quadMaterial);

        Shape3dGlobals globals;

        globals.viewProj = viewport.Camera.GetViewProj();
        globals.colors   = color.ToRGBA();

        _device.SetVertexShaderConstants(0, ref globals);

        _device.SetTexture(0, texture);
    }
Beispiel #12
0
    public void DrawQuad(IGameViewport viewport,
                         ReadOnlySpan <ShapeVertex3d> corners,
                         PackedLinearColorA color,
                         ITexture texture)
    {
        _discVertexBuffer.Resource.Update(corners);
        _discBufferBinding.Resource.Bind();

        BindQuadMaterial(viewport, color, texture);

        _device.SetIndexBuffer(_discIndexBuffer);
        _device.DrawIndexed(PrimitiveType.TriangleList, 4, 2 * 3);
    }
Beispiel #13
0
    public void DrawRectangleOutline(Rectangle rectangle, PackedLinearColorA color)
    {
        var topLeft     = new Vector2(rectangle.Left + 0.5f, rectangle.Top + 0.5f);
        var topRight    = new Vector2(rectangle.Right - 0.5f, rectangle.Top + 0.5f);
        var bottomRight = new Vector2(rectangle.Right - 0.5f, rectangle.Bottom - 0.5f);
        var bottomLeft  = new Vector2(rectangle.Left + 0.5f, rectangle.Bottom - 0.5f);

        Span <Line2d> lines = stackalloc Line2d[4];

        lines[0] = new Line2d(topLeft, topRight, color);
        lines[1] = new Line2d(topRight, bottomRight, color);
        lines[2] = new Line2d(bottomRight, bottomLeft, color);
        lines[3] = new Line2d(bottomLeft, topLeft, color);
        DrawLines(lines);
    }
    public void TestNonRichTextRendering()
    {
        var styles = Globals.UiStyles.StyleResolver.Resolve(new[]
        {
            new StyleDefinition()
            {
                Color     = PackedLinearColorA.FromHex("#AAAAAA"),
                FontSize  = 20,
                Underline = true
            }
        });

        using var layout = Device.TextEngine.CreateTextLayout(styles, "Hello World", 250, 250);
        RenderAndCompare(layout, "Core/GFX/TextRendering/NonRichTextLayout.png");
    }
Beispiel #15
0
    public void DrawQuad(IGameViewport viewport, ReadOnlySpan <ShapeVertex3d> corners,
                         IMdfRenderMaterial material,
                         PackedLinearColorA color)
    {
        _discVertexBuffer.Resource.Update(corners);
        _discBufferBinding.Resource.Bind();

        MdfRenderOverrides overrides = new MdfRenderOverrides();

        overrides.overrideDiffuse = true;
        overrides.overrideColor   = color;
        material.Bind(viewport, _device, null, overrides);

        _device.SetIndexBuffer(_discIndexBuffer);
        _device.DrawIndexed(PrimitiveType.TriangleList, 4, 2 * 3);
    }
Beispiel #16
0
    public void DrawLine(IGameViewport viewport,
                         Vector3 from,
                         Vector3 to,
                         PackedLinearColorA color)
    {
        Span <Vector3> positions = stackalloc Vector3[]
        {
            from,
            to
        };

        _lineVertexBuffer.Resource.Update <Vector3>(positions);
        _lineBinding.Resource.Bind();
        BindLineMaterial(viewport, color);

        _device.Draw(PrimitiveType.LineList, 2);
    }
Beispiel #17
0
    public void DrawRectangleOutline(Vector2 topLeft, Vector2 bottomRight, PackedLinearColorA color)
    {
        topLeft.X     += 0.5f;
        topLeft.Y     += 0.5f;
        bottomRight.X -= 0.5f;
        bottomRight.Y -= 0.5f;

        var topRight   = new Vector2(bottomRight.X, topLeft.Y);
        var bottomLeft = new Vector2(topLeft.X, bottomRight.Y);

        Span <Line2d> lines = stackalloc Line2d[4];

        lines[0] = new Line2d(topLeft, topRight, color);
        lines[1] = new Line2d(topRight, bottomRight, color);
        lines[2] = new Line2d(bottomRight, bottomLeft, color);
        lines[3] = new Line2d(bottomLeft, topLeft, color);
        DrawLines(lines);
    }
Beispiel #18
0
    private void BindLineMaterial(IGameViewport viewport, PackedLinearColorA color, bool occludedOnly = false)
    {
        if (occludedOnly)
        {
            _device.SetMaterial(_lineOccludedMaterial);
        }
        else
        {
            _device.SetMaterial(_lineMaterial);
        }

        Shape3dGlobals globals;

        globals.viewProj = viewport.Camera.GetViewProj();
        globals.colors   = color.ToRGBA();

        _device.SetVertexShaderConstants(0, ref globals);
    }
    private void RenderDebugInfo(IGameViewport gameViewport, PartSys sys)
    {
        var screenPos    = gameViewport.WorldToScreen(sys.WorldPos);
        var screenX      = screenPos.X;
        var screenY      = screenPos.Y;
        var screenBounds = sys.GetScreenBounds();

        var left   = screenX + screenBounds.left * gameViewport.Zoom;
        var top    = screenY + screenBounds.top * gameViewport.Zoom;
        var right  = screenX + screenBounds.right * gameViewport.Zoom;
        var bottom = screenY + screenBounds.bottom * gameViewport.Zoom;

        var color = new PackedLinearColorA(0, 0, 255, 255);

        Span <Line2d> lines = stackalloc Line2d[4]
        {
            new Line2d(new Vector2(left, top), new Vector2(right, top), color),
            new Line2d(new Vector2(right, top), new Vector2(right, bottom), color),
            new Line2d(new Vector2(right, bottom), new Vector2(left, bottom), color),
            new Line2d(new Vector2(left, bottom), new Vector2(left, top), color)
        };

        _shapeRenderer2d.DrawLines(lines);

        var textEngine = Tig.RenderingDevice.TextEngine;

        var text = $"{sys.GetSpec().GetName()}";

        var style   = Globals.UiStyles.GetComputed("default");
        var metrics = textEngine.MeasureText(style, text, (int)(right - left), (int)(bottom - top));

        textEngine.RenderText(
            new RectangleF(
                (left + right - metrics.width) / 2f,
                (top + bottom - metrics.height) / 2f,
                (int)(right - left),
                (int)(bottom - top)
                ),
            style,
            text
            );
    }
}
Beispiel #20
0
    private SimpleMesh BuildSubTileMesh(RenderingDevice device, VertexShader shader, Sector sector)
    {
        var builder = new SubTileMeshBuilder(sector.secLoc);

        for (int y = 0; y < Sector.SectorSideSize; y++)
        {
            for (int x = 0; x < Sector.SectorSideSize; x++)
            {
                var tileIdx = Sector.GetSectorTileIndex(x, y);
                var tile    = sector.tilePkt.tiles[tileIdx];

                for (int dx = 0; dx < 3; dx++)
                {
                    for (int dy = 0; dy < 3; dy++)
                    {
                        var blockFlag   = SectorTile.GetBlockingFlag(dx, dy);
                        var flyOverFlag = SectorTile.GetFlyOverFlag(dx, dy);
                        var blocking    = tile.flags.HasFlag(blockFlag);
                        var flyover     = tile.flags.HasFlag(flyOverFlag);

                        PackedLinearColorA color;
                        if (blocking)
                        {
                            color = new PackedLinearColorA(200, 0, 0, 127);
                        }
                        else if (flyover)
                        {
                            color = new PackedLinearColorA(127, 0, 127, 127);
                        }
                        else
                        {
                            continue;
                        }

                        builder.Add(x * 3 + dx, y * 3 + dy, color);
                    }
                }
            }
        }

        return(builder.Build(shader));
    }
    public void Add(int x, int y, PackedLinearColorA color)
    {
        int topLeftIdx     = _vertexCount++;
        int topRightIdx    = _vertexCount++;
        int bottomRightIdx = _vertexCount++;
        int bottomLeftIdx  = _vertexCount++;

        EnsureVertexCapacity(_vertexCount);

        float subtileX = _basePos.X + x * locXY.INCH_PER_SUBTILE;
        float subtileY = _basePos.Y + y * locXY.INCH_PER_SUBTILE;

        _vertices[topLeftIdx] = new Vertex
        {
            diffuse = color,
            pos     = new Vector4(subtileX, 0, subtileY, 1)
        };
        _vertices[topRightIdx] = new Vertex
        {
            diffuse = color,
            pos     = new Vector4(subtileX + locXY.INCH_PER_SUBTILE, 0, subtileY, 1)
        };
        _vertices[bottomRightIdx] = new Vertex
        {
            diffuse = color,
            pos     = new Vector4(subtileX + locXY.INCH_PER_SUBTILE, 0,
                                  subtileY + locXY.INCH_PER_SUBTILE, 1)
        };
        _vertices[bottomLeftIdx] = new Vertex
        {
            diffuse = color,
            pos     = new Vector4(subtileX, 0, subtileY + locXY.INCH_PER_SUBTILE, 1)
        };

        EnsureIndexCapacity(_indexCount + 6);
        _indices[_indexCount++] = topLeftIdx;
        _indices[_indexCount++] = bottomLeftIdx;
        _indices[_indexCount++] = bottomRightIdx;
        _indices[_indexCount++] = bottomRightIdx;
        _indices[_indexCount++] = topRightIdx;
        _indices[_indexCount++] = topLeftIdx;
    }
Beispiel #22
0
    /// <summary>
    /// Renders a circle/pie segment for use with the radial menu.
    /// </summary>
    public void DrawPieSegment(int segments,
                               int x, int y,
                               float angleCenter, float angleWidth,
                               float innerRadius, float innerOffset,
                               float outerRadius, float outerOffset,
                               PackedLinearColorA color1, PackedLinearColorA color2)
    {
        Trace.Assert(segments <= MaxSegments);

        var posCount = segments * 2 + 2;

        // There are two positions for the start and 2 more for each segment thereafter
        const int       MaxPositions = MaxSegments * 2 + 2;
        Span <Vertex2d> vertices     = stackalloc Vertex2d[MaxPositions];

        var angleStep  = angleWidth / (posCount);
        var angleStart = angleCenter - angleWidth * 0.5f;

        // We generate one more position because of the starting points
        for (var i = 0; i < posCount; ++i)
        {
            var     angle = angleStart + i * angleStep;
            ref var pos   = ref vertices[i].pos;
            vertices[i].diffuse = color1;

            // The generated positions alternate between the outside
            // and inner circle
            if (i % 2 == 0)
            {
                pos.X = x + MathF.Cos(angle) * innerRadius - MathF.Sin(angle) * innerOffset;
                pos.Y = y + MathF.Sin(angle) * innerRadius + MathF.Cos(angle) * innerOffset;
            }
            else
            {
                pos.X = x + MathF.Cos(angle) * outerRadius - MathF.Sin(angle) * outerOffset;
                pos.Y = y + MathF.Sin(angle) * outerRadius + MathF.Cos(angle) * outerOffset;
            }

            pos.Z = 0;
            pos.W = 1;
        }
    public StatsUiParams(
        Rectangle mainWindowRectangle,
        Dictionary <int, string> settings,
        Dictionary <int, string> textures,
        Dictionary <int, string> translations)
    {
        void LoadRectangle(out Rectangle rect, int baseId, bool makeRelative = false)
        {
            rect = new Rectangle(
                int.Parse(settings[baseId]),
                int.Parse(settings[baseId + 1]),
                int.Parse(settings[baseId + 2]),
                int.Parse(settings[baseId + 3])
                );
            if (makeRelative)
            {
                rect.X -= MainWindow.X;
                rect.Y -= MainWindow.Y;
            }
        }

        void LoadColor(out PackedLinearColorA color, int baseId)
        {
            color = new PackedLinearColorA(
                byte.Parse(settings[baseId]),
                byte.Parse(settings[baseId + 1]),
                byte.Parse(settings[baseId + 2]),
                byte.Parse(settings[baseId + 3])
                );
        }

        LoadRectangle(out MainWindow, 0);
        LoadRectangle(out PlatinumButton, 5, true);
        LoadRectangle(out GoldButton, 10, true);
        LoadRectangle(out SilverButton, 14, true);
        LoadRectangle(out CopperButton, 20, true);

        LoadRectangle(out XpLabel, 400, true);
        LoadRectangle(out XpValue, 740, true);
        LoadRectangle(out LevelLabel, 420, true);
        LoadRectangle(out LevelValue, 760, true);
        LoadRectangle(out StrLabel, 440, true);
        LoadRectangle(out StrValue, 780, true);
        LoadRectangle(out StrBonusValue, 980, true);
        LoadRectangle(out DexLabel, 460, true);
        LoadRectangle(out DexValue, 820, true);
        LoadRectangle(out DexBonusValue, 1000, true);
        LoadRectangle(out ConLabel, 480, true);
        LoadRectangle(out ConValue, 840, true);
        LoadRectangle(out ConBonusValue, 1020, true);
        LoadRectangle(out IntLabel, 500, true);
        LoadRectangle(out IntValue, 860, true);
        LoadRectangle(out IntBonusValue, 1040, true);
        LoadRectangle(out WisLabel, 520, true);
        LoadRectangle(out WisValue, 880, true);
        LoadRectangle(out WisBonusValue, 1060, true);
        LoadRectangle(out ChaLabel, 540, true);
        LoadRectangle(out ChaValue, 900, true);
        LoadRectangle(out ChaBonusValue, 1080, true);

        LoadRectangle(out HpLabel, 560, true);
        LoadRectangle(out HpValue, 940, true);
        LoadRectangle(out AcLabel, 580, true);
        LoadRectangle(out AcValue, 960, true);

        LoadRectangle(out FortLabel, 600, true);
        LoadRectangle(out FortValue, 1100, true);
        LoadRectangle(out RefLabel, 620, true);
        LoadRectangle(out RefValue, 1120, true);
        LoadRectangle(out WillLabel, 640, true);
        LoadRectangle(out WillValue, 1140, true);

        LoadRectangle(out HeightLabel, 649, true);
        LoadRectangle(out HeightValue, 1148, true);
        LoadRectangle(out WeightLabel, 653, true);
        LoadRectangle(out WeightValue, 1152, true);

        LoadRectangle(out InitLabel, 660, true);
        LoadRectangle(out InitValue, 1160, true);
        LoadRectangle(out PrimaryAtkLabel, 680, true);
        PrimaryAtkLabelText = translations[10];
        LoadRectangle(out PrimaryAtkValue, 1180, true);
        LoadRectangle(out SecondaryAtkLabel, 700, true);
        SecondaryAtkLabelText = translations[20];
        LoadRectangle(out SecondaryAtkValue, 1200, true);
        LoadRectangle(out SpeedLabel, 720, true);
        LoadRectangle(out SpeedValue, 1220, true);

        var normalFont     = settings[260];
        var normalFontSize = int.Parse(settings[261]);
        var boldFont       = settings[270];
        var boldFontSize   = int.Parse(settings[271]);
        var moneyFont      = settings[280];
        var moneyFontSize  = int.Parse(settings[281]);

        // LoadColor(out FontNormalColor, 300);
        // LoadColor(out FontDarkColor, 319);

        // TooltipUiStyle = int.Parse(settings[200]);

        MainWindow.X -= mainWindowRectangle.X;
        MainWindow.Y -= mainWindowRectangle.Y;

        foreach (var texture in (StatsUiTexture[])Enum.GetValues(typeof(StatsUiTexture)))
        {
            TexturePaths[texture] = "art/interface/char_ui/char_stats_ui/" + textures[(int)texture];
        }
    }
Beispiel #24
0
    private void UiCombatActionBarRender(WidgetContainer container)
    {
        // Get the on-screen content rect
        var contentRect = container.GetContentArea();

        var v21      = true;
        var tbStatus = GameSystems.D20.Actions.curSeqGetTurnBasedStatus()?.Copy();

        if (GameSystems.Combat.IsCombatActive() && tbStatus != null)
        {
            var actor = GameSystems.D20.Initiative.CurrentActor;
            if (uiCombat_10C040B0)
            {
                if (!GameSystems.D20.Actions.IsCurrentlyPerforming(actor))
                {
                    uiCombat_10C040B0 = false;
                    if (GameSystems.Party.IsPlayerControlled(actor))
                    {
                        Logger.Info("Combat UI for {0} ending turn (button)...", actor);
                        GameSystems.Combat.AdvanceTurn(actor);
                    }
                }
            }

            // TODO ui_render_img_file/*0x101e8460*/(dword_10C04088/*0x10c04088*/, uiCombatMainWndX/*0x10c04040*/, uiCombatMainWndY/*0x10c04044*/);
            if (GameSystems.Combat.IsCombatActive() &&
                GameSystems.Party.IsPlayerControlled(GameSystems.D20.Initiative.CurrentActor) && !uiCombat_10C040B0)
            {
                var maxFullRoundMoveDist = UiCombatActionBarGetMaximumMoveDistance();
                if (maxFullRoundMoveDist <= 0.0f)
                {
                    maxFullRoundMoveDist = 30.0f;
                }

                if (actor != actionBarActor)
                {
                    GameSystems.Vagrant.ActionBarStopActivity(_actionBar);
                    actionBarEndingMoveDist = 0;
                }

                float actualRemainingMoveDist;
                if (GameSystems.Vagrant.ActionBarIsActive(_actionBar))
                {
                    actualRemainingMoveDist = GameSystems.Vagrant.ActionBarGetValue(_actionBar);
                    v21 = false;
                }
                else if (GameSystems.D20.Actions.IsCurrentlyPerforming(actor))
                {
                    actualRemainingMoveDist = actionBarEndingMoveDist;
                    v21 = false;
                }
                else
                {
                    actualRemainingMoveDist = UiCombatActionBarGetRemainingMoveDistance(tbStatus);
                }

                var factor = Math.Clamp(actualRemainingMoveDist / maxFullRoundMoveDist, 0.0f, 1.0f);

                var v13 = (int)(contentRect.Height * factor);
                int v14 = v13;
                if (v13 > 0)
                {
                    var a1  = new Render2dArgs();
                    var v22 = new Rectangle(0,
                                            contentRect.Height - v13,
                                            contentRect.Width,
                                            v13);

                    var v23 = new Rectangle(
                        contentRect.X,
                        contentRect.Y + contentRect.Height - v13,
                        v22.Width,
                        v22.Height
                        );
                    a1.customTexture = _combatBarFill.Resource;
                    a1.srcRect       = v22;
                    a1.destRect      = v23;
                    a1.flags         = Render2dFlag.BUFFERTEXTURE;
                    Tig.ShapeRenderer2d.DrawRectangle(ref a1);
                }

                if (UiIntgameActionbarShouldUpdate() && v21)
                {
                    if (GameSystems.D20.Actions.seqCheckFuncs(out tbStatus) != ActionErrorCode.AEC_OK)
                    {
                        UiCombatActionBarDrawButton(contentRect, _combatBarFillInvalid.Resource);
                    }
                    else
                    {
                        var v16 = Math.Clamp(
                            UiCombatActionBarGetRemainingMoveDistance(tbStatus) / maxFullRoundMoveDist, 0.0f, 1.0f);
                        int v17 = v14 - (int)(contentRect.Height * v16);
                        if (v17 >= 1)
                        {
                            Render2dArgs a1      = new Render2dArgs();
                            var          srcRect = new Rectangle(
                                0,
                                contentRect.Height - v14,
                                contentRect.Width,
                                v17
                                );
                            var destRect = new Rectangle(
                                contentRect.X,
                                srcRect.Y + contentRect.Y,
                                srcRect.Width,
                                srcRect.Height
                                );
                            a1.flags = Render2dFlag.BUFFERTEXTURE | Render2dFlag.VERTEXCOLORS |
                                       Render2dFlag.VERTEXALPHA;
                            a1.srcRect       = srcRect;
                            a1.destRect      = destRect;
                            a1.customTexture = _combatBarHighlight2.Resource;

                            var alpha = GameSystems.Vagrant.ActionBarGetValue(_pulseAnimation);
                            var color = new PackedLinearColorA(255, 255, 255, (byte)alpha);
                            a1.vertexColors = new[]
                            {
                                color, color, color, color
                            };

                            if (v17 > 0)
                            {
                                Tig.ShapeRenderer2d.DrawRectangle(ref a1);
                            }
                        }
                    }
                }
            }
            else
            {
                UiCombatActionBarDrawButton(contentRect, _combatBarGrey.Resource);
            }
        }
    }
Beispiel #25
0
 public Brush(PackedLinearColorA fillColor)
 {
     gradient       = false;
     primaryColor   = fillColor;
     secondaryColor = fillColor;
 }
Beispiel #26
0
    public CharUiParams(Dictionary <int, string> settings, Dictionary <int, string> textures)
    {
        void LoadRectangle(out Rectangle rect, int baseId, bool makeRelative = false)
        {
            rect = new Rectangle(
                int.Parse(settings[baseId]),
                int.Parse(settings[baseId + 1]),
                int.Parse(settings[baseId + 2]),
                int.Parse(settings[baseId + 3])
                );
            if (makeRelative)
            {
                rect.X -= CharUiMainWindow.X;
                rect.Y -= CharUiMainWindow.Y;
            }
        }

        void LoadColor(out PackedLinearColorA color, int baseId)
        {
            color = new PackedLinearColorA(
                byte.Parse(settings[baseId]),
                byte.Parse(settings[baseId + 1]),
                byte.Parse(settings[baseId + 2]),
                byte.Parse(settings[baseId + 3])
                );
        }

        void LoadPoint(out Point point, int baseId, bool makeRelative = false)
        {
            point = new Point(
                int.Parse(settings[baseId]),
                int.Parse(settings[baseId + 1])
                );
            if (makeRelative)
            {
                point.X -= CharUiMainWindow.X;
                point.Y -= CharUiMainWindow.Y;
            }
        }

        void LoadSize(out Size point, int baseId)
        {
            point = new Size(
                int.Parse(settings[baseId]),
                int.Parse(settings[baseId + 1])
                );
        }

        LoadRectangle(out CharUiMainWindow, 0);
        LoadColor(out BorderOutside, 10);
        LoadColor(out BorderInside, 14);
        FontName      = settings[18];
        FontSize      = int.Parse(settings[19]);
        FontSmallName = settings[20];
        FontSmallSize = int.Parse(settings[21]);
        LoadPoint(out NameClassesLevel, 22, true);
        LoadPoint(out AlignmentGenderRaceWorship, 24, true);
        FontBig     = settings[26];
        FontBigSize = int.Parse(settings[27]);
        LoadRectangle(out CharUiMainExitButton, 30, true);
        LoadRectangle(out CharUiMainTextField, 40, true);
        LoadRectangle(out CharUiSelectInventory0Button, 60, true);
        LoadRectangle(out CharUiSelectInventory1Button, 80, true);
        LoadRectangle(out CharUiSelectInventory2Button, 100, true);
        LoadRectangle(out CharUiSelectInventory3Button, 120, true);
        LoadRectangle(out CharUiSelectInventory4Button, 140, true);
        LoadRectangle(out CharUiSelectSkillsButton, 160, true);
        LoadRectangle(out CharUiSelectFeatsButton, 180, true);
        LoadRectangle(out CharUiSelectSpellsButton, 200, true);
        LoadRectangle(out CharUiSelectAbilitiesButton, 210, true);
        LoadRectangle(out CharUiMainEditorClassButton, 220, true);
        LoadRectangle(out CharUiMainEditorStatsButton, 224, true);
        LoadRectangle(out CharUiMainEditorFeatsButton, 228, true);
        LoadRectangle(out CharUiMainEditorSkillsButton, 232, true);
        LoadRectangle(out CharUiMainEditorSpellsButton, 236, true);
        LoadRectangle(out CharUiMainEditorFinishButton, 240, true);
        LoadColor(out FontNormalColor, 260);
        LoadColor(out FontDarkColor, 280);
        LoadColor(out FontHighlightColor, 300);
        LoadSize(out TabLeft, 320);
        LoadSize(out TabFill, 340);
        LoadRectangle(out InnerWindowBorder, 360);
        CharUiModeXNormal  = int.Parse(settings[380]);
        CharUiModeXLooting = int.Parse(settings[381]);
        CharUiModeXLevelUp = int.Parse(settings[382]);
        LoadRectangle(out CharUiMainNavEditorWindow, 400, true);
        CharUiMainNavFontOffsetX = int.Parse(settings[420]);
        LoadRectangle(out CharUiMainNameButton, 500, true);
        LoadRectangle(out CharUiMainClassLevelButton, 520, true);
        LoadRectangle(out CharUiMainAlignmentGenderRaceButton, 540, true);
        LoadRectangle(out CharUiMainWorshipButton, 560, true);
        TooltipUiStyle = int.Parse(settings[200]);

        foreach (var texture in (CharUiTexture[])Enum.GetValues(typeof(CharUiTexture)))
        {
            TexturePaths[texture] = "art/interface/char_ui/" + textures[(int)texture];
        }
    }
Beispiel #27
0
 public Line2d(Vector2 from, Vector2 to, PackedLinearColorA diffuse)
 {
     this.from    = from;
     this.to      = to;
     this.diffuse = diffuse;
 }
Beispiel #28
0
    private void BindShader([MaybeNull] WorldCamera camera,
                            RenderingDevice device,
                            IList <Light3d> lights,
                            MdfRenderOverrides overrides)
    {
        // Fill out the globals for the shader
        var globals = new MdfGlobalConstants();

        Matrix4x4 viewProj;

        if (overrides != null && overrides.uiProjection)
        {
            viewProj = device.UiProjection;
        }
        else
        {
            viewProj = camera?.GetViewProj() ?? device.UiProjection;
        }

        // Should we use a separate world matrix?
        if (overrides != null && overrides.useWorldMatrix)
        {
            // Build a world * view * proj matrix
            var worldViewProj = overrides.worldMatrix * viewProj;
            globals.viewProj = worldViewProj;
        }
        else
        {
            globals.viewProj = viewProj;
        }

        // Set material diffuse color for shader
        Vector4 color;

        // TODO: This is a bug, it should check overrideDiffuse
        if (overrides != null && overrides.overrideColor != default)
        {
            color = overrides.overrideColor.ToRGBA();
        }
        else
        {
            color = new PackedLinearColorA(mSpec.diffuse).ToRGBA();
        }

        globals.matDiffuse = color;
        if (overrides != null && overrides.alpha != 1.0f)
        {
            globals.matDiffuse.W *= overrides.alpha;
        }

        // Set time for UV animation in minutes as a floating point number
        var timeInSec = (float)(device.GetLastFrameStart() - device.GetDeviceCreated()).Seconds;

        globals.uvAnimTime.X = timeInSec / 60.0f;
        // Clamp to [0, 1]
        if (globals.uvAnimTime.X > 1)
        {
            globals.uvAnimTime.X -= MathF.Floor(globals.uvAnimTime.X);
        }

        // Swirl is more complicated due to cos/sin involvement
        // This means speedU is in "full rotations every 60 seconds" . RPM
        var uvRotations = globals.UvRotations;

        for (var i = 0; i < mSpec.samplers.Count; ++i)
        {
            var sampler = mSpec.samplers[i];
            if (sampler.uvType != MdfUvType.Swirl)
            {
                continue;
            }

            ref var uvRot = ref uvRotations[i];
            uvRot.X = MathF.Cos(sampler.speedU * globals.uvAnimTime.X * MathF.PI * 2) * 0.1f;
            uvRot.Y = MathF.Sin(sampler.speedV * globals.uvAnimTime.X * MathF.PI * 2) * 0.1f;
        }