connected playernames and free slots are shown on the client.
some bugfixes
This commit is contained in:
parent
e692e6efee
commit
edd3b66273
|
@ -29,6 +29,7 @@ private:
|
|||
string scenario;
|
||||
string scenarioDir;
|
||||
string factionTypeNames[GameConstants::maxPlayers]; //faction names
|
||||
string networkPlayerNames[GameConstants::maxPlayers];
|
||||
|
||||
ControlType factionControls[GameConstants::maxPlayers];
|
||||
|
||||
|
@ -37,6 +38,7 @@ private:
|
|||
int teams[GameConstants::maxPlayers];
|
||||
int startLocationIndex[GameConstants::maxPlayers];
|
||||
|
||||
|
||||
bool defaultUnits;
|
||||
bool defaultResources;
|
||||
bool defaultVictoryConditions;
|
||||
|
@ -60,6 +62,7 @@ public:
|
|||
const string &getScenario() const {return scenario;}
|
||||
const string &getScenarioDir() const {return scenarioDir;}
|
||||
const string &getFactionTypeName(int factionIndex) const {return factionTypeNames[factionIndex];}
|
||||
const string &getNetworkPlayerName(int factionIndex) const {return networkPlayerNames[factionIndex];}
|
||||
ControlType getFactionControl(int factionIndex) const {return factionControls[factionIndex];}
|
||||
|
||||
int getThisFactionIndex() const {return thisFactionIndex;}
|
||||
|
@ -82,6 +85,7 @@ public:
|
|||
void setScenarioDir(const string& scenarioDir) {this->scenarioDir= scenarioDir;}
|
||||
|
||||
void setFactionTypeName(int factionIndex, const string& factionTypeName) {this->factionTypeNames[factionIndex]= factionTypeName;}
|
||||
void setNetworkPlayerName(int factionIndex,const string& playername) {this->networkPlayerNames[factionIndex]= playername;}
|
||||
void setFactionControl(int factionIndex, ControlType controller) {this->factionControls[factionIndex]= controller;}
|
||||
void setThisFactionIndex(int thisFactionIndex) {this->thisFactionIndex= thisFactionIndex;}
|
||||
void setFactionCount(int factionCount) {this->factionCount= factionCount;}
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Glest{ namespace Game{
|
|||
// =====================================================
|
||||
|
||||
// ===================== PUBLIC ========================
|
||||
MenuState *oldstate=NULL;
|
||||
MenuState * MainMenu::oldstate=NULL;
|
||||
|
||||
MainMenu::MainMenu(Program *program):
|
||||
ProgramState(program)
|
||||
|
|
|
@ -57,7 +57,9 @@ class MenuState;
|
|||
// =====================================================
|
||||
|
||||
class MainMenu: public ProgramState{
|
||||
|
||||
private:
|
||||
static MenuState *oldstate;
|
||||
//up
|
||||
Program *program;
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ struct FormatString {
|
|||
}
|
||||
};
|
||||
|
||||
string currentFactionName="";
|
||||
string currentMap="";
|
||||
// =====================================================
|
||||
// class MenuStateConnectedGame
|
||||
// =====================================================
|
||||
|
@ -55,6 +53,12 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
needToSetChangedGameSettings = false;
|
||||
lastSetChangedGameSettings = time(NULL);;
|
||||
|
||||
|
||||
currentFactionName="";
|
||||
currentMap="";
|
||||
settingsReceivedFromServer=false;
|
||||
|
||||
|
||||
vector<string> teamItems, controlItems, results;
|
||||
//state
|
||||
labelStatus.init(330, 700);
|
||||
|
@ -142,7 +146,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
listBoxTeams[i].setItems(teamItems);
|
||||
listBoxTeams[i].setSelectedItemIndex(i);
|
||||
listBoxControls[i].setItems(controlItems);
|
||||
labelNetStatus[i].setText("");
|
||||
labelNetStatus[i].setText("V");
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
labelMap.setText(lang.get("Map"));
|
||||
|
@ -286,6 +290,7 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){
|
|||
void MenuStateConnectedGame::render(){
|
||||
|
||||
try {
|
||||
if (!settingsReceivedFromServer) return;
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
int i;
|
||||
|
@ -299,9 +304,14 @@ void MenuStateConnectedGame::render(){
|
|||
if(listBoxControls[i].getSelectedItemIndex()!=ctClosed){
|
||||
renderer.renderListBox(&listBoxFactions[i]);
|
||||
renderer.renderListBox(&listBoxTeams[i]);
|
||||
//renderer.renderLabel(&labelNetStatus[i]);
|
||||
|
||||
if((listBoxControls[i].getSelectedItemIndex()==ctNetwork) ||
|
||||
(listBoxControls[i].getSelectedItemIndex()==ctHuman)){
|
||||
renderer.renderLabel(&labelNetStatus[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
renderer.renderLabel(&labelStatus);
|
||||
renderer.renderLabel(&labelInfo);
|
||||
renderer.renderLabel(&labelMap);
|
||||
|
@ -420,6 +430,7 @@ void MenuStateConnectedGame::update()
|
|||
clientInterface->close();
|
||||
}
|
||||
mainMenu->setState(new MenuStateJoinGame(program, mainMenu));
|
||||
return;
|
||||
}
|
||||
|
||||
//process network messages
|
||||
|
@ -453,7 +464,6 @@ void MenuStateConnectedGame::update()
|
|||
currentMap=gameSettings->getMap();
|
||||
}
|
||||
|
||||
|
||||
// FogOfWar
|
||||
if(gameSettings->getFogOfWar()){
|
||||
listBoxFogOfWar.setSelectedItemIndex(0);
|
||||
|
@ -474,11 +484,17 @@ void MenuStateConnectedGame::update()
|
|||
listBoxTeams[slot].setSelectedItemIndex(gameSettings->getTeam(i));
|
||||
listBoxFactions[slot].setSelectedItem(formatString(gameSettings->getFactionTypeName(i)));
|
||||
|
||||
if(gameSettings->getFactionControl(i) == ctNetwork ){
|
||||
labelNetStatus[slot].setText(gameSettings->getNetworkPlayerName(i));
|
||||
}
|
||||
|
||||
if(gameSettings->getFactionControl(i) == ctNetwork && gameSettings->getThisFactionIndex() == i){
|
||||
// set my current slot to ctHuman
|
||||
listBoxControls[slot].setSelectedItemIndex(ctHuman);
|
||||
}
|
||||
|
||||
settingsReceivedFromServer=true;
|
||||
|
||||
}
|
||||
}
|
||||
//update lobby
|
||||
|
|
|
@ -57,6 +57,11 @@ private:
|
|||
Console console;
|
||||
ChatManager chatManager;
|
||||
|
||||
string currentFactionName;
|
||||
string currentMap;
|
||||
bool settingsReceivedFromServer;
|
||||
|
||||
|
||||
public:
|
||||
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots= false);
|
||||
|
||||
|
|
|
@ -554,6 +554,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings)
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
int factionCount= 0;
|
||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||
|
||||
gameSettings->setDescription(formatString(mapFiles[listBoxMap.getSelectedItemIndex()]));
|
||||
gameSettings->setMap(mapFiles[listBoxMap.getSelectedItemIndex()]);
|
||||
|
@ -577,6 +578,26 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings)
|
|||
gameSettings->setTeam(factionCount, listBoxTeams[i].getSelectedItemIndex());
|
||||
gameSettings->setStartLocationIndex(factionCount, i);
|
||||
gameSettings->setFactionTypeName(factionCount, factionFiles[listBoxFactions[i].getSelectedItemIndex()]);
|
||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork)
|
||||
{
|
||||
ConnectionSlot* connectionSlot= serverInterface->getSlot(i);
|
||||
if((connectionSlot!=NULL) && (connectionSlot->isConnected()))
|
||||
{
|
||||
gameSettings->setNetworkPlayerName(factionCount, connectionSlot->getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
gameSettings->setNetworkPlayerName(factionCount, "???");
|
||||
}
|
||||
}
|
||||
else if (listBoxControls[i].getSelectedItemIndex() == ctHuman)
|
||||
{
|
||||
gameSettings->setNetworkPlayerName(factionCount, Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
gameSettings->setNetworkPlayerName(factionCount, "");
|
||||
}
|
||||
factionCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,6 +183,7 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
|||
|
||||
for(int i= 0; i<data.factionCount; ++i){
|
||||
data.factionTypeNames[i]= gameSettings->getFactionTypeName(i);
|
||||
data.networkPlayerNames[i]= gameSettings->getNetworkPlayerName(i);
|
||||
data.factionControls[i]= gameSettings->getFactionControl(i);
|
||||
data.teams[i]= gameSettings->getTeam(i);
|
||||
data.startLocationIndex[i]= gameSettings->getStartLocationIndex(i);
|
||||
|
@ -203,6 +204,7 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const{
|
|||
|
||||
for(int i= 0; i<data.factionCount; ++i){
|
||||
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());
|
||||
gameSettings->setNetworkPlayerName(i,data.networkPlayerNames[i].getString());
|
||||
gameSettings->setFactionControl(i, static_cast<ControlType>(data.factionControls[i]));
|
||||
gameSettings->setTeam(i, data.teams[i]);
|
||||
gameSettings->setStartLocationIndex(i, data.startLocationIndex[i]);
|
||||
|
|
|
@ -141,6 +141,7 @@ private:
|
|||
NetworkString<maxStringSize> tileset;
|
||||
NetworkString<maxStringSize> tech;
|
||||
NetworkString<maxStringSize> factionTypeNames[GameConstants::maxPlayers]; //faction names
|
||||
NetworkString<maxStringSize> networkPlayerNames[GameConstants::maxPlayers]; //networkPlayerNames
|
||||
|
||||
int8 factionControls[GameConstants::maxPlayers];
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user