mirror of
https://github.com/glest/glest-source.git
synced 2025-09-30 01:18:58 +02:00
just put a hud.png in a faction dir and you got a HUD overlay
This commit is contained in:
@@ -353,6 +353,48 @@ string Game::extractTechLogoFile(string scenarioDir, string techName,
|
|||||||
return result;
|
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 Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,
|
||||||
string factionLogoFilter) {
|
string factionLogoFilter) {
|
||||||
string result = "";
|
string result = "";
|
||||||
@@ -483,6 +525,8 @@ void Game::load(LoadGameItem loadTypes) {
|
|||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadHudTexture(&gameSettings);
|
||||||
|
|
||||||
string scenarioDir = "";
|
string scenarioDir = "";
|
||||||
if(gameSettings.getScenarioDir() != "") {
|
if(gameSettings.getScenarioDir() != "") {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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
|
//init
|
||||||
renderer.reset2d();
|
renderer.reset2d();
|
||||||
|
|
||||||
|
//HUD
|
||||||
|
renderer.renderHud();
|
||||||
|
|
||||||
//display
|
//display
|
||||||
renderer.renderDisplay();
|
renderer.renderDisplay();
|
||||||
|
|
||||||
|
@@ -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 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.*");
|
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 getGameOver() { return gameOver; }
|
||||||
bool hasGameStarted() { return gameStarted;}
|
bool hasGameStarted() { return gameStarted;}
|
||||||
|
@@ -3044,6 +3044,15 @@ void Renderer::renderWaterEffects(){
|
|||||||
assertGl();
|
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(){
|
void Renderer::renderMinimap(){
|
||||||
const World *world= game->getWorld();
|
const World *world= game->getWorld();
|
||||||
const Minimap *minimap= world->getMinimap();
|
const Minimap *minimap= world->getMinimap();
|
||||||
|
@@ -382,6 +382,7 @@ public:
|
|||||||
|
|
||||||
void renderSelectionEffects();
|
void renderSelectionEffects();
|
||||||
void renderWaterEffects();
|
void renderWaterEffects();
|
||||||
|
void renderHud();
|
||||||
void renderMinimap();
|
void renderMinimap();
|
||||||
void renderDisplay();
|
void renderDisplay();
|
||||||
void renderMenuBackground(const MenuBackground *menuBackground);
|
void renderMenuBackground(const MenuBackground *menuBackground);
|
||||||
|
@@ -110,6 +110,7 @@ Gui::Gui(){
|
|||||||
selectionCalculationFrameSkip=10;
|
selectionCalculationFrameSkip=10;
|
||||||
minQuadSize=20;
|
minQuadSize=20;
|
||||||
selectedResourceObject=NULL;
|
selectedResourceObject=NULL;
|
||||||
|
hudTexture=NULL;
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
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(){
|
void Gui::end(){
|
||||||
selection.clear();
|
selection.clear();
|
||||||
|
if(hudTexture != NULL) {
|
||||||
|
Renderer::getInstance().endTexture(rsGlobal, hudTexture, false);
|
||||||
|
}
|
||||||
|
hudTexture = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== get ====================
|
// ==================== get ====================
|
||||||
|
@@ -139,6 +139,8 @@ private:
|
|||||||
CardinalDir selectedBuildingFacing;
|
CardinalDir selectedBuildingFacing;
|
||||||
const Object *selectedResourceObject;
|
const Object *selectedResourceObject;
|
||||||
|
|
||||||
|
Texture2D* hudTexture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Gui();
|
Gui();
|
||||||
void init(Game *game);
|
void init(Game *game);
|
||||||
@@ -151,6 +153,9 @@ public:
|
|||||||
Vec2i getPosObjWorld() const {return posObjWorld;}
|
Vec2i getPosObjWorld() const {return posObjWorld;}
|
||||||
const UnitType *getBuilding() const;
|
const UnitType *getBuilding() const;
|
||||||
|
|
||||||
|
Texture2D *getHudTexture() const {return hudTexture;}
|
||||||
|
void setHudTexture(Texture2D* value) { hudTexture = value;}
|
||||||
|
|
||||||
const Mouse3d *getMouse3d() const {return &mouse3d;}
|
const Mouse3d *getMouse3d() const {return &mouse3d;}
|
||||||
const Display *getDisplay() const {return &display;}
|
const Display *getDisplay() const {return &display;}
|
||||||
const Selection *getSelection() const {return &selection;}
|
const Selection *getSelection() const {return &selection;}
|
||||||
|
@@ -1407,7 +1407,8 @@ void runTechValidationForPath(string techPath, string techName,
|
|||||||
for(unsigned int j = 0; j < foundFiles.size(); ++j) {
|
for(unsigned int j = 0; j < foundFiles.size(); ++j) {
|
||||||
string file = foundFiles[j];
|
string file = foundFiles[j];
|
||||||
if( file.find("loading_screen") != string::npos ||
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
if(file.find("/factions/") != string::npos) {
|
if(file.find("/factions/") != string::npos) {
|
||||||
|
Reference in New Issue
Block a user