- added ability to override UI placement for connected and custom menus

This commit is contained in:
Mark Vejvoda 2010-09-08 22:37:24 +00:00
parent 54f37d6231
commit cf5b085b2e
6 changed files with 210 additions and 10 deletions

View File

@ -18,6 +18,7 @@
#include "core_data.h"
#include "platform_util.h"
#include "util.h"
#include "conversion.h"
#include "leak_dumper.h"
using namespace std;
@ -34,11 +35,66 @@ float GraphicComponent::fade= 0.f;
const float GraphicComponent::animSpeed= 0.02f;
const float GraphicComponent::fadeSpeed= 0.01f;
GraphicComponent::GraphicComponent(){
std::map<std::string, std::map<std::string, GraphicComponent *> > GraphicComponent::registeredGraphicComponentList;
GraphicComponent::GraphicComponent(std::string containerName, std::string objName) {
instanceName = "";
if(objName != "") {
registerGraphicComponent(containerName,objName);
}
enabled= true;
editable= true;
}
void GraphicComponent::registerGraphicComponent(std::string containerName, std::string objName) {
instanceName = objName;
registeredGraphicComponentList[containerName][objName] = this;
}
GraphicComponent * GraphicComponent::findRegisteredComponent(std::string containerName, std::string objName) {
GraphicComponent *result = NULL;
std::map<std::string, std::map<std::string, GraphicComponent *> >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName);
if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) {
std::map<std::string, GraphicComponent *>::iterator iterFind2 = iterFind1->second.find(objName);
if(iterFind2 != iterFind1->second.end()) {
result = iterFind2->second;
}
}
return result;
}
void GraphicComponent::applyAllCustomProperties(std::string containerName) {
std::map<std::string, std::map<std::string, GraphicComponent *> >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName);
if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) {
for(std::map<std::string, GraphicComponent *>::iterator iterFind2 = iterFind1->second.begin();
iterFind2 != iterFind1->second.end(); iterFind2++) {
iterFind2->second->applyCustomProperties(containerName);
}
}
}
void GraphicComponent::applyCustomProperties(std::string containerName) {
if(instanceName != "") {
std::map<std::string, std::map<std::string, GraphicComponent *> >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName);
if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) {
std::map<std::string, GraphicComponent *>::iterator iterFind2 = iterFind1->second.find(instanceName);
if(iterFind2 != iterFind1->second.end()) {
Config &config = Config::getInstance();
//if(dynamic_cast<GraphicButton *>(iterFind2->second) != NULL) {
GraphicComponent *ctl = dynamic_cast<GraphicComponent *>(iterFind2->second);
ctl->x = config.getInt(containerName + "_" + iterFind2->first + "_x",intToStr(ctl->x).c_str());
ctl->y = config.getInt(containerName + "_" + iterFind2->first + "_y",intToStr(ctl->y).c_str());
ctl->w = config.getInt(containerName + "_" + iterFind2->first + "_w",intToStr(ctl->w).c_str());
ctl->h = config.getInt(containerName + "_" + iterFind2->first + "_h",intToStr(ctl->h).c_str());
//}
}
}
}
}
void GraphicComponent::init(int x, int y, int w, int h){
this->x= x;
this->y= y;

View File

@ -14,7 +14,8 @@
#include <string>
#include <vector>
#include <map>
#include <typeinfo>
#include "font.h"
#include "leak_dumper.h"
@ -25,17 +26,21 @@ using Shared::Graphics::Font2D;
namespace Glest{ namespace Game{
class GraphicComponent;
// ===========================================================
// class GraphicComponent
//
// OpenGL renderer GUI components
// ===========================================================
class GraphicComponent{
class GraphicComponent {
public:
static const float animSpeed;
static const float fadeSpeed;
static std::map<std::string, std::map<std::string, GraphicComponent *> > registeredGraphicComponentList;
protected:
int x, y, w, h;
string text;
@ -46,10 +51,17 @@ protected:
static float anim;
static float fade;
string instanceName;
public:
GraphicComponent();
GraphicComponent(std::string containerName="", std::string objName="");
virtual ~GraphicComponent(){}
void registerGraphicComponent(std::string containerName, std::string objName);
static GraphicComponent * findRegisteredComponent(std::string containerName, std::string objName);
static void applyAllCustomProperties(std::string containerName);
void applyCustomProperties(std::string containerName);
void init(int x, int y, int w, int h);
int getX() const {return x;}
@ -81,7 +93,7 @@ public:
// class GraphicLabel
// ===========================================================
class GraphicLabel: public GraphicComponent{
class GraphicLabel: public GraphicComponent {
public:
static const int defH;
static const int defW;
@ -101,7 +113,7 @@ public:
// class GraphicButton
// ===========================================================
class GraphicButton: public GraphicComponent{
class GraphicButton: public GraphicComponent {
public:
static const int defH;
static const int defW;
@ -122,7 +134,7 @@ public:
// class GraphicListBox
// ===========================================================
class GraphicListBox: public GraphicComponent{
class GraphicListBox: public GraphicComponent {
public:
static const int defH;
static const int defW;
@ -155,7 +167,7 @@ public:
// class GraphicMessageBox
// ===========================================================
class GraphicMessageBox: public GraphicComponent{
class GraphicMessageBox: public GraphicComponent {
public:
static const int defH;
static const int defW;

View File

@ -45,6 +45,8 @@ struct FormatString {
// class MenuStateConnectedGame
// =====================================================
const char *MenuStateConnectedGame::containerName = "ClientConnectedGame";
MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainMenu,JoinMenu joinMenuInfo, bool openNetworkSlots):
MenuState(program, mainMenu, "connected-game") //← set on connected-game
{
@ -86,23 +88,32 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
int xoffset=0;
//state
labelStatus.registerGraphicComponent(containerName,"labelStatus");
labelStatus.init(350, networkHeadPos+30);
labelStatus.setText("");
labelInfo.registerGraphicComponent(containerName,"labelInfo");
labelInfo.init(30, networkHeadPos+30);
labelInfo.setText("");
labelInfo.setFont(CoreData::getInstance().getMenuFontBig());
//create
buttonDisconnect.registerGraphicComponent(containerName,"buttonDisconnect");
buttonDisconnect.init(450, 180, 125);
buttonPlayNow.registerGraphicComponent(containerName,"buttonPlayNow");
buttonPlayNow.init(525, 180, 125);
xoffset=170;
// fog - o - war
// @350 ? 300 ?
labelFogOfWar.registerGraphicComponent(containerName,"labelFogOfWar");
labelFogOfWar.init(xoffset+150, aHeadPos, 80);
labelFogOfWar.setText(lang.get("FogOfWar"));
listBoxFogOfWar.registerGraphicComponent(containerName,"listBoxFogOfWar");
listBoxFogOfWar.init(xoffset+150, aPos, 80);
listBoxFogOfWar.pushBackItem(lang.get("Yes"));
listBoxFogOfWar.pushBackItem(lang.get("No"));
@ -110,8 +121,11 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
listBoxFogOfWar.setEditable(false);
labelAllowObservers.registerGraphicComponent(containerName,"labelAllowObservers");
labelAllowObservers.init(xoffset+50, aHeadPos, 80);
labelAllowObservers.setText(lang.get("AllowObservers"));
listBoxAllowObservers.registerGraphicComponent(containerName,"listBoxAllowObservers");
listBoxAllowObservers.init(xoffset+50, aPos, 80);
listBoxAllowObservers.pushBackItem(lang.get("No"));
listBoxAllowObservers.pushBackItem(lang.get("Yes"));
@ -120,7 +134,10 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
// Enable Observer Mode
labelEnableObserverMode.registerGraphicComponent(containerName,"labelEnableObserverMode");
labelEnableObserverMode.init(xoffset+250, aHeadPos, 80);
listBoxEnableObserverMode.registerGraphicComponent(containerName,"listBoxEnableObserverMode");
listBoxEnableObserverMode.init(xoffset+250, aPos, 110);
listBoxEnableObserverMode.pushBackItem(lang.get("Yes"));
listBoxEnableObserverMode.pushBackItem(lang.get("No"));
@ -128,8 +145,11 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
listBoxEnableObserverMode.setEditable(false);
labelEnableObserverMode.setText(lang.get("EnableObserverMode"));
labelPathFinderType.registerGraphicComponent(containerName,"labelPathFinderType");
labelPathFinderType.init(xoffset+450, aHeadPos, 80);
labelPathFinderType.setText(lang.get("PathFinderType"));
listBoxPathFinderType.registerGraphicComponent(containerName,"listBoxPathFinderType");
listBoxPathFinderType.init(xoffset+450, aPos, 150);
listBoxPathFinderType.pushBackItem(lang.get("PathFinderTypeRegular"));
listBoxPathFinderType.pushBackItem(lang.get("PathFinderTypeRoutePlanner"));
@ -138,8 +158,11 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
// Network Frame Period
xoffset=0;
labelNetworkFramePeriod.registerGraphicComponent(containerName,"labelNetworkFramePeriod");
labelNetworkFramePeriod.init(xoffset+170, networkHeadPos, 80);
labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod"));
listBoxNetworkFramePeriod.registerGraphicComponent(containerName,"listBoxNetworkFramePeriod");
listBoxNetworkFramePeriod.init(xoffset+170, networkPos, 80);
listBoxNetworkFramePeriod.pushBackItem("10");
listBoxNetworkFramePeriod.pushBackItem("20");
@ -149,8 +172,11 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
listBoxNetworkFramePeriod.setEditable(false);
// Network Frame Period
labelNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"labelNetworkPauseGameForLaggedClients");
labelNetworkPauseGameForLaggedClients.init(xoffset+420, networkHeadPos, 80);
labelNetworkPauseGameForLaggedClients.setText(lang.get("NetworkPauseGameForLaggedClients"));
listBoxNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"listBoxNetworkPauseGameForLaggedClients");
listBoxNetworkPauseGameForLaggedClients.init(xoffset+420, networkPos, 80);
listBoxNetworkPauseGameForLaggedClients.pushBackItem(lang.get("No"));
listBoxNetworkPauseGameForLaggedClients.pushBackItem(lang.get("Yes"));
@ -159,8 +185,11 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
// Enable Server Controlled AI
labelEnableServerControlledAI.registerGraphicComponent(containerName,"labelEnableServerControlledAI");
labelEnableServerControlledAI.init(xoffset+640, networkHeadPos, 80);
labelEnableServerControlledAI.setText(lang.get("EnableServerControlledAI"));
listBoxEnableServerControlledAI.registerGraphicComponent(containerName,"listBoxEnableServerControlledAI");
listBoxEnableServerControlledAI.init(xoffset+640, networkPos, 80);
listBoxEnableServerControlledAI.pushBackItem(lang.get("Yes"));
listBoxEnableServerControlledAI.pushBackItem(lang.get("No"));
@ -171,17 +200,23 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
//map listBox
// put them all in a set, to weed out duplicates (gbm & mgm with same name)
// will also ensure they are alphabetically listed (rather than how the OS provides them)
listBoxMap.registerGraphicComponent(containerName,"listBoxMap");
listBoxMap.init(xoffset+100, mapPos, 200);
listBoxMap.setEditable(false);
labelMap.registerGraphicComponent(containerName,"labelMap");
labelMap.init(xoffset+100, mapHeadPos);
labelMap.setText(lang.get("Map"));
//tileset listBox
//listBoxTileset.init(500, 260, 150);
listBoxTileset.registerGraphicComponent(containerName,"listBoxTileset");
listBoxTileset.init(xoffset+350, mapPos, 150);
listBoxTileset.setEditable(false);
//listBoxTileset.setItems(results);
//labelTileset.init(500, 290);
labelTileset.registerGraphicComponent(containerName,"labelTileset");
labelTileset.init(xoffset+350, mapHeadPos);
labelTileset.setText(lang.get("Tileset"));
@ -191,7 +226,11 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
listBoxTechTree.setEditable(false);
//listBoxTechTree.setItems(results);
//labelTechTree.init(700, 290);
listBoxTechTree.registerGraphicComponent(containerName,"listBoxTechTree");
listBoxTechTree.init(xoffset+550, mapPos, 150);
labelTechTree.registerGraphicComponent(containerName,"labelTechTree");
labelTechTree.init(xoffset+550, mapHeadPos);
labelTechTree.setText(lang.get("TechTree"));
@ -201,27 +240,42 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
xoffset=120;
int rowHeight=27;
for(int i=0; i<GameConstants::maxPlayers; ++i){
labelPlayers[i].registerGraphicComponent(containerName,"labelPlayers" + intToStr(i));
labelPlayers[i].init(xoffset+50, setupPos-30-i*rowHeight);
labelPlayers[i].setEditable(false);
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
labelPlayerNames[i].init(xoffset+100,setupPos-30-i*rowHeight);
listBoxControls[i].registerGraphicComponent(containerName,"listBoxControls" + intToStr(i));
listBoxControls[i].init(xoffset+200, setupPos-30-i*rowHeight);
listBoxControls[i].setEditable(false);
listBoxFactions[i].registerGraphicComponent(containerName,"listBoxFactions" + intToStr(i));
listBoxFactions[i].init(xoffset+350, setupPos-30-i*rowHeight);
listBoxFactions[i].setEditable(false);
listBoxTeams[i].registerGraphicComponent(containerName,"listBoxTeams" + intToStr(i));
listBoxTeams[i].init(xoffset+520, setupPos-30-i*rowHeight, 60);
listBoxTeams[i].setEditable(false);
labelNetStatus[i].registerGraphicComponent(containerName,"labelNetStatus" + intToStr(i));
labelNetStatus[i].init(xoffset+600, setupPos-30-i*rowHeight, 60);
grabSlotButton[i].registerGraphicComponent(containerName,"grabSlotButton" + intToStr(i));
grabSlotButton[i].init(xoffset+600, setupPos-30-i*rowHeight, 30);
grabSlotButton[i].setText(">");
}
labelControl.registerGraphicComponent(containerName,"labelControl");
labelControl.init(xoffset+200, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelControl.setText(lang.get("Control"));
labelFaction.registerGraphicComponent(containerName,"labelFaction");
labelFaction.init(xoffset+350, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.setText(lang.get("Faction"));
labelTeam.registerGraphicComponent(containerName,"labelTeam");
labelTeam.init(xoffset+520, setupPos, 60, GraphicListBox::defH, true);
labelTeam.setText(lang.get("Team"));
@ -266,6 +320,9 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
listBoxControls[0].setSelectedItemIndex(ctHuman);
chatManager.init(&console, -1,true);
GraphicComponent::applyAllCustomProperties(containerName);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
MenuStateConnectedGame::~MenuStateConnectedGame() {

View File

@ -30,8 +30,9 @@ enum JoinMenu{
// class MenuStateConnectedGame
// ===============================
class MenuStateConnectedGame: public MenuState{
class MenuStateConnectedGame: public MenuState {
private:
static const char *containerName;
GraphicButton buttonDisconnect;
GraphicButton buttonPlayNow;
GraphicLabel labelControl;

View File

@ -45,6 +45,8 @@ struct FormatString {
// class MenuStateCustomGame
// =====================================================
const char *MenuStateCustomGame::containerName = "CustomGame";
MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots,bool parentMenuIsMasterserver):
MenuState(program, mainMenu, "new-game")
{
@ -65,6 +67,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
showFullConsole=false;
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
mainMessageBox.init(lang.get("Ok"));
mainMessageBox.setEnabled(false);
mainMessageBoxState=0;
@ -106,8 +109,13 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
vector<string> teamItems, controlItems, results;
//create
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
buttonReturn.init(250, 180, 125);
buttonRestoreLastSettings.registerGraphicComponent(containerName,"buttonRestoreLastSettings");
buttonRestoreLastSettings.init(250+130, 180, 200);
buttonPlayNow.registerGraphicComponent(containerName,"buttonPlayNow");
buttonPlayNow.init(250+130+205, 180, 125);
int labelOffset=23;
@ -148,6 +156,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
formattedPlayerSortedMaps[mapInfo.players].push_back(formatString(mapFiles.at(i)));
}
labelLocalIP.registerGraphicComponent(containerName,"labelLocalIP");
labelLocalIP.init(410, networkHeadPos+labelOffset);
string ipText = "none";
@ -166,15 +175,23 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
// Map
xoffset=70;
labelMap.registerGraphicComponent(containerName,"labelMap");
labelMap.init(xoffset+100, mapHeadPos);
labelMap.setText(lang.get("Map")+":");
listBoxMap.registerGraphicComponent(containerName,"listBoxMap");
listBoxMap.init(xoffset+100, mapPos, 200);
listBoxMap.setItems(formattedPlayerSortedMaps[0]);
labelMapInfo.registerGraphicComponent(containerName,"labelMapInfo");
labelMapInfo.init(xoffset+100, mapPos-labelOffset, 200, 40);
// MapFilter
labelMapFilter.registerGraphicComponent(containerName,"labelMapFilter");
labelMapFilter.init(xoffset+310, mapHeadPos);
labelMapFilter.setText(lang.get("MapFilter")+":");
listBoxMapFilter.registerGraphicComponent(containerName,"listBoxMapFilter");
listBoxMapFilter.init(xoffset+310, mapPos, 80);
listBoxMapFilter.pushBackItem("-");
for(int i=1; i<GameConstants::maxPlayers+1; ++i){
@ -189,8 +206,12 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
}
tilesetFiles= results;
std::for_each(results.begin(), results.end(), FormatString());
listBoxTileset.registerGraphicComponent(containerName,"listBoxTileset");
listBoxTileset.init(xoffset+460, mapPos, 150);
listBoxTileset.setItems(results);
labelTileset.registerGraphicComponent(containerName,"labelTileset");
labelTileset.init(xoffset+460, mapHeadPos);
labelTileset.setText(lang.get("Tileset"));
@ -202,14 +223,21 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
}
techTreeFiles= results;
std::for_each(results.begin(), results.end(), FormatString());
listBoxTechTree.registerGraphicComponent(containerName,"listBoxTechTree");
listBoxTechTree.init(xoffset+650, mapPos, 150);
listBoxTechTree.setItems(results);
labelTechTree.registerGraphicComponent(containerName,"labelTechTree");
labelTechTree.init(xoffset+650, mapHeadPos);
labelTechTree.setText(lang.get("TechTree"));
// Allow Observers
// Allow Observers
labelAllowObservers.registerGraphicComponent(containerName,"labelAllowObservers");
labelAllowObservers.init(xoffset+100, aHeadPos, 80);
labelAllowObservers.setText(lang.get("AllowObservers"));
listBoxAllowObservers.registerGraphicComponent(containerName,"listBoxAllowObservers");
listBoxAllowObservers.init(xoffset+100, aPos, 80);
listBoxAllowObservers.pushBackItem(lang.get("No"));
listBoxAllowObservers.pushBackItem(lang.get("Yes"));
@ -217,31 +245,43 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
// fog - o - war
// @350 ? 300 ?
labelFogOfWar.registerGraphicComponent(containerName,"labelFogOfWar");
labelFogOfWar.init(xoffset+310, aHeadPos, 80);
labelFogOfWar.setText(lang.get("FogOfWar"));
listBoxFogOfWar.registerGraphicComponent(containerName,"listBoxFogOfWar");
listBoxFogOfWar.init(xoffset+310, aPos, 80);
listBoxFogOfWar.pushBackItem(lang.get("Yes"));
listBoxFogOfWar.pushBackItem(lang.get("No"));
listBoxFogOfWar.setSelectedItemIndex(0);
// View Map At End Of Game
labelEnableObserverMode.registerGraphicComponent(containerName,"labelEnableObserverMode");
labelEnableObserverMode.init(xoffset+460, aHeadPos, 80);
listBoxEnableObserverMode.registerGraphicComponent(containerName,"listBoxEnableObserverMode");
listBoxEnableObserverMode.init(xoffset+460, aPos, 80);
listBoxEnableObserverMode.pushBackItem(lang.get("Yes"));
listBoxEnableObserverMode.pushBackItem(lang.get("No"));
listBoxEnableObserverMode.setSelectedItemIndex(0);
// Which Pathfinder
labelPathFinderType.registerGraphicComponent(containerName,"labelPathFinderType");
labelPathFinderType.init(xoffset+650, aHeadPos, 80);
labelPathFinderType.setText(lang.get("PathFinderType"));
listBoxPathFinderType.registerGraphicComponent(containerName,"listBoxPathFinderType");
listBoxPathFinderType.init(xoffset+650, aPos, 150);
listBoxPathFinderType.pushBackItem(lang.get("PathFinderTypeRegular"));
listBoxPathFinderType.pushBackItem(lang.get("PathFinderTypeRoutePlanner"));
listBoxPathFinderType.setSelectedItemIndex(0);
// Advanced Options
labelAdvanced.registerGraphicComponent(containerName,"labelAdvanced");
labelAdvanced.init(810, 80, 80);
labelAdvanced.setText(lang.get("AdvancedGameOptions"));
listBoxAdvanced.registerGraphicComponent(containerName,"listBoxAdvanced");
listBoxAdvanced.init(810, 80-labelOffset, 80);
listBoxAdvanced.pushBackItem(lang.get("No"));
listBoxAdvanced.pushBackItem(lang.get("Yes"));
@ -253,8 +293,12 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
xoffset=0;
else
xoffset=90;
labelPublishServer.registerGraphicComponent(containerName,"labelPublishServer");
labelPublishServer.init(xoffset+50, networkHeadPos, 100);
labelPublishServer.setText(lang.get("PublishServer"));
listBoxPublishServer.registerGraphicComponent(containerName,"listBoxPublishServer");
listBoxPublishServer.init(xoffset+50, networkPos, 100);
listBoxPublishServer.pushBackItem(lang.get("Yes"));
listBoxPublishServer.pushBackItem(lang.get("No"));
@ -264,9 +308,11 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
listBoxPublishServer.setSelectedItemIndex(1);
// Port
labelPublishServerExternalPort.registerGraphicComponent(containerName,"labelPublishServerExternalPort");
labelPublishServerExternalPort.init(xoffset+210, networkHeadPos, 150);
labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort"));
listBoxPublishServerExternalPort.registerGraphicComponent(containerName,"listBoxPublishServerExternalPort");
listBoxPublishServerExternalPort.init(xoffset+210, networkPos, 100);
string supportExternalPortList = config.getString("MasterServerExternalPortList",intToStr(GameConstants::serverPort).c_str());
std::vector<std::string> externalPortList;
@ -281,8 +327,11 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
//listBoxPublishServer.setSelectedItemIndex(0);
// Network Frame Period
labelNetworkFramePeriod.registerGraphicComponent(containerName,"labelNetworkFramePeriod");
labelNetworkFramePeriod.init(xoffset+350, networkHeadPos, 80);
labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod"));
listBoxNetworkFramePeriod.registerGraphicComponent(containerName,"listBoxNetworkFramePeriod");
listBoxNetworkFramePeriod.init(xoffset+350, networkPos, 80);
listBoxNetworkFramePeriod.pushBackItem("10");
listBoxNetworkFramePeriod.pushBackItem("20");
@ -291,8 +340,11 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
listBoxNetworkFramePeriod.setSelectedItem("20");
// Network Frame Period
labelNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"labelNetworkPauseGameForLaggedClients");
labelNetworkPauseGameForLaggedClients.init(xoffset+520, networkHeadPos, 80);
labelNetworkPauseGameForLaggedClients.setText(lang.get("NetworkPauseGameForLaggedClients"));
listBoxNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"listBoxNetworkPauseGameForLaggedClients");
listBoxNetworkPauseGameForLaggedClients.init(xoffset+520, networkPos, 80);
listBoxNetworkPauseGameForLaggedClients.pushBackItem(lang.get("No"));
listBoxNetworkPauseGameForLaggedClients.pushBackItem(lang.get("Yes"));
@ -300,8 +352,11 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
// Enable Server Controlled AI
labelEnableServerControlledAI.registerGraphicComponent(containerName,"labelEnableServerControlledAI");
labelEnableServerControlledAI.init(xoffset+670, networkHeadPos, 80);
labelEnableServerControlledAI.setText(lang.get("EnableServerControlledAI"));
listBoxEnableServerControlledAI.registerGraphicComponent(containerName,"listBoxEnableServerControlledAI");
listBoxEnableServerControlledAI.init(xoffset+670, networkPos, 80);
listBoxEnableServerControlledAI.pushBackItem(lang.get("Yes"));
listBoxEnableServerControlledAI.pushBackItem(lang.get("No"));
@ -311,20 +366,34 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
xoffset=120;
int rowHeight=27;
for(int i=0; i<GameConstants::maxPlayers; ++i){
labelPlayers[i].registerGraphicComponent(containerName,"labelPlayers" + intToStr(i));
labelPlayers[i].init(xoffset+50, setupPos-30-i*rowHeight);
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
labelPlayerNames[i].init(xoffset+100,setupPos-30-i*rowHeight);
listBoxControls[i].registerGraphicComponent(containerName,"listBoxControls" + intToStr(i));
listBoxControls[i].init(xoffset+200, setupPos-30-i*rowHeight);
listBoxFactions[i].registerGraphicComponent(containerName,"listBoxFactions" + intToStr(i));
listBoxFactions[i].init(xoffset+350, setupPos-30-i*rowHeight, 150);
listBoxTeams[i].registerGraphicComponent(containerName,"listBoxTeams" + intToStr(i));
listBoxTeams[i].init(xoffset+520, setupPos-30-i*rowHeight, 60);
labelNetStatus[i].registerGraphicComponent(containerName,"labelNetStatus" + intToStr(i));
labelNetStatus[i].init(xoffset+600, setupPos-30-i*rowHeight, 60);
}
labelControl.registerGraphicComponent(containerName,"labelControl");
labelControl.init(xoffset+200, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelControl.setText(lang.get("Control"));
labelFaction.registerGraphicComponent(containerName,"labelFaction");
labelFaction.init(xoffset+350, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.setText(lang.get("Faction"));
labelTeam.registerGraphicComponent(containerName,"labelTeam");
labelTeam.init(xoffset+520, setupPos, 50, GraphicListBox::defH, true);
labelTeam.setText(lang.get("Team"));
@ -423,6 +492,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
//chatManager.init(&console, world.getThisTeamIndex());
chatManager.init(&console, -1,true);
GraphicComponent::applyAllCustomProperties(containerName);
publishToMasterserverThread = new SimpleTaskThread(this,0,25);
publishToMasterserverThread->setUniqueID(__FILE__);
publishToMasterserverThread->start();

View File

@ -24,6 +24,9 @@ namespace Glest{ namespace Game{
class MenuStateCustomGame : public MenuState, public SimpleTaskCallbackInterface {
private:
static const char *containerName;
GraphicButton buttonReturn;
GraphicButton buttonPlayNow;
GraphicButton buttonRestoreLastSettings;