diff --git a/releases/3.2.0/source/cl_dll/ammo.cpp b/releases/3.2.0/source/cl_dll/ammo.cpp index 8511917..deb4cf9 100644 --- a/releases/3.2.0/source/cl_dll/ammo.cpp +++ b/releases/3.2.0/source/cl_dll/ammo.cpp @@ -26,6 +26,7 @@ #include "ammohistory.h" #include "vgui_TeamFortressViewport.h" +#include "mod/AvHClientVariables.h" #include "mod/AvHSharedUtil.h" #include "mod/AvHScrollHandler.h" #include "mod/AvHNetworkMessages.h" @@ -119,12 +120,21 @@ inline void LoadWeaponSprite( client_sprite_t* ptr, HSPRITE& sprite, wrect_t& bo void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) { - int i, iRes; + int resolutions[5] = { 320, 640, 800, 1024, 1280 }; + const int numRes=5; + int i=0, j=0, iRes=320; + int screenWidth=ScreenWidth(); - if (ScreenWidth() < 640) - iRes = 320; - else - iRes = 640; + for ( j=0; j < numRes; j++ ) { + if ( screenWidth == resolutions[j] ) { + iRes=resolutions[j]; + break; + } + if ( i > 0 && screenWidth > resolutions[j-1] && screenWidth < resolutions[j] ) { + iRes=resolutions[j-1]; + break; + } + } char sz[128]; @@ -149,31 +159,50 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) return; } - LoadWeaponSprite( GetSpriteList( pList, "crosshair", iRes, i ), pWeapon->hCrosshair, pWeapon->rcCrosshair ); - LoadWeaponSprite( GetSpriteList( pList, "autoaim", iRes, i ), pWeapon->hAutoaim, pWeapon->rcAutoaim ); - LoadWeaponSprite( GetSpriteList( pList, "zoom", iRes, i ), pWeapon->hZoomedCrosshair, pWeapon->rcZoomedCrosshair ); - LoadWeaponSprite( GetSpriteList( pList, "zoom_autoaim", iRes, i ), pWeapon->hZoomedAutoaim, pWeapon->rcZoomedAutoaim ); - LoadWeaponSprite( GetSpriteList( pList, "weapon", iRes, i ), pWeapon->hInactive, pWeapon->rcInactive ); - LoadWeaponSprite( GetSpriteList( pList, "weapon_s", iRes, i ), pWeapon->hActive, pWeapon->rcActive ); - LoadWeaponSprite( GetSpriteList( pList, "ammo", iRes, i ), pWeapon->hAmmo, pWeapon->rcAmmo ); - LoadWeaponSprite( GetSpriteList( pList, "ammo2", iRes, i ), pWeapon->hAmmo2, pWeapon->rcAmmo2 ); + for ( j=numRes-1; j>=0; j-- ) { + if ( resolutions[j] <= iRes ) { + if( pWeapon->hCrosshair == NULL ) + LoadWeaponSprite( GetSpriteList( pList, "crosshair", resolutions[j], i ), pWeapon->hCrosshair, pWeapon->rcCrosshair ); + + if( pWeapon->hCrosshair1 == NULL ) + LoadWeaponSprite( GetSpriteList( pList, "crosshair_1", resolutions[j], i ), pWeapon->hCrosshair1, pWeapon->rcCrosshair1 ); + + if( pWeapon->hCrosshair2 == NULL ) + LoadWeaponSprite( GetSpriteList( pList, "crosshair_2", resolutions[j], i ), pWeapon->hCrosshair2, pWeapon->rcCrosshair2 ); + + if( pWeapon->hCrosshair3 == NULL ) + LoadWeaponSprite( GetSpriteList( pList, "crosshair_3", resolutions[j], i ), pWeapon->hCrosshair3, pWeapon->rcCrosshair3 ); + + if( pWeapon->hInactive == NULL ) + LoadWeaponSprite( GetSpriteList( pList, "weapon", resolutions[j], i ), pWeapon->hInactive, pWeapon->rcInactive ); + + if( pWeapon->hActive == NULL ) + LoadWeaponSprite( GetSpriteList( pList, "weapon_s", resolutions[j], i ), pWeapon->hActive, pWeapon->rcActive ); + + if( pWeapon->hAmmo == NULL ) + LoadWeaponSprite( GetSpriteList( pList, "ammo", resolutions[j], i ), pWeapon->hAmmo, pWeapon->rcAmmo ); + + if( pWeapon->hAmmo2 == NULL ) + LoadWeaponSprite( GetSpriteList( pList, "ammo2", resolutions[j], i ), pWeapon->hAmmo2, pWeapon->rcAmmo2 ); + } + } - if( pWeapon->hZoomedCrosshair == NULL ) //default to non-zoomed crosshair + if( pWeapon->hCrosshair1 == NULL ) //default { - pWeapon->hZoomedCrosshair = pWeapon->hCrosshair; - pWeapon->rcZoomedCrosshair = pWeapon->rcCrosshair; + pWeapon->hCrosshair1 = pWeapon->hCrosshair; + pWeapon->rcCrosshair1 = pWeapon->rcCrosshair; } - if( pWeapon->hAutoaim == NULL ) //default to non-autoaim crosshair + if( pWeapon->hCrosshair2 == NULL ) //default { - pWeapon->hAutoaim = pWeapon->hCrosshair; - pWeapon->rcAutoaim = pWeapon->rcCrosshair; + pWeapon->hCrosshair2 = pWeapon->hCrosshair; + pWeapon->rcCrosshair2 = pWeapon->rcCrosshair; } - if( pWeapon->hZoomedAutoaim == NULL ) //default to non-autoaim zoomed crosshair + if( pWeapon->hCrosshair3 == NULL ) //default { - pWeapon->hZoomedAutoaim = pWeapon->hZoomedCrosshair; - pWeapon->rcZoomedAutoaim = pWeapon->rcZoomedCrosshair; + pWeapon->hCrosshair3 = pWeapon->hCrosshair; + pWeapon->rcCrosshair3 = pWeapon->rcCrosshair; } if( pWeapon->hActive || pWeapon->hInactive || pWeapon->hAmmo || pWeapon->hAmmo2 ) @@ -597,6 +626,7 @@ void CHudAmmo::Reset(void) gWR.Reset(); gHR.Reset(); + m_customCrosshair=0; // VidInit(); } @@ -634,6 +664,7 @@ int CHudAmmo::VidInit(void) // Think: // Used for selection of weapon menu item. // + void CHudAmmo::Think(void) { if ( gHUD.m_fPlayerDead ) @@ -657,6 +688,29 @@ void CHudAmmo::Think(void) } } } + if ( (int)CVAR_GET_FLOAT(kvCustomCrosshair) != m_customCrosshair ) { + m_customCrosshair=(int)CVAR_GET_FLOAT(kvCustomCrosshair); + WEAPON* currentWeapon = gWR.GetWeapon(gHUD.GetCurrentWeaponID()); + if ( currentWeapon ) { + switch (m_customCrosshair) { + case 0: + gHUD.SetCurrentCrosshair(currentWeapon->hCrosshair, currentWeapon->rcCrosshair, 255, 255, 255); + break; + case 1: + gHUD.SetCurrentCrosshair(currentWeapon->hCrosshair1, currentWeapon->rcCrosshair1, 255, 255, 255); + break; + case 2: + gHUD.SetCurrentCrosshair(currentWeapon->hCrosshair2, currentWeapon->rcCrosshair2, 255, 255, 255); + break; + case 3: + gHUD.SetCurrentCrosshair(currentWeapon->hCrosshair3, currentWeapon->rcCrosshair3, 255, 255, 255); + break; + default: + gHUD.SetCurrentCrosshair(currentWeapon->hCrosshair, currentWeapon->rcCrosshair, 255, 255, 255); + break; + } + } + } if(gHUD.GetIsAlien()) //check for hive death causing loss of current weapon { @@ -805,7 +859,25 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf ) if ( !(gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) ) { - if ( gHUD.m_iFOV >= 90 ) + switch ((int)CVAR_GET_FLOAT(kvCustomCrosshair)) { + case 0: + gHUD.SetCurrentCrosshair(m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255); + break; + case 1: + gHUD.SetCurrentCrosshair(m_pWeapon->hCrosshair1, m_pWeapon->rcCrosshair1, 255, 255, 255); + break; + case 2: + gHUD.SetCurrentCrosshair(m_pWeapon->hCrosshair2, m_pWeapon->rcCrosshair2, 255, 255, 255); + break; + case 3: + gHUD.SetCurrentCrosshair(m_pWeapon->hCrosshair3, m_pWeapon->rcCrosshair3, 255, 255, 255); + break; + default: + gHUD.SetCurrentCrosshair(m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255); + break; + } + +/* if ( gHUD.m_iFOV >= 90 ) { // normal crosshairs if (bOnTarget && m_pWeapon->hAutoaim) gHUD.SetCurrentCrosshair(m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255); @@ -818,7 +890,7 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf ) gHUD.SetCurrentCrosshair(m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255); else gHUD.SetCurrentCrosshair(m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255); - } + }*/ } m_fFade = 200.0f; //!!! diff --git a/releases/3.2.0/source/cl_dll/ammo.h b/releases/3.2.0/source/cl_dll/ammo.h index 577497f..e2cd55c 100644 --- a/releases/3.2.0/source/cl_dll/ammo.h +++ b/releases/3.2.0/source/cl_dll/ammo.h @@ -48,12 +48,20 @@ struct WEAPON wrect_t rcAmmo2; HSPRITE hCrosshair; wrect_t rcCrosshair; - HSPRITE hAutoaim; + HSPRITE hCrosshair1; + wrect_t rcCrosshair1; + HSPRITE hCrosshair2; + wrect_t rcCrosshair2; + HSPRITE hCrosshair3; + wrect_t rcCrosshair3; + +/* HSPRITE hAutoaim; wrect_t rcAutoaim; HSPRITE hZoomedCrosshair; wrect_t rcZoomedCrosshair; HSPRITE hZoomedAutoaim; wrect_t rcZoomedAutoaim; + */ }; typedef int AMMO; diff --git a/releases/3.2.0/source/cl_dll/chudmisc.h b/releases/3.2.0/source/cl_dll/chudmisc.h index d7e42cd..720b099 100644 --- a/releases/3.2.0/source/cl_dll/chudmisc.h +++ b/releases/3.2.0/source/cl_dll/chudmisc.h @@ -113,6 +113,7 @@ private: WEAPON *m_pWeapon; int m_HUD_bucket0; int m_HUD_selection; + int m_customCrosshair; }; @@ -357,7 +358,7 @@ public: void Reset( void ); int MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf ); int MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf ); - + private: HSPRITE m_hSprite1; HSPRITE m_hSprite2; diff --git a/releases/3.2.0/source/cl_dll/hud.cpp b/releases/3.2.0/source/cl_dll/hud.cpp index 4fc6d23..acdfff2 100644 --- a/releases/3.2.0/source/cl_dll/hud.cpp +++ b/releases/3.2.0/source/cl_dll/hud.cpp @@ -209,7 +209,7 @@ void CHud :: Init( void ) CVAR_CREATE( "cl_showspeed", "0", 0); CVAR_CREATE( kvLabelMaps, "1", FCVAR_ARCHIVE); CVAR_CREATE( kvGammaRamp, "1", FCVAR_ARCHIVE); - + CVAR_CREATE( kvCustomCrosshair, "0", FCVAR_ARCHIVE); CVAR_CREATE( "cl_iconr", "0", FCVAR_ARCHIVE); CVAR_CREATE( "cl_icong", "149", FCVAR_ARCHIVE); CVAR_CREATE( "cl_iconb", "221", FCVAR_ARCHIVE); diff --git a/releases/3.2.0/source/mod/AvHClientVariables.h b/releases/3.2.0/source/mod/AvHClientVariables.h index 4d98056..e659893 100644 --- a/releases/3.2.0/source/mod/AvHClientVariables.h +++ b/releases/3.2.0/source/mod/AvHClientVariables.h @@ -39,7 +39,8 @@ extern cvar_t* cl_musicdir; #define kvLabelMaps "cl_labelmaps" // :puzl // tankefugl: 0001070 - enables forced gamma ramp loading -#define kvGammaRamp "cl_gammaramp" +#define kvGammaRamp "cl_gammaramp" +#define kvCustomCrosshair "cl_customcrosshair" // :tankefugl #define kvCMHotKeys "cl_cmhotkeys" #define kvForceDefaultFOV "cl_forcedefaultfov" diff --git a/releases/3.2.0/sprites/weapon_machinegun.txt b/releases/3.2.0/sprites/weapon_machinegun.txt index 6dede7a..6179697 100644 --- a/releases/3.2.0/sprites/weapon_machinegun.txt +++ b/releases/3.2.0/sprites/weapon_machinegun.txt @@ -1,11 +1,36 @@ -10 +35 weapon 320 320w 160 0 80 20 weapon_s 320 320w-s 160 0 80 20 ammo 320 640hud7 48 72 24 24 crosshair 320 xhairmg 0 0 64 64 -autoaim 320 crosshairs 0 72 24 24 +crosshair_1 320 xhairmg 0 0 64 64 +crosshair_2 320 xhairmg 0 0 64 64 +crosshair_3 320 xhairmg 0 0 64 64 weapon 640 640mw2 0 180 170 45 weapon_s 640 640mw2-s 0 180 170 45 ammo 640 640hud7 48 72 24 24 crosshair 640 xhairmg 0 0 64 64 -autoaim 640 crosshairs 0 72 24 24 +crosshair_1 640 xhairmg 0 0 64 64 +crosshair_2 640 xhairmg 0 0 64 64 +crosshair_3 640 xhairmg 0 0 64 64 +weapon 800 640mw2 0 180 170 45 +weapon_s 800 640mw2-s 0 180 170 45 +ammo 800 640hud7 48 72 24 24 +crosshair 800 xhairmg 0 0 64 64 +crosshair_1 800 xhairmg 0 0 64 64 +crosshair_2 800 xhairmg 0 0 64 64 +crosshair_3 800 xhairmg 0 0 64 64 +weapon 1024 640mw2 0 180 170 45 +weapon_s 1024 640mw2-s 0 180 170 45 +ammo 1024 640hud7 48 72 24 24 +crosshair 1024 xhairmg 0 0 64 64 +crosshair_1 1024 xhairmg 0 0 64 64 +crosshair_2 1024 xhairmg 0 0 64 64 +crosshair_3 1024 xhairmg 0 0 64 64 +weapon 1280 640mw2 0 180 170 45 +weapon_s 1280 640mw2-s 0 180 170 45 +ammo 1280 640hud7 48 72 24 24 +crosshair 1280 xhairmg 0 0 64 64 +crosshair_1 1280 xhairmg 0 0 64 64 +crosshair_2 1280 xhairmg 0 0 64 64 +crosshair_3 1280 xhairmg 0 0 64 64 diff --git a/releases/3.2.0/user.scr b/releases/3.2.0/user.scr index 3990972..ebdad32 100644 --- a/releases/3.2.0/user.scr +++ b/releases/3.2.0/user.scr @@ -56,6 +56,19 @@ DESCRIPTION INFO_OPTIONS { "1" } } + "cl_customxhair" + { + "Choose your crosshair" + { + LIST + "Default" "0" + "Custom 1" "1" + "Custom 2" "2" + "Custom 3" "3" + } + { "0.000000" } + } + "cl_centerentityid" { "Center player names"