Erwan
- 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:
@@ -11,6 +11,9 @@
|
||||
#ifndef _FILE_SYSTEM_H_
|
||||
#define _FILE_SYSTEM_H_
|
||||
|
||||
#define JGE_GET_RES(filename) JFileSystem::GetInstance()->GetResourceFile(filename)
|
||||
#define JGE_GET_RESPATH() JFileSystem::GetInstance()->GetResourceRoot()
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@@ -109,6 +112,10 @@ public:
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetResourceRoot(const string& resourceRoot);
|
||||
string GetResourceRoot();
|
||||
|
||||
// Returns a string prefixed with the resource path
|
||||
string GetResourceFile(string filename);
|
||||
|
||||
protected:
|
||||
JFileSystem();
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#ifndef _JGE_H_
|
||||
#define _JGE_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
Binary file not shown.
@@ -257,3 +257,14 @@ void JFileSystem::SetResourceRoot(const string& resourceRoot)
|
||||
{
|
||||
mResourceRoot = resourceRoot;
|
||||
}
|
||||
|
||||
string JFileSystem::GetResourceRoot()
|
||||
{
|
||||
return mResourceRoot;
|
||||
}
|
||||
|
||||
string JFileSystem::GetResourceFile(string filename)
|
||||
{
|
||||
string result = mResourceRoot;
|
||||
return result.append(filename);
|
||||
}
|
||||
+1
-5
@@ -965,11 +965,7 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
JLOG("JRenderer::LoadJPG");
|
||||
textureInfo.mBits = NULL;
|
||||
char filenamenew[4096];
|
||||
#ifdef RESPATH
|
||||
sprintf(filenamenew, RESPATH"/%s", filename);
|
||||
#else
|
||||
sprintf(filenamenew, "Res/%s", filename);
|
||||
#endif
|
||||
sprintf(filenamenew, JGE_GET_RES(filename).c_str());
|
||||
|
||||
bool useVideoRAM = (mode == TEX_TYPE_USE_VRAM);
|
||||
|
||||
|
||||
+4
-6
@@ -9,6 +9,7 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#include "../include/JSoundSystem.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
#include "../include/JAudio.h"
|
||||
#include "../include/JMP3.h"
|
||||
#include <string>
|
||||
@@ -108,12 +109,9 @@ void JSoundSystem::DestroySoundSystem()
|
||||
|
||||
JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
{
|
||||
#ifdef RESPATH
|
||||
string s = RESPATH"/";
|
||||
#else
|
||||
string s = "Res/";
|
||||
#endif
|
||||
s.append(fileName);
|
||||
|
||||
string s = JGE_GET_RES(fileName);
|
||||
|
||||
JMusic *music = new JMusic();
|
||||
if (music)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user