GameExecutable: Fix } else { formatting.

Make code more readable.
This commit is contained in:
zcaliptium 2016-03-31 22:57:40 +03:00
parent 6434adfc1b
commit 80471f5041
13 changed files with 60 additions and 86 deletions

View File

@ -29,16 +29,14 @@ void CMGArrow::Render(CDrawPort *pdp)
CTString str;
if (mg_adDirection == AD_NONE) {
str = "???";
}
else if (mg_adDirection == AD_UP) {
} else if (mg_adDirection == AD_UP) {
str = TRANS("Page Up");
}
else if (mg_adDirection == AD_DOWN) {
} else if (mg_adDirection == AD_DOWN) {
str = TRANS("Page Down");
}
else {
} else {
ASSERT(FALSE);
}
PIX pixI = box.Min()(1);
PIX pixJ = box.Min()(2);
pdp->PutText(str, pixI, pixJ, col);

View File

@ -62,11 +62,9 @@ void CMGButton::Render(CDrawPort *pdp)
{
if (mg_bfsFontSize == BFS_LARGE) {
SetFontBig(pdp);
}
else if (mg_bfsFontSize == BFS_MEDIUM) {
} else if (mg_bfsFontSize == BFS_MEDIUM) {
SetFontMedium(pdp);
}
else {
} else {
ASSERT(mg_bfsFontSize == BFS_SMALL);
SetFontSmall(pdp);
}
@ -159,6 +157,7 @@ void CMGButton::Render(CDrawPort *pdp)
if (mg_strLabel != "") {
pixX += box.Size()(1)*0.55f;
}
PIX pixY = box.Min()(2);
if (!pdp->dp_FontData->fd_bFixedWidth) {
pixY -= pdp->dp_fTextScaling * 2;

View File

@ -27,10 +27,13 @@ void CMGChangePlayer::OnActivate(void)
PlayMenuSound(_psdPress);
IFeel_PlayEffect("Menu_press");
_iLocalPlayer = mg_iLocalPlayer;
if (_pGame->gm_aiMenuLocalPlayers[mg_iLocalPlayer] < 0)
_pGame->gm_aiMenuLocalPlayers[mg_iLocalPlayer] = 0;
_pGUIM->gmPlayerProfile.gm_piCurrentPlayer = &_pGame->gm_aiMenuLocalPlayers[mg_iLocalPlayer];
_pGUIM->gmPlayerProfile.gm_pgmParentMenu = &_pGUIM->gmSelectPlayersMenu;
extern BOOL _bPlayerMenuFromSinglePlayer;
_bPlayerMenuFromSinglePlayer = FALSE;
ChangeToMenu(&_pGUIM->gmPlayerProfile);
@ -40,10 +43,10 @@ void CMGChangePlayer::SetPlayerText(void)
{
INDEX iPlayer = _pGame->gm_aiMenuLocalPlayers[mg_iLocalPlayer];
CPlayerCharacter &pc = _pGame->gm_apcPlayers[iPlayer];
if (iPlayer<0 || iPlayer>7) {
mg_strText = "????";
}
else {
} else {
mg_strText.PrintF(TRANS("Player %d: %s\n"), mg_iLocalPlayer + 1, pc.GetNameForPrinting());
}
}

View File

@ -74,8 +74,7 @@ static void Key_BackDel(CTString &str, INDEX &iPos, BOOL bShift, BOOL bRight)
if (bShift) {
// delete to end of line
str.TrimRight(iPos);
}
else {
} else {
// delete only one char
str.DeleteChar(iPos);
}
@ -85,8 +84,7 @@ static void Key_BackDel(CTString &str, INDEX &iPos, BOOL bShift, BOOL bRight)
// delete to start of line
str.TrimLeft(ctChars - iPos);
iPos = 0;
}
else {
} else {
// delete only one char
str.DeleteChar(iPos - 1);
iPos--;
@ -147,24 +145,21 @@ void CMGEdit::Render(CDrawPort *pdp)
{
if (mg_bEditing) {
mg_iTextMode = -1;
}
else if (mg_bFocused) {
} else if (mg_bFocused) {
mg_iTextMode = 0;
}
else {
} else {
mg_iTextMode = 1;
}
if (mg_strText == "" && !mg_bEditing) {
if (mg_bfsFontSize == BFS_SMALL) {
mg_strText = "*";
}
else {
} else {
mg_strText = TRANS("<none>");
}
CMGButton::Render(pdp);
mg_strText = "";
}
else {
} else {
CMGButton::Render(pdp);
}
}

View File

@ -42,8 +42,7 @@ void CMGFileButton::SaveDescription(void)
CTFileName fnFileNameDescription = mg_fnm.NoExt() + ".des";
try {
mg_strDes.Save_t(fnFileNameDescription);
}
catch (char *strError) {
} catch (char *strError) {
CPrintF("%s\n", strError);
}
}
@ -62,8 +61,7 @@ void CMGFileButton::DoSave(void)
_pmgFileToSave = this;
extern void SaveConfirm(void);
SaveConfirm();
}
else {
} else {
SaveYes();
}
}
@ -118,16 +116,17 @@ void CMGFileButton::OnActivate(void)
// load now
DoLoad();
// if saving
}
else {
} else {
// switch to editing mode
BOOL bWasEmpty = mg_strText == EMPTYSLOTSTRING;
mg_strDes = _pGUIM->gmLoadSaveMenu.gm_strSaveDes;
RefreshText();
_strOrgDescription = _strTmpDescription = mg_strText;
if (bWasEmpty) {
_strOrgDescription = EMPTYSLOTSTRING;
}
mg_pstrToChange = &_strTmpDescription;
StartEdit();
mg_iState = FBS_SAVENAME;
@ -148,8 +147,8 @@ BOOL CMGFileButton::OnKeyDown(int iVKey)
mg_iState = FBS_RENAME;
}
return TRUE;
}
else if (iVKey == VK_DELETE) {
} else if (iVKey == VK_DELETE) {
if (FileExistsForWriting(mg_fnm)) {
// delete the file, its description and thumbnail
RemoveFile(mg_fnm);
@ -164,8 +163,7 @@ BOOL CMGFileButton::OnKeyDown(int iVKey)
}
}
return CMenuGadget::OnKeyDown(iVKey);
}
else {
} else {
// go out of editing mode
if (mg_bEditing) {
if (iVKey == VK_UP || iVKey == VK_DOWN) {
@ -185,6 +183,7 @@ void CMGFileButton::OnSetFocus(void)
} else {
ClearThumbnail();
}
pgmCurrentMenu->KillAllFocuses();
CMGButton::OnSetFocus();
}
@ -195,6 +194,7 @@ void CMGFileButton::OnKillFocus(void)
if (mg_bEditing) {
OnKeyDown(VK_ESCAPE);
}
CMGEdit::OnKillFocus();
}
@ -206,9 +206,8 @@ void CMGFileButton::OnStringChanged(void)
// do the save
mg_strDes = _strTmpDescription + "\n" + mg_strInfo;
DoSave();
// if renaming
}
else if (mg_iState == FBS_RENAME) {
// if renaming
} else if (mg_iState == FBS_RENAME) {
// do the rename
mg_strDes = _strTmpDescription + "\n" + mg_strInfo;
SaveDescription();

View File

@ -94,8 +94,7 @@ void CMGHighScore::Render(CDrawPort *pdp)
}}
if (iRow == 0) {
pixJ += pdp->GetHeight()*0.06f;
}
else {
} else {
pixJ += pdp->GetHeight()*0.04f;
}
}}

View File

@ -79,9 +79,8 @@ void CMGKeyDefinition::SetBindingNames(BOOL bDefining)
if (bKey1Bound && !bKey2Bound) {
// put question mark for second key
mg_strBinding = strKey1 + TRANS(" or ") + "?";
// otherwise
}
else {
// otherwise
} else {
// put question mark only
mg_strBinding = "?";
}
@ -92,9 +91,8 @@ void CMGKeyDefinition::SetBindingNames(BOOL bDefining)
if (bKey2Bound) {
// add both
mg_strBinding = strKey1 + TRANS(" or ") + strKey2;
// if second key is undefined
}
else {
// if second key is undefined
} else {
// display only first one
mg_strBinding = strKey1;
}
@ -139,15 +137,13 @@ void CMGKeyDefinition::DefineKey(INDEX iDik)
ba.ba_iFirstKey = iDik;
// clear second key
ba.ba_iSecondKey = KID_NONE;
// if only first key bound
}
else {
// if only first key bound
} else {
// bind second key
ba.ba_iSecondKey = iDik;
}
// if it is not this one
}
else {
} else {
// clear bindings that contain this key
if (ba.ba_iFirstKey == iDik) {
ba.ba_iFirstKey = KID_NONE;
@ -195,8 +191,7 @@ void CMGKeyDefinition::Think(void)
// define the new key
DefineKey(iDik);
// if escape pressed
}
else {
} else {
// undefine the key
DefineKey(KID_NONE);
}

View File

@ -67,8 +67,7 @@ void CMGServerList::AdjustFirstOnScreen(void)
if (mg_iSelected<mg_iFirstOnScreen) {
mg_iFirstOnScreen = ClampUp(mg_iSelected, ClampDn(ctSessions - mg_ctOnScreen - 1L, 0L));
}
else if (mg_iSelected >= mg_iFirstOnScreen + mg_ctOnScreen) {
} else if (mg_iSelected >= mg_iFirstOnScreen + mg_ctOnScreen) {
mg_iFirstOnScreen = ClampDn(mg_iSelected - mg_ctOnScreen + 1L, 0L);
}
}
@ -104,11 +103,11 @@ extern CMGEdit mgServerFilter[7];
void SortAndFilterServers(void)
{
{ FORDELETELIST(CNetworkSession, ns_lnNode, _lhServers, itns) {
{FORDELETELIST(CNetworkSession, ns_lnNode, _lhServers, itns) {
delete &*itns;
} }
{
FOREACHINLIST(CNetworkSession, ns_lnNode, _pNetwork->ga_lhEnumeratedSessions, itns) {
}}
{FOREACHINLIST(CNetworkSession, ns_lnNode, _pNetwork->ga_lhEnumeratedSessions, itns) {
CNetworkSession &ns = *itns;
extern CTString _strServerFilter[7];
if (_strServerFilter[0] != "" && !ns.ns_strSession.Matches("*" + _strServerFilter[0] + "*")) continue;
@ -245,8 +244,7 @@ void CMGServerList::Render(CDrawPort *pdp)
PrintInBox(pdp, apixSeparatorI[0] + pixCharSizeI, pixListTopJ + pixCharSizeJ + pixLineSize + 1, apixSeparatorI[1] - apixSeparatorI[0],
TRANS("searching..."), colItem);
}
}
else {
} else {
FOREACHINLIST(CNetworkSession, ns_lnNode, _lhServers, itns) {
CNetworkSession &ns = *itns;
@ -352,8 +350,7 @@ void CMGServerList::OnMouseOver(PIX pixI, PIX pixJ)
AdjustFirstOnScreen();
mg_pixMouseDrag = -1;
}
}
else if (bInSlider) {
} else if (bInSlider) {
mg_pixMouseDrag = pixJ;
}
}

View File

@ -60,14 +60,12 @@ BOOL CMGSlider::OnKeyDown(int iVKey)
ApplyCurrentPosition();
return TRUE;
// if scrolling right
}
else if ((iVKey == VK_RETURN || iVKey == VK_RIGHT) && mg_iCurPos<mg_iMaxPos) {
} else if ((iVKey == VK_RETURN || iVKey == VK_RIGHT) && mg_iCurPos<mg_iMaxPos) {
mg_iCurPos++;
ApplyCurrentPosition();
return TRUE;
// if lmb pressed
}
else if (iVKey == VK_LBUTTON) {
} else if (iVKey == VK_LBUTTON) {
// get position of slider box on screen
PIXaabbox2D boxSlider = GetSliderBox();
// if mouse is within

View File

@ -27,10 +27,8 @@ INDEX GetNewLoopValue(int iVKey, INDEX iCurrent, INDEX ctMembers)
if (iVKey == VK_RETURN || iVKey == VK_LBUTTON || iVKey == VK_RIGHT)
{
return iNext;
}
// left arrow and backspace sets prev text
else if ((iVKey == VK_BACK || iVKey == VK_RBUTTON) || (iVKey == VK_LEFT))
{
} else if ((iVKey == VK_BACK || iVKey == VK_RBUTTON) || (iVKey == VK_LEFT)) {
return iPrev;
}
return iCurrent;
@ -94,16 +92,15 @@ void CMGTrigger::Render(CDrawPort *pdp)
if (mg_bVisual) {
strValue = TRANS("none");
}
if (mg_iCenterI == -1) {
pdp->PutText(mg_strLabel, box.Min()(1), pixJ, col);
pdp->PutTextR(strValue, box.Max()(1), pixJ, col);
}
else {
} else {
pdp->PutTextR(mg_strLabel, pixIL, pixJ, col);
pdp->PutText(strValue, pixIR, pixJ, col);
}
}
else {
} else {
CTString strLabel = mg_strLabel + ": ";
pdp->PutText(strLabel, box.Min()(1), pixJ, col);
CTextureObject to;
@ -116,8 +113,7 @@ void CMGTrigger::Render(CDrawPort *pdp)
pdp->PutTexture(&to, PIXaabbox2D(
PIX2D(pixCX - pixSize / 2, pixCY - pixSize / 2),
PIX2D(pixCX - pixSize / 2 + pixSize, pixCY - pixSize / 2 + pixSize)), C_WHITE | 255);
}
catch (char *strError) {
} catch (char *strError) {
CPrintF("%s\n", strError);
}
to.SetData(NULL);

View File

@ -141,9 +141,7 @@ void CMGVarButton::Render(CDrawPort *pdp)
COLOR col = LCDGetColor(C_WHITE | 255, "separator");
CTString strText = mg_pvsVar->vs_strName;
pdp->PutTextC(strText, pixIC, pixJ, col);
}
else if (mg_pvsVar->Validate())
{
} else if (mg_pvsVar->Validate()) {
// check whether the variable is disabled
if (mg_pvsVar->vs_strFilter != "") mg_bEnabled = _pShell->GetINDEX(mg_pvsVar->vs_strFilter);
COLOR col = GetCurrentColor();
@ -160,13 +158,13 @@ void CMGVarButton::Render(CDrawPort *pdp)
PIX pixJSize = box.Size()(2);
LCDDrawBox(0, -1, PIXaabbox2D(PIX2D(pixIR, pixJ + 1), PIX2D(pixIR + pixISize - 4, pixJ + pixJSize - 6)),
LCDGetColor(C_GREEN | 255, "slider box"));
// draw filled part of slider
if (mg_pvsVar->vs_iSlider == 1) {
// fill slider
FLOAT fFactor = (FLOAT)(mg_pvsVar->vs_iValue + 1) / mg_pvsVar->vs_ctValues;
pdp->Fill(pixIR + 1, pixJ + 2, (pixISize - 6)*fFactor, pixJSize - 9, col);
}
else {
} else {
// ratio slider
ASSERT(mg_pvsVar->vs_iSlider == 2);
FLOAT fUnitWidth = (FLOAT)(pixISize - 5) / mg_pvsVar->vs_ctValues;

View File

@ -324,9 +324,8 @@ void CGameMenu::StartMenu(void)
if (itmg->mg_iInList == -2) {
// hide it
itmg->mg_bVisible = FALSE;
// if in list
}
else if (itmg->mg_iInList >= 0) {
// if in list
} else if (itmg->mg_iInList >= 0) {
// show it
itmg->mg_bVisible = TRUE;
}

View File

@ -1364,10 +1364,8 @@ BOOL TryToSetDisplayMode( enum GfxAPIType eGfxAPI, INDEX iAdapter, PIX pixSizeI,
// report success
return TRUE;
}
// if couldn't set new mode
else {
} else {
// close the application window
CloseMainWindow();
// report failure