Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include "GameNetwork/IPEnumeration.h"
#include "WWDownload/Registry.h"

UnsignedInt GetTeamUiColor(Int teamNumber);

SkirmishGameInfo *TheSkirmishGameInfo = NULL;

Expand Down Expand Up @@ -869,25 +870,53 @@ void updateMapStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[
GameSlot *gs =myGame->getSlot(i);
if(onLoadScreen)
{
if(gs->getApparentStartPos() >=0 && gs->getApparentStartPos() < mmd.m_numPlayers && gs->getPlayerTemplate() > PLAYERTEMPLATE_MIN )
{
AsciiString displayNumber;
displayNumber.format("NUMBER:%d",i + 1);
GadgetButtonSetText(buttonMapStartPositions[gs->getApparentStartPos()], TheGameText->fetch(displayNumber));
}
Int startPos = gs->getApparentStartPos();
GameWindow* btn = buttonMapStartPositions[startPos];
if (!btn)
continue;

AsciiString displayNumber;
displayNumber.format("NUMBER:%d", i + 1);
GadgetButtonSetText(btn, TheGameText->fetch(displayNumber));

UnsignedInt col = (gs->getTeamNumber() >= 0)
? GetTeamUiColor(gs->getTeamNumber())
: GameMakeColor(255, 255, 255, 255);

GadgetTextEntrySetTextColor(btn, col);
}
else
{
if(gs->getStartPos() >=0 && gs->getStartPos() < mmd.m_numPlayers && gs->getPlayerTemplate() > PLAYERTEMPLATE_MIN )
if (gs->getStartPos() >= 0 &&
gs->getStartPos() < mmd.m_numPlayers &&
gs->getPlayerTemplate() > PLAYERTEMPLATE_MIN)
{
Int startPos = gs->getStartPos();
GameWindow* btn = buttonMapStartPositions[startPos];
if (!btn)
continue;

AsciiString displayNumber;
displayNumber.format("NUMBER:%d",i + 1);
GadgetButtonSetText(buttonMapStartPositions[gs->getStartPos()], TheGameText->fetch(displayNumber));
//added start position tooltip
//Fixed again to show the right number , ie "i + 1"
displayNumber.format("NUMBER:%d", i + 1);
GadgetButtonSetText(btn, TheGameText->fetch(displayNumber));

UnicodeString temp;
temp.format(TheGameText->fetch("TOOLTIP:StartPositionN"), i + 1);
buttonMapStartPositions[gs->getStartPos()]->winSetTooltip(temp);
btn->winSetTooltip(temp);

Int team = gs->getTeamNumber();
UnsignedInt col;
if (team >= 0)
{
col = GetTeamUiColor(team);
}
else
{
// No team: default to white
col = GameMakeColor(255, 255, 255, 255);
}

GadgetTextEntrySetTextColor(btn, col);
}
}
}
Expand Down
55 changes: 39 additions & 16 deletions GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// FILE: GUIUtil.cpp //////////////////////////////////////////////////////
// Author: Matthew D. Campbell, Sept 2002

#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine
#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine

#include "GameNetwork/GUIUtil.h"
#include "GameNetwork/NetworkDefs.h"
Expand Down Expand Up @@ -137,7 +137,7 @@ void ShowUnderlyingGUIElements( Bool show, const char *layoutFilename, const cha
GameWindow *parent = TheWindowManager->winGetWindowFromId( NULL, parentID );
if (!parent)
{
DEBUG_CRASH(("Window %s not found", parentNameStr.str()));
DEBUG_CRASH(("Window %s not found", parentNameStr.str()));
return;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ void PopulateColorComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myG

for (i = 0; i < MAX_SLOTS; i++)
{
GameSlot *slot = myGame->getSlot(i);
GameSlot *slot = myGame->getSlot(i);
if( slot && (i != comboBox) && (slot->getColor() >= 0 )&& (slot->getColor() < numColors))
{
DEBUG_ASSERTCRASH(slot->getColor() >= 0,("We've tried to access array %d and that ain't good",slot->getColor()));
Expand Down Expand Up @@ -298,6 +298,28 @@ void PopulatePlayerTemplateComboBox(Int comboBox, GameWindow *comboArray[], Game

// -----------------------------------------------------------------------------

// team colors for UI (team combo + minimap start positions).
UnsignedInt GetTeamUiColor(Int teamNumber)
{
switch (teamNumber)
{
case 0:
return GameMakeColor(255, 60, 60, 255); // Red

case 1:
return GameMakeColor(60, 255, 60, 255); // Green

case 2:
return GameMakeColor(60, 120, 255, 255); // Blue

case 3:
return GameMakeColor(255, 220, 60, 255); // Yellow
}

// Default: white (none)
return GameMakeColor(255, 255, 255, 255);
}

void PopulateTeamComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool isObserver)
{
Int numTeams = MAX_SLOTS/2;
Expand All @@ -320,10 +342,10 @@ void PopulateTeamComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGa
AsciiString teamStr;
teamStr.format("Team:%d", c + 1);
teamName = TheGameText->fetch(teamStr.str());
newIndex = GadgetComboBoxAddEntry(comboArray[comboBox], teamName, def->getColor());
GadgetComboBoxSetItemData(comboArray[comboBox], newIndex, (void *)c);
}
GadgetComboBoxSetSelectedPos(comboArray[comboBox], 0);
UnsignedInt teamColor = GetTeamUiColor(c);
newIndex = GadgetComboBoxAddEntry(comboArray[comboBox],teamName,teamColor);
GadgetComboBoxSetItemData(comboArray[comboBox], newIndex, (void *)c);
}
}

// -----------------------------------------------------------------------------
Expand All @@ -338,13 +360,13 @@ void PopulateStartingCashComboBox(GameWindow *comboBox, GameInfo *myGame)
{
GadgetComboBoxReset(comboBox);

const MultiplayerStartingMoneyList & startingCashMap = TheMultiplayerSettings->getStartingMoneyList();
const MultiplayerStartingMoneyList & startingCashMap = TheMultiplayerSettings->getStartingMoneyList();
Int currentSelectionIndex = -1;

MultiplayerStartingMoneyList::const_iterator it = startingCashMap.begin();
for ( ; it != startingCashMap.end(); it++ )
{
Int newIndex = GadgetComboBoxAddEntry(comboBox, formatMoneyForStartingCashComboBox( *it ),
Int newIndex = GadgetComboBoxAddEntry(comboBox, formatMoneyForStartingCashComboBox( *it ),
comboBox->winGetEnabled() ? comboBox->winGetEnabledTextColor() : comboBox->winGetDisabledTextColor());
GadgetComboBoxSetItemData(comboBox, newIndex, (void *)it->countMoney());

Expand All @@ -364,7 +386,7 @@ void PopulateStartingCashComboBox(GameWindow *comboBox, GameInfo *myGame)
if ( currentSelectionIndex == -1 )
{
DEBUG_CRASH( ("Current selection for starting cash not found in list") );
currentSelectionIndex = GadgetComboBoxAddEntry(comboBox, formatMoneyForStartingCashComboBox( myGame->getStartingCash() ),
currentSelectionIndex = GadgetComboBoxAddEntry(comboBox, formatMoneyForStartingCashComboBox( myGame->getStartingCash() ),
comboBox->winGetEnabled() ? comboBox->winGetEnabledTextColor() : comboBox->winGetDisabledTextColor());
GadgetComboBoxSetItemData(comboBox, currentSelectionIndex, (void *)it->countMoney() );
}
Expand All @@ -379,7 +401,7 @@ void PopulateStartingCashComboBox(GameWindow *comboBox, GameInfo *myGame)
//-------------------------------------------------------------------------------------------------
void UpdateSlotList( GameInfo *myGame, GameWindow *comboPlayer[],
GameWindow *comboColor[], GameWindow *comboPlayerTemplate[],
GameWindow *comboTeam[], GameWindow *buttonAccept[],
GameWindow *comboTeam[], GameWindow *buttonAccept[],
GameWindow *buttonStart, GameWindow *buttonMapStartPosition[] )
{
if(!AreSlotListUpdatesEnabled())
Expand All @@ -402,14 +424,14 @@ void UpdateSlotList( GameInfo *myGame, GameWindow *comboPlayer[],
for( int i =0; i < MAX_SLOTS; i++ )
{
GameSlot * slot = myGame->getSlot(i);

// if i'm host, enable the controls for AI
if(myGame->amIHost() && slot->isAI())
if(myGame->amIHost() && slot->isAI())
{
EnableAcceptControls(TRUE, myGame, comboPlayer, comboColor, comboPlayerTemplate,
comboTeam, buttonAccept, buttonStart, buttonMapStartPosition, i);
}
else if (myGame->getLocalSlotNum() == i)
else if (myGame->getLocalSlotNum() == i)
{
if(slot->isAccepted() && !myGame->amIHost())
{
Expand All @@ -428,7 +450,7 @@ void UpdateSlotList( GameInfo *myGame, GameWindow *comboPlayer[],
comboTeam, buttonAccept, buttonStart, buttonMapStartPosition);
}
}

}
else if(myGame->amIHost())
{
Expand Down Expand Up @@ -464,7 +486,7 @@ void UpdateSlotList( GameInfo *myGame, GameWindow *comboPlayer[],
}
}
else
{
{
GadgetComboBoxSetSelectedPos(comboPlayer[i], slot->getState(), TRUE);
if (buttonAccept && buttonAccept[i])
buttonAccept[i]->winHide(TRUE);
Expand Down Expand Up @@ -530,3 +552,4 @@ void UpdateSlotList( GameInfo *myGame, GameWindow *comboPlayer[],
}

// -----------------------------------------------------------------------------

Loading