updated menus to display translated tech name
This commit is contained in:
parent
ef32fcdd7b
commit
a8662c8b31
|
@ -9,9 +9,10 @@ export GLIBCPP_FORCE_NEW=1
|
|||
export GLIBCXX_FORCE_NEW=1
|
||||
export G_SLICE=always-malloc
|
||||
|
||||
exec valgrind --num-callers=50 \
|
||||
exec valgrind --num-callers=20 \
|
||||
--leak-check=yes \
|
||||
--leak-resolution=high \
|
||||
--show-reachable=yes \
|
||||
"$@" 2>&1 1>&3 3>&- |
|
||||
sed 's/^==[0-9]*==/==/' >&2 1>&2 3>&-
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ GraphicComponent::GraphicComponent(std::string containerName, std::string objNam
|
|||
text = "";
|
||||
font = NULL;
|
||||
font3D = NULL;
|
||||
textNativeTranslation = "";
|
||||
}
|
||||
|
||||
void GraphicComponent::clearRegisteredComponents(std::string containerName) {
|
||||
|
@ -377,14 +378,28 @@ void GraphicListBox::init(int x, int y, int w, int h, Vec3f textColor){
|
|||
lighted=false;
|
||||
}
|
||||
|
||||
const string & GraphicListBox::getTextNativeTranslation() {
|
||||
if(this->translated_items.size() == 0 ||
|
||||
this->selectedItemIndex < 0 ||
|
||||
this->selectedItemIndex >= this->translated_items.size() ||
|
||||
this->items.size() != this->translated_items.size()) {
|
||||
return this->text;
|
||||
}
|
||||
else {
|
||||
return this->translated_items[this->selectedItemIndex];
|
||||
}
|
||||
}
|
||||
|
||||
//queryes
|
||||
void GraphicListBox::pushBackItem(string item){
|
||||
void GraphicListBox::pushBackItem(string item, string translated_item){
|
||||
items.push_back(item);
|
||||
translated_items.push_back(translated_item);
|
||||
setSelectedItemIndex(0);
|
||||
}
|
||||
|
||||
void GraphicListBox::setItems(const vector<string> &items){
|
||||
void GraphicListBox::setItems(const vector<string> &items, const vector<string> translated_items){
|
||||
this->items= items;
|
||||
this->translated_items = translated_items;
|
||||
if(items.empty() == false) {
|
||||
setSelectedItemIndex(0);
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
protected:
|
||||
int x, y, w, h;
|
||||
string text;
|
||||
string textNativeTranslation;
|
||||
Font2D *font;
|
||||
Font3D *font3D;
|
||||
bool enabled;
|
||||
|
@ -94,6 +95,7 @@ public:
|
|||
virtual int getW() const {return w;}
|
||||
virtual int getH() const {return h;}
|
||||
virtual const string &getText() const {return text;}
|
||||
virtual const string &getTextNativeTranslation() { return this->textNativeTranslation;}
|
||||
virtual Font2D *getFont() {return font;}
|
||||
virtual Font3D *getFont3D() {return font3D;}
|
||||
virtual bool getEnabled() const {return enabled;}
|
||||
|
@ -105,6 +107,7 @@ public:
|
|||
virtual void setW(int w) {this->w= w;}
|
||||
virtual void setH(int h) {this->h= h;}
|
||||
virtual void setText(const string &text) {this->text= text;}
|
||||
virtual void setTextNativeTranslation(const string &text) {this->textNativeTranslation= text;}
|
||||
virtual void setFont(Font2D *font) {this->font= font;}
|
||||
virtual void setFont3D(Font3D *font) {this->font3D= font;}
|
||||
virtual void setEnabled(bool enabled) {this->enabled= enabled;}
|
||||
|
@ -231,6 +234,7 @@ public:
|
|||
private:
|
||||
GraphicButton graphButton1, graphButton2;
|
||||
vector<string> items;
|
||||
vector<string> translated_items;
|
||||
int selectedItemIndex;
|
||||
bool lighted;
|
||||
Vec3f textColor;
|
||||
|
@ -250,8 +254,8 @@ public:
|
|||
Vec3f getTextColor() const {return textColor;}
|
||||
void setTextColor(Vec3f color) {this->textColor= color;}
|
||||
|
||||
void pushBackItem(string item);
|
||||
void setItems(const vector<string> &items);
|
||||
void pushBackItem(string item, string translated_item="");
|
||||
void setItems(const vector<string> &items, const vector<string> translated_items=vector<string>());
|
||||
void setSelectedItemIndex(int index, bool errorOnMissing=true);
|
||||
void setSelectedItem(string item, bool errorOnMissing=true);
|
||||
void setEditable(bool editable);
|
||||
|
@ -263,6 +267,8 @@ public:
|
|||
|
||||
virtual bool mouseMove(int x, int y);
|
||||
virtual bool mouseClick(int x, int y, string advanceToItemStartingWith="");
|
||||
|
||||
virtual const string &getTextNativeTranslation();
|
||||
};
|
||||
|
||||
// ===========================================================
|
||||
|
|
|
@ -307,6 +307,8 @@ Game::Game(Program *program, const GameSettings *gameSettings,bool masterserverM
|
|||
resetMembers();
|
||||
this->gameSettings= *gameSettings;
|
||||
|
||||
Lang::getInstance().setAllowNativeLanguageTechtree(this->gameSettings.getNetworkAllowNativeLanguageTechtree());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
@ -436,6 +438,8 @@ Game::~Game() {
|
|||
|
||||
Unit::setGame(NULL);
|
||||
|
||||
Lang::getInstance().setAllowNativeLanguageTechtree(true);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== END GAME ==== getCurrentPixelByteCount() = %llu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled) SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"==== END GAME ====\n");
|
||||
|
||||
|
|
|
@ -127,6 +127,8 @@ private:
|
|||
|
||||
int masterserver_admin_factionIndex;
|
||||
|
||||
bool networkAllowNativeLanguageTechtree;
|
||||
|
||||
public:
|
||||
|
||||
static string playerDisconnectedText;
|
||||
|
@ -171,6 +173,7 @@ public:
|
|||
masterserver_admin = -1;
|
||||
masterserver_admin_factionIndex = -1;
|
||||
fallbackCpuMultiplier = 1.0f;
|
||||
networkAllowNativeLanguageTechtree = true;
|
||||
}
|
||||
|
||||
// default copy constructor will do fine, and will maintain itself ;)
|
||||
|
@ -480,17 +483,21 @@ public:
|
|||
|
||||
void setFactionCRCList(vector<pair<string,uint32> > value) { factionCRCList = value; }
|
||||
|
||||
int getAiAcceptSwitchTeamPercentChance() const { return aiAcceptSwitchTeamPercentChance;}
|
||||
void setAiAcceptSwitchTeamPercentChance(int value) { aiAcceptSwitchTeamPercentChance = value; }
|
||||
int getAiAcceptSwitchTeamPercentChance() const { return aiAcceptSwitchTeamPercentChance;}
|
||||
void setAiAcceptSwitchTeamPercentChance(int value) { aiAcceptSwitchTeamPercentChance = value; }
|
||||
|
||||
int getFallbackCpuMultiplier() const { return fallbackCpuMultiplier;}
|
||||
void setFallbackCpuMultiplier(int value) { fallbackCpuMultiplier = value; }
|
||||
void setFallbackCpuMultiplier(int value) { fallbackCpuMultiplier = value; }
|
||||
|
||||
int getMasterserver_admin() const { return masterserver_admin;}
|
||||
void setMasterserver_admin(int value) { masterserver_admin = value; }
|
||||
int getMasterserver_admin() const { return masterserver_admin;}
|
||||
void setMasterserver_admin(int value) { masterserver_admin = value; }
|
||||
|
||||
int getMasterserver_admin_faction_index() const { return masterserver_admin_factionIndex;}
|
||||
void setMasterserver_admin_faction_index(int value) { masterserver_admin_factionIndex = value; }
|
||||
int getMasterserver_admin_faction_index() const { return masterserver_admin_factionIndex;}
|
||||
void setMasterserver_admin_faction_index(int value) { masterserver_admin_factionIndex = value; }
|
||||
|
||||
|
||||
bool getNetworkAllowNativeLanguageTechtree() const { return networkAllowNativeLanguageTechtree;}
|
||||
void setNetworkAllowNativeLanguageTechtree(bool value) { networkAllowNativeLanguageTechtree = value; }
|
||||
|
||||
string toString() const {
|
||||
string result = "";
|
||||
|
@ -541,6 +548,7 @@ public:
|
|||
result += "masterserver_admin = " + intToStr(masterserver_admin) + "\n";
|
||||
result += "masterserver_admin_factionIndex = " + intToStr(masterserver_admin_factionIndex) + "\n";
|
||||
|
||||
result += "networkAllowNativeLanguageTechtree = " + intToStr(networkAllowNativeLanguageTechtree) + "\n";
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -669,6 +677,8 @@ public:
|
|||
gameSettingsNode->addAttribute("masterserver_admin",intToStr(masterserver_admin), mapTagReplacements);
|
||||
|
||||
gameSettingsNode->addAttribute("masterserver_admin_factionIndex",intToStr(masterserver_admin_factionIndex), mapTagReplacements);
|
||||
|
||||
gameSettingsNode->addAttribute("networkAllowNativeLanguageTechtree",intToStr(networkAllowNativeLanguageTechtree), mapTagReplacements);
|
||||
}
|
||||
|
||||
void loadGame(const XmlNode *rootNode) {
|
||||
|
@ -805,6 +815,10 @@ public:
|
|||
if(gameSettingsNode->hasAttribute("masterserver_admin_factionIndex") == true) {
|
||||
masterserver_admin_factionIndex = gameSettingsNode->getAttribute("masterserver_admin_factionIndex")->getIntValue();
|
||||
}
|
||||
|
||||
if(gameSettingsNode->hasAttribute("networkAllowNativeLanguageTechtree") == true) {
|
||||
networkAllowNativeLanguageTechtree = gameSettingsNode->getAttribute("networkAllowNativeLanguageTechtree")->getIntValue() != 0;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -1003,6 +1003,8 @@ void CoreData::saveGameSettingsToFile(std::string fileName, GameSettings *gameSe
|
|||
saveGameFile << "FactionThisFactionIndex=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getThisFactionIndex()) << std::endl;
|
||||
saveGameFile << "FactionCount=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getFactionCount()) << std::endl;
|
||||
|
||||
saveGameFile << "NetworkAllowNativeLanguageTechtree=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getNetworkAllowNativeLanguageTechtree()) << std::endl;
|
||||
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
int slotIndex = gameSettings->getStartLocationIndex(i);
|
||||
|
||||
|
@ -1075,6 +1077,13 @@ bool CoreData::loadGameSettingsFromFile(std::string fileName, GameSettings *game
|
|||
gameSettings->setThisFactionIndex(properties.getInt("FactionThisFactionIndex"));
|
||||
gameSettings->setFactionCount(properties.getInt("FactionCount"));
|
||||
|
||||
if(properties.hasString("NetworkAllowNativeLanguageTechtree") == true) {
|
||||
gameSettings->setNetworkAllowNativeLanguageTechtree(properties.getInt("NetworkAllowNativeLanguageTechtree"));
|
||||
}
|
||||
else {
|
||||
gameSettings->setNetworkAllowNativeLanguageTechtree(false);
|
||||
}
|
||||
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
gameSettings->setFactionControl(i,(ControlType)properties.getInt(string("FactionControlForIndex") + intToStr(i),intToStr(ctClosed).c_str()) );
|
||||
|
||||
|
|
|
@ -41,8 +41,10 @@ const char *DEFAULT_LANGUAGE = "english";
|
|||
// =====================================================
|
||||
|
||||
Lang::Lang() {
|
||||
language = "";
|
||||
is_utf8_language = false;
|
||||
language = "";
|
||||
is_utf8_language = false;
|
||||
allowNativeLanguageTechtree = true;
|
||||
techNameLoaded = "";
|
||||
}
|
||||
|
||||
Lang &Lang::getInstance() {
|
||||
|
@ -279,9 +281,14 @@ void Lang::loadScenarioStrings(string scenarioDir, string scenarioName, bool isT
|
|||
}
|
||||
}
|
||||
|
||||
void Lang::loadTechTreeStrings(string techTree) {
|
||||
void Lang::loadTechTreeStrings(string techTree,bool forceLoad) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] techTree = [%s]\n",__FILE__,__FUNCTION__,__LINE__,techTree.c_str());
|
||||
|
||||
printf("Load techtree strings techTree [%s] techNameLoaded [%s] forceLoad: %d\n",techTree.c_str(),techNameLoaded.c_str(),forceLoad);
|
||||
if(forceLoad == false && techTree == techNameLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
string currentPath = "";
|
||||
Config &config = Config::getInstance();
|
||||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||
|
@ -308,7 +315,10 @@ void Lang::loadTechTreeStrings(string techTree) {
|
|||
|
||||
//try to load the current language first
|
||||
if(fileExists(path)) {
|
||||
techTreeStrings.load(path);
|
||||
if(forceLoad == true || path != techTreeStrings.getpath()) {
|
||||
techTreeStrings.load(path);
|
||||
techNameLoaded = techTree;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path not found [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
|
||||
|
@ -318,12 +328,18 @@ void Lang::loadTechTreeStrings(string techTree) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
|
||||
|
||||
if(fileExists(path)) {
|
||||
techTreeStrings.load(path);
|
||||
if(forceLoad == true || path != techTreeStrings.getpath()) {
|
||||
techTreeStrings.load(path);
|
||||
techNameLoaded = techTree;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fileExists(pathDefault)) {
|
||||
techTreeStringsDefault.load(pathDefault);
|
||||
if(forceLoad == true || pathDefault != techTreeStrings.getpath()) {
|
||||
techTreeStringsDefault.load(pathDefault);
|
||||
techNameLoaded = techTree;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -493,7 +509,8 @@ string Lang::getTechTreeString(const string &s,const char *defaultValue) {
|
|||
try{
|
||||
string result = "";
|
||||
|
||||
if(techTreeStrings.hasString(s) == true || defaultValue == NULL) {
|
||||
if(allowNativeLanguageTechtree == true &&
|
||||
(techTreeStrings.hasString(s) == true || defaultValue == NULL)) {
|
||||
if(techTreeStrings.hasString(s) == false && techTreeStringsDefault.hasString(s) == true) {
|
||||
result = techTreeStringsDefault.getString(s);
|
||||
}
|
||||
|
@ -501,7 +518,8 @@ string Lang::getTechTreeString(const string &s,const char *defaultValue) {
|
|||
result = techTreeStrings.getString(s);
|
||||
}
|
||||
}
|
||||
else if(techTreeStringsDefault.hasString(s) == true) {
|
||||
else if(allowNativeLanguageTechtree == true &&
|
||||
techTreeStringsDefault.hasString(s) == true) {
|
||||
result = techTreeStringsDefault.getString(s);
|
||||
}
|
||||
else if(defaultValue != NULL) {
|
||||
|
|
|
@ -44,6 +44,9 @@ private:
|
|||
|
||||
std::map<string,Properties> otherLanguageStrings;
|
||||
|
||||
string techNameLoaded;
|
||||
bool allowNativeLanguageTechtree;
|
||||
|
||||
private:
|
||||
Lang();
|
||||
void loadStrings(string language, Properties &properties, bool fileMustExist,bool fallbackToDefault=false);
|
||||
|
@ -55,9 +58,12 @@ private:
|
|||
public:
|
||||
static Lang &getInstance();
|
||||
|
||||
bool getAllowNativeLanguageTechtree() const { return allowNativeLanguageTechtree; }
|
||||
void setAllowNativeLanguageTechtree(bool value) { allowNativeLanguageTechtree = value; }
|
||||
|
||||
void loadStrings(string uselanguage, bool loadFonts=true, bool fallbackToDefault=false);
|
||||
void loadScenarioStrings(string scenarioDir, string scenarioName, bool isTutorial);
|
||||
void loadTechTreeStrings(string techTree);
|
||||
void loadTechTreeStrings(string techTree, bool forceLoad=false);
|
||||
void loadTilesetStrings(string tileset);
|
||||
|
||||
string get(const string &s,string uselanguage="", bool fallbackToDefault=false);
|
||||
|
|
|
@ -2972,11 +2972,12 @@ void Renderer::renderLabel(GraphicLabel *label,const Vec4f *color) {
|
|||
glEnable(GL_BLEND);
|
||||
|
||||
vector<string> lines;
|
||||
string renderTextString = (label->getTextNativeTranslation() != "" ? label->getTextNativeTranslation() : label->getText());
|
||||
if(label->getWordWrap() == true) {
|
||||
Tokenize(label->getText(),lines,"\n");
|
||||
Tokenize(renderTextString,lines,"\n");
|
||||
}
|
||||
else {
|
||||
lines.push_back(label->getText());
|
||||
lines.push_back(renderTextString);
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < lines.size(); ++i) {
|
||||
|
@ -3475,6 +3476,7 @@ void Renderer::renderListBox(GraphicListBox *listBox) {
|
|||
GraphicLabel label;
|
||||
label.init(listBox->getX(), listBox->getY(), listBox->getW(), listBox->getH(), true,listBox->getTextColor());
|
||||
label.setText(listBox->getText());
|
||||
label.setTextNativeTranslation(listBox->getTextNativeTranslation());
|
||||
label.setFont(listBox->getFont());
|
||||
label.setFont3D(listBox->getFont3D());
|
||||
renderLabel(&label);
|
||||
|
|
|
@ -144,6 +144,9 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
needToLoadTextures=true;
|
||||
this->dirList = Config::getInstance().getPathListForType(ptScenarios);
|
||||
|
||||
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
|
||||
techTree.reset(new TechTree(techtreesList));
|
||||
|
||||
vector<string> teamItems, controlItems, results, rMultiplier, playerStatuses;
|
||||
int labelOffset=23;
|
||||
int setupPos=590;
|
||||
|
@ -424,7 +427,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
//tileset listBox
|
||||
setupTilesetList("");
|
||||
|
||||
int initialTechSelection = setupTechList("");
|
||||
int initialTechSelection = setupTechList("",true);
|
||||
listBoxTechTree.setSelectedItemIndex(initialTechSelection);
|
||||
|
||||
labelScenario.registerGraphicComponent(containerName,"labelScenario");
|
||||
|
@ -502,7 +505,6 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
}
|
||||
|
||||
std::pair<string,string> techtreesPath;
|
||||
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
|
||||
if(techtreesList.empty() == false) {
|
||||
techtreesPath.first = techtreesList[0];
|
||||
if(techtreesList.size() > 1) {
|
||||
|
@ -4016,11 +4018,15 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName,
|
|||
string scenarioDir = Scenario::getScenarioDir(dirList, gameSettings->getScenario());
|
||||
findDirs(Config::getInstance().getPathListForType(ptTechs,scenarioDir), techTreeFiles);
|
||||
|
||||
vector<string> translatedTechs;
|
||||
std::vector<string> techsFormatted = techTreeFiles;
|
||||
for(int i= 0; i < techsFormatted.size(); i++){
|
||||
techsFormatted.at(i)= formatString(techsFormatted.at(i));
|
||||
|
||||
string txTech = techTree->getTranslatedName(techTreeFiles.at(i), true);
|
||||
translatedTechs.push_back(txTech);
|
||||
}
|
||||
listBoxTechTree.setItems(techsFormatted);
|
||||
listBoxTechTree.setItems(techsFormatted,translatedTechs);
|
||||
}
|
||||
else {
|
||||
curl_version_info_data *curlVersion= curl_version_info(CURLVERSION_NOW);
|
||||
|
@ -4332,7 +4338,13 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
|||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
}
|
||||
listBoxTechTree.setItems(techtree);
|
||||
|
||||
vector<string> translatedTechs;
|
||||
for(unsigned int i= 0; i < techTreeFiles.size(); i++) {
|
||||
string txTech = techTree->getTranslatedName(techTreeFiles.at(i));
|
||||
translatedTechs.push_back(txTech);
|
||||
}
|
||||
listBoxTechTree.setItems(techtree,translatedTechs);
|
||||
listBoxTechTree.setSelectedItem(Lang::getInstance().get("DataMissing","",true));
|
||||
}
|
||||
}
|
||||
|
@ -4750,7 +4762,7 @@ int MenuStateConnectedGame::setupMapList(string scenario) {
|
|||
return initialMapSelection;
|
||||
}
|
||||
|
||||
int MenuStateConnectedGame::setupTechList(string scenario) {
|
||||
int MenuStateConnectedGame::setupTechList(string scenario, bool forceLoad) {
|
||||
int initialTechSelection = 0;
|
||||
try {
|
||||
Config &config = Config::getInstance();
|
||||
|
@ -4773,7 +4785,13 @@ int MenuStateConnectedGame::setupTechList(string scenario) {
|
|||
}
|
||||
}
|
||||
|
||||
listBoxTechTree.setItems(results);
|
||||
vector<string> translatedTechs;
|
||||
for(unsigned int i= 0; i < techTreeFiles.size(); i++) {
|
||||
string txTech = techTree->getTranslatedName(techTreeFiles.at(i), forceLoad);
|
||||
translatedTechs.push_back(txTech);
|
||||
}
|
||||
|
||||
listBoxTechTree.setItems(results,translatedTechs);
|
||||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[8096]="";
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace Shared { namespace Graphics {
|
|||
|
||||
namespace Glest { namespace Game {
|
||||
|
||||
class TechTree;
|
||||
|
||||
enum JoinMenu {
|
||||
jmSimple,
|
||||
jmMasterserver,
|
||||
|
@ -225,6 +227,7 @@ private:
|
|||
int lastGameSettingsReceivedCount;
|
||||
|
||||
bool launchingNewGame;
|
||||
std::auto_ptr<TechTree> techTree;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -278,7 +281,7 @@ private:
|
|||
void setupUIFromGameSettings(GameSettings *gameSettings, bool errorOnMissingData);
|
||||
|
||||
int setupMapList(string scenario);
|
||||
int setupTechList(string scenario);
|
||||
int setupTechList(string scenario, bool forceLoad=false);
|
||||
void setupTilesetList(string scenario);
|
||||
|
||||
void loadScenarioInfo(string file, ScenarioInfo *scenarioInfo);
|
||||
|
|
|
@ -172,11 +172,12 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
buttonPlayNow.registerGraphicComponent(containerName,"buttonPlayNow");
|
||||
buttonPlayNow.init(250+130+235, 180, 125);
|
||||
|
||||
techTree.reset(new TechTree(config.getPathListForType(ptTechs)));
|
||||
|
||||
int labelOffset=23;
|
||||
int setupPos=590;
|
||||
int mapHeadPos=330;
|
||||
int mapPos=mapHeadPos-labelOffset;
|
||||
//int aHeadPos=mapHeadPos-80;
|
||||
int aHeadPos=240;
|
||||
int aPos=aHeadPos-labelOffset;
|
||||
int networkHeadPos=700;
|
||||
|
@ -259,11 +260,10 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
listBoxTileset.setSelectedItemIndex(rand() % listBoxTileset.getItemCount());
|
||||
|
||||
//tech Tree listBox
|
||||
int initialTechSelection = setupTechList("");
|
||||
int initialTechSelection = setupTechList("", true);
|
||||
|
||||
listBoxTechTree.registerGraphicComponent(containerName,"listBoxTechTree");
|
||||
listBoxTechTree.init(xoffset+650, mapPos, 150);
|
||||
//listBoxTechTree.setItems(results);
|
||||
listBoxTechTree.setSelectedItemIndex(initialTechSelection);
|
||||
|
||||
labelTechTree.registerGraphicComponent(containerName,"labelTechTree");
|
||||
|
@ -288,11 +288,6 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
labelAllowObservers.init(xoffset+310, aHeadPos, 80);
|
||||
labelAllowObservers.setText(lang.get("AllowObservers"));
|
||||
|
||||
// listBoxAllowObservers.registerGraphicComponent(containerName,"listBoxAllowObservers");
|
||||
// listBoxAllowObservers.init(xoffset+310, aPos, 80);
|
||||
// listBoxAllowObservers.pushBackItem(lang.get("No"));
|
||||
// listBoxAllowObservers.pushBackItem(lang.get("Yes"));
|
||||
// listBoxAllowObservers.setSelectedItemIndex(0);
|
||||
checkBoxAllowObservers.registerGraphicComponent(containerName,"checkBoxAllowObservers");
|
||||
checkBoxAllowObservers.init(xoffset+310, aPos);
|
||||
checkBoxAllowObservers.setValue(false);
|
||||
|
@ -310,16 +305,6 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
listBoxFallbackCpuMultiplier.setItems(rMultiplier);
|
||||
listBoxFallbackCpuMultiplier.setSelectedItemIndex(5);
|
||||
|
||||
// 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);
|
||||
|
||||
// Allow Switch Team Mode
|
||||
labelEnableSwitchTeamMode.registerGraphicComponent(containerName,"labelEnableSwitchTeamMode");
|
||||
labelEnableSwitchTeamMode.init(xoffset+310, aHeadPos+45, 80);
|
||||
|
@ -351,27 +336,19 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
checkBoxAllowInGameJoinPlayer.setValue(false);
|
||||
checkBoxAllowInGameJoinPlayer.setVisible(allowInProgressJoin);
|
||||
|
||||
// Which Pathfinder
|
||||
//labelPathFinderType.registerGraphicComponent(containerName,"labelPathFinderType");
|
||||
//labelPathFinderType.init(xoffset+650, aHeadPos, 80);
|
||||
//labelPathFinderType.setText(lang.get("PathFinderType"));
|
||||
labelAllowNativeLanguageTechtree.registerGraphicComponent(containerName,"labelAllowNativeLanguageTechtree");
|
||||
labelAllowNativeLanguageTechtree.init(xoffset+650, mapHeadPos-50);
|
||||
labelAllowNativeLanguageTechtree.setText(lang.get("AllowNativeLanguageTechtree"));
|
||||
|
||||
//listBoxPathFinderType.registerGraphicComponent(containerName,"listBoxPathFinderType");
|
||||
//listBoxPathFinderType.init(xoffset+650, aPos, 150);
|
||||
//listBoxPathFinderType.pushBackItem(lang.get("PathFinderTypeRegular"));
|
||||
//listBoxPathFinderType.setSelectedItemIndex(0);
|
||||
checkBoxAllowNativeLanguageTechtree.registerGraphicComponent(containerName,"checkBoxAllowNativeLanguageTechtree");
|
||||
checkBoxAllowNativeLanguageTechtree.init(xoffset+650, mapHeadPos-70);
|
||||
checkBoxAllowNativeLanguageTechtree.setValue(false);
|
||||
|
||||
// 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"));
|
||||
// listBoxAdvanced.setSelectedItemIndex(0);
|
||||
|
||||
checkBoxAdvanced.registerGraphicComponent(containerName,"checkBoxAdvanced");
|
||||
checkBoxAdvanced.init(810, 80-labelOffset);
|
||||
checkBoxAdvanced.setValue(false);
|
||||
|
@ -384,17 +361,6 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
labelPublishServer.init(50, networkHeadPos, 100);
|
||||
labelPublishServer.setText(lang.get("PublishServer"));
|
||||
|
||||
// listBoxPublishServer.registerGraphicComponent(containerName,"listBoxPublishServer");
|
||||
// listBoxPublishServer.init(50, networkPos, 100);
|
||||
// listBoxPublishServer.pushBackItem(lang.get("Yes"));
|
||||
// listBoxPublishServer.pushBackItem(lang.get("No"));
|
||||
// if(this->headlessServerMode == true ||
|
||||
// (openNetworkSlots == true && parentMenuState != pLanGame)) {
|
||||
// listBoxPublishServer.setSelectedItemIndex(0);
|
||||
// }
|
||||
// else {
|
||||
// listBoxPublishServer.setSelectedItemIndex(1);
|
||||
// }
|
||||
checkBoxPublishServer.registerGraphicComponent(containerName,"checkBoxPublishServer");
|
||||
checkBoxPublishServer.init(50, networkPos);
|
||||
|
||||
|
@ -421,47 +387,16 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
}
|
||||
labelGameName.setMaxEditWidth(20);
|
||||
labelGameName.setMaxEditRenderWidth(160);
|
||||
// Network Frame Period
|
||||
//labelNetworkFramePeriod.registerGraphicComponent(containerName,"labelNetworkFramePeriod");
|
||||
//labelNetworkFramePeriod.init(xoffset+230, networkHeadPos, 80);
|
||||
//labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod"));
|
||||
|
||||
//listBoxNetworkFramePeriod.registerGraphicComponent(containerName,"listBoxNetworkFramePeriod");
|
||||
//listBoxNetworkFramePeriod.init(xoffset+230, networkPos, 80);
|
||||
//listBoxNetworkFramePeriod.pushBackItem("10");
|
||||
//listBoxNetworkFramePeriod.pushBackItem("20");
|
||||
//listBoxNetworkFramePeriod.pushBackItem("30");
|
||||
//listBoxNetworkFramePeriod.pushBackItem("40");
|
||||
//listBoxNetworkFramePeriod.setSelectedItem("20");
|
||||
|
||||
// Network Pause for lagged clients
|
||||
labelNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"labelNetworkPauseGameForLaggedClients");
|
||||
//labelNetworkPauseGameForLaggedClients.init(xoffset+380, networkHeadPos, 80);
|
||||
labelNetworkPauseGameForLaggedClients.init(labelAllowInGameJoinPlayer.getX(), networkHeadPos, 80);
|
||||
labelNetworkPauseGameForLaggedClients.setText(lang.get("NetworkPauseGameForLaggedClients"));
|
||||
|
||||
// listBoxNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"listBoxNetworkPauseGameForLaggedClients");
|
||||
// listBoxNetworkPauseGameForLaggedClients.init(xoffset+380, networkPos, 80);
|
||||
// listBoxNetworkPauseGameForLaggedClients.pushBackItem(lang.get("No"));
|
||||
// listBoxNetworkPauseGameForLaggedClients.pushBackItem(lang.get("Yes"));
|
||||
// listBoxNetworkPauseGameForLaggedClients.setSelectedItem(lang.get("Yes"));
|
||||
checkBoxNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"checkBoxNetworkPauseGameForLaggedClients");
|
||||
//checkBoxNetworkPauseGameForLaggedClients.init(xoffset+380, networkPos);
|
||||
checkBoxNetworkPauseGameForLaggedClients.init(checkBoxAllowInGameJoinPlayer.getX(), networkHeadPos);
|
||||
checkBoxNetworkPauseGameForLaggedClients.setValue(true);
|
||||
|
||||
// Enable Server Controlled AI
|
||||
//labelEnableServerControlledAI.registerGraphicComponent(containerName,"labelEnableServerControlledAI");
|
||||
//labelEnableServerControlledAI.init(xoffset+550, networkHeadPos, 80);
|
||||
//labelEnableServerControlledAI.setText(lang.get("EnableServerControlledAI"));
|
||||
|
||||
//listBoxEnableServerControlledAI.registerGraphicComponent(containerName,"listBoxEnableServerControlledAI");
|
||||
//listBoxEnableServerControlledAI.init(xoffset+550, networkPos, 80);
|
||||
//listBoxEnableServerControlledAI.pushBackItem(lang.get("Yes"));
|
||||
//listBoxEnableServerControlledAI.pushBackItem(lang.get("No"));
|
||||
//listBoxEnableServerControlledAI.setSelectedItemIndex(0);
|
||||
|
||||
|
||||
//list boxes
|
||||
xoffset=100;
|
||||
int rowHeight=27;
|
||||
|
@ -560,21 +495,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
|
||||
reloadFactions(false,"");
|
||||
|
||||
// vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||
// for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||
// string &techPath = techPaths[idx];
|
||||
// endPathWithSlash(techPath);
|
||||
// //findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false);
|
||||
// findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false);
|
||||
//
|
||||
// if(results.empty() == false) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(results.empty() == true) {
|
||||
if(factionFiles.empty() == true) {
|
||||
//throw megaglest_runtime_error("(1)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
|
||||
showGeneralError=true;
|
||||
generalErrorToShow = "[#1] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]";
|
||||
}
|
||||
|
@ -785,6 +706,8 @@ void MenuStateCustomGame::reloadUI() {
|
|||
|
||||
labelTechTree.setText(lang.get("TechTree"));
|
||||
|
||||
labelAllowNativeLanguageTechtree.setText(lang.get("AllowNativeLanguageTechtree"));
|
||||
|
||||
labelFogOfWar.setText(lang.get("FogOfWar"));
|
||||
|
||||
std::vector<std::string> listBoxData;
|
||||
|
@ -796,50 +719,20 @@ void MenuStateCustomGame::reloadUI() {
|
|||
// Allow Observers
|
||||
labelAllowObservers.setText(lang.get("AllowObservers"));
|
||||
|
||||
//listBoxData.clear();
|
||||
//listBoxData.push_back(lang.get("No"));
|
||||
//listBoxData.push_back(lang.get("Yes"));
|
||||
//listBoxAllowObservers.setItems(listBoxData);
|
||||
|
||||
// View Map At End Of Game
|
||||
//listBoxData.clear();
|
||||
//listBoxData.push_back(lang.get("Yes"));
|
||||
//listBoxData.push_back(lang.get("No"));
|
||||
//listBoxEnableObserverMode.setItems(listBoxData);
|
||||
|
||||
// Allow Switch Team Mode
|
||||
labelEnableSwitchTeamMode.setText(lang.get("EnableSwitchTeamMode"));
|
||||
|
||||
labelAllowInGameJoinPlayer.setText(lang.get("AllowInGameJoinPlayer"));
|
||||
|
||||
//listBoxData.clear();
|
||||
//listBoxData.push_back(lang.get("Yes"));
|
||||
//listBoxData.push_back(lang.get("No"));
|
||||
//listBoxEnableSwitchTeamMode.setItems(listBoxData);
|
||||
|
||||
labelAISwitchTeamAcceptPercent.setText(lang.get("AISwitchTeamAcceptPercent"));
|
||||
|
||||
//labelPathFinderType.setText(lang.get("PathFinderType"));
|
||||
|
||||
listBoxData.clear();
|
||||
//listBoxData.push_back(lang.get("PathFinderTypeRegular"));
|
||||
//listBoxPathFinderType.setItems(listBoxData);
|
||||
|
||||
// Advanced Options
|
||||
labelAdvanced.setText(lang.get("AdvancedGameOptions"));
|
||||
|
||||
//listBoxData.clear();
|
||||
//listBoxData.push_back(lang.get("No"));
|
||||
//listBoxData.push_back(lang.get("Yes"));
|
||||
//listBoxAdvanced.setItems(listBoxData);
|
||||
|
||||
labelPublishServer.setText(lang.get("PublishServer"));
|
||||
|
||||
//listBoxData.clear();
|
||||
//listBoxData.push_back(lang.get("Yes"));
|
||||
//listBoxData.push_back(lang.get("No"));
|
||||
//listBoxPublishServer.setItems(listBoxData);
|
||||
|
||||
labelGameNameLabel.setText(lang.get("MGGameTitle")+":");
|
||||
|
||||
labelGameName.setFont(CoreData::getInstance().getMenuFontBig());
|
||||
|
@ -853,11 +746,6 @@ void MenuStateCustomGame::reloadUI() {
|
|||
|
||||
labelNetworkPauseGameForLaggedClients.setText(lang.get("NetworkPauseGameForLaggedClients"));
|
||||
|
||||
//listBoxData.clear();
|
||||
//listBoxData.push_back(lang.get("No"));
|
||||
//listBoxData.push_back(lang.get("Yes"));
|
||||
//listBoxNetworkPauseGameForLaggedClients.setItems(listBoxData);
|
||||
|
||||
for(int i=0; i < GameConstants::maxPlayers; ++i) {
|
||||
buttonBlockPlayers[i].setText(lang.get("BlockPlayer"));
|
||||
}
|
||||
|
@ -1168,6 +1056,19 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||
serverInterface->setAllowInGameConnections(checkBoxAllowInGameJoinPlayer.getValue() == true);
|
||||
}
|
||||
else if (checkBoxAllowNativeLanguageTechtree.mouseClick(x, y)) {
|
||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
||||
if(checkBoxPublishServer.getValue() == true) {
|
||||
needToRepublishToMasterserver = true;
|
||||
}
|
||||
|
||||
if(hasNetworkGameSettings() == true)
|
||||
{
|
||||
needToSetChangedGameSettings = true;
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
}
|
||||
else if (checkBoxAdvanced.getValue() == 1 && checkBoxEnableSwitchTeamMode.mouseClick(x, y)) {
|
||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
||||
|
@ -1854,6 +1755,8 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms) {
|
|||
}
|
||||
checkBoxAllowInGameJoinPlayer.mouseMove(x, y);
|
||||
|
||||
checkBoxAllowNativeLanguageTechtree.mouseMove(x, y);
|
||||
|
||||
listBoxTileset.mouseMove(x, y);
|
||||
listBoxMapFilter.mouseMove(x, y);
|
||||
listBoxTechTree.mouseMove(x, y);
|
||||
|
@ -2100,6 +2003,9 @@ void MenuStateCustomGame::render() {
|
|||
if(checkBoxScenario.getValue() == true) {
|
||||
renderer.renderListBox(&listBoxScenario);
|
||||
}
|
||||
|
||||
renderer.renderLabel(&labelAllowNativeLanguageTechtree);
|
||||
renderer.renderCheckBox(&checkBoxAllowNativeLanguageTechtree);
|
||||
}
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
|
@ -3242,6 +3148,8 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
|||
gameSettings->setFlagTypes1(valueFlags1);
|
||||
}
|
||||
|
||||
gameSettings->setNetworkAllowNativeLanguageTechtree(checkBoxAllowNativeLanguageTechtree.getValue());
|
||||
|
||||
// First save Used slots
|
||||
//for(int i=0; i<mapInfo.players; ++i)
|
||||
int AIPlayerCount = 0;
|
||||
|
@ -3589,7 +3497,7 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
|
|||
}
|
||||
}
|
||||
setupMapList(gameSettings.getScenario());
|
||||
setupTechList(gameSettings.getScenario());
|
||||
setupTechList(gameSettings.getScenario(),false);
|
||||
setupTilesetList(gameSettings.getScenario());
|
||||
|
||||
if(checkBoxScenario.getValue() == true) {
|
||||
|
@ -3672,6 +3580,8 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
|
|||
serverInterface->setAllowInGameConnections(checkBoxAllowInGameJoinPlayer.getValue() == true);
|
||||
}
|
||||
|
||||
checkBoxAllowNativeLanguageTechtree.setValue(gameSettings.getNetworkAllowNativeLanguageTechtree());
|
||||
|
||||
//listBoxPathFinderType.setSelectedItemIndex(gameSettings.getPathFinderType());
|
||||
|
||||
//listBoxEnableServerControlledAI.setSelectedItem(gameSettings.getEnableServerControlledAI() == true ? lang.get("Yes") : lang.get("No"));
|
||||
|
@ -4274,7 +4184,7 @@ void MenuStateCustomGame::processScenario() {
|
|||
listBoxFogOfWar.setSelectedItemIndex(0);
|
||||
}
|
||||
|
||||
setupTechList(scenarioInfo.name);
|
||||
setupTechList(scenarioInfo.name, false);
|
||||
listBoxTechTree.setSelectedItem(formatString(scenarioInfo.techTreeName));
|
||||
reloadFactions(false,scenarioInfo.name);
|
||||
|
||||
|
@ -4413,7 +4323,7 @@ void MenuStateCustomGame::processScenario() {
|
|||
loadMapInfo(Map::getMapPath(getCurrentMapFile(),"",true), &mapInfo, true);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
|
||||
setupTechList("");
|
||||
setupTechList("", false);
|
||||
reloadFactions(false,"");
|
||||
setupTilesetList("");
|
||||
}
|
||||
|
@ -4562,7 +4472,7 @@ int MenuStateCustomGame::setupMapList(string scenario) {
|
|||
return initialMapSelection;
|
||||
}
|
||||
|
||||
int MenuStateCustomGame::setupTechList(string scenario) {
|
||||
int MenuStateCustomGame::setupTechList(string scenario, bool forceLoad) {
|
||||
int initialTechSelection = 0;
|
||||
try {
|
||||
Config &config = Config::getInstance();
|
||||
|
@ -4578,6 +4488,8 @@ int MenuStateCustomGame::setupTechList(string scenario) {
|
|||
|
||||
techTreeFiles= results;
|
||||
|
||||
vector<string> translatedTechs;
|
||||
|
||||
for(unsigned int i= 0; i < results.size(); i++) {
|
||||
//printf("TECHS i = %d results [%s] scenario [%s]\n",i,results[i].c_str(),scenario.c_str());
|
||||
|
||||
|
@ -4585,9 +4497,12 @@ int MenuStateCustomGame::setupTechList(string scenario) {
|
|||
if(config.getString("InitialTechTree", "Megapack") == results.at(i)) {
|
||||
initialTechSelection= i;
|
||||
}
|
||||
string txTech = techTree->getTranslatedName(techTreeFiles.at(i), forceLoad);
|
||||
translatedTechs.push_back(txTech);
|
||||
}
|
||||
|
||||
listBoxTechTree.setItems(results);
|
||||
|
||||
listBoxTechTree.setItems(results,translatedTechs);
|
||||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[8096]="";
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace Glest { namespace Game {
|
|||
|
||||
class SwitchSetupRequest;
|
||||
class ServerInterface;
|
||||
class TechTree;
|
||||
|
||||
enum ParentMenuState {
|
||||
pNewGame,
|
||||
|
@ -130,6 +131,9 @@ private:
|
|||
GraphicLabel labelAllowInGameJoinPlayer;
|
||||
GraphicCheckBox checkBoxAllowInGameJoinPlayer;
|
||||
|
||||
GraphicLabel labelAllowNativeLanguageTechtree;
|
||||
GraphicCheckBox checkBoxAllowNativeLanguageTechtree;
|
||||
|
||||
GraphicCheckBox checkBoxScenario;
|
||||
GraphicLabel labelScenario;
|
||||
GraphicListBox listBoxScenario;
|
||||
|
@ -209,6 +213,8 @@ private:
|
|||
bool masterserverModeMinimalResources;
|
||||
int lastMasterServerSettingsUpdateCount;
|
||||
|
||||
std::auto_ptr<TechTree> techTree;
|
||||
|
||||
public:
|
||||
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,
|
||||
bool openNetworkSlots= false, ParentMenuState parentMenuState=pNewGame,
|
||||
|
@ -280,7 +286,7 @@ private:
|
|||
void processScenario();
|
||||
void SetupUIForScenarios();
|
||||
int setupMapList(string scenario);
|
||||
int setupTechList(string scenario);
|
||||
int setupTechList(string scenario, bool forceLoad=false);
|
||||
void reloadFactions(bool keepExistingSelectedItem, string scenario);
|
||||
void setupTilesetList(string scenario);
|
||||
|
||||
|
|
|
@ -547,6 +547,8 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
|||
data.masterserver_admin_factionIndex = gameSettings->getMasterserver_admin_faction_index();
|
||||
|
||||
data.scenario = gameSettings->getScenario();
|
||||
|
||||
data.networkAllowNativeLanguageTechtree = gameSettings->getNetworkAllowNativeLanguageTechtree();
|
||||
}
|
||||
|
||||
void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const {
|
||||
|
@ -603,6 +605,8 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const {
|
|||
gameSettings->setMasterserver_admin_faction_index(data.masterserver_admin_factionIndex);
|
||||
|
||||
gameSettings->setScenario(data.scenario.getString());
|
||||
|
||||
gameSettings->setNetworkAllowNativeLanguageTechtree(data.networkAllowNativeLanguageTechtree);
|
||||
}
|
||||
|
||||
vector<pair<string,uint32> > NetworkMessageLaunch::getFactionCRCList() const {
|
||||
|
@ -617,7 +621,7 @@ vector<pair<string,uint32> > NetworkMessageLaunch::getFactionCRCList() const {
|
|||
}
|
||||
|
||||
const char * NetworkMessageLaunch::getPackedMessageFormat() const {
|
||||
return "c256s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60sllllllll60s60s60s60s60s60s60s60sLLL60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60sLLLLLLLLLLLLLLLLLLLLcccccccccccccccccccccccccccccccccccccccccCccLccll256s60s60s60s60s60s60s60s60s";
|
||||
return "c256s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60sllllllll60s60s60s60s60s60s60s60sLLL60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60s60sLLLLLLLLLLLLLLLLLLLLcccccccccccccccccccccccccccccccccccccccccCccLccll256s60s60s60s60s60s60s60s60sc";
|
||||
}
|
||||
|
||||
unsigned int NetworkMessageLaunch::getPackedSize() {
|
||||
|
@ -763,7 +767,8 @@ unsigned int NetworkMessageLaunch::getPackedSize() {
|
|||
packedData.networkPlayerUUID[4].getBuffer(),
|
||||
packedData.networkPlayerUUID[5].getBuffer(),
|
||||
packedData.networkPlayerUUID[6].getBuffer(),
|
||||
packedData.networkPlayerUUID[7].getBuffer()
|
||||
packedData.networkPlayerUUID[7].getBuffer(),
|
||||
packedData.networkAllowNativeLanguageTechtree
|
||||
);
|
||||
delete [] buf;
|
||||
}
|
||||
|
@ -908,7 +913,8 @@ void NetworkMessageLaunch::unpackMessage(unsigned char *buf) {
|
|||
data.networkPlayerUUID[4].getBuffer(),
|
||||
data.networkPlayerUUID[5].getBuffer(),
|
||||
data.networkPlayerUUID[6].getBuffer(),
|
||||
data.networkPlayerUUID[7].getBuffer()
|
||||
data.networkPlayerUUID[7].getBuffer(),
|
||||
&data.networkAllowNativeLanguageTechtree
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1052,7 +1058,8 @@ unsigned char * NetworkMessageLaunch::packMessage() {
|
|||
data.networkPlayerUUID[4].getBuffer(),
|
||||
data.networkPlayerUUID[5].getBuffer(),
|
||||
data.networkPlayerUUID[6].getBuffer(),
|
||||
data.networkPlayerUUID[7].getBuffer()
|
||||
data.networkPlayerUUID[7].getBuffer(),
|
||||
data.networkAllowNativeLanguageTechtree
|
||||
);
|
||||
return buf;
|
||||
}
|
||||
|
@ -1147,6 +1154,8 @@ void NetworkMessageLaunch::toEndian() {
|
|||
data.cpuReplacementMultiplier = Shared::PlatformByteOrder::toCommonEndian(data.cpuReplacementMultiplier);
|
||||
data.masterserver_admin = Shared::PlatformByteOrder::toCommonEndian(data.masterserver_admin);
|
||||
data.masterserver_admin_factionIndex = Shared::PlatformByteOrder::toCommonEndian(data.masterserver_admin_factionIndex);
|
||||
|
||||
data.networkAllowNativeLanguageTechtree = Shared::PlatformByteOrder::toCommonEndian(data.networkAllowNativeLanguageTechtree);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1184,6 +1193,8 @@ void NetworkMessageLaunch::fromEndian() {
|
|||
data.cpuReplacementMultiplier = Shared::PlatformByteOrder::fromCommonEndian(data.cpuReplacementMultiplier);
|
||||
data.masterserver_admin = Shared::PlatformByteOrder::fromCommonEndian(data.masterserver_admin);
|
||||
data.masterserver_admin_factionIndex = Shared::PlatformByteOrder::fromCommonEndian(data.masterserver_admin_factionIndex);
|
||||
|
||||
data.networkAllowNativeLanguageTechtree = Shared::PlatformByteOrder::fromCommonEndian(data.networkAllowNativeLanguageTechtree);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -297,6 +297,8 @@ private:
|
|||
NetworkString<maxStringSize> scenario;
|
||||
|
||||
NetworkString<maxSmallStringSize> networkPlayerUUID[GameConstants::maxPlayers];
|
||||
|
||||
int8 networkAllowNativeLanguageTechtree;
|
||||
};
|
||||
void toEndian();
|
||||
void fromEndian();
|
||||
|
|
|
@ -366,7 +366,7 @@ void FactionThread::execute() {
|
|||
|
||||
bool update = unit->needToUpdate();
|
||||
|
||||
if(minorDebugPerformance && (chrono.getMillis() - elapsed1) >= 1) printf("Faction [%d - %s] #1-unit threaded updates on frame: %d for [%d] unit # %d, unitCount = %d, took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName().c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),j,unitCount,(long long int)chrono.getMillis() - elapsed1);
|
||||
if(minorDebugPerformance && (chrono.getMillis() - elapsed1) >= 1) printf("Faction [%d - %s] #1-unit threaded updates on frame: %d for [%d] unit # %d, unitCount = %d, took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName(false).c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),j,unitCount,(long long int)chrono.getMillis() - elapsed1);
|
||||
|
||||
//update = true;
|
||||
if(update == true) {
|
||||
|
@ -391,7 +391,7 @@ void FactionThread::execute() {
|
|||
|
||||
world->getUnitUpdater()->updateUnitCommand(unit,currentTriggeredFrameIndex);
|
||||
|
||||
if(minorDebugPerformance && (chrono.getMillis() - elapsed2) >= 1) printf("Faction [%d - %s] #2-unit threaded updates on frame: %d for [%d] unit # %d, unitCount = %d, took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName().c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),j,unitCount,(long long int)chrono.getMillis() - elapsed2);
|
||||
if(minorDebugPerformance && (chrono.getMillis() - elapsed2) >= 1) printf("Faction [%d - %s] #2-unit threaded updates on frame: %d for [%d] unit # %d, unitCount = %d, took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName(false).c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),j,unitCount,(long long int)chrono.getMillis() - elapsed2);
|
||||
}
|
||||
else {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
|
||||
|
@ -408,7 +408,7 @@ void FactionThread::execute() {
|
|||
}
|
||||
}
|
||||
|
||||
if(minorDebugPerformance && chrono.getMillis() >= 1) printf("Faction [%d - %s] threaded updates on frame: %d for [%d] units took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName().c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),(long long int)chrono.getMillis());
|
||||
if(minorDebugPerformance && chrono.getMillis() >= 1) printf("Faction [%d - %s] threaded updates on frame: %d for [%d] units took [%lld] msecs\n",faction->getStartLocationIndex(),faction->getType()->getName(false).c_str(),currentTriggeredFrameIndex,faction->getUnitPathfindingListCount(),(long long int)chrono.getMillis());
|
||||
|
||||
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -2022,7 +2022,7 @@ std::string Faction::toString() const {
|
|||
|
||||
result += "Allies = " + intToStr(allies.size()) + "\n";
|
||||
for(int idx = 0; idx < allies.size(); idx ++) {
|
||||
result += "index = " + intToStr(idx) + " name: " + allies[idx]->factionType->getName() + " factionindex = " + intToStr(allies[idx]->index) + "\n";
|
||||
result += "index = " + intToStr(idx) + " name: " + allies[idx]->factionType->getName(false) + " factionindex = " + intToStr(allies[idx]->index) + "\n";
|
||||
}
|
||||
|
||||
result += "Units = " + intToStr(units.size()) + "\n";
|
||||
|
@ -2073,7 +2073,7 @@ void Faction::saveGame(XmlNode *rootNode) {
|
|||
factionNode->addAttribute("overridePersonalityType",intToStr(overridePersonalityType), mapTagReplacements);
|
||||
// Texture2D *texture;
|
||||
// FactionType *factionType;
|
||||
factionNode->addAttribute("factiontype",factionType->getName(), mapTagReplacements);
|
||||
factionNode->addAttribute("factiontype",factionType->getName(false), mapTagReplacements);
|
||||
// int index;
|
||||
factionNode->addAttribute("index",intToStr(index), mapTagReplacements);
|
||||
// int teamIndex;
|
||||
|
|
|
@ -4048,7 +4048,7 @@ std::string Unit::toString() const {
|
|||
result += "thisFaction = " + intToStr(this->faction->getThisFaction()) + "\n";
|
||||
result += "control = " + intToStr(this->faction->getControlType()) + "\n";
|
||||
if(this->faction->getType() != NULL) {
|
||||
result += "factionName = " + this->faction->getType()->getName() + "\n";
|
||||
result += "factionName = " + this->faction->getType()->getName(false) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ TechTree::TechTree(const vector<string> pathList) {
|
|||
factionTypes.clear();
|
||||
armorTypes.clear();
|
||||
attackTypes.clear();
|
||||
translatedTechNames.clear();
|
||||
}
|
||||
|
||||
string TechTree::getName(bool translatedValue) const {
|
||||
|
@ -52,6 +53,34 @@ string TechTree::getName(bool translatedValue) const {
|
|||
return lang.getTechTreeString("TechTreeName",name.c_str());
|
||||
}
|
||||
|
||||
string TechTree::getTranslatedName(string techName, bool forceLoad) {
|
||||
string result = techName;
|
||||
|
||||
if(translatedTechNames.find(techName) != translatedTechNames.end()) {
|
||||
result = translatedTechNames[techName];
|
||||
}
|
||||
else {
|
||||
//TechTree techTree(pathList);
|
||||
name = "";
|
||||
string path = findPath(techName);
|
||||
if(path != "") {
|
||||
string currentPath = path;
|
||||
endPathWithSlash(currentPath);
|
||||
treePath = currentPath;
|
||||
name= lastDir(currentPath);
|
||||
|
||||
Lang &lang = Lang::getInstance();
|
||||
lang.loadTechTreeStrings(name,forceLoad);
|
||||
|
||||
result = getName(true);
|
||||
|
||||
translatedTechNames[techName] = result;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Checksum TechTree::loadTech(const string &techName,
|
||||
set<string> &factions, Checksum* checksum, std::map<string,vector<pair<string, string> > > &loadedFileList) {
|
||||
name = "";
|
||||
|
@ -98,7 +127,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||
name= lastDir(currentPath);
|
||||
|
||||
Lang &lang = Lang::getInstance();
|
||||
lang.loadTechTreeStrings(name);
|
||||
lang.loadTechTreeStrings(name, true);
|
||||
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,Lang::getInstance().get("LogScreenGameLoadingTechtree","",true).c_str(),formatString(getName(true)).c_str());
|
||||
|
@ -321,7 +350,7 @@ std::vector<std::string> TechTree::validateResourceTypes() {
|
|||
|
||||
FactionType *TechTree::getTypeByName(const string &name) {
|
||||
for(int i=0; i < factionTypes.size(); ++i) {
|
||||
if(factionTypes[i].getName() == name) {
|
||||
if(factionTypes[i].getName(false) == name) {
|
||||
return &factionTypes[i];
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +360,7 @@ FactionType *TechTree::getTypeByName(const string &name) {
|
|||
|
||||
const FactionType *TechTree::getType(const string &name) const {
|
||||
for(int i=0; i < factionTypes.size(); ++i) {
|
||||
if(factionTypes[i].getName() == name) {
|
||||
if(factionTypes[i].getName(false) == name) {
|
||||
return &factionTypes[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@ private:
|
|||
DamageMultiplierTable damageMultiplierTable;
|
||||
Checksum checksumValue;
|
||||
|
||||
std::map<string,string> translatedTechNames;
|
||||
|
||||
public:
|
||||
Checksum loadTech(const string &techName,
|
||||
set<string> &factions, Checksum* checksum, std::map<string,vector<pair<string, string> > > &loadedFileList);
|
||||
|
@ -71,6 +73,8 @@ public:
|
|||
const FactionType *getType(int i) const {return &factionTypes[i];}
|
||||
const ResourceType *getResourceType(int i) const {return &resourceTypes[i];}
|
||||
string getName(bool translatedValue=false) const;
|
||||
string getTranslatedName(string techName, bool forceLoad=false);
|
||||
|
||||
vector<string> getPathList() const {return pathList;}
|
||||
//const string &getDesc() const {return desc;}
|
||||
|
||||
|
|
|
@ -2122,7 +2122,7 @@ void World::initUnitsForScenario() {
|
|||
string unitName = unit->getType()->getName();
|
||||
delete unit;
|
||||
unit = NULL;
|
||||
throw megaglest_runtime_error("Unit: " + unitName + " can't be placed, this error is caused because there\nis not enough room to put all units near their start location.\nmake a better/larger map. Faction: #" + intToStr(i) + " name: " + ft->getName());
|
||||
throw megaglest_runtime_error("Unit: " + unitName + " can't be placed, this error is caused because there\nis not enough room to put all units near their start location.\nmake a better/larger map. Faction: #" + intToStr(i) + " name: " + ft->getName(false));
|
||||
}
|
||||
|
||||
if (unit->getType()->hasSkillClass(scBeBuilt)) {
|
||||
|
@ -2146,7 +2146,7 @@ void World::placeUnitAtLocation(const Vec2i &location, int radius, Unit *unit, b
|
|||
}
|
||||
else {
|
||||
string unitName = unit->getType()->getName();
|
||||
string unitFactionName = unit->getFaction()->getType()->getName();
|
||||
string unitFactionName = unit->getFaction()->getType()->getName(false);
|
||||
int unitFactionIndex = unit->getFactionIndex();
|
||||
|
||||
delete unit;
|
||||
|
@ -2784,7 +2784,7 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
|
|||
std::cout << "Faction detail for index: " << i << std::endl;
|
||||
std::cout << "--------------------------" << std::endl;
|
||||
|
||||
std::cout << "FactionName = " << getFaction(i)->getType()->getName() << std::endl;
|
||||
std::cout << "FactionName = " << getFaction(i)->getType()->getName(false) << std::endl;
|
||||
std::cout << "FactionIndex = " << intToStr(getFaction(i)->getIndex()) << std::endl;
|
||||
std::cout << "teamIndex = " << intToStr(getFaction(i)->getTeam()) << std::endl;
|
||||
std::cout << "startLocationIndex = " << intToStr(getFaction(i)->getStartLocationIndex()) << std::endl;
|
||||
|
@ -2814,7 +2814,7 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
|
|||
//undertake the dead
|
||||
logFile << "Undertake stats:" << std::endl;
|
||||
for(int i = 0; i < getFactionCount(); ++i){
|
||||
logFile << "Faction: " << getFaction(i)->getType()->getName() << std::endl;
|
||||
logFile << "Faction: " << getFaction(i)->getType()->getName(false) << std::endl;
|
||||
int unitCount = getFaction(i)->getUnitCount();
|
||||
for(int j= unitCount - 1; j >= 0; j--){
|
||||
Unit *unit= getFaction(i)->getUnit(j);
|
||||
|
|
Loading…
Reference in New Issue