first working version of "game hints" displayed while loading. ( still missing language support and techtree specific hint support )
This commit is contained in:
parent
f5e8a523e3
commit
dc99918cfe
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "util.h"
|
||||
#include "renderer.h"
|
||||
#include "properties.h"
|
||||
#include "core_data.h"
|
||||
#include "metrics.h"
|
||||
#include "lang.h"
|
||||
|
@ -50,6 +51,7 @@ Logger::Logger() {
|
|||
fileName= userData + "log.txt";
|
||||
}
|
||||
loadingTexture=NULL;
|
||||
gameHintToShow="";
|
||||
showProgressBar = false;
|
||||
|
||||
cancelSelected = false;
|
||||
|
@ -113,6 +115,21 @@ void Logger::loadLoadingScreen(string filepath) {
|
|||
}
|
||||
}
|
||||
|
||||
void Logger::loadGameHints(string filepath) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(filepath == "") {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str());
|
||||
gameHints.load(filepath,false);
|
||||
gameHintToShow=gameHints.getRandomString(true);
|
||||
replaceAll(gameHintToShow, "\\n", "\n");
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::handleMouseClick(int x, int y) {
|
||||
if(buttonCancel.getEnabled() == true) {
|
||||
if(buttonCancel.mouseClick(x, y)) {
|
||||
|
@ -195,6 +212,21 @@ void Logger::renderLoadingScreen() {
|
|||
56 * metrics.getVirtualH() / 100, false);
|
||||
}
|
||||
}
|
||||
if(gameHintToShow!=""){
|
||||
if(Renderer::renderText3DEnabled) {
|
||||
renderer.renderText3D(
|
||||
"Hint: "+gameHintToShow, coreData.getMenuFontBig3D(), Vec3f(1.f),
|
||||
xLocation*1.5f,
|
||||
90 * metrics.getVirtualH() / 100, false);
|
||||
}
|
||||
else {
|
||||
renderer.renderText(
|
||||
"Hint: "+gameHintToShow, coreData.getMenuFontBig(), Vec3f(1.f),
|
||||
xLocation*1.5f,
|
||||
90 * metrics.getVirtualH() / 100, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(buttonCancel.getEnabled() == true) {
|
||||
renderer.renderButton(&buttonCancel);
|
||||
|
|
|
@ -21,12 +21,14 @@
|
|||
#include <deque>
|
||||
|
||||
#include "texture.h"
|
||||
#include "properties.h"
|
||||
#include "components.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::string;
|
||||
using std::deque;
|
||||
using Shared::Graphics::Texture2D;
|
||||
using Shared::Util::Properties;
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
|
@ -49,6 +51,8 @@ private:
|
|||
string subtitle;
|
||||
string current;
|
||||
Texture2D *loadingTexture;
|
||||
Properties gameHints;
|
||||
string gameHintToShow;
|
||||
int progress;
|
||||
bool showProgressBar;
|
||||
|
||||
|
@ -77,6 +81,7 @@ public:
|
|||
|
||||
void add(const string str, bool renderScreen= false, const string statusText="");
|
||||
void loadLoadingScreen(string filepath);
|
||||
void loadGameHints(string filepath);
|
||||
void renderLoadingScreen();
|
||||
|
||||
void setCancelLoadingEnabled(bool value);
|
||||
|
|
|
@ -733,6 +733,13 @@ void Game::load(int loadTypes) {
|
|||
string tilesetName= gameSettings.getTileset();
|
||||
string techName= gameSettings.getTech();
|
||||
string scenarioName= gameSettings.getScenario();
|
||||
string data_path= getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
// loadHints
|
||||
|
||||
if(data_path != ""){
|
||||
endPathWithSlash(data_path);
|
||||
}
|
||||
logger.loadGameHints(getGameCustomCoreDataPath(data_path, "data/core/hint/hint_english.lng"));
|
||||
|
||||
if((loadTypes & lgt_FactionPreview) == lgt_FactionPreview) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
@ -742,9 +749,10 @@ void Game::load(int loadTypes) {
|
|||
SDL_PumpEvents();
|
||||
}
|
||||
|
||||
|
||||
|
||||
loadHudTexture(&gameSettings);
|
||||
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
const string markCellTextureFilename = data_path + "data/core/misc_textures/mark_cell.png";
|
||||
markCellTexture = Renderer::findFactionLogoTexture(markCellTextureFilename);
|
||||
const string unmarkCellTextureFilename = data_path + "data/core/misc_textures/unmark_cell.png";
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
bool getBool(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
||||
float getFloat(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
||||
const string getString(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
||||
const string getRandomString(const bool realrandom) const;
|
||||
|
||||
void setInt(const string &key, int value);
|
||||
void setBool(const string &key, bool value);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "util.h"
|
||||
#include "platform_common.h"
|
||||
#include "platform_util.h"
|
||||
#include "randomgen.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <shlwapi.h>
|
||||
|
@ -416,6 +417,21 @@ const string Properties::getString(const string &key, const char *defaultValueIf
|
|||
}
|
||||
}
|
||||
|
||||
const string Properties::getRandomString(const bool realrandom) const{
|
||||
PropertyMap::const_iterator it;
|
||||
int max=getPropertyCount();
|
||||
int randomIndex=-1;
|
||||
if(realrandom == true){
|
||||
randomIndex=rand()%max;
|
||||
}
|
||||
else{
|
||||
RandomGen randgen;
|
||||
randomIndex=randgen.randRange(0,max);
|
||||
}
|
||||
string s=getString(randomIndex);
|
||||
return (s != "" ? s : "nothing found");
|
||||
}
|
||||
|
||||
bool Properties::hasString(const string &key) const {
|
||||
PropertyMap::const_iterator it;
|
||||
it= propertyMap.find(key);
|
||||
|
@ -451,9 +467,6 @@ string Properties::toString(){
|
|||
return rStr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Properties::getBool(const char *key, const char *defaultValueIfNotFound) const{
|
||||
try{
|
||||
return strToBool(getString(key,defaultValueIfNotFound));
|
||||
|
|
Loading…
Reference in New Issue