Skip to content

Commit

Permalink
Merge pull request #332 from Calinou/add-crosshair-size-option
Browse files Browse the repository at this point in the history
Add a crosshair size option
  • Loading branch information
fgsfdsfgs authored Jan 14, 2024
2 parents 9afc7e1 + de14f90 commit 2cb52b7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions port/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,6 @@ PD_CONSTRUCTOR static void gameConfigInit(void)
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);
configRegisterUInt(strFmt("Game.Player%d.CrosshairColour", i), &g_PlayerExtCfg[j].crosshaircolour, 0, 0xFFFFFFFF);
configRegisterUInt(strFmt("Game.Player%d.CrosshairSize", i), &g_PlayerExtCfg[j].crosshairsize, 0, 4);
}
}
22 changes: 22 additions & 0 deletions port/src/optionsmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,20 @@ static MenuItemHandlerResult menuhandlerCrosshairColorPreview(s32 operation, str
return 0;
}

static MenuItemHandlerResult menuhandlerCrosshairSize(s32 operation, struct menuitem *item, union handlerdata *data)
{
switch (operation) {
case MENUOP_GETSLIDER:
data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].crosshairsize;
break;
case MENUOP_SET:
g_PlayerExtCfg[g_ExtMenuPlayer].crosshairsize = data->slider.value;
break;
}

return 0;
}

struct menuitem g_ExtendedGameCrosshairColourMenuItems[] = {
{
MENUITEMTYPE_SLIDER,
Expand Down Expand Up @@ -1128,6 +1142,14 @@ struct menuitem g_ExtendedGameMenuItems[] = {
20,
menuhandlerCrosshairSway,
},
{
MENUITEMTYPE_SLIDER,
0,
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE,
(uintptr_t)"Crosshair Size",
4,
menuhandlerCrosshairSize,
},
{
MENUITEMTYPE_SELECTABLE,
0,
Expand Down
1 change: 1 addition & 0 deletions src/game/mplayer/mplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ struct mpweapon g_MpWeapons[NUM_MPWEAPONS] = {
.crouchmode = CROUCHMODE_TOGGLE_ANALOG, \
.extcontrols = true, \
.crosshaircolour = 0x00ff0028, \
.crosshairsize = 2, \
}

struct extplayerconfig g_PlayerExtCfg[MAX_LOCAL_PLAYERS] = {
Expand Down
23 changes: 15 additions & 8 deletions src/game/sight.c
Original file line number Diff line number Diff line change
Expand Up @@ -1473,14 +1473,21 @@ Gfx *sightDrawTarget(Gfx *gdl)
gSPSetExtraGeometryModeEXT(gdl++, G_ASPECT_CENTER_EXT);
#endif

gDPHudRectangle(gdl++, x + 2, y + 0, x + 6, y + 0);
gDPHudRectangle(gdl++, x + 2, y + 0, x + 4, y + 0);
gDPHudRectangle(gdl++, x - 6, y + 0, x - 2, y + 0);
gDPHudRectangle(gdl++, x - 4, y + 0, x - 2, y + 0);
gDPHudRectangle(gdl++, x + 0, y + 2, x + 0, y + 6);
gDPHudRectangle(gdl++, x + 0, y + 2, x + 0, y + 4);
gDPHudRectangle(gdl++, x + 0, y - 6, x + 0, y - 2);
gDPHudRectangle(gdl++, x + 0, y - 4, x + 0, y - 2);
#define SIGHT_SCALE PLAYER_EXTCFG().crosshairsize

if (SIGHT_SCALE == 0) {
// Draw single rectangle to preserve intended opacity
gDPHudRectangle(gdl++, x, y, x, y);
} else {
gDPHudRectangle(gdl++, x + 1 * SIGHT_SCALE, y + 0 * SIGHT_SCALE, x + 3 * SIGHT_SCALE, y + 0 * SIGHT_SCALE);
gDPHudRectangle(gdl++, x + 1 * SIGHT_SCALE, y + 0 * SIGHT_SCALE, x + 2 * SIGHT_SCALE, y + 0 * SIGHT_SCALE);
gDPHudRectangle(gdl++, x - 3 * SIGHT_SCALE, y + 0 * SIGHT_SCALE, x - 1 * SIGHT_SCALE, y + 0 * SIGHT_SCALE);
gDPHudRectangle(gdl++, x - 2 * SIGHT_SCALE, y + 0 * SIGHT_SCALE, x - 1 * SIGHT_SCALE, y + 0 * SIGHT_SCALE);
gDPHudRectangle(gdl++, x + 0 * SIGHT_SCALE, y + 1 * SIGHT_SCALE, x + 0 * SIGHT_SCALE, y + 3 * SIGHT_SCALE);
gDPHudRectangle(gdl++, x + 0 * SIGHT_SCALE, y + 1 * SIGHT_SCALE, x + 0 * SIGHT_SCALE, y + 2 * SIGHT_SCALE);
gDPHudRectangle(gdl++, x + 0 * SIGHT_SCALE, y - 3 * SIGHT_SCALE, x + 0 * SIGHT_SCALE, y - 1 * SIGHT_SCALE);
gDPHudRectangle(gdl++, x + 0 * SIGHT_SCALE, y - 2 * SIGHT_SCALE, x + 0 * SIGHT_SCALE, y - 1 * SIGHT_SCALE);
}

#ifndef PLATFORM_N64
gSPClearExtraGeometryModeEXT(gdl++, G_ASPECT_CENTER_EXT);
Expand Down
1 change: 1 addition & 0 deletions src/include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6155,6 +6155,7 @@ struct extplayerconfig {
f32 crosshairsway;
s32 extcontrols;
u32 crosshaircolour;
u32 crosshairsize;
};

#endif
Expand Down

0 comments on commit 2cb52b7

Please sign in to comment.