forked from Ports/perfect_dark
Add option to change crosshair alpha, and could provide fully custom colors. Proof of concept.
This commit is contained in:
1 parent
0a7faf2409
commit
342e186f79
5 files changed
+93
-1
No files matched your search
@@ -166,5 +166,7 @@ PD_CONSTRUCTOR static void gameConfigInit(void)
|
||||
configRegisterFloat(strFmt("Game.Player%d.CrosshairSway", i), &g_PlayerExtCfg[j].crosshairsway, 0.f, 10.f);
|
||||
configRegisterInt(strFmt("Game.Player%d.CrouchMode", i), &g_PlayerExtCfg[j].crouchmode, 0, CROUCHMODE_TOGGLE_ANALOG);
|
||||
configRegisterInt(strFmt("Game.Player%d.ExtendedControls", i), &g_PlayerExtCfg[j].extcontrols, 0, 1);
|
||||
configRegisterInt(strFmt("Game.Player%d.CrosshairAlpha", i), &g_PlayerExtCfg[j].crosshairalpha, 0, 255);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -903,6 +903,33 @@ static MenuItemHandlerResult menuhandlerCrosshairSway(s32 operation, struct menu
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SIGHT_COLOUR_R 0;
|
||||
#define SIGHT_COLOUR_G 255;
|
||||
#define SIGHT_COLOUR_B 0;
|
||||
|
||||
static u32 RGBAToINT(u32 r, u32 g, u32 b, u32 a)
|
||||
{
|
||||
return (((r) & 0xff) << 24 | ((g) & 0xff) << 16 | ((b) & 0xff) << 8 | ((a) & 0xff));
|
||||
}
|
||||
|
||||
static MenuItemHandlerResult menuhandlerCrosshairAlpha(s32 operation, struct menuitem* item, union handlerdata* data)
|
||||
{
|
||||
switch (operation) {
|
||||
case MENUOP_GETSLIDER:
|
||||
data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].crosshairalpha;
|
||||
break;
|
||||
case MENUOP_SET:
|
||||
g_PlayerExtCfg[g_ExtMenuPlayer].crosshairalpha = data->slider.value;
|
||||
|
||||
g_PlayerExtCfg[g_ExtMenuPlayer].crosshaircolour = RGBAToINT(SIGHT_COLOUR_R, SIGHT_COLOUR_G, SIGHT_COLOUR_B, g_PlayerExtCfg[g_ExtMenuPlayer].crosshairalpha);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct menuitem g_ExtendedGameMenuItems[] = {
|
||||
{
|
||||
MENUITEMTYPE_DROPDOWN,
|
||||
@@ -928,6 +955,14 @@ struct menuitem g_ExtendedGameMenuItems[] = {
|
||||
20,
|
||||
menuhandlerCrosshairSway,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_SLIDER,
|
||||
0,
|
||||
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE,
|
||||
(uintptr_t)"Crosshair Alpha",
|
||||
255,
|
||||
menuhandlerCrosshairAlpha,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_SEPARATOR,
|
||||
0,
|
||||
|
||||
@@ -121,7 +121,8 @@ struct mpweapon g_MpWeapons[NUM_MPWEAPONS] = {
|
||||
.radialmenuspeed = 4.f, \
|
||||
.crosshairsway = 1.f, \
|
||||
.crouchmode = CROUCHMODE_TOGGLE_ANALOG, \
|
||||
.extcontrols = true, \
|
||||
.crosshairalpha = 40, \
|
||||
.crosshaircolour = 0x00ff0028, \
|
||||
}
|
||||
|
||||
struct extplayerconfig g_PlayerExtCfg[MAX_PLAYERS] = {
|
||||
|
||||
@@ -459,7 +459,11 @@ Gfx *sightDrawAimer(Gfx *gdl, s32 x, s32 y, s32 radius, s32 cornergap, u32 colou
|
||||
s32 viewright = viewleft + viewwidth - 1;
|
||||
s32 viewbottom = viewtop + viewheight - 1;
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
gdl = textSetPrimColour(gdl, PLAYER_EXTCFG().crosshaircolour);
|
||||
#else
|
||||
gdl = textSetPrimColour(gdl, 0x00ff0028);
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
x = sightGetAdjustedX(x);
|
||||
@@ -619,7 +623,11 @@ Gfx *sightDrawDelayedAimer(Gfx *gdl, s32 x, s32 y, s32 radius, s32 cornergap, u3
|
||||
boxx = xpos;
|
||||
boxy = ypos;
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
gdl = textSetPrimColour(gdl, PLAYER_EXTCFG().crosshaircolour);
|
||||
#else
|
||||
gdl = textSetPrimColour(gdl, 0x00ff0028);
|
||||
#endif
|
||||
|
||||
// Fill a 3x3 box at the live crosshair
|
||||
gDPHudRectangle(gdl++, x - 1, y - 1, x + 1, y - 1);
|
||||
@@ -677,7 +685,13 @@ Gfx *sightDrawDefault(Gfx *gdl, bool sighton)
|
||||
// SIGHTTRACKTYPE_NONE is used for unarmed, but this appears to be
|
||||
// unreachable. The aimer is never drawn when unarmed.
|
||||
if (sighton) {
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
colour = PLAYER_EXTCFG().crosshaircolour;
|
||||
#else
|
||||
colour = 0x00ff0028;
|
||||
#endif
|
||||
|
||||
radius = 8;
|
||||
cornergap = 5;
|
||||
gdl = sightDrawAimer(gdl, x, y, radius, cornergap, colour);
|
||||
@@ -687,7 +701,13 @@ Gfx *sightDrawDefault(Gfx *gdl, bool sighton)
|
||||
// For most guns, render the aimer if holding R
|
||||
if (sighton) {
|
||||
if (g_Vars.currentplayer->lookingatprop.prop == NULL) {
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
colour = PLAYER_EXTCFG().crosshaircolour;
|
||||
#else
|
||||
colour = 0x00ff0028;
|
||||
#endif
|
||||
|
||||
radius = 8;
|
||||
cornergap = 5;
|
||||
} else {
|
||||
@@ -716,7 +736,13 @@ Gfx *sightDrawDefault(Gfx *gdl, bool sighton)
|
||||
s32 texty;
|
||||
|
||||
if (g_Vars.currentplayer->lookingatprop.prop == NULL) {
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
colour = PLAYER_EXTCFG().crosshaircolour;
|
||||
#else
|
||||
colour = 0x00ff0028;
|
||||
#endif
|
||||
|
||||
radius = 8;
|
||||
cornergap = 5;
|
||||
} else {
|
||||
@@ -761,7 +787,13 @@ Gfx *sightDrawDefault(Gfx *gdl, bool sighton)
|
||||
|
||||
if (sighton) {
|
||||
if (g_Vars.currentplayer->lookingatprop.prop == NULL) {
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
colour = PLAYER_EXTCFG().crosshaircolour;
|
||||
#else
|
||||
colour = 0x00ff0028;
|
||||
#endif
|
||||
|
||||
radius = 8;
|
||||
cornergap = 5;
|
||||
} else {
|
||||
@@ -832,7 +864,13 @@ Gfx *sightDrawDefault(Gfx *gdl, bool sighton)
|
||||
|
||||
if (sighton) {
|
||||
if (g_Vars.currentplayer->lookingatprop.prop == NULL) {
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
colour = PLAYER_EXTCFG().crosshaircolour;
|
||||
#else
|
||||
colour = 0x00ff0028;
|
||||
#endif
|
||||
|
||||
radius = 8;
|
||||
cornergap = 5;
|
||||
} else {
|
||||
@@ -1252,7 +1290,12 @@ Gfx *sightDrawZoom(Gfx *gdl, bool sighton)
|
||||
|
||||
if (showzoomrange) {
|
||||
gdl = text0f153628(gdl);
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
gdl = textSetPrimColour(gdl, PLAYER_EXTCFG().crosshaircolour);
|
||||
#else
|
||||
gdl = textSetPrimColour(gdl, 0x00ff0028);
|
||||
#endif
|
||||
|
||||
if (frac < 0.2f) {
|
||||
cornerwidth *= 0.2f;
|
||||
@@ -1436,7 +1479,12 @@ Gfx *sightDrawMaian(Gfx *gdl, bool sighton)
|
||||
gSPTri4(gdl++, 0, 4, 5, 5, 3, 6, 7, 6, 1, 4, 7, 2);
|
||||
|
||||
gdl = func0f0d49c8(gdl);
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
gdl = textSetPrimColour(gdl, PLAYER_EXTCFG().crosshaircolour);
|
||||
#else
|
||||
gdl = textSetPrimColour(gdl, 0x00ff0028);
|
||||
#endif
|
||||
|
||||
// Draw border over inner points
|
||||
gDPHudRectangle(gdl++, x - 4, y - 4, x - 4, y + 4); // left
|
||||
@@ -1464,7 +1512,11 @@ Gfx *sightDrawTarget(Gfx *gdl)
|
||||
mainOverrideVariable("sout", &var80070f9c);
|
||||
mainOverrideVariable("sin", &var80070fa0);
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
gdl = textSetPrimColour(gdl, PLAYER_EXTCFG().crosshaircolour);
|
||||
#else
|
||||
gdl = textSetPrimColour(gdl, 0x00ff0028);
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
gSPSetExtraGeometryModeEXT(gdl++, G_ASPECT_CENTER_EXT);
|
||||
|
||||
@@ -6139,6 +6139,8 @@ struct extplayerconfig {
|
||||
f32 radialmenuspeed;
|
||||
f32 crosshairsway;
|
||||
s32 extcontrols;
|
||||
u32 crosshairalpha;
|
||||
u32 crosshaircolour;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user