1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Cache the selected graphic resolution instead of looking it up many times.

This commit is contained in:
Frank Zago
2011-08-24 04:13:45 +00:00
parent 839c437fbc
commit 4cad2f4587
3 changed files with 10 additions and 8 deletions

View File

@@ -137,7 +137,7 @@ static void setGem(AdventureMapConfig &ac, const int gem, const JsonNode &g)
ac.gemG.push_back(g["graphic"].String());
}
CConfigHandler::CConfigHandler(void)
CConfigHandler::CConfigHandler(void): current(NULL)
{
}
@@ -250,9 +250,6 @@ void config::CConfigHandler::init()
cc.screenx = cc.resx;
cc.screeny = cc.resy;
}
}
GUIOptions * config::CConfigHandler::go()
{
return &guiOptions[std::pair<int,int>(cc.resx,cc.resy)];
SetResolution(cc.resx, cc.resy);
}

View File

@@ -79,13 +79,19 @@ namespace config
/// Handles adventure map screen settings
class CConfigHandler
{
GUIOptions *current; // pointer to current gui options
public:
ClientConfig cc;
std::map<std::pair<int,int>, GUIOptions > guiOptions;
GUIOptions *go(); //return pointer to gui options appropriate for used screen resolution
void init();
CConfigHandler(void); //c-tor
~CConfigHandler(void); //d-tor
GUIOptions *go() { return current; };
void SetResolution(int x, int y) {
current = &guiOptions[std::pair<int,int>(x, y)];
}
};
}
extern config::CConfigHandler conf;

View File

@@ -430,8 +430,7 @@ void processCommand(const std::string &message)
else
{
for(j=conf.guiOptions.begin(); j!=conf.guiOptions.end() && hlp++<i; j++); //move j to the i-th resolution info
conf.cc.resx = j->first.first;
conf.cc.resy = j->first.second;
conf.SetResolution(j->first.first, j->first.second);
conf.cc.screenx = j->first.first;
conf.cc.screeny = j->first.second;
tlog0 << "Screen resolution set to " << conf.cc.resx << " x " << conf.cc.resy <<". It will be aplied when the game starts.\n";