just put a hud.png in a faction dir and you got a HUD overlay

This commit is contained in:
Titus Tscharntke 2011-06-09 00:59:03 +00:00
parent d7e4d972a3
commit bc2c59a82a
7 changed files with 70 additions and 1 deletions

View File

@ -353,6 +353,48 @@ string Game::extractTechLogoFile(string scenarioDir, string techName,
return result;
}
void Game::loadHudTexture(const GameSettings *settings)
{
string factionName = "";
string techName = settings->getTech();
string scenarioDir =settings->getScenarioDir();
for(int i=0; i < settings->getFactionCount(); ++i ) {
if(settings->getFactionControl(i) == ctHuman){
factionName= settings->getFactionTypeName(i);
break;
}
}
if(factionName != ""){
Config &config= Config::getInstance();
vector<string> pathList= config.getPathListForType(ptTechs, scenarioDir);
for(int idx= 0; idx < pathList.size(); idx++){
string currentPath= pathList[idx];
endPathWithSlash(currentPath);
vector<string> hudList;
string path= currentPath + techName + "/" + "factions" + "/" + factionName;
endPathWithSlash(path);
findAll(path + "hud.*", hudList, false, false);
if(hudList.size() > 0){
string hudImageFileName= path + hudList[0];
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled)
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for a HUD '%s'\n",__FILE__,__FUNCTION__,__LINE__,hudImageFileName.c_str());
if(fileExists(hudImageFileName) == true){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled)
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] found HUD image '%s'\n",__FILE__,__FUNCTION__,__LINE__,hudImageFileName.c_str());
Texture2D* texture= Renderer::findFactionLogoTexture(hudImageFileName);
gui.setHudTexture(texture);
//printf("Hud texture found! \n");
break;
}
}
}
}
}
string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,
string factionLogoFilter) {
string result = "";
@ -483,6 +525,8 @@ void Game::load(LoadGameItem loadTypes) {
SDL_PumpEvents();
}
loadHudTexture(&gameSettings);
string scenarioDir = "";
if(gameSettings.getScenarioDir() != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -1840,6 +1884,9 @@ void Game::render2d(){
//init
renderer.reset2d();
//HUD
renderer.renderHud();
//display
renderer.renderDisplay();

View File

@ -183,6 +183,7 @@ public:
static string extractFactionLogoFile(bool &loadingImageUsed, string factionName, string scenarioDir, string techName, Logger *logger=NULL, string factionLogoFilter="loading_screen.*");
static string extractTechLogoFile(string scenarioDir, string techName, bool &loadingImageUsed, Logger *logger=NULL,string factionLogoFilter="loading_screen.*");
void loadHudTexture(const GameSettings *settings);
bool getGameOver() { return gameOver; }
bool hasGameStarted() { return gameStarted;}

View File

@ -3044,6 +3044,15 @@ void Renderer::renderWaterEffects(){
assertGl();
}
void Renderer::renderHud(){
const Metrics &metrics= Metrics::getInstance();
const World *world= game->getWorld();
Texture2D *hudTexture=game->getGui()->getHudTexture();
if(hudTexture!=NULL){
renderTextureQuad(0, 0, metrics.getVirtualW(), metrics.getVirtualH(),hudTexture,1.0f);
}
}
void Renderer::renderMinimap(){
const World *world= game->getWorld();
const Minimap *minimap= world->getMinimap();

View File

@ -382,6 +382,7 @@ public:
void renderSelectionEffects();
void renderWaterEffects();
void renderHud();
void renderMinimap();
void renderDisplay();
void renderMenuBackground(const MenuBackground *menuBackground);

View File

@ -110,6 +110,7 @@ Gui::Gui(){
selectionCalculationFrameSkip=10;
minQuadSize=20;
selectedResourceObject=NULL;
hudTexture=NULL;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
}
@ -125,6 +126,10 @@ void Gui::init(Game *game){
void Gui::end(){
selection.clear();
if(hudTexture != NULL) {
Renderer::getInstance().endTexture(rsGlobal, hudTexture, false);
}
hudTexture = NULL;
}
// ==================== get ====================

View File

@ -139,6 +139,8 @@ private:
CardinalDir selectedBuildingFacing;
const Object *selectedResourceObject;
Texture2D* hudTexture;
public:
Gui();
void init(Game *game);
@ -151,6 +153,9 @@ public:
Vec2i getPosObjWorld() const {return posObjWorld;}
const UnitType *getBuilding() const;
Texture2D *getHudTexture() const {return hudTexture;}
void setHudTexture(Texture2D* value) { hudTexture = value;}
const Mouse3d *getMouse3d() const {return &mouse3d;}
const Display *getDisplay() const {return &display;}
const Selection *getSelection() const {return &selection;}

View File

@ -1407,7 +1407,8 @@ void runTechValidationForPath(string techPath, string techName,
for(unsigned int j = 0; j < foundFiles.size(); ++j) {
string file = foundFiles[j];
if( file.find("loading_screen") != string::npos ||
file.find("preview_screen") != string::npos) {
file.find("preview_screen") != string::npos ||
file.find("hud") != string::npos) {
continue;
}
if(file.find("/factions/") != string::npos) {