Readd fidget spinner crosshair
This commit is contained in:
parent
39058d7066
commit
9525d26e02
@ -51,7 +51,7 @@ void draw_line(float x, float y, float dx, float dy, const rgba_t &rgba,
|
||||
float thickness);
|
||||
void draw_rect_textured(float x, float y, float w, float h, const rgba_t &rgba,
|
||||
texture_handle_t texture, float u, float v, float s,
|
||||
float t);
|
||||
float t, float a);
|
||||
void draw_circle(float x, float y, float radius, const rgba_t &rgba,
|
||||
float thickness, int steps);
|
||||
void draw_string(float x, float y, const char *string, font_handle_t &font,
|
||||
|
2
libglez
2
libglez
@ -1 +1 @@
|
||||
Subproject commit 35e0841d5ee9d885013e47ce72e155bd22cf7a98
|
||||
Subproject commit e3bdf1c994da95544b84896efe8de0099dffe023
|
@ -6,12 +6,14 @@
|
||||
*/
|
||||
|
||||
#include "fidgetspinner.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
#ifndef FEATURE_FIDGET_SPINNER_DISABLED
|
||||
#include <math.h>
|
||||
|
||||
#ifndef FEATURE_FIDGET_SPINNER_ENABLED
|
||||
|
||||
CatVar enable_spinner(CV_SWITCH, "fidgetspinner", "0", "Fidget Spinner",
|
||||
"Part of Cathook Autism Awareness program");
|
||||
std::vector<textures::AtlasTexture> spinner_states{};
|
||||
|
||||
float spinning_speed = 0.0f;
|
||||
float angle = 0;
|
||||
@ -44,9 +46,6 @@ SpinnerListener listener;
|
||||
|
||||
void InitSpinner()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
spinner_states.emplace_back(i * 64, textures::atlas_height - 64 * 4, 64,
|
||||
64);
|
||||
g_IGameEventManager->AddListener(&listener, false);
|
||||
}
|
||||
|
||||
@ -86,41 +85,16 @@ void DrawSpinner()
|
||||
(speed_cap - 10) + 10 * ((spinning_speed - 750.0f) / 250.0f);
|
||||
const float speed_scale(spinner_speed_scale);
|
||||
const float size(spinner_scale);
|
||||
ftgl::vec2 positions[4] = {
|
||||
{ -size, -size }, { size, -size }, { size, size }, { -size, size }
|
||||
};
|
||||
angle += speed_scale * real_speed;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
float x = positions[i].x;
|
||||
float y = positions[i].y;
|
||||
positions[i].x = x * cos(angle) - y * sin(angle);
|
||||
positions[i].y = x * sin(angle) + y * cos(angle);
|
||||
positions[i].x += draw::width / 2;
|
||||
positions[i].y += draw::height / 2;
|
||||
}
|
||||
int state = min(3, spinning_speed / 250.0f);
|
||||
int state = min(3, int(spinning_speed / 250));
|
||||
|
||||
// Paste from draw_api::
|
||||
using namespace drawgl;
|
||||
using namespace ftgl;
|
||||
const glez_rgba_t color = glez_rgba(255, 255, 255, 255);
|
||||
|
||||
const auto &u1v1 = spinner_states[state].tex_coords[0];
|
||||
const auto &u2v2 = spinner_states[state].tex_coords[1];
|
||||
GLuint idx = buffer_triangles_textured->vertices->size;
|
||||
GLuint indices[] = { idx, idx + 1, idx + 2, idx, idx + 2, idx + 3 };
|
||||
vertex_v2t2c4_t vertices[] = {
|
||||
{ vec2{ positions[0].x, positions[0].y }, vec2{ u1v1.x, u2v2.y },
|
||||
*reinterpret_cast<const vec4 *>(&colors::white) },
|
||||
{ vec2{ positions[1].x, positions[1].y }, vec2{ u2v2.x, u2v2.y },
|
||||
*reinterpret_cast<const vec4 *>(&colors::white) },
|
||||
{ vec2{ positions[2].x, positions[2].y }, vec2{ u2v2.x, u1v1.y },
|
||||
*reinterpret_cast<const vec4 *>(&colors::white) },
|
||||
{ vec2{ positions[3].x, positions[3].y }, vec2{ u1v1.x, u1v1.y },
|
||||
*reinterpret_cast<const vec4 *>(&colors::white) }
|
||||
};
|
||||
vertex_buffer_push_back_indices(buffer_triangles_textured, indices, 6);
|
||||
vertex_buffer_push_back_vertices(buffer_triangles_textured, vertices, 4);
|
||||
|
||||
static glez_texture_t tex = glez_texture_load_png_rgba("/opt/cathook/data/res/atlas.png");
|
||||
while (!tex)
|
||||
tex = glez_texture_load_png_rgba("/opt/cathook/data/res/atlas.png");
|
||||
glez_rect_textured(draw::width / 2, draw::height / 2, size, size, color, tex, 0 + 64 * state, 3 * 64, 64, 64, angle);
|
||||
if (angle > PI * 4)
|
||||
angle -= PI * 4;
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ free(logname);*/
|
||||
hacks::tf2::healarrow::Init();
|
||||
|
||||
#if ENABLE_VISUALS == 1
|
||||
#ifndef FEATURE_FIDGET_SPINNER_DISABLED
|
||||
#ifndef FEATURE_FIDGET_SPINNER_ENABLED
|
||||
InitSpinner();
|
||||
logging::Info("Initialized Fidget Spinner");
|
||||
#endif
|
||||
|
@ -395,10 +395,10 @@ void CreateMove()
|
||||
}
|
||||
if (instant_weapon_switch && not HasCondition<TFCond_Cloaked>(LOCAL_E))
|
||||
{
|
||||
if (lastwep != g_pLocalPlayer->weapon()->m_IDX)
|
||||
if (lastwep != g_pLocalPlayer->weapon()->m_iClassID)
|
||||
{
|
||||
amount = 2 * 90;
|
||||
lastwep = g_pLocalPlayer->weapon()->m_IDX;
|
||||
lastwep = g_pLocalPlayer->weapon()->m_iClassID;
|
||||
}
|
||||
}
|
||||
// SHOUTOUTS TO BLACKFIRE
|
||||
@ -408,7 +408,7 @@ void CreateMove()
|
||||
servertime =
|
||||
(float) (CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) *
|
||||
g_GlobalVars->interval_per_tick;
|
||||
if (!nextattack || !i || g_pLocalPlayer->weapon()->m_IDX != lastwep)
|
||||
if (!nextattack || !i || g_pLocalPlayer->weapon()->m_iClassID != lastwep)
|
||||
nextattack =
|
||||
CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack);
|
||||
if (servertime - nextattack > 30.0f)
|
||||
@ -441,7 +441,7 @@ void CreateMove()
|
||||
}
|
||||
if (i)
|
||||
i--;
|
||||
lastwep = g_pLocalPlayer->weapon()->m_IDX;
|
||||
lastwep = g_pLocalPlayer->weapon()->m_iClassID;
|
||||
}
|
||||
if (!amount)
|
||||
return;
|
||||
|
@ -22,7 +22,7 @@ void sprite::draw(float scrx, float scry, float scrw, float scrh,
|
||||
const rgba_t &rgba) const
|
||||
{
|
||||
draw_api::draw_rect_textured(scrx, scry, scrw, scrh, rgba, atlas.texture,
|
||||
nx, ny, nw, nh);
|
||||
nx, ny, nw, nh, 0);
|
||||
}
|
||||
|
||||
texture_atlas::texture_atlas(std::string filename, float width, float height)
|
||||
|
@ -150,7 +150,7 @@ void DrawCheatVisuals()
|
||||
{
|
||||
criticals::draw();
|
||||
}
|
||||
#ifndef FEATURE_FIDGET_SPINNER_DISABLED
|
||||
#ifndef FEATURE_FIDGET_SPINNER_ENABLED
|
||||
DrawSpinner();
|
||||
#endif
|
||||
Prediction_PaintTraverse();
|
||||
|
Reference in New Issue
Block a user