Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 14d4bede9a | |||
| 8636a99d0d | |||
| 73cdbd6b88 | |||
| 3482afeb84 | |||
| de40146462 | |||
| 94d5a85043 | |||
| 4811fbcc9f | |||
| 6fd136a211 | |||
| d98640fc01 | |||
| 685317b457 | |||
| a9a59d7b8e | |||
| fe9ad84ee5 | |||
| 3f43648b22 | |||
| afb4c4605b | |||
| fec4468aea | |||
| b09db0c60f | |||
| da31371d86 | |||
| 0df408793a | |||
| 9630bcd56b | |||
| 3c38e21b25 | |||
| caec886e22 | |||
| 927f8955e9 | |||
| d4e0296d2b | |||
| 8eb664f93d | |||
| b180c3d1a7 | |||
| db9f18a644 | |||
| 95805ea387 | |||
| 4765890d0a | |||
| 2e13f29945 | |||
| 22b1c3b5d8 | |||
| c7bae65697 | |||
| 2381f0306c | |||
| b12e15e4ff | |||
| 9e21751e12 | |||
| db60c38eda | |||
| 1a4327a2e6 | |||
| 88095c67b8 | |||
| ec34380668 | |||
| 89dcd6c71d | |||
| fd3cf574cf | |||
| f21452feec | |||
| 0f85471216 | |||
| 5d92553017 | |||
| f0e6d820c7 | |||
| 545fc21260 | |||
| 8b68568106 | |||
| 739a5d9e2b | |||
| 4c627f74b6 | |||
| 1e610ff653 | |||
| 5d6557a49f | |||
| 7528329a58 | |||
| c62597dce5 | |||
| d8dfcdba67 | |||
| 7b5f00260b | |||
| f9dc551942 | |||
| 718ceca919 | |||
| 89fb76a8e7 | |||
| 1cc65ab611 | |||
| 3b22354ad9 | |||
| 2b9977a334 | |||
| 12c5f31562 | |||
| 8cfd887375 |
+10
-3
@@ -1,12 +1,18 @@
|
||||
language: cpp
|
||||
branches:
|
||||
except:
|
||||
- latest-master
|
||||
before_install:
|
||||
- export PSPDEV="$TRAVIS_BUILD_DIR/opt/pspsdk"
|
||||
- export PSPSDK="$PSPDEV/psp/sdk"
|
||||
- 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; fi
|
||||
- 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
|
||||
- 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
|
||||
@@ -14,11 +20,12 @@ 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,4,18 --no-ui --force > log.txt
|
||||
- echo yes | $ANDROID update sdk -a --filter 1,2,5,19 --no-ui --force > log.txt
|
||||
- sudo pip install pyjavaproperties
|
||||
script: ./travis-script.sh
|
||||
env:
|
||||
global:
|
||||
secure: YocijVYZa1oDPviFubPIpmBmXyw0gQ7D0YA6tC01wExXvY+8tGUh1HQ5uXn8LotRZ+Ob5HLHDaCzkKWF8+57ILSMeHrnf6tcRyyeO7wjNY9P7WvSZyCjvqnWzsUN9tiMmsEzhTz2MaUgsY6ocB/4nbWZwfQvL7z+s7z41R4J1I4=
|
||||
secure: "fJgWlCFbde96OSQNGKUmowGX+ERPeqP+n1EOMf1+FJzOU4DdkTLRAlV5+5qnEX9jB/3mWN6iPpmG1qEz/SdDG3KHxJYs4ZU/Lu485O24zZ/+GdYBNsrvhPD9ckPGEMLDa1foEVTDnW0Dlkz3BCFcszjhtXGUJv7v6Pj6LRk1Mg8="
|
||||
|
||||
script: "./travis-script.sh"
|
||||
after_success: ./upload-binaries.sh
|
||||
|
||||
@@ -297,7 +297,6 @@ public:
|
||||
private:
|
||||
float mTimer;
|
||||
float mFrameTime;
|
||||
JAnimator* mAnimator;
|
||||
vector<JAnimatorObject *> mObjects;
|
||||
|
||||
};
|
||||
|
||||
@@ -37,7 +37,6 @@ private:
|
||||
float mTexY;
|
||||
float mTexWidth;
|
||||
float mTexHeight;
|
||||
JTexture* mTexture;
|
||||
JQuad* mQuad;
|
||||
|
||||
|
||||
|
||||
+37
-11
@@ -1,6 +1,10 @@
|
||||
#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;
|
||||
@@ -18,13 +22,38 @@ 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 {
|
||||
@@ -32,23 +61,21 @@ 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.
|
||||
///
|
||||
@@ -83,7 +110,7 @@ public:
|
||||
/// Open file for reading.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool OpenFile(const string &filename);
|
||||
JFile* 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);
|
||||
@@ -97,20 +124,19 @@ public:
|
||||
/// @return Number of bytes read.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int ReadFile(void *buffer, int size);
|
||||
int ReadFile(JFile*, void *buffer, int size);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get size of file.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetFileSize();
|
||||
int GetFileSize(izfstream & file);
|
||||
int GetFileSize(JFile*);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Close file.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CloseFile();
|
||||
void CloseFile(JFile*);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set root for all the following file operations
|
||||
@@ -124,8 +150,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);
|
||||
|
||||
|
||||
@@ -178,7 +178,6 @@ private:
|
||||
float mSpacing;
|
||||
|
||||
PIXEL_TYPE mColor;
|
||||
int mBlend;
|
||||
|
||||
int mBase;
|
||||
|
||||
|
||||
+84
-10
@@ -1,7 +1,7 @@
|
||||
#ifndef THREADING_H
|
||||
#define THREADING_H
|
||||
|
||||
#if !defined(PSP) && !defined(QT_CONFIG)
|
||||
#if !defined(PSP) && !defined(QT_CONFIG) && !(__cplusplus > 199711L)
|
||||
#include <boost/date_time.hpp>
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -14,7 +14,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#elif !defined(QT_CONFIG)
|
||||
#elif defined(PSP)
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
@@ -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
|
||||
@@ -307,7 +307,7 @@ namespace boost
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(QT_CONFIG)
|
||||
#elif defined(QT_CONFIG) && (__cplusplus <= 199711L)
|
||||
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
@@ -537,6 +537,80 @@ 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
|
||||
|
||||
@@ -136,6 +136,20 @@ 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);
|
||||
@@ -154,6 +168,7 @@ 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;
|
||||
|
||||
@@ -44,11 +44,12 @@ bool JAnimator::Load(const char* scriptFile)
|
||||
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
||||
if (fileSystem == NULL) return false;
|
||||
|
||||
if (!fileSystem->OpenFile(scriptFile)) return false;
|
||||
JFile* jFile = fileSystem->OpenFile(scriptFile);
|
||||
if (!jFile) return false;
|
||||
|
||||
int size = fileSystem->GetFileSize();
|
||||
int size = fileSystem->GetFileSize(jFile);
|
||||
char *xmlBuffer = new char[size];
|
||||
fileSystem->ReadFile(xmlBuffer, size);
|
||||
fileSystem->ReadFile(jFile, xmlBuffer, size);
|
||||
|
||||
TiXmlDocument doc;
|
||||
doc.Parse(xmlBuffer);
|
||||
@@ -173,7 +174,7 @@ bool JAnimator::Load(const char* scriptFile)
|
||||
|
||||
}
|
||||
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
delete[] xmlBuffer;
|
||||
|
||||
return true;
|
||||
|
||||
+17
-16
@@ -49,7 +49,8 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
||||
{
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(fileName))
|
||||
JFile* jFile = fileSystem->OpenFile(fileName);
|
||||
if (!jFile)
|
||||
return 0;
|
||||
|
||||
memset(p_wav, 0, sizeof(WAVDATA));
|
||||
@@ -57,14 +58,14 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
||||
char head[256];
|
||||
memset(head, 0, 256);
|
||||
//sceIoRead(fd, head, 20);
|
||||
fileSystem->ReadFile(head, 20);
|
||||
fileSystem->ReadFile(jFile, head, 20);
|
||||
char string[8];
|
||||
memset(string, 0, 8);
|
||||
memcpy(string, head, 4);
|
||||
if (0!=strcmp(string, "RIFF"))
|
||||
{
|
||||
//sceIoClose(fd);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
return 0;
|
||||
}
|
||||
memset(string, 0, 8);
|
||||
@@ -72,7 +73,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
||||
if (0!=strcmp(string, "WAVE"))
|
||||
{
|
||||
//sceIoClose(fd);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
return 0;
|
||||
}
|
||||
memset(string, 0, 8);
|
||||
@@ -80,42 +81,42 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
||||
if (0!=strcmp(string, "fmt"))
|
||||
{
|
||||
//sceIoClose(fd);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
return 0;
|
||||
}
|
||||
int fmtSize = 0;
|
||||
memcpy(&fmtSize, head+16, 4);
|
||||
//sceIoRead(fd, head+20, fmtSize);
|
||||
fileSystem->ReadFile(head+20,fmtSize );
|
||||
fileSystem->ReadFile(jFile, head+20,fmtSize );
|
||||
p_wav->headSize = 20+fmtSize;
|
||||
while (1)
|
||||
{
|
||||
//sceIoRead(fd, head+p_wav->headSize, 4);
|
||||
fileSystem->ReadFile(head+p_wav->headSize, 4);
|
||||
fileSystem->ReadFile(jFile, 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(head+p_wav->headSize, 4);
|
||||
fileSystem->ReadFile(jFile, 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(head+p_wav->headSize, fmtSize);
|
||||
fileSystem->ReadFile(jFile, head+p_wav->headSize, fmtSize);
|
||||
p_wav->headSize += fmtSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
//sceIoRead(fd, head+p_wav->headSize, 4);
|
||||
fileSystem->ReadFile(head+p_wav->headSize, 4);
|
||||
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
|
||||
p_wav->headSize += 4;
|
||||
break;
|
||||
}
|
||||
if (p_wav->headSize>191)
|
||||
{
|
||||
//sceIoClose(fd);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -126,7 +127,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
||||
if (p_wav->channelCount!=1 && p_wav->channelCount!=2)
|
||||
{
|
||||
//sceIoClose(fd);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
return 0;
|
||||
}
|
||||
memcpy(&p_wav->samplePerSecond, head+24, 4);
|
||||
@@ -136,7 +137,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
||||
if (p_wav->bytePerSample!=1 && p_wav->bytePerSample!=2)
|
||||
{
|
||||
//sceIoClose(fd);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
return 0;
|
||||
}
|
||||
p_wav->nSample = 44100 / p_wav->samplePerSecond;
|
||||
@@ -147,17 +148,17 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
||||
if (p_wav->soundSize>4096000)
|
||||
{
|
||||
//sceIoClose(fd);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
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(p_wav->buffer, p_wav->soundSize);
|
||||
fileSystem->ReadFile(jFile, p_wav->buffer, p_wav->soundSize);
|
||||
p_wav->bytePosition = 0;
|
||||
p_wav->fd = -1;
|
||||
//sceIoClose(fd);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+162
-65
@@ -107,7 +107,6 @@ 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;
|
||||
@@ -131,8 +130,8 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
||||
dir.mkdir(USERDIR);
|
||||
dir.cd(USERDIR);
|
||||
|
||||
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
|
||||
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
|
||||
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
|
||||
|
||||
DebugTrace("User path " << userPath);
|
||||
DebugTrace("System path " << systemPath);
|
||||
@@ -192,9 +191,6 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
||||
mZipAvailable = false;
|
||||
mZipCachedElementsCount = 0;
|
||||
mPassword = NULL;
|
||||
mFileSize = 0;
|
||||
mCurrentFileInZip = NULL;
|
||||
|
||||
};
|
||||
|
||||
void JFileSystem::Destroy()
|
||||
@@ -208,14 +204,26 @@ void JFileSystem::Destroy()
|
||||
|
||||
bool JFileSystem::DirExists(const string& strDirname)
|
||||
{
|
||||
return (mSystemFS && mSystemFS->DirExists(strDirname)) || mUserFS->DirExists(strDirname);
|
||||
return (
|
||||
(mSystemFS && mSystemFS->DirExists(strDirname))
|
||||
|| mUserFS->DirExists(strDirname)
|
||||
#ifdef QT_CONFIG
|
||||
|| QDir(QString(":/") + strDirname.c_str()).exists()
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
bool JFileSystem::FileExists(const string& strFilename)
|
||||
{
|
||||
if (strFilename.length() < 1 ) return false;
|
||||
|
||||
return (mSystemFS && mSystemFS->FileExists(strFilename)) || mUserFS->FileExists(strFilename);
|
||||
return (
|
||||
(mSystemFS && mSystemFS->FileExists(strFilename))
|
||||
|| mUserFS->FileExists(strFilename)
|
||||
#ifdef QT_CONFIG
|
||||
|| QFile(QString(":/") + strFilename.c_str()).exists()
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
bool JFileSystem::MakeDir(const string & dir)
|
||||
@@ -275,7 +283,6 @@ bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL
|
||||
}
|
||||
mZipAvailable = true;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +292,6 @@ void JFileSystem::DetachZipFile()
|
||||
{
|
||||
mZipFile.close();
|
||||
}
|
||||
mCurrentFileInZip = NULL;
|
||||
mZipAvailable = false;
|
||||
}
|
||||
|
||||
@@ -307,24 +313,58 @@ bool JFileSystem::openForRead(izfstream & File, const string & FilePath) {
|
||||
|
||||
bool JFileSystem::readIntoString(const string & FilePath, string & target)
|
||||
{
|
||||
izfstream file;
|
||||
if (!openForRead(file, FilePath))
|
||||
return false;
|
||||
bool result = false;
|
||||
|
||||
int fileSize = GetFileSize(file);
|
||||
// Trying first with a izfstream
|
||||
do {
|
||||
izfstream file;
|
||||
if (!openForRead(file, FilePath))
|
||||
break;
|
||||
|
||||
try {
|
||||
target.resize((std::string::size_type) fileSize);
|
||||
} catch (bad_alloc&) {
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
qfile.close();
|
||||
result = true;
|
||||
} while (0);
|
||||
#endif //QT_CONFIG
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode)
|
||||
@@ -370,57 +410,72 @@ bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_bas
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JFileSystem::OpenFile(const string &filename)
|
||||
JFile* JFileSystem::OpenFile(const string &filename)
|
||||
{
|
||||
mCurrentFileInZip = NULL;
|
||||
bool result;
|
||||
JFile* jFile = new JFile();
|
||||
jFile->mCurrentFileInZip = NULL;
|
||||
|
||||
if (!mZipAvailable || !mZipFile)
|
||||
return openForRead(mFile, filename);
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
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); */
|
||||
return openForRead(mFile, filename);
|
||||
result = openForRead(jFile->mFile, filename);
|
||||
break;
|
||||
}
|
||||
|
||||
jFile->mCurrentFileInZip = &(it2->second);
|
||||
result = true;
|
||||
} while(0);
|
||||
|
||||
if(result)
|
||||
return jFile;
|
||||
else {
|
||||
delete jFile;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mCurrentFileInZip = &(it2->second);
|
||||
mFileSize = it2->second.m_Size;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JFileSystem::CloseFile()
|
||||
void JFileSystem::CloseFile(JFile* jFile)
|
||||
{
|
||||
if (mZipAvailable && mZipFile)
|
||||
{
|
||||
mCurrentFileInZip = NULL;
|
||||
}
|
||||
|
||||
if (mFile)
|
||||
mFile.close();
|
||||
delete jFile;
|
||||
}
|
||||
|
||||
//returns 0 if less than "size" bits were read
|
||||
int JFileSystem::ReadFile(void *buffer, int size)
|
||||
int JFileSystem::ReadFile(JFile* jFile, void *buffer, int size)
|
||||
{
|
||||
if (mCurrentFileInZip)
|
||||
if (jFile->mCurrentFileInZip)
|
||||
{
|
||||
assert(mZipFile);
|
||||
if((size_t)size > mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
|
||||
if((size_t)size > jFile->mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
|
||||
return 0;
|
||||
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, mCurrentFileInZip->m_Offset);
|
||||
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, jFile->mCurrentFileInZip->m_Offset);
|
||||
if (!mZipFile.seekg(offset))
|
||||
return 0;
|
||||
mZipFile.read((char *) buffer, size);
|
||||
@@ -428,16 +483,43 @@ int JFileSystem::ReadFile(void *buffer, int size)
|
||||
return size;
|
||||
}
|
||||
|
||||
if (!mFile)
|
||||
#ifdef QT_CONFIG
|
||||
if(jFile->mpqFile) {
|
||||
return jFile->mpqFile->read((char*)buffer, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!jFile->mFile)
|
||||
return 0;
|
||||
|
||||
assert(!mFile.Zipped() || (size_t)size <= mFile.getUncompSize());
|
||||
mFile.read((char *)buffer, size);
|
||||
if (mFile.eof())
|
||||
assert(!jFile->mFile.Zipped() || (size_t)size <= jFile->mFile.getUncompSize());
|
||||
jFile->mFile.read((char *)buffer, size);
|
||||
if (jFile->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());
|
||||
@@ -525,6 +607,15 @@ 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)
|
||||
{
|
||||
@@ -540,12 +631,18 @@ std::vector<std::string> JFileSystem::scanfolder(const std::string& folderName)
|
||||
return scanfolder(folderName, result);
|
||||
}
|
||||
|
||||
int JFileSystem::GetFileSize()
|
||||
int JFileSystem::GetFileSize(JFile* jFile)
|
||||
{
|
||||
if (mCurrentFileInZip)
|
||||
return mFileSize;
|
||||
if (jFile->mCurrentFileInZip)
|
||||
return jFile->mCurrentFileInZip->m_Size;
|
||||
|
||||
return GetFileSize(mFile);
|
||||
#ifdef QT_CONFIG
|
||||
if(jFile->mpqFile) {
|
||||
return jFile->mpqFile->size();
|
||||
}
|
||||
#endif
|
||||
|
||||
return GetFileSize(jFile->mFile);
|
||||
}
|
||||
|
||||
bool JFileSystem::Rename(string _from, string _to)
|
||||
|
||||
+10
-9
@@ -116,25 +116,26 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
|
||||
int size;
|
||||
|
||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||
if (!fileSys->OpenFile(engFileName))
|
||||
JFile* jFile = fileSys->OpenFile(engFileName);
|
||||
if (!jFile)
|
||||
return false;
|
||||
|
||||
size = fileSys->GetFileSize();
|
||||
size = fileSys->GetFileSize(jFile);
|
||||
mEngFont = new BYTE[size];
|
||||
|
||||
fileSys->ReadFile(mEngFont, size);
|
||||
fileSys->CloseFile();
|
||||
fileSys->ReadFile(jFile, mEngFont, size);
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
|
||||
if (!fileSys->OpenFile(chnFileName))
|
||||
jFile = fileSys->OpenFile(chnFileName);
|
||||
if (!jFile)
|
||||
return false;
|
||||
|
||||
size = fileSys->GetFileSize();
|
||||
size = fileSys->GetFileSize(jFile);
|
||||
|
||||
mChnFont = new BYTE[size];
|
||||
|
||||
fileSys->ReadFile(mChnFont, size);
|
||||
fileSys->CloseFile();
|
||||
fileSys->ReadFile(jFile, mChnFont, size);
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+25
-20
@@ -892,9 +892,10 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
|
||||
{
|
||||
png_size_t check;
|
||||
|
||||
JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
|
||||
JFile* jFile = (JFile*)png_ptr->io_ptr;
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
|
||||
check = fileSystem->ReadFile(data, length);
|
||||
check = fileSystem->ReadFile(jFile, data, length);
|
||||
|
||||
if (check != length)
|
||||
{
|
||||
@@ -1038,23 +1039,24 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
bits32 = NULL;
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(filename))
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rawsize = fileSystem->GetFileSize();
|
||||
rawsize = fileSystem->GetFileSize(jFile);
|
||||
|
||||
rawdata = new u8[rawsize];
|
||||
|
||||
if (!rawdata)
|
||||
{
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
return;
|
||||
}
|
||||
|
||||
fileSystem->ReadFile(rawdata, rawsize);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->ReadFile(jFile, rawdata, rawsize);
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
|
||||
cinfo.err = jpeg_std_error(&jerr);
|
||||
@@ -1362,24 +1364,25 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
|
||||
u32* line;
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile) 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();
|
||||
fileSystem->CloseFile(jFile);
|
||||
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();
|
||||
fileSystem->CloseFile(jFile);
|
||||
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)fileSystem, PNGCustomReadDataFn);
|
||||
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn);
|
||||
|
||||
png_set_sig_bytes(png_ptr, sig_read);
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
@@ -1392,7 +1395,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();
|
||||
fileSystem->CloseFile(jFile);
|
||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
return JGE_ERR_MALLOC_FAILED;
|
||||
}
|
||||
@@ -1430,7 +1433,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();
|
||||
fileSystem->CloseFile(jFile);
|
||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
return JGE_ERR_MALLOC_FAILED;
|
||||
}
|
||||
@@ -1505,7 +1508,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();
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
if (done)
|
||||
{
|
||||
@@ -1725,9 +1728,9 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
||||
|
||||
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
|
||||
{
|
||||
|
||||
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
|
||||
if (fileSys->ReadFile(buf, size))
|
||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||
JFile* jFile = (JFile*)ft->UserData;
|
||||
if (fileSys->ReadFile(jFile, buf, size))
|
||||
return size;
|
||||
else
|
||||
return 0;
|
||||
@@ -1740,15 +1743,17 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
|
||||
|
||||
|
||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||
if (!fileSys->OpenFile(filename))
|
||||
JFile* jFile = fileSys->OpenFile(filename);
|
||||
|
||||
if (!jFile)
|
||||
return;
|
||||
|
||||
DWORD bkcol;
|
||||
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
|
||||
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
|
||||
|
||||
if(result!=0)
|
||||
textureInfo.mBits=NULL;
|
||||
fileSys->CloseFile();
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
+4
-3
@@ -42,10 +42,11 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
||||
|
||||
//FILE *file;
|
||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||
if (!fileSys->OpenFile(filename)) return;
|
||||
JFile* jFile = fileSys->OpenFile(filename);
|
||||
if (!jFile) return;
|
||||
|
||||
fileSys->ReadFile((u8 *)buffer, 2048);
|
||||
fileSys->CloseFile();
|
||||
fileSys->ReadFile(jFile, (u8 *)buffer, 2048);
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
sprintf(filename, "%s.png", fontname);
|
||||
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
|
||||
|
||||
@@ -96,7 +96,8 @@ bool JMD2Model::Load(char *filename, char *textureName)
|
||||
// open the model file
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(filename))
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile)
|
||||
return false;
|
||||
//filePtr = fopen(filename, "rb");
|
||||
//if (filePtr == NULL)
|
||||
@@ -107,13 +108,13 @@ bool JMD2Model::Load(char *filename, char *textureName)
|
||||
//fileLen = ftell(filePtr);
|
||||
//fseek(filePtr, 0, SEEK_SET);
|
||||
|
||||
fileLen = fileSystem->GetFileSize();
|
||||
fileLen = fileSystem->GetFileSize(jFile);
|
||||
|
||||
// read entire file into buffer
|
||||
buffer = (char*)malloc(fileLen + 1);
|
||||
//fread(buffer, sizeof(char), fileLen, filePtr);
|
||||
fileSystem->ReadFile(buffer, fileLen);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->ReadFile(jFile, buffer, fileLen);
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
// extract model file header from buffer
|
||||
modelHeader = (modelHeader_t*)buffer;
|
||||
|
||||
@@ -47,14 +47,15 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
|
||||
{
|
||||
|
||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||
if (!fileSys->OpenFile(modelName))
|
||||
JFile* jFile = fileSys->OpenFile(modelName);
|
||||
if (!jFile)
|
||||
return false;
|
||||
|
||||
int size = fileSys->GetFileSize();
|
||||
int size = fileSys->GetFileSize(jFile);
|
||||
char *buffer = new char[size];
|
||||
|
||||
fileSys->ReadFile(buffer, size);
|
||||
fileSys->CloseFile();
|
||||
fileSys->ReadFile(jFile, buffer, size);
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
Vector3D vert;
|
||||
|
||||
|
||||
@@ -55,11 +55,12 @@ bool JParticleEffect::Load(const char* filename)
|
||||
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
||||
if (fileSystem == NULL) return false;
|
||||
|
||||
if (!fileSystem->OpenFile(filename)) return false;
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile) return false;
|
||||
|
||||
int size = fileSystem->GetFileSize();
|
||||
int size = fileSystem->GetFileSize(jFile);
|
||||
char *xmlBuffer = new char[size];
|
||||
fileSystem->ReadFile(xmlBuffer, size);
|
||||
fileSystem->ReadFile(jFile, xmlBuffer, size);
|
||||
|
||||
TiXmlDocument doc;
|
||||
|
||||
@@ -296,7 +297,7 @@ bool JParticleEffect::Load(const char* filename)
|
||||
}
|
||||
}
|
||||
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
delete[] xmlBuffer;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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;
|
||||
|
||||
if (!fileSystem->OpenFile(path.c_str())) return false;
|
||||
|
||||
int size = fileSystem->GetFileSize();
|
||||
int size = fileSystem->GetFileSize(jFile);
|
||||
char *xmlBuffer = new char[size];
|
||||
fileSystem->ReadFile(xmlBuffer, size);
|
||||
fileSystem->ReadFile(jFile, xmlBuffer, size);
|
||||
|
||||
TiXmlDocument doc;
|
||||
doc.Parse(xmlBuffer);
|
||||
@@ -179,7 +179,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
||||
|
||||
}
|
||||
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
delete[] xmlBuffer;
|
||||
// JGERelease();
|
||||
|
||||
|
||||
+5
-4
@@ -41,11 +41,12 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
|
||||
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
||||
|
||||
if (fileSystem == NULL) return false;
|
||||
if (!fileSystem->OpenFile(filename)) return false;
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile) return false;
|
||||
|
||||
int size = fileSystem->GetFileSize();
|
||||
int size = fileSystem->GetFileSize(jFile);
|
||||
char *xmlBuffer = new char[size];
|
||||
fileSystem->ReadFile(xmlBuffer, size);
|
||||
fileSystem->ReadFile(jFile, xmlBuffer, size);
|
||||
|
||||
TiXmlDocument doc;
|
||||
doc.Parse(xmlBuffer);
|
||||
@@ -76,7 +77,7 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
|
||||
|
||||
}
|
||||
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
delete[] xmlBuffer;
|
||||
|
||||
return true;
|
||||
|
||||
+6
-5
@@ -199,15 +199,16 @@ bool JTTFont::Load(const char *filename, int size, int mode)
|
||||
|
||||
if (FT_Init_FreeType( &mLibrary ) == 0)
|
||||
{
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (fileSystem->OpenFile(filename))
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (jFile)
|
||||
{
|
||||
mFontBitsSize = fileSystem->GetFileSize();
|
||||
mFontBitsSize = fileSystem->GetFileSize(jFile);
|
||||
|
||||
mFontBits = (FT_Byte*)malloc(mFontBitsSize);
|
||||
|
||||
fileSystem->ReadFile(mFontBits, mFontBitsSize);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->ReadFile(jFile, mFontBits, mFontBitsSize);
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
if (FT_New_Memory_Face(mLibrary, mFontBits, mFontBitsSize, 0, &mFace ) == 0)
|
||||
{
|
||||
|
||||
@@ -57,19 +57,20 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap __attribute__((unused)))
|
||||
// Load font description
|
||||
|
||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||
if (!fileSys->OpenFile(szFont)) return;
|
||||
JFile* jFile = fileSys->OpenFile(szFont);
|
||||
if (!jFile) return;
|
||||
|
||||
//data=hge->Resource_Load(szFont, &size);
|
||||
//if(!data) return;
|
||||
size = fileSys->GetFileSize();
|
||||
size = fileSys->GetFileSize(jFile);
|
||||
|
||||
desc = new char[size+1];
|
||||
//memcpy(desc,data,size);
|
||||
fileSys->ReadFile(desc, size);
|
||||
fileSys->ReadFile(jFile, desc, size);
|
||||
desc[size]=0;
|
||||
|
||||
//hge->Resource_Free(data);
|
||||
fileSys->CloseFile();
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
pdesc=_get_line(desc,linebuf);
|
||||
if(strcmp(linebuf, FNTHEADERTAG))
|
||||
|
||||
+28
-33
@@ -50,46 +50,41 @@ float Random_Float(float min, float max)
|
||||
|
||||
hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
|
||||
{
|
||||
//void *psi;
|
||||
//hgeParticleSystemInfo psi;
|
||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||
JFile* jFile = fileSys->OpenFile(filename);
|
||||
if (!jFile) return;
|
||||
|
||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||
//hge=hgeCreate(HGE_VERSION);
|
||||
//if(!psi) return;
|
||||
|
||||
//psi=hge->Resource_Load(filename);
|
||||
if (!fileSys->OpenFile(filename)) return;
|
||||
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
||||
//hge->Resource_Free(psi);
|
||||
|
||||
//if(!psi) return;
|
||||
// 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);
|
||||
|
||||
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
||||
//hge->Resource_Free(psi);
|
||||
info.sprite=sprite;
|
||||
// info.fGravityMin *= 100;
|
||||
// info.fGravityMax *= 100;
|
||||
// info.fSpeedMin *= 100;
|
||||
// info.fSpeedMax *= 100;
|
||||
|
||||
// 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();
|
||||
vecLocation.x=vecPrevLocation.x=0.0f;
|
||||
vecLocation.y=vecPrevLocation.y=0.0f;
|
||||
fTx=fTy=0;
|
||||
|
||||
info.sprite=sprite;
|
||||
// info.fGravityMin *= 100;
|
||||
// info.fGravityMax *= 100;
|
||||
// info.fSpeedMin *= 100;
|
||||
// info.fSpeedMax *= 100;
|
||||
fEmissionResidue=0.0f;
|
||||
nParticlesAlive=0;
|
||||
fAge=-2.0;
|
||||
mTimer = 0.0f;
|
||||
|
||||
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;
|
||||
rectBoundingBox.Clear();
|
||||
bUpdateBoundingBox=false;
|
||||
}
|
||||
|
||||
hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi)
|
||||
|
||||
+36
-29
@@ -1683,20 +1683,21 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
int rawsize, i;
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(filename)) return;
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile) return;
|
||||
|
||||
rawsize = fileSystem->GetFileSize();
|
||||
rawsize = fileSystem->GetFileSize(jFile);
|
||||
|
||||
rawdata = new BYTE[rawsize];
|
||||
|
||||
if (!rawdata)
|
||||
{
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
return;
|
||||
}
|
||||
|
||||
fileSystem->ReadFile(rawdata, rawsize);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->ReadFile(jFile, rawdata, rawsize);
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
// Initialize libJpeg Object
|
||||
cinfo.err = jpeg_std_error(&jerr);
|
||||
@@ -1804,9 +1805,10 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
|
||||
{
|
||||
png_size_t check;
|
||||
|
||||
JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
JFile *jFile = (JFile*)png_ptr->io_ptr;
|
||||
|
||||
check = fileSystem->ReadFile(data, length);
|
||||
check = fileSystem->ReadFile(jFile, data, length);
|
||||
|
||||
if (check != length)
|
||||
{
|
||||
@@ -1869,13 +1871,14 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
DWORD* line;
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(filename))
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile)
|
||||
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();
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
return JGE_ERR_PNG;
|
||||
}
|
||||
@@ -1885,14 +1888,14 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
if (info_ptr == NULL)
|
||||
{
|
||||
//fclose(fp);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
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)fileSystem, PNGCustomReadDataFn);
|
||||
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn);
|
||||
|
||||
png_set_sig_bytes(png_ptr, sig_read);
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
@@ -1908,7 +1911,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
if (!line)
|
||||
{
|
||||
//fclose(fp);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
return JGE_ERR_MALLOC_FAILED;
|
||||
@@ -1957,7 +1960,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();
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
|
||||
textureInfo.mBits = buffer;
|
||||
@@ -2116,9 +2119,10 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
||||
|
||||
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
|
||||
{
|
||||
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
|
||||
//return fread(buf, 1, size, (FILE *)ft->UserData);
|
||||
if (fileSys->ReadFile(buf, size))
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
JFile* jFile = (JFile*)ft->UserData;
|
||||
|
||||
if (fileSys->ReadFile(jFile, buf, size))
|
||||
return size;
|
||||
else
|
||||
return 0;
|
||||
@@ -2130,17 +2134,18 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
|
||||
///*
|
||||
//FILE * fp = fopen(filename, "rb");
|
||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||
if (!fileSys->OpenFile(filename))
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile))
|
||||
return;
|
||||
|
||||
//if(fp == NULL)
|
||||
// return;
|
||||
DWORD bkcol;
|
||||
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
|
||||
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
|
||||
if(result!=0)
|
||||
textureInfo.mBits=NULL;
|
||||
//fclose(fp);
|
||||
fileSys->CloseFile();
|
||||
fileSys->CloseFile(jFile);
|
||||
return ;//*/
|
||||
}
|
||||
#endif //(!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
|
||||
@@ -2161,20 +2166,21 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
|
||||
UIImage *image = NULL;
|
||||
|
||||
do {
|
||||
if (!fileSystem->OpenFile(filename))
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile)
|
||||
break;
|
||||
|
||||
rawsize = fileSystem->GetFileSize();
|
||||
rawsize = fileSystem->GetFileSize(jFile);
|
||||
rawdata = new BYTE[rawsize];
|
||||
|
||||
if (!rawdata)
|
||||
{
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
break;
|
||||
}
|
||||
|
||||
fileSystem->ReadFile(rawdata, rawsize);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->ReadFile(jFile, rawdata, rawsize);
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
texData = [[NSData alloc] initWithBytes:rawdata length:rawsize];
|
||||
image = [[UIImage alloc] initWithData:texData];
|
||||
@@ -2254,20 +2260,21 @@ JTexture* JRenderer::LoadTexture(const char* filename, int, int)
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
|
||||
do {
|
||||
if (!fileSystem->OpenFile(filename))
|
||||
JFile* jFile = fileSystem->OpenFile(filename);
|
||||
if (!jFile)
|
||||
break;
|
||||
|
||||
rawsize = fileSystem->GetFileSize();
|
||||
rawsize = fileSystem->GetFileSize(jFile);
|
||||
rawdata = new BYTE[rawsize];
|
||||
|
||||
if (!rawdata)
|
||||
{
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
break;
|
||||
}
|
||||
|
||||
fileSystem->ReadFile(rawdata, rawsize);
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->ReadFile(jFile, rawdata, rawsize);
|
||||
fileSystem->CloseFile(jFile);
|
||||
|
||||
QImage tmpImage = QImage::fromData(rawdata, rawsize);
|
||||
if(tmpImage.isNull())
|
||||
|
||||
+10
-8
@@ -161,15 +161,16 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
if (music)
|
||||
{
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (fileSystem->OpenFile(fileName))
|
||||
JFile* jFile = fileSystem->OpenFile(fileName);
|
||||
if (jFile)
|
||||
{
|
||||
int size = fileSystem->GetFileSize();
|
||||
int size = fileSystem->GetFileSize(jFile);
|
||||
char *buffer = new char[size];
|
||||
fileSystem->ReadFile(buffer, size);
|
||||
fileSystem->ReadFile(jFile, buffer, size);
|
||||
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
|
||||
|
||||
delete[] buffer;
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
}
|
||||
}
|
||||
return music;
|
||||
@@ -281,15 +282,16 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
if (sample)
|
||||
{
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (fileSystem->OpenFile(fileName))
|
||||
JFile* jFile = fileSystem->OpenFile(fileName);
|
||||
if (jFile)
|
||||
{
|
||||
int size = fileSystem->GetFileSize();
|
||||
int size = fileSystem->GetFileSize(jFile);
|
||||
char *buffer = new char[size];
|
||||
fileSystem->ReadFile(buffer, size);
|
||||
fileSystem->ReadFile(jFile, buffer, size);
|
||||
sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
|
||||
|
||||
delete[] buffer;
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
}else
|
||||
sample->mSample = NULL;
|
||||
|
||||
|
||||
+28
-28
@@ -418,29 +418,29 @@ void WagicCore::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
QPoint lastPos = event->pos();
|
||||
m_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 (lastPos.y() >= m_viewPort.top() &&
|
||||
lastPos.y() <= m_viewPort.bottom() &&
|
||||
lastPos.x() <= m_viewPort.right() &&
|
||||
lastPos.x() >= m_viewPort.left()) {
|
||||
if (lastPosy() >= m_viewPort.top() &&
|
||||
lastPosy() <= m_viewPort.bottom() &&
|
||||
lastPosx() <= m_viewPort.right() &&
|
||||
lastPosx() >= m_viewPort.left()) {
|
||||
m_engine->LeftClicked(
|
||||
((lastPos.x()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
|
||||
((lastPos.y()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight);
|
||||
((lastPosx()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
|
||||
((lastPosy()-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 = lastPos.x();
|
||||
mMouseDownY = lastPos.y();
|
||||
mMouseDownX = lastPosx();
|
||||
mMouseDownY = lastPosy();
|
||||
mLastFingerDownTime = g_startTimer.elapsed();
|
||||
#endif
|
||||
} else if(lastPos.y()<m_viewPort.top()) {
|
||||
} else if(lastPosy()<m_viewPort.top()) {
|
||||
m_engine->HoldKey_NoRepeat(JGE_BTN_MENU);
|
||||
} else if(lastPos.y()>m_viewPort.bottom()) {
|
||||
} else if(lastPosy()>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)
|
||||
{
|
||||
QPoint lastPos = event->pos();
|
||||
m_lastPos = event->pos();
|
||||
|
||||
if (lastPos.y() >= m_viewPort.top() &&
|
||||
lastPos.y() <= m_viewPort.bottom() &&
|
||||
lastPos.x() <= m_viewPort.right() &&
|
||||
lastPos.x() >= m_viewPort.left()) {
|
||||
if (lastPosy() >= m_viewPort.top() &&
|
||||
lastPosy() <= m_viewPort.bottom() &&
|
||||
lastPosx() <= m_viewPort.right() &&
|
||||
lastPosx() >= 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 - lastPos.x()) < kHitzonePliancy &&
|
||||
abs(mMouseDownY - lastPos.y()) < kHitzonePliancy)
|
||||
if(abs(mMouseDownX - lastPosx()) < kHitzonePliancy &&
|
||||
abs(mMouseDownY - lastPosy()) < kHitzonePliancy)
|
||||
{
|
||||
m_engine->HoldKey_NoRepeat(JGE_BTN_OK);
|
||||
}
|
||||
}
|
||||
else if (g_startTimer.elapsed() - mLastFingerDownTime >= kSwipeEventMinDuration)
|
||||
{ // Let's swipe
|
||||
m_engine->Scroll(lastPos.x()-mMouseDownX, lastPos.y()-mMouseDownY);
|
||||
m_engine->Scroll(lastPosx()-mMouseDownX, lastPosy()-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(lastPos.y() < m_viewPort.top()) {
|
||||
} else if(lastPosy() < m_viewPort.top()) {
|
||||
m_engine->ReleaseKey(JGE_BTN_MENU);
|
||||
} else if(lastPos.y() > m_viewPort.bottom()) {
|
||||
} else if(lastPosy() > 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();
|
||||
|
||||
QPoint lastPos = event->pos();
|
||||
m_lastPos = event->pos();
|
||||
|
||||
if (lastPos.y() >= m_viewPort.top() &&
|
||||
lastPos.y() <= m_viewPort.bottom() &&
|
||||
lastPos.x() <= m_viewPort.right() &&
|
||||
lastPos.x() >= m_viewPort.left()) {
|
||||
if (lastPosy() >= m_viewPort.top() &&
|
||||
lastPosy() <= m_viewPort.bottom() &&
|
||||
lastPosx() <= m_viewPort.right() &&
|
||||
lastPosx() >= m_viewPort.left()) {
|
||||
m_engine->LeftClicked(
|
||||
((lastPos.x()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
|
||||
((lastPos.y()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight);
|
||||
((lastPosx()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
|
||||
((lastPosy()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight);
|
||||
event->accept();
|
||||
} else {
|
||||
super::mouseMoveEvent(event);
|
||||
|
||||
@@ -106,6 +106,7 @@ 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);
|
||||
|
||||
@@ -131,6 +132,7 @@ 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);
|
||||
|
||||
|
||||
@@ -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, and more at http://wololo.net
|
||||
Info, downloads, discussions and more at http://wololo.net/forum/index.php
|
||||
|
||||
-
|
||||
|
||||
@@ -7,10 +7,13 @@ from optparse import OptionParser
|
||||
def createResZipFile(filename):
|
||||
|
||||
utilities = ZipUtilities()
|
||||
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
|
||||
|
||||
zip_file = zipfile.ZipFile(filename, 'w', zipfile.ZIP_STORED)
|
||||
utilities.addFolderToZip(zip_file, 'themes')
|
||||
@@ -26,6 +29,10 @@ def createResZipFile(filename):
|
||||
utilities.addFolderToZip(zip_file, 'ai')
|
||||
zip_file.close()
|
||||
|
||||
if rename:
|
||||
os.rename('settings/options.txt', 'settings/options.orig.txt')
|
||||
os.rename('player/options.txt', 'player/options.orig.txt')
|
||||
|
||||
def getFilename():
|
||||
p = Properties();
|
||||
p.load(open('../../build.number.properties'));
|
||||
@@ -35,6 +42,39 @@ 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():
|
||||
@@ -77,20 +117,37 @@ 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 ios, android, etc)", metavar="PLATFORM", dest="platform")
|
||||
parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg qt, ios, android, etc)", metavar="PLATFORM", dest="platform")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if (options.platform):
|
||||
if (options.platform == "ios"):
|
||||
createIosResFile()
|
||||
print "reading %s..." % options.platform
|
||||
if (options.platform == 'ios'):
|
||||
createIosResFile()
|
||||
elif (options.platform == 'qt'):
|
||||
createQrcFile()
|
||||
else:
|
||||
createStandardResFile()
|
||||
createStandardResFile()
|
||||
else:
|
||||
createStandardResFile()
|
||||
|
||||
|
||||
@@ -1513,3 +1513,8 @@ primitive=Zephyr Net
|
||||
id=142357
|
||||
rarity=C
|
||||
[/card]
|
||||
[card]
|
||||
primitive=Avatar Token
|
||||
id=-140233
|
||||
rarity=T
|
||||
[/card]
|
||||
|
||||
@@ -1248,3 +1248,8 @@ primitive=Zombie Goliath
|
||||
id=190545
|
||||
rarity=C
|
||||
[/card]
|
||||
[card]
|
||||
primitive=Avatar Token
|
||||
id=-191239
|
||||
rarity=T
|
||||
[/card]
|
||||
|
||||
@@ -1258,3 +1258,8 @@ primitive=Yavimaya Wurm
|
||||
id=205221
|
||||
rarity=C
|
||||
[/card]
|
||||
[card]
|
||||
primitive=Avatar Token
|
||||
id=-205957
|
||||
rarity=T
|
||||
[/card]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31457,7 +31457,7 @@ toughness=2
|
||||
[/card]
|
||||
[card]
|
||||
name=Flourishing Defenses
|
||||
auto=@counteradded(-1/-1) from(creature|mybattlefield):may token(Elf Warrior,Creature elf warrior,1/1,green)
|
||||
auto=@counteradded(-1/-1) from(creature):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 >30) all(this) flip(Rune-Tail's Essence)
|
||||
auto=this(controllerlife > 29) transforms((,newability[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,11 +78444,7 @@ toughness=2
|
||||
[/card]
|
||||
[card]
|
||||
name=Shifting Sky
|
||||
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
|
||||
auto=chooseacolor lord(*[-land]) becomes(,chosencolor) chooseend
|
||||
text=As Shifting Sky enters the battlefield, choose a color. -- All nonland permanents are the chosen color.
|
||||
mana={2}{U}
|
||||
type=Enchantment
|
||||
|
||||
@@ -11,6 +11,7 @@ private:
|
||||
static const float x_center;
|
||||
static const float right_border;
|
||||
static const float slide_animation_duration;
|
||||
static const float scroll_animation_duration;
|
||||
|
||||
public:
|
||||
CarouselDeckView();
|
||||
@@ -18,19 +19,21 @@ public:
|
||||
void Reset();
|
||||
|
||||
void UpdateViewState(float dt);
|
||||
void UpdateCardPosition(CardRep &rep, int index);
|
||||
void UpdateCardPosition(int index);
|
||||
void renderCard(int index)
|
||||
{
|
||||
int alpha = (int) (255 * (getCardRep(index).scale + 1.0 - max_scale));
|
||||
int alpha = (int) (255 * (mCards[index].scale + 1.0 - max_scale));
|
||||
DeckView::renderCard(index, alpha);
|
||||
}
|
||||
|
||||
void Render();
|
||||
|
||||
bool ButtonPressed(Buttons button);
|
||||
MTGCard * Click(int x, int y);
|
||||
MTGCard * Click();
|
||||
|
||||
void changePosition(int offset);
|
||||
void changeFilter(int offset);
|
||||
void changePositionAnimated(int offset);
|
||||
void changeFilterAnimated(int offset);
|
||||
|
||||
MTGCard *getActiveCard();
|
||||
private:
|
||||
|
||||
+190
-12
@@ -9,55 +9,233 @@
|
||||
#include "WResourceManager.h"
|
||||
#include "Pos.h"
|
||||
|
||||
|
||||
/*! \brief A abstract base class for deck views
|
||||
*
|
||||
* The deck editor uses a deck view to present the cards
|
||||
* e.g. in a circular "Carousel" layout or in a flat grid
|
||||
* layout. Both layouts inherit this base class to ensure
|
||||
* a common interface which the deck editor can rely on.
|
||||
*/
|
||||
class DeckView
|
||||
{
|
||||
protected:
|
||||
/*! \brief defines the delay until additional card informations get shown
|
||||
*
|
||||
* \note I am not entirely sure about that
|
||||
*/
|
||||
static const float no_user_activity_show_card_delay;
|
||||
|
||||
public:
|
||||
/*! \brief Represents a card for internal use in the deck view
|
||||
*
|
||||
* It stores positional information and a pointer to the actual card structure.
|
||||
*/
|
||||
struct CardRep{
|
||||
float x;
|
||||
float y;
|
||||
float scale;
|
||||
MTGCard * card;
|
||||
};
|
||||
|
||||
public:
|
||||
/*! \brief Defines if the filter needs an update
|
||||
*
|
||||
* The owner of the deck that is shown is responsible for updating the filters.
|
||||
*/
|
||||
bool dirtyFilters;
|
||||
|
||||
/*! \brief Defines if the card positions need an update
|
||||
*
|
||||
* If the card positions are dirty, UpdateCardPosition will get called on
|
||||
* all cards during Update(float dt);
|
||||
*
|
||||
* \see Update
|
||||
* \see UpdateCardPosition
|
||||
*/
|
||||
bool dirtyCardPos;
|
||||
|
||||
/*! \brief Constructs the view and initializes datamembers
|
||||
*
|
||||
* It sets the dirty states to true, the currently shown deck to NULL and selects filter 0.
|
||||
*
|
||||
* \param numberOfCards the number of cards the view handles (this includes hidden cards for caching)
|
||||
*/
|
||||
DeckView(int numberOfCards);
|
||||
|
||||
/*! \brief Does nothing but is needed to ensure proper deletion of derived classes.
|
||||
*/
|
||||
virtual ~DeckView();
|
||||
|
||||
/*! \brief Resets nearly all datamembers to their initial values
|
||||
*
|
||||
* Does not reset mCards.
|
||||
*/
|
||||
virtual void Reset();
|
||||
|
||||
//advances the view and card representations
|
||||
/*! \brief Advances the view by dt time units
|
||||
*
|
||||
* This method calls UpdateViewState unconditionally and UpdateCardPosition on every card
|
||||
* if dirtyCardPos is set. It then resets dirtyCardPos.
|
||||
*
|
||||
* \param dt the number of time units to advance
|
||||
* \see UpdateViewState
|
||||
* \see UpdateCardPosition
|
||||
*/
|
||||
void Update(float dt);
|
||||
virtual void SetDeck(DeckDataWrapper *toShow);
|
||||
|
||||
/*! \brief Sets the deck that this view shows
|
||||
*
|
||||
* This method replaces the currently shown deck with toShow, sets all dirty states and
|
||||
* reloads the mtg cards. No ownership changes.
|
||||
*
|
||||
* \param toShow the deck to show
|
||||
* \see reloadIndexes
|
||||
*/
|
||||
void SetDeck(DeckDataWrapper *toShow);
|
||||
|
||||
/*! \brief Returns a pointer to the current deck.
|
||||
*/
|
||||
DeckDataWrapper *deck();
|
||||
void SwitchFilter(int delta);
|
||||
void SwitchPosition(int delta);
|
||||
|
||||
/*! \brief Performs an immediate switch of the filter without animations
|
||||
*
|
||||
* This method rotates the currently selected filter by delta and sets dirtyFilters.
|
||||
*
|
||||
* \param delta the filter to select relatively to the currently selected filter
|
||||
* \see dirtyFilters
|
||||
*/
|
||||
void changeFilter(int delta);
|
||||
|
||||
/*! \brief Performs an immediate switch of the position without animations
|
||||
*
|
||||
* If the i-th card stored in mCards points to the j-th card in the deck, it will point
|
||||
* to the (j+delta)-th card after this method is called. No dirty states are set.
|
||||
*
|
||||
* \param delta the number of cards to advances
|
||||
* \see mCards
|
||||
*/
|
||||
void changePosition(int delta);
|
||||
|
||||
/*! \brief Returns the number of the currently selected filter
|
||||
*
|
||||
* \return the currently selected filter
|
||||
*/
|
||||
int filter();
|
||||
|
||||
/*! \brief Reloads the mtg card pointers of mCards from the deck
|
||||
*
|
||||
* This is called when: We change the position in the deck or the deck structure changes
|
||||
* (due to filtering or addition or removal of cards).
|
||||
*/
|
||||
void reloadIndexes();
|
||||
|
||||
/*! \brief Returns the current position in the deck
|
||||
*/
|
||||
int getPosition();
|
||||
|
||||
/*! \brief Renders the view
|
||||
*/
|
||||
virtual void Render() = 0;
|
||||
|
||||
/*! \brief Reacts to selections by a pointer device (e. g. mouse, touch)
|
||||
*
|
||||
* If the selection in view internal i. e. a card got selected, there is
|
||||
* no outside action performed and this method will return NULL. If a action got
|
||||
* triggered i. e. a selected card was activated, it returns that card
|
||||
* for further handling by the caller.
|
||||
*
|
||||
* \param x the x coordinate of the pointer during the action
|
||||
* \param y the y coordinate of the pointer during the action
|
||||
* \returns the card the action corresponds to
|
||||
*/
|
||||
virtual MTGCard * Click(int x, int y) = 0;
|
||||
bool ButtonPressed(Buttons button);
|
||||
|
||||
/*! \brief Reacts to selections by pointerless devices (e. g. buttons)
|
||||
*
|
||||
* \see Click(int x, int y)
|
||||
* \returns the card the actions corresponds to
|
||||
*/
|
||||
virtual MTGCard * Click() = 0;
|
||||
|
||||
/*! \brief Handles ordinary button presses
|
||||
*
|
||||
* \param the pressed JButton
|
||||
* \returns true if the view reacted to the button and false otherwise
|
||||
*/
|
||||
virtual bool ButtonPressed(Buttons button) = 0;
|
||||
|
||||
/*! \brief Returns the currently active card
|
||||
*/
|
||||
virtual MTGCard *getActiveCard() = 0;
|
||||
virtual void changePosition(int offset) = 0;
|
||||
virtual void changeFilter(int offset) = 0;
|
||||
|
||||
/*! \brief Changes the position by a given offset
|
||||
*
|
||||
* Advances the view by offset cards and animates the change.
|
||||
*
|
||||
* \param offset the number of positions to advance
|
||||
*/
|
||||
virtual void changePositionAnimated(int offset) = 0;
|
||||
|
||||
/*! \brief Changes the filter by a given offset
|
||||
*
|
||||
* Rotates the selected filter by the given offset and animates the change.
|
||||
*/
|
||||
virtual void changeFilterAnimated(int offset) = 0;
|
||||
protected:
|
||||
|
||||
/*! \brief The number of time units since an user activity occurred
|
||||
*/
|
||||
float last_user_activity;
|
||||
|
||||
/*! \brief The currently selected filter
|
||||
*/
|
||||
int mFilter;
|
||||
|
||||
/*! \brief The currently selected deck
|
||||
*
|
||||
* This class does not take ownership of the deck
|
||||
*/
|
||||
DeckDataWrapper *mCurrentDeck;
|
||||
|
||||
/*! \brief The card positions and pointers
|
||||
*/
|
||||
vector<CardRep> mCards;
|
||||
|
||||
CardRep& getCardRep(unsigned int index);
|
||||
/*! \brief Renders a card with given alpha value
|
||||
*
|
||||
* \param index of the card in mCards to render
|
||||
* \param alpha the alpha value of the card
|
||||
* \param asThumbnail renders the thumbnail image of the card if set to true
|
||||
*
|
||||
* \see mCards
|
||||
*/
|
||||
void renderCard(int index, int alpha, bool asThumbnail = false);
|
||||
|
||||
/*! \brief Returns the index in mCards of the card that is nearest to the given point
|
||||
*
|
||||
* \note This method uses the euclidian distance to the center of the card
|
||||
*
|
||||
* \param x the reference points x coordinate
|
||||
* \param y the reference points y coordinate
|
||||
* \returns the index of the nearest card to the reference point and -1 of mCards is empty
|
||||
*/
|
||||
int getCardIndexNextTo(int x, int y);
|
||||
private:
|
||||
|
||||
/*! \brief Updates the state of the view e. g. view transitions
|
||||
*
|
||||
* \param dt the passes time since the last update
|
||||
*/
|
||||
virtual void UpdateViewState(float dt) = 0;
|
||||
virtual void UpdateCardPosition(CardRep& rep, int index) = 0;
|
||||
|
||||
/*! \brief Updates the given card reps positional members
|
||||
*
|
||||
* This method is called from Update when dirtyCardPos is set
|
||||
*
|
||||
* \param index the index in mCards of the card to update
|
||||
*
|
||||
* \see Update
|
||||
* \see mCards
|
||||
*/
|
||||
virtual void UpdateCardPosition(int index) = 0;
|
||||
};
|
||||
|
||||
#endif // _DECK_VIEW_H_
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
*/
|
||||
void update(float dt)
|
||||
{
|
||||
if(duration > 0)
|
||||
if(time_acc < duration)
|
||||
{
|
||||
time_acc += dt;
|
||||
|
||||
@@ -167,6 +167,50 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/*! \brief This class defines an easing with quadratic acceleration
|
||||
*/
|
||||
class InQuadEasing : public Easing
|
||||
{
|
||||
public:
|
||||
/*! \brief Calls Easing::Easing(val).
|
||||
*
|
||||
* \see Easing::Easing(float& val)
|
||||
*/
|
||||
InQuadEasing(float& val): Easing(val) {}
|
||||
|
||||
/*! \brief Implements the value calculation.
|
||||
*
|
||||
* \see Easing::updateValue()
|
||||
*/
|
||||
void updateValue()
|
||||
{
|
||||
float time_tmp = time_acc / duration;
|
||||
value = delta_value * time_tmp * time_tmp + start_value;
|
||||
}
|
||||
};
|
||||
|
||||
/*! \brief This class defines an easing with quadratic decceleration
|
||||
*/
|
||||
class OutQuadEasing : public Easing
|
||||
{
|
||||
public:
|
||||
/*! \brief Calls Easing::Easing(val).
|
||||
*
|
||||
* \see Easing::Easing(float& val)
|
||||
*/
|
||||
OutQuadEasing(float& val): Easing(val) {}
|
||||
|
||||
/*! \brief Implements the value calculation.
|
||||
*
|
||||
* \see Easing::updateValue()
|
||||
*/
|
||||
void updateValue()
|
||||
{
|
||||
float time_tmp = time_acc / duration;
|
||||
value = (-delta_value) * time_tmp * (time_tmp - 2.0f) + start_value;
|
||||
}
|
||||
};
|
||||
|
||||
/*! \brief This class defines an easing with quadratic acceleration and decceleration.
|
||||
*/
|
||||
class InOutQuadEasing : public Easing
|
||||
|
||||
@@ -17,7 +17,6 @@ private:
|
||||
WSrcCards * setSrc;
|
||||
SimpleMenu * menu;
|
||||
bool showMenu;
|
||||
bool showAlt;
|
||||
bool saveMe;
|
||||
int mState;
|
||||
int mDetailItem;
|
||||
|
||||
@@ -65,7 +65,6 @@ private:
|
||||
JQuadPtr pspIcons[8];
|
||||
WSrcCards * srcCards;
|
||||
TaskList * taskList;
|
||||
float mElapsed;
|
||||
WGuiMenu * shopMenu;
|
||||
WGuiFilters * filterMenu; //Filter menu slides in sideways from right, or up from bottom.
|
||||
WGuiCardImage * bigDisplay;
|
||||
|
||||
@@ -4,6 +4,15 @@
|
||||
#include "DeckView.h"
|
||||
#include "Easing.h"
|
||||
|
||||
/*! \brief Implements a grid view
|
||||
*
|
||||
* This view displays 12 cards in two rows as thumbnails. The currently
|
||||
* selected card is dislayed bigger than the rest and uses the fullsize
|
||||
* image. Scrolling the view horizontally and toggeling filters is
|
||||
* animated and uses quadratic easing.
|
||||
*
|
||||
* It also implements a button mode for pointerless devices.
|
||||
*/
|
||||
class GridDeckView : public DeckView
|
||||
{
|
||||
private:
|
||||
@@ -12,27 +21,134 @@ private:
|
||||
static const float card_scale_small;
|
||||
static const float card_scale_big;
|
||||
public:
|
||||
/*! \brief Constructs a grid view with no decks set
|
||||
*/
|
||||
GridDeckView();
|
||||
|
||||
/*! \brief Does nothing but is needed to ensure proper deletion of derived classes.
|
||||
*/
|
||||
virtual ~GridDeckView();
|
||||
|
||||
/*! \brief Resets almost all member variables but mRows and mCols
|
||||
*/
|
||||
void Reset();
|
||||
|
||||
/*! \brief Advances scrolling and sliding animations
|
||||
*
|
||||
* \param dt the time since the last update
|
||||
*
|
||||
* \see DeckView::UpdateViewState()
|
||||
*/
|
||||
void UpdateViewState(float dt);
|
||||
void UpdateCardPosition(CardRep &rep, int index);
|
||||
|
||||
/*! \brief Updates the cards position
|
||||
*
|
||||
* \see DeckView::UpdateCardPosition()
|
||||
*/
|
||||
void UpdateCardPosition(int index);
|
||||
|
||||
/*! \brief Renders the view
|
||||
*
|
||||
* This method prefetches all rendered cards as thumbnails except the
|
||||
* selected card to reduce cache pressure.
|
||||
*/
|
||||
void Render();
|
||||
|
||||
/*! \brief Handles button presses
|
||||
*
|
||||
* The mapping is as follows:
|
||||
* JGE_BTN_LEFT moves the position to the left if not in button mode
|
||||
* moves the selection otherwise
|
||||
* JGE_BTN_RIGHT move the position to the right if not in button mode
|
||||
* moves the selection otherwise
|
||||
* JGE_BTN_UP select the previous filter if not in button mode
|
||||
* moves the selection otherwise
|
||||
* JGE_BTN_DOWN select the next filter if not in button mode
|
||||
* moves the selection otherwise
|
||||
* JGE_BTN_CTRL deactivate button mode
|
||||
*
|
||||
* \param button the pressed button
|
||||
* \returns if the view handled the button
|
||||
*/
|
||||
bool ButtonPressed(Buttons button);
|
||||
|
||||
/*! \brief Handles clicks and triggers scrolling and the selection of cards
|
||||
*
|
||||
* This method deactivates the button mode and searches for the nearest
|
||||
* card to the given position. If this card is in column 0 or 1 it scrolls
|
||||
* left. If it is in column (mCols-1) or (mCols-2) it scrolls to the right.
|
||||
* In any other case, it selects the card.
|
||||
*
|
||||
* \param x the clicks x coordinate
|
||||
* \param y the clicks y coordinate
|
||||
*
|
||||
* \return selected card c if c was already selected and no animation is running, NULL otherwise
|
||||
*/
|
||||
MTGCard * Click(int x, int y);
|
||||
|
||||
void changePosition(int offset);
|
||||
void changeFilter(int offset);
|
||||
/*! \brief Handles pointerless clicks (JGE_BTN_OK)
|
||||
*
|
||||
* If no card is selected, this method activates button mode and selects a card.
|
||||
*
|
||||
* \returns selected card, NULL otherwise
|
||||
*/
|
||||
MTGCard * Click();
|
||||
|
||||
/*! \brief Scrolls the view horizontally
|
||||
*
|
||||
* \param offset the number of columns to scroll
|
||||
*/
|
||||
void changePositionAnimated(int offset);
|
||||
|
||||
/*! \brief Rotates the selected filter and slides vertically
|
||||
*
|
||||
* \param the number of filters to rotate
|
||||
*/
|
||||
void changeFilterAnimated(int offset);
|
||||
|
||||
/*! \brief Returns the currently selected card
|
||||
*
|
||||
* \returns card c if c is selected and in column 4 to 6 and NULL otherwise*/
|
||||
MTGCard *getActiveCard();
|
||||
private:
|
||||
int mCols;
|
||||
int mRows;
|
||||
float mScrollOffset, mSlideOffset;
|
||||
/*! \brief The amount of columns (visible and hidden)
|
||||
*/
|
||||
const int mCols;
|
||||
|
||||
/*! \brief The amount of rows
|
||||
*/
|
||||
const int mRows;
|
||||
|
||||
/*! \brief The current scrolling offset
|
||||
*/
|
||||
float mScrollOffset;
|
||||
|
||||
/*! \brief The current sliding offset
|
||||
*/
|
||||
float mSlideOffset;
|
||||
|
||||
/*! \brief The easing functor that gets applied while scrolling
|
||||
*/
|
||||
InOutQuadEasing mScrollEasing;
|
||||
|
||||
/*! \brief The easing functor that gets applied while sliding
|
||||
*/
|
||||
InOutQuadEasing mSlideEasing;
|
||||
|
||||
/*! \brief The current selected card index
|
||||
*/
|
||||
int mCurrentSelection;
|
||||
|
||||
/*! \brief Stores if we are in button mode.
|
||||
*/
|
||||
bool mButtonMode;
|
||||
|
||||
/*! \brief Moves the card selection by an offset.
|
||||
*
|
||||
* \param offset the offset to move the selection
|
||||
* \param alignIfOutOfBounds the view will scroll if the selection moves out of bound if set to true
|
||||
*/
|
||||
void moveSelection(int offset, bool alignIfOutOfBounds);
|
||||
};
|
||||
|
||||
#endif //_GRID_DECK_VIEW_H
|
||||
|
||||
@@ -4,15 +4,25 @@
|
||||
#include "GuiLayers.h"
|
||||
#include "PhaseRing.h"
|
||||
#include "WEvent.h"
|
||||
#include "PlayGuiObject.h"
|
||||
|
||||
#include "Easing.h"
|
||||
|
||||
class GuiPhaseBar: public GuiLayer, public PlayGuiObject
|
||||
{
|
||||
protected:
|
||||
Phase* phase;
|
||||
private:
|
||||
static const float zoom_big;
|
||||
static const float zoom_small;
|
||||
static const float step;
|
||||
|
||||
int displayedPhaseId;
|
||||
float angle;
|
||||
float zoomFactor;
|
||||
DuelLayers* mpDuelLayers;
|
||||
OutQuadEasing angleEasing;
|
||||
InOutQuadEasing zoomFactorEasing;
|
||||
DuelLayers* mpDuelLayers;
|
||||
|
||||
void DrawGlyph(JQuad *inQuad, int phaseId, float x, float y, float scale);
|
||||
public:
|
||||
GuiPhaseBar(DuelLayers* duelLayers);
|
||||
~GuiPhaseBar();
|
||||
|
||||
@@ -47,7 +47,6 @@ protected:
|
||||
{
|
||||
static const float HEIGHT;
|
||||
unsigned attackers;
|
||||
unsigned blockers;
|
||||
unsigned currentAttacker;
|
||||
float height;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ class SimplePopup: public JGuiController
|
||||
private:
|
||||
float mWidth, mX, mY;
|
||||
int mMaxLines;
|
||||
int mFontId;
|
||||
DeckMetaData * mDeckInformation;
|
||||
string mTitle;
|
||||
WFont *mTextFont;
|
||||
|
||||
@@ -2,8 +2,15 @@
|
||||
#define TASK_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "Easing.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class GameObserver;
|
||||
class JQuad;
|
||||
class JTexture;
|
||||
|
||||
// Task type constant
|
||||
|
||||
@@ -72,8 +79,11 @@ class TaskList
|
||||
{
|
||||
protected:
|
||||
string fileName;
|
||||
|
||||
float vPos;
|
||||
float mElapsed;
|
||||
OutQuadEasing vPosInEasing;
|
||||
InQuadEasing vPosOutEasing;
|
||||
|
||||
int mState;
|
||||
JQuad * mBg[9];
|
||||
JTexture * mBgTex;
|
||||
@@ -97,7 +107,6 @@ public:
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
;
|
||||
void addTask(string params, bool rand = false);
|
||||
void addTask(Task *task);
|
||||
void addRandomTask(int diff = 100);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef WRESOURCE_FWD_H
|
||||
#define WRESOURCE_FWD_H
|
||||
|
||||
#ifndef WP8
|
||||
#include <boost/shared_ptr.hpp>
|
||||
typedef boost::shared_ptr<JQuad> JQuadPtr;
|
||||
#else
|
||||
#if (__cplusplus > 199711L)
|
||||
#include <memory>
|
||||
typedef std::shared_ptr<JQuad> JQuadPtr;
|
||||
#else
|
||||
#include <boost/shared_ptr.hpp>
|
||||
typedef boost::shared_ptr<JQuad> JQuadPtr;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _DEBUG_H_
|
||||
#define _DEBUG_H_
|
||||
|
||||
#if ((defined WIN32) || (defined WP8))
|
||||
#if ((defined WIN32) || (defined WP8)) && !defined(__MINGW32__)
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ bool AIHints::canWeCombo(GameObserver* observer,MTGCardInstance * card,AIPlayerB
|
||||
int comboPartsRestriction = 0;
|
||||
|
||||
if(gotCombo)
|
||||
return gotCombo;//because more then one might be possible at any time.
|
||||
return gotCombo;//because more than one might be possible at any time.
|
||||
if (hints[i]->hold.size())
|
||||
{
|
||||
for(unsigned int hPart = 0; hPart < hints[i]->hold.size(); hPart++)
|
||||
|
||||
@@ -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 then 10 cards in hand, eff is 0;
|
||||
//if the amount im drawing will mill me to death or i have more than 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 then 1 converted while using the old pMana method.
|
||||
{//ai can't use cards which produce more than 1 converted while using the old pMana method.
|
||||
result->add(amp->output);
|
||||
used[card] = true;
|
||||
}
|
||||
|
||||
@@ -1994,28 +1994,23 @@ 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)
|
||||
|
||||
@@ -4,6 +4,7 @@ const float CarouselDeckView::max_scale = 0.96f;
|
||||
const float CarouselDeckView::x_center = 180;
|
||||
const float CarouselDeckView::right_border = SCREEN_WIDTH + 180;
|
||||
const float CarouselDeckView::slide_animation_duration = 0.6f;
|
||||
const float CarouselDeckView::scroll_animation_duration = 0.3f;
|
||||
|
||||
CarouselDeckView::CarouselDeckView() :
|
||||
DeckView(10), mScrollOffset(0), mSlideOffset(0), mScrollEasing(mScrollOffset), mSlideEasing(mSlideOffset)
|
||||
@@ -21,12 +22,12 @@ void CarouselDeckView::UpdateViewState(float dt)
|
||||
|
||||
if(mScrollOffset <= -1.0f)
|
||||
{
|
||||
SwitchPosition(-1);
|
||||
changePosition(-1);
|
||||
mScrollEasing.translate(1.0f);
|
||||
}
|
||||
else if(mScrollOffset >= 1.0f)
|
||||
{
|
||||
SwitchPosition(1);
|
||||
changePosition(1);
|
||||
mScrollEasing.translate(-1.0f);
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ void CarouselDeckView::UpdateViewState(float dt)
|
||||
if(mSlideOffset < -1.0f)
|
||||
{
|
||||
mSlideEasing.translate(2.0f);
|
||||
SwitchFilter(1);
|
||||
changeFilter(1);
|
||||
}
|
||||
}
|
||||
else if(mSlideOffset > mSlideEasing.start_value)
|
||||
@@ -52,7 +53,7 @@ void CarouselDeckView::UpdateViewState(float dt)
|
||||
if(mSlideOffset > 1.0f)
|
||||
{
|
||||
mSlideEasing.translate(-2.0f);
|
||||
SwitchFilter(-1);
|
||||
changeFilter(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +61,10 @@ void CarouselDeckView::UpdateViewState(float dt)
|
||||
}
|
||||
}
|
||||
|
||||
void CarouselDeckView::UpdateCardPosition(CardRep &rep, int index)
|
||||
void CarouselDeckView::UpdateCardPosition(int index)
|
||||
{
|
||||
CardRep &rep = mCards[index];
|
||||
|
||||
float rotation = mScrollOffset + 8 - index;
|
||||
|
||||
rep.x = x_center + cos((rotation) * M_PI / 12) * (right_border - x_center);
|
||||
@@ -84,13 +87,13 @@ void CarouselDeckView::Render()
|
||||
// in a different order, ie the center card should appear first, then the adjacent ones
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(0).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(3).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(4).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(2).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(5).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(1).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(6).card);
|
||||
WResourceManager::Instance()->RetrieveCard(mCards[0].card);
|
||||
WResourceManager::Instance()->RetrieveCard(mCards[3].card);
|
||||
WResourceManager::Instance()->RetrieveCard(mCards[4].card);
|
||||
WResourceManager::Instance()->RetrieveCard(mCards[2].card);
|
||||
WResourceManager::Instance()->RetrieveCard(mCards[5].card);
|
||||
WResourceManager::Instance()->RetrieveCard(mCards[1].card);
|
||||
WResourceManager::Instance()->RetrieveCard(mCards[6].card);
|
||||
}
|
||||
|
||||
renderCard(6);
|
||||
@@ -118,6 +121,31 @@ void CarouselDeckView::Render()
|
||||
}
|
||||
}
|
||||
|
||||
bool CarouselDeckView::ButtonPressed(Buttons button)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
case JGE_BTN_LEFT:
|
||||
changePositionAnimated(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_RIGHT:
|
||||
changePositionAnimated(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_UP:
|
||||
changeFilterAnimated(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_DOWN:
|
||||
changeFilterAnimated(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
MTGCard * CarouselDeckView::Click(int x, int y)
|
||||
{
|
||||
int n = getCardIndexNextTo(x, y);
|
||||
@@ -132,35 +160,41 @@ MTGCard * CarouselDeckView::Click(int x, int y)
|
||||
}
|
||||
else
|
||||
{
|
||||
changePosition(n - 2);
|
||||
changePositionAnimated(n - 2);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CarouselDeckView::changePosition(int offset)
|
||||
MTGCard *CarouselDeckView::Click()
|
||||
{
|
||||
mScrollEasing.start((float)offset, (float)(0.3f*abs(offset)));
|
||||
if(mSlideEasing.finished() && mScrollEasing.finished())
|
||||
{
|
||||
return getActiveCard();
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CarouselDeckView::changePositionAnimated(int offset)
|
||||
{
|
||||
if(mScrollEasing.finished())
|
||||
mScrollEasing.start((float)offset, (float)(scroll_animation_duration * abs(offset)));
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
void CarouselDeckView::changeFilter(int offset)
|
||||
void CarouselDeckView::changeFilterAnimated(int offset)
|
||||
{
|
||||
if(offset < 0)
|
||||
{
|
||||
mSlideEasing.start(-2.0f, slide_animation_duration);
|
||||
}
|
||||
else if(offset > 0)
|
||||
{
|
||||
mSlideEasing.start(2.0f, slide_animation_duration);
|
||||
}
|
||||
if(mSlideEasing.finished())
|
||||
mSlideEasing.start(2.0f * float(offset), float(slide_animation_duration * abs(offset)));
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
MTGCard *CarouselDeckView::getActiveCard()
|
||||
{
|
||||
return getCardRep(2).card;
|
||||
return mCards[2].card;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 then 80 percentage of games"));
|
||||
CreditBonus * b = NEW CreditBonus(250, _("Won more than 80 percentage of games"));
|
||||
bonus.push_back(b);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,38 +35,12 @@ void DeckView::Update(float dt)
|
||||
{
|
||||
for(unsigned int i = 0; i < mCards.size(); ++i)
|
||||
{
|
||||
UpdateCardPosition(mCards[i], i);
|
||||
UpdateCardPosition(i);
|
||||
}
|
||||
dirtyCardPos = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DeckView::ButtonPressed(Buttons button)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
case JGE_BTN_LEFT:
|
||||
changePosition(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_RIGHT:
|
||||
changePosition(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_UP:
|
||||
changeFilter(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_DOWN:
|
||||
changeFilter(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeckView::SetDeck(DeckDataWrapper *toShow)
|
||||
{
|
||||
mCurrentDeck = toShow;
|
||||
@@ -80,14 +54,14 @@ DeckDataWrapper* DeckView::deck()
|
||||
return mCurrentDeck;
|
||||
}
|
||||
|
||||
void DeckView::SwitchFilter(int delta)
|
||||
void DeckView::changeFilter(int delta)
|
||||
{
|
||||
unsigned int FilterCount = Constants::NB_Colors + 1;
|
||||
mFilter = (FilterCount + mFilter + delta) % FilterCount;
|
||||
dirtyFilters = true;
|
||||
}
|
||||
|
||||
void DeckView::SwitchPosition(int delta)
|
||||
void DeckView::changePosition(int delta)
|
||||
{
|
||||
for(int i = 0; i < delta; ++i)
|
||||
{
|
||||
@@ -118,16 +92,11 @@ void DeckView::reloadIndexes()
|
||||
}
|
||||
}
|
||||
|
||||
DeckView::CardRep& DeckView::getCardRep(unsigned int index)
|
||||
{
|
||||
return mCards[index];
|
||||
}
|
||||
|
||||
void DeckView::renderCard(int index, int alpha, bool asThumbnail)
|
||||
{
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||
|
||||
const CardRep& cardPosition = getCardRep(index);
|
||||
const CardRep& cardPosition = mCards[index];
|
||||
|
||||
if (!cardPosition.card) return;
|
||||
|
||||
@@ -213,7 +182,7 @@ int DeckView::getCardIndexNextTo(int x, int y)
|
||||
|
||||
for(unsigned int i = 0; i < mCards.size(); i++)
|
||||
{
|
||||
const CardRep& cardPosition = getCardRep(i);
|
||||
const CardRep& cardPosition = mCards[i];
|
||||
|
||||
float dx = (x - cardPosition.x);
|
||||
float dy = (y - cardPosition.y);
|
||||
|
||||
@@ -407,9 +407,8 @@ void GameStateDeckViewer::Update(float dt)
|
||||
case JGE_BTN_RIGHT:
|
||||
case JGE_BTN_UP:
|
||||
case JGE_BTN_DOWN:
|
||||
if(last_user_activity > 0.2)
|
||||
if(mView->ButtonPressed(button))
|
||||
{
|
||||
mView->ButtonPressed(button);
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_WAITING;
|
||||
}
|
||||
@@ -443,19 +442,21 @@ void GameStateDeckViewer::Update(float dt)
|
||||
int x, y;
|
||||
if (mEngine->GetLeftClickCoordinates(x, y))
|
||||
{
|
||||
last_user_activity = 0;
|
||||
mEngine->LeftClickedProcessed();
|
||||
if(mView->Click(x, y) == mView->getActiveCard())
|
||||
if(mView->Click(x, y) != NULL)
|
||||
{
|
||||
addRemove(mView->getActiveCard());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
last_user_activity = 0;
|
||||
addRemove(mView->getActiveCard());
|
||||
if(mView->Click() != NULL)
|
||||
{
|
||||
addRemove(mView->getActiveCard());
|
||||
}
|
||||
}
|
||||
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_WAITING;
|
||||
break;
|
||||
}
|
||||
@@ -468,17 +469,20 @@ void GameStateDeckViewer::Update(float dt)
|
||||
buildEditorMenu();
|
||||
break;
|
||||
case JGE_BTN_CTRL:
|
||||
mStage = STAGE_FILTERS;
|
||||
if (!filterMenu)
|
||||
if(!mView->ButtonPressed(JGE_BTN_CTRL))
|
||||
{
|
||||
filterMenu = NEW WGuiFilters("Filter by...", NULL);
|
||||
if (source)
|
||||
SAFE_DELETE(source);
|
||||
source = NEW WSrcDeckViewer(myDeck, myCollection);
|
||||
filterMenu->setSrc(source);
|
||||
if (mView->deck() != myDeck) source->swapSrc();
|
||||
mStage = STAGE_FILTERS;
|
||||
if (!filterMenu)
|
||||
{
|
||||
filterMenu = NEW WGuiFilters("Filter by...", NULL);
|
||||
if (source)
|
||||
SAFE_DELETE(source);
|
||||
source = NEW WSrcDeckViewer(myDeck, myCollection);
|
||||
filterMenu->setSrc(source);
|
||||
if (mView->deck() != myDeck) source->swapSrc();
|
||||
}
|
||||
filterMenu->Entering(JGE_BTN_NONE);
|
||||
}
|
||||
filterMenu->Entering(JGE_BTN_NONE);
|
||||
break;
|
||||
case JGE_BTN_PREV:
|
||||
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY)
|
||||
@@ -1527,11 +1531,18 @@ void GameStateDeckViewer::OnScroll(int inXVelocity, int inYVelocity)
|
||||
{
|
||||
//FIXME: this 500 is a bit arbitrary
|
||||
int numCards = (magnitude / 500) % 8;
|
||||
mView->changePosition(flickRight ? numCards : - numCards);
|
||||
mView->changePositionAnimated(flickRight ? numCards : - numCards);
|
||||
}
|
||||
}
|
||||
else
|
||||
mView->changeFilter(flickUp ? 1 : -1);
|
||||
{
|
||||
if(abs(inYVelocity) > 300)
|
||||
{
|
||||
//FIXME: this 500 is a bit arbitrary
|
||||
int numFilters = (magnitude / 500);
|
||||
mView->changeFilterAnimated(flickUp ? numFilters : - numFilters);
|
||||
}
|
||||
}
|
||||
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
@@ -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 then 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 than 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;
|
||||
int deckNumber=0;
|
||||
unsigned int random=0;
|
||||
int k=0;
|
||||
bool isDouble=true;
|
||||
|
||||
@@ -300,12 +300,12 @@ string GameStateMenu::loadRandomWallpaper()
|
||||
return wallpaper;
|
||||
|
||||
vector<string> wallpapers;
|
||||
izfstream file;
|
||||
if (! JFileSystem::GetInstance()->openForRead(file, "graphics/wallpapers.txt"))
|
||||
JFile* jFile = JFileSystem::GetInstance()->OpenFile("graphics/wallpapers.txt");
|
||||
if (!jFile)
|
||||
return wallpaper;
|
||||
|
||||
string s;
|
||||
while (std::getline(file, s))
|
||||
while (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
|
||||
{
|
||||
if (!s.size())
|
||||
continue;
|
||||
@@ -313,7 +313,7 @@ string GameStateMenu::loadRandomWallpaper()
|
||||
s.erase(s.size() - 1); //Handle DOS files
|
||||
wallpapers.push_back(s);
|
||||
}
|
||||
file.close();
|
||||
JFileSystem::GetInstance()->CloseFile(jFile);
|
||||
|
||||
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]);
|
||||
if (! JFileSystem::GetInstance()->openForRead(file, filePath))
|
||||
JFile* jFile = JFileSystem::GetInstance()->OpenFile(filePath);
|
||||
if (!jFile)
|
||||
continue;
|
||||
|
||||
string s;
|
||||
string lang;
|
||||
|
||||
if (std::getline(file, s))
|
||||
if (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
|
||||
{
|
||||
lang = getLang(s);
|
||||
}
|
||||
|
||||
file.close();
|
||||
JFileSystem::GetInstance()->CloseFile(jFile);
|
||||
|
||||
if (lang.size())
|
||||
{
|
||||
|
||||
@@ -102,7 +102,6 @@ void GameStateShop::Start()
|
||||
bListCards = false;
|
||||
mTouched = false;
|
||||
mStage = STAGE_FADE_IN;
|
||||
mElapsed = 0;
|
||||
needLoad = true;
|
||||
booster = NULL;
|
||||
srcCards = NEW WSrcUnlockedCards(0);
|
||||
@@ -427,7 +426,7 @@ void GameStateShop::End()
|
||||
{
|
||||
save();
|
||||
JRenderer::GetInstance()->EnableVSync(false);
|
||||
mElapsed = 0;
|
||||
|
||||
SAFE_DELETE(shopMenu);
|
||||
SAFE_DELETE(bigDisplay);
|
||||
SAFE_DELETE(srcCards);
|
||||
@@ -469,9 +468,6 @@ void GameStateShop::Update(float dt)
|
||||
if (lightAlpha > 50)
|
||||
lightAlpha = 50;
|
||||
|
||||
if (mStage != STAGE_FADE_IN)
|
||||
mElapsed += dt;
|
||||
|
||||
JButton btn;
|
||||
switch (mStage)
|
||||
{
|
||||
@@ -496,7 +492,7 @@ void GameStateShop::Update(float dt)
|
||||
}
|
||||
break;
|
||||
case STAGE_SHOP_TASKS:
|
||||
if (menu)
|
||||
if (menu && !menu->isClosed())
|
||||
{
|
||||
menu->Update(dt);
|
||||
return;
|
||||
|
||||
@@ -7,7 +7,8 @@ const float GridDeckView::card_scale_big = 0.7f;
|
||||
|
||||
GridDeckView::GridDeckView()
|
||||
: DeckView(16), mCols(8), mRows(2), mScrollOffset(0), mSlideOffset(0),
|
||||
mScrollEasing(mScrollOffset), mSlideEasing(mSlideOffset), mCurrentSelection(-1)
|
||||
mScrollEasing(mScrollOffset), mSlideEasing(mSlideOffset), mCurrentSelection(-1),
|
||||
mButtonMode(false)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -23,6 +24,7 @@ void GridDeckView::Reset()
|
||||
mScrollEasing.finish();
|
||||
|
||||
mCurrentSelection = 0;
|
||||
mButtonMode = false;
|
||||
|
||||
DeckView::Reset();
|
||||
}
|
||||
@@ -35,15 +37,15 @@ void GridDeckView::UpdateViewState(float dt)
|
||||
|
||||
if(mScrollOffset <= -1.0f)
|
||||
{
|
||||
SwitchPosition(2);
|
||||
changePosition(2);
|
||||
moveSelection(-2, false);
|
||||
mScrollEasing.translate(1.0f);
|
||||
mCurrentSelection = (mCurrentSelection >= 6) ? mCurrentSelection - 2 : -1;
|
||||
}
|
||||
else if(mScrollOffset >= 1.0f)
|
||||
{
|
||||
SwitchPosition(-2);
|
||||
changePosition(-2);
|
||||
moveSelection(2, false);
|
||||
mScrollEasing.translate(-1.0f);
|
||||
mCurrentSelection = (mCurrentSelection >= 0 && mCurrentSelection < 10) ? mCurrentSelection + 2 : -1;
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
@@ -56,20 +58,22 @@ void GridDeckView::UpdateViewState(float dt)
|
||||
if(mSlideOffset < -1.0f)
|
||||
{
|
||||
mSlideEasing.translate(2.0f);
|
||||
SwitchFilter(1);
|
||||
changeFilter(1);
|
||||
}
|
||||
else if(mSlideOffset > 1.0f)
|
||||
{
|
||||
mSlideEasing.translate(-2.0f);
|
||||
SwitchFilter(-1);
|
||||
changeFilter(-1);
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GridDeckView::UpdateCardPosition(CardRep &rep, int index)
|
||||
void GridDeckView::UpdateCardPosition(int index)
|
||||
{
|
||||
CardRep &rep = mCards[index];
|
||||
|
||||
int col = index / mRows;
|
||||
int row = index % mRows;
|
||||
float colWidth = SCREEN_WIDTH_F / (mCols - 3);
|
||||
@@ -119,7 +123,7 @@ void GridDeckView::Render()
|
||||
{
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(i).card, RETRIEVE_THUMB);
|
||||
WResourceManager::Instance()->RetrieveCard(mCards[i].card, RETRIEVE_THUMB);
|
||||
}
|
||||
renderCard(i, 255, true);
|
||||
}
|
||||
@@ -127,7 +131,7 @@ void GridDeckView::Render()
|
||||
{
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(i).card);
|
||||
WResourceManager::Instance()->RetrieveCard(mCards[i].card);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,10 +142,50 @@ void GridDeckView::Render()
|
||||
}
|
||||
}
|
||||
|
||||
bool GridDeckView::ButtonPressed(Buttons button)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
case JGE_BTN_LEFT:
|
||||
if(mButtonMode && mScrollEasing.finished()) moveSelection(-2, true);
|
||||
else if(!mButtonMode) changePositionAnimated(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_RIGHT:
|
||||
if(mButtonMode && mScrollEasing.finished()) moveSelection(2, true);
|
||||
else if(!mButtonMode) changePositionAnimated(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_UP:
|
||||
if(mButtonMode && mScrollEasing.finished()) moveSelection(-1, true);
|
||||
else if(!mButtonMode) changeFilterAnimated(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_DOWN:
|
||||
if(mButtonMode && mScrollEasing.finished()) moveSelection(1, true);
|
||||
else if(!mButtonMode) changeFilterAnimated(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_CTRL:
|
||||
if(mButtonMode)
|
||||
{
|
||||
mButtonMode = false;
|
||||
dirtyCardPos = true;
|
||||
mCurrentSelection = -1;
|
||||
}
|
||||
else return false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
MTGCard * GridDeckView::Click(int x, int y)
|
||||
{
|
||||
int n = getCardIndexNextTo(x, y);
|
||||
last_user_activity = 0;
|
||||
mButtonMode = false;
|
||||
|
||||
if(mScrollEasing.finished() && mSlideEasing.finished())
|
||||
{ //clicked and no animations running
|
||||
@@ -151,11 +195,11 @@ MTGCard * GridDeckView::Click(int x, int y)
|
||||
}
|
||||
else if(n < 4)
|
||||
{
|
||||
changePosition(-1);
|
||||
changePositionAnimated(-1);
|
||||
}
|
||||
else if(n >= 12)
|
||||
{
|
||||
changePosition(1);
|
||||
changePositionAnimated(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -167,28 +211,43 @@ MTGCard * GridDeckView::Click(int x, int y)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void GridDeckView::changePosition(int offset)
|
||||
MTGCard * GridDeckView::Click()
|
||||
{
|
||||
mScrollEasing.start(-1.0f * offset, scroll_animation_duration * abs(offset));
|
||||
if(mScrollEasing.finished() && mSlideEasing.finished())
|
||||
{
|
||||
MTGCard *active = getActiveCard();
|
||||
if(active != NULL)
|
||||
{
|
||||
return active;
|
||||
}
|
||||
else
|
||||
{
|
||||
mButtonMode = true;
|
||||
dirtyCardPos = true;
|
||||
mCurrentSelection = 4;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void GridDeckView::changePositionAnimated(int offset)
|
||||
{
|
||||
if(mScrollEasing.finished())
|
||||
mScrollEasing.start(-1.0f * offset, scroll_animation_duration * abs(offset));
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
void GridDeckView::changeFilter(int offset)
|
||||
void GridDeckView::changeFilterAnimated(int offset)
|
||||
{
|
||||
if(offset < 0)
|
||||
{
|
||||
mSlideEasing.start(-2.0f, slide_animation_duration);
|
||||
}
|
||||
else if(offset > 0)
|
||||
{
|
||||
mSlideEasing.start(2.0f, slide_animation_duration);
|
||||
}
|
||||
if(mSlideEasing.finished())
|
||||
mSlideEasing.start(2.0f * offset, float(slide_animation_duration * abs(offset)));
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
MTGCard* GridDeckView::getActiveCard()
|
||||
{
|
||||
if(mCurrentSelection >= 0 && mCurrentSelection < int(mCards.size()))
|
||||
if(mCurrentSelection >= 4 && mCurrentSelection < int(mCards.size())-4)
|
||||
{
|
||||
return mCards[mCurrentSelection].card;
|
||||
}
|
||||
@@ -197,3 +256,29 @@ MTGCard* GridDeckView::getActiveCard()
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void GridDeckView::moveSelection(int offset, bool alignIfOutOfBounds)
|
||||
{
|
||||
mCurrentSelection += offset;
|
||||
|
||||
if(alignIfOutOfBounds)
|
||||
{
|
||||
if(mCurrentSelection < 4)
|
||||
{
|
||||
changePositionAnimated(-1);
|
||||
}
|
||||
else if(mCurrentSelection >= 12)
|
||||
{
|
||||
changePositionAnimated(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mCurrentSelection < 4 || mCurrentSelection >= 12)
|
||||
{
|
||||
mCurrentSelection = -1;
|
||||
}
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
|
||||
@@ -24,26 +24,28 @@
|
||||
};
|
||||
*/
|
||||
|
||||
const float GuiPhaseBar::zoom_big = (float)(1.5 * 1.4);
|
||||
const float GuiPhaseBar::zoom_small = 1.5;
|
||||
const float GuiPhaseBar::step = M_PI/6.0f;
|
||||
|
||||
namespace
|
||||
{
|
||||
//width and height of the phase symbol textures
|
||||
const float kWidth = 28;
|
||||
const float kHeight = kWidth;
|
||||
const unsigned kPhases = 12;
|
||||
const unsigned kPhases = NB_MTG_PHASES - 2; //there are two phases we do not show
|
||||
}
|
||||
|
||||
const float ICONSCALE = 1.5;
|
||||
const float CENTER = SCREEN_HEIGHT_F / 2 + 10;
|
||||
|
||||
void DrawGlyph(JQuad* inQuad, int inGlyph, float inY, float, unsigned int inP, float inScale)
|
||||
{
|
||||
float xPos = static_cast<float> ((inP + inGlyph * (int) (kWidth + 1)) % (kPhases * (int) (kWidth + 1)));
|
||||
inQuad->SetTextureRect(xPos, 0, kWidth, kHeight);
|
||||
JRenderer::GetInstance()->RenderQuad(inQuad, 0, inY, 0.0, inScale, inScale);
|
||||
}
|
||||
void GuiPhaseBar::DrawGlyph(JQuad *inQuad, int phaseId, float x, float y, float scale)
|
||||
{
|
||||
inQuad->SetTextureRect(phaseId * (kWidth + 1), 0, kWidth, kHeight);
|
||||
JRenderer::GetInstance()->RenderQuad(inQuad, x, y - scale * kWidth/2, 0.0f, scale, scale);
|
||||
}
|
||||
|
||||
GuiPhaseBar::GuiPhaseBar(DuelLayers* duelLayers) :
|
||||
GuiLayer(duelLayers->getObserver()), PlayGuiObject(0, 0, 106, 0, false),
|
||||
phase(NULL), angle(0.0f), zoomFactor(ICONSCALE), mpDuelLayers(duelLayers)
|
||||
GuiLayer(duelLayers->getObserver()), PlayGuiObject(80, 0, 106, 0, false),
|
||||
displayedPhaseId(0), angle(0.0f), zoomFactor(zoom_small), angleEasing(angle),
|
||||
zoomFactorEasing(zoomFactor), mpDuelLayers(duelLayers)
|
||||
{
|
||||
if(duelLayers->getObserver()->getResourceManager())
|
||||
{
|
||||
@@ -57,10 +59,7 @@ GuiPhaseBar::GuiPhaseBar(DuelLayers* duelLayers) :
|
||||
GameApp::systemError = "Error loading phasebar texture : " __FILE__;
|
||||
}
|
||||
|
||||
|
||||
zoom = ICONSCALE;
|
||||
mpDuelLayers->getCardSelector()->Add(this);
|
||||
|
||||
}
|
||||
|
||||
GuiPhaseBar::~GuiPhaseBar()
|
||||
@@ -69,32 +68,27 @@ GuiPhaseBar::~GuiPhaseBar()
|
||||
|
||||
void GuiPhaseBar::Update(float dt)
|
||||
{
|
||||
if (angle > 3 * dt)
|
||||
angle -= 3 * dt;
|
||||
else
|
||||
angle = 0;
|
||||
angleEasing.update(dt);
|
||||
|
||||
if (dt > 0.05f) dt = 0.05f;
|
||||
if(zoomFactor + 0.05f < zoom)
|
||||
if(angle <= -step)
|
||||
{
|
||||
zoomFactor += dt;
|
||||
}
|
||||
else if (zoomFactor - 0.05f > zoom)
|
||||
{
|
||||
zoomFactor -= dt;
|
||||
displayedPhaseId = (displayedPhaseId + 1) % kPhases;
|
||||
angleEasing.translate(step);
|
||||
}
|
||||
|
||||
zoomFactorEasing.update(dt);
|
||||
}
|
||||
|
||||
void GuiPhaseBar::Entering()
|
||||
{
|
||||
mHasFocus = true;
|
||||
zoom = 1.4f*ICONSCALE;
|
||||
zoomFactorEasing.start(zoom_big, 0.3f);
|
||||
}
|
||||
|
||||
bool GuiPhaseBar::Leaving(JButton)
|
||||
{
|
||||
mHasFocus = false;
|
||||
zoom = ICONSCALE;
|
||||
zoomFactorEasing.start(zoom_small, 0.6f);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -102,41 +96,28 @@ void GuiPhaseBar::Render()
|
||||
{
|
||||
JQuadPtr quad = WResourceManager::Instance()->GetQuad("phasebar");
|
||||
//uncomment to draw a hideous line across hires screens.
|
||||
// JRenderer::GetInstance()->DrawLine(0, CENTER, SCREEN_WIDTH, CENTER, ARGB(255, 255, 255, 255));
|
||||
// JRenderer::GetInstance()->DrawLine(0, CENTER, SCREEN_WIDTH, CENTER, ARGB(255, 255, 255, 255));
|
||||
|
||||
unsigned int p = (phase->id + kPhases - 4) * (int) (kWidth + 1);
|
||||
float centerYPosition = CENTER + (kWidth / 2) * angle * zoomFactor / (M_PI / 6) - zoomFactor * kWidth / 4;
|
||||
float yPos = centerYPosition;
|
||||
float scale = 0;
|
||||
for (int glyph = 3; glyph < 6; ++glyph)
|
||||
{
|
||||
scale = zoomFactor * sinf(angle + glyph * M_PI / 6) / 2;
|
||||
DrawGlyph(quad.get(), glyph, yPos, angle, p, scale);
|
||||
yPos += kWidth * scale;
|
||||
}
|
||||
const float radius = 25 * zoomFactor;
|
||||
|
||||
yPos = centerYPosition;
|
||||
for (int glyph = 2; glyph > 0; --glyph)
|
||||
for(int i = 0; i < 6; ++i)
|
||||
{
|
||||
scale = zoomFactor * sinf(angle + glyph * M_PI / 6) / 2;
|
||||
yPos -= kWidth * scale;
|
||||
DrawGlyph(quad.get(), glyph, yPos, angle, p, scale);
|
||||
}
|
||||
//the position of the glyphe in the circle
|
||||
const float circPos = (i - 2) * step + angle;
|
||||
const float glyphY = this->y + this->mHeight / 2 + sin(circPos) * radius;
|
||||
|
||||
if (angle > 0)
|
||||
{
|
||||
scale = zoomFactor * sinf(angle) / 2;
|
||||
yPos -= kWidth * scale;
|
||||
float xPos = static_cast<float> (p % (kPhases * (int) (kWidth + 1)));
|
||||
quad->SetTextureRect(xPos, kHeight, kWidth, kHeight);
|
||||
JRenderer::GetInstance()->RenderQuad(quad.get(), 0, yPos, 0.0, scale, scale);
|
||||
//the scale is computed so that the glyphes touch each other
|
||||
//hint: sin(circPos + PI/2) = cos(circPos)
|
||||
const float glyphScale = float(zoomFactor * cosf(circPos) * 0.5f);
|
||||
|
||||
DrawGlyph(quad.get(), (displayedPhaseId - 2 + i + kPhases) % kPhases, 0, glyphY, glyphScale);
|
||||
}
|
||||
|
||||
//print phase name
|
||||
WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||
string currentP = _("your turn");
|
||||
string interrupt = "";
|
||||
if (observer->currentPlayer == mpDuelLayers->getRenderedPlayerOpponent())
|
||||
if (observer->currentPlayer == mpDuelLayers->getRenderedPlayerOpponent())
|
||||
{
|
||||
currentP = _("opponent's turn");
|
||||
}
|
||||
@@ -147,7 +128,7 @@ void GuiPhaseBar::Render()
|
||||
}
|
||||
if (observer->currentlyActing() != observer->currentPlayer)
|
||||
{
|
||||
if (observer->currentPlayer == mpDuelLayers->getRenderedPlayer())
|
||||
if (observer->currentPlayer == mpDuelLayers->getRenderedPlayer())
|
||||
{
|
||||
interrupt = _(" - ") + _("opponent plays");
|
||||
}
|
||||
@@ -159,7 +140,9 @@ void GuiPhaseBar::Render()
|
||||
|
||||
char buf[200];
|
||||
//running this string through translate returns gibberish even though we defined the variables in the lang.txt
|
||||
string phaseNameToTranslate = observer->phaseRing->phaseName(phase->id);
|
||||
//the conversion from phase bar phases to mtg phases is x%kPhases + 1
|
||||
//todo: just to this when the displayedPhaseId updates
|
||||
string phaseNameToTranslate = observer->phaseRing->phaseName(displayedPhaseId%kPhases + 1);
|
||||
phaseNameToTranslate = _(phaseNameToTranslate);
|
||||
sprintf(buf, _("(%s%s) %s").c_str(), currentP.c_str(), interrupt.c_str(),phaseNameToTranslate.c_str());
|
||||
font->DrawString(buf, SCREEN_WIDTH - 5, 2, JGETEXT_RIGHT);
|
||||
@@ -170,8 +153,20 @@ int GuiPhaseBar::receiveEventMinus(WEvent *e)
|
||||
WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*> (e);
|
||||
if (event)
|
||||
{
|
||||
angle = M_PI / 6;
|
||||
phase = event->to;
|
||||
//convert the mtg phase to the phases of the phase wheel
|
||||
//the mapping is
|
||||
//0 -> none
|
||||
//1..12 -> 0..11
|
||||
//13 -> none
|
||||
int targetPhase = event->to->id;
|
||||
|
||||
if(targetPhase != 0 && targetPhase != 13)
|
||||
{
|
||||
targetPhase -= 1;
|
||||
|
||||
int phasesToAnimate = (targetPhase - displayedPhaseId + kPhases) % kPhases;
|
||||
angleEasing.start(float(phasesToAnimate * (- step)), 0.3f * float(sqrt(float(phasesToAnimate))));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ inline float GuiPlay::VertStack::nextX()
|
||||
}
|
||||
|
||||
GuiPlay::BattleField::BattleField() :
|
||||
attackers(0), blockers(0), height(0.0), red(0), colorFlow(0)
|
||||
attackers(0), height(0.0), red(0), colorFlow(0)
|
||||
{
|
||||
}
|
||||
const float GuiPlay::BattleField::HEIGHT = 80.0f;
|
||||
|
||||
@@ -4276,8 +4276,6 @@ 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])
|
||||
{
|
||||
|
||||
@@ -399,8 +399,8 @@ int MTGAllCards::load(const string &config_file, int set_id)
|
||||
|
||||
int lineNumber = 0;
|
||||
std::string contents;
|
||||
izfstream file;
|
||||
if (!JFileSystem::GetInstance()->openForRead(file, config_file))
|
||||
JFile* jFile = JFileSystem::GetInstance()->OpenFile(config_file);
|
||||
if (!jFile)
|
||||
{
|
||||
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 (getline(file,s))
|
||||
while (JFileSystem::GetInstance()->ReadFileLine(jFile, 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)
|
||||
{
|
||||
file.close();
|
||||
JFileSystem::GetInstance()->CloseFile(jFile);
|
||||
return total_cards;
|
||||
}
|
||||
}
|
||||
@@ -480,7 +480,7 @@ int MTGAllCards::load(const string &config_file, int set_id)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
JFileSystem::GetInstance()->CloseFile(jFile);
|
||||
return total_cards;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 then one of the types, and for more then one to trigger.
|
||||
//more than one of the types, and for more than one to trigger.
|
||||
if(e->card->hasType(Subtypes::TYPE_ARTIFACT))
|
||||
toys[currentPlayer->getId()]++;
|
||||
if(e->card->isCreature())
|
||||
|
||||
@@ -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]);
|
||||
if (! JFileSystem::GetInstance()->openForRead(file, filePath))
|
||||
JFile* jFile = JFileSystem::GetInstance()->OpenFile(filePath);
|
||||
if (!jFile)
|
||||
continue;
|
||||
|
||||
string s;
|
||||
string lang;
|
||||
|
||||
if (std::getline(file, s))
|
||||
if (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
|
||||
{
|
||||
if (!s.size())
|
||||
{
|
||||
@@ -352,7 +352,7 @@ void OptionLanguage::Reload()
|
||||
lang = s.substr(6);
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
JFileSystem::GetInstance()->CloseFile(jFile);
|
||||
|
||||
if (lang.size())
|
||||
{
|
||||
|
||||
@@ -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), mFontId(fontId), mCollection(collection)
|
||||
JGuiController(JGE::GetInstance(), id, listener), mCollection(collection)
|
||||
{
|
||||
mX = 19;
|
||||
mY = 66;
|
||||
|
||||
@@ -599,16 +599,17 @@ bool StoryFlow::parse(string path)
|
||||
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem) return false;
|
||||
|
||||
if (!fileSystem->OpenFile(path.c_str())) return false;
|
||||
JFile* jFile = fileSystem->OpenFile(path.c_str());
|
||||
if (!jFile) return false;
|
||||
|
||||
int size = fileSystem->GetFileSize();
|
||||
int size = fileSystem->GetFileSize(jFile);
|
||||
char *xmlBuffer = NEW char[size];
|
||||
fileSystem->ReadFile(xmlBuffer, size);
|
||||
fileSystem->ReadFile(jFile, xmlBuffer, size);
|
||||
|
||||
TiXmlDocument doc;
|
||||
doc.Parse(xmlBuffer);
|
||||
|
||||
fileSystem->CloseFile();
|
||||
fileSystem->CloseFile(jFile);
|
||||
delete[] xmlBuffer;
|
||||
|
||||
for (TiXmlNode* node = doc.FirstChild(); node; node = node->NextSibling())
|
||||
|
||||
+18
-14
@@ -258,9 +258,10 @@ Task* Task::createFromStr(const string params, bool rand)
|
||||
|
||||
/*---------------- TaskList -----------------*/
|
||||
|
||||
TaskList::TaskList(string _fileName)
|
||||
TaskList::TaskList(string _fileName):
|
||||
fileName(_fileName), vPos(-SCREEN_HEIGHT), vPosInEasing(vPos), vPosOutEasing(vPos)
|
||||
{
|
||||
fileName = _fileName;
|
||||
|
||||
if (fileName == "")
|
||||
{
|
||||
fileName = options.profileFile(PLAYER_TASKS).c_str();
|
||||
@@ -378,9 +379,10 @@ void TaskList::removeTask(Task *task)
|
||||
|
||||
void TaskList::Start()
|
||||
{
|
||||
vPos = -SCREEN_HEIGHT; //Offscreen
|
||||
mElapsed = 0;
|
||||
mState = TASKS_IN;
|
||||
vPos = -SCREEN_HEIGHT; //Offscreen
|
||||
vPosInEasing.start(0.0f, 1.0f);
|
||||
|
||||
if (!mBgTex)
|
||||
{
|
||||
mBgTex = WResourceManager::Instance()->RetrieveTexture("taskboard.png", RETRIEVE_LOCK);
|
||||
@@ -410,7 +412,7 @@ void TaskList::Start()
|
||||
void TaskList::End()
|
||||
{
|
||||
mState = TASKS_OUT;
|
||||
mElapsed = 0;
|
||||
vPosOutEasing.start(float(-SCREEN_HEIGHT), 0.9f);
|
||||
}
|
||||
|
||||
void TaskList::passOneDay()
|
||||
@@ -451,21 +453,23 @@ int TaskList::getTaskCount()
|
||||
|
||||
void TaskList::Update(float dt)
|
||||
{
|
||||
mElapsed += dt;
|
||||
|
||||
if (mState == TASKS_IN && vPos < 0)
|
||||
if(!vPosInEasing.finished())
|
||||
{
|
||||
vPos = -SCREEN_HEIGHT + (SCREEN_HEIGHT * mElapsed / 0.75f); //Todo: more physical drop-in.
|
||||
if (vPos >= 0)
|
||||
vPosInEasing.update(dt);
|
||||
|
||||
if(vPosInEasing.finished())
|
||||
{
|
||||
vPos = 0;
|
||||
mState = TaskList::TASKS_ACTIVE;
|
||||
}
|
||||
}
|
||||
else if (mState == TASKS_OUT && vPos > -SCREEN_HEIGHT)
|
||||
else if(!vPosOutEasing.finished())
|
||||
{
|
||||
vPos = -(SCREEN_HEIGHT * mElapsed / 0.75f);
|
||||
if (vPos <= -SCREEN_HEIGHT) mState = TASKS_INACTIVE;
|
||||
vPosOutEasing.update(dt);
|
||||
|
||||
if(vPosOutEasing.finished())
|
||||
{
|
||||
mState = TASKS_INACTIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -333,8 +333,9 @@ bool WCachedParticles::Attempt(const string& filename, int, int & error)
|
||||
{
|
||||
|
||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||
JFile* jFile = fileSys->OpenFile(WResourceManager::Instance()->graphicsFile(filename));
|
||||
|
||||
if (!fileSys->OpenFile(WResourceManager::Instance()->graphicsFile(filename)))
|
||||
if (!jFile)
|
||||
{
|
||||
error = CACHE_ERROR_404;
|
||||
return false;
|
||||
@@ -345,12 +346,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(&dummyPointer, 4);
|
||||
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(&(particles->nEmission), sizeof(hgeParticleSystemInfo) - sizeof(void*));
|
||||
fileSys->CloseFile();
|
||||
fileSys->ReadFile(jFile, &(particles->nEmission), sizeof(hgeParticleSystemInfo) - sizeof(void*));
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
particles->sprite = NULL;
|
||||
error = CACHE_ERROR_NONE;
|
||||
|
||||
+21
-17
@@ -171,20 +171,22 @@ WFont(inFontID), mTexture(0)
|
||||
unsigned char height;
|
||||
} sizeStr = { 0, 0, 0 };
|
||||
|
||||
if (!fileSys->OpenFile(engFileName)) return;
|
||||
size = fileSys->GetFileSize();
|
||||
JFile* jFile = fileSys->OpenFile(engFileName);
|
||||
if (!jFile) return;
|
||||
size = fileSys->GetFileSize(jFile);
|
||||
mStdFont = NEW u8[size];
|
||||
fileSys->ReadFile(mStdFont, size);
|
||||
fileSys->CloseFile();
|
||||
fileSys->ReadFile(jFile, mStdFont, size);
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
if (!fileSys->OpenFile(fontname)) return;
|
||||
fileSys->ReadFile(&sizeStr, 4); // Works only for little-endian machines (PSP and PC are)
|
||||
jFile = fileSys->OpenFile(fontname);
|
||||
if (!jFile) return;
|
||||
fileSys->ReadFile(jFile, &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(mIndex, 65536 * sizeof(u16));
|
||||
fileSys->ReadFile(mExtraFont, size);
|
||||
fileSys->CloseFile();
|
||||
fileSys->ReadFile(jFile, mIndex, 65536 * sizeof(u16));
|
||||
fileSys->ReadFile(jFile, mExtraFont, size);
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
mColor0 = ARGB(255, 255, 255, 255);
|
||||
mColor = mColor0;
|
||||
@@ -612,17 +614,19 @@ WGBKFont::WGBKFont(int inFontID, const char *fontname, int lineheight, bool) :
|
||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||
int size = 0;
|
||||
|
||||
if (!fileSys->OpenFile(fontname)) return;
|
||||
size = fileSys->GetFileSize();
|
||||
JFile* jFile = fileSys->OpenFile(fontname);
|
||||
if (!jFile) return;
|
||||
size = fileSys->GetFileSize(jFile);
|
||||
mExtraFont = NEW u8[size];
|
||||
fileSys->ReadFile(mExtraFont, size);
|
||||
fileSys->CloseFile();
|
||||
fileSys->ReadFile(jFile, mExtraFont, size);
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
if (!fileSys->OpenFile(engFileName)) return;
|
||||
size = fileSys->GetFileSize();
|
||||
jFile = fileSys->OpenFile(engFileName);
|
||||
if (!jFile) return;
|
||||
size = fileSys->GetFileSize(jFile);
|
||||
mStdFont = NEW u8[size];
|
||||
fileSys->ReadFile(mStdFont, size);
|
||||
fileSys->CloseFile();
|
||||
fileSys->ReadFile(jFile, mStdFont, size);
|
||||
fileSys->CloseFile(jFile);
|
||||
|
||||
mIndex = 0;
|
||||
|
||||
|
||||
@@ -15,8 +15,9 @@ CONFIG(console, graphics|console){
|
||||
}
|
||||
else:CONFIG(graphics, graphics|console){
|
||||
folder_01.source = qml/QmlWagic
|
||||
folder_01.target = /usr/share
|
||||
folder_01.target = qml
|
||||
DEPLOYMENTFOLDERS = folder_01
|
||||
windows:RESOURCES = bin/Res/core.qrc
|
||||
QT += core gui opengl network
|
||||
QT -= declarative quick qml
|
||||
#maemo5:DEFINES += QT_WIDGET
|
||||
|
||||
+6
-112
@@ -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,6 +27,7 @@ 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
|
||||
@@ -370,110 +371,3 @@ 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\\\"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+56
-12
@@ -1,22 +1,45 @@
|
||||
#!/bin/sh -ex
|
||||
|
||||
# let's dump some info to debug a bit
|
||||
echo PSPDEV = $PSPDEV
|
||||
echo psp-config = `psp-config --psp-prefix`
|
||||
echo ls = `ls`
|
||||
echo pwd = `pwd`
|
||||
|
||||
# updating versions with the TRAVIS build numbers
|
||||
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 psprelease
|
||||
mv EBOOT.PBP psprelease/
|
||||
mv wagic.elf psprelease/
|
||||
mv wagic.prx psprelease/
|
||||
zip psprelease.zip -r psprelease/
|
||||
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/
|
||||
cd ../..
|
||||
|
||||
# we're building an Android binary here
|
||||
@@ -28,6 +51,8 @@ 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 ..
|
||||
@@ -36,11 +61,30 @@ cd ..
|
||||
qmake projects/mtg/wagic-qt.pro CONFIG+=console CONFIG+=debug DEFINES+=CAPTURE_STDERR
|
||||
make -j 8
|
||||
|
||||
# Now we run the testsuite
|
||||
./wagic
|
||||
# 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 ../..
|
||||
|
||||
# And we create resource package (not before testsuite, it mofifies resources)
|
||||
cd projects/mtg/bin/Res
|
||||
python createResourceZip.py
|
||||
mv core_*.zip core.zip
|
||||
cd ../../../..
|
||||
# Now we run the testsuite (Res needs to be in the working directory)
|
||||
cd projects/mtg
|
||||
../../wagic
|
||||
cd ../..
|
||||
|
||||
+71
-3
@@ -2,14 +2,14 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
if [ "$TRAVIS_BRANCH" == "alphas" ]; then
|
||||
echo -e "Creating a release\n"
|
||||
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
|
||||
-d '{"tag_name": "alpha-'${TRAVIS_BUILD_NUMBER}'", "target_commitish": "master", "name": "Alpha release number '${TRAVIS_BUILD_NUMBER}'", "body": "Automatic alpha release generated by Travis CI'", "draft": false, "prerelease": true}' "https://api.github.com/repos/WagicProject/wagic/releases" > json.txt
|
||||
export IDDI=`cat json.txt | jq '.id'`
|
||||
-d '{"tag_name": "alpha-'${TRAVIS_BUILD_NUMBER}'", "target_commitish": "master", "name": "Alpha release number '${TRAVIS_BUILD_NUMBER}'", "body": "Automatic alpha release 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"
|
||||
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
|
||||
-H "Accept: application/vnd.github.manifold-preview" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--data-binary @projects/mtg/bin/Res/core.zip \
|
||||
--data-binary @core.zip \
|
||||
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-core-${TRAVIS_BUILD_NUMBER}.zip"
|
||||
|
||||
echo -e "Uploading android package\n"
|
||||
@@ -26,6 +26,74 @@ 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
|
||||
|
||||
# get info about all releases
|
||||
echo -e "Getting info about previous releases"
|
||||
curl -X GET -H "Authorization: token ${GH_TOKEN}" \
|
||||
"https://api.github.com/repos/WagicProject/wagic/releases" > json.txt
|
||||
|
||||
# extract info only about only "latest-release" tag
|
||||
cat json.txt |jq 'map(select (.tag_name == "latest-master"))' > latest.txt
|
||||
|
||||
# get id of release
|
||||
ID_TO_DELETE=`cat latest.txt |jq '.[0].id'`
|
||||
|
||||
# delete previous release
|
||||
echo -e "Deleting release number ${ID_TO_DELETE}"
|
||||
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
|
||||
IDDI=`cat json.txt | jq '.id'`
|
||||
|
||||
echo -e "Uploading Core resources\n"
|
||||
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
|
||||
-H "Accept: application/vnd.github.manifold-preview" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--data-binary @core.zip \
|
||||
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-core-${TRAVIS_BUILD_NUMBER}.zip"
|
||||
|
||||
echo -e "Uploading android package\n"
|
||||
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
|
||||
-H "Accept: application/vnd.github.manifold-preview" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--data-binary @projects/mtg/Android/bin/Wagic-debug.apk \
|
||||
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-android-${TRAVIS_BUILD_NUMBER}.apk"
|
||||
|
||||
echo -e "Uploading PSP package\n"
|
||||
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
|
||||
-H "Accept: application/vnd.github.manifold-preview" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--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
|
||||
|
||||
Reference in New Issue
Block a user