- updated menus to allow dynamic UI placement via ini settings
This commit is contained in:
parent
d806e7f9ff
commit
7f9c9cde28
|
@ -69,7 +69,6 @@ GraphicComponent * GraphicComponent::findRegisteredComponent(std::string contain
|
|||
}
|
||||
|
||||
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();
|
||||
|
@ -87,19 +86,30 @@ void GraphicComponent::applyCustomProperties(std::string containerName) {
|
|||
if(iterFind2 != iterFind1->second.end()) {
|
||||
Config &config = Config::getInstance();
|
||||
|
||||
string languageToken = config.getString("Lang");
|
||||
|
||||
//if(dynamic_cast<GraphicButton *>(iterFind2->second) != NULL) {
|
||||
GraphicComponent *ctl = dynamic_cast<GraphicComponent *>(iterFind2->second);
|
||||
|
||||
// First check default overrides
|
||||
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());
|
||||
|
||||
// Now check language specific overrides
|
||||
ctl->x = config.getInt(containerName + "_" + iterFind2->first + "_x_" + languageToken, intToStr(ctl->x).c_str());
|
||||
ctl->y = config.getInt(containerName + "_" + iterFind2->first + "_y_" + languageToken, intToStr(ctl->y).c_str());
|
||||
ctl->w = config.getInt(containerName + "_" + iterFind2->first + "_w_" + languageToken, intToStr(ctl->w).c_str());
|
||||
ctl->h = config.getInt(containerName + "_" + iterFind2->first + "_h_" + languageToken, intToStr(ctl->h).c_str());
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicComponent::init(int x, int y, int w, int h){
|
||||
void GraphicComponent::init(int x, int y, int w, int h) {
|
||||
this->x= x;
|
||||
this->y= y;
|
||||
this->w= w;
|
||||
|
|
|
@ -231,4 +231,12 @@ MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateNa
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
MenuState::~MenuState() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
GraphicComponent::clearRegisteredComponents();
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -121,7 +121,7 @@ protected:
|
|||
|
||||
public:
|
||||
MenuState(Program *program, MainMenu *mainMenu, const string &stateName);
|
||||
virtual ~MenuState(){};
|
||||
virtual ~MenuState();
|
||||
virtual void mouseClick(int x, int y, MouseButton mouseButton)=0;
|
||||
virtual void mouseMove(int x, int y, const MouseState *mouseState)=0;
|
||||
virtual void render()=0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Martiño Figueroa
|
||||
// Copyright (C) 2001-2005 MartiC1o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -25,27 +25,34 @@ namespace Glest{ namespace Game{
|
|||
// class MenuStateAbout
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateAbout::containerName = "About";
|
||||
|
||||
MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "about")
|
||||
{
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
//init
|
||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||
buttonReturn.init(460, 100, 125);
|
||||
buttonReturn.setText(lang.get("Return"));
|
||||
|
||||
for(int i= 0; i<aboutStringCount1; ++i){
|
||||
labelAbout1[i].registerGraphicComponent(containerName,"labelAbout1" + intToStr(i));
|
||||
labelAbout1[i].init(100, 650-i*20);
|
||||
labelAbout1[i].setText(getAboutString1(i));
|
||||
}
|
||||
|
||||
for(int i= 0; i<aboutStringCount2; ++i){
|
||||
labelAbout2[i].registerGraphicComponent(containerName,"labelAbout2" + intToStr(i));
|
||||
labelAbout2[i].init(460, 650-i*20);
|
||||
labelAbout2[i].setText(getAboutString2(i));
|
||||
}
|
||||
|
||||
for(int i= 0; i<teammateCount; ++i){
|
||||
labelTeammateName[i].registerGraphicComponent(containerName,"labelTeammateName" + intToStr(i));
|
||||
labelTeammateName[i].init(100+i*180, 500);
|
||||
labelTeammateRole[i].registerGraphicComponent(containerName,"labelTeammateRole" + intToStr(i));
|
||||
labelTeammateRole[i].init(100+i*180, 520);
|
||||
labelTeammateName[i].setText(getTeammateName(i));
|
||||
labelTeammateRole[i].setText(getTeammateRole(i));
|
||||
|
@ -59,6 +66,8 @@ MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu):
|
|||
labelTeammateRole[7].init(566, 180);
|
||||
labelTeammateName[8].init(800, 160);
|
||||
labelTeammateRole[8].init(800, 180);
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
}
|
||||
|
||||
void MenuStateAbout::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Glest{ namespace Game{
|
|||
|
||||
class MenuStateAbout: public MenuState{
|
||||
public:
|
||||
static const char *containerName;
|
||||
static const int aboutStringCount1= 3;
|
||||
static const int aboutStringCount2= 3;
|
||||
static const int teammateCount= 9;
|
||||
|
|
|
@ -24,14 +24,23 @@ namespace Glest{ namespace Game{
|
|||
// class MenuStateGraphicInfo
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateGraphicInfo::containerName = "GraphicInfo";
|
||||
|
||||
MenuStateGraphicInfo::MenuStateGraphicInfo(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "info")
|
||||
{
|
||||
buttonReturn.init(387, 100, 125);
|
||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||
buttonReturn.init(387, 70, 125);
|
||||
|
||||
labelInfo.registerGraphicComponent(containerName,"labelInfo");
|
||||
labelInfo.init(100, 700);
|
||||
|
||||
labelMoreInfo.registerGraphicComponent(containerName,"labelMoreInfo");
|
||||
labelMoreInfo.init(100, 500);
|
||||
labelMoreInfo.setFont(CoreData::getInstance().getDisplayFontSmall());
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
glInfo= renderer.getGlInfo();
|
||||
glMoreInfo= renderer.getGlMoreInfo();
|
||||
|
|
|
@ -21,8 +21,9 @@ namespace Glest{ namespace Game{
|
|||
// class MenuStateGraphicInfo
|
||||
// ===============================
|
||||
|
||||
class MenuStateGraphicInfo: public MenuState{
|
||||
class MenuStateGraphicInfo: public MenuState {
|
||||
private:
|
||||
static const char *containerName;
|
||||
GraphicButton buttonReturn;
|
||||
GraphicLabel labelInfo;
|
||||
GraphicLabel labelMoreInfo;
|
||||
|
|
|
@ -41,6 +41,7 @@ const int MenuStateJoinGame::foundServersIndex= 2;
|
|||
|
||||
const string MenuStateJoinGame::serverFileName= "servers.ini";
|
||||
|
||||
const char *MenuStateJoinGame::containerName = "JoinGame";
|
||||
|
||||
MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool connect, Ip serverIp):
|
||||
MenuState(program, mainMenu, "join-game")
|
||||
|
@ -61,46 +62,57 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
|
|||
servers.load(serversSavedFile);
|
||||
|
||||
//buttons
|
||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||
buttonReturn.init(300, 300, 125);
|
||||
buttonReturn.setText(lang.get("Return"));
|
||||
|
||||
buttonConnect.registerGraphicComponent(containerName,"buttonConnect");
|
||||
buttonConnect.init(450, 300, 125);
|
||||
buttonConnect.setText(lang.get("Connect"));
|
||||
|
||||
buttonAutoFindServers.registerGraphicComponent(containerName,"buttonAutoFindServers");
|
||||
buttonAutoFindServers.init(595, 300, 125);
|
||||
buttonAutoFindServers.setText(lang.get("FindLANGames"));
|
||||
buttonAutoFindServers.setEnabled(true);
|
||||
|
||||
//server type label
|
||||
labelServerType.registerGraphicComponent(containerName,"labelServerType");
|
||||
labelServerType.init(330, 490);
|
||||
labelServerType.setText(lang.get("ServerType") + ":");
|
||||
|
||||
//server type list box
|
||||
listBoxServerType.registerGraphicComponent(containerName,"listBoxServerType");
|
||||
listBoxServerType.init(465, 490);
|
||||
listBoxServerType.pushBackItem(lang.get("ServerTypeNew"));
|
||||
listBoxServerType.pushBackItem(lang.get("ServerTypePrevious"));
|
||||
listBoxServerType.pushBackItem(lang.get("ServerTypeFound"));
|
||||
|
||||
//server label
|
||||
labelServer.registerGraphicComponent(containerName,"labelServer");
|
||||
labelServer.init(330, 460);
|
||||
labelServer.setText(lang.get("Server") + ": ");
|
||||
|
||||
//server listbox
|
||||
listBoxServers.registerGraphicComponent(containerName,"listBoxServers");
|
||||
listBoxServers.init(465, 460);
|
||||
for(int i= 0; i<servers.getPropertyCount(); ++i){
|
||||
listBoxServers.pushBackItem(servers.getKey(i));
|
||||
}
|
||||
|
||||
// found servers listbox
|
||||
listBoxFoundServers.registerGraphicComponent(containerName,"listBoxFoundServers");
|
||||
listBoxFoundServers.init(465, 460);
|
||||
|
||||
//server ip
|
||||
labelServerIp.registerGraphicComponent(containerName,"labelServerIp");
|
||||
labelServerIp.init(465, 460);
|
||||
|
||||
|
||||
// server port
|
||||
labelServerPortLabel.registerGraphicComponent(containerName,"labelServerPortLabel");
|
||||
labelServerPortLabel.init(330,430);
|
||||
labelServerPortLabel.setText(lang.get("ServerPort"));
|
||||
|
||||
labelServerPort.registerGraphicComponent(containerName,"labelServerPort");
|
||||
labelServerPort.init(465,430);
|
||||
string port=intToStr(config.getInt("ServerPort"));
|
||||
if(port!="61357"){
|
||||
|
@ -111,9 +123,11 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
|
|||
}
|
||||
labelServerPort.setText(port);
|
||||
|
||||
labelStatus.registerGraphicComponent(containerName,"labelStatus");
|
||||
labelStatus.init(330, 400);
|
||||
labelStatus.setText("");
|
||||
|
||||
labelInfo.registerGraphicComponent(containerName,"labelInfo");
|
||||
labelInfo.init(330, 370);
|
||||
labelInfo.setText("");
|
||||
|
||||
|
@ -132,6 +146,8 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
|
|||
labelServerIp.setText(config.getString("ServerIp") + "_");
|
||||
}
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
|
||||
chatManager.init(&console, -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ class NetworkMessageIntro;
|
|||
|
||||
class MenuStateJoinGame: public MenuState, public DiscoveredServersInterface {
|
||||
private:
|
||||
static const char *containerName;
|
||||
static const int newServerIndex;
|
||||
static const int newPrevServerIndex;
|
||||
static const int foundServersIndex;
|
||||
|
|
|
@ -31,13 +31,14 @@
|
|||
namespace Glest{ namespace Game{
|
||||
|
||||
DisplayMessageFunction MenuStateMasterserver::pCB_DisplayMessage = NULL;
|
||||
const char *MenuStateMasterserver::containerName = "MasterServer";
|
||||
|
||||
// =====================================================
|
||||
// class ServerLine
|
||||
// =====================================================
|
||||
|
||||
ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex)
|
||||
{
|
||||
ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex) {
|
||||
const char *containerName = MenuStateMasterserver::containerName;
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
index=lineIndex;
|
||||
|
@ -48,53 +49,65 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex)
|
|||
|
||||
//general info:
|
||||
i+=10;
|
||||
glestVersionLabel.registerGraphicComponent(containerName,"glestVersionLabel" + intToStr(lineIndex));
|
||||
glestVersionLabel.init(i,startOffset-lineOffset);
|
||||
glestVersionLabel.setText(masterServerInfo->getGlestVersion());
|
||||
i+=80;
|
||||
platformLabel.registerGraphicComponent(containerName,"platformLabel" + intToStr(lineIndex));
|
||||
platformLabel.init(i,startOffset-lineOffset);
|
||||
platformLabel.setText(masterServerInfo->getPlatform());
|
||||
i+=50;
|
||||
binaryCompileDateLabel.registerGraphicComponent(containerName,"binaryCompileDateLabel" + intToStr(lineIndex));
|
||||
binaryCompileDateLabel.init(i,startOffset-lineOffset);
|
||||
binaryCompileDateLabel.setText(masterServerInfo->getBinaryCompileDate());
|
||||
|
||||
//game info:
|
||||
i+=130;
|
||||
serverTitleLabel.registerGraphicComponent(containerName,"serverTitleLabel" + intToStr(lineIndex));
|
||||
serverTitleLabel.init(i,startOffset-lineOffset);
|
||||
serverTitleLabel.setText(masterServerInfo->getServerTitle());
|
||||
|
||||
i+=160;
|
||||
ipAddressLabel.registerGraphicComponent(containerName,"ipAddressLabel" + intToStr(lineIndex));
|
||||
ipAddressLabel.init(i,startOffset-lineOffset);
|
||||
ipAddressLabel.setText(masterServerInfo->getIpAddress());
|
||||
|
||||
//game setup info:
|
||||
i+=100;
|
||||
techLabel.registerGraphicComponent(containerName,"techLabel" + intToStr(lineIndex));
|
||||
techLabel.init(i,startOffset-lineOffset);
|
||||
techLabel.setText(masterServerInfo->getTech());
|
||||
|
||||
i+=100;
|
||||
mapLabel.registerGraphicComponent(containerName,"mapLabel" + intToStr(lineIndex));
|
||||
mapLabel.init(i,startOffset-lineOffset);
|
||||
mapLabel.setText(masterServerInfo->getMap());
|
||||
|
||||
i+=100;
|
||||
tilesetLabel.registerGraphicComponent(containerName,"tilesetLabel" + intToStr(lineIndex));
|
||||
tilesetLabel.init(i,startOffset-lineOffset);
|
||||
tilesetLabel.setText(masterServerInfo->getTileset());
|
||||
|
||||
i+=100;
|
||||
activeSlotsLabel.registerGraphicComponent(containerName,"activeSlotsLabel" + intToStr(lineIndex));
|
||||
activeSlotsLabel.init(i,startOffset-lineOffset);
|
||||
activeSlotsLabel.setText(intToStr(masterServerInfo->getActiveSlots())+"/"+intToStr(masterServerInfo->getNetworkSlots())+"/"+intToStr(masterServerInfo->getConnectedClients()));
|
||||
|
||||
i+=50;
|
||||
externalConnectPort.registerGraphicComponent(containerName,"externalConnectPort" + intToStr(lineIndex));
|
||||
externalConnectPort.init(i,startOffset-lineOffset);
|
||||
externalConnectPort.setText(intToStr(masterServerInfo->getExternalConnectPort()));
|
||||
|
||||
i+=50;
|
||||
selectButton.registerGraphicComponent(containerName,"selectButton" + intToStr(lineIndex));
|
||||
selectButton.init(i, startOffset-lineOffset, 30);
|
||||
selectButton.setText(">");
|
||||
if(glestVersionString!=masterServerInfo->getGlestVersion())
|
||||
{
|
||||
if(glestVersionString!=masterServerInfo->getGlestVersion()) {
|
||||
selectButton.setEnabled(false);
|
||||
selectButton.setEditable(false);
|
||||
}
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
}
|
||||
|
||||
ServerLine::~ServerLine(){
|
||||
|
@ -128,7 +141,6 @@ void ServerLine::render(){
|
|||
renderer.renderLabel(&tilesetLabel);
|
||||
renderer.renderLabel(&activeSlotsLabel);
|
||||
renderer.renderLabel(&externalConnectPort);
|
||||
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
|
@ -144,7 +156,8 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
|
||||
autoRefreshTime=0;
|
||||
playServerFoundSound=false;
|
||||
|
||||
|
||||
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||
mainMessageBox.init(lang.get("Ok"));
|
||||
mainMessageBox.setEnabled(false);
|
||||
mainMessageBoxState=0;
|
||||
|
@ -153,6 +166,7 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
|
||||
|
||||
// header
|
||||
labelTitle.registerGraphicComponent(containerName,"labelTitle");
|
||||
labelTitle.init(330, 700);
|
||||
labelTitle.setText(lang.get("AvailableServers"));
|
||||
|
||||
|
@ -163,19 +177,29 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
// bottom
|
||||
int buttonPos=130;
|
||||
|
||||
labelChatUrl.registerGraphicComponent(containerName,"labelChatUrl");
|
||||
labelChatUrl.init(150,buttonPos-50);
|
||||
labelChatUrl.setFont(CoreData::getInstance().getMenuFontBig());
|
||||
labelChatUrl.setText(lang.get("NoServerVisitChat")+": http://webchat.freenode.net/?channels=glest");
|
||||
|
||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||
buttonReturn.init(50, buttonPos, 150);
|
||||
|
||||
buttonCreateGame.registerGraphicComponent(containerName,"buttonCreateGame");
|
||||
buttonCreateGame.init(300, buttonPos, 150);
|
||||
|
||||
buttonRefresh.registerGraphicComponent(containerName,"buttonRefresh");
|
||||
buttonRefresh.init(550, buttonPos, 150);
|
||||
|
||||
buttonRefresh.setText(lang.get("RefreshList"));
|
||||
buttonReturn.setText(lang.get("Return"));
|
||||
buttonCreateGame.setText(lang.get("CustomGame"));
|
||||
labelAutoRefresh.setText(lang.get("AutoRefreshRate"));
|
||||
|
||||
labelAutoRefresh.registerGraphicComponent(containerName,"labelAutoRefresh");
|
||||
labelAutoRefresh.init(800,buttonPos+30);
|
||||
|
||||
listBoxAutoRefresh.registerGraphicComponent(containerName,"listBoxAutoRefresh");
|
||||
listBoxAutoRefresh.init(800,buttonPos);
|
||||
listBoxAutoRefresh.pushBackItem(lang.get("Off"));
|
||||
listBoxAutoRefresh.pushBackItem("10 s");
|
||||
|
@ -194,6 +218,8 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
console.addLine(lang.get("To switch off music press")+" - \""+configKeys.getCharKey("ToggleMusic")+"\"");
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
|
||||
needUpdateFromServer = true;
|
||||
updateFromMasterserverThread = new SimpleTaskThread(this,0,100);
|
||||
updateFromMasterserverThread->setUniqueID(__FILE__);
|
||||
|
|
|
@ -70,7 +70,11 @@ typedef vector<ServerLine*> ServerLines;
|
|||
typedef vector<MasterServerInfo*> MasterServerInfos;
|
||||
|
||||
class MenuStateMasterserver : public MenuState, public SimpleTaskCallbackInterface {
|
||||
public:
|
||||
static const char *containerName;
|
||||
|
||||
private:
|
||||
|
||||
GraphicButton buttonRefresh;
|
||||
GraphicButton buttonReturn;
|
||||
GraphicButton buttonCreateGame;
|
||||
|
|
|
@ -32,14 +32,20 @@ namespace Glest{ namespace Game{
|
|||
// class MenuStateNewGame
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateNewGame::containerName = "NewGame";
|
||||
|
||||
MenuStateNewGame::MenuStateNewGame(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "root")
|
||||
{
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
buttonCustomGame.registerGraphicComponent(containerName,"buttonCustomGame");
|
||||
buttonCustomGame.init(425, 350, 150);
|
||||
buttonScenario.registerGraphicComponent(containerName,"buttonScenario");
|
||||
buttonScenario.init(425, 310, 150);
|
||||
buttonTutorial.registerGraphicComponent(containerName,"buttonTutorial");
|
||||
buttonTutorial.init(425, 270, 150);
|
||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||
buttonReturn.init(425, 230, 150);
|
||||
|
||||
buttonCustomGame.setText(lang.get("CustomGame"));
|
||||
|
@ -47,6 +53,8 @@ MenuStateNewGame::MenuStateNewGame(Program *program, MainMenu *mainMenu):
|
|||
buttonTutorial.setText(lang.get("Tutorial"));
|
||||
buttonReturn.setText(lang.get("Return"));
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
|
||||
NetworkManager::getInstance().end();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Glest{ namespace Game{
|
|||
|
||||
class MenuStateNewGame: public MenuState{
|
||||
private:
|
||||
static const char *containerName;
|
||||
GraphicButton buttonCustomGame;
|
||||
GraphicButton buttonScenario;
|
||||
GraphicButton buttonTutorial;
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace Glest{ namespace Game{
|
|||
// =====================================================
|
||||
// class MenuStateOptions
|
||||
// =====================================================
|
||||
const char *MenuStateOptions::containerName = "Options";
|
||||
|
||||
MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "config")
|
||||
|
@ -47,18 +48,23 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
int buttonRowPos=80;
|
||||
int captionOffset=75;
|
||||
|
||||
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||
mainMessageBox.init(lang.get("Ok"));
|
||||
mainMessageBox.setEnabled(false);
|
||||
mainMessageBoxState=0;
|
||||
|
||||
labelAudioSection.registerGraphicComponent(containerName,"labelAudioSection");
|
||||
labelAudioSection.init(leftLabelStart+captionOffset, leftline);
|
||||
labelAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||
labelAudioSection.setText(lang.get("Audio"));
|
||||
leftline-=30;
|
||||
|
||||
//soundboxes
|
||||
labelSoundFactory.registerGraphicComponent(containerName,"labelSoundFactory");
|
||||
labelSoundFactory.init(leftLabelStart, leftline);
|
||||
labelSoundFactory.setText(lang.get("SoundAndMusic"));
|
||||
|
||||
listBoxSoundFactory.registerGraphicComponent(containerName,"listBoxSoundFactory");
|
||||
listBoxSoundFactory.init(leftColumnStart, leftline, 80);
|
||||
listBoxSoundFactory.pushBackItem("None");
|
||||
listBoxSoundFactory.pushBackItem("OpenAL");
|
||||
|
@ -69,17 +75,26 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
listBoxSoundFactory.setSelectedItem(config.getString("FactorySound"));
|
||||
leftline-=30;
|
||||
|
||||
labelVolumeFx.registerGraphicComponent(containerName,"labelVolumeFx");
|
||||
labelVolumeFx.init(leftLabelStart, leftline);
|
||||
labelVolumeFx.setText(lang.get("FxVolume"));
|
||||
|
||||
listBoxVolumeFx.registerGraphicComponent(containerName,"listBoxVolumeFx");
|
||||
listBoxVolumeFx.init(leftColumnStart, leftline, 80);
|
||||
leftline-=30;
|
||||
|
||||
labelVolumeAmbient.registerGraphicComponent(containerName,"labelVolumeAmbient");
|
||||
labelVolumeAmbient.init(leftLabelStart, leftline);
|
||||
|
||||
listBoxVolumeAmbient.registerGraphicComponent(containerName,"listBoxVolumeAmbient");
|
||||
listBoxVolumeAmbient.init(leftColumnStart, leftline, 80);
|
||||
labelVolumeAmbient.setText(lang.get("AmbientVolume"));
|
||||
leftline-=30;
|
||||
|
||||
labelVolumeMusic.registerGraphicComponent(containerName,"labelVolumeMusic");
|
||||
labelVolumeMusic.init(leftLabelStart, leftline);
|
||||
|
||||
listBoxVolumeMusic.registerGraphicComponent(containerName,"listBoxVolumeMusic");
|
||||
listBoxVolumeMusic.init(leftColumnStart, leftline, 80);
|
||||
labelVolumeMusic.setText(lang.get("MusicVolume"));
|
||||
leftline-=30;
|
||||
|
@ -95,14 +110,18 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
|
||||
|
||||
leftline-=30;
|
||||
labelMiscSection.registerGraphicComponent(containerName,"labelMiscSection");
|
||||
labelMiscSection.init(leftLabelStart+captionOffset, leftline);
|
||||
labelMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||
labelMiscSection.setText(lang.get("Misc"));
|
||||
leftline-=30;
|
||||
|
||||
//lang
|
||||
labelLang.registerGraphicComponent(containerName,"labelLang");
|
||||
labelLang.init(leftLabelStart, leftline);
|
||||
labelLang.setText(lang.get("Language"));
|
||||
|
||||
listBoxLang.registerGraphicComponent(containerName,"listBoxLang");
|
||||
listBoxLang.init(leftColumnStart, leftline, 170);
|
||||
vector<string> langResults;
|
||||
findAll("data/lang/*.lng", langResults, true);
|
||||
|
@ -114,17 +133,21 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
leftline-=30;
|
||||
|
||||
//playerName
|
||||
labelPlayerNameLabel.registerGraphicComponent(containerName,"labelPlayerNameLabel");
|
||||
labelPlayerNameLabel.init(leftLabelStart,leftline);
|
||||
labelPlayerNameLabel.setText(lang.get("Playername"));
|
||||
|
||||
labelPlayerName.registerGraphicComponent(containerName,"labelPlayerName");
|
||||
labelPlayerName.init(leftColumnStart,leftline);
|
||||
labelPlayerName.setText(config.getString("NetPlayerName",Socket::getHostName().c_str()));
|
||||
leftline-=30;
|
||||
|
||||
//FontSizeAdjustment
|
||||
labelFontSizeAdjustment.registerGraphicComponent(containerName,"labelFontSizeAdjustment");
|
||||
labelFontSizeAdjustment.init(leftLabelStart,leftline);
|
||||
labelFontSizeAdjustment.setText(lang.get("FontSizeAdjustment"));
|
||||
|
||||
listFontSizeAdjustment.registerGraphicComponent(containerName,"listFontSizeAdjustment");
|
||||
listFontSizeAdjustment.init(leftColumnStart, leftline, 80);
|
||||
for(int i=-5; i<=5; i+=1){
|
||||
listFontSizeAdjustment.pushBackItem(intToStr(i));
|
||||
|
@ -133,6 +156,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
|
||||
leftline-=30;
|
||||
// server port
|
||||
labelServerPortLabel.registerGraphicComponent(containerName,"labelServerPortLabel");
|
||||
labelServerPortLabel.init(leftLabelStart,leftline);
|
||||
labelServerPortLabel.setText(lang.get("ServerPort"));
|
||||
labelServerPort.init(leftColumnStart,leftline);
|
||||
|
@ -147,14 +171,18 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
labelServerPort.setText(port);
|
||||
|
||||
leftline-=30;
|
||||
labelVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
|
||||
labelVideoSection.init(leftLabelStart+captionOffset, leftline);
|
||||
labelVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||
labelVideoSection.setText(lang.get("Video"));
|
||||
leftline-=30;
|
||||
|
||||
//resolution
|
||||
labelScreenModes.registerGraphicComponent(containerName,"labelScreenModes");
|
||||
labelScreenModes.init(leftLabelStart, leftline);
|
||||
labelScreenModes.setText(lang.get("Resolution"));
|
||||
|
||||
listBoxScreenModes.registerGraphicComponent(containerName,"listBoxScreenModes");
|
||||
listBoxScreenModes.init(leftColumnStart, leftline, 170);
|
||||
|
||||
string currentResString = config.getString("ScreenWidth") + "x" +
|
||||
|
@ -175,7 +203,10 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
|
||||
|
||||
//FullscreenWindowed
|
||||
labelFullscreenWindowed.registerGraphicComponent(containerName,"labelFullscreenWindowed");
|
||||
labelFullscreenWindowed.init(leftLabelStart, leftline);
|
||||
|
||||
listBoxFullscreenWindowed.registerGraphicComponent(containerName,"listBoxFullscreenWindowed");
|
||||
listBoxFullscreenWindowed.init(leftColumnStart, leftline, 80);
|
||||
labelFullscreenWindowed.setText(lang.get("Windowed"));
|
||||
listBoxFullscreenWindowed.pushBackItem(lang.get("No"));
|
||||
|
@ -184,8 +215,11 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
leftline-=30;
|
||||
|
||||
//filter
|
||||
labelFilter.registerGraphicComponent(containerName,"labelFilter");
|
||||
labelFilter.init(leftLabelStart, leftline);
|
||||
labelFilter.setText(lang.get("Filter"));
|
||||
|
||||
listBoxFilter.registerGraphicComponent(containerName,"listBoxFilter");
|
||||
listBoxFilter.init(leftColumnStart, leftline, 170);
|
||||
listBoxFilter.pushBackItem("Bilinear");
|
||||
listBoxFilter.pushBackItem("Trilinear");
|
||||
|
@ -193,8 +227,11 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
leftline-=30;
|
||||
|
||||
//shadows
|
||||
labelShadows.registerGraphicComponent(containerName,"labelShadows");
|
||||
labelShadows.init(leftLabelStart, leftline);
|
||||
labelShadows.setText(lang.get("Shadows"));
|
||||
|
||||
listBoxShadows.registerGraphicComponent(containerName,"listBoxShadows");
|
||||
listBoxShadows.init(leftColumnStart, leftline, 170);
|
||||
for(int i= 0; i<Renderer::sCount; ++i){
|
||||
listBoxShadows.pushBackItem(lang.get(Renderer::shadowsToStr(static_cast<Renderer::Shadows>(i))));
|
||||
|
@ -204,7 +241,10 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
leftline-=30;
|
||||
|
||||
//textures 3d
|
||||
labelTextures3D.registerGraphicComponent(containerName,"labelTextures3D");
|
||||
labelTextures3D.init(leftLabelStart, leftline);
|
||||
|
||||
listBoxTextures3D.registerGraphicComponent(containerName,"listBoxTextures3D");
|
||||
listBoxTextures3D.init(leftColumnStart, leftline, 80);
|
||||
labelTextures3D.setText(lang.get("Textures3D"));
|
||||
listBoxTextures3D.pushBackItem(lang.get("No"));
|
||||
|
@ -213,8 +253,11 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
leftline-=30;
|
||||
|
||||
//lights
|
||||
labelLights.registerGraphicComponent(containerName,"labelLights");
|
||||
labelLights.init(leftLabelStart, leftline);
|
||||
labelLights.setText(lang.get("MaxLights"));
|
||||
|
||||
listBoxLights.registerGraphicComponent(containerName,"listBoxLights");
|
||||
listBoxLights.init(leftColumnStart, leftline, 80);
|
||||
for(int i= 1; i<=8; ++i){
|
||||
listBoxLights.pushBackItem(intToStr(i));
|
||||
|
@ -223,8 +266,11 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
leftline-=30;
|
||||
|
||||
//unit particles
|
||||
labelUnitParticles.registerGraphicComponent(containerName,"labelUnitParticles");
|
||||
labelUnitParticles.init(leftLabelStart,leftline);
|
||||
labelUnitParticles.setText(lang.get("ShowUnitParticles"));
|
||||
|
||||
listBoxUnitParticles.registerGraphicComponent(containerName,"listBoxUnitParticles");
|
||||
listBoxUnitParticles.init(leftColumnStart,leftline,80);
|
||||
listBoxUnitParticles.pushBackItem(lang.get("No"));
|
||||
listBoxUnitParticles.pushBackItem(lang.get("Yes"));
|
||||
|
@ -232,16 +278,23 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
leftline-=30;
|
||||
|
||||
// buttons
|
||||
buttonOk.registerGraphicComponent(containerName,"buttonOk");
|
||||
buttonOk.init(200, buttonRowPos, 100);
|
||||
buttonOk.setText(lang.get("Ok"));
|
||||
buttonAbort.setText(lang.get("Abort"));
|
||||
|
||||
buttonAbort.registerGraphicComponent(containerName,"buttonAbort");
|
||||
buttonAbort.init(310, buttonRowPos, 100);
|
||||
buttonAutoConfig.setText(lang.get("AutoConfig"));
|
||||
|
||||
buttonAutoConfig.registerGraphicComponent(containerName,"buttonAutoConfig");
|
||||
buttonAutoConfig.init(450, buttonRowPos, 125);
|
||||
|
||||
buttonVideoInfo.setText(lang.get("VideoInfo"));
|
||||
buttonVideoInfo.registerGraphicComponent(containerName,"buttonVideoInfo");
|
||||
buttonVideoInfo.init(620, buttonRowPos, 100);
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
}
|
||||
|
||||
void MenuStateOptions::showMessageBox(const string &text, const string &header, bool toggle){
|
||||
|
|
|
@ -23,6 +23,8 @@ namespace Glest{ namespace Game{
|
|||
|
||||
class MenuStateOptions: public MenuState{
|
||||
private:
|
||||
static const char *containerName;
|
||||
|
||||
GraphicButton buttonOk;
|
||||
GraphicButton buttonAbort;
|
||||
GraphicButton buttonAutoConfig;
|
||||
|
|
|
@ -34,22 +34,32 @@ namespace Glest{ namespace Game{
|
|||
// class MenuStateRoot
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateRoot::containerName = "MainMenu";
|
||||
|
||||
MenuStateRoot::MenuStateRoot(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "root")
|
||||
{
|
||||
Lang &lang= Lang::getInstance();
|
||||
int i=375;
|
||||
|
||||
buttonNewGame.registerGraphicComponent(containerName,"buttonNewGame");
|
||||
buttonNewGame.init(425, i, 150);
|
||||
i-=40;
|
||||
buttonJoinGame.registerGraphicComponent(containerName,"buttonJoinGame");
|
||||
buttonJoinGame.init(425, i, 150);
|
||||
i-=40;
|
||||
buttonMasterserverGame.registerGraphicComponent(containerName,"buttonMasterserverGame");
|
||||
buttonMasterserverGame.init(425, i, 150);
|
||||
i-=40;
|
||||
buttonOptions.registerGraphicComponent(containerName,"buttonOptions");
|
||||
buttonOptions.init(425, i, 150);
|
||||
i-=40;
|
||||
buttonAbout.registerGraphicComponent(containerName,"buttonAbout");
|
||||
buttonAbout.init(425, i , 150);
|
||||
i-=40;
|
||||
buttonExit.registerGraphicComponent(containerName,"buttonExit");
|
||||
buttonExit.init(425, i, 150);
|
||||
labelVersion.registerGraphicComponent(containerName,"labelVersion");
|
||||
labelVersion.init(525, 420);
|
||||
|
||||
buttonNewGame.setText(lang.get("NewGame"));
|
||||
|
@ -61,9 +71,11 @@ MenuStateRoot::MenuStateRoot(Program *program, MainMenu *mainMenu):
|
|||
labelVersion.setText(glestVersionString);
|
||||
|
||||
//mesage box
|
||||
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||
mainMessageBox.init(lang.get("Yes"), lang.get("No"));
|
||||
mainMessageBox.setEnabled(false);
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
}
|
||||
|
||||
void MenuStateRoot::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
|
@ -126,7 +138,7 @@ void MenuStateRoot::mouseMove(int x, int y, const MouseState *ms){
|
|||
|
||||
}
|
||||
|
||||
void MenuStateRoot::render(){
|
||||
void MenuStateRoot::render() {
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
|
|
@ -25,6 +25,9 @@ class GraphicMessageBox;
|
|||
|
||||
class MenuStateRoot: public MenuState{
|
||||
private:
|
||||
|
||||
static const char *containerName;
|
||||
|
||||
GraphicButton buttonNewGame;
|
||||
GraphicButton buttonJoinGame;
|
||||
GraphicButton buttonMasterserverGame;
|
||||
|
|
Loading…
Reference in New Issue
Block a user