Skip to content

Commit

Permalink
UI/CLIENT: Add gender selection option to player settings menu
Browse files Browse the repository at this point in the history
also set "model" as default gender instead of "none" or "male".
  • Loading branch information
kai-li-wop committed Oct 30, 2023
1 parent fcea6d3 commit b0b2753
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 38 deletions.
2 changes: 1 addition & 1 deletion code/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3394,7 +3394,7 @@ void CL_Init(void) {
Cvar_Get("team_model", "padman", CVAR_USERINFO | CVAR_ARCHIVE);
Cvar_Get("team_headmodel", "padman", CVAR_USERINFO | CVAR_ARCHIVE);
Cvar_Get("handicap", "100", CVAR_USERINFO | CVAR_ARCHIVE);
Cvar_Get("sex", "none", CVAR_USERINFO | CVAR_ARCHIVE);
Cvar_Get("sex", "model", CVAR_USERINFO | CVAR_ARCHIVE);
Cvar_Get("cl_anonymous", "0", CVAR_USERINFO | CVAR_ARCHIVE);

Cvar_Get("password", "", CVAR_USERINFO);
Expand Down
100 changes: 63 additions & 37 deletions code/ui/ui_playersettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#define ID_NAME 10
#define ID_HANDICAP 11
#define ID_SKINCOLOR 12
#define ID_EFFECTS 13
#define ID_BACK 14

#define ID_PREVMODEL 15
#define ID_NEXTMODEL 16
#define ID_PREVSKIN 17
#define ID_NEXTSKIN 18
#define ID_MICON 19 //+4
#define ID_SICON 24//+2
#define ID_PLAYERMODEL 27
#define ID_SPRAYCOLOR 28
#define ID_NEXTLOGO 29
#define ID_PREVLOGO 30
#define ID_GENDER 12
#define ID_SKINCOLOR 13
#define ID_EFFECTS 14
#define ID_BACK 15

#define ID_PREVMODEL 16
#define ID_NEXTMODEL 17
#define ID_PREVSKIN 18
#define ID_NEXTSKIN 19
#define ID_MICON 20 //+4
#define ID_SICON 25//+2
#define ID_PLAYERMODEL 28
#define ID_SPRAYCOLOR 29
#define ID_NEXTLOGO 30
#define ID_PREVLOGO 31

#define MAX_NAMELENGTH 20

Expand All @@ -73,9 +74,8 @@ typedef struct {

menutext_s nameheader;
menufield_s name;
menutext_s handicapheader;
menulist_s handicap;
menutext_s skincolorheader;
menulist_s gender;
menulist_s skincolor;
menutext_s logoheader;
menulist_s effects;
Expand Down Expand Up @@ -116,6 +116,8 @@ static playersettings_t s_playersettings;
static int gamecodetoui[] = {4, 2, 3, 0, 5, 1, 6};
static int uitogamecode[] = {4, 6, 2, 3, 1, 5, 7};

static const char *gender_items[] = {"Model", "Male", "Female", "Neuter", "None", NULL};

static const char *handicap_items[] = {S_COLOR_WHITE "None",
S_COLOR_WHITE "90",
S_COLOR_WHITE "80",
Expand Down Expand Up @@ -251,6 +253,7 @@ PlayerSettings_SaveChanges
=================
*/
static void PlayerSettings_SaveChanges(void) {
int g;

// name
trap_Cvar_Set("name", s_playersettings.name.field.buffer);
Expand All @@ -261,6 +264,21 @@ static void PlayerSettings_SaveChanges(void) {
// effects color
trap_Cvar_SetValue("color1", uitogamecode[s_playersettings.effects.curvalue]);

// gender
g = s_playersettings.gender.curvalue;
if (g > 3) {
trap_Cvar_Set("sex", "none");
} else if (g == 1) {
trap_Cvar_Set("sex", "male");
} else if (g == 2) {
trap_Cvar_Set("sex", "female");
} else if (g == 3) {
trap_Cvar_Set("sex", "neuter");
} else {
trap_Cvar_Set("sex", "model");
}

// spray logo
trap_Cvar_Set("syc_logo", uis.spraylogoNames[s_playersettings.slogo_num]);

if (trap_Cvar_VariableValue("cl_paused")) {
Expand Down Expand Up @@ -312,6 +330,7 @@ static void PlayerSettings_SetMenuItems(void) {
vec3_t viewangles;
int c;
int h;
char gStr[32];

// name
Q_strncpyz(s_playersettings.name.field.buffer, UI_Cvar_VariableString("name"),
Expand Down Expand Up @@ -377,6 +396,19 @@ static void PlayerSettings_SetMenuItems(void) {
h = Com_Clamp(10, 100, trap_Cvar_VariableValue("handicap"));
s_playersettings.handicap.curvalue = 10 - h / 10;

// gender
trap_Cvar_VariableStringBuffer("sex", gStr, sizeof(gStr));
if (!Q_stricmp(gStr, "none")) {
s_playersettings.gender.curvalue = 4;
} else if (!Q_stricmp(gStr, "neuter")) {
s_playersettings.gender.curvalue = 3;
} else if (!Q_stricmp(gStr, "female")) {
s_playersettings.gender.curvalue = 2;
} else if (!Q_stricmp(gStr, "male")) {
s_playersettings.gender.curvalue = 1;
} else {
s_playersettings.gender.curvalue = 0;
}
}

static int GetSpecialSkinScore(const char *iconPath) {
Expand Down Expand Up @@ -726,6 +758,7 @@ static void PlayerSettings_MenuEvent(void *ptr, int event) {
switch (tmpid) {

case ID_HANDICAP:
case ID_GENDER:
break;

case ID_SKINCOLOR:
Expand Down Expand Up @@ -1033,42 +1066,36 @@ static void PlayerSettings_MenuInit(void) {
s_playersettings.name.generic.bottom = y + 2 * (BIGCHAR_HEIGHT);

y += 2 * (BIGCHAR_HEIGHT + 2);
s_playersettings.handicapheader.generic.type = MTYPE_TEXT;
s_playersettings.handicapheader.generic.x = XPOSITION;
s_playersettings.handicapheader.generic.y = y;
s_playersettings.handicapheader.string = "Handicap:";
s_playersettings.handicapheader.style = UI_LEFT | UI_SMALLFONT;
s_playersettings.handicapheader.color = color_yellow;

y += BIGCHAR_HEIGHT + 2;
s_playersettings.handicap.generic.type = MTYPE_SPINCONTROL;
s_playersettings.handicap.generic.name = "";
s_playersettings.handicap.generic.name = "Cap:";
s_playersettings.handicap.generic.flags = QMF_SMALLFONT;
s_playersettings.handicap.generic.id = ID_HANDICAP;
s_playersettings.handicap.generic.callback = PlayerSettings_MenuEvent;
s_playersettings.handicap.generic.x = XPOSITION;
s_playersettings.handicap.generic.x = XPOSITION + 48;
s_playersettings.handicap.generic.y = y;
s_playersettings.handicap.itemnames = handicap_items;

y += BIGCHAR_HEIGHT + 2;
s_playersettings.skincolorheader.generic.type = MTYPE_TEXT;
s_playersettings.skincolorheader.generic.x = XPOSITION;
s_playersettings.skincolorheader.generic.y = y;
s_playersettings.skincolorheader.string = "Skin Color:";
s_playersettings.skincolorheader.style = UI_LEFT | UI_SMALLFONT;
s_playersettings.skincolorheader.color = color_yellow;
s_playersettings.gender.generic.type = MTYPE_SPINCONTROL;
s_playersettings.gender.generic.name = "Sex:";
s_playersettings.gender.generic.flags = QMF_SMALLFONT;
s_playersettings.gender.generic.id = ID_GENDER;
s_playersettings.gender.generic.callback = PlayerSettings_MenuEvent;
s_playersettings.gender.generic.x = XPOSITION + 48;
s_playersettings.gender.generic.y = y;
s_playersettings.gender.itemnames = gender_items;

y += BIGCHAR_HEIGHT + 2;
s_playersettings.skincolor.generic.type = MTYPE_SPINCONTROL;
s_playersettings.skincolor.generic.name = "";
s_playersettings.skincolor.generic.name = "Color:";
s_playersettings.skincolor.generic.flags = QMF_SMALLFONT;
s_playersettings.skincolor.generic.id = ID_SKINCOLOR;
s_playersettings.skincolor.generic.callback = PlayerSettings_MenuEvent;
s_playersettings.skincolor.generic.x = XPOSITION;
s_playersettings.skincolor.generic.x = XPOSITION + 48;
s_playersettings.skincolor.generic.y = y;
s_playersettings.skincolor.itemnames = skincolor_items;

y += BIGCHAR_HEIGHT + 2;
y += 2 * (BIGCHAR_HEIGHT + 2);
s_playersettings.logoheader.generic.type = MTYPE_TEXT;
s_playersettings.logoheader.generic.x = XPOSITION;
s_playersettings.logoheader.generic.y = y;
Expand Down Expand Up @@ -1098,9 +1125,8 @@ static void PlayerSettings_MenuInit(void) {

Menu_AddItem(&s_playersettings.menu, &s_playersettings.nameheader);
Menu_AddItem(&s_playersettings.menu, &s_playersettings.name);
Menu_AddItem(&s_playersettings.menu, &s_playersettings.handicapheader);
Menu_AddItem(&s_playersettings.menu, &s_playersettings.handicap);
Menu_AddItem(&s_playersettings.menu, &s_playersettings.skincolorheader);
Menu_AddItem(&s_playersettings.menu, &s_playersettings.gender);
Menu_AddItem(&s_playersettings.menu, &s_playersettings.skincolor);
Menu_AddItem(&s_playersettings.menu, &s_playersettings.logoheader);
Menu_AddItem(&s_playersettings.menu, &s_playersettings.logoleft);
Expand Down

0 comments on commit b0b2753

Please sign in to comment.