mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-17 19:11:30 +00:00
Allow creating new profiles
This commit is contained in:
parent
debc93ff5c
commit
3aadf1bff0
4 changed files with 42 additions and 11 deletions
|
|
@ -1024,9 +1024,8 @@ static void M_DrawCharSelectCursor(UINT8 num)
|
|||
|
||||
// Draw character profile card.
|
||||
// Moved here because in the case of profile edition this is drawn in the charsel menu.
|
||||
static void M_DrawProfileCard(INT32 x, INT32 y, profile_t *p)
|
||||
static void M_DrawProfileCard(INT32 x, INT32 y, boolean greyedout, profile_t *p)
|
||||
{
|
||||
|
||||
setup_player_t *sp = &setup_player[0]; // When editing profile character, we'll always be checking for what P1 is doing.
|
||||
patch_t *card = W_CachePatchName("PR_CARD", PU_CACHE);
|
||||
patch_t *cardbot = W_CachePatchName("PR_CARDB", PU_CACHE);
|
||||
|
|
@ -1051,7 +1050,10 @@ static void M_DrawProfileCard(INT32 x, INT32 y, profile_t *p)
|
|||
colormap = R_GetTranslationColormap(skinnum, sp->color, GTC_MENUCACHE);
|
||||
|
||||
// Card
|
||||
V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT, 0, card, colormap);
|
||||
V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT, greyedout ? V_TRANSLUCENT : 0, card, colormap);
|
||||
|
||||
if (greyedout)
|
||||
return; // only used for profiles we can't select.
|
||||
|
||||
// Draw pwlv if we can
|
||||
if (powerlevel > -1)
|
||||
|
|
@ -1167,7 +1169,7 @@ void M_DrawCharacterSelect(void)
|
|||
if (optionsmenu.profile == NULL)
|
||||
M_DrawCharSelectPreview(i);
|
||||
else if (i == 0)
|
||||
M_DrawProfileCard(optionsmenu.optx, optionsmenu.opty, optionsmenu.profile);
|
||||
M_DrawProfileCard(optionsmenu.optx, optionsmenu.opty, false, optionsmenu.profile);
|
||||
|
||||
if (i >= setup_numplayers)
|
||||
continue;
|
||||
|
|
@ -2173,6 +2175,7 @@ void M_DrawGenericOptions(void)
|
|||
void M_DrawProfileSelect(void)
|
||||
{
|
||||
INT32 i;
|
||||
const INT32 maxp = PR_GetNumProfiles();
|
||||
INT32 x = 160 - optionsmenu.profilen*(128 + 128/8) + optionsmenu.offset;
|
||||
INT32 y = 35 + menutransition.tics*16;
|
||||
|
||||
|
|
@ -2189,14 +2192,14 @@ void M_DrawProfileSelect(void)
|
|||
|
||||
// don't draw the card in this specific scenario
|
||||
if (!(menutransition.tics && optionsmenu.profile != NULL && optionsmenu.profilen == i))
|
||||
M_DrawProfileCard(x, y, p);
|
||||
M_DrawProfileCard(x, y, i > maxp, p);
|
||||
|
||||
x += 128 + 128/8;
|
||||
}
|
||||
|
||||
// needs to be drawn since it happens on the transition
|
||||
if (optionsmenu.profile != NULL)
|
||||
M_DrawProfileCard(optionsmenu.optx, optionsmenu.opty, optionsmenu.profile);
|
||||
M_DrawProfileCard(optionsmenu.optx, optionsmenu.opty, false, optionsmenu.profile);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2264,7 +2267,7 @@ void M_DrawEditProfile(void)
|
|||
// Finally, draw the card ontop
|
||||
if (optionsmenu.profile != NULL)
|
||||
{
|
||||
M_DrawProfileCard(optionsmenu.optx, optionsmenu.opty, optionsmenu.profile);
|
||||
M_DrawProfileCard(optionsmenu.optx, optionsmenu.opty, false, optionsmenu.profile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3558,6 +3558,7 @@ void M_VideoModeMenu(INT32 choice)
|
|||
void M_HandleProfileSelect(INT32 ch)
|
||||
{
|
||||
const UINT8 pid = 0;
|
||||
const INT32 maxp = PR_GetNumProfiles();
|
||||
(void) ch;
|
||||
|
||||
if (menucmd[pid].dpad_lr > 0)
|
||||
|
|
@ -3565,10 +3566,10 @@ void M_HandleProfileSelect(INT32 ch)
|
|||
optionsmenu.profilen++;
|
||||
optionsmenu.offset += (128 + 128/8);
|
||||
|
||||
if (optionsmenu.profilen > MAXPROFILES)
|
||||
if (optionsmenu.profilen > maxp)
|
||||
{
|
||||
optionsmenu.profilen = 0;
|
||||
optionsmenu.offset -= (128 + 128/8)*(MAXPROFILES+1);
|
||||
optionsmenu.offset -= (128 + 128/8)*(maxp+1);
|
||||
}
|
||||
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
|
|
@ -3582,8 +3583,8 @@ void M_HandleProfileSelect(INT32 ch)
|
|||
|
||||
if (optionsmenu.profilen < 0)
|
||||
{
|
||||
optionsmenu.profilen = MAXPROFILES;
|
||||
optionsmenu.offset += (128 + 128/8)*(MAXPROFILES+1);
|
||||
optionsmenu.profilen = maxp;
|
||||
optionsmenu.offset += (128 + 128/8)*(maxp+1);
|
||||
}
|
||||
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
|
|
@ -3593,6 +3594,10 @@ void M_HandleProfileSelect(INT32 ch)
|
|||
else if (M_MenuButtonPressed(pid, MBT_A) || M_MenuButtonPressed(pid, MBT_X))
|
||||
{
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
|
||||
if (optionsmenu.profilen == maxp)
|
||||
PR_InitNewProfile(); // initialize the new profile.
|
||||
|
||||
optionsmenu.profile = PR_GetProfile(optionsmenu.profilen);
|
||||
|
||||
// This is now used to move the card we've selected.
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@
|
|||
static profile_t profilesList[MAXPROFILES+1]; // +1 because we're gonna add a default "GUEST' profile.
|
||||
static UINT8 numprofiles = 0; // # of loaded profiles
|
||||
|
||||
INT32 PR_GetNumProfiles(void)
|
||||
{
|
||||
return numprofiles;
|
||||
}
|
||||
|
||||
profile_t PR_MakeProfile(const char *prname, const char *pname, const char *sname, const UINT16 col, const char *fname, UINT16 fcol, INT32 controlarray[num_gamecontrols][MAXINPUTMAPPING])
|
||||
{
|
||||
profile_t new;
|
||||
|
|
@ -71,6 +76,17 @@ profile_t* PR_GetProfile(INT32 num)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void PR_InitNewProfile(void)
|
||||
{
|
||||
char pname[PROFILENAMELEN+1] = "PRF";
|
||||
profile_t dprofile;
|
||||
|
||||
strcpy(pname, va("PRF%c", 'A'+numprofiles-1));
|
||||
|
||||
dprofile = PR_MakeProfile(pname, PROFILEDEFAULTPNAME, PROFILEDEFAULTSKIN, PROFILEDEFAULTCOLOR, PROFILEDEFAULTFOLLOWER, PROFILEDEFAULTFOLLOWERCOLOR, gamecontroldefault);
|
||||
PR_AddProfile(dprofile);
|
||||
}
|
||||
|
||||
void PR_SaveProfiles(void)
|
||||
{
|
||||
FILE *f = NULL;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ typedef struct profile_s
|
|||
|
||||
// Functions
|
||||
|
||||
// returns how many profiles there are
|
||||
INT32 PR_GetNumProfiles(void);
|
||||
|
||||
// PR_MakeProfile
|
||||
// Makes a profile from the supplied profile name, player name, colour, follower, followercolour and controls.
|
||||
// The consvar values are left untouched.
|
||||
|
|
@ -87,6 +90,10 @@ boolean PR_AddProfile(profile_t p);
|
|||
// Returns a pointer to the profile you're asking for or NULL if the profile is uninitialized.
|
||||
profile_t* PR_GetProfile(INT32 num);
|
||||
|
||||
// PR_InitNewProfile(void)
|
||||
// Initializes the first new profile
|
||||
void PR_InitNewProfile(void);
|
||||
|
||||
// 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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue