- changed default command display text to be same as 3.4 but with support to override and show queued commands up to a max of: MaxQueuedCommandDisplayCount=x where x is max queued text to show

- added ini support on linux so it by default looks for glest.ini and glestkeys.ini in /usr/share/megaglest and /usr/local/share/megaglest first
This commit is contained in:
Mark Vejvoda 2011-05-01 03:12:36 +00:00
parent 5ef1313296
commit 700e768b0f
4 changed files with 70 additions and 23 deletions

View File

@ -62,6 +62,8 @@ const char *GameConstants::path_logs_CacheLookupKey = "logs";
const char *Config::glest_ini_filename = "glest.ini";
const char *Config::glestuser_ini_filename = "glestuser.ini";
const char *Config::glestkeys_ini_filename = "glestkeys.ini";
const char *Config::glestuserkeys_ini_filename = "glestuserkeys.ini";
// =====================================================
// class Config
@ -72,31 +74,62 @@ const string defaultNotFoundValue = "~~NOT FOUND~~";
map<ConfigType,Config> Config::configList;
Config::Config() {
fileLoaded.first = false;
fileLoaded.second = false;
cfgType.first = cfgMainGame;
cfgType.second = cfgUserGame;
fileName.first = "";
fileName.second = "";
fileNameParameter.first = "";
fileNameParameter.second = "";
fileLoaded.first = false;
fileLoaded.second = false;
fileLoaded.first = false;
fileLoaded.second = false;
cfgType.first = cfgMainGame;
cfgType.second = cfgUserGame;
fileName.first = "";
fileName.second = "";
fileNameParameter.first = "";
fileNameParameter.second = "";
fileLoaded.first = false;
fileLoaded.second = false;
}
Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist) {
fileLoaded.first = false;
fileLoaded.second = false;
cfgType = type;
fileName = file;
fileNameParameter = file;
fileLoaded.first = false;
fileLoaded.second = false;
cfgType = type;
fileName = file;
fileNameParameter = file;
if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
fileName.first = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName.first;
fileName.second = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName.second;
}
// Look in standard linux shared paths for ini files
#if defined(__linux__)
else if(cfgType.first == cfgMainGame && cfgType.second == cfgUserGame &&
fileName.first == glest_ini_filename && fileName.second == glestuser_ini_filename) {
string linuxPath = "/usr/share/megaglest/";
if(fileExists(linuxPath + fileName.first) == true) {
fileName.first = linuxPath + fileName.first;
fileName.second = linuxPath + fileName.second;
}
else {
linuxPath = "/usr/local/share/megaglest/";
if(fileExists(linuxPath + fileName.first) == true) {
fileName.first = linuxPath + fileName.first;
fileName.second = linuxPath + fileName.second;
}
}
}
else if(cfgType.first == cfgMainKeys && cfgType.second == cfgUserKeys &&
fileName.first == glestkeys_ini_filename && fileName.second == glestuserkeys_ini_filename) {
string linuxPath = "/usr/share/megaglest/";
if(fileExists(linuxPath + fileName.first) == true) {
fileName.first = linuxPath + fileName.first;
fileName.second = linuxPath + fileName.second;
}
else {
linuxPath = "/usr/local/share/megaglest/";
if(fileExists(linuxPath + fileName.first) == true) {
fileName.first = linuxPath + fileName.first;
fileName.second = linuxPath + fileName.second;
}
}
}
#endif
if(fileMustExist.first == true && fileExists(fileName.first) == false) {
string currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath());
fileName.first = currentpath + fileName.first;

View File

@ -48,6 +48,10 @@ private:
static const char *glest_ini_filename;
static const char *glestuser_ini_filename;
public:
static const char *glestkeys_ini_filename;
static const char *glestuserkeys_ini_filename;
protected:
Config();
Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist);

View File

@ -2169,7 +2169,7 @@ int glestMain(int argc, char** argv) {
// Setup hotkeys from key ini files
Config &configKeys = Config::getInstance(
std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys),
std::pair<string,string>("glestkeys.ini","glestuserkeys.ini"),
std::pair<string,string>(Config::glestkeys_ini_filename,Config::glestuserkeys_ini_filename),
std::pair<bool,bool>(true,false));
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -235,7 +235,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, const UnitType
Config &config= Config::getInstance();
showUnitParticles = config.getBool("UnitParticles","true");
maxQueuedCommandDisplayCount = config.getInt("MaxQueuedCommandDisplayCount","3");
maxQueuedCommandDisplayCount = config.getInt("MaxQueuedCommandDisplayCount","1");
lastPos= pos;
progress= 0;
@ -1472,15 +1472,25 @@ string Unit::getDesc() const {
//command info
if(commands.empty() == false) {
str += "\n" + lang.get("OrdersOnQueue") + ": " + intToStr(commands.size());
Commands::const_iterator it= commands.begin();
for(unsigned int i = 0; i < min((size_t)maxQueuedCommandDisplayCount,commands.size()); ++i) {
const CommandType *ct = (*it)->getCommandType();
if(commands.size() == 1) {
str += "\n" + ct->getName();
if(maxQueuedCommandDisplayCount == 1) {
str+= "\n" + ct->getName();
if(commands.size()>1){
str+="\n"+lang.get("OrdersOnQueue")+": "+intToStr(commands.size());
}
}
else {
str += "\n#" + intToStr(i+1) + " " + ct->getName();
if(commands.size() == 1) {
str += "\n" + ct->getName();
}
else {
if(i == 0) {
str += "\n" + lang.get("OrdersOnQueue") + ": " + intToStr(commands.size());
}
str += "\n#" + intToStr(i+1) + " " + ct->getName();
}
}
it++;
}