From: Samual Lenks Date: Thu, 2 Jan 2014 21:07:40 +0000 (-0500) Subject: Begin moving per-weapon crosshair selection as weapon specific info X-Git-Tag: xonotic-v0.8.0~152^2~162 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c66fc18b4a36dad6b90b8a6fc2fa99f5c27d43d1;p=xonotic%2Fxonotic-data.pk3dir.git Begin moving per-weapon crosshair selection as weapon specific info --- diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index 837c72f3e..e6c9d3bb6 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -1228,42 +1228,39 @@ void CSQC_UpdateView(float w, float h) shottype = SHOTTYPE_HITWORLD; vector wcross_color = '0 0 0', wcross_size = '0 0 0'; - string wcross_wep = "", wcross_name; + string wcross_name = ""; float wcross_scale, wcross_blur; - if (autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1)) + if(autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1)) { e = get_weaponinfo(switchingweapon); - if (e && e.netname != "") + if(e) { - wcross_wep = e.netname; if(autocvar_crosshair_per_weapon) { - wcross_resolution *= cvar(strcat("crosshair_", wcross_wep, "_size")); - if (wcross_resolution == 0) - return; - wcross_alpha *= cvar(strcat("crosshair_", wcross_wep, "_alpha")); - if (wcross_alpha == 0) - return; - - wcross_style = cvar_string(strcat("crosshair_", wcross_wep)); - if(wcross_style == "" || wcross_style == "0") - wcross_style = wcross_wep; + // WEAPONTODO: access these through some general settings (with non-balance config settings) + //wcross_resolution *= cvar(strcat("crosshair_", wcross_wep, "_size")); + //if (wcross_resolution == 0) + //return; + + //wcross_style = cvar_string(strcat("crosshair_", wcross_wep)); + wcross_resolution *= e.w_crosshair_size; + wcross_name = e.w_crosshair; } } } - //printf("crosshair style: %s\n", wcross_style); - wcross_name = strcat("gfx/crosshair", wcross_style); + if(wcross_name == "") + wcross_name = strcat("gfx/crosshair", wcross_style); // MAIN CROSSHAIR COLOR DECISION switch(autocvar_crosshair_color_special) { case 1: // crosshair_color_per_weapon { - if(wcross_wep != "") + if(e) { - wcross_color = stov(cvar_string(sprintf("crosshair_%s_color", wcross_wep))); + wcross_color = e.wpcolor; break; } else { goto normalcolor; } diff --git a/qcsrc/common/weapons/w_arc.qc b/qcsrc/common/weapons/w_arc.qc index 62bf5dd00..b453f5ea4 100644 --- a/qcsrc/common/weapons/w_arc.qc +++ b/qcsrc/common/weapons/w_arc.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '1 1 1', /* model */ "arc", +/* crosshair */ "gfx/crosshairhlac", /* netname */ "arc", /* fullname */ _("Arc") ); diff --git a/qcsrc/common/weapons/w_blaster.qc b/qcsrc/common/weapons/w_blaster.qc index 3d0fced42..a20361446 100644 --- a/qcsrc/common/weapons/w_blaster.qc +++ b/qcsrc/common/weapons/w_blaster.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ 0, /* color */ '1 0.5 0.5', /* model */ "laser", +/* crosshair */ "gfx/crosshairlaser", /* netname */ "laser", /* fullname */ _("Blaster") ); diff --git a/qcsrc/common/weapons/w_crylink.qc b/qcsrc/common/weapons/w_crylink.qc index c2f6b49de..38ca5e5eb 100644 --- a/qcsrc/common/weapons/w_crylink.qc +++ b/qcsrc/common/weapons/w_crylink.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 0.5 1', /* model */ "crylink", +/* crosshair */ "gfx/crosshaircrylink", /* netname */ "crylink", /* fullname */ _("Crylink") ); diff --git a/qcsrc/common/weapons/w_devastator.qc b/qcsrc/common/weapons/w_devastator.qc index 7298ded15..00a0a3068 100644 --- a/qcsrc/common/weapons/w_devastator.qc +++ b/qcsrc/common/weapons/w_devastator.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '1 1 0', /* model */ "rl", +/* crosshair */ "gfx/crosshairrocketlauncher", /* netname */ "devastator", /* fullname */ _("Devastator") ); diff --git a/qcsrc/common/weapons/w_electro.qc b/qcsrc/common/weapons/w_electro.qc index 6fb5e7bdc..d41c8ff6c 100644 --- a/qcsrc/common/weapons/w_electro.qc +++ b/qcsrc/common/weapons/w_electro.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0 0.5 1', /* model */ "electro", +/* crosshair */ "gfx/crosshairelectro", /* netname */ "electro", /* fullname */ _("Electro") ); diff --git a/qcsrc/common/weapons/w_fireball.qc b/qcsrc/common/weapons/w_fireball.qc index 07b137159..d52a565d3 100644 --- a/qcsrc/common/weapons/w_fireball.qc +++ b/qcsrc/common/weapons/w_fireball.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 0.5 0', /* model */ "fireball", +/* crosshair */ "gfx/crosshairfireball", /* netname */ "fireball", /* fullname */ _("Fireball") ); diff --git a/qcsrc/common/weapons/w_hagar.qc b/qcsrc/common/weapons/w_hagar.qc index b1a8be24f..0e0c58981 100644 --- a/qcsrc/common/weapons/w_hagar.qc +++ b/qcsrc/common/weapons/w_hagar.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 1 0.5', /* model */ "hagar", +/* crosshair */ "gfx/crosshairhagar", /* netname */ "hagar", /* fullname */ _("Hagar") ); diff --git a/qcsrc/common/weapons/w_hlac.qc b/qcsrc/common/weapons/w_hlac.qc index eb6bfcffd..d7aa50483 100644 --- a/qcsrc/common/weapons/w_hlac.qc +++ b/qcsrc/common/weapons/w_hlac.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0 1 0', /* model */ "hlac", +/* crosshair */ "gfx/crosshairhlac", /* netname */ "hlac", /* fullname */ _("Heavy Laser Assault Cannon") ); diff --git a/qcsrc/common/weapons/w_hook.qc b/qcsrc/common/weapons/w_hook.qc index a4b07319a..f5fdb8922 100644 --- a/qcsrc/common/weapons/w_hook.qc +++ b/qcsrc/common/weapons/w_hook.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ 0, /* color */ '0 0.5 0', /* model */ "hookgun", +/* crosshair */ "gfx/crosshairhook", /* netname */ "hook", /* fullname */ _("Grappling Hook") ); diff --git a/qcsrc/common/weapons/w_machinegun.qc b/qcsrc/common/weapons/w_machinegun.qc index 2fd5bf27d..acc54f059 100644 --- a/qcsrc/common/weapons/w_machinegun.qc +++ b/qcsrc/common/weapons/w_machinegun.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 1 0', /* model */ "uzi", +/* crosshair */ "gfx/crosshairuzi", /* netname */ "uzi", /* fullname */ _("Machine Gun") ); diff --git a/qcsrc/common/weapons/w_minelayer.qc b/qcsrc/common/weapons/w_minelayer.qc index 19d49b50d..62d0e4ac0 100644 --- a/qcsrc/common/weapons/w_minelayer.qc +++ b/qcsrc/common/weapons/w_minelayer.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '0.75 1 0', /* model */ "minelayer", +/* crosshair */ "gfx/crosshairminelayer", /* netname */ "minelayer", /* fullname */ _("Mine Layer") ); diff --git a/qcsrc/common/weapons/w_mortar.qc b/qcsrc/common/weapons/w_mortar.qc index 39fc9c407..16b10aca4 100644 --- a/qcsrc/common/weapons/w_mortar.qc +++ b/qcsrc/common/weapons/w_mortar.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 0 0', /* model */ "gl", +/* crosshair */ "gfx/crosshairgrenadelauncher", /* netname */ "grenadelauncher", /* fullname */ _("Mortar") ); diff --git a/qcsrc/common/weapons/w_porto.qc b/qcsrc/common/weapons/w_porto.qc index c5b5585d8..1f73ebb82 100644 --- a/qcsrc/common/weapons/w_porto.qc +++ b/qcsrc/common/weapons/w_porto.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ 0, /* color */ '0.5 0.5 0.5', /* model */ "porto" , +/* crosshair */ "gfx/crosshairporto", /* netname */ "porto", /* fullname */ _("Port-O-Launch") ); diff --git a/qcsrc/common/weapons/w_rifle.qc b/qcsrc/common/weapons/w_rifle.qc index 530eccf71..79c029355 100644 --- a/qcsrc/common/weapons/w_rifle.qc +++ b/qcsrc/common/weapons/w_rifle.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0.5 1 0', /* model */ "campingrifle", +/* crosshair */ "gfx/crosshairrifle", /* netname */ "rifle", /* fullname */ _("Rifle") ); diff --git a/qcsrc/common/weapons/w_seeker.qc b/qcsrc/common/weapons/w_seeker.qc index 943734b7b..4608c4962 100644 --- a/qcsrc/common/weapons/w_seeker.qc +++ b/qcsrc/common/weapons/w_seeker.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0.5 1 0', /* model */ "seeker", +/* crosshair */ "gfx/crosshairseeker", /* netname */ "seeker", /* fullname */ _("T.A.G. Seeker") ); diff --git a/qcsrc/common/weapons/w_shockwave.qc b/qcsrc/common/weapons/w_shockwave.qc index c1083c401..1d8e5e6e6 100644 --- a/qcsrc/common/weapons/w_shockwave.qc +++ b/qcsrc/common/weapons/w_shockwave.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_LOW, /* color */ '0.5 0.25 0', /* model */ "shotgun", +/* crosshair */ "gfx/crosshairshotgun", /* netname */ "shockwave", /* fullname */ _("Shockwave") ); diff --git a/qcsrc/common/weapons/w_shotgun.qc b/qcsrc/common/weapons/w_shotgun.qc index 4a678607d..ef6557ef4 100644 --- a/qcsrc/common/weapons/w_shotgun.qc +++ b/qcsrc/common/weapons/w_shotgun.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_LOW, /* color */ '0.5 0.25 0', /* model */ "shotgun", +/* crosshair */ "gfx/crosshairshotgun", /* shortname */ "shotgun", /* fullname */ _("Shotgun") ); diff --git a/qcsrc/common/weapons/w_tuba.qc b/qcsrc/common/weapons/w_tuba.qc index 9c8ea1a20..707d3836a 100644 --- a/qcsrc/common/weapons/w_tuba.qc +++ b/qcsrc/common/weapons/w_tuba.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0 1 0', /* model */ "tuba", +/* crosshair */ "gfx/crosshairtuba", /* netname */ "tuba", /* xgettext:no-c-format */ /* fullname */ _("@!#%'n Tuba") diff --git a/qcsrc/common/weapons/w_vaporizer.qc b/qcsrc/common/weapons/w_vaporizer.qc index 7ef66ab58..4e3b8fc68 100644 --- a/qcsrc/common/weapons/w_vaporizer.qc +++ b/qcsrc/common/weapons/w_vaporizer.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '0.5 1 1', /* model */ "minstanex", +/* crosshair */ "gfx/crosshairminstanex", /* netname */ "minstanex", /* fullname */ _("Vaporizer") ); diff --git a/qcsrc/common/weapons/w_vortex.qc b/qcsrc/common/weapons/w_vortex.qc index c1bda8400..9900dbefb 100644 --- a/qcsrc/common/weapons/w_vortex.qc +++ b/qcsrc/common/weapons/w_vortex.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '0.5 1 1', /* model */ "nex", +/* crosshair */ "gfx/crosshairnex 0.65", /* netname */ "nex", /* fullname */ _("Vortex") ); diff --git a/qcsrc/common/weapons/weapons.qc b/qcsrc/common/weapons/weapons.qc index baf6adb61..97dda801b 100644 --- a/qcsrc/common/weapons/weapons.qc +++ b/qcsrc/common/weapons/weapons.qc @@ -84,6 +84,7 @@ void register_weapon( float pickupbasevalue, vector clr, string modelname, + string crosshair, string shortname, string wname) { @@ -104,6 +105,14 @@ void register_weapon( e.bot_pickupbasevalue = pickupbasevalue; e.ammo_field = ammotype; + // WEAPONTODO: reorganize this + + e.w_crosshair = strzone(car(crosshair)); + string s = cdr(crosshair); + e.w_crosshair_size = ((s != "") ? stof(s) : 1); + + printf("wtf: '%s', '%s', %f.\n", car(crosshair), s, e.w_crosshair_size); + #ifndef MENUQC func(WR_INIT); #endif @@ -129,6 +138,9 @@ void register_weapons_done() dummy_weapon_info.bot_pickupbasevalue = 0; dummy_weapon_info.ammo_field = ammo_none; + dummy_weapon_info.w_crosshair = "gfx/crosshair1"; + dummy_weapon_info.w_crosshair_size = 1; + float i; weaponorder_byid = ""; for(i = WEP_MAXCOUNT; i >= 1; --i) diff --git a/qcsrc/common/weapons/weapons.qh b/qcsrc/common/weapons/weapons.qh index 0f9fba729..3c0ac8577 100644 --- a/qcsrc/common/weapons/weapons.qh +++ b/qcsrc/common/weapons/weapons.qh @@ -139,6 +139,7 @@ void register_weapon( float pickupbasevalue, vector clr, string modelname, + string crosshair, string shortname, string wname); @@ -157,11 +158,14 @@ void register_weapons_done(); .string model2; // A: wpn-id // wpn- sprite name .string mdl; // M: model // modelname without g_, v_, w_ .string model; // A: model // full name of g_ model +.string w_crosshair; +.float w_crosshair_size; .string netname; // M: refname // reference name name .string message; // M: fullname // human readable name + // note: the fabs call is just there to hide "if result is constant" warning -#define REGISTER_WEAPON_2(id,bit,function,ammotype,impulse,flags,rating,color,model,refname,wepname) \ +#define REGISTER_WEAPON_2(id,bit,function,ammotype,impulse,flags,rating,color,model,crosshair,refname,wepname) \ float id; \ WepSet bit; \ float function(float); \ @@ -173,15 +177,15 @@ void register_weapons_done(); if((flags) & WEP_FLAG_SUPERWEAPON) \ WEPSET_SUPERWEAPONS |= bit; \ ++WEP_COUNT; \ - register_weapon(id,bit,function,ammotype,impulse,flags,rating,color,model,refname,wepname); \ + register_weapon(id,bit,function,ammotype,impulse,flags,rating,color,model,crosshair,refname,wepname); \ } \ ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id) #ifdef MENUQC -#define REGISTER_WEAPON(id,function,ammotype,impulse,flags,rating,color,model,refname,wepname) \ - REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,w_null,ammotype,impulse,flags,rating,color,model,refname,wepname) +#define REGISTER_WEAPON(id,function,ammotype,impulse,flags,rating,color,model,crosshair,refname,wepname) \ + REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,w_null,ammotype,impulse,flags,rating,color,model,crosshair,refname,wepname) #else -#define REGISTER_WEAPON(id,function,ammotype,impulse,flags,rating,color,model,refname,wepname) \ - REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,function,ammotype,impulse,flags,rating,color,model,refname,wepname) +#define REGISTER_WEAPON(id,function,ammotype,impulse,flags,rating,color,model,crosshair,refname,wepname) \ + REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,function,ammotype,impulse,flags,rating,color,model,crosshair,refname,wepname) #endif #include "all.qh"