Jump to content

source gamesense indicators


ivsofte
 Share

Recommended Posts

namespace visuals {
    class _Indicators {
    public:
        // \param _Text
        //        The text that will be drawn
        // \param _Color
        //        Text color
        // \returns The Y screen coordinate (vertical offset) of the drawn text
        math::vec2::value_type add(const std::string& _Text, const math::color& _Color);

        void on_draw();

    private:
        static constexpr math::color _Shadow = math::color().from_rgba(0, 0, 0, .22f);

        static constexpr math::vec2::value_type    _Zone = 380.f, _Spacing = 4.f, _Vertical_padding = 2.f,
                                                                _Horizontal_offset = 10.f, _Text_offset = 10.f;

        std::vector<std::tuple<std::string, math::color,
                                      math::vec2::value_type /* Vertical offset */, math::vec2 /* Text size */>> _Draw_queue{};
    };

    inline _Indicators indicators;
}

namespace visuals {
    math::vec2::value_type _Indicators::add(const std::string& _Text, const math::color& _Color) {
        const auto _Graphics = visuals::esp_buffer();

        const auto _Text_size = _Graphics.measure_text(draw::flags::large | draw::flags::dpi, _Text) + math::vec2(0.f, _Vertical_padding * 2.f);
        const auto _Vertical_offset = _Draw_queue.empty()
            ? _Graphics.display_size().y() - (_Graphics.screen_size().y() - _Zone) / 2.f
            : std::get<math::vec2::value_type>(_Draw_queue.back()) - _Spacing - _Text_size.y();

        _Draw_queue.emplace_back(
            std::make_tuple(
                _Text, _Color,
                _Vertical_offset, _Text_size
            )
        );

        return _Vertical_offset;
    }

    void _Indicators::on_draw() {
        for (const auto& _Data : _Draw_queue) {
            const auto _Graphics = visuals::esp_buffer();

            const auto _Position = math::vec2(_Horizontal_offset, std::get<math::vec2::value_type>(_Data));
            const auto _Text_pos = _Position + math::vec2(_Text_offset, _Vertical_padding);
            const auto _Half_size = std::get<math::vec2>(_Data) * math::vec2(.5f, 1.f);

            // Shadow
            _Graphics.gradient(_Position, _Half_size, math::color().from_rgba(0, 0, 0, 0.f), _Shadow);
            _Graphics.gradient(_Position + math::vec2(_Half_size.x(), 0.f), _Half_size, _Shadow,  math::color().from_rgba(0, 0, 0, 0.f));

            // Text shadow
            _Graphics.text(_Text_pos + math::vec2(1.f), math::color().from_rgba(0, 0, 0, .5f), draw::flags::large | draw::flags::dpi, 0.f, std::get<std::string>(_Data));

            // Text
            _Graphics.text(_Text_pos, std::get<math::color>(_Data), draw::flags::large | draw::flags::dpi, 0.f, std::get<std::string>(_Data));
        }

        _Draw_queue.clear();
    }
}

usage:

// fps warning

visuals::indicators.add("FPS", math::color().from_rgba(255, 255, 40, 200.f / 255.f));

// bomb begin plant

const auto graphics = visuals::esp_buffer();

const auto bombsite_str = bomb->get_site() ? "Bombsite B" : "Bombsite A";
const auto vertical_offset = visuals::indicators.add(bombsite_str, math::color().from_rgba(252, 243, 105));
const auto text_size = graphics.measure_text(draw::flags::large | draw::flags::dpi, bombsite_str);

graphics.circle_outline(math::vec2(20.f + text_size.x(), vertical_offset + text_size.y() / 2.f), math::color().from_rgba(0, 0, 0, 200.f / 255.f), 20.f, 0.f, 1.f, 5.f);
graphics.circle_outline(math::vec2(20.f + text_size.x(), vertical_offset + text_size.y() / 2.f), math::color().from_rgba(255, 255, 255, 200.f / 255.f), 18.f, 0.f, planting_complete, 3.f);

// bomb is ticking

visuals::indicators.add(std::format(bomb->get_site() ? "B - {:.1fs}" : "A - {:.1fs}", remaining_seconds), math::color().from_rgba(255, 255, 255, 200.f / 255.f));

if (globals.local_player.get_health() - damage <= 0) {
    visuals::indicators.add("FATAL", math::color().from_rgba(255, 0, 0));
}
else if (damage > 0) {
    visuals::indicators.add(std::format("-{} HP", damage), math::color().from_rgba(252, 243, 105));
}

// aa

if (!globals::local_player.on_ground()) {
    visuals::indicators.add("LC", lc_state ? math::color().from_rgba(123, 194, 21) : math::color().from_rgba(255, 0, 0));
}

if (fake_ducking) {
    visuals::indicators.add("DUCK", math::color().from_rgba(255, 255, 255, 200.f / 255.f));
}

// dt

visuals::indicators.add("DT", charged ? math::color().from_rgba(255, 255, 255, 200.f / 255.f) : math::color().from_rgba(255, 0, 0));

// directx hook

visuals::indicators.on_draw();

 

zCSN70c.png

  • Like 3
Link to comment
Share on other sites

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...