Ejemplo n.º 1
0
    private void UiCombatActionBarDrawButton(Rectangle rect, ITexture texture)
    {
        var args = new Render2dArgs();

        args.srcRect       = new Rectangle(0, 0, rect.Width, rect.Height);
        args.destRect      = rect;
        args.flags         = Render2dFlag.BUFFERTEXTURE;
        args.customTexture = texture;
        Tig.ShapeRenderer2d.DrawRectangle(ref args);
    }
    public void Render(IGameViewport viewport, LocAndOffsets location, ITexture texture)
    {
        var screenPos = viewport.WorldToScreen(location.ToInches3D());

        var contentRect = texture.GetContentRect();
        var renderArgs  = new Render2dArgs
        {
            srcRect  = contentRect,
            flags    = Render2dFlag.BUFFERTEXTURE,
            destRect = new Rectangle(
                (int)(screenPos.X - contentRect.Width / 2),
                (int)(screenPos.Y - contentRect.Height / 2),
                contentRect.Width,
                contentRect.Height
                ),
            customTexture = texture
        };

        Tig.ShapeRenderer2d.DrawRectangle(ref renderArgs);
    }
Ejemplo n.º 3
0
    public override void Render()
    {
        if (!mTexture.IsValid)
        {
            return;
        }

        var renderer = Tig.ShapeRenderer2d;

        if (SourceRect.HasValue)
        {
            var drawArgs = new Render2dArgs();
            drawArgs.srcRect       = SourceRect.Value;
            drawArgs.destRect      = ContentArea;
            drawArgs.customTexture = mTexture.Resource;
            drawArgs.flags         = Render2dFlag.BUFFERTEXTURE;
            if (Color != PackedLinearColorA.White)
            {
                drawArgs.flags       |= Render2dFlag.VERTEXALPHA | Render2dFlag.VERTEXCOLORS;
                drawArgs.vertexColors = new[]
                {
                    Color,
                    Color,
                    Color,
                    Color
                };
            }
            renderer.DrawRectangle(ref drawArgs);
        }
        else
        {
            renderer.DrawRectangle(
                ContentArea.X,
                ContentArea.Y,
                ContentArea.Width,
                ContentArea.Height,
                mTexture.Resource,
                Color
                );
        }
    }
        public void RenderTownmapTiles(Rectangle srcRect, Rectangle destRect, float widthScale, float heightScale)
        {
            var rightmostTile = (srcRect.X + srcRect.Width) / _tileDimension;

            if (rightmostTile >= _cols)
            {
                rightmostTile = _cols;
            }

            var bottommostTile = (srcRect.Y + srcRect.Height) / _tileDimension;

            if (bottommostTile >= _rows)
            {
                bottommostTile = _rows;
            }

            var startTileX = srcRect.X / _tileDimension;

            if (srcRect.X / _tileDimension < 0)
            {
                startTileX = 0;
            }

            var startTileY = srcRect.Y / _tileDimension;

            if (srcRect.Y / _tileDimension < 0)
            {
                startTileY = 0;
            }

            for (var tileY = startTileY; tileY <= bottommostTile; ++tileY)
            {
                var curSrcY = tileY * _tileDimension;

                for (var tileX = startTileX; tileX <= rightmostTile; ++tileX)
                {
                    var curSrcX         = tileX * _tileDimension;
                    var clippedSrcX     = tileX * (float)_tileDimension;
                    var clippedSrcWidth = clippedSrcX + _tileDimension;
                    if (clippedSrcX < srcRect.X)
                    {
                        clippedSrcX = srcRect.X;
                    }

                    var srcRectRight = (float)(srcRect.X + srcRect.Width);
                    if (clippedSrcWidth > srcRectRight)
                    {
                        clippedSrcWidth = srcRectRight;
                    }

                    clippedSrcWidth = clippedSrcWidth - clippedSrcX;

                    var clippedSrcY      = tileY * (float)_tileDimension;
                    var clippedSrcHeight = clippedSrcY + _tileDimension;
                    if (clippedSrcY < srcRect.Y)
                    {
                        clippedSrcY = srcRect.Y;
                    }

                    var srcRectBottom = (float)(srcRect.Y + srcRect.Height);
                    if (clippedSrcHeight > srcRectBottom)
                    {
                        clippedSrcHeight = srcRectBottom;
                    }
                    clippedSrcHeight -= clippedSrcY;

                    Rectangle tileDestRect = default;
                    tileDestRect.X     = destRect.X + (int)((clippedSrcX - srcRect.X) * widthScale);
                    tileDestRect.Y     = destRect.Y + (int)((clippedSrcY - srcRect.Y) * heightScale);
                    tileDestRect.Width = destRect.X +
                                         (int)((clippedSrcX + clippedSrcWidth - srcRect.X) * widthScale) -
                                         tileDestRect.X;
                    tileDestRect.Height = destRect.Y +
                                          (int)((clippedSrcY + clippedSrcHeight - srcRect.Y) * heightScale) -
                                          tileDestRect.Y;

                    clippedSrcX       = (clippedSrcX - curSrcX) * _tileScale;
                    clippedSrcY       = (clippedSrcY - curSrcY) * _tileScale;
                    clippedSrcWidth  *= _tileScale;
                    clippedSrcHeight *= _tileScale;

                    if (clippedSrcWidth > 0 && clippedSrcHeight > 0 && tileDestRect.Width != 0 &&
                        tileDestRect.Height != 0)
                    {
                        var texture = GetTexture(tileX, tileY);
                        if (texture == null)
                        {
                            continue;
                        }

                        Render2dArgs arg = default;
                        arg.customTexture = texture;
                        arg.flags         = Render2dFlag.FLOATSRCRECT | Render2dFlag.BUFFERTEXTURE;
                        arg.srcRectFloat  = new RectangleF(
                            clippedSrcX,
                            clippedSrcY,
                            clippedSrcWidth,
                            clippedSrcHeight
                            );
                        arg.destRect = tileDestRect;
                        Tig.ShapeRenderer2d.DrawRectangle(ref arg);
                    }
                }
            }
        }
Ejemplo n.º 5
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);
            }
        }
    }
Ejemplo n.º 6
0
    public override void Render()
    {
        var contentArea = GetContentArea();

        var destRect = GetContentArea();
        var srcRect  = new Rectangle(0, 0, destRect.Width, destRect.Height);

        destRect.Y -= 2;

        ResourceRef <ITexture> buttonTexture = default;

        try
        {
            switch (ButtonState)
            {
            case LgcyButtonState.Normal:
                buttonTexture = _normalTexture;
                break;

            case LgcyButtonState.Disabled:
                buttonTexture = _selectedTexture;
                break;

            case LgcyButtonState.Down:
                destRect.Width  += 3;
                destRect.Height += 3;
                srcRect.Width   += 3;
                srcRect.Height  += 3;
                buttonTexture    = _pressedTexture;
                break;

            case LgcyButtonState.Hovered:
                buttonTexture = _hoverTexture;
                break;

            default:
                buttonTexture = _normalTexture;
                break;
            }

            if (UiSystems.CharSheet.CurrentPage == _sheetPage)
            {
                Render2dArgs args = default;
                args.customTexture = _arcTopTexture.Resource;
                args.flags         = Render2dFlag.BUFFERTEXTURE;
                args.srcRect       = new Rectangle(0, 0, 21, 21);
                args.destRect      = new Rectangle(contentArea.X - 18, contentArea.Y + 5, 21, 21);
                Tig.ShapeRenderer2d.DrawRectangle(ref args);

                args.destRect.X = contentArea.X + contentArea.Width;
                args.flags     |= Render2dFlag.FLIPH;
                Tig.ShapeRenderer2d.DrawRectangle(ref args);

                if (ButtonState != LgcyButtonState.Down)
                {
                    srcRect.Width   += 3;
                    srcRect.Height  += 3;
                    destRect.Width  += 3;
                    destRect.Height += 3;
                    buttonTexture    = _selectedTexture;
                }
            }

            var buttonArgs = new Render2dArgs();
            buttonArgs.flags         = Render2dFlag.BUFFERTEXTURE;
            buttonArgs.srcRect       = srcRect;
            buttonArgs.destRect      = destRect;
            buttonArgs.customTexture = buttonTexture.Resource;
            Tig.ShapeRenderer2d.DrawRectangle(ref buttonArgs);
        }
        finally
        {
            buttonTexture.Dispose();
        }
    }