diff --git a/src/k_menu.h b/src/k_menu.h index 9fb09a450..b4a69c861 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -19,6 +19,7 @@ #include "command.h" #include "doomstat.h" // MAXSPLITSCREENPLAYERS #include "g_demo.h" //menudemo_t +#include "k_profiles.h" // profile data & functions // flags for items in the menu // menu handle (what we do when key is pressed @@ -219,6 +220,9 @@ typedef enum mopt_manual, } mopt_e; +extern menuitem_t OPTIONS_Profiles[]; +extern menu_t OPTIONS_ProfilesDef; + extern menuitem_t OPTIONS_Video[]; extern menu_t OPTIONS_VideoDef; @@ -619,8 +623,10 @@ void M_OptionsChangeBGColour(INT16 newcolour); // changes the background colour void M_HandleItemToggles(INT32 choice); // For item toggling void M_EraseData(INT32 choice); // For data erasing -// video modes menu (resolution) +// profile selection menu +void M_HandleProfileSelect(INT32 ch); +// video modes menu (resolution) void M_VideoModeMenu(INT32 choice); void M_HandleVideoModes(INT32 ch); @@ -758,6 +764,7 @@ void M_DrawPlaybackMenu(void); void M_DrawOptionsMovingButton(void); // for sick transitions... void M_DrawOptions(void); void M_DrawGenericOptions(void); +void M_DrawProfileSelect(void); void M_DrawVideoModes(void); void M_DrawItemToggles(void); diff --git a/src/k_menudef.c b/src/k_menudef.c index aeee90865..c75354eb3 100644 --- a/src/k_menudef.c +++ b/src/k_menudef.c @@ -367,8 +367,8 @@ menu_t PLAY_MP_RoomSelectDef = { menuitem_t OPTIONS_Main[] = { - {IT_STRING | IT_TRANSTEXT, "Profile Setup", "Remap keys & buttons to your likings.", - NULL, NULL, 0, 0}, + {IT_STRING | IT_SUBMENU, "Profile Setup", "Remap keys & buttons to your likings.", + NULL, &OPTIONS_ProfilesDef, 0, 0}, {IT_STRING | IT_SUBMENU, "Video Options", "Change video settings such as the resolution.", NULL, &OPTIONS_VideoDef, 0, 0}, @@ -408,6 +408,28 @@ menu_t OPTIONS_MainDef = { M_OptionsInputs }; +// profiles menu +// profile select +menuitem_t OPTIONS_Profiles[] = { + {IT_KEYHANDLER | IT_NOTHING, NULL, "Select a Profile.", + NULL, M_HandleProfileSelect, 0, 0}, // dummy menuitem for the control func +}; + +menu_t OPTIONS_ProfilesDef = { + sizeof (OPTIONS_Profiles) / sizeof (menuitem_t), + &OPTIONS_MainDef, + 0, + OPTIONS_Profiles, + 32, 80, + SKINCOLOR_ULTRAMARINE, 0, + 2, 10, + M_DrawProfileSelect, + M_OptionsTick, + NULL, + NULL, + NULL, +}; + // video options menu... // options menu menuitem_t OPTIONS_Video[] = diff --git a/src/k_menudraw.c b/src/k_menudraw.c index eb91a2c7b..29cc158ee 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -2011,6 +2011,40 @@ void M_DrawGenericOptions(void) } } +// Draws profile selection +void M_DrawProfileSelect(void) +{ + INT32 i; + patch_t *card = W_CachePatchName("PR_CARD", PU_CACHE); + + INT32 x = 160; + INT32 y = 75 + menutransition.tics*16; + + M_DrawOptionsCogs(); + M_DrawMenuTooltips(); + M_DrawOptionsMovingButton(); + + for (i=0; i < MAXPROFILES; i++) + { + profile_t *p = PR_GetProfile(i); + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_BLACK, GTC_CACHE); + char pname[PROFILENAMELEN+1] = "EMPTY"; + + if (p != NULL) + { + colormap = R_GetTranslationColormap(TC_DEFAULT, p->color, GTC_CACHE); + strcpy(pname, p->profilename); + } + + V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT, 0, card, colormap); + V_DrawCenteredGamemodeString(x, y+18, 0, 0, pname); + + CONS_Printf("pname %s\n", pname); + + x += 96; + } +} + // Draw the video modes list, a-la-Quake void M_DrawVideoModes(void) { diff --git a/src/k_menufunc.c b/src/k_menufunc.c index f422aad5d..05b980146 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -3264,6 +3264,10 @@ void M_VideoModeMenu(INT32 choice) M_SetupNextMenu(&OPTIONS_VideoModesDef, false); } +void M_HandleProfileSelect(INT32 ch) +{ + (void) ch; +} // special menuitem key handler for video mode list void M_HandleVideoModes(INT32 ch) diff --git a/src/k_profiles.c b/src/k_profiles.c index 980827765..979c7da83 100644 --- a/src/k_profiles.c +++ b/src/k_profiles.c @@ -19,20 +19,20 @@ static UINT8 numprofiles = 0; // # of loaded profiles profile_t PR_MakeProfile(const char *prname, const char *pname, const UINT16 col, const char *fname, UINT16 fcol, INT32 controlarray[num_gamecontrols][MAXINPUTMAPPING]) { profile_t new; - + new.version = PROFILEVER; - + strcpy(new.profilename, prname); - + strcpy(new.playername, pname); new.color = col; - + strcpy(new.follower, fname); new.followercolor = fcol; - + // Copy from gamecontrol directly as we'll be setting controls up directly in the profile. - memcpy(new.controls, controlarray, sizeof(new.controls)); - + memcpy(new.controls, controlarray, sizeof(new.controls)); + return new; } @@ -40,10 +40,10 @@ profile_t PR_MakeProfileFromPlayer(const char *prname, const char *pname, const { // Generate profile using the player's gamecontrol, as we set them directly when making profiles from menus. profile_t new = PR_MakeProfile(prname, pname, col, fname, fcol, gamecontrol[pnum]); - + // Player bound cvars: new.kickstartaccel = cv_kickstartaccel[pnum].value; - + return new; } @@ -53,35 +53,43 @@ boolean PR_AddProfile(profile_t p) { memcpy(&profilesList[numprofiles], &p, sizeof(profile_t)); numprofiles++; - + CONS_Printf("Profile '%s' added\n", p.profilename); - + return true; } else return false; } +profile_t* PR_GetProfile(INT32 num) +{ + if (num < numprofiles) + return &profilesList[num]; + else + return NULL; +} + void PR_SaveProfiles(void) { FILE *f = NULL; - + f = fopen(PROFILESFILE, "w"); if (f != NULL) { fwrite(profilesList, sizeof(profile_t), MAXPROFILES, f); fclose(f); } -} +} void PR_LoadProfiles(void) { //FILE *f = NULL; profile_t dprofile = PR_MakeProfile(PROFILEDEFAULTNAME, PROFILEDEFAULTPNAME, PROFILEDEFAULTCOLOR, PROFILEDEFAULTFOLLOWER, PROFILEDEFAULTFOLLOWERCOLOR, gamecontroldefault); PR_AddProfile(dprofile); - + /*f = fopen(PROFILESFILE, "r"); - + if (f != NULL) { fread(&profilesList[1], sizeof(profile_t)*(MAXPROFILES), MAXPROFILES, f); diff --git a/src/k_profiles.h b/src/k_profiles.h index ccd8bd2fb..7611fa43f 100644 --- a/src/k_profiles.h +++ b/src/k_profiles.h @@ -26,7 +26,7 @@ #define SKINNAMESIZE 16 #define PROFILENAMELEN 6 -#define PROFILEVER 0 +#define PROFILEVER 1 #define MAXPROFILES 16 #define PROFILESFILE "kartprofiles.cfg" @@ -40,25 +40,26 @@ // Man I wish I had more than 16 friends!! // profile_t definition (WIP) -typedef struct profile_s +typedef struct profile_s { - + // Versionning UINT8 version; // Version of the profile, this can be useful for backwards compatibility reading if we ever update the profile structure/format after release. + // A version of 0 can easily be checked to identify an unitialized profile. // Profile header char profilename[PROFILENAMELEN+1]; // Profile name (not to be confused with player name) - + // Player data char playername[MAXPLAYERNAME+1]; // Player name UINT16 color; // Default player coloUr. ...But for consistency we'll name it color. char follower[SKINNAMESIZE+1]; // Follower UINT16 followercolor; // Follower color - + // Player-specific consvars. // @TODO: List all of those boolean kickstartaccel; // cv_kickstartaccel - + // Finally, control data itself INT32 controls[num_gamecontrols][MAXINPUTMAPPING]; // Lists of all the controls, defined the same way as default inputs in g_input.c } profile_t; @@ -81,6 +82,10 @@ profile_t PR_MakeProfileFromPlayer(const char *prname, const char *pname, const // Returns true if succesful, false if not. boolean PR_AddProfile(profile_t p); +// PR_GetProfile(INT32 num) +// Returns a pointer to the profile you're asking for or NULL if the profile is uninitialized. +profile_t* PR_GetProfile(INT32 num); + // PR_SaveProfiles(void) // Saves all the profiles in profiles.cfg // This does not save profilesList[0] since that's always going to be the default profile. @@ -88,7 +93,7 @@ void PR_SaveProfiles(void); // PR_LoadProfiles(void) // Loads all the profiles saved in profiles.cfg. -// This also loads +// This also loads void PR_LoadProfiles(void);