Compare commits

..

5 Commits

Author SHA1 Message Date
Dmitry Panin 0bb6cf4a4a Removing previous releases in order to upload new one 2013-12-12 01:53:46 +04:00
Dmitry Panin 8691e7e2c7 Excluding tag latest-master from build 2013-12-12 01:26:23 +04:00
Dmitry Panin 8717e148bf One more test upload 2013-12-12 01:12:55 +04:00
Dmitry Panin 9faca83e18 changed git tag 2013-12-12 00:18:59 +04:00
Dmitry Panin fd081c4ad2 hacking releases 2013-12-11 23:58:00 +04:00
53 changed files with 501 additions and 1980 deletions
+2 -5
View File
@@ -8,11 +8,8 @@ before_install:
- export PATH="$PATH:$PSPDEV/bin:$PSPSDK/bin"
- export ANDROID="android-sdk-linux/tools/android"
install:
- sudo add-apt-repository ppa:tobydox/mingw -y
- sudo apt-get update -qq
- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch jq mingw32-x-gcc mingw32-x-qt; fi
- sudo ln -s /opt/mingw32/bin/moc /opt/mingw32/bin/i686-w64-mingw32-moc
- sudo ln -s /opt/mingw32/bin/rcc /opt/mingw32/bin/i686-w64-mingw32-rcc
- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch jq; fi
- wget -O sdk.lzma http://sourceforge.net/projects/minpspw/files/SDK%20%2B%20devpak/pspsdk%200.11.2/minpspw_0.11.2-amd64.tar.lzma/download
- tar -x --xz -f sdk.lzma
- wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv
@@ -20,7 +17,7 @@ install:
- tar --absolute-names -jxf android-ndk-r9-linux-x86_64.tar.bz2
- tar -zxf android-sdk_r22-linux.tgz
- $ANDROID list sdk -a
- echo yes | $ANDROID update sdk -a --filter 1,2,5,19 --no-ui --force > log.txt
- echo yes | $ANDROID update sdk -a --filter 1,2,4,18 --no-ui --force > log.txt
- sudo pip install pyjavaproperties
script: ./travis-script.sh
env:
+1
View File
@@ -297,6 +297,7 @@ public:
private:
float mTimer;
float mFrameTime;
JAnimator* mAnimator;
vector<JAnimatorObject *> mObjects;
};
+1
View File
@@ -37,6 +37,7 @@ private:
float mTexY;
float mTexWidth;
float mTexHeight;
JTexture* mTexture;
JQuad* mQuad;
+12 -38
View File
@@ -1,10 +1,6 @@
#ifndef _J_FILE_SYSTEM_H_
#define _J_FILE_SYSTEM_H_
#ifdef QT_CONFIG
#include <QFile>
#endif
#include "zfsystem.h"
#include <string>
using zip_file_system::filesystem;
@@ -22,38 +18,13 @@ using namespace std;
/// archive file.
///
//////////////////////////////////////////////////////////////////////////
class JFile {
friend class JFileSystem;
filesystem::limited_file_info * mCurrentFileInZip;
izfstream mFile;
#ifdef QT_CONFIG
QFile *mpqFile;
#endif
public:
JFile() : mCurrentFileInZip(0)
#ifdef QT_CONFIG
, mpqFile(0)
#endif
{
};
~JFile() {
#ifdef QT_CONFIG
if(mpqFile) {
mpqFile->close();
delete mpqFile;
}
#endif
if (mFile)
mFile.close();
};
};
class JZipCache {
public:
JZipCache();
~JZipCache();
map<string, filesystem::limited_file_info> dir;
};
class JFileSystem {
@@ -61,21 +32,23 @@ private:
string mSystemFSPath, mUserFSPath;
filesystem * mSystemFS, * mUserFS;
static JFileSystem* mInstance;
izfstream mFile;
map<string,JZipCache *>mZipCache;
unsigned int mZipCachedElementsCount;
string mZipFileName;
int mFileSize;
char *mPassword;
bool mZipAvailable;
void preloadZip(const string& filename);
izfstream mZipFile;
filesystem::limited_file_info * mCurrentFileInZip;
std::vector<std::string>& scanRealFolder(const std::string& folderName, std::vector<std::string>& results);
bool openForRead(izfstream & File, const string & FilePath);
int GetFileSize(izfstream & file);
public:
//////////////////////////////////////////////////////////////////////////
/// Attach ZIP archive to the file system.
///
@@ -110,7 +83,7 @@ public:
/// Open file for reading.
///
//////////////////////////////////////////////////////////////////////////
JFile* OpenFile(const string &filename);
bool OpenFile(const string &filename);
//Fills the vector results with a list of children of the given folder
std::vector<std::string>& scanfolder(const std::string& folderName, std::vector<std::string>& results);
@@ -124,19 +97,20 @@ public:
/// @return Number of bytes read.
///
//////////////////////////////////////////////////////////////////////////
int ReadFile(JFile*, void *buffer, int size);
int ReadFile(void *buffer, int size);
//////////////////////////////////////////////////////////////////////////
/// Get size of file.
///
//////////////////////////////////////////////////////////////////////////
int GetFileSize(JFile*);
int GetFileSize();
int GetFileSize(izfstream & file);
//////////////////////////////////////////////////////////////////////////
/// Close file.
///
//////////////////////////////////////////////////////////////////////////
void CloseFile(JFile*);
void CloseFile();
//////////////////////////////////////////////////////////////////////////
/// Set root for all the following file operations
@@ -150,8 +124,8 @@ public:
void SetUSerRoot(const string& resourceRoot);
string GetUserRoot() { return mUserFSPath; };
bool openForRead(izfstream & File, const string & FilePath);
bool readIntoString(const string & FilePath, string & target);
bool ReadFileLine(JFile*, string&);
bool openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode = ios_base::out );
bool Rename(string from, string to);
@@ -189,4 +163,4 @@ protected:
#endif
#endif
+1
View File
@@ -178,6 +178,7 @@ private:
float mSpacing;
PIXEL_TYPE mColor;
int mBlend;
int mBase;
+15 -89
View File
@@ -1,7 +1,7 @@
#ifndef THREADING_H
#define THREADING_H
#if !defined(PSP) && !defined(QT_CONFIG) && !(__cplusplus > 199711L)
#if !defined(PSP) && !defined(QT_CONFIG)
#include <boost/date_time.hpp>
#ifdef WIN32
@@ -14,7 +14,7 @@
#endif
#include <boost/thread/mutex.hpp>
#elif defined(PSP)
#elif !defined(QT_CONFIG)
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
@@ -26,7 +26,7 @@
namespace boost
{
/**
** PSP specific variant of a boost mutex & scoped_lock
** PSP specific variant of a boost mutex & scoped_lock
*/
template <class Mutex>
@@ -60,7 +60,7 @@ namespace boost
{
sceKernelDeleteSema(mID);
}
void lock()
{
int result = sceKernelWaitSema(mID, 1, 0);
@@ -142,7 +142,7 @@ namespace boost
}
}
int mID;
int mThreadID;
volatile int mRecursionCount;
@@ -164,7 +164,7 @@ namespace boost
/**
** Emulating boost::thread configuration glue, with some shortcuts
** Emulating boost::thread configuration glue, with some shortcuts
** This detail namespace is a distillation of boost's thread.hpp, thread_data.hpp.
*/
namespace detail
@@ -212,13 +212,13 @@ namespace boost
**
** The intent of its usage is this form only:
** mWorkerThread = boost::thread(ThreadProc, this);
** where ThreadProc is a static member function of the 'this' class,eg:
** static void FOO::ThreadProc(void* inParam)
** {
** FOO* instance = reinterpret_cast<FOO*>(inParam);
** // now you have class instance data available...
** }
**
** where ThreadProc is a static member function of the 'this' class,eg:
** static void FOO::ThreadProc(void* inParam)
** {
** FOO* instance = reinterpret_cast<FOO*>(inParam);
** // now you have class instance data available...
** }
**
** Any other variant of a thread proc with more than one param is unimplemented.
*/
class thread
@@ -227,7 +227,7 @@ namespace boost
** Helper class for sceKernelStartThread, which passes args by value, not by reference
** We use this struct to wrap any pointers that we want to pass to the worker thread.
*/
struct CallbackData
struct CallbackData
{
CallbackData(detail::thread_data_ptr inThreadInfo)
: mThreadInfo(inThreadInfo)
@@ -307,7 +307,7 @@ namespace boost
}
}
#elif defined(QT_CONFIG) && (__cplusplus <= 199711L)
#elif defined(QT_CONFIG)
#include <QMutex>
#include <QThread>
@@ -537,80 +537,6 @@ namespace boost
}
}
#elif (__cplusplus > 199711L)
#include <thread>
#include <mutex>
namespace boost
{
typedef std::thread thread;
template <class Mutex>
struct unique_lock
{
unique_lock(Mutex& inMutex) : mMutex(&inMutex)
{
mMutex->lock();
}
~unique_lock()
{
mMutex->unlock();
}
Mutex* mMutex;
};
class mutex
{
public:
typedef unique_lock<mutex> scoped_lock;
mutex()
: mQMutex()
{
}
~mutex()
{
}
void lock()
{
mQMutex.lock();
}
void unlock()
{
mQMutex.unlock();
}
std::mutex mQMutex;
private:
mutex(mutex const&);
mutex& operator=(mutex const&);
};
namespace posix_time
{
typedef unsigned int milliseconds;
}
/**
** boost's platform neutral sleep call.
*/
namespace this_thread
{
inline void sleep(boost::posix_time::milliseconds const& time)
{
std::this_thread::sleep_for(std::chrono::milliseconds(time));
}
}
}
#endif
#endif // THREADING_H
-15
View File
@@ -136,20 +136,6 @@ signals:
private slots:
private:
int lastPosx(){
#if QT_VERSION >= 0x050000
return m_lastPos.x()*devicePixelRatio();
#else
return m_lastPos.x();
#endif
}
int lastPosy(){
#if QT_VERSION >= 0x050000
return m_lastPos.y()*devicePixelRatio();
#else
return m_lastPos.y();
#endif
}
void timerEvent( QTimerEvent* );
void doAndEnqueue(JButton action) {
m_engine->HoldKey_NoRepeat(action);
@@ -168,7 +154,6 @@ private:
int m_timerId;
bool m_active;
QRect m_viewPort;
QPoint m_lastPos;
#ifdef QT_WIDGET
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID)
int mMouseDownX;
+4 -5
View File
@@ -44,12 +44,11 @@ bool JAnimator::Load(const char* scriptFile)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(scriptFile);
if (!jFile) return false;
if (!fileSystem->OpenFile(scriptFile)) return false;
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
@@ -174,7 +173,7 @@ bool JAnimator::Load(const char* scriptFile)
}
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
return true;
+16 -17
View File
@@ -49,8 +49,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(fileName);
if (!jFile)
if (!fileSystem->OpenFile(fileName))
return 0;
memset(p_wav, 0, sizeof(WAVDATA));
@@ -58,14 +57,14 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
char head[256];
memset(head, 0, 256);
//sceIoRead(fd, head, 20);
fileSystem->ReadFile(jFile, head, 20);
fileSystem->ReadFile(head, 20);
char string[8];
memset(string, 0, 8);
memcpy(string, head, 4);
if (0!=strcmp(string, "RIFF"))
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
memset(string, 0, 8);
@@ -73,7 +72,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (0!=strcmp(string, "WAVE"))
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
memset(string, 0, 8);
@@ -81,42 +80,42 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (0!=strcmp(string, "fmt"))
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
int fmtSize = 0;
memcpy(&fmtSize, head+16, 4);
//sceIoRead(fd, head+20, fmtSize);
fileSystem->ReadFile(jFile, head+20,fmtSize );
fileSystem->ReadFile(head+20,fmtSize );
p_wav->headSize = 20+fmtSize;
while (1)
{
//sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
fileSystem->ReadFile(head+p_wav->headSize, 4);
memset(string, 0, 8);
memcpy(string, head+p_wav->headSize, 4);
p_wav->headSize += 4;
if (0!=strcmp(string, "data"))
{
//sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
fileSystem->ReadFile(head+p_wav->headSize, 4);
memcpy(&fmtSize, head+p_wav->headSize, 4);
p_wav->headSize += 4;
//sceIoRead(fd, head+p_wav->headSize, fmtSize);
fileSystem->ReadFile(jFile, head+p_wav->headSize, fmtSize);
fileSystem->ReadFile(head+p_wav->headSize, fmtSize);
p_wav->headSize += fmtSize;
}
else
{
//sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
fileSystem->ReadFile(head+p_wav->headSize, 4);
p_wav->headSize += 4;
break;
}
if (p_wav->headSize>191)
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
}
@@ -127,7 +126,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->channelCount!=1 && p_wav->channelCount!=2)
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
memcpy(&p_wav->samplePerSecond, head+24, 4);
@@ -137,7 +136,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->bytePerSample!=1 && p_wav->bytePerSample!=2)
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
p_wav->nSample = 44100 / p_wav->samplePerSecond;
@@ -148,17 +147,17 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->soundSize>4096000)
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
p_wav->buffer = (char*)malloc(p_wav->soundSize);
memset(p_wav->buffer, 0, p_wav->soundSize);
//sceIoRead(fd, p_wav->buffer, p_wav->soundSize);
fileSystem->ReadFile(jFile, p_wav->buffer, p_wav->soundSize);
fileSystem->ReadFile(p_wav->buffer, p_wav->soundSize);
p_wav->bytePosition = 0;
p_wav->fd = -1;
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
}
else
{
+72 -169
View File
@@ -107,6 +107,7 @@ JFileSystem* JFileSystem::GetInstance()
// Tries to set the system and user paths.
// On some OSes, the parameters get overriden by hardcoded values
JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
{
string systemPath = _systemPath;
string userPath = _userPath;
@@ -130,8 +131,8 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
dir.mkdir(USERDIR);
dir.cd(USERDIR);
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
DebugTrace("User path " << userPath);
DebugTrace("System path " << systemPath);
@@ -191,6 +192,9 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
mZipAvailable = false;
mZipCachedElementsCount = 0;
mPassword = NULL;
mFileSize = 0;
mCurrentFileInZip = NULL;
};
void JFileSystem::Destroy()
@@ -204,26 +208,14 @@ void JFileSystem::Destroy()
bool JFileSystem::DirExists(const string& strDirname)
{
return (
(mSystemFS && mSystemFS->DirExists(strDirname))
|| mUserFS->DirExists(strDirname)
#ifdef QT_CONFIG
|| QDir(QString(":/") + strDirname.c_str()).exists()
#endif
);
return (mSystemFS && mSystemFS->DirExists(strDirname)) || mUserFS->DirExists(strDirname);
}
bool JFileSystem::FileExists(const string& strFilename)
{
if (strFilename.length() < 1 ) return false;
return (
(mSystemFS && mSystemFS->FileExists(strFilename))
|| mUserFS->FileExists(strFilename)
#ifdef QT_CONFIG
|| QFile(QString(":/") + strFilename.c_str()).exists()
#endif
);
return (mSystemFS && mSystemFS->FileExists(strFilename)) || mUserFS->FileExists(strFilename);
}
bool JFileSystem::MakeDir(const string & dir)
@@ -283,6 +275,7 @@ bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL
}
mZipAvailable = true;
return true;
}
@@ -292,6 +285,7 @@ void JFileSystem::DetachZipFile()
{
mZipFile.close();
}
mCurrentFileInZip = NULL;
mZipAvailable = false;
}
@@ -313,58 +307,24 @@ bool JFileSystem::openForRead(izfstream & File, const string & FilePath) {
bool JFileSystem::readIntoString(const string & FilePath, string & target)
{
bool result = false;
// Trying first with a izfstream
do {
izfstream file;
if (!openForRead(file, FilePath))
break;
int fileSize = GetFileSize(file);
#ifndef __MINGW32__
try {
#endif
target.resize((std::string::size_type) fileSize);
#ifndef __MINGW32__
} catch (bad_alloc&) {
break;
}
#endif
if (fileSize)
file.read(&target[0], fileSize);
file.close();
result = true;
} while (0);
#ifdef QT_CONFIG
// Now we try with qrc if we haven't finc anything yet
if (!result) do {
string path = string(":/") + FilePath.c_str();
QFile qfile(path.c_str());
qfile.open(QIODevice::ReadOnly);
if(!qfile.isReadable())
break;
int fileSize = qfile.size();
#ifndef __MINGW32__
try {
#endif
target.resize((std::string::size_type) fileSize);
#ifndef __MINGW32__
} catch (bad_alloc&) {
break;
}
#endif
if (fileSize)
qfile.read(&target[0], fileSize);
qfile.close();
result = true;
} while (0);
#endif //QT_CONFIG
return result;
izfstream file;
if (!openForRead(file, FilePath))
return false;
int fileSize = GetFileSize(file);
try {
target.resize((std::string::size_type) fileSize);
} catch (bad_alloc&) {
return false;
}
if (fileSize)
file.read(&target[0], fileSize);
file.close();
return true;
}
bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode)
@@ -410,72 +370,57 @@ bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_bas
return false;
}
JFile* JFileSystem::OpenFile(const string &filename)
bool JFileSystem::OpenFile(const string &filename)
{
bool result;
JFile* jFile = new JFile();
jFile->mCurrentFileInZip = NULL;
mCurrentFileInZip = NULL;
do {
if (!mZipAvailable || !mZipFile) {
result = openForRead(jFile->mFile, filename);
if(!result) {
#ifdef QT_CONFIG
string path = string(":/") + filename.c_str();
jFile->mpqFile = new QFile(path.c_str());
jFile->mpqFile->open(QIODevice::ReadOnly);
result = jFile->mpqFile->isReadable();
#endif
}
break;
}
if (!mZipAvailable || !mZipFile)
return openForRead(mFile, filename);
preloadZip(mZipFileName);
map<string,JZipCache *>::iterator it = mZipCache.find(mZipFileName);
if (it == mZipCache.end())
{
//DetachZipFile();
//return OpenFile(filename);
result = openForRead(jFile->mFile, filename);
break;
}
JZipCache * zc = it->second;
map<string, filesystem::limited_file_info>::iterator it2 = zc->dir.find(filename);
if (it2 == zc->dir.end())
{
/*DetachZipFile();
return OpenFile(filename); */
result = openForRead(jFile->mFile, filename);
break;
}
jFile->mCurrentFileInZip = &(it2->second);
result = true;
} while(0);
if(result)
return jFile;
else {
delete jFile;
return 0;
preloadZip(mZipFileName);
map<string,JZipCache *>::iterator it = mZipCache.find(mZipFileName);
if (it == mZipCache.end())
{
//DetachZipFile();
//return OpenFile(filename);
return openForRead(mFile, filename);
}
JZipCache * zc = it->second;
map<string, filesystem::limited_file_info>::iterator it2 = zc->dir.find(filename);
if (it2 == zc->dir.end())
{
/*DetachZipFile();
return OpenFile(filename); */
return openForRead(mFile, filename);
}
mCurrentFileInZip = &(it2->second);
mFileSize = it2->second.m_Size;
return true;
}
void JFileSystem::CloseFile(JFile* jFile)
void JFileSystem::CloseFile()
{
delete jFile;
if (mZipAvailable && mZipFile)
{
mCurrentFileInZip = NULL;
}
if (mFile)
mFile.close();
}
//returns 0 if less than "size" bits were read
int JFileSystem::ReadFile(JFile* jFile, void *buffer, int size)
int JFileSystem::ReadFile(void *buffer, int size)
{
if (jFile->mCurrentFileInZip)
if (mCurrentFileInZip)
{
assert(mZipFile);
if((size_t)size > jFile->mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
if((size_t)size > mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
return 0;
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, jFile->mCurrentFileInZip->m_Offset);
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, mCurrentFileInZip->m_Offset);
if (!mZipFile.seekg(offset))
return 0;
mZipFile.read((char *) buffer, size);
@@ -483,43 +428,16 @@ int JFileSystem::ReadFile(JFile* jFile, void *buffer, int size)
return size;
}
#ifdef QT_CONFIG
if(jFile->mpqFile) {
return jFile->mpqFile->read((char*)buffer, size);
}
#endif
if (!jFile->mFile)
if (!mFile)
return 0;
assert(!jFile->mFile.Zipped() || (size_t)size <= jFile->mFile.getUncompSize());
jFile->mFile.read((char *)buffer, size);
if (jFile->mFile.eof())
assert(!mFile.Zipped() || (size_t)size <= mFile.getUncompSize());
mFile.read((char *)buffer, size);
if (mFile.eof())
return 0;
return size;
}
bool JFileSystem::ReadFileLine(JFile* jFile, string& s)
{
if(!jFile) return false;
#ifdef QT_CONFIG
if(jFile->mpqFile) {
QString qs = jFile->mpqFile->readLine();
if(qs.isEmpty())
return false;
else {
s = qs.toStdString();
return true;
}
}
#endif
if(!jFile->mFile)
return 0;
assert(!jFile->mFile.Zipped());
return std::getline(jFile->mFile, s);
}
std::vector<std::string>& JFileSystem::scanRealFolder(const std::string& folderName, std::vector<std::string>& results)
{
DIR *dip = opendir(folderName.c_str());
@@ -607,17 +525,8 @@ std::vector<std::string>& JFileSystem::scanfolder(const std::string& _folderName
seen[systemReal[i]] = true;
}
}
#ifdef QT_CONFIG
string path = string(":/") + folderName;
QDir dir(path.c_str());
QStringList list = dir.entryList();
for(int i = 0; i < list.size(); i++)
{
seen[list.at(i).toStdString()] = true;
}
#endif
for(map<string,bool>::iterator it = seen.begin(); it != seen.end(); ++it)
for(map<string,bool>::iterator it = seen.begin(); it != seen.end(); ++it)
{
results.push_back(it->first);
}
@@ -631,18 +540,12 @@ std::vector<std::string> JFileSystem::scanfolder(const std::string& folderName)
return scanfolder(folderName, result);
}
int JFileSystem::GetFileSize(JFile* jFile)
int JFileSystem::GetFileSize()
{
if (jFile->mCurrentFileInZip)
return jFile->mCurrentFileInZip->m_Size;
if (mCurrentFileInZip)
return mFileSize;
#ifdef QT_CONFIG
if(jFile->mpqFile) {
return jFile->mpqFile->size();
}
#endif
return GetFileSize(jFile->mFile);
return GetFileSize(mFile);
}
bool JFileSystem::Rename(string _from, string _to)
+9 -10
View File
@@ -116,26 +116,25 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
int size;
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(engFileName);
if (!jFile)
if (!fileSys->OpenFile(engFileName))
return false;
size = fileSys->GetFileSize(jFile);
size = fileSys->GetFileSize();
mEngFont = new BYTE[size];
fileSys->ReadFile(jFile, mEngFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mEngFont, size);
fileSys->CloseFile();
jFile = fileSys->OpenFile(chnFileName);
if (!jFile)
if (!fileSys->OpenFile(chnFileName))
return false;
size = fileSys->GetFileSize(jFile);
size = fileSys->GetFileSize();
mChnFont = new BYTE[size];
fileSys->ReadFile(jFile, mChnFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mChnFont, size);
fileSys->CloseFile();
return true;
}
+21 -26
View File
@@ -892,10 +892,9 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
{
png_size_t check;
JFile* jFile = (JFile*)png_ptr->io_ptr;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
check = fileSystem->ReadFile(jFile, data, length);
check = fileSystem->ReadFile(data, length);
if (check != length)
{
@@ -1039,24 +1038,23 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
bits32 = NULL;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
{
return;
}
rawsize = fileSystem->GetFileSize(jFile);
rawsize = fileSystem->GetFileSize();
rawdata = new u8[rawsize];
if (!rawdata)
{
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return;
}
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
cinfo.err = jpeg_std_error(&jerr);
@@ -1364,25 +1362,24 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
u32* line;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return JGE_ERR_CANT_OPEN_FILE;
if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
//JLOG("PNG opened - creating read struct");
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) {
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return JGE_ERR_PNG;
}
//JLOG("Setting error callback func");
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn);
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_PNG;
}
png_init_io(png_ptr, NULL);
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn);
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr);
@@ -1395,7 +1392,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
line = (u32*) malloc(width * 4);
if (!line) {
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED;
}
@@ -1433,7 +1430,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
std::ostringstream stream;
stream << "Alloc failed for: Tex Width: " << texWidth << " Tex Height: " << kVerticalBlockSize << ", total bytes: " << texWidth * kVerticalBlockSize * sizeof(PIXEL_TYPE);
JLOG(stream.str().c_str());
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED;
}
@@ -1508,7 +1505,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
//JLOG("Closing PNG");
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
if (done)
{
@@ -1728,9 +1725,9 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
{
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = (JFile*)ft->UserData;
if (fileSys->ReadFile(jFile, buf, size))
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
if (fileSys->ReadFile(buf, size))
return size;
else
return 0;
@@ -1743,17 +1740,15 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(filename);
if (!jFile)
if (!fileSys->OpenFile(filename))
return;
DWORD bkcol;
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
if(result!=0)
textureInfo.mBits=NULL;
fileSys->CloseFile(jFile);
fileSys->CloseFile();
return ;
}
@@ -2267,4 +2262,4 @@ void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius,
void JRenderer::SetImageFilter(JImageFilter* imageFilter)
{
mImageFilter = imageFilter;
}
}
+3 -4
View File
@@ -42,11 +42,10 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
//FILE *file;
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(filename);
if (!jFile) return;
if (!fileSys->OpenFile(filename)) return;
fileSys->ReadFile(jFile, (u8 *)buffer, 2048);
fileSys->CloseFile(jFile);
fileSys->ReadFile((u8 *)buffer, 2048);
fileSys->CloseFile();
sprintf(filename, "%s.png", fontname);
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
+4 -5
View File
@@ -96,8 +96,7 @@ bool JMD2Model::Load(char *filename, char *textureName)
// open the model file
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
return false;
//filePtr = fopen(filename, "rb");
//if (filePtr == NULL)
@@ -108,13 +107,13 @@ bool JMD2Model::Load(char *filename, char *textureName)
//fileLen = ftell(filePtr);
//fseek(filePtr, 0, SEEK_SET);
fileLen = fileSystem->GetFileSize(jFile);
fileLen = fileSystem->GetFileSize();
// read entire file into buffer
buffer = (char*)malloc(fileLen + 1);
//fread(buffer, sizeof(char), fileLen, filePtr);
fileSystem->ReadFile(jFile, buffer, fileLen);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(buffer, fileLen);
fileSystem->CloseFile();
// extract model file header from buffer
modelHeader = (modelHeader_t*)buffer;
+4 -5
View File
@@ -47,15 +47,14 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
{
JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(modelName);
if (!jFile)
if (!fileSys->OpenFile(modelName))
return false;
int size = fileSys->GetFileSize(jFile);
int size = fileSys->GetFileSize();
char *buffer = new char[size];
fileSys->ReadFile(jFile, buffer, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(buffer, size);
fileSys->CloseFile();
Vector3D vert;
+4 -5
View File
@@ -55,12 +55,11 @@ bool JParticleEffect::Load(const char* filename)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return false;
if (!fileSystem->OpenFile(filename)) return false;
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
@@ -297,7 +296,7 @@ bool JParticleEffect::Load(const char* filename)
}
}
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
return true;
+5 -5
View File
@@ -93,13 +93,13 @@ bool JResourceManager::LoadResource(const string& resourceName)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(path.c_str());
if (!jFile) return false;
int size = fileSystem->GetFileSize(jFile);
if (!fileSystem->OpenFile(path.c_str())) return false;
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
@@ -179,7 +179,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
}
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
// JGERelease();
+4 -5
View File
@@ -41,12 +41,11 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return false;
if (!fileSystem->OpenFile(filename)) return false;
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
@@ -77,7 +76,7 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
}
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
return true;
+5 -6
View File
@@ -199,16 +199,15 @@ bool JTTFont::Load(const char *filename, int size, int mode)
if (FT_Init_FreeType( &mLibrary ) == 0)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (jFile)
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(filename))
{
mFontBitsSize = fileSystem->GetFileSize(jFile);
mFontBitsSize = fileSystem->GetFileSize();
mFontBits = (FT_Byte*)malloc(mFontBitsSize);
fileSystem->ReadFile(jFile, mFontBits, mFontBitsSize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(mFontBits, mFontBitsSize);
fileSystem->CloseFile();
if (FT_New_Memory_Face(mLibrary, mFontBits, mFontBitsSize, 0, &mFace ) == 0)
{
+4 -5
View File
@@ -57,20 +57,19 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap __attribute__((unused)))
// Load font description
JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(szFont);
if (!jFile) return;
if (!fileSys->OpenFile(szFont)) return;
//data=hge->Resource_Load(szFont, &size);
//if(!data) return;
size = fileSys->GetFileSize(jFile);
size = fileSys->GetFileSize();
desc = new char[size+1];
//memcpy(desc,data,size);
fileSys->ReadFile(jFile, desc, size);
fileSys->ReadFile(desc, size);
desc[size]=0;
//hge->Resource_Free(data);
fileSys->CloseFile(jFile);
fileSys->CloseFile();
pdesc=_get_line(desc,linebuf);
if(strcmp(linebuf, FNTHEADERTAG))
+40 -35
View File
@@ -50,41 +50,46 @@ float Random_Float(float min, float max)
hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
{
JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(filename);
if (!jFile) return;
//if(!psi) return;
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
//hge->Resource_Free(psi);
// Skip reading the pointer as it may be larger than 4 bytes in the structure
void *dummyPointer;
fileSys->ReadFile(jFile, &dummyPointer, 4);
// we're actually trying to read more than the file size now, but it's no problem.
// Note that this fix is only to avoid the largest problems, filling a structure
// by directly reading a file, is really a bad idea ...
fileSys->ReadFile(jFile, &(info.nEmission), sizeof(hgeParticleSystemInfo) - 4);
fileSys->CloseFile(jFile);
info.sprite=sprite;
// info.fGravityMin *= 100;
// info.fGravityMax *= 100;
// info.fSpeedMin *= 100;
// info.fSpeedMax *= 100;
vecLocation.x=vecPrevLocation.x=0.0f;
vecLocation.y=vecPrevLocation.y=0.0f;
fTx=fTy=0;
fEmissionResidue=0.0f;
nParticlesAlive=0;
fAge=-2.0;
mTimer = 0.0f;
rectBoundingBox.Clear();
bUpdateBoundingBox=false;
//void *psi;
//hgeParticleSystemInfo psi;
JFileSystem* fileSys = JFileSystem::GetInstance();
//hge=hgeCreate(HGE_VERSION);
//psi=hge->Resource_Load(filename);
if (!fileSys->OpenFile(filename)) return;
//if(!psi) return;
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
//hge->Resource_Free(psi);
// Skip reading the pointer as it may be larger than 4 bytes in the structure
void *dummyPointer;
fileSys->ReadFile(&dummyPointer, 4);
// we're actually trying to read more than the file size now, but it's no problem.
// Note that this fix is only to avoid the largest problems, filling a structure
// by directly reading a file, is really a bad idea ...
fileSys->ReadFile(&(info.nEmission), sizeof(hgeParticleSystemInfo) - 4);
fileSys->CloseFile();
info.sprite=sprite;
// info.fGravityMin *= 100;
// info.fGravityMax *= 100;
// info.fSpeedMin *= 100;
// info.fSpeedMax *= 100;
vecLocation.x=vecPrevLocation.x=0.0f;
vecLocation.y=vecPrevLocation.y=0.0f;
fTx=fTy=0;
fEmissionResidue=0.0f;
nParticlesAlive=0;
fAge=-2.0;
mTimer = 0.0f;
rectBoundingBox.Clear();
bUpdateBoundingBox=false;
}
hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi)
+29 -36
View File
@@ -1683,21 +1683,20 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
int rawsize, i;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return;
if (!fileSystem->OpenFile(filename)) return;
rawsize = fileSystem->GetFileSize(jFile);
rawsize = fileSystem->GetFileSize();
rawdata = new BYTE[rawsize];
if (!rawdata)
{
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return;
}
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
// Initialize libJpeg Object
cinfo.err = jpeg_std_error(&jerr);
@@ -1805,10 +1804,9 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
{
png_size_t check;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile *jFile = (JFile*)png_ptr->io_ptr;
JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
check = fileSystem->ReadFile(jFile, data, length);
check = fileSystem->ReadFile(data, length);
if (check != length)
{
@@ -1871,14 +1869,13 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
DWORD* line;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
return JGE_ERR_CANT_OPEN_FILE;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL)
{
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return JGE_ERR_PNG;
}
@@ -1888,14 +1885,14 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
if (info_ptr == NULL)
{
//fclose(fp);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_PNG;
}
png_init_io(png_ptr, NULL);
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn);
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr);
@@ -1911,7 +1908,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
if (!line)
{
//fclose(fp);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED;
@@ -1960,7 +1957,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
textureInfo.mBits = buffer;
@@ -2119,10 +2116,9 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = (JFile*)ft->UserData;
if (fileSys->ReadFile(jFile, buf, size))
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
//return fread(buf, 1, size, (FILE *)ft->UserData);
if (fileSys->ReadFile(buf, size))
return size;
else
return 0;
@@ -2134,18 +2130,17 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
///*
//FILE * fp = fopen(filename, "rb");
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile))
if (!fileSys->OpenFile(filename))
return;
//if(fp == NULL)
// return;
DWORD bkcol;
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
if(result!=0)
textureInfo.mBits=NULL;
//fclose(fp);
fileSys->CloseFile(jFile);
fileSys->CloseFile();
return ;//*/
}
#endif //(!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
@@ -2166,21 +2161,20 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
UIImage *image = NULL;
do {
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
break;
rawsize = fileSystem->GetFileSize(jFile);
rawsize = fileSystem->GetFileSize();
rawdata = new BYTE[rawsize];
if (!rawdata)
{
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
break;
}
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
texData = [[NSData alloc] initWithBytes:rawdata length:rawsize];
image = [[UIImage alloc] initWithData:texData];
@@ -2260,21 +2254,20 @@ JTexture* JRenderer::LoadTexture(const char* filename, int, int)
JFileSystem* fileSystem = JFileSystem::GetInstance();
do {
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
break;
rawsize = fileSystem->GetFileSize(jFile);
rawsize = fileSystem->GetFileSize();
rawdata = new BYTE[rawsize];
if (!rawdata)
{
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
break;
}
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
QImage tmpImage = QImage::fromData(rawdata, rawsize);
if(tmpImage.isNull())
+8 -10
View File
@@ -161,16 +161,15 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
if (music)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(fileName);
if (jFile)
if (fileSystem->OpenFile(fileName))
{
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *buffer = new char[size];
fileSystem->ReadFile(jFile, buffer, size);
fileSystem->ReadFile(buffer, size);
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer;
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
}
}
return music;
@@ -282,16 +281,15 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
if (sample)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(fileName);
if (jFile)
if (fileSystem->OpenFile(fileName))
{
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *buffer = new char[size];
fileSystem->ReadFile(jFile, buffer, size);
fileSystem->ReadFile(buffer, size);
sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer;
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
}else
sample->mSample = NULL;
+28 -28
View File
@@ -418,29 +418,29 @@ void WagicCore::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
m_lastPos = event->pos();
QPoint lastPos = event->pos();
// this is intended to convert window coordinate into game coordinate.
// this is correct only if the game and window have the same aspect ratio, otherwise, it's just wrong
int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth();
int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight();
if (lastPosy() >= m_viewPort.top() &&
lastPosy() <= m_viewPort.bottom() &&
lastPosx() <= m_viewPort.right() &&
lastPosx() >= m_viewPort.left()) {
if (lastPos.y() >= m_viewPort.top() &&
lastPos.y() <= m_viewPort.bottom() &&
lastPos.x() <= m_viewPort.right() &&
lastPos.x() >= m_viewPort.left()) {
m_engine->LeftClicked(
((lastPosx()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
((lastPosy()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight);
((lastPos.x()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
((lastPos.y()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight);
#if (!defined Q_WS_MAEMO_5) && (!defined MEEGO_EDITION_HARMATTAN) && (!defined Q_WS_ANDROID)
m_engine->HoldKey_NoRepeat(JGE_BTN_OK);
#else
mMouseDownX = lastPosx();
mMouseDownY = lastPosy();
mMouseDownX = lastPos.x();
mMouseDownY = lastPos.y();
mLastFingerDownTime = g_startTimer.elapsed();
#endif
} else if(lastPosy()<m_viewPort.top()) {
} else if(lastPos.y()<m_viewPort.top()) {
m_engine->HoldKey_NoRepeat(JGE_BTN_MENU);
} else if(lastPosy()>m_viewPort.bottom()) {
} else if(lastPos.y()>m_viewPort.bottom()) {
m_engine->HoldKey_NoRepeat(JGE_BTN_NEXT);
}
event->accept();
@@ -465,33 +465,33 @@ void WagicCore::mouseReleaseEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
m_lastPos = event->pos();
QPoint lastPos = event->pos();
if (lastPosy() >= m_viewPort.top() &&
lastPosy() <= m_viewPort.bottom() &&
lastPosx() <= m_viewPort.right() &&
lastPosx() >= m_viewPort.left()) {
if (lastPos.y() >= m_viewPort.top() &&
lastPos.y() <= m_viewPort.bottom() &&
lastPos.x() <= m_viewPort.right() &&
lastPos.x() >= m_viewPort.left()) {
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID)
if(g_startTimer.elapsed() - mLastFingerDownTime <= kTapEventTimeout )
{
if(abs(mMouseDownX - lastPosx()) < kHitzonePliancy &&
abs(mMouseDownY - lastPosy()) < kHitzonePliancy)
if(abs(mMouseDownX - lastPos.x()) < kHitzonePliancy &&
abs(mMouseDownY - lastPos.y()) < kHitzonePliancy)
{
m_engine->HoldKey_NoRepeat(JGE_BTN_OK);
}
}
else if (g_startTimer.elapsed() - mLastFingerDownTime >= kSwipeEventMinDuration)
{ // Let's swipe
m_engine->Scroll(lastPosx()-mMouseDownX, lastPosy()-mMouseDownY);
m_engine->Scroll(lastPos.x()-mMouseDownX, lastPos.y()-mMouseDownY);
}
#else
//#if (!defined Q_WS_MAEMO_5) && (!defined MEEGO_EDITION_HARMATTAN)
m_engine->ReleaseKey(JGE_BTN_OK);
#endif
m_engine->ReleaseKey(JGE_BTN_MENU);
} else if(lastPosy() < m_viewPort.top()) {
} else if(lastPos.y() < m_viewPort.top()) {
m_engine->ReleaseKey(JGE_BTN_MENU);
} else if(lastPosy() > m_viewPort.bottom()) {
} else if(lastPos.y() > m_viewPort.bottom()) {
m_engine->ReleaseKey(JGE_BTN_NEXT);
}
event->accept();
@@ -517,15 +517,15 @@ void WagicCore::mouseMoveEvent(QMouseEvent *event)
int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth();
int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight();
m_lastPos = event->pos();
QPoint lastPos = event->pos();
if (lastPosy() >= m_viewPort.top() &&
lastPosy() <= m_viewPort.bottom() &&
lastPosx() <= m_viewPort.right() &&
lastPosx() >= m_viewPort.left()) {
if (lastPos.y() >= m_viewPort.top() &&
lastPos.y() <= m_viewPort.bottom() &&
lastPos.x() <= m_viewPort.right() &&
lastPos.x() >= m_viewPort.left()) {
m_engine->LeftClicked(
((lastPosx()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
((lastPosy()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight);
((lastPos.x()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
((lastPos.y()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight);
event->accept();
} else {
super::mouseMoveEvent(event);
-2
View File
@@ -106,7 +106,6 @@ public:
virtual int overflow(int c = EOF);
virtual int underflow();
virtual int sync();
using std::streambuf::setbuf;
virtual std::streambuf * setbuf(char * pr, int nLength);
virtual std::streampos seekoff(std::streamoff, std::ios::seekdir, std::ios::openmode);
@@ -132,7 +131,6 @@ public:
virtual int overflow(int c = EOF);
virtual int underflow();
virtual int sync();
using std::streambuf::setbuf;
virtual std::streambuf * setbuf(char * pr, int nLength);
virtual std::streampos seekoff(std::streamoff, std::ios::seekdir, std::ios::openmode);
+1 -1
View File
@@ -16,6 +16,6 @@ Wagic, the Homebrew, is a C++ game engine that allows to play card games against
It is highly customizable and allows the player to tweak the rules / create their own cards, their own themes, etc...
Info, downloads, discussions and more at http://wololo.net/forum/index.php
Info, Downloads, and more at http://wololo.net
-![alt text](http://wololo.net/wagic/wp-content/uploads/2009/10/shop.jpg "Screenshot")
+4 -54
View File
@@ -42,39 +42,6 @@ def getFilename():
filename = 'core_' + major + minor + point
return filename
def createQrcFile():
utilities = ZipUtilities()
print "Creating Qt Resource File"
filename = "core.qrc"
f = open(filename, 'w')
f.seek(0,0)
f.write("""<!DOCTYPE RCC><RCC version="1.0">\n<qresource>\n""")
rename = False
if not os.path.isfile('settings/options.txt'):
os.rename('settings/options.orig.txt', 'settings/options.txt')
remame = True
if not os.path.isfile('player/options.txt'):
os.rename('player/options.orig.txt', 'player/options.txt')
rename = True
utilities.addFolderToQrc(f, 'themes')
utilities.addFolderToQrc(f, 'sound')
utilities.addFolderToQrc(f, 'settings')
utilities.addFolderToQrc(f, 'sets')
utilities.addFolderToQrc(f, 'rules')
utilities.addFolderToQrc(f, 'player')
utilities.addFolderToQrc(f, 'packs')
utilities.addFolderToQrc(f, 'lang')
utilities.addFolderToQrc(f, 'graphics')
utilities.addFolderToQrc(f, 'campaigns')
utilities.addFolderToQrc(f, 'ai')
if rename:
os.rename('settings/options.txt', 'settings/options.orig.txt')
os.rename('player/options.txt', 'player/options.orig.txt')
f.seek(0,2)
f.write('</qresource>\n</RCC>\n')
f.close
print >> sys.stderr, 'Created Resource Package for Qt projects: {0}'.format( filename)
def createStandardResFile():
@@ -117,37 +84,20 @@ class ZipUtilities:
print 'Entering folder: ' + str(full_path)
self.addFolderToZip(zip_file, full_path)
def addFolderToQrc(self, qrc, folder):
qrc.seek(0,2)
for file in os.listdir(folder):
if file != '.svn':
full_path = os.path.join(folder, file)
if os.path.isfile(full_path):
print 'File added: ' + str(full_path)
qrc.write('<file>')
qrc.write(full_path)
qrc.write('</file>\n')
elif os.path.isdir(full_path):
print 'Entering folder: ' + str(full_path)
self.addFolderToQrc(qrc, full_path)
def main():
## using optparse instead of argParse for now since python 2.7 may not be installed.
parser = OptionParser()
parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg qt, ios, android, etc)", metavar="PLATFORM", dest="platform")
parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg ios, android, etc)", metavar="PLATFORM", dest="platform")
(options, args) = parser.parse_args()
if (options.platform):
print "reading %s..." % options.platform
if (options.platform == 'ios'):
createIosResFile()
elif (options.platform == 'qt'):
createQrcFile()
if (options.platform == "ios"):
createIosResFile()
else:
createStandardResFile()
createStandardResFile()
else:
createStandardResFile()
File diff suppressed because it is too large Load Diff
+7 -3
View File
@@ -31457,7 +31457,7 @@ toughness=2
[/card]
[card]
name=Flourishing Defenses
auto=@counteradded(-1/-1) from(creature):may token(Elf Warrior,Creature elf warrior,1/1,green)
auto=@counteradded(-1/-1) from(creature|mybattlefield):may token(Elf Warrior,Creature elf warrior,1/1,green)
text=Whenever a -1/-1 counter is placed on a creature, you may put a 1/1 green Elf Warrior creature token onto the battlefield.
mana={4}{G}
type=Enchantment
@@ -73586,7 +73586,7 @@ toughness=6
###The 2 cards below should stay together (Flip Card)###
[card]
name=Rune-Tail, Kitsune Ascendant
auto=this(controllerlife > 29) transforms((,newability[flip(Rune-Tail's Essence)]))
auto=this(controllerlife >30) all(this) flip(Rune-Tail's Essence)
text=When you have 30 or more life, flip Rune-Tail, Kitsune Ascendant.
mana={2}{W}
type=Legendary Creature
@@ -78444,7 +78444,11 @@ toughness=2
[/card]
[card]
name=Shifting Sky
auto=chooseacolor lord(*[-land]) becomes(,chosencolor) chooseend
auto=choice name(choose white) all(this) transforms((,newability[lord(*[-land]) becomes(,white)])) forever
auto=choice name(choose blue) all(this) transforms((,newability[lord(*[-land]) becomes(,blue)])) forever
auto=choice name(choose black) all(this) transforms((,newability[lord(*[-land]) becomes(,black)])) forever
auto=choice name(choose red) all(this) transforms((,newability[lord(*[-land]) becomes(,red)])) forever
auto=choice name(choose green) all(this) transforms((,newability[lord(*[-land]) becomes(,green)])) forever
text=As Shifting Sky enters the battlefield, choose a color. -- All nonland permanents are the chosen color.
mana={2}{U}
type=Enchantment
+1
View File
@@ -17,6 +17,7 @@ private:
WSrcCards * setSrc;
SimpleMenu * menu;
bool showMenu;
bool showAlt;
bool saveMe;
int mState;
int mDetailItem;
+1
View File
@@ -47,6 +47,7 @@ protected:
{
static const float HEIGHT;
unsigned attackers;
unsigned blockers;
unsigned currentAttacker;
float height;
+1
View File
@@ -20,6 +20,7 @@ class SimplePopup: public JGuiController
private:
float mWidth, mX, mY;
int mMaxLines;
int mFontId;
DeckMetaData * mDeckInformation;
string mTitle;
WFont *mTextFont;
+4 -4
View File
@@ -1,12 +1,12 @@
#ifndef WRESOURCE_FWD_H
#define WRESOURCE_FWD_H
#if (__cplusplus > 199711L)
#include <memory>
typedef std::shared_ptr<JQuad> JQuadPtr;
#else
#ifndef WP8
#include <boost/shared_ptr.hpp>
typedef boost::shared_ptr<JQuad> JQuadPtr;
#else
#include <memory>
typedef std::shared_ptr<JQuad> JQuadPtr;
#endif
#endif
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef _DEBUG_H_
#define _DEBUG_H_
#if ((defined WIN32) || (defined WP8)) && !defined(__MINGW32__)
#if ((defined WIN32) || (defined WP8))
#define snprintf sprintf_s
#endif
+1 -1
View File
@@ -314,7 +314,7 @@ bool AIHints::canWeCombo(GameObserver* observer,MTGCardInstance * card,AIPlayerB
int comboPartsRestriction = 0;
if(gotCombo)
return gotCombo;//because more than one might be possible at any time.
return gotCombo;//because more then one might be possible at any time.
if (hints[i]->hold.size())
{
for(unsigned int hPart = 0; hPart < hints[i]->hold.size(); hPart++)
+2 -2
View File
@@ -445,7 +445,7 @@ int OrderedAIAction::getEfficiency()
}
if ((drawer->getNumCards() >= p->game->library->nb_cards && (Targetable*)p == drawer->getTarget()) || (p->game->hand->nb_cards > 10 && (Targetable*)p == drawer->getTarget()))
{
//if the amount im drawing will mill me to death or i have more than 10 cards in hand, eff is 0;
//if the amount im drawing will mill me to death or i have more then 10 cards in hand, eff is 0;
efficiency = 0;
}
break;
@@ -853,7 +853,7 @@ ManaCost * AIPlayerBaka::getPotentialMana(MTGCardInstance * target)
if (card == target)
used[card] = true; //http://code.google.com/p/wagic/issues/detail?id=76
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() == 1)
{//ai can't use cards which produce more than 1 converted while using the old pMana method.
{//ai can't use cards which produce more then 1 converted while using the old pMana method.
result->add(amp->output);
used[card] = true;
}
+5
View File
@@ -1994,23 +1994,28 @@ int AADynamic::resolve()
break;
case DYNAMIC_ABILITY_WHO_ITSELF:
source = ((MTGCardInstance *) _target);
_target = _target;
break;
case DYNAMIC_ABILITY_WHO_TARGETCONTROLLER:
_target = _target;
secondaryTarget = ((MTGCardInstance *) _target)->controller();
break;
case DYNAMIC_ABILITY_WHO_TARGETOPPONENT:
_target = _target;
secondaryTarget = ((MTGCardInstance *) _target)->controller()->opponent();
break;
case DYNAMIC_ABILITY_WHO_TOSOURCE:
tosrc = true;
break;
case DYNAMIC_ABILITY_WHO_SOURCECONTROLLER:
_target = _target;
secondaryTarget = ((MTGCardInstance *) OriginalSrc)->controller();
break;
case DYNAMIC_ABILITY_WHO_SOURCEOPPONENT:
secondaryTarget = OriginalSrc->controller()->opponent();
break;
default:
_target = _target;
break;
}
if(amountsource == DYNAMIC_MYSELF_AMOUNT)
+1 -1
View File
@@ -386,7 +386,7 @@ void Credits::computeTournament(GameObserver* g, GameApp * _app,bool tournament,
}
if (mGamesWon>mGamesPlayed*0.80 && mGamesWon<mGamesPlayed)
{
CreditBonus * b = NEW CreditBonus(250, _("Won more than 80 percentage of games"));
CreditBonus * b = NEW CreditBonus(250, _("Won more then 80 percentage of games"));
bonus.push_back(b);
}
+2 -2
View File
@@ -796,7 +796,7 @@ void GameStateDuel::Update(float dt)
if (game->didWin())
{
//the following section will be called only in a classic or demo gamemode and if a tournament or match with more than one game is activ
//the following section will be called only in a classic or demo gamemode and if a tournament or match with more then one game is activ
if ( (mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO)&& mParent->players[1] == PLAYER_TYPE_CPU && (tournament->isTournament() || tournament->getGamesToPlay()>1 ))
{
setGamePhase(DUEL_STATE_SHOW_SCORE);
@@ -1843,7 +1843,7 @@ int Tournament::getRandomDeck(bool noEasyDecks)
DeckManager *deckManager = DeckManager::GetInstance();
vector<DeckMetaData *> *deckList = deckManager->getAIDeckOrderList();
int deckNumber=0;
int deckNumber;
unsigned int random=0;
int k=0;
bool isDouble=true;
+8 -8
View File
@@ -300,12 +300,12 @@ string GameStateMenu::loadRandomWallpaper()
return wallpaper;
vector<string> wallpapers;
JFile* jFile = JFileSystem::GetInstance()->OpenFile("graphics/wallpapers.txt");
if (!jFile)
izfstream file;
if (! JFileSystem::GetInstance()->openForRead(file, "graphics/wallpapers.txt"))
return wallpaper;
string s;
while (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
while (std::getline(file, s))
{
if (!s.size())
continue;
@@ -313,7 +313,7 @@ string GameStateMenu::loadRandomWallpaper()
s.erase(s.size() - 1); //Handle DOS files
wallpapers.push_back(s);
}
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
int rnd = rand() % (wallpapers.size());
wallpaper = wallpapers[rnd];
@@ -352,21 +352,21 @@ void GameStateMenu::loadLangMenu()
vector<string> langFiles = JFileSystem::GetInstance()->scanfolder("lang/");
for (size_t i = 0; i < langFiles.size(); ++i)
{
izfstream file;
string filePath = "lang/";
filePath.append(langFiles[i]);
JFile* jFile = JFileSystem::GetInstance()->OpenFile(filePath);
if (!jFile)
if (! JFileSystem::GetInstance()->openForRead(file, filePath))
continue;
string s;
string lang;
if (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
if (std::getline(file, s))
{
lang = getLang(s);
}
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
if (lang.size())
{
+1 -1
View File
@@ -103,7 +103,7 @@ inline float GuiPlay::VertStack::nextX()
}
GuiPlay::BattleField::BattleField() :
attackers(0), height(0.0), red(0), colorFlow(0)
attackers(0), blockers(0), height(0.0), red(0), colorFlow(0)
{
}
const float GuiPlay::BattleField::HEIGHT = 80.0f;
+2
View File
@@ -4276,6 +4276,8 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
if (card->hasType(Subtypes::TYPE_INSTANT) || card->hasType(Subtypes::TYPE_SORCERY))
{
MTGPlayerCards * zones = card->owner->game;
if(card->getCurrentZone())
card->currentZone->owner->game;//grab it from where ever it is.
MTGPlayerCards * Endzones = card->owner->game;//put them in thier owners respective zones as per rules.
if (card->basicAbilities[(int)Constants::EXILEDEATH])
{
+5 -5
View File
@@ -399,8 +399,8 @@ int MTGAllCards::load(const string &config_file, int set_id)
int lineNumber = 0;
std::string contents;
JFile* jFile = JFileSystem::GetInstance()->OpenFile(config_file);
if (!jFile)
izfstream file;
if (!JFileSystem::GetInstance()->openForRead(file, config_file))
{
DebugTrace("MTGAllCards::load: error loading: " << config_file);
return total_cards;
@@ -408,7 +408,7 @@ int MTGAllCards::load(const string &config_file, int set_id)
string s;
while (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
while (getline(file,s))
{
lineNumber++;
if (!s.size()) continue;
@@ -448,7 +448,7 @@ int MTGAllCards::load(const string &config_file, int set_id)
if (!maxGrade) maxGrade = Constants::GRADE_BORDERLINE; //Default setting for grade is borderline?
if (fileGrade > maxGrade)
{
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
return total_cards;
}
}
@@ -480,7 +480,7 @@ int MTGAllCards::load(const string &config_file, int set_id)
continue;
}
}
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
return total_cards;
}
+1 -1
View File
@@ -146,7 +146,7 @@ int MTGEventBonus::receiveEvent(WEvent * event)
}
//////bonus for having a LOT of specific type.
//not else'd becuase it is possible for a card to contain
//more than one of the types, and for more than one to trigger.
//more then one of the types, and for more then one to trigger.
if(e->card->hasType(Subtypes::TYPE_ARTIFACT))
toys[currentPlayer->getId()]++;
if(e->card->isCreature())
+4 -4
View File
@@ -326,16 +326,16 @@ void OptionLanguage::Reload()
vector<string> langFiles = JFileSystem::GetInstance()->scanfolder("lang/");
for (size_t i = 0; i < langFiles.size(); ++i)
{
izfstream file;
string filePath = "lang/";
filePath.append(langFiles[i]);
JFile* jFile = JFileSystem::GetInstance()->OpenFile(filePath);
if (!jFile)
if (! JFileSystem::GetInstance()->openForRead(file, filePath))
continue;
string s;
string lang;
if (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
if (std::getline(file, s))
{
if (!s.size())
{
@@ -352,7 +352,7 @@ void OptionLanguage::Reload()
lang = s.substr(6);
}
}
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
if (lang.size())
{
+1 -1
View File
@@ -15,7 +15,7 @@
#include <iomanip>
SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title, DeckMetaData* deckMetaData, MTGAllCards * collection, float cancelX, float cancelY) :
JGuiController(JGE::GetInstance(), id, listener), mCollection(collection)
JGuiController(JGE::GetInstance(), id, listener), mFontId(fontId), mCollection(collection)
{
mX = 19;
mY = 66;
+4 -5
View File
@@ -599,17 +599,16 @@ bool StoryFlow::parse(string path)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (!fileSystem) return false;
JFile* jFile = fileSystem->OpenFile(path.c_str());
if (!jFile) return false;
if (!fileSystem->OpenFile(path.c_str())) return false;
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *xmlBuffer = NEW char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
for (TiXmlNode* node = doc.FirstChild(); node; node = node->NextSibling())
+4 -5
View File
@@ -333,9 +333,8 @@ bool WCachedParticles::Attempt(const string& filename, int, int & error)
{
JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(WResourceManager::Instance()->graphicsFile(filename));
if (!jFile)
if (!fileSys->OpenFile(WResourceManager::Instance()->graphicsFile(filename)))
{
error = CACHE_ERROR_404;
return false;
@@ -346,12 +345,12 @@ bool WCachedParticles::Attempt(const string& filename, int, int & error)
particles = NEW hgeParticleSystemInfo;
// We Skip reading the pointer as it may be larger than 4 bytes in the structure
void *dummyPointer;
fileSys->ReadFile(jFile, &dummyPointer, 4);
fileSys->ReadFile(&dummyPointer, 4);
// we're actually trying to read more than the file size now, but it's no problem.
// Note that this fix is only to avoid the largest problems, filling a structure
// by directly reading a file, is really a bad idea ...
fileSys->ReadFile(jFile, &(particles->nEmission), sizeof(hgeParticleSystemInfo) - sizeof(void*));
fileSys->CloseFile(jFile);
fileSys->ReadFile(&(particles->nEmission), sizeof(hgeParticleSystemInfo) - sizeof(void*));
fileSys->CloseFile();
particles->sprite = NULL;
error = CACHE_ERROR_NONE;
+17 -21
View File
@@ -171,22 +171,20 @@ WFont(inFontID), mTexture(0)
unsigned char height;
} sizeStr = { 0, 0, 0 };
JFile* jFile = fileSys->OpenFile(engFileName);
if (!jFile) return;
size = fileSys->GetFileSize(jFile);
if (!fileSys->OpenFile(engFileName)) return;
size = fileSys->GetFileSize();
mStdFont = NEW u8[size];
fileSys->ReadFile(jFile, mStdFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mStdFont, size);
fileSys->CloseFile();
jFile = fileSys->OpenFile(fontname);
if (!jFile) return;
fileSys->ReadFile(jFile, &sizeStr, 4); // Works only for little-endian machines (PSP and PC are)
if (!fileSys->OpenFile(fontname)) return;
fileSys->ReadFile(&sizeStr, 4); // Works only for little-endian machines (PSP and PC are)
size = sizeStr.chars * sizeStr.width * sizeStr.height / 2;
mExtraFont = NEW u8[size]; // 4 bits for a pixel
mIndex = NEW u16[65536];
fileSys->ReadFile(jFile, mIndex, 65536 * sizeof(u16));
fileSys->ReadFile(jFile, mExtraFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mIndex, 65536 * sizeof(u16));
fileSys->ReadFile(mExtraFont, size);
fileSys->CloseFile();
mColor0 = ARGB(255, 255, 255, 255);
mColor = mColor0;
@@ -614,19 +612,17 @@ WGBKFont::WGBKFont(int inFontID, const char *fontname, int lineheight, bool) :
JFileSystem *fileSys = JFileSystem::GetInstance();
int size = 0;
JFile* jFile = fileSys->OpenFile(fontname);
if (!jFile) return;
size = fileSys->GetFileSize(jFile);
if (!fileSys->OpenFile(fontname)) return;
size = fileSys->GetFileSize();
mExtraFont = NEW u8[size];
fileSys->ReadFile(jFile, mExtraFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mExtraFont, size);
fileSys->CloseFile();
jFile = fileSys->OpenFile(engFileName);
if (!jFile) return;
size = fileSys->GetFileSize(jFile);
if (!fileSys->OpenFile(engFileName)) return;
size = fileSys->GetFileSize();
mStdFont = NEW u8[size];
fileSys->ReadFile(jFile, mStdFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mStdFont, size);
fileSys->CloseFile();
mIndex = 0;
+1 -2
View File
@@ -15,9 +15,8 @@ CONFIG(console, graphics|console){
}
else:CONFIG(graphics, graphics|console){
folder_01.source = qml/QmlWagic
folder_01.target = qml
folder_01.target = /usr/share
DEPLOYMENTFOLDERS = folder_01
windows:RESOURCES = bin/Res/core.qrc
QT += core gui opengl network
QT -= declarative quick qml
#maemo5:DEFINES += QT_WIDGET
+112 -6
View File
@@ -4,11 +4,11 @@ TEMPLATE = app
#!macx:CONFIG += precompile_header
unix|macx:QMAKE_CXXFLAGS += -Wno-unused-parameter
unix:!*macx*:QMAKE_CXXFLAGS += -Wno-unused-but-set-parameter
unix:!*macx*:QMAKE_CXXFLAGS += -Wno-unused-but-set-variable
unix|*macx*:QMAKE_CXXFLAGS += -Wno-unused-value
unix:!*macx*:QMAKE_CXXFLAGS += -Wno-unused-local-typedefs
unix:!*macx*:!maemo5:!symbian:QMAKE_CXXFLAGS += -Werror
unix:!macx:QMAKE_CXXFLAGS += -Wno-unused-but-set-parameter
unix:!macx:QMAKE_CXXFLAGS += -Wno-unused-but-set-variable
unix|macx:QMAKE_CXXFLAGS += -Wno-unused-value
unix:!macx:QMAKE_CXXFLAGS += -Wno-unused-local-typedefs
unix:!macx:!maemo5:!symbian:QMAKE_CXXFLAGS += -Werror
windows:DEFINES += _CRT_SECURE_NO_WARNINGS
unix|macx:DEFINES += LINUX
@@ -27,7 +27,6 @@ windows{
# INCLUDEPATH += /usr/i686-w64-mingw32/sys-root/mingw/include/c++
LIBS += -L/usr/i686-w64-mingw32/sys-root/mingw/lib
LIBS += -lwsock32
DEFINES += FORCE_GL2
}
*-msvc* {
INCLUDEPATH += extra
@@ -371,3 +370,110 @@ HEADERS += \
../../JGE/src/tinyxml/tinystr.h\
../../JGE/src/tinyxml/tinyxml.h\
../../JGE/include/vram.h
# maemo 5 packaging
maemo5: {
# Variables
BINDIR = /opt/wagic/bin
RESDIR = /home/user/wagic/Res
USERDIR = MyDocs/.Wagic
ICONDIR = /usr/share
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
INSTALLS += target \
desktop \
icon
target.path = $$BINDIR
desktop.path = $$ICONDIR/applications/hildon
desktop.files += wagic.desktop
icon.path = $$ICONDIR/icons/hicolor/64x64/apps
icon.files += wagic-64x64.png
# Meego/maemo 6 packaging (no launcher)
} else:contains(MEEGO_EDITION,harmattan): {
# Variables
BINDIR = /opt/wagic/bin
RESDIR = /opt/wagic/Res
USERDIR = MyDocs/.Wagic
ICONDIR = /usr/share
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
INSTALLS += target \
desktop \
icon \
policy
target.path = $$BINDIR
desktop.path = /usr/share/applications
desktop.files += debian_harmattan/wagic.desktop
icon.files = wagic-80x80.png
icon.path = /usr/share/icons/hicolor/64x64/apps
policy.files = debian_harmattan/wagic.conf
policy.path = /usr/share/policy/etc/syspart.conf.d
} else:symbian {
TARGET.UID3 = 0xE1D807D3
# Smart Installer package's UID
# This UID is from the protected range
# and therefore the package will fail to install if self-signed
# By default qmake uses the unprotected range value if unprotected UID is defined for the application
# and 0x2002CCCF value if protected UID is given to the application
#symbian:DEPLOYMENT.installer_header = 0x2002CCCF
# Allow network access on Symbian... that's probably pointless
TARGET.CAPABILITY += NetworkServices
RESDIR = some/res/dir
USERDIR = .Wagic
DEFINES += RESDIR=\"$$RESDIR\"
DEFINES += USERDIR=\"$$USERDIR\"
ICON = wagic.svg
} else:android {
DEFINES += Q_WS_ANDROID
RESDIR = Res
USERDIR = /sdcard/Wagic/Res
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
} else:unix {
# Variables
BINDIR = /usr/bin
ICONDIR = /usr/share
RESDIR = Res
USERDIR = .Wagic
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
target.path = $$BINDIR
desktop.path = $$ICONDIR/applications
desktop.files += wagic.desktop
icon.path = $$ICONDIR/icons/hicolor/64x64/apps
icon.files += wagic-64x64.png
INSTALLS += target \
desktop \
icon
} else:windows {
RESDIR = ./Res
USERDIR = .Wagic
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
}
+13 -46
View File
@@ -11,35 +11,18 @@ cd projects/mtg/
ant update > error.txt
cd ../..
# we create resource package
cd projects/mtg/bin/Res
python createResourceZip.py
python createResourceZip.py --platform=qt
# if we let the zip here, Wagic will use it in the testsuite
# and we'll get 51 failed test cases
mv core_*.zip ../../../../core.zip
cd ../../../..
# we're building a PSP binary here
cd JGE
make -j 8
make -j 8 -f Makefile.hge install
cd ..
cd projects/mtg
mkdir objs
make -j 8
mkdir WTH
mkdir WTH/Res
mv EBOOT.PBP WTH/
mv ../../JGE/exceptionHandler/prx/exception.prx WTH/
cp ../../core.zip WTH/Res
cd WTH/Res
unzip core.zip
rm core.zip
cd ..
chmod -R 775 Res
cd ..
zip psprelease.zip -r WTH/
mkdir psprelease
mv EBOOT.PBP psprelease/
mv wagic.elf psprelease/
mv wagic.prx psprelease/
zip psprelease.zip -r psprelease/
cd ../..
# we're building an Android binary here
@@ -51,8 +34,6 @@ ant debug -f projects/mtg/Android/build.xml
# we're building a Qt version with GUI here
mkdir qt-gui-build
cd qt-gui-build
mv ../projects/mtg/bin/Res/settings/options.orig.txt ../projects/mtg/bin/Res/settings/options.txt
mv ../projects/mtg/bin/Res/player/options.orig.txt ../projects/mtg/bin/Res/player/options.txt
qmake ../projects/mtg/wagic-qt.pro CONFIG+=release CONFIG+=graphics
make -j 8
cd ..
@@ -61,30 +42,16 @@ cd ..
qmake projects/mtg/wagic-qt.pro CONFIG+=console CONFIG+=debug DEFINES+=CAPTURE_STDERR
make -j 8
# we're cross-compiling a Qt Windows version here,
# PATH is only set here to prevent collision
export PATH="$PATH:/opt/mingw32/bin"
mkdir build
cd build
mkdir win-cross
cd win-cross
/opt/mingw32/bin/qmake ../../projects/mtg/wagic-qt.pro CONFIG+=release CONFIG+=graphics
make -j 8
cd release
cp ../../../projects/mtg/bin/fmod.dll .
cp /opt/mingw32/bin/QtCore4.dll .
cp /opt/mingw32/bin/QtGui4.dll .
cp /opt/mingw32/bin/QtNetwork4.dll .
cp /opt/mingw32/bin/QtOpenGL4.dll .
cp ../../../projects/mtg/bin/zlib1.dll .
cp /opt/mingw32/bin/libpng15-15.dll .
cd ..
zip win-cross.zip -r release/
mv ../../projects/mtg/bin/Res/settings/options.txt ../../projects/mtg/bin/Res/settings/options.orig.txt
mv ../../projects/mtg/bin/Res/player/options.txt ../../projects/mtg/bin/Res/player/options.orig.txt
cd ../..
# we create resource package
cd projects/mtg/bin/Res
python createResourceZip.py
# if we let the zip here, Wagic will use it in the testsuite
# and we'll get 51 failed test cases
mv core_*.zip ../../../../core.zip
cd ../../../..
# Now we run the testsuite (Res needs to be in the working directory)
cd projects/mtg
../../wagic
cd ../..
+5 -22
View File
@@ -26,19 +26,14 @@ if [ "$TRAVIS_BRANCH" == "alphas" ]; then
--data-binary @projects/mtg/psprelease.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-psp-${TRAVIS_BUILD_NUMBER}.zip"
echo -e "Uploading Windows package\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @build/win-cross/win-cross.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-windows-${TRAVIS_BUILD_NUMBER}.zip"
echo -e "Done uploading\n"
fi
fi
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$TRAVIS_BRANCH" == "master" ]; then
if [ "$TRAVIS_BRANCH" == "releasing-master" ]; then
# get info about all releases
echo -e "Getting info about previous releases"
@@ -56,14 +51,9 @@ if [ "$TRAVIS_BRANCH" == "master" ]; then
curl -X DELETE -H "Authorization: token ${GH_TOKEN}" \
"https://api.github.com/repos/WagicProject/wagic/releases/${ID_TO_DELETE}"
# delete previous tag
curl -X DELETE -H "Authorization: token ${GH_TOKEN}" \
"https://api.github.com/repos/WagicProject/wagic/git/refs/tags/latest-master"
echo -e "Creating a release\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-d '{"tag_name": "latest-master", "target_commitish": "master", "name": "master-'${TRAVIS_BUILD_NUMBER}'", "body": "Automatic release based on latest commit to master branch generated by Travis CI", "draft": false, "prerelease": true}' "https://api.github.com/repos/WagicProject/wagic/releases" > json.txt
-d '{"tag_name": "latest-master", "target_commitish": "master", "name": "Master branch release number '${TRAVIS_BUILD_NUMBER}'", "body": "Automatic release on master branch generated by Travis CI", "draft": false, "prerelease": true}' "https://api.github.com/repos/WagicProject/wagic/releases" > json.txt
IDDI=`cat json.txt | jq '.id'`
echo -e "Uploading Core resources\n"
@@ -87,13 +77,6 @@ if [ "$TRAVIS_BRANCH" == "master" ]; then
--data-binary @projects/mtg/psprelease.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-psp-${TRAVIS_BUILD_NUMBER}.zip"
echo -e "Uploading Windows package\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @build/win-cross/win-cross.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-windows-${TRAVIS_BUILD_NUMBER}.zip"
echo -e "Done uploading\n"
fi
fi
fi