mirror of
https://github.com/glest/glest-source.git
synced 2025-08-15 04:43:58 +02:00
- added new commandline options to tell the game where to look for data, ini's and where to write logs
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <stdlib.h>
|
||||
#include "platform_util.h"
|
||||
#include "conversion.h"
|
||||
#include "cache_manager.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
@@ -191,9 +192,24 @@ string formatString(const string &str){
|
||||
return outStr;
|
||||
}
|
||||
|
||||
string getGameReadWritePath() {
|
||||
string path = "";
|
||||
if(getenv("GLESTHOME") != NULL) {
|
||||
string getGameReadWritePath(string lookupKey) {
|
||||
string path = "";
|
||||
|
||||
if(lookupKey != "") {
|
||||
std::map<string,string> &pathCache = CacheManager::getCachedItem< std::map<string,string> >(GameConstants::pathCacheLookupKey);
|
||||
std::map<string,string>::const_iterator iterFind = pathCache.find(lookupKey);
|
||||
if(iterFind != pathCache.end()) {
|
||||
path = iterFind->second;
|
||||
|
||||
if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
|
||||
path += "/";
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path to be used for [%s] files [%s]\n",__FILE__,__FUNCTION__,__LINE__,lookupKey.c_str(),path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if(path == "" && getenv("GLESTHOME") != NULL) {
|
||||
path = getenv("GLESTHOME");
|
||||
if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
|
||||
path += "/";
|
||||
|
@@ -41,7 +41,7 @@ string getCompileDateTime();
|
||||
|
||||
string formatString(const string &str);
|
||||
|
||||
string getGameReadWritePath();
|
||||
string getGameReadWritePath(string lookupKey="");
|
||||
|
||||
}}//end namespace
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
#include "metrics.h"
|
||||
#include "lang.h"
|
||||
#include "graphics_interface.h"
|
||||
|
||||
#include "game_constants.h"
|
||||
#include "game_util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -32,10 +33,12 @@ namespace Glest{ namespace Game{
|
||||
|
||||
const int Logger::logLineCount= 15;
|
||||
|
||||
// ===================== PUBLIC ========================
|
||||
// ===================== PUBLIC ========================
|
||||
|
||||
Logger::Logger(){
|
||||
fileName= "log.txt";
|
||||
string logs_path = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey);
|
||||
|
||||
fileName= logs_path + "log.txt";
|
||||
loadingTexture=NULL;
|
||||
}
|
||||
|
||||
@@ -87,7 +90,7 @@ void Logger::clear(){
|
||||
if(f==NULL){
|
||||
throw runtime_error("Error opening log file"+ fileName);
|
||||
}
|
||||
|
||||
|
||||
fprintf(f, "%s", s.c_str());
|
||||
fprintf(f, "\n");
|
||||
|
||||
@@ -96,14 +99,14 @@ void Logger::clear(){
|
||||
|
||||
|
||||
void Logger::loadLoadingScreen(string filepath){
|
||||
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
cleanupLoadingTexture();
|
||||
|
||||
if(filepath=="")
|
||||
{
|
||||
loadingTexture=NULL;
|
||||
loadingTexture=NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -124,7 +127,7 @@ void Logger::loadLoadingScreen(string filepath){
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== PRIVATE ====================
|
||||
// ==================== PRIVATE ====================
|
||||
|
||||
void Logger::renderLoadingScreen(){
|
||||
|
||||
@@ -139,16 +142,16 @@ void Logger::renderLoadingScreen(){
|
||||
}
|
||||
else{
|
||||
renderer.renderBackground(loadingTexture);
|
||||
}
|
||||
}
|
||||
renderer.renderText(
|
||||
state, coreData.getMenuFontBig(), Vec3f(1.f),
|
||||
state, coreData.getMenuFontBig(), Vec3f(1.f),
|
||||
metrics.getVirtualW()/4, 65*metrics.getVirtualH()/100, false);
|
||||
|
||||
renderer.renderText(
|
||||
current, coreData.getMenuFontNormal(), 1.0f,
|
||||
metrics.getVirtualW()/4,
|
||||
current, coreData.getMenuFontNormal(), 1.0f,
|
||||
metrics.getVirtualW()/4,
|
||||
62*metrics.getVirtualH()/100, false);
|
||||
|
||||
|
||||
renderer.swapBuffers();
|
||||
}
|
||||
|
||||
|
@@ -103,7 +103,7 @@ Game::~Game() {
|
||||
|
||||
Logger &logger= Logger::getInstance();
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
|
||||
logger.loadLoadingScreen("");
|
||||
logger.setState(Lang::getInstance().get("Deleting"));
|
||||
logger.add("Game", true);
|
||||
@@ -235,7 +235,8 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,st
|
||||
|
||||
//printf("In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,settings->getFactionTypeName(i).c_str());
|
||||
if(settings->getFactionTypeName(i) == formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
||||
const string factionLogo = "data/core/misc_textures/observer.jpg";
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
const string factionLogo = data_path + "data/core/misc_textures/observer.jpg";
|
||||
//printf("In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str());
|
||||
|
||||
if(fileExists(factionLogo) == true) {
|
||||
@@ -249,7 +250,8 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,st
|
||||
}
|
||||
}
|
||||
else if(settings->getFactionTypeName(i) == formatString(GameConstants::RANDOMFACTION_SLOTNAME)) {
|
||||
const string factionLogo = "data/core/misc_textures/random.jpg";
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
const string factionLogo = data_path + "data/core/misc_textures/random.jpg";
|
||||
//printf("In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str());
|
||||
|
||||
if(fileExists(factionLogo) == true) {
|
||||
@@ -1560,7 +1562,7 @@ void Game::render2d(){
|
||||
string str="";
|
||||
std::map<int,string> factionDebugInfo;
|
||||
|
||||
if( renderer.getShowDebugUI() == true ||
|
||||
if( renderer.getShowDebugUI() == true ||
|
||||
(perfLogging == true && difftime(time(NULL),lastRenderLog2d) >= 1)) {
|
||||
str+= "MouseXY: " + intToStr(mouseX) + "," + intToStr(mouseY)+"\n";
|
||||
str+= "PosObjWord: " + intToStr(gui.getPosObjWorld().x) + "," + intToStr(gui.getPosObjWorld().y)+"\n";
|
||||
@@ -1711,7 +1713,7 @@ void Game::render2d(){
|
||||
|
||||
if(perfLogging == true && difftime(time(NULL),lastRenderLog2d) >= 1) {
|
||||
lastRenderLog2d = time(NULL);
|
||||
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] Statistics: %s\n",__FILE__,__FUNCTION__,__LINE__,str.c_str());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"In [%s::%s Line: %d] Statistics: %s\n",__FILE__,__FUNCTION__,__LINE__,str.c_str());
|
||||
}
|
||||
|
@@ -107,6 +107,10 @@ public:
|
||||
static const char *RANDOMFACTION_SLOTNAME;
|
||||
|
||||
static const char *playerTextureCacheLookupKey;
|
||||
static const char *pathCacheLookupKey;
|
||||
static const char *path_data_CacheLookupKey;
|
||||
static const char *path_ini_CacheLookupKey;
|
||||
static const char *path_logs_CacheLookupKey;
|
||||
|
||||
static const char *application_name;
|
||||
};
|
||||
|
@@ -48,6 +48,15 @@ const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*";
|
||||
const char *GameConstants::playerTextureCacheLookupKey = "playerTextureCache";
|
||||
const char *GameConstants::application_name = "MegaGlest";
|
||||
|
||||
const char *GameConstants::pathCacheLookupKey = "pathCache_";
|
||||
const char *GameConstants::path_data_CacheLookupKey = "data";
|
||||
const char *GameConstants::path_ini_CacheLookupKey = "ini";
|
||||
const char *GameConstants::path_logs_CacheLookupKey = "logs";
|
||||
|
||||
const char *Config::glest_ini_filename = "glest.ini";
|
||||
const char *Config::glestuser_ini_filename = "glestuser.ini";
|
||||
|
||||
|
||||
// =====================================================
|
||||
// class Config
|
||||
// =====================================================
|
||||
@@ -73,9 +82,9 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
|
||||
cfgType = type;
|
||||
|
||||
fileName = file;
|
||||
if(getGameReadWritePath() != "") {
|
||||
fileName.first = getGameReadWritePath() + fileName.first;
|
||||
fileName.second = getGameReadWritePath() + fileName.second;
|
||||
if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||
fileName.first = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName.first;
|
||||
fileName.second = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName.second;
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.first = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.first.c_str());
|
||||
@@ -148,7 +157,7 @@ void Config::reload() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame);
|
||||
Config newconfig(type, std::make_pair("glest.ini","glestuser.ini"), std::make_pair(true,false));
|
||||
Config newconfig(type, std::make_pair(glest_ini_filename,glestuser_ini_filename), std::make_pair(true,false));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -382,46 +391,51 @@ string Config::toString(){
|
||||
vector<string> Config::getPathListForType(PathType type, string scenarioDir) {
|
||||
vector<string> pathList;
|
||||
|
||||
//#include "game_constants.h"
|
||||
//#include "game_util.h"
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
|
||||
string userData = getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData[userData.size()-1] != '/' && userData[userData.size()-1] != '\\') {
|
||||
userData += '/';
|
||||
}
|
||||
userData=data_path+userData;
|
||||
if(isdir(userData.c_str()) == false) {
|
||||
createDirectoryPaths(userData);
|
||||
}
|
||||
}
|
||||
if(scenarioDir != "") {
|
||||
pathList.push_back(scenarioDir);
|
||||
pathList.push_back(data_path+scenarioDir);
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case ptMaps:
|
||||
pathList.push_back(GameConstants::folder_path_maps);
|
||||
pathList.push_back(data_path+GameConstants::folder_path_maps);
|
||||
if(userData != "") {
|
||||
pathList.push_back(userData + string(GameConstants::folder_path_maps));
|
||||
}
|
||||
break;
|
||||
case ptScenarios:
|
||||
pathList.push_back(GameConstants::folder_path_scenarios);
|
||||
pathList.push_back(data_path+GameConstants::folder_path_scenarios);
|
||||
if(userData != "") {
|
||||
pathList.push_back(userData + string(GameConstants::folder_path_scenarios));
|
||||
}
|
||||
break;
|
||||
case ptTechs:
|
||||
pathList.push_back(GameConstants::folder_path_techs);
|
||||
pathList.push_back(data_path+GameConstants::folder_path_techs);
|
||||
if(userData != "") {
|
||||
pathList.push_back(userData + string(GameConstants::folder_path_techs));
|
||||
}
|
||||
break;
|
||||
case ptTilesets:
|
||||
pathList.push_back(GameConstants::folder_path_tilesets);
|
||||
pathList.push_back(data_path+GameConstants::folder_path_tilesets);
|
||||
if(userData != "") {
|
||||
pathList.push_back(userData + string(GameConstants::folder_path_tilesets));
|
||||
}
|
||||
break;
|
||||
case ptTutorials:
|
||||
pathList.push_back(GameConstants::folder_path_tutorials);
|
||||
pathList.push_back(data_path+GameConstants::folder_path_tutorials);
|
||||
if(userData != "") {
|
||||
pathList.push_back(userData + string(GameConstants::folder_path_tutorials));
|
||||
}
|
||||
|
@@ -34,7 +34,6 @@ enum ConfigType {
|
||||
cfgUserKeys
|
||||
};
|
||||
|
||||
|
||||
class Config {
|
||||
private:
|
||||
std::pair<Properties,Properties> properties;
|
||||
@@ -44,6 +43,9 @@ private:
|
||||
|
||||
static map<ConfigType,Config> configList;
|
||||
|
||||
static const char *glest_ini_filename;
|
||||
static const char *glestuser_ini_filename;
|
||||
|
||||
protected:
|
||||
Config();
|
||||
Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist);
|
||||
@@ -54,7 +56,7 @@ protected:
|
||||
|
||||
public:
|
||||
static Config &getInstance(std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame) ,
|
||||
std::pair<string,string> file = std::make_pair("glest.ini","glestuser.ini") ,
|
||||
std::pair<string,string> file = std::make_pair(glest_ini_filename,glestuser_ini_filename) ,
|
||||
std::pair<bool,bool> fileMustExist = std::make_pair(true,false) );
|
||||
void save(const string &path="");
|
||||
void reload();
|
||||
|
@@ -3,9 +3,9 @@
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "platform_util.h"
|
||||
#include "game_constants.h"
|
||||
#include "game_util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Sound;
|
||||
@@ -31,17 +33,19 @@ namespace Glest{ namespace Game{
|
||||
|
||||
// ===================== PUBLIC ========================
|
||||
|
||||
CoreData &CoreData::getInstance(){
|
||||
CoreData &CoreData::getInstance() {
|
||||
static CoreData coreData;
|
||||
return coreData;
|
||||
}
|
||||
|
||||
CoreData::~CoreData(){
|
||||
CoreData::~CoreData() {
|
||||
deleteValues(waterSounds.getSounds().begin(), waterSounds.getSounds().end());
|
||||
}
|
||||
|
||||
void CoreData::load(){
|
||||
const string dir="data/core";
|
||||
void CoreData::load() {
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
|
||||
const string dir = data_path + "data/core";
|
||||
Logger::getInstance().add("Core data");
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
@@ -49,7 +53,7 @@ void CoreData::load(){
|
||||
//textures
|
||||
backgroundTexture= renderer.newTexture2D(rsGlobal);
|
||||
backgroundTexture->setMipmap(false);
|
||||
backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga");
|
||||
backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga");
|
||||
|
||||
fireTexture= renderer.newTexture2D(rsGlobal);
|
||||
fireTexture->setFormat(Texture::fAlpha);
|
||||
@@ -61,9 +65,9 @@ void CoreData::load(){
|
||||
snowTexture->setFormat(Texture::fAlpha);
|
||||
snowTexture->getPixmap()->init(1);
|
||||
snowTexture->getPixmap()->load(dir+"/misc_textures/snow_particle.tga");
|
||||
|
||||
|
||||
customTexture= renderer.newTexture2D(rsGlobal);
|
||||
customTexture->getPixmap()->load("data/core/menu/textures/custom_texture.tga");
|
||||
customTexture->getPixmap()->load(dir+"/menu/textures/custom_texture.tga");
|
||||
|
||||
logoTexture= renderer.newTexture2D(rsGlobal);
|
||||
logoTexture->setMipmap(false);
|
||||
@@ -95,7 +99,7 @@ void CoreData::load(){
|
||||
buttonBigTexture= renderer.newTexture2D(rsGlobal);
|
||||
buttonBigTexture->setForceCompressionDisabled(true);
|
||||
buttonBigTexture->getPixmap()->load(dir+"/menu/textures/button_big.tga");
|
||||
|
||||
|
||||
//display font
|
||||
Config &config= Config::getInstance();
|
||||
string displayFontNamePrefix=config.getString("FontDisplayPrefix");
|
||||
@@ -116,9 +120,9 @@ void CoreData::load(){
|
||||
displayFontSmall= renderer.newFont(rsGlobal);
|
||||
displayFontSmall->setType(displayFontNameSmall);
|
||||
displayFontSmall->setSize(displayFontNameSmallSize);
|
||||
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontSmallName = [%s] displayFontSmallNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontNameSmall.c_str(),displayFontNameSmallSize);
|
||||
|
||||
|
||||
string menuFontNameNormalPrefix= config.getString("FontMenuNormalPrefix");
|
||||
string menuFontNameNormalPostfix= config.getString("FontMenuNormalPostfix");
|
||||
int menuFontNameNormalSize=computeFontSize(config.getInt("FontMenuNormalBaseSize"));
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include "logger.h"
|
||||
#include "util.h"
|
||||
#include "platform_util.h"
|
||||
#include "game_constants.h"
|
||||
#include "game_util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -36,7 +38,8 @@ Lang &Lang::getInstance(){
|
||||
void Lang::loadStrings(const string &language){
|
||||
this->language= language;
|
||||
strings.clear();
|
||||
strings.load("data/lang/"+language+".lng");
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
strings.load(data_path + "data/lang/"+language+".lng");
|
||||
}
|
||||
|
||||
void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenarioName){
|
||||
|
@@ -82,7 +82,10 @@ const char *GAME_ARGS[] = {
|
||||
"--sdl-info",
|
||||
"--lua-info",
|
||||
"--validate-techtrees",
|
||||
"--validate-factions"
|
||||
"--validate-factions",
|
||||
"--data-path",
|
||||
"--ini-path",
|
||||
"--log-path"
|
||||
|
||||
};
|
||||
|
||||
@@ -97,7 +100,10 @@ enum GAME_ARG_TYPE {
|
||||
GAME_ARG_SDL_INFO,
|
||||
GAME_ARG_LUA_INFO,
|
||||
GAME_ARG_VALIDATE_TECHTREES,
|
||||
GAME_ARG_VALIDATE_FACTIONS
|
||||
GAME_ARG_VALIDATE_FACTIONS,
|
||||
GAME_ARG_DATA_PATH,
|
||||
GAME_ARG_INI_PATH,
|
||||
GAME_ARG_LOG_PATH
|
||||
};
|
||||
|
||||
string runtimeErrorMsg = "";
|
||||
@@ -602,7 +608,13 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
||||
printf("\n \t\tWhere x is a comma-delimited list of factions to validate.");
|
||||
printf("\n \t\t*NOTE: leaving the list empty is the same as running");
|
||||
printf("\n \t\t%s",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
|
||||
printf("\n \t\texample: %s %s=tech,egypt",argv0,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]);
|
||||
printf("\n \t\texample: %s %s=tech,egypt",argv0,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]);
|
||||
printf("\n%s=x\t\t\tSets the game data path to x",GAME_ARGS[GAME_ARG_DATA_PATH]);
|
||||
printf("\n \t\texample: %s %s=/usr/local/game_data/",argv0,GAME_ARGS[GAME_ARG_DATA_PATH]);
|
||||
printf("\n%s=x\t\t\tSets the game ini path to x",GAME_ARGS[GAME_ARG_INI_PATH]);
|
||||
printf("\n \t\texample: %s %s=~/game_config/",argv0,GAME_ARGS[GAME_ARG_INI_PATH]);
|
||||
printf("\n%s=x\t\t\tSets the game logs path to x",GAME_ARGS[GAME_ARG_LOG_PATH]);
|
||||
printf("\n \t\texample: %s %s=~/game_logs/",argv0,GAME_ARGS[GAME_ARG_LOG_PATH]);
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
@@ -682,7 +694,80 @@ int glestMain(int argc, char** argv) {
|
||||
ExceptionHandler exceptionHandler;
|
||||
exceptionHandler.install( getCrashDumpFileName() );
|
||||
|
||||
try {
|
||||
try {
|
||||
// Setup path cache for files and folders used in the game
|
||||
std::map<string,string> &pathCache = CacheManager::getCachedItem< std::map<string,string> >(GameConstants::pathCacheLookupKey);
|
||||
|
||||
//GAME_ARG_DATA_PATH
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_DATA_PATH]) == true) {
|
||||
int foundParamIndIndex = -1;
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_DATA_PATH]) + string("="),&foundParamIndIndex);
|
||||
if(foundParamIndIndex < 0) {
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_DATA_PATH]),&foundParamIndIndex);
|
||||
}
|
||||
string customPath = argv[foundParamIndIndex];
|
||||
vector<string> paramPartTokens;
|
||||
Tokenize(customPath,paramPartTokens,"=");
|
||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||
string customPathValue = paramPartTokens[1];
|
||||
pathCache[GameConstants::path_data_CacheLookupKey]=customPathValue;
|
||||
printf("Using custom data path [%s]\n",customPathValue.c_str());
|
||||
}
|
||||
else {
|
||||
|
||||
printf("\nInvalid path specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
printParameterHelp(argv[0],foundInvalidArgs);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//GAME_ARG_INI_PATH
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_INI_PATH]) == true) {
|
||||
int foundParamIndIndex = -1;
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_INI_PATH]) + string("="),&foundParamIndIndex);
|
||||
if(foundParamIndIndex < 0) {
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_INI_PATH]),&foundParamIndIndex);
|
||||
}
|
||||
string customPath = argv[foundParamIndIndex];
|
||||
vector<string> paramPartTokens;
|
||||
Tokenize(customPath,paramPartTokens,"=");
|
||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||
string customPathValue = paramPartTokens[1];
|
||||
pathCache[GameConstants::path_ini_CacheLookupKey]=customPathValue;
|
||||
printf("Using custom ini path [%s]\n",customPathValue.c_str());
|
||||
}
|
||||
else {
|
||||
|
||||
printf("\nInvalid path specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
printParameterHelp(argv[0],foundInvalidArgs);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//GAME_ARG_LOG_PATH
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LOG_PATH]) == true) {
|
||||
int foundParamIndIndex = -1;
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_LOG_PATH]) + string("="),&foundParamIndIndex);
|
||||
if(foundParamIndIndex < 0) {
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_LOG_PATH]),&foundParamIndIndex);
|
||||
}
|
||||
string customPath = argv[foundParamIndIndex];
|
||||
vector<string> paramPartTokens;
|
||||
Tokenize(customPath,paramPartTokens,"=");
|
||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||
string customPathValue = paramPartTokens[1];
|
||||
pathCache[GameConstants::path_logs_CacheLookupKey]=customPathValue;
|
||||
printf("Using custom logs path [%s]\n",customPathValue.c_str());
|
||||
}
|
||||
else {
|
||||
|
||||
printf("\nInvalid path specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
printParameterHelp(argv[0],foundInvalidArgs);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::auto_ptr<FileCRCPreCacheThread> preCacheThread;
|
||||
Config &config = Config::getInstance();
|
||||
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
||||
@@ -699,33 +784,57 @@ int glestMain(int argc, char** argv) {
|
||||
SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled = config.getBool("DebugError","true");
|
||||
|
||||
string debugLogFile = config.getString("DebugLogFile","");
|
||||
if(getGameReadWritePath() != "") {
|
||||
debugLogFile = getGameReadWritePath() + debugLogFile;
|
||||
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
|
||||
debugLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugLogFile;
|
||||
}
|
||||
string debugWorldSynchLogFile = config.getString("DebugLogFileWorldSynch","");
|
||||
if(debugWorldSynchLogFile == "") {
|
||||
debugWorldSynchLogFile = debugLogFile;
|
||||
}
|
||||
}
|
||||
else {
|
||||
debugWorldSynchLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugWorldSynchLogFile;
|
||||
}
|
||||
|
||||
string debugPerformanceLogFile = config.getString("DebugLogFilePerformance","");
|
||||
if(debugPerformanceLogFile == "") {
|
||||
debugPerformanceLogFile = debugLogFile;
|
||||
}
|
||||
else {
|
||||
debugPerformanceLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugPerformanceLogFile;
|
||||
}
|
||||
|
||||
string debugNetworkLogFile = config.getString("DebugLogFileNetwork","");
|
||||
if(debugNetworkLogFile == "") {
|
||||
debugNetworkLogFile = debugLogFile;
|
||||
}
|
||||
else {
|
||||
debugNetworkLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugNetworkLogFile;
|
||||
}
|
||||
|
||||
string debugUnitCommandsLogFile = config.getString("DebugLogFileUnitCommands","");
|
||||
if(debugUnitCommandsLogFile == "") {
|
||||
debugUnitCommandsLogFile = debugLogFile;
|
||||
}
|
||||
else {
|
||||
debugUnitCommandsLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugUnitCommandsLogFile;
|
||||
}
|
||||
|
||||
string debugPathFinderLogFile = config.getString("DebugLogFilePathFinder","");
|
||||
if(debugUnitCommandsLogFile == "") {
|
||||
debugUnitCommandsLogFile = debugLogFile;
|
||||
}
|
||||
else {
|
||||
debugUnitCommandsLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugUnitCommandsLogFile;
|
||||
}
|
||||
|
||||
string debugLUALogFile = config.getString("DebugLogFileLUA","");
|
||||
if(debugLUALogFile == "") {
|
||||
debugLUALogFile = debugLogFile;
|
||||
}
|
||||
else {
|
||||
debugLUALogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugLUALogFile;
|
||||
}
|
||||
|
||||
string debugErrorLogFile = config.getString("DebugLogFileError","");
|
||||
|
||||
SystemFlags::getSystemSettingType(SystemFlags::debugSystem).debugLogFileName = debugLogFile;
|
||||
@@ -1052,11 +1161,12 @@ int glestMain(int argc, char** argv) {
|
||||
createDirectoryPaths(screenShotsPath);
|
||||
//printf("In [%s::%s Line: %d] screenShotsPath [%s]\n",__FILE__,__FUNCTION__,__LINE__,screenShotsPath.c_str());
|
||||
}
|
||||
|
||||
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
// Cache Player textures - START
|
||||
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
|
||||
for(int index = 0; index < GameConstants::maxPlayers; ++index) {
|
||||
string playerTexture = "data/core/faction_textures/faction" + intToStr(index) + ".tga";
|
||||
string playerTexture = data_path + "data/core/faction_textures/faction" + intToStr(index) + ".tga";
|
||||
if(fileExists(playerTexture) == true) {
|
||||
Texture2D *texture = Renderer::getInstance().newTexture2D(rsGlobal);
|
||||
texture->load(playerTexture);
|
||||
|
@@ -495,8 +495,8 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
|
||||
//log start
|
||||
Logger &logger= Logger::getInstance();
|
||||
string logFile = "glest.log";
|
||||
if(getGameReadWritePath() != "") {
|
||||
logFile = getGameReadWritePath() + logFile;
|
||||
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
|
||||
logFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + logFile;
|
||||
}
|
||||
logger.setFile(logFile);
|
||||
logger.clear();
|
||||
|
@@ -3,19 +3,19 @@
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#include "main_menu.h"
|
||||
#include "main_menu.h"
|
||||
|
||||
#include "renderer.h"
|
||||
#include "sound.h"
|
||||
#include "config.h"
|
||||
#include "program.h"
|
||||
#include "game_util.h"
|
||||
#include "game_util.h"
|
||||
#include "game.h"
|
||||
#include "platform_util.h"
|
||||
#include "sound_renderer.h"
|
||||
@@ -49,7 +49,7 @@ MainMenu::MainMenu(Program *program):
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
mouseX=100;
|
||||
mouseX=100;
|
||||
mouseY=100;
|
||||
|
||||
state= NULL;
|
||||
@@ -96,7 +96,7 @@ void MainMenu::render(){
|
||||
fps++;
|
||||
|
||||
renderer.clearBuffers();
|
||||
|
||||
|
||||
//3d
|
||||
renderer.reset3dMenu();
|
||||
|
||||
@@ -113,7 +113,7 @@ void MainMenu::render(){
|
||||
//if(config.getBool("DebugMode")){
|
||||
if(renderer.getShowDebugUI() == true) {
|
||||
renderer.renderText(
|
||||
"FPS: " + intToStr(lastFps),
|
||||
"FPS: " + intToStr(lastFps),
|
||||
coreData.getMenuFontNormal(), Vec3f(1.f), 10, 10, false);
|
||||
}
|
||||
|
||||
@@ -141,11 +141,11 @@ void MainMenu::mouseMove(int x, int y, const MouseState *ms){
|
||||
|
||||
//returns if exiting
|
||||
void MainMenu::mouseDownLeft(int x, int y){
|
||||
state->mouseClick(x, y, mbLeft);
|
||||
state->mouseClick(x, y, mbLeft);
|
||||
}
|
||||
|
||||
void MainMenu::mouseDownRight(int x, int y){
|
||||
state->mouseClick(x, y, mbRight);
|
||||
state->mouseClick(x, y, mbRight);
|
||||
}
|
||||
|
||||
void MainMenu::keyDown(char key){
|
||||
@@ -199,11 +199,12 @@ MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateNa
|
||||
Config &config = Config::getInstance();
|
||||
float configVolume = (config.getInt("SoundVolumeMusic") / 100.f);
|
||||
CoreData::getInstance().getMenuMusic()->setVolume(configVolume);
|
||||
|
||||
|
||||
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
|
||||
//camera
|
||||
XmlTree xmlTree;
|
||||
xmlTree.load("data/core/menu/menu.xml");
|
||||
xmlTree.load(data_path + "data/core/menu/menu.xml");
|
||||
const XmlNode *menuNode= xmlTree.getRootNode();
|
||||
const XmlNode *cameraNode= menuNode->getChild("camera");
|
||||
|
||||
@@ -226,8 +227,8 @@ MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateNa
|
||||
startRotation.y= rotationNode->getAttribute("y")->getFloatValue();
|
||||
startRotation.z= rotationNode->getAttribute("z")->getFloatValue();
|
||||
camera.setOrientation(Quaternion(EulerAngles(
|
||||
degToRad(startRotation.x),
|
||||
degToRad(startRotation.y),
|
||||
degToRad(startRotation.x),
|
||||
degToRad(startRotation.y),
|
||||
degToRad(startRotation.z))));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
182
source/glest_game/menu/menu_background.cpp
Normal file
182
source/glest_game/menu/menu_background.cpp
Normal file
@@ -0,0 +1,182 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#include "menu_background.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "renderer.h"
|
||||
#include "core_data.h"
|
||||
#include "config.h"
|
||||
#include "xml_parser.h"
|
||||
#include "util.h"
|
||||
#include "game_constants.h"
|
||||
#include "game_util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
using namespace Shared::Xml;
|
||||
using namespace Shared::Graphics;
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
// =====================================================
|
||||
// class MenuBackground
|
||||
// =====================================================
|
||||
|
||||
MenuBackground::MenuBackground(){
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
//load data
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
|
||||
XmlTree xmlTree;
|
||||
xmlTree.load(data_path + "data/core/menu/menu.xml");
|
||||
const XmlNode *menuNode= xmlTree.getRootNode();
|
||||
|
||||
//water
|
||||
const XmlNode *waterNode= menuNode->getChild("water");
|
||||
water= waterNode->getAttribute("value")->getBoolValue();
|
||||
if(water){
|
||||
waterHeight= waterNode->getAttribute("height")->getFloatValue();
|
||||
|
||||
//water texture
|
||||
waterTexture= renderer.newTexture2D(rsMenu);
|
||||
waterTexture->getPixmap()->init(4);
|
||||
waterTexture->getPixmap()->load(data_path + "data/core/menu/textures/water.tga");
|
||||
}
|
||||
|
||||
//fog
|
||||
const XmlNode *fogNode= menuNode->getChild("fog");
|
||||
fog= fogNode->getAttribute("value")->getBoolValue();
|
||||
if(fog){
|
||||
fogDensity= fogNode->getAttribute("density")->getFloatValue();
|
||||
}
|
||||
|
||||
//rain
|
||||
rain= menuNode->getChild("rain")->getAttribute("value")->getBoolValue();
|
||||
if(rain){
|
||||
RainParticleSystem *rps= new RainParticleSystem();
|
||||
rps->setSpeed(12.f/GameConstants::updateFps);
|
||||
rps->setEmissionRate(25);
|
||||
rps->setWind(-90.f, 4.f/GameConstants::updateFps);
|
||||
rps->setPos(Vec3f(0.f, 25.f, 0.f));
|
||||
rps->setColor(Vec4f(1.f, 1.f, 1.f, 0.2f));
|
||||
rps->setRadius(30.f);
|
||||
renderer.manageParticleSystem(rps, rsMenu);
|
||||
|
||||
for(int i=0; i<raindropCount; ++i){
|
||||
raindropStates[i]= random.randRange(0.f, 1.f);
|
||||
raindropPos[i]= computeRaindropPos();
|
||||
}
|
||||
}
|
||||
|
||||
//camera
|
||||
const XmlNode *cameraNode= menuNode->getChild("camera");
|
||||
|
||||
//position
|
||||
const XmlNode *positionNode= cameraNode->getChild("start-position");
|
||||
Vec3f startPosition;
|
||||
startPosition.x= positionNode->getAttribute("x")->getFloatValue();
|
||||
startPosition.y= positionNode->getAttribute("y")->getFloatValue();
|
||||
startPosition.z= positionNode->getAttribute("z")->getFloatValue();
|
||||
camera.setPosition(startPosition);
|
||||
|
||||
//rotation
|
||||
const XmlNode *rotationNode= cameraNode->getChild("start-rotation");
|
||||
Vec3f startRotation;
|
||||
startRotation.x= rotationNode->getAttribute("x")->getFloatValue();
|
||||
startRotation.y= rotationNode->getAttribute("y")->getFloatValue();
|
||||
startRotation.z= rotationNode->getAttribute("z")->getFloatValue();
|
||||
camera.setOrientation(Quaternion(EulerAngles(
|
||||
degToRad(startRotation.x),
|
||||
degToRad(startRotation.y),
|
||||
degToRad(startRotation.z))));
|
||||
|
||||
//load main model
|
||||
mainModel= renderer.newModel(rsMenu);
|
||||
mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d");
|
||||
|
||||
//models
|
||||
for(int i=0; i<5; ++i){
|
||||
characterModels[i]= renderer.newModel(rsMenu);
|
||||
characterModels[i]->load(data_path + "data/core/menu/about_models/character"+intToStr(i)+".g3d");
|
||||
}
|
||||
|
||||
//about position
|
||||
positionNode= cameraNode->getChild("about-position");
|
||||
aboutPosition.x= positionNode->getAttribute("x")->getFloatValue();
|
||||
aboutPosition.y= positionNode->getAttribute("y")->getFloatValue();
|
||||
aboutPosition.z= positionNode->getAttribute("z")->getFloatValue();
|
||||
rotationNode= cameraNode->getChild("about-rotation");
|
||||
|
||||
targetCamera= NULL;
|
||||
t= 0.f;
|
||||
fade= 0.f;
|
||||
anim= 0.f;
|
||||
}
|
||||
|
||||
void MenuBackground::setTargetCamera(const Camera *targetCamera){
|
||||
this->targetCamera= targetCamera;
|
||||
this->lastCamera= camera;
|
||||
t= 0.f;
|
||||
}
|
||||
|
||||
void MenuBackground::update(){
|
||||
|
||||
//rain drops
|
||||
for(int i=0; i<raindropCount; ++i){
|
||||
raindropStates[i]+= 1.f / GameConstants::updateFps;
|
||||
if(raindropStates[i]>=1.f){
|
||||
raindropStates[i]= 0.f;
|
||||
raindropPos[i]= computeRaindropPos();
|
||||
}
|
||||
}
|
||||
|
||||
if(targetCamera!=NULL){
|
||||
t+= ((0.01f+(1.f-t)/10.f)/20.f)*(60.f/GameConstants::updateFps);
|
||||
|
||||
//interpolate position
|
||||
camera.setPosition(lastCamera.getPosition().lerp(t, targetCamera->getPosition()));
|
||||
|
||||
//interpolate orientation
|
||||
Quaternion q= lastCamera.getOrientation().lerp(t, targetCamera->getOrientation());
|
||||
camera.setOrientation(q);
|
||||
|
||||
if(t>=1.f){
|
||||
targetCamera= NULL;
|
||||
t= 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
//fade
|
||||
if(fade<=1.f){
|
||||
fade+= 0.6f/GameConstants::updateFps;
|
||||
if(fade>1.f){
|
||||
fade= 1.f;
|
||||
}
|
||||
}
|
||||
|
||||
//animation
|
||||
anim+=(0.6f/GameConstants::updateFps)/5+random.randRange(0.f, (0.6f/GameConstants::updateFps)/5.f);
|
||||
if(anim>1.f){
|
||||
anim= 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
Vec2f MenuBackground::computeRaindropPos(){
|
||||
float f= static_cast<float>(meshSize);
|
||||
return Vec2f(random.randRange(-f, f), random.randRange(-f, f));
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -2116,8 +2116,8 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||
void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(getGameReadWritePath() != "") {
|
||||
fileName = getGameReadWritePath() + fileName;
|
||||
if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||
fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
|
||||
@@ -2174,8 +2174,8 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
||||
|
||||
GameSettings gameSettings;
|
||||
|
||||
if(getGameReadWritePath() != "") {
|
||||
fileName = getGameReadWritePath() + fileName;
|
||||
if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||
fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
|
||||
|
@@ -52,10 +52,10 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.end();
|
||||
networkManager.init(nrClient);
|
||||
|
||||
|
||||
serversSavedFile = serverFileName;
|
||||
if(getGameReadWritePath() != "") {
|
||||
serversSavedFile = getGameReadWritePath() + serversSavedFile;
|
||||
if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||
serversSavedFile = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + serversSavedFile;
|
||||
}
|
||||
|
||||
servers.load(serversSavedFile);
|
||||
@@ -119,7 +119,7 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
|
||||
}
|
||||
else{
|
||||
port=port +" ("+lang.get("StandardPort")+")";
|
||||
}
|
||||
}
|
||||
labelServerPort.setText(port);
|
||||
|
||||
labelStatus.registerGraphicComponent(containerName,"labelStatus");
|
||||
@@ -557,11 +557,11 @@ void MenuStateJoinGame::connectToServer()
|
||||
//save server ip
|
||||
config.setString("ServerIp", serverIp.getString());
|
||||
config.save();
|
||||
|
||||
|
||||
abortAutoFind = true;
|
||||
clientInterface->stopServerDiscovery();
|
||||
mainMenu->setState(new MenuStateConnectedGame(program, mainMenu));
|
||||
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
||||
}
|
||||
|
||||
|
@@ -37,7 +37,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
//modeinfos=list<ModeInfo> ();
|
||||
Shared::PlatformCommon::getFullscreenVideoModes(&modeInfos);
|
||||
activeInputLabel=NULL;
|
||||
|
||||
|
||||
int leftline=700;
|
||||
int rightline=700;
|
||||
int leftLabelStart=250;
|
||||
@@ -46,18 +46,18 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
int rightColumnStart=rightLabelStart+150;
|
||||
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);
|
||||
@@ -81,7 +81,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
listBoxVolumeFx.registerGraphicComponent(containerName,"listBoxVolumeFx");
|
||||
listBoxVolumeFx.init(leftColumnStart, leftline, 80);
|
||||
leftline-=30;
|
||||
|
||||
|
||||
labelVolumeAmbient.registerGraphicComponent(containerName,"labelVolumeAmbient");
|
||||
labelVolumeAmbient.init(leftLabelStart, leftline);
|
||||
|
||||
@@ -89,7 +89,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
listBoxVolumeAmbient.init(leftColumnStart, leftline, 80);
|
||||
labelVolumeAmbient.setText(lang.get("AmbientVolume"));
|
||||
leftline-=30;
|
||||
|
||||
|
||||
labelVolumeMusic.registerGraphicComponent(containerName,"labelVolumeMusic");
|
||||
labelVolumeMusic.init(leftLabelStart, leftline);
|
||||
|
||||
@@ -97,7 +97,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
listBoxVolumeMusic.init(leftColumnStart, leftline, 80);
|
||||
labelVolumeMusic.setText(lang.get("MusicVolume"));
|
||||
leftline-=30;
|
||||
|
||||
|
||||
for(int i=0; i<=100; i+=5){
|
||||
listBoxVolumeFx.pushBackItem(intToStr(i));
|
||||
listBoxVolumeAmbient.pushBackItem(intToStr(i));
|
||||
@@ -106,15 +106,15 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
listBoxVolumeFx.setSelectedItem(intToStr(config.getInt("SoundVolumeFx")/5*5));
|
||||
listBoxVolumeAmbient.setSelectedItem(intToStr(config.getInt("SoundVolumeAmbient")/5*5));
|
||||
listBoxVolumeMusic.setSelectedItem(intToStr(config.getInt("SoundVolumeMusic")/5*5));
|
||||
|
||||
|
||||
|
||||
|
||||
//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);
|
||||
@@ -123,36 +123,38 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
listBoxLang.registerGraphicComponent(containerName,"listBoxLang");
|
||||
listBoxLang.init(leftColumnStart, leftline, 170);
|
||||
vector<string> langResults;
|
||||
findAll("data/lang/*.lng", langResults, true);
|
||||
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
findAll(data_path + "data/lang/*.lng", langResults, true);
|
||||
if(langResults.empty()){
|
||||
throw runtime_error("There is no lang file");
|
||||
}
|
||||
listBoxLang.setItems(langResults);
|
||||
listBoxLang.setSelectedItem(config.getString("Lang"));
|
||||
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));
|
||||
}
|
||||
listFontSizeAdjustment.setSelectedItem(intToStr(config.getInt("FontSizeAdjustment")));
|
||||
|
||||
|
||||
leftline-=30;
|
||||
// server port
|
||||
labelServerPortLabel.registerGraphicComponent(containerName,"labelServerPortLabel");
|
||||
@@ -166,16 +168,16 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
else{
|
||||
port=port +" ("+lang.get("StandardPort")+")";
|
||||
}
|
||||
|
||||
|
||||
labelServerPort.setText(port);
|
||||
|
||||
|
||||
// external server port
|
||||
leftline-=30;
|
||||
|
||||
|
||||
labelPublishServerExternalPort.registerGraphicComponent(containerName,"labelPublishServerExternalPort");
|
||||
labelPublishServerExternalPort.init(leftLabelStart, leftline, 150);
|
||||
labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort"));
|
||||
|
||||
|
||||
listBoxPublishServerExternalPort.registerGraphicComponent(containerName,"listBoxPublishServerExternalPort");
|
||||
listBoxPublishServerExternalPort.init(leftColumnStart, leftline, 170);
|
||||
string supportExternalPortList = config.getString("MasterServerExternalPortList",intToStr(GameConstants::serverPort).c_str());
|
||||
@@ -194,7 +196,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
}
|
||||
}
|
||||
listBoxPublishServerExternalPort.setSelectedItemIndex(masterServerExternalPortSelectionIndex);
|
||||
|
||||
|
||||
// Video Section
|
||||
leftline-=30;
|
||||
labelVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
|
||||
@@ -211,7 +213,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
listBoxScreenModes.registerGraphicComponent(containerName,"listBoxScreenModes");
|
||||
listBoxScreenModes.init(leftColumnStart, leftline, 170);
|
||||
|
||||
string currentResString = config.getString("ScreenWidth") + "x" +
|
||||
string currentResString = config.getString("ScreenWidth") + "x" +
|
||||
config.getString("ScreenHeight") + "-" +
|
||||
intToStr(config.getInt("ColorBits"));
|
||||
bool currentResolutionFound = false;
|
||||
@@ -226,8 +228,8 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
}
|
||||
listBoxScreenModes.setSelectedItem(currentResString);
|
||||
leftline-=30;
|
||||
|
||||
|
||||
|
||||
|
||||
//FullscreenWindowed
|
||||
labelFullscreenWindowed.registerGraphicComponent(containerName,"labelFullscreenWindowed");
|
||||
labelFullscreenWindowed.init(leftLabelStart, leftline);
|
||||
@@ -239,7 +241,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
listBoxFullscreenWindowed.pushBackItem(lang.get("Yes"));
|
||||
listBoxFullscreenWindowed.setSelectedItemIndex(clamp(config.getBool("Windowed"), false, true));
|
||||
leftline-=30;
|
||||
|
||||
|
||||
//filter
|
||||
labelFilter.registerGraphicComponent(containerName,"labelFilter");
|
||||
labelFilter.init(leftLabelStart, leftline);
|
||||
@@ -251,7 +253,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
listBoxFilter.pushBackItem("Trilinear");
|
||||
listBoxFilter.setSelectedItem(config.getString("Filter"));
|
||||
leftline-=30;
|
||||
|
||||
|
||||
//shadows
|
||||
labelShadows.registerGraphicComponent(containerName,"labelShadows");
|
||||
labelShadows.init(leftLabelStart, leftline);
|
||||
@@ -265,7 +267,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
string str= config.getString("Shadows");
|
||||
listBoxShadows.setSelectedItemIndex(clamp(Renderer::strToShadows(str), 0, Renderer::sCount-1));
|
||||
leftline-=30;
|
||||
|
||||
|
||||
//textures 3d
|
||||
labelTextures3D.registerGraphicComponent(containerName,"labelTextures3D");
|
||||
labelTextures3D.init(leftLabelStart, leftline);
|
||||
@@ -277,7 +279,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
listBoxTextures3D.pushBackItem(lang.get("Yes"));
|
||||
listBoxTextures3D.setSelectedItemIndex(clamp(config.getBool("Textures3D"), false, true));
|
||||
leftline-=30;
|
||||
|
||||
|
||||
//lights
|
||||
labelLights.registerGraphicComponent(containerName,"labelLights");
|
||||
labelLights.init(leftLabelStart, leftline);
|
||||
@@ -290,7 +292,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
}
|
||||
listBoxLights.setSelectedItemIndex(clamp(config.getInt("MaxLights")-1, 0, 7));
|
||||
leftline-=30;
|
||||
|
||||
|
||||
//unit particles
|
||||
labelUnitParticles.registerGraphicComponent(containerName,"labelUnitParticles");
|
||||
labelUnitParticles.init(leftLabelStart,leftline);
|
||||
@@ -317,7 +319,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
|
||||
// buttons
|
||||
buttonOk.registerGraphicComponent(containerName,"buttonOk");
|
||||
buttonOk.init(200, buttonRowPos, 100);
|
||||
buttonOk.init(200, buttonRowPos, 100);
|
||||
buttonOk.setText(lang.get("Ok"));
|
||||
buttonAbort.setText(lang.get("Abort"));
|
||||
|
||||
@@ -378,7 +380,7 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
}
|
||||
else if(buttonOk.mouseClick(x, y)){
|
||||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
|
||||
|
||||
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight")+"-"+intToStr(config.getInt("ColorBits"));
|
||||
string selectedResolution=listBoxScreenModes.getSelectedItem();
|
||||
if(currentResolution!=selectedResolution){
|
||||
@@ -395,7 +397,7 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
showMessageBox(lang.get("RestartNeeded"), lang.get("FontSizeAdjustmentChanged"), false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool currentFullscreenWindowed=config.getBool("Windowed");
|
||||
bool selectedFullscreenWindowed = (listBoxFullscreenWindowed.getSelectedItemIndex() != 0);
|
||||
if(currentFullscreenWindowed!=selectedFullscreenWindowed){
|
||||
@@ -404,7 +406,7 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
showMessageBox(lang.get("RestartNeeded"), lang.get("DisplaySettingsChanged"), false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
saveConfig();
|
||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||
}
|
||||
@@ -592,7 +594,7 @@ void MenuStateOptions::saveConfig(){
|
||||
CoreData::getInstance().getMenuMusic()->setVolume(strToInt(listBoxVolumeMusic.getSelectedItem())/100.f);
|
||||
config.setString("SoundVolumeMusic", listBoxVolumeMusic.getSelectedItem());
|
||||
config.setString("MasterServerExternalPort", listBoxPublishServerExternalPort.getSelectedItem());
|
||||
|
||||
|
||||
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight");
|
||||
string selectedResolution=listBoxScreenModes.getSelectedItem();
|
||||
if(currentResolution!=selectedResolution){
|
||||
@@ -605,7 +607,7 @@ void MenuStateOptions::saveConfig(){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
config.save();
|
||||
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
|
@@ -80,7 +80,8 @@ void Faction::init(
|
||||
}
|
||||
|
||||
texture= Renderer::getInstance().newTexture2D(rsGame);
|
||||
texture->load("data/core/faction_textures/faction"+intToStr(startLocationIndex)+".tga");
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
texture->load(data_path + "data/core/faction_textures/faction"+intToStr(startLocationIndex)+".tga");
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
@@ -181,16 +182,16 @@ bool Faction::reqsOk(const RequirableType *rt) const{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(dynamic_cast<const UnitType *>(rt) != NULL ) {
|
||||
const UnitType *producedUnitType=(UnitType *) rt;
|
||||
const UnitType *producedUnitType=(UnitType *) rt;
|
||||
if(producedUnitType != NULL && producedUnitType->getMaxUnitCount() > 0) {
|
||||
if(producedUnitType->getMaxUnitCount() <= getCountForMaxUnitCount(producedUnitType)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -155,7 +155,7 @@ void World::init(Game *game, bool createUnits){
|
||||
if(fogOfWarOverride == false) {
|
||||
fogOfWar = gs->getFogOfWar();
|
||||
}
|
||||
|
||||
|
||||
initFactionTypes(gs);
|
||||
initCells(fogOfWar); //must be done after knowing faction number and dimensions
|
||||
initMap();
|
||||
@@ -965,7 +965,7 @@ void World::initFactionTypes(GameSettings *gs) {
|
||||
stats.setPlayerName(i,gs->getNetworkPlayerName(i));
|
||||
stats.setPlayerColor(i,getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0));
|
||||
}
|
||||
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(factions.size() > 0) {
|
||||
@@ -1355,10 +1355,10 @@ int World::getNextUnitId(Faction *faction) {
|
||||
}
|
||||
|
||||
std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
|
||||
|
||||
|
||||
string debugWorldLogFile = Config::getInstance().getString("DebugWorldLogFile","debugWorld.log");
|
||||
if(getGameReadWritePath() != "") {
|
||||
debugWorldLogFile = getGameReadWritePath() + debugWorldLogFile;
|
||||
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
|
||||
debugWorldLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugWorldLogFile;
|
||||
}
|
||||
|
||||
if(consoleBasicInfoOnly == true) {
|
||||
@@ -1369,7 +1369,7 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
|
||||
for(int i = 0; i < getFactionCount(); ++i) {
|
||||
std::cout << "Faction detail for index: " << i << std::endl;
|
||||
std::cout << "--------------------------" << std::endl;
|
||||
|
||||
|
||||
std::cout << "FactionName = " << getFaction(i)->getType()->getName() << std::endl;
|
||||
std::cout << "FactionIndex = " << intToStr(getFaction(i)->getIndex()) << std::endl;
|
||||
std::cout << "teamIndex = " << intToStr(getFaction(i)->getTeam()) << std::endl;
|
||||
|
@@ -73,8 +73,8 @@ Profiler::~Profiler(){
|
||||
rootSection->stop();
|
||||
|
||||
string profileLog = "profiler.log";
|
||||
if(getGameReadWritePath() != "") {
|
||||
profileLog = getGameReadWritePath() + profileLog;
|
||||
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
|
||||
profileLog = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + profileLog;
|
||||
}
|
||||
FILE *f= fopen(profileLog.c_str(), "w");
|
||||
if(f==NULL)
|
||||
|
Reference in New Issue
Block a user