- hardened code for standalone mods

This commit is contained in:
Mark Vejvoda 2011-11-23 19:12:06 +00:00
parent aefdfd98f8
commit 115ef63f57
4 changed files with 95 additions and 58 deletions

View File

@ -269,26 +269,32 @@ void CoreData::load() {
loadFonts(); loadFonts();
//sounds //sounds
clickSoundA.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_a.wav"));
clickSoundB.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_b.wav"));
clickSoundC.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_c.wav"));
attentionSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/attention.wav"));
highlightSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/highlight.wav"));
XmlTree xmlTree; XmlTree xmlTree;
//string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); //string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
xmlTree.load(getGameCustomCoreDataPath(data_path, "data/core/menu/menu.xml"),Properties::getTagReplacementValues()); xmlTree.load(getGameCustomCoreDataPath(data_path, "data/core/menu/menu.xml"),Properties::getTagReplacementValues());
const XmlNode *menuNode= xmlTree.getRootNode(); const XmlNode *menuNode= xmlTree.getRootNode();
const XmlNode *introNode= menuNode->getChild("intro");
clickSoundA.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_a.wav")); string menuMusicPath = "/menu/music/";
clickSoundB.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_b.wav")); string menuIntroMusicFile = "intro_music.ogg";
clickSoundC.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_c.wav")); string menuMusicFile = "menu_music.ogg";
attentionSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/attention.wav"));
highlightSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/highlight.wav"));
// intro info if(menuNode->hasChild("intro") == true) {
const XmlNode *menuPathNode= introNode->getChild("menu-music-path"); const XmlNode *introNode= menuNode->getChild("intro");
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();
// intro info
const XmlNode *menuPathNode= introNode->getChild("menu-music-path");
menuMusicPath = menuPathNode->getAttribute("value")->getRestrictedValue();
const XmlNode *menuIntroMusicNode= introNode->getChild("menu-intro-music");
menuIntroMusicFile = menuIntroMusicNode->getAttribute("value")->getRestrictedValue();
const XmlNode *menuMusicNode= introNode->getChild("menu-music");
menuMusicFile = menuMusicNode->getAttribute("value")->getRestrictedValue();
}
introMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuIntroMusicFile)); introMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuIntroMusicFile));
introMusic.setNext(&menuMusic); introMusic.setNext(&menuMusic);
menuMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuMusicFile)); menuMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuMusicFile));

View File

@ -103,58 +103,87 @@ Intro::Intro(Program *program):
renderer.initMenu(NULL); renderer.initMenu(NULL);
fade= 0.f; fade= 0.f;
anim= 0.f; anim= 0.f;
XmlTree xmlTree;
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
xmlTree.load(getGameCustomCoreDataPath(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__);
targetCamera= NULL; targetCamera= NULL;
t= 0.f; t= 0.f;
//camera startPosition.x= 5;;
const XmlNode *cameraNode= introNode->getChild("camera"); startPosition.y= 10;
startPosition.z= 40;
//position
const XmlNode *positionNode= cameraNode->getChild("start-position");
startPosition.x= positionNode->getAttribute("x")->getFloatValue();
startPosition.y= positionNode->getAttribute("y")->getFloatValue();
startPosition.z= positionNode->getAttribute("z")->getFloatValue();
camera.setPosition(startPosition); camera.setPosition(startPosition);
//rotation
const XmlNode *rotationNode= cameraNode->getChild("start-rotation");
Vec3f startRotation; Vec3f startRotation;
startRotation.x= rotationNode->getAttribute("x")->getFloatValue(); startRotation.x= 0;
startRotation.y= rotationNode->getAttribute("y")->getFloatValue(); startRotation.y= 0;
startRotation.z= rotationNode->getAttribute("z")->getFloatValue(); startRotation.z= 0;
camera.setOrientation(Quaternion(EulerAngles( camera.setOrientation(Quaternion(EulerAngles(
degToRad(startRotation.x), degToRad(startRotation.x),
degToRad(startRotation.y), degToRad(startRotation.y),
degToRad(startRotation.z)))); degToRad(startRotation.z))));
// intro info Intro::introTime = 3000;
const XmlNode *introTimeNode= introNode->getChild("intro-time"); Intro::appearTime = 500;
Intro::introTime = introTimeNode->getAttribute("value")->getIntValue(); Intro::showTime = 500;
const XmlNode *appearTimeNode= introNode->getChild("appear-time"); Intro::disapearTime = 500;
Intro::appearTime = appearTimeNode->getAttribute("value")->getIntValue(); int showIntroPics = 0;
const XmlNode *showTimeNode= introNode->getChild("show-time"); int showIntroPicsTime = 0;
Intro::showTime = showTimeNode->getAttribute("value")->getIntValue(); bool showIntroPicsRandom = false;
const XmlNode *disappearTimeNode= introNode->getChild("disappear-time"); bool showIntroModels = false;
Intro::disapearTime = disappearTimeNode->getAttribute("value")->getIntValue(); bool showIntroModelsRandom = false;
const XmlNode *showIntroPicturesNode= introNode->getChild("show-intro-pictures"); modelMinAnimSpeed = 0;
int showIntroPics = showIntroPicturesNode->getAttribute("value")->getIntValue(); modelMaxAnimSpeed = 0;
int showIntroPicsTime = showIntroPicturesNode->getAttribute("time")->getIntValue();
bool showIntroPicsRandom = showIntroPicturesNode->getAttribute("random")->getBoolValue();
const XmlNode *showIntroModelsNode= introNode->getChild("show-intro-models"); XmlTree xmlTree;
bool showIntroModels = showIntroModelsNode->getAttribute("value")->getBoolValue(); string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
bool showIntroModelsRandom = showIntroModelsNode->getAttribute("random")->getBoolValue(); xmlTree.load(getGameCustomCoreDataPath(data_path, "data/core/menu/menu.xml"),Properties::getTagReplacementValues());
modelMinAnimSpeed = showIntroModelsNode->getAttribute("min-anim-speed")->getFloatValue(); const XmlNode *menuNode= xmlTree.getRootNode();
modelMaxAnimSpeed = showIntroModelsNode->getAttribute("max-anim-speed")->getFloatValue();
if(menuNode->hasChild("intro") == true) {
const XmlNode *introNode= menuNode->getChild("intro");
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
//camera
const XmlNode *cameraNode= introNode->getChild("camera");
//position
const XmlNode *positionNode= cameraNode->getChild("start-position");
startPosition.x= positionNode->getAttribute("x")->getFloatValue();
startPosition.y= positionNode->getAttribute("y")->getFloatValue();
startPosition.z= positionNode->getAttribute("z")->getFloatValue();
camera.setPosition(startPosition);
//rotation
const XmlNode *rotationNode= cameraNode->getChild("start-rotation");
Vec3f startRotation;
startRotation.x= rotationNode->getAttribute("x")->getFloatValue();
startRotation.y= rotationNode->getAttribute("y")->getFloatValue();
startRotation.z= rotationNode->getAttribute("z")->getFloatValue();
camera.setOrientation(Quaternion(EulerAngles(
degToRad(startRotation.x),
degToRad(startRotation.y),
degToRad(startRotation.z))));
// 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();
const XmlNode *showIntroModelsNode= introNode->getChild("show-intro-models");
showIntroModels = showIntroModelsNode->getAttribute("value")->getBoolValue();
showIntroModelsRandom = showIntroModelsNode->getAttribute("random")->getBoolValue();
modelMinAnimSpeed = showIntroModelsNode->getAttribute("min-anim-speed")->getFloatValue();
modelMaxAnimSpeed = showIntroModelsNode->getAttribute("max-anim-speed")->getFloatValue();
}
//load main model //load main model
modelIndex = 0; modelIndex = 0;

View File

@ -646,7 +646,7 @@ void handleSIGSEGV(int sig) {
printf("%s",szBuf); printf("%s",szBuf);
//abort(); //abort();
//ExceptionHandler::handleRuntimeError(szBuf); ExceptionHandler::handleRuntimeError(szBuf);
} }
#endif #endif

View File

@ -107,10 +107,12 @@ MenuBackground::MenuBackground(){
//load main model //load main model
mainModel= renderer.newModel(rsMenu); mainModel= renderer.newModel(rsMenu);
if(mainModel) { if(mainModel) {
//mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d"); string mainModelFile = "data/core/menu/main_model/menu_main.g3d";
const XmlNode *mainMenuModelNode= menuNode->getChild("menu-background-model"); if(menuNode->hasChild("menu-background-model") == true) {
string mainModelFile = mainMenuModelNode->getAttribute("value")->getRestrictedValue(); //mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d");
const XmlNode *mainMenuModelNode= menuNode->getChild("menu-background-model");
mainModelFile = mainMenuModelNode->getAttribute("value")->getRestrictedValue();
}
mainModel->load(getGameCustomCoreDataPath(data_path, mainModelFile)); mainModel->load(getGameCustomCoreDataPath(data_path, mainModelFile));
} }