mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
profiles: they work(?) now
This commit is contained in:
parent
3aadf1bff0
commit
2b74b7188f
5 changed files with 188 additions and 12 deletions
|
|
@ -461,6 +461,7 @@ extern struct setup_chargrid_s {
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
CSSTEP_NONE = 0,
|
CSSTEP_NONE = 0,
|
||||||
|
CSSTEP_PROFILE,
|
||||||
CSSTEP_CHARS,
|
CSSTEP_CHARS,
|
||||||
CSSTEP_ALTS,
|
CSSTEP_ALTS,
|
||||||
CSSTEP_COLORS,
|
CSSTEP_COLORS,
|
||||||
|
|
@ -470,6 +471,7 @@ typedef enum
|
||||||
typedef struct setup_player_s
|
typedef struct setup_player_s
|
||||||
{
|
{
|
||||||
SINT8 gridx, gridy;
|
SINT8 gridx, gridy;
|
||||||
|
UINT8 profilen;
|
||||||
SINT8 skin;
|
SINT8 skin;
|
||||||
SINT8 clonenum;
|
SINT8 clonenum;
|
||||||
SINT8 rotate;
|
SINT8 rotate;
|
||||||
|
|
|
||||||
|
|
@ -929,6 +929,41 @@ static void M_DrawCharSelectPreview(UINT8 num)
|
||||||
V_DrawScaledPatch(x+9, y+2, 0, W_CachePatchName("FILEBACK", PU_CACHE));
|
V_DrawScaledPatch(x+9, y+2, 0, W_CachePatchName("FILEBACK", PU_CACHE));
|
||||||
V_DrawScaledPatch(x, y+2, 0, W_CachePatchName(va("CHARSEL%c", letter), PU_CACHE));
|
V_DrawScaledPatch(x, y+2, 0, W_CachePatchName(va("CHARSEL%c", letter), PU_CACHE));
|
||||||
V_DrawFileString(x+16, y+2, 0, "PLAYER");
|
V_DrawFileString(x+16, y+2, 0, "PLAYER");
|
||||||
|
|
||||||
|
// Profile selection
|
||||||
|
if (p->mdepth == CSSTEP_PROFILE)
|
||||||
|
{
|
||||||
|
UINT8 i = 0;
|
||||||
|
INT16 px = x+12;
|
||||||
|
INT16 py = y+48 - p->profilen*12;
|
||||||
|
UINT8 maxp = MAXPROFILES+1;
|
||||||
|
|
||||||
|
for (i=0; i < maxp; i++)
|
||||||
|
{
|
||||||
|
profile_t *pr = PR_GetProfile(i);
|
||||||
|
INT16 dist = abs(p->profilen - i);
|
||||||
|
|
||||||
|
if (dist > 2)
|
||||||
|
{
|
||||||
|
py += 12;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (dist == 2)
|
||||||
|
{
|
||||||
|
V_DrawCenteredFileString(px+26, py, 0, pr->version ? pr->profilename : "EMPTY");
|
||||||
|
V_DrawScaledPatch(px, py, V_TRANSLUCENT, W_CachePatchName("FILEBACK", PU_CACHE));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
V_DrawScaledPatch(px, py, 0, W_CachePatchName("FILEBACK", PU_CACHE));
|
||||||
|
|
||||||
|
if (i != p->profilen || ((setup_animcounter/10) & 1))
|
||||||
|
V_DrawCenteredFileString(px+26, py, 0, pr->version ? pr->profilename : "EMPTY");
|
||||||
|
}
|
||||||
|
py += 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_DrawCharSelectExplosions(void)
|
static void M_DrawCharSelectExplosions(void)
|
||||||
|
|
|
||||||
111
src/k_menufunc.c
111
src/k_menufunc.c
|
|
@ -2134,6 +2134,9 @@ static boolean M_HandlePressStart(setup_player_t *p, UINT8 num)
|
||||||
{
|
{
|
||||||
INT32 i, j;
|
INT32 i, j;
|
||||||
|
|
||||||
|
if (optionsmenu.profile)
|
||||||
|
return false; // Don't allow for the possibility of SOMEHOW another player joining in.
|
||||||
|
|
||||||
// Detect B press first ... this means P1 can actually exit out of the menu.
|
// Detect B press first ... this means P1 can actually exit out of the menu.
|
||||||
if (M_MenuButtonPressed(num, MBT_B) || M_MenuButtonPressed(num, MBT_Y))
|
if (M_MenuButtonPressed(num, MBT_B) || M_MenuButtonPressed(num, MBT_Y))
|
||||||
{
|
{
|
||||||
|
|
@ -2182,7 +2185,7 @@ static boolean M_HandlePressStart(setup_player_t *p, UINT8 num)
|
||||||
CONS_Printf("========\n");
|
CONS_Printf("========\n");
|
||||||
|
|
||||||
//setup_numplayers++;
|
//setup_numplayers++;
|
||||||
p->mdepth = CSSTEP_CHARS;
|
p->mdepth = CSSTEP_PROFILE;
|
||||||
S_StartSound(NULL, sfx_s3k65);
|
S_StartSound(NULL, sfx_s3k65);
|
||||||
|
|
||||||
// Prevent quick presses for multiple players
|
// Prevent quick presses for multiple players
|
||||||
|
|
@ -2201,6 +2204,94 @@ static boolean M_HandlePressStart(setup_player_t *p, UINT8 num)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sets up the grid pos for the skin used by the profile.
|
||||||
|
static void M_SetupProfileGridPos(setup_player_t *p)
|
||||||
|
{
|
||||||
|
profile_t *pr = PR_GetProfile(p->profilen);
|
||||||
|
INT32 i;
|
||||||
|
|
||||||
|
for (i = 0; i < numskins; i++)
|
||||||
|
{
|
||||||
|
if (!(strcmp(pr->skinname, skins[i].name)))
|
||||||
|
{
|
||||||
|
INT32 alt = 0; // Hey it's my character's name!
|
||||||
|
p->gridx = skins[i].kartspeed-1;
|
||||||
|
p->gridy = skins[i].kartweight-1;
|
||||||
|
|
||||||
|
// Now this put our cursor on the good alt
|
||||||
|
while (setup_chargrid[p->gridx][p->gridy].skinlist[alt] != i)
|
||||||
|
alt++;
|
||||||
|
|
||||||
|
p->clonenum = alt;
|
||||||
|
p->color = pr->color;
|
||||||
|
return; // we're done here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean M_HandleCSelectProfile(setup_player_t *p, UINT8 num)
|
||||||
|
{
|
||||||
|
const UINT8 maxp = MAXPROFILES;
|
||||||
|
UINT8 i;
|
||||||
|
|
||||||
|
if (menucmd[num].dpad_ud > 0)
|
||||||
|
{
|
||||||
|
p->profilen++;
|
||||||
|
if (p->profilen > maxp)
|
||||||
|
p->profilen = 0;
|
||||||
|
|
||||||
|
S_StartSound(NULL, sfx_menu1);
|
||||||
|
M_SetMenuDelay(num);
|
||||||
|
}
|
||||||
|
else if (menucmd[num].dpad_ud < 0)
|
||||||
|
{
|
||||||
|
if (p->profilen == 0)
|
||||||
|
p->profilen = maxp;
|
||||||
|
else
|
||||||
|
p->profilen--;
|
||||||
|
|
||||||
|
S_StartSound(NULL, sfx_menu1);
|
||||||
|
M_SetMenuDelay(num);
|
||||||
|
}
|
||||||
|
else if (M_MenuButtonPressed(num, MBT_B) || M_MenuButtonPressed(num, MBT_Y))
|
||||||
|
{
|
||||||
|
if (num == setup_numplayers-1)
|
||||||
|
{
|
||||||
|
|
||||||
|
p->mdepth = CSSTEP_NONE;
|
||||||
|
S_StartSound(NULL, sfx_s3k5b);
|
||||||
|
|
||||||
|
// Prevent quick presses for multiple players
|
||||||
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
|
{
|
||||||
|
setup_player[i].delay = MENUDELAYTIME;
|
||||||
|
M_SetMenuDelay(i);
|
||||||
|
menucmd[i].buttonsHeld |= (MBT_B|MBT_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
S_StartSound(NULL, sfx_s3kb2);
|
||||||
|
}
|
||||||
|
|
||||||
|
M_SetMenuDelay(num);
|
||||||
|
}
|
||||||
|
else if (M_MenuButtonPressed(num, MBT_A) || M_MenuButtonPressed(num, MBT_X))
|
||||||
|
{
|
||||||
|
// Apply the profile.
|
||||||
|
PR_ApplyProfile(p->profilen, num);
|
||||||
|
M_SetupProfileGridPos(p);
|
||||||
|
|
||||||
|
p->mdepth = CSSTEP_CHARS;
|
||||||
|
S_StartSound(NULL, sfx_s3k63);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num)
|
static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
@ -2271,7 +2362,7 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num)
|
||||||
}
|
}
|
||||||
else // for the actual player select, go back to device detection.
|
else // for the actual player select, go back to device detection.
|
||||||
{
|
{
|
||||||
p->mdepth = CSSTEP_NONE;
|
p->mdepth = CSSTEP_PROFILE;
|
||||||
S_StartSound(NULL, sfx_s3k5b);
|
S_StartSound(NULL, sfx_s3k5b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2391,8 +2482,11 @@ boolean M_CharacterSelectHandler(INT32 choice)
|
||||||
case CSSTEP_NONE: // Enter Game
|
case CSSTEP_NONE: // Enter Game
|
||||||
playersChanged = M_HandlePressStart(p, i);
|
playersChanged = M_HandlePressStart(p, i);
|
||||||
break;
|
break;
|
||||||
|
case CSSTEP_PROFILE:
|
||||||
|
playersChanged = M_HandleCSelectProfile(p, i);
|
||||||
|
break;
|
||||||
case CSSTEP_CHARS: // Character Select grid
|
case CSSTEP_CHARS: // Character Select grid
|
||||||
playersChanged = M_HandleCharacterGrid(p, i);
|
M_HandleCharacterGrid(p, i);
|
||||||
break;
|
break;
|
||||||
case CSSTEP_ALTS: // Select clone
|
case CSSTEP_ALTS: // Select clone
|
||||||
M_HandleCharRotate(p, i);
|
M_HandleCharRotate(p, i);
|
||||||
|
|
@ -2415,10 +2509,12 @@ boolean M_CharacterSelectHandler(INT32 choice)
|
||||||
// Just makes it easier to access later
|
// Just makes it easier to access later
|
||||||
p->skin = setup_chargrid[p->gridx][p->gridy].skinlist[p->clonenum];
|
p->skin = setup_chargrid[p->gridx][p->gridy].skinlist[p->clonenum];
|
||||||
|
|
||||||
if (p->mdepth < CSSTEP_COLORS)
|
// Keep profile colour.
|
||||||
|
/*if (p->mdepth < CSSTEP_COLORS)
|
||||||
{
|
{
|
||||||
p->color = skins[p->skin].prefcolor;
|
p->color = skins[p->skin].prefcolor;
|
||||||
}
|
|
||||||
|
}*/
|
||||||
|
|
||||||
if (playersChanged == true)
|
if (playersChanged == true)
|
||||||
{
|
{
|
||||||
|
|
@ -3350,6 +3446,9 @@ void M_InitOptions(INT32 choice)
|
||||||
Moviemode_option_Onchange();
|
Moviemode_option_Onchange();
|
||||||
Addons_option_Onchange();
|
Addons_option_Onchange();
|
||||||
|
|
||||||
|
// For profiles:
|
||||||
|
memset(setup_player, 0, sizeof(setup_player));
|
||||||
|
|
||||||
M_SetupNextMenu(&OPTIONS_MainDef, false);
|
M_SetupNextMenu(&OPTIONS_MainDef, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3646,6 +3745,8 @@ boolean M_ProfileEditInputs(INT32 ch)
|
||||||
optionsmenu.topty = 35;
|
optionsmenu.topty = 35;
|
||||||
optionsmenu.resetprofile = true; // Reset profile after the transition is done.
|
optionsmenu.resetprofile = true; // Reset profile after the transition is done.
|
||||||
|
|
||||||
|
PR_SaveProfiles(); // save profiles after we do that.
|
||||||
|
|
||||||
M_GoBack(0);
|
M_GoBack(0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,22 +94,56 @@ void PR_SaveProfiles(void)
|
||||||
f = fopen(PROFILESFILE, "w");
|
f = fopen(PROFILESFILE, "w");
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
{
|
{
|
||||||
fwrite(profilesList, sizeof(profile_t), MAXPROFILES, f);
|
fwrite(profilesList, sizeof(profile_t), MAXPROFILES+1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
I_Error("Couldn't save profiles. Are you out of Disk space / playing in a protected folder?");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PR_LoadProfiles(void)
|
void PR_LoadProfiles(void)
|
||||||
{
|
{
|
||||||
//FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
profile_t dprofile = PR_MakeProfile(PROFILEDEFAULTNAME, PROFILEDEFAULTPNAME, PROFILEDEFAULTSKIN, PROFILEDEFAULTCOLOR, PROFILEDEFAULTFOLLOWER, PROFILEDEFAULTFOLLOWERCOLOR, gamecontroldefault);
|
profile_t dprofile = PR_MakeProfile(PROFILEDEFAULTNAME, PROFILEDEFAULTPNAME, PROFILEDEFAULTSKIN, PROFILEDEFAULTCOLOR, PROFILEDEFAULTFOLLOWER, PROFILEDEFAULTFOLLOWERCOLOR, gamecontroldefault);
|
||||||
PR_AddProfile(dprofile);
|
f = fopen(PROFILESFILE, "r");
|
||||||
|
|
||||||
/*f = fopen(PROFILESFILE, "r");
|
|
||||||
|
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
{
|
{
|
||||||
fread(&profilesList[1], sizeof(profile_t)*(MAXPROFILES), MAXPROFILES, f);
|
INT32 i;
|
||||||
|
fread(profilesList, sizeof(profile_t)*(MAXPROFILES+1), MAXPROFILES+1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}*/
|
|
||||||
|
// Overwrite the first profile for the default profile to avoid letting anyone tamper with it.
|
||||||
|
memcpy(&profilesList[0], &dprofile, sizeof(profile_t));
|
||||||
|
|
||||||
|
// Omega, count how many profiles there are in the list.
|
||||||
|
// WHY DID YOU ASK HIM TO DO THAT IT'S GOING TO TAKE FOR-EVER
|
||||||
|
for (i=0; i < MAXPROFILES; i++)
|
||||||
|
{
|
||||||
|
if (!profilesList[i].version)
|
||||||
|
{
|
||||||
|
numprofiles = i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No profiles. Add the default one.
|
||||||
|
PR_AddProfile(dprofile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum)
|
||||||
|
{
|
||||||
|
profile_t *p = PR_GetProfile(profilenum);
|
||||||
|
|
||||||
|
CV_StealthSet(&cv_skin[playernum], p->skinname);
|
||||||
|
CV_StealthSetValue(&cv_playercolor[playernum], p->color);
|
||||||
|
CV_StealthSet(&cv_playername[playernum], p->playername);
|
||||||
|
// @TODO followers
|
||||||
|
|
||||||
|
// set controls...
|
||||||
|
memcpy(&gamecontrol[playernum], p->controls, sizeof(gamecontroldefault));
|
||||||
}
|
}
|
||||||
|
|
@ -104,6 +104,10 @@ void PR_SaveProfiles(void);
|
||||||
// This also loads
|
// This also loads
|
||||||
void PR_LoadProfiles(void);
|
void PR_LoadProfiles(void);
|
||||||
|
|
||||||
|
// PR_ApplyProfile(UINT8 profilenum, UINT8 playernum)
|
||||||
|
// Applies the given profile's settings to the given player.
|
||||||
|
void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Add table
Reference in a new issue