Counter-Strike: Cache scope images using spriteframe() instead of the old

deprecated method.
This commit is contained in:
Marco Cawthorne 2021-02-15 11:54:32 +01:00
parent 23edd47438
commit 1f10bbd4f0
3 changed files with 32 additions and 10 deletions

View file

@ -76,7 +76,7 @@ Cstrike_DrawSimpleCrosshair(void)
{
static vector cross_pos;
cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12];
drawsubpic(cross_pos, [24,24], "sprites/crosshairs.spr_0.tga", [0.1875,0], [0.1875, 0.1875], [1,1,1], 1, DRAWFLAG_NORMAL);
drawsubpic(cross_pos, [24,24], g_cs_cross, [0.1875,0], [0.1875, 0.1875], [1,1,1], 1, DRAWFLAG_NORMAL);
}
/*
@ -99,21 +99,21 @@ Cstrike_DrawScope(void)
// Draw the scope in the middle, seperately from the border
scope_pos = g_hudmins + (g_hudres / 2) + [-128,-128];
drawpic(scope_pos, "sprites/sniper_scope.spr_0.tga", [256,256], [1,1,1], 1.0f, DRAWFLAG_NORMAL);
drawpic(scope_pos, g_cs_scope0, [256,256], [1,1,1], 1.0f, DRAWFLAG_NORMAL);
// Border scale to fit the screen
scope_scale = g_hudres[1] / 480;
scope_offset = g_hudmins[0] + (g_hudres[0] / 2) - ((640 * scope_scale) / 2);
// Type 1 Border... more coming soon?
Cstrike_ScopePic([0,0], [192,112], "sprites/top_left.spr_0.tga");
Cstrike_ScopePic([192,0], [256,112], "sprites/top.spr_0.tga");
Cstrike_ScopePic([448,0], [192,112], "sprites/top_right.spr_0.tga");
Cstrike_ScopePic([0,112], [192,256], "sprites/left.spr_0.tga");
Cstrike_ScopePic([448,112], [192,256], "sprites/right.spr_0.tga");
Cstrike_ScopePic([0,368], [192,112], "sprites/bottom_left.spr_0.tga");
Cstrike_ScopePic([192,368], [256,112], "sprites/bottom.spr_0.tga");
Cstrike_ScopePic([448,368], [192,112], "sprites/bottom_right.spr_0.tga");
Cstrike_ScopePic([0,0], [192,112], g_cs_scope1);
Cstrike_ScopePic([192,0], [256,112], g_cs_scope2);
Cstrike_ScopePic([448,0], [192,112], g_cs_scope3);
Cstrike_ScopePic([0,112], [192,256], g_cs_scope4);
Cstrike_ScopePic([448,112], [192,256], g_cs_scope5);
Cstrike_ScopePic([0,368], [192,112], g_cs_scope6);
Cstrike_ScopePic([192,368], [256,112], g_cs_scope7);
Cstrike_ScopePic([448,368], [192,112], g_cs_scope8);
// Rect borders left and right
if (scope_offset > 0) {

View file

@ -39,6 +39,17 @@ var string g_hud14_spr;
var string g_hud15_spr;
var string g_hud16_spr;
var string g_cs_cross;
var string g_cs_scope0;
var string g_cs_scope1;
var string g_cs_scope2;
var string g_cs_scope3;
var string g_cs_scope4;
var string g_cs_scope5;
var string g_cs_scope6;
var string g_cs_scope7;
var string g_cs_scope8;
struct
{
/* viewmodel stuff */

View file

@ -118,6 +118,17 @@ Client_InitDone(void)
void
Game_RendererRestarted(string rstr)
{
g_cs_cross = spriteframe("sprites/crosshairs.spr", 0, 0.0f);
g_cs_scope0 = spriteframe("sprites/sniper_scope.spr", 0, 0.0f);
g_cs_scope1 = spriteframe("sprites/top_left.spr", 0, 0.0f);
g_cs_scope2 = spriteframe("sprites/top.spr", 0, 0.0f);
g_cs_scope3 = spriteframe("sprites/top_right.spr", 0, 0.0f);
g_cs_scope4 = spriteframe("sprites/left.spr", 0, 0.0f);
g_cs_scope5 = spriteframe("sprites/right.spr", 0, 0.0f);
g_cs_scope6 = spriteframe("sprites/bottom_left.spr", 0, 0.0f);
g_cs_scope7 = spriteframe("sprites/bottom.spr", 0, 0.0f);
g_cs_scope8 = spriteframe("sprites/bottom_right.spr", 0, 0.0f);
Obituary_Precache();
FX_Blood_Init();