Merge branch 'origin/maint'

Conflicts:
	src/sound/fmodsound.cpp
This commit is contained in:
Braden Obrzut 2013-10-23 19:39:22 -04:00
commit 97d7b1e59e
517 changed files with 31032 additions and 11291 deletions

View file

@ -169,12 +169,16 @@ public:
int GetSelection()
{
double f = SELECTED_JOYSTICK->GetAxisMap(mAxis);
// Map from joystick axis to menu selection.
for(unsigned i=0;i<mValues->mValues.Size(); i++)
FOptionValues **opt = OptionValues.CheckKey(mValues);
if (opt != NULL && *opt != NULL)
{
if (fabs(f - mValues->mValues[i].Value) < FLT_EPSILON)
// Map from joystick axis to menu selection.
for(unsigned i = 0; i < (*opt)->mValues.Size(); i++)
{
return i;
if (fabs(f - (*opt)->mValues[i].Value) < FLT_EPSILON)
{
return i;
}
}
}
return -1;
@ -182,14 +186,15 @@ public:
void SetSelection(int selection)
{
FOptionValues **opt = OptionValues.CheckKey(mValues);
// Map from menu selection to joystick axis.
if ((unsigned)selection >= mValues->mValues.Size())
if (opt == NULL || *opt == NULL || (unsigned)selection >= (*opt)->mValues.Size())
{
selection = JOYAXIS_None;
}
else
{
selection = (int)mValues->mValues[selection].Value;
selection = (int)(*opt)->mValues[selection].Value;
}
SELECTED_JOYSTICK->SetAxisMap(mAxis, (EJoyAxis)selection);
}
@ -275,15 +280,16 @@ FOptionMenuDescriptor *UpdateJoystickConfigMenu(IJoystickConfig *joy)
delete opt->mItems[i];
opt->mItems.Clear();
}
opt->mTitle.Format("Configure %s", joy->GetName().GetChars());
if (joy == NULL)
{
opt->mTitle = "Configure Controller";
it = new FOptionMenuItemStaticText("Invalid controller specified for menu", false);
opt->mItems.Push(it);
}
else
{
opt->mTitle.Format("Configure %s", joy->GetName().GetChars());
SELECTED_JOYSTICK = joy;
it = new FOptionMenuSliderJoySensitivity("Overall sensitivity", 0, 2, 0.1, 3);

View file

@ -495,12 +495,13 @@ bool FListMenuItemSelectable::MouseEvent(int type, int x, int y)
//
//=============================================================================
FListMenuItemText::FListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, EColorRange color, FName child, int param)
FListMenuItemText::FListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, EColorRange color, EColorRange color2, FName child, int param)
: FListMenuItemSelectable(x, y, height, child, param)
{
mText = ncopystring(text);
mFont = font;
mColor = color;
mColorSelected = color2;
mHotkey = hotkey;
}
@ -518,7 +519,7 @@ void FListMenuItemText::Drawer(bool selected)
if (text != NULL)
{
if (*text == '$') text = GStrings(text+1);
screen->DrawText(mFont, mColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE);
screen->DrawText(mFont, selected ? mColorSelected : mColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE);
}
}
@ -553,7 +554,9 @@ void FListMenuItemPatch::Drawer(bool selected)
}
int FListMenuItemPatch::GetWidth()
{
return TexMan[mTexture]->GetScaledWidth();
{
return mTexture.isValid()
? TexMan[mTexture]->GetScaledWidth()
: 0;
}

View file

@ -131,7 +131,8 @@ void ClearSaveGames()
{
for(unsigned i=0;i<DLoadSaveMenu::SaveGames.Size(); i++)
{
delete DLoadSaveMenu::SaveGames[i];
if(!DLoadSaveMenu::SaveGames[i]->bNoDelete)
delete DLoadSaveMenu::SaveGames[i];
}
DLoadSaveMenu::SaveGames.Clear();
}
@ -898,7 +899,7 @@ IMPLEMENT_CLASS(DSaveMenu)
DSaveMenu::DSaveMenu(DMenu *parent, FListMenuDescriptor *desc)
: DLoadSaveMenu(parent, desc)
{
strcpy (NewSaveNode.Title, "<New Save Game>");
strcpy (NewSaveNode.Title, GStrings["NEWSAVE"]);
NewSaveNode.bNoDelete = true;
SaveGames.Insert(0, &NewSaveNode);
TopItem = 0;
@ -961,7 +962,7 @@ void DSaveMenu::DoSave (FSaveGameNode *node)
G_SaveGame (filename, savegamestring);
}
M_ClearMenus();
BorderNeedRefresh = screen->GetPageCount ();
V_SetBorderNeedRefresh();
}
//=============================================================================
@ -1100,7 +1101,7 @@ bool DLoadMenu::MenuEvent (int mkey, bool fromcontroller)
quickSaveSlot = SaveGames[Selected];
}
M_ClearMenus();
BorderNeedRefresh = screen->GetPageCount ();
V_SetBorderNeedRefresh();
LastAccessed = Selected;
return true;
}

View file

@ -396,7 +396,7 @@ void M_SetMenu(FName menu, int param)
return;
case NAME_Savegamemenu:
if (!usergame || (players[consoleplayer].health <= 0 && !multiplayer))
if (!usergame || (players[consoleplayer].health <= 0 && !multiplayer) || gamestate != GS_LEVEL)
{
// cannot save outside the game.
M_StartMessage (GStrings("SAVEDEAD"), 1);
@ -409,7 +409,7 @@ void M_SetMenu(FName menu, int param)
FMenuDescriptor **desc = MenuDescriptors.CheckKey(menu);
if (desc != NULL)
{
if ((*desc)->mNetgameMessage.IsNotEmpty() && netgame)
if ((*desc)->mNetgameMessage.IsNotEmpty() && netgame && !demoplayback)
{
M_StartMessage((*desc)->mNetgameMessage, 1);
return;
@ -734,7 +734,7 @@ void M_ClearMenus ()
DMenu::CurrentMenu->Destroy();
DMenu::CurrentMenu = NULL;
}
BorderNeedRefresh = screen->GetPageCount ();
V_SetBorderNeedRefresh();
menuactive = MENU_Off;
}
@ -957,5 +957,6 @@ CCMD(reset2saved)
{
GameConfig->DoGlobalSetup ();
GameConfig->DoGameSetup (gameinfo.ConfigName);
GameConfig->DoModSetup (gameinfo.ConfigName);
R_SetViewSize (screenblocks);
}

View file

@ -86,6 +86,7 @@ struct FMenuDescriptor
FName mMenuName;
FString mNetgameMessage;
int mType;
const PClass *mClass;
virtual ~FMenuDescriptor() {}
};
@ -108,7 +109,6 @@ struct FListMenuDescriptor : public FMenuDescriptor
FFont *mFont;
EColorRange mFontColor;
EColorRange mFontColor2;
const PClass *mClass;
FMenuDescriptor *mRedirect; // used to redirect overlong skill and episode menus to option menu based alternatives
bool mCenter;
@ -139,7 +139,6 @@ struct FOptionMenuSettings
EColorRange mFontColorHighlight;
EColorRange mFontColorSelection;
int mLinespacing;
int mLabelOffset;
};
struct FOptionMenuDescriptor : public FMenuDescriptor
@ -153,7 +152,6 @@ struct FOptionMenuDescriptor : public FMenuDescriptor
int mIndent;
int mPosition;
bool mDontDim;
const PClass *mClass;
void CalcIndent();
FOptionMenuItem *GetItem(FName name);
@ -346,6 +344,7 @@ class FListMenuItemPlayerDisplay : public FListMenuItem
void SetPlayerClass(int classnum, bool force = false);
bool UpdatePlayerClass();
void UpdateRandomClass();
void UpdateTranslation();
public:
@ -394,8 +393,9 @@ class FListMenuItemText : public FListMenuItemSelectable
const char *mText;
FFont *mFont;
EColorRange mColor;
EColorRange mColorSelected;
public:
FListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, EColorRange color, FName child, int param = 0);
FListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, EColorRange color, EColorRange color2, FName child, int param = 0);
~FListMenuItemText();
void Drawer(bool selected);
int GetWidth();
@ -671,6 +671,7 @@ void M_ActivateMenu(DMenu *menu);
void M_ClearMenus ();
void M_ParseMenuDefs();
void M_StartupSkillMenu(FGameStartup *gs);
int M_GetDefaultSkill();
void M_StartControlPanel (bool makeSound);
void M_SetMenu(FName menu, int param = -1);
void M_NotifyNewSave (const char *file, const char *title, bool okForQuicksave);

View file

@ -326,7 +326,7 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
param = sc.Number;
}
FListMenuItem *it = new FListMenuItemText(desc->mXpos, desc->mYpos, desc->mLinespacing, hotkey, text, desc->mFont, desc->mFontColor, action, param);
FListMenuItem *it = new FListMenuItemText(desc->mXpos, desc->mYpos, desc->mLinespacing, hotkey, text, desc->mFont, desc->mFontColor, desc->mFontColor2, action, param);
desc->mItems.Push(it);
desc->mYpos += desc->mLinespacing;
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size()-1;
@ -452,6 +452,37 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
//
//=============================================================================
static bool CheckCompatible(FMenuDescriptor *newd, FMenuDescriptor *oldd)
{
if (oldd->mClass == NULL) return true;
return oldd->mClass == newd->mClass;
}
static bool ReplaceMenu(FScanner &sc, FMenuDescriptor *desc)
{
FMenuDescriptor **pOld = MenuDescriptors.CheckKey(desc->mMenuName);
if (pOld != NULL && *pOld != NULL)
{
if (CheckCompatible(desc, *pOld))
{
delete *pOld;
}
else
{
sc.ScriptMessage("Tried to replace menu '%s' with a menu of different type", desc->mMenuName.GetChars());
return true;
}
}
MenuDescriptors[desc->mMenuName] = desc;
return false;
}
//=============================================================================
//
//
//
//=============================================================================
static void ParseListMenu(FScanner &sc)
{
sc.MustGetString();
@ -478,11 +509,9 @@ static void ParseListMenu(FScanner &sc)
desc->mWRight = 0;
desc->mCenter = false;
FMenuDescriptor **pOld = MenuDescriptors.CheckKey(desc->mMenuName);
if (pOld != NULL && *pOld != NULL) delete *pOld;
MenuDescriptors[desc->mMenuName] = desc;
ParseListMenuBody(sc, desc);
bool scratch = ReplaceMenu(sc, desc);
if (scratch) delete desc;
}
//=============================================================================
@ -509,7 +538,10 @@ static void ParseOptionValue(FScanner &sc)
pair.Text = strbin1(sc.String);
}
FOptionValues **pOld = OptionValues.CheckKey(optname);
if (pOld != NULL && *pOld != NULL) delete *pOld;
if (pOld != NULL && *pOld != NULL)
{
delete *pOld;
}
OptionValues[optname] = val;
}
@ -539,7 +571,10 @@ static void ParseOptionString(FScanner &sc)
pair.Text = strbin1(sc.String);
}
FOptionValues **pOld = OptionValues.CheckKey(optname);
if (pOld != NULL && *pOld != NULL) delete *pOld;
if (pOld != NULL && *pOld != NULL)
{
delete *pOld;
}
OptionValues[optname] = val;
}
@ -572,7 +607,7 @@ static void ParseOptionSettings(FScanner &sc)
else if (sc.Compare("LabelOffset"))
{
sc.MustGetNumber();
OptionSettings.mLabelOffset = sc.Number;
// ignored
}
else
{
@ -806,13 +841,10 @@ static void ParseOptionMenu(FScanner &sc)
desc->mIndent = DefaultOptionMenuSettings.mIndent;
desc->mDontDim = DefaultOptionMenuSettings.mDontDim;
FMenuDescriptor **pOld = MenuDescriptors.CheckKey(desc->mMenuName);
if (pOld != NULL && *pOld != NULL) delete *pOld;
MenuDescriptors[desc->mMenuName] = desc;
ParseOptionMenuBody(sc, desc);
bool scratch = ReplaceMenu(sc, desc);
if (desc->mIndent == 0) desc->CalcIndent();
if (scratch) delete desc;
}
@ -946,7 +978,7 @@ static void BuildEpisodeMenu()
else
{
it = new FListMenuItemText(ld->mXpos, posy, ld->mLinespacing, AllEpisodes[i].mShortcut,
AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, NAME_Skillmenu, i);
AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Skillmenu, i);
}
ld->mItems.Push(it);
posy += ld->mLinespacing;
@ -1035,7 +1067,7 @@ static void BuildPlayerclassMenu()
{
// create a dummy item that auto-chooses the default class.
FListMenuItemText *it = new FListMenuItemText(0, 0, 0, 'p', "player",
ld->mFont,ld->mFontColor, NAME_Episodemenu, -1000);
ld->mFont,ld->mFontColor, ld->mFontColor2, NAME_Episodemenu, -1000);
ld->mAutoselect = ld->mItems.Push(it);
success = true;
}
@ -1061,17 +1093,17 @@ static void BuildPlayerclassMenu()
if (pname != NULL)
{
FListMenuItemText *it = new FListMenuItemText(ld->mXpos, ld->mYpos, ld->mLinespacing, *pname,
pname, ld->mFont,ld->mFontColor, NAME_Episodemenu, i);
pname, ld->mFont,ld->mFontColor,ld->mFontColor2, NAME_Episodemenu, i);
ld->mItems.Push(it);
ld->mYpos += ld->mLinespacing;
n++;
}
}
}
if (n > 1)
if (n > 1 && !gameinfo.norandomplayerclass)
{
FListMenuItemText *it = new FListMenuItemText(ld->mXpos, ld->mYpos, ld->mLinespacing, 'r',
"$MNU_RANDOM", ld->mFont,ld->mFontColor, NAME_Episodemenu, -1);
"$MNU_RANDOM", ld->mFont,ld->mFontColor,ld->mFontColor2, NAME_Episodemenu, -1);
ld->mItems.Push(it);
}
if (n == 0)
@ -1080,7 +1112,7 @@ static void BuildPlayerclassMenu()
if (pname != NULL)
{
FListMenuItemText *it = new FListMenuItemText(ld->mXpos, ld->mYpos, ld->mLinespacing, *pname,
pname, ld->mFont,ld->mFontColor, NAME_Episodemenu, 0);
pname, ld->mFont,ld->mFontColor,ld->mFontColor2, NAME_Episodemenu, 0);
ld->mItems.Push(it);
}
}
@ -1105,7 +1137,7 @@ static void BuildPlayerclassMenu()
od->mScrollTop = 0;
od->mIndent = 160;
od->mDontDim = false;
od->mNetgameMessage = "$NETGAME";
od->mNetgameMessage = "$NEWGAME";
for (unsigned i = 0; i < PlayerClasses.Size (); i++)
{
@ -1226,7 +1258,6 @@ void M_CreateMenus()
BuildPlayerclassMenu();
InitCrosshairsList();
InitKeySections();
UpdateJoystickMenu(NULL);
FOptionValues **opt = OptionValues.CheckKey(NAME_Mididevices);
if (opt != NULL)
@ -1242,7 +1273,7 @@ void M_CreateMenus()
//=============================================================================
//
// THe skill menu must be refeshed each time it starts up
// The skill menu must be refeshed each time it starts up
//
//=============================================================================
extern int restart;
@ -1327,8 +1358,8 @@ void M_StartupSkillMenu(FGameStartup *gs)
FSkillInfo &skill = AllSkills[i];
FListMenuItem *li;
// Using a different name for skills that must be confirmed makes handling this easier.
FName action = skill.MustConfirm? NAME_StartgameConfirm : NAME_Startgame;
FName action = (skill.MustConfirm && !AllEpisodes[gs->Episode].mNoSkill) ?
NAME_StartgameConfirm : NAME_Startgame;
FString *pItemText = NULL;
if (gs->PlayerClass != NULL)
{
@ -1345,14 +1376,14 @@ void M_StartupSkillMenu(FGameStartup *gs)
EColorRange color = (EColorRange)skill.GetTextColor();
if (color == CR_UNTRANSLATED) color = ld->mFontColor;
li = new FListMenuItemText(x, y, ld->mLinespacing, skill.Shortcut,
pItemText? *pItemText : skill.MenuName, ld->mFont, color, action, i);
pItemText? *pItemText : skill.MenuName, ld->mFont, color,ld->mFontColor2, action, i);
}
ld->mItems.Push(li);
y += ld->mLinespacing;
}
if (AllEpisodes[gs->Episode].mNoSkill || AllSkills.Size() == 1)
{
ld->mAutoselect = firstitem + MIN(2u, AllSkills.Size()-1);
ld->mAutoselect = firstitem + M_GetDefaultSkill();
}
else
{
@ -1395,7 +1426,8 @@ fail:
FSkillInfo &skill = AllSkills[i];
FOptionMenuItem *li;
// Using a different name for skills that must be confirmed makes handling this easier.
const char *action = skill.MustConfirm? "StartgameConfirm" : "Startgame";
const char *action = (skill.MustConfirm && !AllEpisodes[gs->Episode].mNoSkill) ?
"StartgameConfirm" : "Startgame";
FString *pItemText = NULL;
if (gs->PlayerClass != NULL)
@ -1407,12 +1439,23 @@ fail:
if (!done)
{
done = true;
int defskill = DefaultSkill;
if ((unsigned int)defskill >= AllSkills.Size())
{
defskill = (AllSkills.Size() - 1) / 2;
}
od->mSelectedItem = defskill;
od->mSelectedItem = M_GetDefaultSkill();
}
}
}
//=============================================================================
//
// Returns the default skill level.
//
//=============================================================================
int M_GetDefaultSkill()
{
int defskill = DefaultSkill;
if ((unsigned int)defskill >= AllSkills.Size())
{
defskill = (AllSkills.Size() - 1) / 2;
}
return defskill;
}

View file

@ -179,8 +179,8 @@ void DMessageBoxMenu::Drawer ()
PalEntry fade = 0;
int fontheight = SmallFont->GetHeight();
//BorderNeedRefresh = screen->GetPageCount ();
//SB_state = screen->GetPageCount ();
//V_SetBorderNeedRefresh();
//ST_SetNeedRefresh();
y = 100;
@ -214,7 +214,7 @@ void DMessageBoxMenu::Drawer ()
{
screen->DrawText(ConFont, OptionSettings.mFontColorSelection,
(150 - 160) * CleanXfac + screen->GetWidth() / 2,
(y + (fontheight + 1) * messageSelection - 100) * CleanYfac + screen->GetHeight() / 2,
(y + (fontheight + 1) * messageSelection - 100 + fontheight/2 - 5) * CleanYfac + screen->GetHeight() / 2,
"\xd",
DTA_CellX, 8 * CleanXfac,
DTA_CellY, 8 * CleanYfac,
@ -466,19 +466,7 @@ IMPLEMENT_CLASS(DEndGameMenu)
DEndGameMenu::DEndGameMenu(bool playsound)
{
int messageindex = gametic % gameinfo.quitmessages.Size();
FString EndString = gameinfo.quitmessages[messageindex];
if (netgame)
{
EndString = GStrings("NETEND");
return;
}
EndString = GStrings("ENDGAME");
Init(NULL, EndString, 0, playsound);
Init(NULL, GStrings(netgame ? "NETEND" : "ENDGAME"), 0, playsound);
}
//=============================================================================
@ -492,7 +480,10 @@ void DEndGameMenu::HandleResult(bool res)
if (res)
{
M_ClearMenus ();
D_StartTitle ();
if (!netgame)
{
D_StartTitle ();
}
}
else
{

View file

@ -58,8 +58,6 @@
void M_DrawConText (int color, int x, int y, const char *str)
{
int len = (int)strlen(str);
screen->DrawText (ConFont, color, x, y, str,
DTA_CellX, 8 * CleanXfac_1,
DTA_CellY, 8 * CleanYfac_1,
@ -400,8 +398,6 @@ void DOptionMenu::Drawer ()
}
}
mDesc->mDrawTop = y;
//int labelofs = OptionSettings.mLabelOffset * CleanXfac_1;
//int cursorspace = 14 * CleanXfac_1;
int fontheight = OptionSettings.mLinespacing * CleanYfac_1;
y *= CleanYfac_1;
@ -440,7 +436,7 @@ void DOptionMenu::Drawer ()
{
if (((DMenu::MenuTime%8) < 6) || DMenu::CurrentMenu != this)
{
M_DrawConText(OptionSettings.mFontColorSelection, cur_indent + 3 * CleanXfac_1, y-CleanYfac_1+OptionSettings.mLabelOffset, "\xd");
M_DrawConText(OptionSettings.mFontColorSelection, cur_indent + 3 * CleanXfac_1, y+fontheight-9*CleanYfac_1, "\xd");
}
}
}
@ -451,11 +447,11 @@ void DOptionMenu::Drawer ()
if (CanScrollUp)
{
M_DrawConText(CR_ORANGE, 3 * CleanXfac_1, ytop + OptionSettings.mLabelOffset, "\x1a");
M_DrawConText(CR_ORANGE, 3 * CleanXfac_1, ytop, "\x1a");
}
if (CanScrollDown)
{
M_DrawConText(CR_ORANGE, 3 * CleanXfac_1, y - 8*CleanYfac_1 + OptionSettings.mLabelOffset, "\x1b");
M_DrawConText(CR_ORANGE, 3 * CleanXfac_1, y - 8*CleanYfac_1, "\x1b");
}
Super::Drawer();
}
@ -584,7 +580,7 @@ public:
Super::Drawer();
char text[64];
mysnprintf(text, 64, "compatflags = %d", *compatflags);
mysnprintf(text, 64, "compatflags = %d compatflags2 = %d", *compatflags, *compatflags2);
screen->DrawText (SmallFont, OptionSettings.mFontColorValue,
(screen->GetWidth() - SmallFont->StringWidth (text) * CleanXfac_1) / 2, 0, text,
DTA_CleanNoMove_1, true, TAG_DONE);

View file

@ -134,7 +134,7 @@ class FOptionMenuItemOptionBase : public FOptionMenuItem
{
protected:
// action is a CVAR
FOptionValues *mValues;
FName mValues; // Entry in OptionValues table
FBaseCVar *mGrayCheck;
int mCenter;
public:
@ -147,15 +147,7 @@ public:
FOptionMenuItemOptionBase(const char *label, const char *menu, const char *values, const char *graycheck, int center)
: FOptionMenuItem(label, menu)
{
FOptionValues **opt = OptionValues.CheckKey(values);
if (opt != NULL)
{
mValues = *opt;
}
else
{
mValues = NULL;
}
mValues = values;
mGrayCheck = (FBoolCVar*)FindCVar(graycheck, NULL);
mCenter = center;
}
@ -165,11 +157,11 @@ public:
if (i == OP_VALUES)
{
FOptionValues **opt = OptionValues.CheckKey(newtext);
if (opt != NULL)
mValues = newtext;
if (opt != NULL && *opt != NULL)
{
mValues = *opt;
int s = GetSelection();
if (s >= (int)mValues->mValues.Size()) s = 0;
if (s >= (int)(*opt)->mValues.Size()) s = 0;
SetSelection(s); // readjust the CVAR if its value is outside the range now
return true;
}
@ -197,13 +189,14 @@ public:
int overlay = grayed? MAKEARGB(96,48,0,0) : 0;
const char *text;
int Selection = GetSelection();
if (Selection < 0)
FOptionValues **opt = OptionValues.CheckKey(mValues);
if (Selection < 0 || opt == NULL || *opt == NULL)
{
text = "Unknown";
}
else
{
text = mValues->mValues[Selection].Text;
text = (*opt)->mValues[Selection].Text;
}
screen->DrawText (SmallFont, OptionSettings.mFontColorValue, indent + CURSORSPACE, y,
text, DTA_CleanNoMove_1, true, DTA_ColorOverlay, overlay, TAG_DONE);
@ -213,17 +206,18 @@ public:
//=============================================================================
bool MenuEvent (int mkey, bool fromcontroller)
{
if (mValues->mValues.Size() > 0)
FOptionValues **opt = OptionValues.CheckKey(mValues);
if (opt != NULL && *opt != NULL && (*opt)->mValues.Size() > 0)
{
int Selection = GetSelection();
if (mkey == MKEY_Left)
{
if (Selection == -1) Selection = 0;
else if (--Selection < 0) Selection = mValues->mValues.Size()-1;
else if (--Selection < 0) Selection = (*opt)->mValues.Size()-1;
}
else if (mkey == MKEY_Right || mkey == MKEY_Enter)
{
if (++Selection >= (int)mValues->mValues.Size()) Selection = 0;
if (++Selection >= (int)(*opt)->mValues.Size()) Selection = 0;
}
else
{
@ -263,14 +257,15 @@ public:
int GetSelection()
{
int Selection = -1;
if (mValues != NULL && mCVar != NULL && mValues->mValues.Size() > 0)
FOptionValues **opt = OptionValues.CheckKey(mValues);
if (opt != NULL && *opt != NULL && mCVar != NULL && (*opt)->mValues.Size() > 0)
{
if (mValues->mValues[0].TextValue.IsEmpty())
if ((*opt)->mValues[0].TextValue.IsEmpty())
{
UCVarValue cv = mCVar->GetGenericRep(CVAR_Float);
for(unsigned i=0;i<mValues->mValues.Size(); i++)
{
if (fabs(cv.Float - mValues->mValues[i].Value) < FLT_EPSILON)
for(unsigned i = 0; i < (*opt)->mValues.Size(); i++)
{
if (fabs(cv.Float - (*opt)->mValues[i].Value) < FLT_EPSILON)
{
Selection = i;
break;
@ -280,9 +275,9 @@ public:
else
{
UCVarValue cv = mCVar->GetGenericRep(CVAR_String);
for(unsigned i=0;i<mValues->mValues.Size(); i++)
for(unsigned i = 0; i < (*opt)->mValues.Size(); i++)
{
if (mValues->mValues[i].TextValue.CompareNoCase(cv.String) == 0)
if ((*opt)->mValues[i].TextValue.CompareNoCase(cv.String) == 0)
{
Selection = i;
break;
@ -296,18 +291,19 @@ public:
void SetSelection(int Selection)
{
UCVarValue value;
if (mValues != NULL && mCVar != NULL && mValues->mValues.Size() > 0)
FOptionValues **opt = OptionValues.CheckKey(mValues);
if (opt != NULL && *opt != NULL && mCVar != NULL && (*opt)->mValues.Size() > 0)
{
if (mValues->mValues[0].TextValue.IsEmpty())
if ((*opt)->mValues[0].TextValue.IsEmpty())
{
value.Float = (float)mValues->mValues[Selection].Value;
value.Float = (float)(*opt)->mValues[Selection].Value;
mCVar->SetGenericRep (value, CVAR_Float);
}
else
{
value.String = mValues->mValues[Selection].TextValue.LockBuffer();
value.String = (*opt)->mValues[Selection].TextValue.LockBuffer();
mCVar->SetGenericRep (value, CVAR_String);
mValues->mValues[Selection].TextValue.UnlockBuffer();
(*opt)->mValues[Selection].TextValue.UnlockBuffer();
}
}
}
@ -411,11 +407,11 @@ public:
C_NameKeys (description, Key1, Key2);
if (description[0])
{
M_DrawConText(CR_WHITE, indent + CURSORSPACE, y-1+OptionSettings.mLabelOffset, description);
M_DrawConText(CR_WHITE, indent + CURSORSPACE, y + (OptionSettings.mLinespacing-8)*CleanYfac_1, description);
}
else
{
screen->DrawText(SmallFont, CR_BLACK, indent + CURSORSPACE, y + OptionSettings.mLabelOffset, "---",
screen->DrawText(SmallFont, CR_BLACK, indent + CURSORSPACE, y + (OptionSettings.mLinespacing-8)*CleanYfac_1, "---",
DTA_CleanNoMove_1, true, TAG_DONE);
}
return indent;
@ -573,12 +569,13 @@ public:
//
//=============================================================================
void DrawSlider (int x, int y, double min, double max, double cur,int fracdigits, int indent)
void DrawSlider (int x, int y, double min, double max, double cur, int fracdigits, int indent)
{
char textbuf[16];
double range;
int maxlen = 0;
int right = x + (12*8 + 4) * CleanXfac_1;
int cy = y + (OptionSettings.mLinespacing-8)*CleanYfac_1;
range = max - min;
double ccur = clamp(cur, min, max) - min;
@ -593,14 +590,14 @@ public:
if (!mSliderShort)
{
M_DrawConText(CR_WHITE, x, y, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12");
M_DrawConText(CR_ORANGE, x + int((5 + ((ccur * 78) / range)) * CleanXfac_1), y, "\x13");
M_DrawConText(CR_WHITE, x, cy, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12");
M_DrawConText(CR_ORANGE, x + int((5 + ((ccur * 78) / range)) * CleanXfac_1), cy, "\x13");
}
else
{
// On 320x200 we need a shorter slider
M_DrawConText(CR_WHITE, x, y, "\x10\x11\x11\x11\x11\x11\x12");
M_DrawConText(CR_ORANGE, x + int((5 + ((ccur * 38) / range)) * CleanXfac_1), y, "\x13");
M_DrawConText(CR_WHITE, x, cy, "\x10\x11\x11\x11\x11\x11\x12");
M_DrawConText(CR_ORANGE, x + int((5 + ((ccur * 38) / range)) * CleanXfac_1), cy, "\x13");
right -= 5*8*CleanXfac_1;
}
@ -617,7 +614,7 @@ public:
{
drawLabel(indent, y, selected? OptionSettings.mFontColorSelection : OptionSettings.mFontColor);
mDrawX = indent + CURSORSPACE;
DrawSlider (mDrawX, y + OptionSettings.mLabelOffset, mMin, mMax, GetValue(), mShowValue, indent);
DrawSlider (mDrawX, y, mMin, mMax, GetValue(), mShowValue, indent);
return indent;
}
@ -781,8 +778,8 @@ public:
if (mCVar != NULL)
{
int box_x = indent + CURSORSPACE;
int box_y = y + OptionSettings.mLabelOffset * CleanYfac_1 / 2;
screen->Clear (box_x, box_y, box_x + 32*CleanXfac_1, box_y + (SmallFont->GetHeight() - 1) * CleanYfac_1,
int box_y = y + CleanYfac_1;
screen->Clear (box_x, box_y, box_x + 32*CleanXfac_1, box_y + OptionSettings.mLinespacing*CleanYfac_1,
-1, (uint32)*mCVar | 0xff000000);
}
return indent;

View file

@ -48,6 +48,7 @@
#include "gi.h"
#include "r_defs.h"
#include "r_state.h"
#include "r_data/r_translate.h"
//=============================================================================
@ -384,11 +385,39 @@ void FListMenuItemPlayerDisplay::UpdateRandomClass()
if (++mRandomClass >= (int)PlayerClasses.Size ()) mRandomClass = 0;
mPlayerClass = &PlayerClasses[mRandomClass];
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SeeState;
mPlayerTics = mPlayerState->GetTics();
if (mPlayerState == NULL)
{ // No see state, so try spawn state.
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SpawnState;
}
mPlayerTics = mPlayerState != NULL ? mPlayerState->GetTics() : -1;
mRandomTimer = 6;
// Since the newly displayed class may used a different translation
// range than the old one, we need to update the translation, too.
UpdateTranslation();
}
}
//=============================================================================
//
//
//
//=============================================================================
void FListMenuItemPlayerDisplay::UpdateTranslation()
{
int PlayerColor = players[consoleplayer].userinfo.GetColor();
int PlayerSkin = players[consoleplayer].userinfo.GetSkin();
int PlayerColorset = players[consoleplayer].userinfo.GetColorSet();
if (mPlayerClass != NULL)
{
PlayerSkin = R_FindSkin (skins[PlayerSkin].name, int(mPlayerClass - &PlayerClasses[0]));
R_GetPlayerTranslation(PlayerColor,
P_GetPlayerColorSet(mPlayerClass->Type->TypeName, PlayerColorset),
&skins[PlayerSkin], translationtables[TRANSLATION_Players][MAXPLAYERS]);
}
}
//=============================================================================
//
@ -411,7 +440,11 @@ void FListMenuItemPlayerDisplay::SetPlayerClass(int classnum, bool force)
{
mPlayerClass = &PlayerClasses[classnum];
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SeeState;
mPlayerTics = mPlayerState->GetTics();
if (mPlayerState == NULL)
{ // No see state, so try spawn state.
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SpawnState;
}
mPlayerTics = mPlayerState != NULL ? mPlayerState->GetTics() : -1;
mClassNum = classnum;
}
}
@ -530,20 +563,23 @@ void FListMenuItemPlayerDisplay::Drawer(bool selected)
V_DrawFrame (x, y, 72*CleanXfac, 80*CleanYfac-1);
spriteframe_t *sprframe;
spriteframe_t *sprframe = NULL;
fixed_t scaleX, scaleY;
if (mSkin == 0)
if (mPlayerState != NULL)
{
sprframe = &SpriteFrames[sprites[mPlayerState->sprite].spriteframes + mPlayerState->GetFrame()];
scaleX = GetDefaultByType(mPlayerClass->Type)->scaleX;
scaleY = GetDefaultByType(mPlayerClass->Type)->scaleY;
}
else
{
sprframe = &SpriteFrames[sprites[skins[mSkin].sprite].spriteframes + mPlayerState->GetFrame()];
scaleX = skins[mSkin].ScaleX;
scaleY = skins[mSkin].ScaleY;
if (mSkin == 0)
{
sprframe = &SpriteFrames[sprites[mPlayerState->sprite].spriteframes + mPlayerState->GetFrame()];
scaleX = GetDefaultByType(mPlayerClass->Type)->scaleX;
scaleY = GetDefaultByType(mPlayerClass->Type)->scaleY;
}
else
{
sprframe = &SpriteFrames[sprites[skins[mSkin].sprite].spriteframes + mPlayerState->GetFrame()];
scaleX = skins[mSkin].ScaleX;
scaleY = skins[mSkin].ScaleY;
}
}
if (sprframe != NULL)
@ -555,9 +591,10 @@ void FListMenuItemPlayerDisplay::Drawer(bool selected)
if (mTranslate) trans = translationtables[TRANSLATION_Players](MAXPLAYERS);
screen->DrawTexture (tex,
x + 36*CleanXfac, y + 71*CleanYfac,
DTA_DestWidth, MulScale16 (tex->GetWidth() * CleanXfac, scaleX),
DTA_DestHeight, MulScale16 (tex->GetHeight() * CleanYfac, scaleY),
DTA_DestWidth, MulScale16 (tex->GetScaledWidth() * CleanXfac, scaleX),
DTA_DestHeight, MulScale16 (tex->GetScaledHeight() * CleanYfac, scaleY),
DTA_Translation, trans,
DTA_FlipX, sprframe->Flip & (1 << mRotation),
TAG_DONE);
}
}

View file

@ -55,8 +55,6 @@ EXTERN_CVAR (Float, autoaim)
EXTERN_CVAR(Bool, neverswitchonpickup)
EXTERN_CVAR (Bool, cl_run)
void R_GetPlayerTranslation (int color, const FPlayerColorSet *colorset, FPlayerSkin *skin, FRemapTable *table);
//=============================================================================
//
// Player's name
@ -547,11 +545,11 @@ void DPlayerMenu::Init(DMenu *parent, FListMenuDescriptor *desc)
li->SetValue(FListMenuItemPlayerDisplay::PDF_ROTATION, 0);
li->SetValue(FListMenuItemPlayerDisplay::PDF_MODE, 1);
li->SetValue(FListMenuItemPlayerDisplay::PDF_TRANSLATE, 1);
li->SetValue(FListMenuItemPlayerDisplay::PDF_CLASS, players[consoleplayer].userinfo.PlayerClass);
li->SetValue(FListMenuItemPlayerDisplay::PDF_CLASS, players[consoleplayer].userinfo.GetPlayerClassNum());
if (PlayerClass != NULL && !(GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN) &&
players[consoleplayer].userinfo.PlayerClass != -1)
players[consoleplayer].userinfo.GetPlayerClassNum() != -1)
{
li->SetValue(FListMenuItemPlayerDisplay::PDF_SKIN, players[consoleplayer].userinfo.skin);
li->SetValue(FListMenuItemPlayerDisplay::PDF_SKIN, players[consoleplayer].userinfo.GetSkin());
}
}
@ -572,8 +570,8 @@ void DPlayerMenu::Init(DMenu *parent, FListMenuDescriptor *desc)
li->SetValue(0, team == TEAM_NONE? 0 : team + 1);
}
int mycolorset = players[consoleplayer].userinfo.colorset;
int color = players[consoleplayer].userinfo.color;
int mycolorset = players[consoleplayer].userinfo.GetColorSet();
int color = players[consoleplayer].userinfo.GetColor();
UpdateColorsets();
@ -608,13 +606,16 @@ void DPlayerMenu::Init(DMenu *parent, FListMenuDescriptor *desc)
}
else
{
li->SetString(0, "Random");
// [XA] Remove the "Random" option if the relevant gameinfo flag is set.
if(!gameinfo.norandomplayerclass)
li->SetString(0, "Random");
for(unsigned i=0; i< PlayerClasses.Size(); i++)
{
const char *cls = GetPrintableDisplayName(PlayerClasses[i].Type);
li->SetString(i+1, cls);
li->SetString(gameinfo.norandomplayerclass ? i : i+1, cls);
}
li->SetValue(0, players[consoleplayer].userinfo.PlayerClass + 1);
int pclass = players[consoleplayer].userinfo.GetPlayerClassNum();
li->SetValue(0, gameinfo.norandomplayerclass && pclass >= 0 ? pclass : pclass + 1);
}
}
@ -623,7 +624,7 @@ void DPlayerMenu::Init(DMenu *parent, FListMenuDescriptor *desc)
li = GetItem(NAME_Gender);
if (li != NULL)
{
li->SetValue(0, players[consoleplayer].userinfo.gender);
li->SetValue(0, players[consoleplayer].userinfo.GetGender());
}
li = GetItem(NAME_Autoaim);
@ -685,9 +686,9 @@ bool DPlayerMenu::Responder (event_t *ev)
void DPlayerMenu::UpdateTranslation()
{
int PlayerColor = players[consoleplayer].userinfo.color;
int PlayerSkin = players[consoleplayer].userinfo.skin;
int PlayerColorset = players[consoleplayer].userinfo.colorset;
int PlayerColor = players[consoleplayer].userinfo.GetColor();
int PlayerSkin = players[consoleplayer].userinfo.GetSkin();
int PlayerColorset = players[consoleplayer].userinfo.GetColorSet();
if (PlayerClass != NULL)
{
@ -721,7 +722,7 @@ void DPlayerMenu::PickPlayerClass()
// [GRB] Pick a class from player class list
if (PlayerClasses.Size () > 1)
{
pclass = players[consoleplayer].userinfo.PlayerClass;
pclass = players[consoleplayer].userinfo.GetPlayerClassNum();
if (pclass < 0)
{
@ -744,7 +745,7 @@ void DPlayerMenu::SendNewColor (int red, int green, int blue)
{
char command[24];
players[consoleplayer].userinfo.color = MAKERGB(red, green, blue);
players[consoleplayer].userinfo.ColorChanged(MAKERGB(red,green,blue));
mysnprintf (command, countof(command), "color \"%02x %02x %02x\"", red, green, blue);
C_DoCommand (command);
UpdateTranslation();
@ -769,7 +770,7 @@ void DPlayerMenu::UpdateColorsets()
FPlayerColorSet *colorset = P_GetPlayerColorSet(PlayerClass->Type->TypeName, PlayerColorSets[i]);
li->SetString(i+1, colorset->Name);
}
int mycolorset = players[consoleplayer].userinfo.colorset;
int mycolorset = players[consoleplayer].userinfo.GetColorSet();
if (mycolorset != -1)
{
for(unsigned i=0;i<PlayerColorSets.Size(); i++)
@ -798,7 +799,7 @@ void DPlayerMenu::UpdateSkins()
if (li != NULL)
{
if (GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN ||
players[consoleplayer].userinfo.PlayerClass == -1)
players[consoleplayer].userinfo.GetPlayerClassNum() == -1)
{
li->SetString(0, "Base");
li->SetValue(0, 0);
@ -813,7 +814,7 @@ void DPlayerMenu::UpdateSkins()
{
int j = PlayerSkins.Push(i);
li->SetString(j, skins[i].name);
if (players[consoleplayer].userinfo.skin == i)
if (players[consoleplayer].userinfo.GetSkin() == i)
{
sel = j;
}
@ -885,7 +886,7 @@ void DPlayerMenu::ColorSetChanged (FListMenuItem *li)
if (blue != NULL) blue->Enable(mycolorset == -1);
char command[24];
players[consoleplayer].userinfo.colorset = mycolorset;
players[consoleplayer].userinfo.ColorSetChanged(mycolorset);
mysnprintf(command, countof(command), "colorset %d", mycolorset);
C_DoCommand(command);
UpdateTranslation();
@ -909,10 +910,10 @@ void DPlayerMenu::ClassChanged (FListMenuItem *li)
if (li->GetValue(0, &sel))
{
players[consoleplayer].userinfo.PlayerClass = sel-1;
players[consoleplayer].userinfo.PlayerClassNumChanged(gameinfo.norandomplayerclass ? sel : sel-1);
PickPlayerClass();
cvar_set ("playerclass", sel == 0 ? "Random" : PlayerClass->Type->Meta.GetMetaString (APMETA_DisplayName));
cvar_set ("playerclass", sel == 0 && !gameinfo.norandomplayerclass ? "Random" : PlayerClass->Type->Meta.GetMetaString (APMETA_DisplayName));
UpdateSkins();
UpdateColorsets();
@ -921,7 +922,7 @@ void DPlayerMenu::ClassChanged (FListMenuItem *li)
li = GetItem(NAME_Playerdisplay);
if (li != NULL)
{
li->SetValue(FListMenuItemPlayerDisplay::PDF_CLASS, players[consoleplayer].userinfo.PlayerClass);
li->SetValue(FListMenuItemPlayerDisplay::PDF_CLASS, players[consoleplayer].userinfo.GetPlayerClassNum());
}
}
}
@ -935,7 +936,7 @@ void DPlayerMenu::ClassChanged (FListMenuItem *li)
void DPlayerMenu::SkinChanged (FListMenuItem *li)
{
if (GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN ||
players[consoleplayer].userinfo.PlayerClass == -1)
players[consoleplayer].userinfo.GetPlayerClassNum() == -1)
{
return;
}
@ -945,7 +946,7 @@ void DPlayerMenu::SkinChanged (FListMenuItem *li)
if (li->GetValue(0, &sel))
{
sel = PlayerSkins[sel];
players[consoleplayer].userinfo.skin = sel;
players[consoleplayer].userinfo.SkinNumChanged(sel);
UpdateTranslation();
cvar_set ("skin", skins[sel].name);
@ -1012,7 +1013,7 @@ bool DPlayerMenu::MenuEvent (int mkey, bool fromcontroller)
case NAME_Red:
if (li->GetValue(0, &v))
{
int color = players[consoleplayer].userinfo.color;
uint32 color = players[consoleplayer].userinfo.GetColor();
SendNewColor (v, GPART(color), BPART(color));
}
break;
@ -1020,7 +1021,7 @@ bool DPlayerMenu::MenuEvent (int mkey, bool fromcontroller)
case NAME_Green:
if (li->GetValue(0, &v))
{
int color = players[consoleplayer].userinfo.color;
uint32 color = players[consoleplayer].userinfo.GetColor();
SendNewColor (RPART(color), v, BPART(color));
}
break;
@ -1028,7 +1029,7 @@ bool DPlayerMenu::MenuEvent (int mkey, bool fromcontroller)
case NAME_Blue:
if (li->GetValue(0, &v))
{
int color = players[consoleplayer].userinfo.color;
uint32 color = players[consoleplayer].userinfo.GetColor();
SendNewColor (RPART(color), GPART(color), v);
}
break;
@ -1091,7 +1092,7 @@ bool DPlayerMenu::MouseEvent(int type, int x, int y)
case NAME_Red:
if (li->GetValue(0, &v))
{
int color = players[consoleplayer].userinfo.color;
uint32 color = players[consoleplayer].userinfo.GetColor();
SendNewColor (v, GPART(color), BPART(color));
}
break;
@ -1099,7 +1100,7 @@ bool DPlayerMenu::MouseEvent(int type, int x, int y)
case NAME_Green:
if (li->GetValue(0, &v))
{
int color = players[consoleplayer].userinfo.color;
uint32 color = players[consoleplayer].userinfo.GetColor();
SendNewColor (RPART(color), v, BPART(color));
}
break;
@ -1107,7 +1108,7 @@ bool DPlayerMenu::MouseEvent(int type, int x, int y)
case NAME_Blue:
if (li->GetValue(0, &v))
{
int color = players[consoleplayer].userinfo.color;
uint32 color = players[consoleplayer].userinfo.GetColor();
SendNewColor (RPART(color), GPART(color), v);
}
break;

View file

@ -83,15 +83,15 @@ int OldWidth, OldHeight, OldBits;
static FIntCVar DummyDepthCvar (NULL, 0, 0);
static BYTE BitTranslate[32];
CUSTOM_CVAR (Int, menu_screenratios, 0, CVAR_ARCHIVE)
CUSTOM_CVAR (Int, menu_screenratios, -1, CVAR_ARCHIVE)
{
if (self < 0 || self > 4)
if (self < -1 || self > 4)
{
self = 3;
self = -1;
}
else if (self == 4 && !vid_tft)
{
self = 3;
self = 0;
}
else
{
@ -99,7 +99,7 @@ CUSTOM_CVAR (Int, menu_screenratios, 0, CVAR_ARCHIVE)
}
}
CUSTOM_CVAR (Bool, vid_tft, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CUSTOM_CVAR (Bool, vid_tft, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{
FOptionMenuDescriptor *opt = GetVideoModeMenu();
if (opt != NULL)
@ -166,15 +166,18 @@ public:
NewWidth = SCREENWIDTH;
NewHeight = SCREENHEIGHT;
}
OldWidth = SCREENWIDTH;
OldHeight = SCREENHEIGHT;
OldBits = DisplayBits;
NewBits = BitTranslate[DummyDepthCvar];
setmodeneeded = true;
testingmode = I_GetTime(false) + 5 * TICRATE;
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", snd_menuvolume, ATTN_NONE);
SetModesMenu (NewWidth, NewHeight, NewBits);
return true;
else
{
OldWidth = SCREENWIDTH;
OldHeight = SCREENHEIGHT;
OldBits = DisplayBits;
NewBits = BitTranslate[DummyDepthCvar];
setmodeneeded = true;
testingmode = I_GetTime(false) + 5 * TICRATE;
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", snd_menuvolume, ATTN_NONE);
SetModesMenu (NewWidth, NewHeight, NewBits);
return true;
}
}
return Super::Responder(ev);
}
@ -213,7 +216,7 @@ static void BuildModesList (int hiwidth, int hiheight, int hi_bits)
bool letterbox=false;
int ratiomatch;
if (menu_screenratios >= 0 && menu_screenratios <= 4 && menu_screenratios != 3)
if (menu_screenratios >= 0 && menu_screenratios <= 4)
{
ratiomatch = menu_screenratios;
}
@ -316,6 +319,7 @@ void M_InitVideoModesMenu ()
size_t currval = 0;
M_RefreshModesList();
vid_tft.Callback();
for (unsigned int i = 1; i <= 32 && currval < countof(BitTranslate); i++)
{
@ -347,7 +351,7 @@ void M_InitVideoModesMenu ()
static bool GetSelectedSize (int *width, int *height)
{
FOptionMenuDescriptor *opt = GetVideoModeMenu();
if (opt != NULL)
if (opt != NULL && (unsigned)opt->mSelectedItem < opt->mItems.Size())
{
int line = opt->mSelectedItem;
int hsel;