MegaGlest Forum
Archives (read only) => Glest Advanced Engine => Feature requests => Topic started by: ChupaReaper on 12 May 2011, 14:30:40
-
I think I've requested this before but couldn't find the topic to bump lol! Anyway, when loading a game it would be cool if a random loading screen per faction was used defined in the xml like this:
<loading-screen>
<background-image path="images/loading/loading_valkeries.png" />
<background-image path="images/loading/loading_blessings.png" />
<background-image path="images/loading/loading_unicorns.png" />
<background-image path="images/loading/loading_arix.png" />
<background-image path="images/loading/loading_wendigos.png" />
<background-image path="images/loading/loading_harpies.png" />
<background-image path="images/loading/loading_icegolems.png" />
<background-image path="images/loading/loading_frosttempests.png" />
</loading-screen>
As you can see, Malevoelnt Rising would make heavy use out of it! :D
Maybe this too: <loading-screen shuffle="true"> I will be having it random regardless but some people might not for whatever reason.
Also GAE should remember what screens have been used so it tries not to load the same one again by chance until all the others have been used, else there is a small possibility that someone will always see the same one, small but not impossible!
-
Full agreement. I will use this too, in Military. Shuffle would be unneccessary, in my opinion, as it should always randomly play.
-
Full agreement. I will use this too, in Military. Shuffle would be unneccessary, in my opinion, as it should always randomly play.
^this^
-
Would be nice if loading text could be added separate for different languages. So randomly pick a loading screen which has a language string bound to it that is shown with it. Scenarios could have their own strings and loading screens too.
-
Would be nice if loading text could be added separate for different languages. So randomly pick a loading screen which has a language string bound to it that is shown with it. Scenarios could have their own strings and loading screens too.
Also in agreement, as people will without doubt use tips too. We'd probably have to specify a rectangular area where a textbox would be drawn.
-
Loads tips_en.txt in fraction lang folder if present.
game.cpp modification
// ==================== init and load ====================
void GameState::load() {
GameSettings &gameSettings = g_simInterface.getGameSettings();
const string &mapName = gameSettings.getMapPath();
const string &tilesetName = gameSettings.getTilesetPath();
const string &techName = gameSettings.getTechPath();
const string &scenarioPath = gameSettings.getScenarioPath();
string scenarioName = basename(scenarioPath);
const string &thisFactionName = gameSettings.getFactionTypeName(gameSettings.getThisFactionIndex());
// determine loading screen settings:
// 1. check sceneraio if applicable
// 2. check faction
// 3. check tech
// 4. use defaults
ProgramLog &log = g_logger.getProgramLog();
if (!scenarioName.empty()
&& log.setupLoadingScreen(scenarioPath)) {
} else if (log.setupLoadingScreen(techName + "/factions/" + thisFactionName)) {
} else if (log.setupLoadingScreen(techName)) {
} else {
log.useLoadingScreenDefaults();
}
// maybe use config option instead - hailstone 01May2011
if (g_program.getMouseCursor().descType() == "ImageSetMouseCursor") {
ImageSetMouseCursor &mouse = static_cast<ImageSetMouseCursor&>(g_program.getMouseCursor());
// check for custom mouse (faction then tech)
if (mouse.loadMouse(techName + "/factions/" + thisFactionName)) {
} else if (mouse.loadMouse(techName)) {
} else {
// already using default
}
}
g_logger.getProgramLog().setProgressBar(true);
g_logger.getProgramLog().setState(Lang::getInstance().get("Loading"));
// overwrite subtitles
//if (scenarioName.empty()) {
//log.setSubtitle(formatString(mapName) + " - " +
// formatString(tilesetName) + " - " + formatString(techName));
//} else {
// log.setSubtitle(formatString(scenarioName));
//}
simInterface->loadWorld();
// finished loading
g_logger.getProgramLog().setProgressBar(false);
}
logger.cpp modification
/** Load the loading screen settings from xml
* @return true if loaded successfully
*/
bool ProgramLog::setupLoadingScreen(const string &dir) {
string path = dir + "/" + basename(dir) + ".xml";
//open xml file
XmlTree xmlTree;
try {
xmlTree.load(path);
} catch (runtime_error e) {
g_logger.logXmlError(path, "File missing or wrongly named.");
return false; // bail
}
const XmlNode *rootNode;
try {
rootNode = xmlTree.getRootNode();
} catch (runtime_error e) {
g_logger.logXmlError(path, "File appears to lack contents.");
return false; // bail
}
const XmlNode *loadingScreenNode = rootNode->getChild("loading-screen", 0, false);
if (loadingScreenNode) {
// could randomly choose from multiple or choose
// based on resolution - hailstone 21Jan2011
// background texture
int x = loadingScreenNode->getChildCount();
int k = 0;
if (x!=1) {
int seed = int(Chrono::getCurMicros());
Random random(seed);
k = random.randRange(0, x - 1);
}
const XmlNode *backgroundImageNode = loadingScreenNode->getChild("background-image", k, true);
if (backgroundImageNode) {
// load background image from faction.xml
m_backgroundTexture = g_renderer.newTexture2D(ResourceScope::GLOBAL);
m_backgroundTexture->setMipmap(false);
m_backgroundTexture->getPixmap()->load(dir + "/" +
backgroundImageNode->getAttribute("path")->getValue());
try {
m_backgroundTexture->init(Texture::fBilinear);
} catch (...) {
m_backgroundTexture = Texture2D::defaultTexture;
}
}
// faction tips
string path = dir + "/lang/tips_" + g_lang.getLocale() + ".txt";
vector<string> Strings;
FileOps *f = g_fileFactory.getFileOps();
char *buf = 0;
try {
f->openRead(path.c_str());
int size = f->fileSize();
buf = new char[size + 1];
f->read(buf, size, 1);
buf[size] = '\0';
stringstream ss(buf);
delete [] buf;
buf = 0;
char buffer[1024];
while (!ss.eof()) {
ss.getline(buffer, 1023);
if (buffer[0] == ';' || buffer[0] == '\0' || buffer[0] == 10 || buffer[0] == 13) {
continue;
}
string str(buffer);
if (*(str.end() - 1) == 13) {
str = str.substr(0, str.size() - 1);
}
if (!str.empty()) {
Strings.push_back(str);
}
}
} catch (runtime_error &e) {
delete [] buf;
Strings.clear();
}
delete f;
// random tips selection
if(Strings.size()!=0){
int seed = int(Chrono::getCurMicros());
Random random(seed);
int k = random.randRange(0, Strings.size() - 1);
setSubtitle(Strings.at(k));
Strings.clear();
}
return true; // successfully using settings
}
return false;
}
void ProgramLog::renderLoadingScreen(){
g_renderer.reset2d();
g_renderer.clearBuffers();
const Font *normFont = g_widgetConfig.getMenuFont();
const Font *bigFont = g_widgetConfig.getTitleFont();
if (m_backgroundTexture) {
g_renderer.renderBackground(m_backgroundTexture);
}
Vec2i headerPos(g_metrics.getScreenW() / 4, 25 * g_metrics.getScreenH() / 100);
Vec4f colour(1.f);
g_renderer.renderText(state, bigFont, colour, headerPos.x, headerPos.y);
int yStart = headerPos.y + int(bigFont->getMetrics()->getHeight()) + 6;
if (loadingGame) {
int offset = 0;
int step = int(normFont->getMetrics()->getHeight()) + 4;
//for (Strings::reverse_iterator it = logLines.rbegin(); it != logLines.rend(); ++it) {
// colour.a = 1.f - float(offset) / float(logLineCount + 1);
// g_renderer.renderText(*it, normFont, colour, g_metrics.getScreenW() / 4,
// 30 * g_metrics.getScreenH() / 100 + offset * step);
// ++offset;
//}
colour.a = 1.f - float(offset);
string k = logLines.back();
g_renderer.renderText(k, normFont, colour, g_metrics.getScreenW() / 4,
30 * g_metrics.getScreenH() / 100 + offset * step);
g_renderer.renderText(subtitle, normFont, colour, g_metrics.getScreenW() / 4,
38 * g_metrics.getScreenH() / 100);
if (m_progressBar) {
Vec2i progBarPos = headerPos;
progBarPos.x += int(bigFont->getMetrics()->getTextDiminsions(state).w) + 20;
int w = g_metrics.getScreenW() / 4 * 3 - progBarPos.x;
int h = int(normFont->getMetrics()->getHeight() + 2.f);
g_renderer.renderProgressBar(m_progress, progBarPos.x, progBarPos.y, w, h, normFont);
}
} else {
g_renderer.renderText(current, normFont, colour, g_metrics.getScreenW() / 4,
38 * g_metrics.getScreenH() / 100);
}
g_renderer.swapBuffers();
}
-
I think I've requested this before but couldn't find the topic to bump lol! Anyway, when loading a game it would be cool if a random loading screen per faction was used defined in the xml like this:
<loading-screen>
<background-image path="images/loading/loading_valkeries.png" />
<background-image path="images/loading/loading_blessings.png" />
<background-image path="images/loading/loading_unicorns.png" />
<background-image path="images/loading/loading_arix.png" />
<background-image path="images/loading/loading_wendigos.png" />
<background-image path="images/loading/loading_harpies.png" />
<background-image path="images/loading/loading_icegolems.png" />
<background-image path="images/loading/loading_frosttempests.png" />
</loading-screen>
As you can see, Malevoelnt Rising would make heavy use out of it! :D
Maybe this too: <loading-screen shuffle="true"> I will be having it random regardless but some people might not for whatever reason.
Also GAE should remember what screens have been used so it tries not to load the same one again by chance until all the others have been used, else there is a small possibility that someone will always see the same one, small but not impossible!
Instead of this just make is so that if you define a single image you will get that image, but if you want to randomize you just pick a folder, like so
<loading-screen>
<background-image path="images/loading/loading_valkeries.png" />
</loading-screen>
<loading-screen>
<background-image path="images/random_images_folder" />
</loading-screen>
-
/** Load the loading screen settings from xml
* @return true if loaded successfully
*/
bool ProgramLog::setupLoadingScreen(const string &dir) {
string path = dir + "/" + basename(dir) + ".xml";
//open xml file
XmlTree xmlTree;
try {
xmlTree.load(path);
} catch (runtime_error e) {
g_logger.logXmlError(path, "File missing or wrongly named.");
return false; // bail
}
const XmlNode *rootNode;
try {
rootNode = xmlTree.getRootNode();
} catch (runtime_error e) {
g_logger.logXmlError(path, "File appears to lack contents.");
return false; // bail
}
const XmlNode *loadingScreenNode = rootNode->getChild("loading-screen", 0, false);
if (loadingScreenNode) {
// could randomly choose from multiple or choose
// based on resolution - hailstone 21Jan2011
// background texture
int x = loadingScreenNode->getChildCount();
int k = 0;
if (x!=1) {
int seed = int(Chrono::getCurMicros());
Random random(seed);
k = random.randRange(0, x - 1);
}
const XmlNode *backgroundImageNode = loadingScreenNode->getChild("background-image", k, true);
if (backgroundImageNode) {
// load background image from faction.xml
m_backgroundTexture = g_renderer.newTexture2D(ResourceScope::GLOBAL);
m_backgroundTexture->setMipmap(false);
m_backgroundTexture->getPixmap()->load(dir + "/" +
backgroundImageNode->getAttribute("path")->getValue());
try {
m_backgroundTexture->init(Texture::fBilinear);
} catch (...) {
m_backgroundTexture = Texture2D::defaultTexture;
}
}
// faction tips
return true; // successfully using settings
}
return false;
}
Nice job, and welcome, Snaips! I never tested it, but this was really needed, and hope that a GAE team member will be able to check and implement the code.
-
/** Load the loading screen settings from xml
* @return true if loaded successfully
*/
bool ProgramLog::setupLoadingScreen(const string &dir) {
string path = dir + "/" + basename(dir) + ".xml";
//open xml file
XmlTree xmlTree;
try {
xmlTree.load(path);
} catch (runtime_error e) {
g_logger.logXmlError(path, "File missing or wrongly named.");
return false; // bail
}
const XmlNode *rootNode;
try {
rootNode = xmlTree.getRootNode();
} catch (runtime_error e) {
g_logger.logXmlError(path, "File appears to lack contents.");
return false; // bail
}
const XmlNode *loadingScreenNode = rootNode->getChild("loading-screen", 0, false);
if (loadingScreenNode) {
// could randomly choose from multiple or choose
// based on resolution - hailstone 21Jan2011
// background texture
int x = loadingScreenNode->getChildCount();
int k = 0;
if (x!=1) {
int seed = int(Chrono::getCurMicros());
Random random(seed);
k = random.randRange(0, x - 1);
}
const XmlNode *backgroundImageNode = loadingScreenNode->getChild("background-image", k, true);
if (backgroundImageNode) {
// load background image from faction.xml
m_backgroundTexture = g_renderer.newTexture2D(ResourceScope::GLOBAL);
m_backgroundTexture->setMipmap(false);
m_backgroundTexture->getPixmap()->load(dir + "/" +
backgroundImageNode->getAttribute("path")->getValue());
try {
m_backgroundTexture->init(Texture::fBilinear);
} catch (...) {
m_backgroundTexture = Texture2D::defaultTexture;
}
}
// faction tips
return true; // successfully using settings
}
return false;
}
Cool! I don't know C++ well at all but it looks pretty good. Maybe a ticket should be made of this so it is not lost?