- allow for multiple preview / loading / hud textures for different resolutions
This commit is contained in:
parent
41671ac997
commit
5fd8b121a9
|
@ -528,9 +528,55 @@ string Game::extractFactionLogoFile(bool &loadingImageUsed, string factionName,
|
||||||
endPathWithSlash(path);
|
endPathWithSlash(path);
|
||||||
|
|
||||||
vector<string> loadScreenList;
|
vector<string> loadScreenList;
|
||||||
findAll(path + factionLogoFilter, loadScreenList, false, false);
|
string logoFullPathFilter = path + factionLogoFilter;
|
||||||
|
findAll(logoFullPathFilter, loadScreenList, false, false);
|
||||||
if(loadScreenList.empty() == false) {
|
if(loadScreenList.empty() == false) {
|
||||||
string factionLogo = path + loadScreenList[0];
|
int bestLogoIndex = 0;
|
||||||
|
|
||||||
|
if(loadScreenList.size() > 1 && EndsWith(factionLogoFilter, ".xml") == false) {
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nLooking for best logo from a list of: " MG_SIZE_T_SPECIFIER " using filter: [%s]\n",loadScreenList.size(),logoFullPathFilter.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
int bestMinWidthDiff = INT_MAX;
|
||||||
|
int bestMinHeightDiff = INT_MAX;
|
||||||
|
// Now find the best texture for our screen
|
||||||
|
// Texture2D *result = preloadTexture(logoFilename);
|
||||||
|
for(unsigned int logoIndex = 0; logoIndex < loadScreenList.size(); ++logoIndex) {
|
||||||
|
string factionLogo = path + loadScreenList[logoIndex];
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,factionLogo.c_str());
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Looking for best logo: %u [%s]\n",logoIndex,factionLogo.c_str());
|
||||||
|
|
||||||
|
if(fileExists(factionLogo) == true) {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] found loading screen '%s'\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,factionLogo.c_str());
|
||||||
|
|
||||||
|
Texture2D *checkLogo = Renderer::preloadTexture(factionLogo);
|
||||||
|
if(checkLogo != NULL) {
|
||||||
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
int minWidthDifference = abs(metrics.getScreenW() - checkLogo->getPixmapConst()->getW());
|
||||||
|
int minHeightDifference = abs(metrics.getScreenH() - checkLogo->getPixmapConst()->getH());
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Logo info: %d x %d (%d,%d)\n",checkLogo->getPixmapConst()->getW(),checkLogo->getPixmapConst()->getH(),minWidthDifference,minHeightDifference);
|
||||||
|
|
||||||
|
if(minWidthDifference < bestMinWidthDiff) {
|
||||||
|
bestMinWidthDiff = minWidthDifference;
|
||||||
|
|
||||||
|
bestLogoIndex = logoIndex;
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 New best logo is [%s]\n",factionLogo.c_str());
|
||||||
|
}
|
||||||
|
else if(minWidthDifference == bestMinWidthDiff &&
|
||||||
|
minHeightDifference < bestMinHeightDiff) {
|
||||||
|
bestMinHeightDiff = minHeightDifference;
|
||||||
|
|
||||||
|
bestLogoIndex = logoIndex;
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 New best logo is [%s]\n",factionLogo.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string factionLogo = path + loadScreenList[bestLogoIndex];
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,factionLogo.c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,factionLogo.c_str());
|
||||||
|
|
||||||
if(fileExists(factionLogo) == true) {
|
if(fileExists(factionLogo) == true) {
|
||||||
|
@ -698,7 +744,7 @@ void Game::loadHudTexture(const GameSettings *settings)
|
||||||
vector<string> hudList;
|
vector<string> hudList;
|
||||||
string path= currentPath + techName + "/" + "factions" + "/" + factionName;
|
string path= currentPath + techName + "/" + "factions" + "/" + factionName;
|
||||||
endPathWithSlash(path);
|
endPathWithSlash(path);
|
||||||
findAll(path + "hud.*", hudList, false, false);
|
findAll(path + GameConstants::HUD_SCREEN_FILE_FILTER, hudList, false, false);
|
||||||
if(hudList.empty() == false){
|
if(hudList.empty() == false){
|
||||||
for(unsigned int hudIdx = 0; hudFound == false && hudIdx < hudList.size(); ++hudIdx) {
|
for(unsigned int hudIdx = 0; hudFound == false && hudIdx < hudList.size(); ++hudIdx) {
|
||||||
string hudImageFileName= path + hudList[hudIdx];
|
string hudImageFileName= path + hudList[hudIdx];
|
||||||
|
@ -800,7 +846,7 @@ vector<Texture2D *> Game::processTech(string techName) {
|
||||||
"",
|
"",
|
||||||
techName,
|
techName,
|
||||||
NULL,
|
NULL,
|
||||||
"preview_screen.*");
|
GameConstants::PREVIEW_SCREEN_FILE_FILTER);
|
||||||
|
|
||||||
if(factionLogo == "") {
|
if(factionLogo == "") {
|
||||||
factionLogo = Game::extractFactionLogoFile(
|
factionLogo = Game::extractFactionLogoFile(
|
||||||
|
@ -809,7 +855,7 @@ vector<Texture2D *> Game::processTech(string techName) {
|
||||||
"",
|
"",
|
||||||
techName,
|
techName,
|
||||||
NULL,
|
NULL,
|
||||||
"loading_screen.*");
|
GameConstants::LOADING_SCREEN_FILE_FILTER);
|
||||||
}
|
}
|
||||||
if(factionLogo != "") {
|
if(factionLogo != "") {
|
||||||
Texture2D *texture = Renderer::preloadTexture(factionLogo);
|
Texture2D *texture = Renderer::preloadTexture(factionLogo);
|
||||||
|
|
|
@ -277,11 +277,11 @@ public:
|
||||||
void endPerformanceTimer();
|
void endPerformanceTimer();
|
||||||
Vec2i getPerformanceTimerResults();
|
Vec2i getPerformanceTimerResults();
|
||||||
|
|
||||||
static Texture2D * findFactionLogoTexture(const GameSettings *settings, Logger *logger=NULL,string factionLogoFilter="loading_screen.*", bool useTechDefaultIfFilterNotFound=true);
|
static Texture2D * findFactionLogoTexture(const GameSettings *settings, Logger *logger=NULL,string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER, bool useTechDefaultIfFilterNotFound=true);
|
||||||
static string findFactionLogoFile(const GameSettings *settings, Logger *logger=NULL, string factionLogoFilter="loading_screen.*");
|
static string findFactionLogoFile(const GameSettings *settings, Logger *logger=NULL, string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER);
|
||||||
static string extractScenarioLogoFile(const GameSettings *settings, string &result, bool &loadingImageUsed, Logger *logger=NULL, string factionLogoFilter="loading_screen.*");
|
static string extractScenarioLogoFile(const GameSettings *settings, string &result, bool &loadingImageUsed, Logger *logger=NULL, string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER);
|
||||||
static string extractFactionLogoFile(bool &loadingImageUsed, string factionName, string scenarioDir, string techName, Logger *logger=NULL, string factionLogoFilter="loading_screen.*");
|
static string extractFactionLogoFile(bool &loadingImageUsed, string factionName, string scenarioDir, string techName, Logger *logger=NULL, string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER);
|
||||||
static string extractTechLogoFile(string scenarioDir, string techName, bool &loadingImageUsed, Logger *logger=NULL,string factionLogoFilter="loading_screen.*");
|
static string extractTechLogoFile(string scenarioDir, string techName, bool &loadingImageUsed, Logger *logger=NULL,string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER);
|
||||||
|
|
||||||
void loadHudTexture(const GameSettings *settings);
|
void loadHudTexture(const GameSettings *settings);
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,13 @@ public:
|
||||||
static const float megaMultiplier;
|
static const float megaMultiplier;
|
||||||
//
|
//
|
||||||
|
|
||||||
|
static const char * LOADING_SCREEN_FILE;
|
||||||
|
static const char * LOADING_SCREEN_FILE_FILTER;
|
||||||
|
static const char * PREVIEW_SCREEN_FILE;
|
||||||
|
static const char * PREVIEW_SCREEN_FILE_FILTER;
|
||||||
|
static const char * HUD_SCREEN_FILE;
|
||||||
|
static const char * HUD_SCREEN_FILE_FILTER;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PathType {
|
enum PathType {
|
||||||
|
|
|
@ -56,6 +56,13 @@ const char *GameConstants::factionPreviewTextureCacheLookupKey = "factionPrevie
|
||||||
const char *GameConstants::characterMenuScreenPositionListCacheLookupKey = "characterMenuScreenPositionListCache";
|
const char *GameConstants::characterMenuScreenPositionListCacheLookupKey = "characterMenuScreenPositionListCache";
|
||||||
const char *GameConstants::application_name = "MegaGlest";
|
const char *GameConstants::application_name = "MegaGlest";
|
||||||
|
|
||||||
|
const char * GameConstants::LOADING_SCREEN_FILE = "loading_screen";
|
||||||
|
const char * GameConstants::LOADING_SCREEN_FILE_FILTER = "loading_screen*.*";
|
||||||
|
const char * GameConstants::PREVIEW_SCREEN_FILE = "preview_screen";
|
||||||
|
const char * GameConstants::PREVIEW_SCREEN_FILE_FILTER = "preview_screen*.*";
|
||||||
|
const char * GameConstants::HUD_SCREEN_FILE = "hud";
|
||||||
|
const char * GameConstants::HUD_SCREEN_FILE_FILTER = "hud*.*";
|
||||||
|
|
||||||
|
|
||||||
const char *GameConstants::pathCacheLookupKey = "pathCache_";
|
const char *GameConstants::pathCacheLookupKey = "pathCache_";
|
||||||
const char *GameConstants::path_data_CacheLookupKey = "data";
|
const char *GameConstants::path_data_CacheLookupKey = "data";
|
||||||
|
|
|
@ -2058,9 +2058,9 @@ void runTechValidationForPath(string techPath, string techName,
|
||||||
replaceAll(file, "//", "/");
|
replaceAll(file, "//", "/");
|
||||||
replaceAll(file, "\\\\", "\\");
|
replaceAll(file, "\\\\", "\\");
|
||||||
|
|
||||||
if( file.find("loading_screen") != string::npos ||
|
if( file.find(GameConstants::LOADING_SCREEN_FILE) != string::npos ||
|
||||||
file.find("preview_screen") != string::npos ||
|
file.find(GameConstants::PREVIEW_SCREEN_FILE) != string::npos ||
|
||||||
file.find("hud") != string::npos) {
|
file.find(GameConstants::HUD_SCREEN_FILE) != string::npos) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(file.find("/factions/") != string::npos) {
|
if(file.find("/factions/") != string::npos) {
|
||||||
|
|
|
@ -4514,7 +4514,7 @@ void MenuStateConnectedGame::initFactionPreview(const GameSettings *gameSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
if(factionVideo == NULL) {
|
if(factionVideo == NULL) {
|
||||||
string factionLogo = Game::findFactionLogoFile(gameSettings, NULL,"preview_screen.*");
|
string factionLogo = Game::findFactionLogoFile(gameSettings, NULL,GameConstants::PREVIEW_SCREEN_FILE_FILTER);
|
||||||
if(factionLogo == "") {
|
if(factionLogo == "") {
|
||||||
factionLogo = Game::findFactionLogoFile(gameSettings, NULL);
|
factionLogo = Game::findFactionLogoFile(gameSettings, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2798,7 +2798,7 @@ void MenuStateCustomGame::initFactionPreview(const GameSettings *gameSettings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(factionVideo == NULL) {
|
if(factionVideo == NULL) {
|
||||||
string factionLogo = Game::findFactionLogoFile(gameSettings, NULL,"preview_screen.*");
|
string factionLogo = Game::findFactionLogoFile(gameSettings, NULL,GameConstants::PREVIEW_SCREEN_FILE_FILTER);
|
||||||
if(factionLogo == "") {
|
if(factionLogo == "") {
|
||||||
factionLogo = Game::findFactionLogoFile(gameSettings, NULL);
|
factionLogo = Game::findFactionLogoFile(gameSettings, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user