- Added a possibility to put a file "Res.txt" instead of the folder "Res". The file Res.txt is a simple 1 line text file, telling where to find the Res folder, terminated by "/". For example: "../../wagic_res".
This addresses issue 428 . This could also help us in the future, to develop mods.
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-11-07 09:26:29 +00:00
parent b14e3808db
commit 5d907f5abe
31 changed files with 115 additions and 94 deletions

View File

@@ -10,7 +10,7 @@ using std::string;
#include "SimplePad.h"
#include "GameApp.h"
#define GLOBAL_SETTINGS RESPATH"/settings/options.txt"
#define GLOBAL_SETTINGS "settings/options.txt"
#define PLAYER_SAVEFILE "data.dat"
#define PLAYER_SETTINGS "options.txt"
#define PLAYER_COLLECTION "collection.dat"

View File

@@ -2,10 +2,10 @@
#define _LOGGER_H_
//TODO Remove this and use the jge logging facility (same system)
//#define DOLOG
#define DOLOG
#ifdef DOLOG
#define LOG_FILE RESPATH"/debug.txt"
#define LOG_FILE "debug.txt"
class Logger{
public:

View File

@@ -16,5 +16,6 @@
#include <assert.h>
#include "JGE.h"
#include "JFileSystem.h"
#endif //PRECOMPILEDHEADER_H

View File

@@ -9,7 +9,7 @@ using namespace std;
#include <JGui.h>
class GameObserver;
class MTGDeck;
#define CAMPAIGNS_FOLDER "Res/campaigns/"
#define CAMPAIGNS_FOLDER "campaigns/"
class StoryDialogElement:public JGuiObject {

View File

@@ -654,7 +654,7 @@ int AIPlayer::combatDamages(){
AIStats * AIPlayer::getStats(){
if (!stats){
char statFile[512];
sprintf(statFile, RESPATH"/ai/baka/stats/%s.stats", opponent()->deckFileSmall.c_str());
sprintf(statFile,JGE_GET_RES("ai/baka/stats/%s.stats").c_str(), opponent()->deckFileSmall.c_str());
stats = NEW AIStats(this, statFile);
}
return stats;
@@ -677,7 +677,7 @@ AIPlayer * AIPlayerFactory::createAIPlayer(MTGAllCards * collection, Player * op
while (found){
found = 0;
char buffer[512];
sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbdecks+1);
sprintf(buffer, JGE_GET_RES("ai/baka/deck%i.txt").c_str(),nbdecks+1);
std::ifstream file(buffer);
if(file){
found = 1;
@@ -688,7 +688,7 @@ AIPlayer * AIPlayerFactory::createAIPlayer(MTGAllCards * collection, Player * op
if (!nbdecks) return NULL;
deckid = 1 + WRand() % (nbdecks);
}
sprintf(deckFile, RESPATH"/ai/baka/deck%i.txt",deckid);
sprintf(deckFile, JGE_GET_RES("ai/baka/deck%i.txt").c_str(),deckid);
sprintf(avatarFile, "avatar%i.jpg",deckid);
sprintf(deckFileSmall, "ai_baka_deck%i",deckid);
}

View File

@@ -255,7 +255,7 @@ int Credits::isDifficultyUnlocked(){
found = 0;
char buffer[512];
char aiSmallDeckName[512];
sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbAIDecks+1);
sprintf(buffer, JGE_GET_RES("ai/baka/deck%i.txt").c_str(),nbAIDecks+1);
if(fileExists(buffer)){
found = 1;
nbAIDecks++;

View File

@@ -90,6 +90,21 @@ void GameApp::Create()
//_CrtSetBreakAlloc(368);
LOG("starting Game");
//Find the Res folder
std::ifstream mfile("Res.txt");
string resPath;
if(mfile){
if (std::getline(mfile, resPath)) {
if (resPath[resPath.size()-1] == '\r') resPath.erase(resPath.size()-1); //Handle DOS files
//TODO ERROR Handling if file does not exist
JFileSystem::GetInstance()->SetResourceRoot(trim(resPath));
}
mfile.close();
}
LOG("Res Root:");
LOG(JFileSystem::GetInstance()->GetResourceRoot().c_str());
//Link this to our settings manager.
options.theGame = this;
@@ -99,16 +114,14 @@ void GameApp::Create()
LOG("Checking for music files");
//Test for Music files presence
string filepath = RESPATH;
filepath = filepath + "/" + resources.musicFile("Track0.mp3");
string filepath = JGE_GET_RES(resources.musicFile("Track0.mp3"));
std::ifstream file(filepath.c_str());
if (file)
file.close();
else
HasMusic = 0;
filepath = RESPATH;
filepath = filepath + "/" + resources.musicFile("Track1.mp3");
filepath = JGE_GET_RES(resources.musicFile("Track1.mp3"));
std::ifstream file2(filepath.c_str());
if (file2)
file2.close();
@@ -129,7 +142,8 @@ void GameApp::Create()
manaIcons[Constants::MTG_COLOR_ARTIFACT] = resources.RetrieveQuad("menuicons.png", 2 + 6*36, 38, 32, 32, "c_artifact",RETRIEVE_MANAGE);
for (int i = sizeof(manaIcons)/sizeof(manaIcons[0]) - 1; i >= 0; --i) manaIcons[i]->SetHotSpot(16,16);
for (int i = sizeof(manaIcons)/sizeof(manaIcons[0]) - 1; i >= 0; --i)
if (manaIcons[i]) manaIcons[i]->SetHotSpot(16,16);
LOG("--Loading back.jpg");
resources.RetrieveTexture("back.jpg",RETRIEVE_MANAGE);
@@ -142,9 +156,9 @@ void GameApp::Create()
LOG("--Loading particles.png");
resources.RetrieveTexture("particles.png",RETRIEVE_MANAGE);
jq = resources.RetrieveQuad("particles.png", 0, 0, 32, 32, "particles",RETRIEVE_MANAGE);
jq->SetHotSpot(16,16);
if (jq) jq->SetHotSpot(16,16);
jq = resources.RetrieveQuad("particles.png", 64, 0, 32, 32, "stars",RETRIEVE_MANAGE);
jq->SetHotSpot(16,16);
if (jq) jq->SetHotSpot(16,16);
LOG("--Loading fonts");
string lang = options[Options::LANG].str;
@@ -163,11 +177,11 @@ void GameApp::Create()
resources.RetrieveTexture("shadow.png",RETRIEVE_MANAGE);
jq = resources.RetrieveQuad("BattleIcon.png", 0, 0, 25, 25,"BattleIcon",RETRIEVE_MANAGE);
jq->SetHotSpot(12, 12);
if (jq) jq->SetHotSpot(12, 12);
jq = resources.RetrieveQuad("DefenderIcon.png", 0, 0, 24, 23,"DefenderIcon",RETRIEVE_MANAGE);
jq->SetHotSpot(12, 12);
if (jq) jq->SetHotSpot(12, 12);
jq = resources.RetrieveQuad("shadow.png", 0, 0, 16, 16,"shadow",RETRIEVE_MANAGE);
jq->SetHotSpot(8, 8);
if (jq) jq->SetHotSpot(8, 8);
jq = resources.RetrieveQuad("phasebar.png",0,0,0,0,"phasebar",RETRIEVE_MANAGE);
LOG("Init Collection");

View File

@@ -498,7 +498,7 @@ int GameSettings::save(){
if(profileOptions){
//Force our directories to exist.
MAKEDIR(RESPATH"/profiles");
MAKEDIR(JGE_GET_RES("profiles").c_str());
string temp = profileFile("","",false,false);
MAKEDIR(temp.c_str());
temp+="/stats";
@@ -521,11 +521,11 @@ string GameSettings::profileFile(string filename, string fallback,bool sanity, b
if(!(*this)[Options::ACTIVE_PROFILE].isDefault()) {
//No file, return root of profile directory
if(filename == ""){
sprintf(buf,"%sprofiles/%s",( relative ? "" : RESPATH"/" ),profile.c_str());
sprintf(buf,"%sprofiles/%s",( relative ? "" : JGE_GET_RES("").c_str() ),profile.c_str());
return buf;
}
//Return file
sprintf(buf,RESPATH"/profiles/%s/%s",profile.c_str(),filename.c_str());
sprintf(buf,JGE_GET_RES("profiles/%s/%s").c_str(),profile.c_str(),filename.c_str());
if(fileExists(buf)){
if(relative)
sprintf(buf,"profiles/%s/%s",profile.c_str(),filename.c_str());
@@ -534,13 +534,13 @@ string GameSettings::profileFile(string filename, string fallback,bool sanity, b
}
else{
//Use the default directory.
sprintf(buf,"%splayer%s%s",(relative ? "" : RESPATH"/"),(filename == "" ? "" : "/"), filename.c_str());
sprintf(buf,"%splayer%s%s",(relative ? "" :JGE_GET_RES("").c_str()),(filename == "" ? "" : "/"), filename.c_str());
return buf;
}
//Don't fallback if sanity checking is disabled..
if(!sanity){
sprintf(buf,"%sprofiles/%s%s%s",(relative ? "" : RESPATH"/"),profile.c_str(),(filename == "" ? "" : "/"), filename.c_str());
sprintf(buf,"%sprofiles/%s%s%s",(relative ? "" : JGE_GET_RES("").c_str()),profile.c_str(),(filename == "" ? "" : "/"), filename.c_str());
return buf;
}
@@ -548,7 +548,7 @@ string GameSettings::profileFile(string filename, string fallback,bool sanity, b
if(fallback == "")
return "";
sprintf(buf,"%s%s%s%s",(relative ? "" : RESPATH"/"),fallback.c_str(),(filename == "" ? "" : "/"), filename.c_str());
sprintf(buf,"%s%s%s%s",(relative ? "" : JGE_GET_RES("").c_str()),fallback.c_str(),(filename == "" ? "" : "/"), filename.c_str());
return buf;
}
@@ -561,7 +561,7 @@ void GameSettings::reloadProfile(bool images){
void GameSettings::checkProfile(){
if(!globalOptions)
globalOptions = NEW GameOptions(GLOBAL_SETTINGS);
globalOptions = NEW GameOptions(JGE_GET_RES(GLOBAL_SETTINGS));
//If it doesn't exist, load current profile.
if(!profileOptions){
@@ -589,7 +589,7 @@ void GameSettings::checkProfile(){
//Make the proper directories
if(profileOptions){
//Force our directories to exist.
MAKEDIR(RESPATH"/profiles");
MAKEDIR(JGE_GET_RES("profiles").c_str());
string temp = profileFile("","",false,false);
MAKEDIR(temp.c_str());
temp+="/stats";

View File

@@ -214,7 +214,7 @@ void GameStateDeckViewer::Start()
lastPos = 0;
lastTotal = 0;
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",mParent->collection);
pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(),mParent->collection);
playerdata = NEW PlayerData(mParent->collection);
myCollection = NEW DeckDataWrapper(playerdata->collection);
myCollection->Sort(WSrcCards::SORT_ALPHA);
@@ -306,7 +306,7 @@ void GameStateDeckViewer::saveDeck(){
void GameStateDeckViewer::saveAsAIDeck( string deckName )
{
DeckManager * deckManager = DeckManager::GetInstance();
vector<DeckMetaData *> aiDecks = GameState::getValidDeckMetaData( RESPATH"/ai/baka", "ai_baka", NULL);
vector<DeckMetaData *> aiDecks = GameState::getValidDeckMetaData( JGE_GET_RES("ai/baka"), "ai_baka", NULL);
int nbAiDecks = aiDecks.size() + 1;
aiDecks.clear();
@@ -320,8 +320,8 @@ void GameStateDeckViewer::saveAsAIDeck( string deckName )
else
oss << myDeck->parent->meta_desc;
string deckDesc = oss.str();
string filepath = RESPATH;
filepath.append("/ai/baka/").append( defaultAiDeckName ).append( ".txt" );
string filepath = JGE_GET_RES("ai/baka/");
filepath.append( defaultAiDeckName ).append( ".txt" );
DebugTrace("saving AI deck " << filepath);
myDeck->save( filepath, true, deckName, deckDesc);
}
@@ -1503,7 +1503,7 @@ int GameStateDeckViewer::loadDeck(int deckid){
found = 0;
char buffer[512];
char smallDeckName[512];
sprintf(buffer, "%s/deck%i.txt",RESPATH"/ai/baka",nbDecks+1);
sprintf(buffer, "%s/deck%i.txt",JGE_GET_RES("ai/baka").c_str(),nbDecks+1);
if(fileExists(buffer)){
MTGDeck * mtgd = NEW MTGDeck(buffer,NULL,1);
found = 1;

View File

@@ -81,7 +81,7 @@ void GameStateDuel::Start()
#ifdef TESTSUITE
SAFE_DELETE(testSuite);
testSuite = NEW TestSuite(RESPATH"/test/_tests.txt",mParent->collection);
testSuite = NEW TestSuite(JGE_GET_RES("test/_tests.txt").c_str(),mParent->collection);
#endif
mGamePhase = DUEL_STATE_CHOOSE_DECK1;
@@ -126,7 +126,7 @@ void GameStateDuel::Start()
else
deckmenu->Add( MENUITEM_NEW_DECK, "Create your Deck!", "Highly recommended to get\nthe full Wagic experience!");
premadeDeck = true;
fillDeckMenu(deckmenu,RESPATH"/player/premade");
fillDeckMenu(deckmenu,JGE_GET_RES("player/premade"));
}
deckmenu->Add( MENUITEM_NEW_DECK, "New Deck...", "Create a new deck to play with.");
deckmenu->Add( MENUITEM_CANCEL, "Main Menu", "Return to Main Menu");
@@ -143,7 +143,7 @@ void GameStateDuel::loadPlayer(int playerId, int decknb, int isAI){
if (!isAI) { //Human Player
char deckFile[255];
if(premadeDeck)
sprintf(deckFile, RESPATH"/player/premade/deck%i.txt",decknb);
sprintf(deckFile, JGE_GET_RES("player/premade/deck%i.txt").c_str(),decknb);
else
sprintf(deckFile, "%s/deck%i.txt",options.profileFile().c_str(), decknb);
char deckFileSmall[255];
@@ -226,8 +226,7 @@ void GameStateDuel::End()
//TODO Move This to utils or ResourceManager. Don't we have more generic functions that can do that?
bool GameStateDuel::MusicExist(string FileName){
string filepath = RESPATH;
filepath = filepath + "/" + resources.musicFile(FileName);
string filepath = JGE_GET_RES(resources.musicFile(FileName));
std::ifstream file(filepath.c_str());
if (file) {
file.close();
@@ -244,7 +243,7 @@ void GameStateDuel::ensureOpponentMenu(){
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
opponentMenu->Add( MENUITEM_EVIL_TWIN, "Evil Twin", _("Can you play against yourself?").c_str());
DeckManager * deckManager = DeckManager::GetInstance();
vector<DeckMetaData* > opponentDeckList = fillDeckMenu( opponentMenu, RESPATH"/ai/baka", "ai_baka", mPlayers[0]);
vector<DeckMetaData* > opponentDeckList = fillDeckMenu( opponentMenu, JGE_GET_RES("ai/baka"), "ai_baka", mPlayers[0]);
deckManager->updateMetaDataList(&opponentDeckList, true);
opponentMenu->Add( MENUITEM_CANCEL, "Cancel", _("Choose a different player deck").c_str());
opponentDeckList.clear();

View File

@@ -103,7 +103,7 @@ void GameStateMenu::Create()
for (int j=0;j<2;j++){
sprintf(buf,"menuicons%d%d",i,j);
mIcons[n] = resources.RetrieveQuad("menuicons.png", 2 + i * 36.0f, 2.0f + j * 36.0f, 32.0f, 32.0f, buf);
mIcons[n]->SetHotSpot(16,16);
if(mIcons[n]) mIcons[n]->SetHotSpot(16,16);
n++;
}
}
@@ -112,7 +112,7 @@ void GameStateMenu::Create()
bool langChosen = false;
string lang = options[Options::LANG].str;
if (lang.size()){
lang = "Res/lang/" + lang + ".txt";
lang = JGE_GET_RES("lang/") + lang + ".txt";
if (fileExists(lang.c_str())) langChosen = true;
}
if (!langChosen){
@@ -155,7 +155,7 @@ void GameStateMenu::Start(){
bgTexture = resources.RetrieveTexture("menutitle.png", RETRIEVE_LOCK);
mBg = resources.RetrieveQuad("menutitle.png", 0, 0, 256, 166); // Create background quad for rendering.
mBg->SetHotSpot(128,50);
if (mBg) mBg->SetHotSpot(128,50);
if (MENU_STATE_MAJOR_MAINMENU == currentState)
currentState = currentState | MENU_STATE_MINOR_FADEIN;
@@ -286,7 +286,7 @@ string GameStateMenu::loadRandomWallpaper() {
return wallpaper;
vector<string> wallpapers;
std::ifstream file("Res/graphics/wallpapers.txt");
std::ifstream file(JGE_GET_RES("graphics/wallpapers.txt").c_str());
if (!file) return wallpaper;
@@ -322,11 +322,11 @@ void GameStateMenu::loadLangMenu(){
if (!subMenuController) return;
resetDirectory();
if (!mDip){
mDip = opendir("Res/lang");
mDip = opendir(JGE_GET_RES("lang").c_str());
}
while ((mDit = readdir(mDip))){
string filename = "Res/lang/";
string filename = JGE_GET_RES("lang/");
filename += mDit->d_name;
std::ifstream file(filename.c_str());
string s;
@@ -352,11 +352,11 @@ void GameStateMenu::listPrimitives(){
LOG("GameStateMenu::listPrimitives");
resetDirectory();
if (!mDip){
mDip = opendir("Res/sets/primitives/");
mDip = opendir(JGE_GET_RES("sets/primitives/").c_str());
}
while ((mDit = readdir(mDip))){
string filename = "Res/sets/primitives/";
string filename = JGE_GET_RES("sets/primitives/");
filename += mDit->d_name;
std::ifstream file(filename.c_str());
if(!file) continue;
@@ -414,7 +414,7 @@ void GameStateMenu::Update(float dt)
}else{
mReadConf = 1;
}
if (!nextDirectory(RESPATH"/sets/","_cards.dat")){
if (!nextDirectory(JGE_GET_RES("sets/").c_str(),"_cards.dat")){
//Remove temporary translations
Translator::GetInstance()->tempValues.clear();

View File

@@ -79,7 +79,7 @@ void GameStateShop::Start(){
MTGAllCards * ac = GameApp::collection;
playerdata = NEW PlayerData(ac);
myCollection = NEW DeckDataWrapper(playerdata->collection);
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",ac);
pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(),ac);
for(int i=0;i<SHOP_SLOTS;i++){
WGuiCardDistort * dist;
if(i < BOOSTER_SLOTS)

View File

@@ -55,7 +55,7 @@ void GameStateStory::loadStoriesMenu(const char * root){
void GameStateStory::Start() {
flow = NULL;
menu = NULL;
loadStoriesMenu( RESPATH"/campaigns/");
loadStoriesMenu(JGE_GET_RES("campaigns/").c_str());
}
void GameStateStory::Update(float dt) {

View File

@@ -513,7 +513,7 @@ MTGDeck::MTGDeck(MTGAllCards * _allcards){
}
int MTGDeck::totalPrice(){
int total = 0;
PriceList * pricelist = NEW PriceList(RESPATH"/settings/prices.dat",GameApp::collection);
PriceList * pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(),GameApp::collection);
map<int,int>::iterator it;
for ( it=cards.begin() ; it != cards.end(); it++ ){
int nb = it->second;
@@ -932,7 +932,7 @@ MTGSetInfo::MTGSetInfo(string _id) {
counts[i] = 0;
char myFilename[4096];
sprintf(myFilename, RESPATH"/sets/%s/booster.txt", id.c_str());
sprintf(myFilename, JGE_GET_RES("sets/%s/booster.txt").c_str(), id.c_str());
mPack = NEW MTGPack(myFilename);
if(!mPack->isValid()){
SAFE_DELETE(mPack);

View File

@@ -220,13 +220,13 @@ MTGPack * MTGPacks::randomPack(int key){
return packs[key%s];
}
void MTGPacks::loadAll(){
DIR *mDip = opendir(RESPATH"/packs/");
DIR *mDip = opendir(JGE_GET_RES("packs/").c_str());
struct dirent *mDit;
if(!mDip) return;
while ((mDit = readdir(mDip))){
char myFilename[4096];
sprintf(myFilename, RESPATH"/packs/%s", mDit->d_name);
sprintf(myFilename, JGE_GET_RES("packs/%s").c_str(), mDit->d_name);
if(mDit->d_name[0] == '.') continue;
if(!strcmp(mDit->d_name,"default_booster.txt")) continue;
MTGPack * p = NEW MTGPack(myFilename);
@@ -276,7 +276,7 @@ bool MTGPack::isUnlocked(){
MTGPack * MTGPacks::getDefault(){
if(!defaultBooster.isValid()){
defaultBooster.load(RESPATH"/packs/default_booster.txt");
defaultBooster.load(JGE_GET_RES("packs/default_booster.txt"));
defaultBooster.unlockStatus = 1;
if(!defaultBooster.isValid()){
MTGPackSlot * ps = NEW MTGPackSlot(); ps->copies = 1;

View File

@@ -94,7 +94,7 @@ void OptionSelect::addSelection(string s){
//OptionProfile
const string OptionProfile::DIRTESTER = "collection.dat";
OptionProfile::OptionProfile(GameApp * _app, JGuiListener * jgl) : OptionDirectory(RESPATH"/profiles", Options::ACTIVE_PROFILE, "Profile", DIRTESTER){
OptionProfile::OptionProfile(GameApp * _app, JGuiListener * jgl) : OptionDirectory(JGE_GET_RES("profiles"), Options::ACTIVE_PROFILE, "Profile", DIRTESTER){
app = _app;
listener = jgl;
height=60;
@@ -271,10 +271,10 @@ void OptionLanguage::Reload(){
struct dirent *mDit;
DIR *mDip;
mDip = opendir("Res/lang");
mDip = opendir(JGE_GET_RES("lang").c_str());
while ((mDit = readdir(mDip))){
string filename = "Res/lang/";
string filename = JGE_GET_RES("lang/");
filename += mDit->d_name;
std::ifstream file(filename.c_str());
string s;
@@ -368,7 +368,7 @@ OptionDirectory::OptionDirectory(string root, int id, string displayValue, strin
}
const string OptionTheme::DIRTESTER = "preview.png";
OptionTheme::OptionTheme(OptionThemeStyle * style) : OptionDirectory(RESPATH"/themes", Options::ACTIVE_THEME, "Current Theme", DIRTESTER){
OptionTheme::OptionTheme(OptionThemeStyle * style) : OptionDirectory(JGE_GET_RES("themes"), Options::ACTIVE_THEME, "Current Theme", DIRTESTER){
addSelection("Default");
sort(selections.begin(),selections.end());
initSelections();
@@ -402,9 +402,9 @@ void OptionTheme::Render(){
author = "";
bChecked = true;
if(selections[value] == "Default")
sprintf(buf,RESPATH"/graphics/themeinfo.txt");
sprintf(buf,JGE_GET_RES("graphics/themeinfo.txt").c_str());
else
sprintf(buf,RESPATH"/themes/%s/themeinfo.txt",selections[value].c_str());
sprintf(buf,JGE_GET_RES("themes/%s/themeinfo.txt").c_str(),selections[value].c_str());
std::ifstream file(buf);
if(file){
string temp;

View File

@@ -383,7 +383,7 @@ int Rules::load(string _filename){
if (fileExists(_filename.c_str())){
sprintf(filename, "%s", _filename.c_str());
}else{
sprintf(filename, RESPATH"/rules/%s", _filename.c_str());
sprintf(filename, JGE_GET_RES("rules/%s").c_str(), _filename.c_str());
}
std::ifstream file(filename);
std::string s;

View File

@@ -269,7 +269,7 @@ void StoryDuel::init(){
Player * players[2];
char folder[255], deckFile[255],deckFileSmall[255];
sprintf(folder, CAMPAIGNS_FOLDER"%s/%s" ,mParent->folder.c_str(), pageId.c_str());
sprintf(folder, JGE_GET_RES(CAMPAIGNS_FOLDER"%s/%s").c_str() ,mParent->folder.c_str(), pageId.c_str());
sprintf(deckFile, "%s/deck.txt", folder);
MTGDeck * tempDeck = NEW MTGDeck(deckFile, GameApp::collection);

View File

@@ -40,7 +40,7 @@ string WStyle::stylized(string filename){
void StyleManager::loadRules(){
killRules();
//TODO Placeholder until XML format available.
string filename = RESPATH"/" + resources.graphicsFile("style.txt");
string filename = JGE_GET_RES(resources.graphicsFile("style.txt"));
TiXmlDocument xmlfile(filename.c_str());
if(!xmlfile.LoadFile())
return;

View File

@@ -165,7 +165,7 @@ void Task::loadAIDeckNames() {
while (found){
found = 0;
char buffer[512];
sprintf(buffer, "%s/deck%i.txt",RESPATH"/ai/baka",nbDecks + 1);
sprintf(buffer, "%s/deck%i.txt",JGE_GET_RES("ai/baka").c_str(),nbDecks + 1);
if(fileExists(buffer)){
found = 1;

View File

@@ -316,7 +316,7 @@ void TestSuite::initGame(){
DebugTrace("TESTUITE Init Game Done !");
}
int TestSuite::Log(const char * text){
ofstream file (RESPATH"/test/results.html",ios_base::app);
ofstream file (JGE_GET_RES("test/results.html").c_str(),ios_base::app);
if (file){
file << text;
file << "\n";
@@ -429,7 +429,7 @@ TestSuite::TestSuite(const char * filename,MTGAllCards* _collection){
file.close();
}
ofstream file2 (RESPATH"/test/results.html");
ofstream file2 (JGE_GET_RES("/test/results.html").c_str());
if (file2){
file2 << "<html><head>";
#ifdef WIN32
@@ -496,7 +496,7 @@ int TestSuite::load(const char * _filename){
forceAbility = false;
gameType = GAME_TYPE_CLASSIC;
char filename[4096];
sprintf(filename, RESPATH"/test/%s", _filename);
sprintf(filename, JGE_GET_RES("/test/%s").c_str(), _filename);
std::ifstream file(filename);
std::string s;
loadRandValues("");

View File

@@ -37,7 +37,7 @@ string Translator::translate(string value){
Translator::~Translator(){
#if defined DEBUG_TRANSLATE
if (!checkMisses) return;
std::ofstream file("Res/lang/missing.txt");
std::ofstream file(JGE_GET_RES("lang/missing.txt").c_str());
char writer[4096];
if (file){
map<string,int>::iterator it;
@@ -78,7 +78,7 @@ void Translator::load(string filename, map<string,string> * dictionary) {
#if defined DEBUG_TRANSLATE
if (!checkMisses) return;
std::ifstream file2("Res/lang/dontcare.txt");
std::ifstream file2(JGE_GET_RES("lang/dontcare.txt").c_str());
if(file2){
string s;
@@ -98,14 +98,14 @@ void Translator::load(string filename, map<string,string> * dictionary) {
void Translator::initCards(){
string lang = options[Options::LANG].str;
if (!lang.size()) return;
string cards_dict = "Res/lang/" + lang + "_cards.txt";
string cards_dict = JGE_GET_RES("lang/") + lang + "_cards.txt";
load(cards_dict,&tempValues);
}
void Translator::initDecks(){
string lang = options[Options::LANG].str;
if (!lang.size()) return;
string decks_dict = "Res/lang/" + lang + "_decks.txt";
string decks_dict = JGE_GET_RES("lang/") + lang + "_decks.txt";
// Load file
std::ifstream file(decks_dict.c_str());
@@ -136,7 +136,7 @@ void Translator::init() {
#endif
string lang = options[Options::LANG].str;
if (!lang.size()) return;
string name = "Res/lang/" + lang + ".txt";
string name = JGE_GET_RES("lang/") + lang + ".txt";
if (fileExists(name.c_str())){
// fixup for Chinese language support.

View File

@@ -489,7 +489,7 @@ int WSrcDeck::getCount(int count){
}
int WSrcDeck::totalPrice(){
int total = 0;
PriceList * pricelist = NEW PriceList(RESPATH"/settings/prices.dat",GameApp::collection);
PriceList * pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(),GameApp::collection);
map<int,int>::iterator it;
for ( it=copies.begin() ; it != copies.end(); it++ ){
int nb = it->second;

View File

@@ -683,7 +683,7 @@ string WResourceManager::cardFile(const string filename){
if(set.size()){
char zipname[512];
sprintf(zipname, "Res/themes/%s/sets/%s/%s.zip", theme.c_str(), set.c_str(),set.c_str());
sprintf(zipname, JGE_GET_RES("themes/%s/sets/%s/%s.zip").c_str(), theme.c_str(), set.c_str(),set.c_str());
if (fs->AttachZipFile(zipname))
return filename.substr(i+1);
}
@@ -718,7 +718,7 @@ string WResourceManager::cardFile(const string filename){
if(set.size()){
char zipname[512];
sprintf(zipname, "Res/sets/%s/%s.zip", set.c_str(),set.c_str());
sprintf(zipname, JGE_GET_RES("sets/%s/%s.zip").c_str(), set.c_str(),set.c_str());
if (fs->AttachZipFile(zipname))
return filename.substr(i+1);
}
@@ -808,13 +808,13 @@ int WResourceManager::dirOK(string dirname){
char fname[512];
#if defined (WIN32)
sprintf(fname,RESPATH"/%s",dirname.c_str());
sprintf(fname,JGE_GET_RES(dirname).c_str());
struct _stat statBuffer;
return (_stat(fname, &statBuffer) >= 0 && // make sure it exists
statBuffer.st_mode & S_IFDIR); // and it's not a file
#else
sprintf(fname,RESPATH"/%s",dirname.c_str());
sprintf(fname,JGE_GET_RES(dirname).c_str());
struct stat st;
if(stat(fname,&st) == 0)
return 1;
@@ -824,11 +824,9 @@ char fname[512];
int WResourceManager::fileOK(string filename, bool relative){
char fname[512];
std::ifstream * fp = NULL;
if(relative){
sprintf(fname,RESPATH"/%s",filename.c_str());
fp = NEW std::ifstream(fname);
fp = NEW std::ifstream(JGE_GET_RES(filename).c_str());
}
else
fp = NEW std::ifstream(filename.c_str());

View File

@@ -64,9 +64,7 @@ if(fichier){
return 1;
}
char alternateFilename[512];
sprintf(alternateFilename, RESPATH"/%s",filename);
std::ifstream fichier2(alternateFilename);
std::ifstream fichier2(JGE_GET_RES(filename).c_str());
if(fichier2){
fichier2.close();
return 1;