- added experimental new intro for Megaglest. Its easy to revert back to original but i think its time we had some new music and intro pics

This commit is contained in:
Mark Vejvoda 2011-10-07 17:21:09 +00:00
parent 572ef33ee3
commit af2abb57b8
4 changed files with 138 additions and 15 deletions

View File

@ -112,7 +112,7 @@ void CoreData::load() {
logoTextureList.clear();
string logosPath= dir+"/menu/textures/logo*.*";
vector<string> logoFilenames;
findAll(logosPath, logoFilenames);
findAll(logosPath, logoFilenames, false, false);
for(int i = 0; i < logoFilenames.size(); ++i) {
string logo = logoFilenames[i];
if(strcmp("logo.tga",logo.c_str()) != 0) {
@ -125,6 +125,22 @@ void CoreData::load() {
}
}
miscTextureList.clear();
string introPath= dir+"/menu/textures/intro*.*";
vector<string> introFilenames;
findAll(introPath, introFilenames, false, false);
for(int i = 0; i < introFilenames.size(); ++i) {
string logo = introFilenames[i];
//if(strcmp("logo.tga",logo.c_str()) != 0) {
Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal);
if(logoTextureExtra) {
logoTextureExtra->setMipmap(true);
logoTextureExtra->getPixmap()->load(dir+"/menu/textures/" + logo);
miscTextureList.push_back(logoTextureExtra);
}
//}
}
waterSplashTexture= renderer.newTexture2D(rsGlobal);
if(waterSplashTexture) {
waterSplashTexture->setFormat(Texture::fAlpha);
@ -382,15 +398,31 @@ void CoreData::load() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] consoleFontName = [%s] consoleFontNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,consoleFontName.c_str(),consoleFontNameSize);
//sounds
XmlTree xmlTree;
//string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
xmlTree.load(data_path + "data/core/menu/menu.xml",Properties::getTagReplacementValues());
const XmlNode *menuNode= xmlTree.getRootNode();
const XmlNode *introNode= menuNode->getChild("intro");
clickSoundA.load(dir+"/menu/sound/click_a.wav");
clickSoundB.load(dir+"/menu/sound/click_b.wav");
clickSoundC.load(dir+"/menu/sound/click_c.wav");
attentionSound.load(dir+"/menu/sound/attention.wav");
highlightSound.load(dir+"/menu/sound/highlight.wav");
introMusic.open(dir+"/menu/music/intro_music.ogg");
// intro info
const XmlNode *menuPathNode= introNode->getChild("menu-music-path");
string menuMusicPath = menuPathNode->getAttribute("value")->getRestrictedValue();
const XmlNode *menuIntroMusicNode= introNode->getChild("menu-intro-music");
string menuIntroMusicFile = menuIntroMusicNode->getAttribute("value")->getRestrictedValue();
const XmlNode *menuMusicNode= introNode->getChild("menu-music");
string menuMusicFile = menuMusicNode->getAttribute("value")->getRestrictedValue();
introMusic.open(dir + menuMusicPath + menuIntroMusicFile);
introMusic.setNext(&menuMusic);
menuMusic.open(dir+"/menu/music/menu_music.ogg");
menuMusic.open(dir + menuMusicPath + menuMusicFile);
menuMusic.setNext(&menuMusic);
waterSounds.resize(6);
for(int i=0; i<6; ++i){

View File

@ -66,6 +66,7 @@ private:
Texture2D *onServerTexture;
Texture2D *onServerInstalledTexture;
std::vector<Texture2D *> miscTextureList;
Font2D *displayFont;
Font2D *menuFontNormal;
@ -110,6 +111,8 @@ public:
size_t getLogoTextureExtraCount() const {return logoTextureList.size();}
Texture2D *getLogoTextureExtra(int idx) const {return logoTextureList[idx];}
std::vector<Texture2D *> & getMiscTextureList() { return miscTextureList; }
StrSound *getIntroMusic() {return &introMusic;}
StrSound *getMenuMusic() {return &menuMusic;}
StaticSound *getClickSoundA() {return &clickSoundA;}

View File

@ -25,6 +25,7 @@
using namespace Shared::Util;
using namespace Shared::Graphics;
using namespace Shared::Xml;
namespace Glest{ namespace Game{
@ -54,15 +55,15 @@ Text::Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int ti
// class Intro
// =====================================================
const int Intro::introTime= 24000;
const int Intro::appearTime= 2500;
const int Intro::showTime= 2500;
const int Intro::disapearTime= 2500;
int Intro::introTime = 50000;
int Intro::appearTime = 2500;
int Intro::showTime = 3500;
int Intro::disapearTime = 2500;
Intro::Intro(Program *program):
ProgramState(program)
{
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__);
CoreData &coreData= CoreData::getInstance();
const Metrics &metrics= Metrics::getInstance();
@ -73,9 +74,96 @@ Intro::Intro(Program *program):
mouseY = 0;
mouse2d = 0;
texts.push_back(Text(coreData.getLogoTexture(), Vec2i(w/2-128, h/2-64), Vec2i(256, 128), 4000));
texts.push_back(Text(glestVersionString, Vec2i(w/2+45, h/2-45), 4000, coreData.getMenuFontNormal(),coreData.getMenuFontNormal3D()));
texts.push_back(Text("www.megaglest.org", Vec2i(w/2, h/2), 12000, coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D()));
XmlTree xmlTree;
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
xmlTree.load(data_path + "data/core/menu/menu.xml",Properties::getTagReplacementValues());
const XmlNode *menuNode= xmlTree.getRootNode();
const XmlNode *introNode= menuNode->getChild("intro");
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
// intro info
const XmlNode *introTimeNode= introNode->getChild("intro-time");
Intro::introTime = introTimeNode->getAttribute("value")->getIntValue();
const XmlNode *appearTimeNode= introNode->getChild("appear-time");
Intro::appearTime = appearTimeNode->getAttribute("value")->getIntValue();
const XmlNode *showTimeNode= introNode->getChild("show-time");
Intro::showTime = showTimeNode->getAttribute("value")->getIntValue();
const XmlNode *disappearTimeNode= introNode->getChild("disappear-time");
Intro::disapearTime = disappearTimeNode->getAttribute("value")->getIntValue();
const XmlNode *showIntroPicturesNode= introNode->getChild("show-intro-pictures");
int showIntroPics = showIntroPicturesNode->getAttribute("value")->getIntValue();
int showIntroPicsTime = showIntroPicturesNode->getAttribute("time")->getIntValue();
bool showIntroPicsRandom = showIntroPicturesNode->getAttribute("random")->getBoolValue();
texts.push_back(Text(coreData.getLogoTexture(), Vec2i(w/2-128, h/2-64), Vec2i(256, 128), Intro::appearTime));
texts.push_back(Text(glestVersionString, Vec2i(w/2+45, h/2-45), Intro::appearTime, coreData.getMenuFontNormal(),coreData.getMenuFontNormal3D()));
texts.push_back(Text("www.megaglest.org", Vec2i(w/2, h/2), Intro::showTime+Intro::appearTime+Intro::disapearTime, coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D()));
if(showIntroPics > 0 && coreData.getMiscTextureList().size() > 0) {
const int showMiscTime = showIntroPicsTime;
std::vector<Texture2D *> intoTexList;
if(showIntroPicsRandom == true) {
unsigned int seed = time(NULL);
srand(seed);
int failedLookups=0;
std::map<int,bool> usedIndex;
for(;intoTexList.size() < showIntroPics;) {
int picIndex = rand() % coreData.getMiscTextureList().size();
if(usedIndex.find(picIndex) != usedIndex.end()) {
failedLookups++;
seed = time(NULL) / failedLookups;
srand(seed);
continue;
}
//printf("picIndex = %d list count = %d\n",picIndex,coreData.getMiscTextureList().size());
intoTexList.push_back(coreData.getMiscTextureList()[picIndex]);
usedIndex[picIndex]=true;
seed = time(NULL) / intoTexList.size();
srand(seed);
}
}
else {
for(unsigned int i = 0;
i < coreData.getMiscTextureList().size() &&
i < showIntroPics; ++i) {
Texture2D *tex = coreData.getMiscTextureList()[i];
intoTexList.push_back(tex);
}
}
for(unsigned int i = 0; i < intoTexList.size(); ++i) {
Texture2D *tex = intoTexList[i];
//printf("tex # %d [%s]\n",i,tex->getPath().c_str());
if(i == 0) {
texts.push_back(Text(tex, Vec2i(1, h-tex->getTextureHeight()), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1))));
}
if(i == 1) {
texts.push_back(Text(tex, Vec2i(1, 1), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1))));
}
if(i == 2) {
texts.push_back(Text(tex, Vec2i(w-tex->getTextureWidth(), 1), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1))));
}
if(i == 3) {
texts.push_back(Text(tex, Vec2i(w-tex->getTextureWidth(), h-tex->getTextureHeight()), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1))));
}
if(i == 4) {
texts.push_back(Text(tex, Vec2i(w/2 - tex->getTextureWidth()/2, h-tex->getTextureHeight()), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1))));
}
if(i == 5) {
texts.push_back(Text(tex, Vec2i(w/2 - tex->getTextureWidth()/2, 1), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1))));
}
if(i == 6) {
texts.push_back(Text(tex, Vec2i(1, (h/2) - (tex->getTextureHeight()/2)), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1))));
}
if(i == 7) {
texts.push_back(Text(tex, Vec2i(w-tex->getTextureWidth(), (h/2) - (tex->getTextureHeight()/2)), Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), Intro::showTime+Intro::appearTime+Intro::disapearTime+(showMiscTime*(i+1))));
}
}
}
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -66,10 +66,10 @@ public:
class Intro: public ProgramState{
private:
static const int introTime;
static const int appearTime;
static const int showTime;
static const int disapearTime;
static int introTime;
static int appearTime;
static int showTime;
static int disapearTime;
private:
vector<Text> texts;