Compare commits

..

1 Commits

Author SHA1 Message Date
Michael Nguyen 9cc2c6cc4d updated iOS UI issues:
* fixed status bar issue on iOS7, where status bar information was invisible on iOS7 devices
  * fixed some font issues on the Shop screens to make them more legible for iOS users. ( changed font size for Interactive Buttons and card list)
  * added new gesture for opening up the menu screen for iOS.  Since there are no external buttons on iOS devices, we need either on-screen buttons or gestures to compensate.  Using the pinch or zoom gesture will simulate pressing the "MENU" button on the PSP on all screens now.  Not ideal, but something for now until we can work in a new button or way to open up the menu.
2013-11-27 22:25:22 -08:00
146 changed files with 2357 additions and 5253 deletions
+13 -27
View File
@@ -1,31 +1,17 @@
language: cpp language: cpp
branches:
except:
- latest-master
before_install: before_install:
- export PSPDEV="$TRAVIS_BUILD_DIR/opt/pspsdk" - export PSPDEV="$TRAVIS_BUILD_DIR/opt/pspsdk"
- export PSPSDK="$PSPDEV/psp/sdk" - export PSPSDK="$PSPDEV/psp/sdk"
- export PATH="$PATH:$PSPDEV/bin:$PSPSDK/bin" - export PATH="$PATH:$PSPDEV/bin:$PSPSDK/bin"
- export ANDROID="android-sdk-linux/tools/android" - export ANDROID="android-sdk-linux/tools/android"
install: install:
- sudo add-apt-repository ppa:tobydox/mingw -y - sudo apt-get update -qq
- 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; 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 - 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
- sudo ln -s /opt/mingw32/bin/moc /opt/mingw32/bin/i686-w64-mingw32-moc - tar -x --xz -f sdk.lzma
- sudo ln -s /opt/mingw32/bin/rcc /opt/mingw32/bin/i686-w64-mingw32-rcc - wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv
- 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 - wget http://dl.google.com/android/android-sdk_r22-linux.tgz -nv
- tar -x --xz -f sdk.lzma - tar --absolute-names -jxf android-ndk-r9-linux-x86_64.tar.bz2
- wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv - tar -zxf android-sdk_r22-linux.tgz
- wget http://dl.google.com/android/android-sdk_r22-linux.tgz -nv - echo yes | $ANDROID update sdk --filter 1,2,3,8 --no-ui --force > log.txt
- tar --absolute-names -jxf android-ndk-r9-linux-x86_64.tar.bz2
- tar -zxf android-sdk_r22-linux.tgz
- $ANDROID list sdk -a
- echo yes | $ANDROID update sdk -a --filter 1,2,5,19 --no-ui --force > log.txt
- sudo pip install pyjavaproperties
script: ./travis-script.sh
env:
global:
secure: "fJgWlCFbde96OSQNGKUmowGX+ERPeqP+n1EOMf1+FJzOU4DdkTLRAlV5+5qnEX9jB/3mWN6iPpmG1qEz/SdDG3KHxJYs4ZU/Lu485O24zZ/+GdYBNsrvhPD9ckPGEMLDa1foEVTDnW0Dlkz3BCFcszjhtXGUJv7v6Pj6LRk1Mg8="
script: "./travis-script.sh" script: "./travis-script.sh"
after_success: ./upload-binaries.sh
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -73,7 +73,7 @@
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>TIXML_USE_STL; SDL_CONFIG;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>SDL_CONFIG;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -101,7 +101,7 @@
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>TIXML_USE_STL; SDL_CONFIG;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>SDL_CONFIG;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader> <PrecompiledHeader>
@@ -129,7 +129,7 @@
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>TIXML_USE_STL; SDL_CONFIG;WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_HAS_ITERATOR_DEBBUGING=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>SDL_CONFIG;WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_HAS_ITERATOR_DEBBUGING=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
-1
View File
@@ -31,7 +31,6 @@ HGE_OBJS = src/hge/hgecolor.o src/hge/hgeparticle.o \
CXXFLAGS = -W -Wall -Werror -Wno-unused CXXFLAGS = -W -Wall -Werror -Wno-unused
CXXFLAGS += -DTIXML_USE_STL
ifdef DEBUG ifdef DEBUG
CXXFLAGS += -ggdb3 CXXFLAGS += -ggdb3
+1 -1
View File
@@ -61,7 +61,7 @@ std::string ToHex(T* pointer)
{ \ { \
std::ostringstream stream; \ std::ostringstream stream; \
stream << inString << std::endl; \ stream << inString << std::endl; \
OutputDebugStringA(stream.str().c_str()); \ OutputDebugString(stream.str().c_str()); \
} }
#endif // QT_CONFIG #endif // QT_CONFIG
#endif // Win32, Linux #endif // Win32, Linux
+1
View File
@@ -297,6 +297,7 @@ public:
private: private:
float mTimer; float mTimer;
float mFrameTime; float mFrameTime;
JAnimator* mAnimator;
vector<JAnimatorObject *> mObjects; vector<JAnimatorObject *> mObjects;
}; };
+1
View File
@@ -37,6 +37,7 @@ private:
float mTexY; float mTexY;
float mTexWidth; float mTexWidth;
float mTexHeight; float mTexHeight;
JTexture* mTexture;
JQuad* mQuad; JQuad* mQuad;
+11 -37
View File
@@ -1,10 +1,6 @@
#ifndef _J_FILE_SYSTEM_H_ #ifndef _J_FILE_SYSTEM_H_
#define _J_FILE_SYSTEM_H_ #define _J_FILE_SYSTEM_H_
#ifdef QT_CONFIG
#include <QFile>
#endif
#include "zfsystem.h" #include "zfsystem.h"
#include <string> #include <string>
using zip_file_system::filesystem; using zip_file_system::filesystem;
@@ -22,38 +18,13 @@ using namespace std;
/// archive file. /// 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 { class JZipCache {
public: public:
JZipCache(); JZipCache();
~JZipCache(); ~JZipCache();
map<string, filesystem::limited_file_info> dir; map<string, filesystem::limited_file_info> dir;
}; };
class JFileSystem { class JFileSystem {
@@ -61,21 +32,23 @@ private:
string mSystemFSPath, mUserFSPath; string mSystemFSPath, mUserFSPath;
filesystem * mSystemFS, * mUserFS; filesystem * mSystemFS, * mUserFS;
static JFileSystem* mInstance; static JFileSystem* mInstance;
izfstream mFile;
map<string,JZipCache *>mZipCache; map<string,JZipCache *>mZipCache;
unsigned int mZipCachedElementsCount; unsigned int mZipCachedElementsCount;
string mZipFileName; string mZipFileName;
int mFileSize;
char *mPassword; char *mPassword;
bool mZipAvailable; bool mZipAvailable;
void preloadZip(const string& filename); void preloadZip(const string& filename);
izfstream mZipFile; izfstream mZipFile;
filesystem::limited_file_info * mCurrentFileInZip;
std::vector<std::string>& scanRealFolder(const std::string& folderName, std::vector<std::string>& results); 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: public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Attach ZIP archive to the file system. /// Attach ZIP archive to the file system.
/// ///
@@ -110,7 +83,7 @@ public:
/// Open file for reading. /// Open file for reading.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JFile* OpenFile(const string &filename); bool OpenFile(const string &filename);
//Fills the vector results with a list of children of the given folder //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); std::vector<std::string>& scanfolder(const std::string& folderName, std::vector<std::string>& results);
@@ -124,19 +97,20 @@ public:
/// @return Number of bytes read. /// @return Number of bytes read.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int ReadFile(JFile*, void *buffer, int size); int ReadFile(void *buffer, int size);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get size of file. /// Get size of file.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int GetFileSize(JFile*); int GetFileSize();
int GetFileSize(izfstream & file);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Close file. /// Close file.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void CloseFile(JFile*); void CloseFile();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set root for all the following file operations /// Set root for all the following file operations
@@ -150,8 +124,8 @@ public:
void SetUSerRoot(const string& resourceRoot); void SetUSerRoot(const string& resourceRoot);
string GetUserRoot() { return mUserFSPath; }; string GetUserRoot() { return mUserFSPath; };
bool openForRead(izfstream & File, const string & FilePath);
bool readIntoString(const string & FilePath, string & target); 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 openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode = ios_base::out );
bool Rename(string from, string to); bool Rename(string from, string to);
+1
View File
@@ -178,6 +178,7 @@ private:
float mSpacing; float mSpacing;
PIXEL_TYPE mColor; PIXEL_TYPE mColor;
int mBlend;
int mBase; int mBase;
+10 -84
View File
@@ -1,7 +1,7 @@
#ifndef THREADING_H #ifndef THREADING_H
#define THREADING_H #define THREADING_H
#if !defined(PSP) && !defined(QT_CONFIG) && !(__cplusplus > 199711L) #if !defined(PSP) && !defined(QT_CONFIG)
#include <boost/date_time.hpp> #include <boost/date_time.hpp>
#ifdef WIN32 #ifdef WIN32
@@ -14,7 +14,7 @@
#endif #endif
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
#elif defined(PSP) #elif !defined(QT_CONFIG)
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
@@ -212,13 +212,13 @@ namespace boost
** **
** The intent of its usage is this form only: ** The intent of its usage is this form only:
** mWorkerThread = boost::thread(ThreadProc, this); ** mWorkerThread = boost::thread(ThreadProc, this);
** where ThreadProc is a static member function of the 'this' class,eg: ** where ThreadProc is a static member function of the 'this' class,eg:
** static void FOO::ThreadProc(void* inParam) ** static void FOO::ThreadProc(void* inParam)
** { ** {
** FOO* instance = reinterpret_cast<FOO*>(inParam); ** FOO* instance = reinterpret_cast<FOO*>(inParam);
** // now you have class instance data available... ** // now you have class instance data available...
** } ** }
** **
** Any other variant of a thread proc with more than one param is unimplemented. ** Any other variant of a thread proc with more than one param is unimplemented.
*/ */
class thread class thread
@@ -307,7 +307,7 @@ namespace boost
} }
} }
#elif defined(QT_CONFIG) && (__cplusplus <= 199711L) #elif defined(QT_CONFIG)
#include <QMutex> #include <QMutex>
#include <QThread> #include <QThread>
@@ -537,80 +537,6 @@ namespace boost
} }
} }
#elif (__cplusplus > 199711L)
#include <thread>
#include <mutex>
namespace boost
{
typedef std::thread thread;
template <class Mutex>
struct unique_lock
{
unique_lock(Mutex& inMutex) : mMutex(&inMutex)
{
mMutex->lock();
}
~unique_lock()
{
mMutex->unlock();
}
Mutex* mMutex;
};
class mutex
{
public:
typedef unique_lock<mutex> scoped_lock;
mutex()
: mQMutex()
{
}
~mutex()
{
}
void lock()
{
mQMutex.lock();
}
void unlock()
{
mQMutex.unlock();
}
std::mutex mQMutex;
private:
mutex(mutex const&);
mutex& operator=(mutex const&);
};
namespace posix_time
{
typedef unsigned int milliseconds;
}
/**
** boost's platform neutral sleep call.
*/
namespace this_thread
{
inline void sleep(boost::posix_time::milliseconds const& time)
{
std::this_thread::sleep_for(std::chrono::milliseconds(time));
}
}
}
#endif #endif
#endif // THREADING_H #endif // THREADING_H
-15
View File
@@ -136,20 +136,6 @@ signals:
private slots: private slots:
private: 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 timerEvent( QTimerEvent* );
void doAndEnqueue(JButton action) { void doAndEnqueue(JButton action) {
m_engine->HoldKey_NoRepeat(action); m_engine->HoldKey_NoRepeat(action);
@@ -168,7 +154,6 @@ private:
int m_timerId; int m_timerId;
bool m_active; bool m_active;
QRect m_viewPort; QRect m_viewPort;
QPoint m_lastPos;
#ifdef QT_WIDGET #ifdef QT_WIDGET
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID) #if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID)
int mMouseDownX; int mMouseDownX;
+7 -8
View File
@@ -44,12 +44,11 @@ bool JAnimator::Load(const char* scriptFile)
JFileSystem *fileSystem = JFileSystem::GetInstance(); JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false; if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(scriptFile); if (!fileSystem->OpenFile(scriptFile)) return false;
if (!jFile) return false;
int size = fileSystem->GetFileSize(jFile); int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size]; char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size); fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc; TiXmlDocument doc;
doc.Parse(xmlBuffer); doc.Parse(xmlBuffer);
@@ -68,7 +67,7 @@ bool JAnimator::Load(const char* scriptFile)
element = script->ToElement(); element = script->ToElement();
printf("---- Loading %s:%s\n", element->Value(), element->Attribute("name")); printf("---- Loading %s:%s\n", element->Value(), element->Attribute("name"));
string type[] = const char *type[] =
{ {
"ANIMATION_TYPE_LOOPING", "ANIMATION_TYPE_LOOPING",
"ANIMATION_TYPE_ONCE_AND_STAY", "ANIMATION_TYPE_ONCE_AND_STAY",
@@ -79,7 +78,7 @@ bool JAnimator::Load(const char* scriptFile)
const char* aniType = element->Attribute("type"); const char* aniType = element->Attribute("type");
for (int i=0;i<5;i++) for (int i=0;i<5;i++)
if (type[i] == aniType) if (strcmp(type[i], aniType)==0)
{ {
SetAnimationType(i); SetAnimationType(i);
break; break;
@@ -109,7 +108,7 @@ bool JAnimator::Load(const char* scriptFile)
element = param->ToElement(); element = param->ToElement();
if (element != NULL) if (element != NULL)
{ {
if (element->ValueStr() == "settings") if (strcmp(element->Value(), "settings")==0)
{ {
const char* quadName = element->Attribute("quad"); const char* quadName = element->Attribute("quad");
JQuad* quad = mResource->GetQuad(quadName); JQuad* quad = mResource->GetQuad(quadName);
@@ -174,7 +173,7 @@ bool JAnimator::Load(const char* scriptFile)
} }
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
delete[] xmlBuffer; delete[] xmlBuffer;
return true; return true;
+16 -17
View File
@@ -49,8 +49,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
{ {
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(fileName); if (!fileSystem->OpenFile(fileName))
if (!jFile)
return 0; return 0;
memset(p_wav, 0, sizeof(WAVDATA)); memset(p_wav, 0, sizeof(WAVDATA));
@@ -58,14 +57,14 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
char head[256]; char head[256];
memset(head, 0, 256); memset(head, 0, 256);
//sceIoRead(fd, head, 20); //sceIoRead(fd, head, 20);
fileSystem->ReadFile(jFile, head, 20); fileSystem->ReadFile(head, 20);
char string[8]; char string[8];
memset(string, 0, 8); memset(string, 0, 8);
memcpy(string, head, 4); memcpy(string, head, 4);
if (0!=strcmp(string, "RIFF")) if (0!=strcmp(string, "RIFF"))
{ {
//sceIoClose(fd); //sceIoClose(fd);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return 0; return 0;
} }
memset(string, 0, 8); memset(string, 0, 8);
@@ -73,7 +72,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (0!=strcmp(string, "WAVE")) if (0!=strcmp(string, "WAVE"))
{ {
//sceIoClose(fd); //sceIoClose(fd);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return 0; return 0;
} }
memset(string, 0, 8); memset(string, 0, 8);
@@ -81,42 +80,42 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (0!=strcmp(string, "fmt")) if (0!=strcmp(string, "fmt"))
{ {
//sceIoClose(fd); //sceIoClose(fd);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return 0; return 0;
} }
int fmtSize = 0; int fmtSize = 0;
memcpy(&fmtSize, head+16, 4); memcpy(&fmtSize, head+16, 4);
//sceIoRead(fd, head+20, fmtSize); //sceIoRead(fd, head+20, fmtSize);
fileSystem->ReadFile(jFile, head+20,fmtSize ); fileSystem->ReadFile(head+20,fmtSize );
p_wav->headSize = 20+fmtSize; p_wav->headSize = 20+fmtSize;
while (1) while (1)
{ {
//sceIoRead(fd, head+p_wav->headSize, 4); //sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4); fileSystem->ReadFile(head+p_wav->headSize, 4);
memset(string, 0, 8); memset(string, 0, 8);
memcpy(string, head+p_wav->headSize, 4); memcpy(string, head+p_wav->headSize, 4);
p_wav->headSize += 4; p_wav->headSize += 4;
if (0!=strcmp(string, "data")) if (0!=strcmp(string, "data"))
{ {
//sceIoRead(fd, head+p_wav->headSize, 4); //sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4); fileSystem->ReadFile(head+p_wav->headSize, 4);
memcpy(&fmtSize, head+p_wav->headSize, 4); memcpy(&fmtSize, head+p_wav->headSize, 4);
p_wav->headSize += 4; p_wav->headSize += 4;
//sceIoRead(fd, head+p_wav->headSize, fmtSize); //sceIoRead(fd, head+p_wav->headSize, fmtSize);
fileSystem->ReadFile(jFile, head+p_wav->headSize, fmtSize); fileSystem->ReadFile(head+p_wav->headSize, fmtSize);
p_wav->headSize += fmtSize; p_wav->headSize += fmtSize;
} }
else else
{ {
//sceIoRead(fd, head+p_wav->headSize, 4); //sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4); fileSystem->ReadFile(head+p_wav->headSize, 4);
p_wav->headSize += 4; p_wav->headSize += 4;
break; break;
} }
if (p_wav->headSize>191) if (p_wav->headSize>191)
{ {
//sceIoClose(fd); //sceIoClose(fd);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return 0; return 0;
} }
} }
@@ -127,7 +126,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->channelCount!=1 && p_wav->channelCount!=2) if (p_wav->channelCount!=1 && p_wav->channelCount!=2)
{ {
//sceIoClose(fd); //sceIoClose(fd);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return 0; return 0;
} }
memcpy(&p_wav->samplePerSecond, head+24, 4); memcpy(&p_wav->samplePerSecond, head+24, 4);
@@ -137,7 +136,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->bytePerSample!=1 && p_wav->bytePerSample!=2) if (p_wav->bytePerSample!=1 && p_wav->bytePerSample!=2)
{ {
//sceIoClose(fd); //sceIoClose(fd);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return 0; return 0;
} }
p_wav->nSample = 44100 / p_wav->samplePerSecond; p_wav->nSample = 44100 / p_wav->samplePerSecond;
@@ -148,17 +147,17 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->soundSize>4096000) if (p_wav->soundSize>4096000)
{ {
//sceIoClose(fd); //sceIoClose(fd);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return 0; return 0;
} }
p_wav->buffer = (char*)malloc(p_wav->soundSize); p_wav->buffer = (char*)malloc(p_wav->soundSize);
memset(p_wav->buffer, 0, p_wav->soundSize); memset(p_wav->buffer, 0, p_wav->soundSize);
//sceIoRead(fd, p_wav->buffer, p_wav->soundSize); //sceIoRead(fd, p_wav->buffer, p_wav->soundSize);
fileSystem->ReadFile(jFile, p_wav->buffer, p_wav->soundSize); fileSystem->ReadFile(p_wav->buffer, p_wav->soundSize);
p_wav->bytePosition = 0; p_wav->bytePosition = 0;
p_wav->fd = -1; p_wav->fd = -1;
//sceIoClose(fd); //sceIoClose(fd);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
} }
else else
{ {
+67 -164
View File
@@ -107,6 +107,7 @@ JFileSystem* JFileSystem::GetInstance()
// Tries to set the system and user paths. // Tries to set the system and user paths.
// On some OSes, the parameters get overriden by hardcoded values // On some OSes, the parameters get overriden by hardcoded values
JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath) JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
{ {
string systemPath = _systemPath; string systemPath = _systemPath;
string userPath = _userPath; string userPath = _userPath;
@@ -125,13 +126,13 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
DebugTrace("User path " << userPath); DebugTrace("User path " << userPath);
#elif defined (QT_CONFIG) #elif defined (QT_CONFIG)
QDir sysDir(RESDIR); QDir sysDir("projects/mtg/bin/Res");
QDir dir(QDir::homePath()); QDir dir(QDir::homePath());
dir.mkdir(USERDIR); dir.mkdir(USERDIR);
dir.cd(USERDIR); dir.cd(USERDIR);
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString(); userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
DebugTrace("User path " << userPath); DebugTrace("User path " << userPath);
DebugTrace("System path " << systemPath); DebugTrace("System path " << systemPath);
@@ -191,6 +192,9 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
mZipAvailable = false; mZipAvailable = false;
mZipCachedElementsCount = 0; mZipCachedElementsCount = 0;
mPassword = NULL; mPassword = NULL;
mFileSize = 0;
mCurrentFileInZip = NULL;
}; };
void JFileSystem::Destroy() void JFileSystem::Destroy()
@@ -204,26 +208,14 @@ void JFileSystem::Destroy()
bool JFileSystem::DirExists(const string& strDirname) bool JFileSystem::DirExists(const string& strDirname)
{ {
return ( return (mSystemFS && mSystemFS->DirExists(strDirname)) || mUserFS->DirExists(strDirname);
(mSystemFS && mSystemFS->DirExists(strDirname))
|| mUserFS->DirExists(strDirname)
#ifdef QT_CONFIG
|| QDir(QString(":/") + strDirname.c_str()).exists()
#endif
);
} }
bool JFileSystem::FileExists(const string& strFilename) bool JFileSystem::FileExists(const string& strFilename)
{ {
if (strFilename.length() < 1 ) return false; if (strFilename.length() < 1 ) return false;
return ( return (mSystemFS && mSystemFS->FileExists(strFilename)) || mUserFS->FileExists(strFilename);
(mSystemFS && mSystemFS->FileExists(strFilename))
|| mUserFS->FileExists(strFilename)
#ifdef QT_CONFIG
|| QFile(QString(":/") + strFilename.c_str()).exists()
#endif
);
} }
bool JFileSystem::MakeDir(const string & dir) bool JFileSystem::MakeDir(const string & dir)
@@ -283,6 +275,7 @@ bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL
} }
mZipAvailable = true; mZipAvailable = true;
return true; return true;
} }
@@ -292,6 +285,7 @@ void JFileSystem::DetachZipFile()
{ {
mZipFile.close(); mZipFile.close();
} }
mCurrentFileInZip = NULL;
mZipAvailable = false; mZipAvailable = false;
} }
@@ -313,58 +307,24 @@ bool JFileSystem::openForRead(izfstream & File, const string & FilePath) {
bool JFileSystem::readIntoString(const string & FilePath, string & target) bool JFileSystem::readIntoString(const string & FilePath, string & target)
{ {
bool result = false; izfstream file;
if (!openForRead(file, FilePath))
return false;
// Trying first with a izfstream int fileSize = GetFileSize(file);
do {
izfstream file;
if (!openForRead(file, FilePath))
break;
int fileSize = GetFileSize(file); try {
target.resize((std::string::size_type) fileSize);
} catch (bad_alloc&) {
return false;
}
#ifndef __MINGW32__
try {
#endif
target.resize((std::string::size_type) fileSize);
#ifndef __MINGW32__
} catch (bad_alloc&) {
break;
}
#endif
if (fileSize)
file.read(&target[0], fileSize);
file.close(); if (fileSize)
result = true; file.read(&target[0], fileSize);
} while (0);
#ifdef QT_CONFIG
// Now we try with qrc if we haven't finc anything yet
if (!result) do {
string path = string(":/") + FilePath.c_str();
QFile qfile(path.c_str());
qfile.open(QIODevice::ReadOnly);
if(!qfile.isReadable())
break;
int fileSize = qfile.size();
#ifndef __MINGW32__
try {
#endif
target.resize((std::string::size_type) fileSize);
#ifndef __MINGW32__
} catch (bad_alloc&) {
break;
}
#endif
if (fileSize)
qfile.read(&target[0], fileSize);
qfile.close(); file.close();
result = true; return true;
} while (0);
#endif //QT_CONFIG
return result;
} }
bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode) bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode)
@@ -410,72 +370,57 @@ bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_bas
return false; return false;
} }
JFile* JFileSystem::OpenFile(const string &filename) bool JFileSystem::OpenFile(const string &filename)
{ {
bool result; mCurrentFileInZip = NULL;
JFile* jFile = new JFile();
jFile->mCurrentFileInZip = NULL;
do { if (!mZipAvailable || !mZipFile)
if (!mZipAvailable || !mZipFile) { return openForRead(mFile, filename);
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); preloadZip(mZipFileName);
map<string,JZipCache *>::iterator it = mZipCache.find(mZipFileName); map<string,JZipCache *>::iterator it = mZipCache.find(mZipFileName);
if (it == mZipCache.end()) if (it == mZipCache.end())
{ {
//DetachZipFile(); //DetachZipFile();
//return OpenFile(filename); //return OpenFile(filename);
result = openForRead(jFile->mFile, filename); return openForRead(mFile, filename);
break;
}
JZipCache * zc = it->second;
map<string, filesystem::limited_file_info>::iterator it2 = zc->dir.find(filename);
if (it2 == zc->dir.end())
{
/*DetachZipFile();
return OpenFile(filename); */
result = openForRead(jFile->mFile, filename);
break;
}
jFile->mCurrentFileInZip = &(it2->second);
result = true;
} while(0);
if(result)
return jFile;
else {
delete jFile;
return 0;
} }
JZipCache * zc = it->second;
map<string, filesystem::limited_file_info>::iterator it2 = zc->dir.find(filename);
if (it2 == zc->dir.end())
{
/*DetachZipFile();
return OpenFile(filename); */
return openForRead(mFile, filename);
}
mCurrentFileInZip = &(it2->second);
mFileSize = it2->second.m_Size;
return true;
} }
void JFileSystem::CloseFile(JFile* jFile) void JFileSystem::CloseFile()
{ {
delete jFile; if (mZipAvailable && mZipFile)
{
mCurrentFileInZip = NULL;
}
if (mFile)
mFile.close();
} }
//returns 0 if less than "size" bits were read //returns 0 if less than "size" bits were read
int JFileSystem::ReadFile(JFile* jFile, void *buffer, int size) int JFileSystem::ReadFile(void *buffer, int size)
{ {
if (jFile->mCurrentFileInZip) if (mCurrentFileInZip)
{ {
assert(mZipFile); assert(mZipFile);
if((size_t)size > jFile->mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips if((size_t)size > mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
return 0; return 0;
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, jFile->mCurrentFileInZip->m_Offset); std::streamoff offset = filesystem::SkipLFHdr(mZipFile, mCurrentFileInZip->m_Offset);
if (!mZipFile.seekg(offset)) if (!mZipFile.seekg(offset))
return 0; return 0;
mZipFile.read((char *) buffer, size); mZipFile.read((char *) buffer, size);
@@ -483,43 +428,16 @@ int JFileSystem::ReadFile(JFile* jFile, void *buffer, int size)
return size; return size;
} }
#ifdef QT_CONFIG if (!mFile)
if(jFile->mpqFile) {
return jFile->mpqFile->read((char*)buffer, size);
}
#endif
if (!jFile->mFile)
return 0; return 0;
assert(!jFile->mFile.Zipped() || (size_t)size <= jFile->mFile.getUncompSize()); assert(!mFile.Zipped() || (size_t)size <= mFile.getUncompSize());
jFile->mFile.read((char *)buffer, size); mFile.read((char *)buffer, size);
if (jFile->mFile.eof()) if (mFile.eof())
return 0; return 0;
return size; 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) std::vector<std::string>& JFileSystem::scanRealFolder(const std::string& folderName, std::vector<std::string>& results)
{ {
DIR *dip = opendir(folderName.c_str()); DIR *dip = opendir(folderName.c_str());
@@ -607,15 +525,6 @@ std::vector<std::string>& JFileSystem::scanfolder(const std::string& _folderName
seen[systemReal[i]] = true; seen[systemReal[i]] = true;
} }
} }
#ifdef QT_CONFIG
string path = string(":/") + folderName;
QDir dir(path.c_str());
QStringList list = dir.entryList();
for(int i = 0; i < list.size(); i++)
{
seen[list.at(i).toStdString()] = true;
}
#endif
for(map<string,bool>::iterator it = seen.begin(); it != seen.end(); ++it) for(map<string,bool>::iterator it = seen.begin(); it != seen.end(); ++it)
{ {
@@ -631,18 +540,12 @@ std::vector<std::string> JFileSystem::scanfolder(const std::string& folderName)
return scanfolder(folderName, result); return scanfolder(folderName, result);
} }
int JFileSystem::GetFileSize(JFile* jFile) int JFileSystem::GetFileSize()
{ {
if (jFile->mCurrentFileInZip) if (mCurrentFileInZip)
return jFile->mCurrentFileInZip->m_Size; return mFileSize;
#ifdef QT_CONFIG return GetFileSize(mFile);
if(jFile->mpqFile) {
return jFile->mpqFile->size();
}
#endif
return GetFileSize(jFile->mFile);
} }
bool JFileSystem::Rename(string _from, string _to) bool JFileSystem::Rename(string _from, string _to)
+9 -10
View File
@@ -116,26 +116,25 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
int size; int size;
JFileSystem *fileSys = JFileSystem::GetInstance(); JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(engFileName); if (!fileSys->OpenFile(engFileName))
if (!jFile)
return false; return false;
size = fileSys->GetFileSize(jFile); size = fileSys->GetFileSize();
mEngFont = new BYTE[size]; mEngFont = new BYTE[size];
fileSys->ReadFile(jFile, mEngFont, size); fileSys->ReadFile(mEngFont, size);
fileSys->CloseFile(jFile); fileSys->CloseFile();
jFile = fileSys->OpenFile(chnFileName);
if (!jFile) if (!fileSys->OpenFile(chnFileName))
return false; return false;
size = fileSys->GetFileSize(jFile); size = fileSys->GetFileSize();
mChnFont = new BYTE[size]; mChnFont = new BYTE[size];
fileSys->ReadFile(jFile, mChnFont, size); fileSys->ReadFile(mChnFont, size);
fileSys->CloseFile(jFile); fileSys->CloseFile();
return true; return true;
} }
+3 -1
View File
@@ -65,7 +65,7 @@ void JQuad::SetHotSpot(float x, float y)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JTexture::JTexture() : mWidth(0), mHeight(0), mBuffer(NULL) JTexture::JTexture() : mBuffer(NULL)
{ {
mTexId = -1; mTexId = -1;
} }
@@ -305,12 +305,14 @@ void JRenderer::TransferTextureToGLContext(JTexture& inTexture)
JTexture* JRenderer::CreateTexture(int width, int height, int mode __attribute__((unused))) JTexture* JRenderer::CreateTexture(int width, int height, int mode __attribute__((unused)))
{ {
JTexture *tex = new JTexture(); JTexture *tex = new JTexture();
return tex; return tex;
} }
JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureFormat) JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureFormat)
{ {
JTexture *tex = new JTexture(); JTexture *tex = new JTexture();
return tex; return tex;
} }
+20 -25
View File
@@ -892,10 +892,9 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
{ {
png_size_t check; png_size_t check;
JFile* jFile = (JFile*)png_ptr->io_ptr; JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
JFileSystem* fileSystem = JFileSystem::GetInstance();
check = fileSystem->ReadFile(jFile, data, length); check = fileSystem->ReadFile(data, length);
if (check != length) if (check != length)
{ {
@@ -1039,24 +1038,23 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
bits32 = NULL; bits32 = NULL;
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSystem->OpenFile(filename))
if (!jFile)
{ {
return; return;
} }
rawsize = fileSystem->GetFileSize(jFile); rawsize = fileSystem->GetFileSize();
rawdata = new u8[rawsize]; rawdata = new u8[rawsize];
if (!rawdata) if (!rawdata)
{ {
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return; return;
} }
fileSystem->ReadFile(jFile, rawdata, rawsize); fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
@@ -1364,25 +1362,24 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
u32* line; u32* line;
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
if (!jFile) return JGE_ERR_CANT_OPEN_FILE;
//JLOG("PNG opened - creating read struct"); //JLOG("PNG opened - creating read struct");
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) { if (png_ptr == NULL) {
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return JGE_ERR_PNG; return JGE_ERR_PNG;
} }
//JLOG("Setting error callback func"); //JLOG("Setting error callback func");
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn); png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn);
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) { if (info_ptr == NULL) {
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_PNG; return JGE_ERR_PNG;
} }
png_init_io(png_ptr, NULL); png_init_io(png_ptr, NULL);
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn); png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
png_set_sig_bytes(png_ptr, sig_read); png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr); png_read_info(png_ptr, info_ptr);
@@ -1395,7 +1392,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
line = (u32*) malloc(width * 4); line = (u32*) malloc(width * 4);
if (!line) { if (!line) {
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED; return JGE_ERR_MALLOC_FAILED;
} }
@@ -1433,7 +1430,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
std::ostringstream stream; std::ostringstream stream;
stream << "Alloc failed for: Tex Width: " << texWidth << " Tex Height: " << kVerticalBlockSize << ", total bytes: " << texWidth * kVerticalBlockSize * sizeof(PIXEL_TYPE); stream << "Alloc failed for: Tex Width: " << texWidth << " Tex Height: " << kVerticalBlockSize << ", total bytes: " << texWidth * kVerticalBlockSize * sizeof(PIXEL_TYPE);
JLOG(stream.str().c_str()); JLOG(stream.str().c_str());
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED; return JGE_ERR_MALLOC_FAILED;
} }
@@ -1508,7 +1505,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
//JLOG("Closing PNG"); //JLOG("Closing PNG");
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
if (done) if (done)
{ {
@@ -1728,9 +1725,9 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
int image_gif_read(GifFileType * ft, GifByteType * buf, int size) int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
{ {
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = (JFile*)ft->UserData; JFileSystem *fileSys = (JFileSystem *)ft->UserData;
if (fileSys->ReadFile(jFile, buf, size)) if (fileSys->ReadFile(buf, size))
return size; return size;
else else
return 0; return 0;
@@ -1743,17 +1740,15 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
JFileSystem *fileSys = JFileSystem::GetInstance(); JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(filename); if (!fileSys->OpenFile(filename))
if (!jFile)
return; return;
DWORD bkcol; DWORD bkcol;
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode); int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
if(result!=0) if(result!=0)
textureInfo.mBits=NULL; textureInfo.mBits=NULL;
fileSys->CloseFile(jFile); fileSys->CloseFile();
return ; return ;
} }
+3 -4
View File
@@ -42,11 +42,10 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
//FILE *file; //FILE *file;
JFileSystem *fileSys = JFileSystem::GetInstance(); JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(filename); if (!fileSys->OpenFile(filename)) return;
if (!jFile) return;
fileSys->ReadFile(jFile, (u8 *)buffer, 2048); fileSys->ReadFile((u8 *)buffer, 2048);
fileSys->CloseFile(jFile); fileSys->CloseFile();
sprintf(filename, "%s.png", fontname); sprintf(filename, "%s.png", fontname);
mTexture = mRenderer->LoadTexture(filename, useVideoRAM); mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
+4 -5
View File
@@ -96,8 +96,7 @@ bool JMD2Model::Load(char *filename, char *textureName)
// open the model file // open the model file
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSystem->OpenFile(filename))
if (!jFile)
return false; return false;
//filePtr = fopen(filename, "rb"); //filePtr = fopen(filename, "rb");
//if (filePtr == NULL) //if (filePtr == NULL)
@@ -108,13 +107,13 @@ bool JMD2Model::Load(char *filename, char *textureName)
//fileLen = ftell(filePtr); //fileLen = ftell(filePtr);
//fseek(filePtr, 0, SEEK_SET); //fseek(filePtr, 0, SEEK_SET);
fileLen = fileSystem->GetFileSize(jFile); fileLen = fileSystem->GetFileSize();
// read entire file into buffer // read entire file into buffer
buffer = (char*)malloc(fileLen + 1); buffer = (char*)malloc(fileLen + 1);
//fread(buffer, sizeof(char), fileLen, filePtr); //fread(buffer, sizeof(char), fileLen, filePtr);
fileSystem->ReadFile(jFile, buffer, fileLen); fileSystem->ReadFile(buffer, fileLen);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
// extract model file header from buffer // extract model file header from buffer
modelHeader = (modelHeader_t*)buffer; modelHeader = (modelHeader_t*)buffer;
+12 -13
View File
@@ -47,15 +47,14 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
{ {
JFileSystem* fileSys = JFileSystem::GetInstance(); JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(modelName); if (!fileSys->OpenFile(modelName))
if (!jFile)
return false; return false;
int size = fileSys->GetFileSize(jFile); int size = fileSys->GetFileSize();
char *buffer = new char[size]; char *buffer = new char[size];
fileSys->ReadFile(jFile, buffer, size); fileSys->ReadFile(buffer, size);
fileSys->CloseFile(jFile); fileSys->CloseFile();
Vector3D vert; Vector3D vert;
@@ -76,10 +75,10 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
int count; int count;
while (filePtr < size) while (filePtr < size)
{ {
filePtr = ReadLine(tmpLine, buffer, filePtr, size); filePtr = ReadLine(tmpLine, buffer, filePtr, size);
{ {
if ((tmpLine[0] == '#') || (strlen(tmpLine) < 3)) if ((tmpLine[0] == '#') || (strlen(tmpLine) < 3))
{ {
@@ -90,16 +89,16 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
if (count == 4) if (count == 4)
{ {
if (string("vn") == s1) if (strcmp(s1, "vn") == 0)
normalList.push_back(vert); normalList.push_back(vert);
else if (string("vt") == s1) else if (strcmp(s1, "vt") == 0)
texList.push_back(vert); texList.push_back(vert);
else if (string("v") == s1) else if (strcmp(s1, "v") == 0)
vertList.push_back(vert); vertList.push_back(vert);
} }
else if (count == 3) else if (count == 3)
{ {
if (string("vt") == s1) if (strcmp(s1, "vt") == 0)
texList.push_back(vert); texList.push_back(vert);
} }
@@ -212,7 +211,7 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
if (textureName != NULL) if (textureName != NULL)
mTexture = JRenderer::GetInstance()->LoadTexture(textureName); mTexture = JRenderer::GetInstance()->LoadTexture(textureName);
return true; return true;
} }
+20 -21
View File
@@ -55,12 +55,11 @@ bool JParticleEffect::Load(const char* filename)
JFileSystem *fileSystem = JFileSystem::GetInstance(); JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false; if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSystem->OpenFile(filename)) return false;
if (!jFile) return false;
int size = fileSystem->GetFileSize(jFile); int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size]; char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size); fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc; TiXmlDocument doc;
@@ -91,7 +90,7 @@ bool JParticleEffect::Load(const char* filename)
// FIELD_COUNT // FIELD_COUNT
// }; // };
const string lifeValues[] = const char* lifeValues[] =
{ {
"speed", "speed",
"size", "size",
@@ -105,7 +104,7 @@ bool JParticleEffect::Load(const char* filename)
"gravity" "gravity"
}; };
const string typeNames[] = const char* typeNames[] =
{ {
"POINT", "POINT",
"AREA", "AREA",
@@ -114,7 +113,7 @@ bool JParticleEffect::Load(const char* filename)
"CIRCLE" "CIRCLE"
}; };
const string modeNames[] = const char* modeNames[] =
{ {
"REPEAT", "REPEAT",
"ONCE", "ONCE",
@@ -150,32 +149,32 @@ bool JParticleEffect::Load(const char* filename)
{ {
element = param->ToElement(); element = param->ToElement();
if (string("settings") == element->Attribute("name")) if (strcmp(element->Attribute("name"), "settings")==0)
{ {
if (string("NORMAL") == element->Attribute("blend")) if (strcmp(element->Attribute("blend"), "NORMAL")==0)
mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA); mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
else if (string("ADDITIVE") == element->Attribute("blend")) else if (strcmp(element->Attribute("blend"), "ADDITIVE")==0)
mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE); mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE);
for (unsigned int i=0;i<sizeof(modeNames)/sizeof(char*);i++) for (unsigned int i=0;i<sizeof(modeNames)/sizeof(char*);i++)
{ {
if (modeNames[i] == element->Attribute("mode")) if (strcmp(element->Attribute("mode"), modeNames[i])==0)
{ {
mParticleEmitters[mEmitterCount]->mEmitterMode = i; mParticleEmitters[mEmitterCount]->mEmitterMode = i;
#if defined (_DEBUG) #if defined (_DEBUG)
printf("emitter mode:%s\n", modeNames[i].c_str()); printf("emitter mode:%s\n", modeNames[i]);
#endif #endif
break; break;
} }
} }
for (unsigned i=0;i<sizeof(typeNames)/sizeof(char*);i++) for (unsigned i=0;i<sizeof(typeNames)/sizeof(char*);i++)
{ {
if (typeNames[i] == element->Attribute("type")) if (strcmp(element->Attribute("type"), typeNames[i])==0)
{ {
mParticleEmitters[mEmitterCount]->mType = i; mParticleEmitters[mEmitterCount]->mType = i;
#if defined (_DEBUG) #if defined (_DEBUG)
printf("emitter type:%s\n", typeNames[i].c_str()); printf("emitter type:%s\n", typeNames[i]);
#endif #endif
break; break;
} }
@@ -214,7 +213,7 @@ bool JParticleEffect::Load(const char* filename)
} }
} }
else if (string("quantity") == element->Attribute("name")) else if (strcmp(element->Attribute("name"), "quantity")==0)
{ {
for (key = param->FirstChild(); key; key = key->NextSibling()) for (key = param->FirstChild(); key; key = key->NextSibling())
{ {
@@ -228,7 +227,7 @@ bool JParticleEffect::Load(const char* filename)
} }
} }
else if (string("lifex") == element->Attribute("name")) else if (strcmp(element->Attribute("name"), "lifex")==0)
{ {
if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS && if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS &&
element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS) element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS)
@@ -237,7 +236,7 @@ bool JParticleEffect::Load(const char* filename)
mParticleEmitters[mEmitterCount]->mLifeMax= value; mParticleEmitters[mEmitterCount]->mLifeMax= value;
} }
} }
else if (string("anglex") == element->Attribute("name")) else if (strcmp(element->Attribute("name"), "anglex")==0)
{ {
if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS && if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS &&
element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS) element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS)
@@ -246,7 +245,7 @@ bool JParticleEffect::Load(const char* filename)
mParticleEmitters[mEmitterCount]->mAngleMax= value*DEG2RAD; mParticleEmitters[mEmitterCount]->mAngleMax= value*DEG2RAD;
} }
} }
else if (string("speedx") == element->Attribute("name")) else if (strcmp(element->Attribute("name"), "speedx")==0)
{ {
if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS && if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS &&
element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS) element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS)
@@ -255,7 +254,7 @@ bool JParticleEffect::Load(const char* filename)
mParticleEmitters[mEmitterCount]->mSpeedMax= value; mParticleEmitters[mEmitterCount]->mSpeedMax= value;
} }
} }
else if (string("sizex") == element->Attribute("name")) else if (strcmp(element->Attribute("name"), "sizex")==0)
{ {
if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS && if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS &&
element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS) element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS)
@@ -268,7 +267,7 @@ bool JParticleEffect::Load(const char* filename)
{ {
for (int i=0;i<FIELD_COUNT;i++) for (int i=0;i<FIELD_COUNT;i++)
{ {
if (lifeValues[i] == element->Attribute("name")) if (strcmp(element->Attribute("name"), lifeValues[i])==0)
{ {
for (key = param->FirstChild(); key; key = key->NextSibling()) for (key = param->FirstChild(); key; key = key->NextSibling())
{ {
@@ -297,7 +296,7 @@ bool JParticleEffect::Load(const char* filename)
} }
} }
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
delete[] xmlBuffer; delete[] xmlBuffer;
return true; return true;
+8 -8
View File
@@ -93,13 +93,13 @@ bool JResourceManager::LoadResource(const string& resourceName)
JFileSystem *fileSystem = JFileSystem::GetInstance(); JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false; if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(path.c_str());
if (!jFile) return false;
int size = fileSystem->GetFileSize(jFile); if (!fileSystem->OpenFile(path.c_str())) return false;
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size]; char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size); fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc; TiXmlDocument doc;
doc.Parse(xmlBuffer); doc.Parse(xmlBuffer);
@@ -119,11 +119,11 @@ bool JResourceManager::LoadResource(const string& resourceName)
element = node->ToElement(); element = node->ToElement();
if (element != NULL) if (element != NULL)
{ {
if (element->ValueStr() == "texture") if (strcmp(element->Value(), "texture")==0)
{ {
CreateTexture(element->Attribute("name")); CreateTexture(element->Attribute("name"));
} }
else if (element->ValueStr() == "quad") else if (strcmp(element->Value(), "quad")==0)
{ {
string quadName = element->Attribute("name"); string quadName = element->Attribute("name");
string textureName = element->Attribute("texture"); string textureName = element->Attribute("texture");
@@ -170,7 +170,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
GetQuad(id)->SetHotSpot(hotspotX, hotspotY); GetQuad(id)->SetHotSpot(hotspotX, hotspotY);
} }
} }
else if (element->ValueStr() == "font") else if (strcmp(element->Value(), "font")==0)
{ {
} }
@@ -179,7 +179,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
} }
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
delete[] xmlBuffer; delete[] xmlBuffer;
// JGERelease(); // JGERelease();
+4 -5
View File
@@ -41,12 +41,11 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
JFileSystem *fileSystem = JFileSystem::GetInstance(); JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false; if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSystem->OpenFile(filename)) return false;
if (!jFile) return false;
int size = fileSystem->GetFileSize(jFile); int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size]; char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size); fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc; TiXmlDocument doc;
doc.Parse(xmlBuffer); doc.Parse(xmlBuffer);
@@ -77,7 +76,7 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
} }
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
delete[] xmlBuffer; delete[] xmlBuffer;
return true; return true;
+5 -6
View File
@@ -199,16 +199,15 @@ bool JTTFont::Load(const char *filename, int size, int mode)
if (FT_Init_FreeType( &mLibrary ) == 0) if (FT_Init_FreeType( &mLibrary ) == 0)
{ {
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename); if (fileSystem->OpenFile(filename))
if (jFile)
{ {
mFontBitsSize = fileSystem->GetFileSize(jFile); mFontBitsSize = fileSystem->GetFileSize();
mFontBits = (FT_Byte*)malloc(mFontBitsSize); mFontBits = (FT_Byte*)malloc(mFontBitsSize);
fileSystem->ReadFile(jFile, mFontBits, mFontBitsSize); fileSystem->ReadFile(mFontBits, mFontBitsSize);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
if (FT_New_Memory_Face(mLibrary, mFontBits, mFontBitsSize, 0, &mFace ) == 0) if (FT_New_Memory_Face(mLibrary, mFontBits, mFontBitsSize, 0, &mFace ) == 0)
{ {
+2 -1
View File
@@ -96,8 +96,9 @@ int main(int argc, char* argv[])
options.reloadProfile(); options.reloadProfile();
TestSuite testSuite("test/_tests.txt"); TestSuite testSuite("test/_tests.txt");
result = testSuite.run(); result = testSuite.run();
int totalTests = testSuite.nbTests + testSuite.nbAITests;
delete wagicCore; delete wagicCore;
DebugTrace("TestSuite done: failed test: " << result << " out of " << testSuite.nbTests + testSuite.nbAITests << " total"); DebugTrace("TestSuite done: failed test: " << result << " out of " << totalTests << " total");
#ifdef CAPTURE_STDERR #ifdef CAPTURE_STDERR
OutputCapturer::debugAndClear(); OutputCapturer::debugAndClear();
#endif #endif
+1 -1
View File
@@ -69,7 +69,7 @@ int main(int argc, char* argv[])
#endif //QT_WIDGET #endif //QT_WIDGET
if(argc >= 2 && string(argv[1]) == "testsuite") if(argc >= 2 && strcmp(argv[1], "testsuite")==0)
{ {
int result = 0; int result = 0;
result += WagicCore::runTestSuite(); result += WagicCore::runTestSuite();
+4 -5
View File
@@ -57,20 +57,19 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap __attribute__((unused)))
// Load font description // Load font description
JFileSystem* fileSys = JFileSystem::GetInstance(); JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(szFont); if (!fileSys->OpenFile(szFont)) return;
if (!jFile) return;
//data=hge->Resource_Load(szFont, &size); //data=hge->Resource_Load(szFont, &size);
//if(!data) return; //if(!data) return;
size = fileSys->GetFileSize(jFile); size = fileSys->GetFileSize();
desc = new char[size+1]; desc = new char[size+1];
//memcpy(desc,data,size); //memcpy(desc,data,size);
fileSys->ReadFile(jFile, desc, size); fileSys->ReadFile(desc, size);
desc[size]=0; desc[size]=0;
//hge->Resource_Free(data); //hge->Resource_Free(data);
fileSys->CloseFile(jFile); fileSys->CloseFile();
pdesc=_get_line(desc,linebuf); pdesc=_get_line(desc,linebuf);
if(strcmp(linebuf, FNTHEADERTAG)) if(strcmp(linebuf, FNTHEADERTAG))
+33 -28
View File
@@ -50,41 +50,46 @@ float Random_Float(float min, float max)
hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite) hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
{ {
JFileSystem* fileSys = JFileSystem::GetInstance(); //void *psi;
JFile* jFile = fileSys->OpenFile(filename); //hgeParticleSystemInfo psi;
if (!jFile) return;
//if(!psi) return; JFileSystem* fileSys = JFileSystem::GetInstance();
//hge=hgeCreate(HGE_VERSION);
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo)); //psi=hge->Resource_Load(filename);
//hge->Resource_Free(psi); if (!fileSys->OpenFile(filename)) return;
// Skip reading the pointer as it may be larger than 4 bytes in the structure //if(!psi) return;
void *dummyPointer;
fileSys->ReadFile(jFile, &dummyPointer, 4);
// we're actually trying to read more than the file size now, but it's no problem.
// Note that this fix is only to avoid the largest problems, filling a structure
// by directly reading a file, is really a bad idea ...
fileSys->ReadFile(jFile, &(info.nEmission), sizeof(hgeParticleSystemInfo) - 4);
fileSys->CloseFile(jFile);
info.sprite=sprite; //memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
// info.fGravityMin *= 100; //hge->Resource_Free(psi);
// info.fGravityMax *= 100;
// info.fSpeedMin *= 100;
// info.fSpeedMax *= 100;
vecLocation.x=vecPrevLocation.x=0.0f; // Skip reading the pointer as it may be larger than 4 bytes in the structure
vecLocation.y=vecPrevLocation.y=0.0f; void *dummyPointer;
fTx=fTy=0; 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();
fEmissionResidue=0.0f; info.sprite=sprite;
nParticlesAlive=0; // info.fGravityMin *= 100;
fAge=-2.0; // info.fGravityMax *= 100;
mTimer = 0.0f; // info.fSpeedMin *= 100;
// info.fSpeedMax *= 100;
rectBoundingBox.Clear(); vecLocation.x=vecPrevLocation.x=0.0f;
bUpdateBoundingBox=false; vecLocation.y=vecPrevLocation.y=0.0f;
fTx=fTy=0;
fEmissionResidue=0.0f;
nParticlesAlive=0;
fAge=-2.0;
mTimer = 0.0f;
rectBoundingBox.Clear();
bUpdateBoundingBox=false;
} }
hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi) hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi)
+18 -4
View File
@@ -166,11 +166,12 @@ void DestroyGame(void)
[menuKeyRecognizer requireGestureRecognizerToFail: selectKeyRecognizer]; [menuKeyRecognizer requireGestureRecognizerToFail: selectKeyRecognizer];
[self addGestureRecognizer:menuKeyRecognizer]; [self addGestureRecognizer:menuKeyRecognizer];
/* // initialize the scaling factor
lastScale = 1.f;
UIPinchGestureRecognizer *pinchZoomRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchZoom:)]; UIPinchGestureRecognizer *pinchZoomRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchZoom:)];
[self addGestureRecognizer:pinchZoomRecognizer]; [self addGestureRecognizer:pinchZoomRecognizer];
[pinchZoomRecognizer release]; [pinchZoomRecognizer release];
*/
/* /*
Create a single tap recognizer to select the nearest object. Create a single tap recognizer to select the nearest object.
@@ -391,8 +392,6 @@ void DestroyGame(void)
} }
- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer - (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{ {
return YES; return YES;
@@ -425,6 +424,21 @@ void DestroyGame(void)
} }
#pragma mark Gesture Recognizer callbacks #pragma mark Gesture Recognizer callbacks
- (void)handlePinchZoom: (UIPinchGestureRecognizer *) pinchGesture {
[[[pinchGesture view] layer] removeAllAnimations];
CGFloat currentScaleFactor = [pinchGesture scale];
if (pinchGesture.state == UIGestureRecognizerStateEnded) {
if (lastScale < 1.3f) {
lastScale *= currentScaleFactor;
}
else {
lastScale = 1;
[self displayGameMenu];
}
pinchGesture.scale = 1.f;
}
}
- (void)handlePanMotion: (UIPanGestureRecognizer *) panGesture - (void)handlePanMotion: (UIPanGestureRecognizer *) panGesture
{ {
+4 -2
View File
@@ -47,7 +47,6 @@
- (void)viewDidLoad { - (void)viewDidLoad {
NSLog(@"EAGL ViewController - view Did Load"); NSLog(@"EAGL ViewController - view Did Load");
[super viewDidLoad]; [super viewDidLoad];
} }
@@ -56,7 +55,6 @@
[self.view resumeGame]; [self.view resumeGame];
} }
- (void)viewWillDisappear:(BOOL)animated - (void)viewWillDisappear:(BOOL)animated
{ {
[self.view pauseGame]; [self.view pauseGame];
@@ -77,6 +75,10 @@
[self.view endGame]; [self.view endGame];
} }
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- (void)viewDidAppear:(BOOL)animated { - (void)viewDidAppear:(BOOL)animated {
NSLog(@"EAGL ViewController - view Did Appear"); NSLog(@"EAGL ViewController - view Did Appear");
+2 -1
View File
@@ -7,6 +7,7 @@
#include "JFileSystem.h" #include "JFileSystem.h"
#include "JRenderer.h" #include "JRenderer.h"
#include "JGameLauncher.h" #include "JGameLauncher.h"
#include "UIScreen+Util.h"
#define ACTUAL_SCREEN_WIDTH (SCREEN_WIDTH) #define ACTUAL_SCREEN_WIDTH (SCREEN_WIDTH)
#define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT) #define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT)
@@ -61,7 +62,7 @@ bool checkFramebufferStatus();
// for retina devices. because of the 568 px, the ratio between height-width skews the // for retina devices. because of the 568 px, the ratio between height-width skews the
// frame a bit // frame a bit
if ( backingHeight == 568 || backingWidth == 568) { if ( [UIScreen isRetinaDisplay]) {
viewPort.left = 0; viewPort.left = 0;
viewPort.top = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2 + 22; // account for status bar viewPort.top = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2 + 22; // account for status bar
viewPort.right = backingWidth; viewPort.right = backingWidth;
+31 -38
View File
@@ -343,7 +343,7 @@ void JQuad::SetHotSpot(float x, float y)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JTexture::JTexture() : mWidth(0), mHeight(0), mBuffer(NULL) JTexture::JTexture() : mBuffer(NULL)
{ {
mTexId = -1; mTexId = -1;
} }
@@ -1683,21 +1683,20 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
int rawsize, i; int rawsize, i;
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSystem->OpenFile(filename)) return;
if (!jFile) return;
rawsize = fileSystem->GetFileSize(jFile); rawsize = fileSystem->GetFileSize();
rawdata = new BYTE[rawsize]; rawdata = new BYTE[rawsize];
if (!rawdata) if (!rawdata)
{ {
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return; return;
} }
fileSystem->ReadFile(jFile, rawdata, rawsize); fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
// Initialize libJpeg Object // Initialize libJpeg Object
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
@@ -1805,10 +1804,9 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
{ {
png_size_t check; png_size_t check;
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
JFile *jFile = (JFile*)png_ptr->io_ptr;
check = fileSystem->ReadFile(jFile, data, length); check = fileSystem->ReadFile(data, length);
if (check != length) if (check != length)
{ {
@@ -1871,14 +1869,13 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
DWORD* line; DWORD* line;
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSystem->OpenFile(filename))
if (!jFile)
return JGE_ERR_CANT_OPEN_FILE; return JGE_ERR_CANT_OPEN_FILE;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) if (png_ptr == NULL)
{ {
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
return JGE_ERR_PNG; return JGE_ERR_PNG;
} }
@@ -1888,14 +1885,14 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
if (info_ptr == NULL) if (info_ptr == NULL)
{ {
//fclose(fp); //fclose(fp);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_PNG; return JGE_ERR_PNG;
} }
png_init_io(png_ptr, NULL); png_init_io(png_ptr, NULL);
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn); png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
png_set_sig_bytes(png_ptr, sig_read); png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr); png_read_info(png_ptr, info_ptr);
@@ -1911,7 +1908,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
if (!line) if (!line)
{ {
//fclose(fp); //fclose(fp);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED; return JGE_ERR_MALLOC_FAILED;
@@ -1960,7 +1957,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
png_read_end(png_ptr, info_ptr); png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
textureInfo.mBits = buffer; textureInfo.mBits = buffer;
@@ -2119,10 +2116,9 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
int image_gif_read(GifFileType * ft, GifByteType * buf, int size) int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
{ {
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem *fileSys = (JFileSystem *)ft->UserData;
JFile* jFile = (JFile*)ft->UserData; //return fread(buf, 1, size, (FILE *)ft->UserData);
if (fileSys->ReadFile(buf, size))
if (fileSys->ReadFile(jFile, buf, size))
return size; return size;
else else
return 0; return 0;
@@ -2134,18 +2130,17 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
///* ///*
//FILE * fp = fopen(filename, "rb"); //FILE * fp = fopen(filename, "rb");
JFileSystem *fileSys = JFileSystem::GetInstance(); JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSys->OpenFile(filename))
if (!jFile))
return; return;
//if(fp == NULL) //if(fp == NULL)
// return; // return;
DWORD bkcol; DWORD bkcol;
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode); int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
if(result!=0) if(result!=0)
textureInfo.mBits=NULL; textureInfo.mBits=NULL;
//fclose(fp); //fclose(fp);
fileSys->CloseFile(jFile); fileSys->CloseFile();
return ;//*/ return ;//*/
} }
#endif //(!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG) #endif //(!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
@@ -2166,21 +2161,20 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
UIImage *image = NULL; UIImage *image = NULL;
do { do {
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSystem->OpenFile(filename))
if (!jFile)
break; break;
rawsize = fileSystem->GetFileSize(jFile); rawsize = fileSystem->GetFileSize();
rawdata = new BYTE[rawsize]; rawdata = new BYTE[rawsize];
if (!rawdata) if (!rawdata)
{ {
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
break; break;
} }
fileSystem->ReadFile(jFile, rawdata, rawsize); fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
texData = [[NSData alloc] initWithBytes:rawdata length:rawsize]; texData = [[NSData alloc] initWithBytes:rawdata length:rawsize];
image = [[UIImage alloc] initWithData:texData]; image = [[UIImage alloc] initWithData:texData];
@@ -2260,21 +2254,20 @@ JTexture* JRenderer::LoadTexture(const char* filename, int, int)
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
do { do {
JFile* jFile = fileSystem->OpenFile(filename); if (!fileSystem->OpenFile(filename))
if (!jFile)
break; break;
rawsize = fileSystem->GetFileSize(jFile); rawsize = fileSystem->GetFileSize();
rawdata = new BYTE[rawsize]; rawdata = new BYTE[rawsize];
if (!rawdata) if (!rawdata)
{ {
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
break; break;
} }
fileSystem->ReadFile(jFile, rawdata, rawsize); fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
QImage tmpImage = QImage::fromData(rawdata, rawsize); QImage tmpImage = QImage::fromData(rawdata, rawsize);
if(tmpImage.isNull()) if(tmpImage.isNull())
@@ -2493,7 +2486,7 @@ void JRenderer::Enable2D()
#if (defined GL_VERSION_ES_CM_1_1) || (defined GL_OES_VERSION_1_1) #if (defined GL_VERSION_ES_CM_1_1) || (defined GL_OES_VERSION_1_1)
glOrthof(0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f, -1.0f, 1.0f); glOrthof(0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f, -1.0f, 1.0f);
#else #else
glOrtho(0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f, -1.0f, 1.0f); gluOrtho2D(0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f);
#endif #endif
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
+8 -10
View File
@@ -161,16 +161,15 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
if (music) if (music)
{ {
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(fileName); if (fileSystem->OpenFile(fileName))
if (jFile)
{ {
int size = fileSystem->GetFileSize(jFile); int size = fileSystem->GetFileSize();
char *buffer = new char[size]; char *buffer = new char[size];
fileSystem->ReadFile(jFile, buffer, size); fileSystem->ReadFile(buffer, size);
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size); music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer; delete[] buffer;
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
} }
} }
return music; return music;
@@ -282,16 +281,15 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
if (sample) if (sample)
{ {
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(fileName); if (fileSystem->OpenFile(fileName))
if (jFile)
{ {
int size = fileSystem->GetFileSize(jFile); int size = fileSystem->GetFileSize();
char *buffer = new char[size]; char *buffer = new char[size];
fileSystem->ReadFile(jFile, buffer, size); fileSystem->ReadFile(buffer, size);
sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size); sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer; delete[] buffer;
fileSystem->CloseFile(jFile); fileSystem->CloseFile();
}else }else
sample->mSample = NULL; sample->mSample = NULL;
+29 -29
View File
@@ -335,7 +335,7 @@ void WagicCore::resizeGL(int width, int height)
#if (defined GL_VERSION_ES_CM_1_1 || defined GL_OES_VERSION_1_1) #if (defined GL_VERSION_ES_CM_1_1 || defined GL_OES_VERSION_1_1)
glOrthof(0.0f, (float) (m_viewPort.right()-m_viewPort.left())-1.0f, 0.0f, (float) (m_viewPort.bottom()-m_viewPort.top())-1.0f, -1.0f, 1.0f); glOrthof(0.0f, (float) (m_viewPort.right()-m_viewPort.left())-1.0f, 0.0f, (float) (m_viewPort.bottom()-m_viewPort.top())-1.0f, -1.0f, 1.0f);
#else #else
glOrtho(0.0f, (float) (m_viewPort.right()-m_viewPort.left())-1.0f, 0.0f, (float) (m_viewPort.bottom()-m_viewPort.top())-1.0f, -1.0f, 1.0f); gluOrtho2D(0.0f, (float) (m_viewPort.right()-m_viewPort.left())-1.0f, 0.0f, (float) (m_viewPort.bottom()-m_viewPort.top())-1.0f);
#endif #endif
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
@@ -418,29 +418,29 @@ void WagicCore::mousePressEvent(QMouseEvent *event)
{ {
if(event->button() == Qt::LeftButton) if(event->button() == Qt::LeftButton)
{ {
m_lastPos = event->pos(); QPoint lastPos = event->pos();
// this is intended to convert window coordinate into game coordinate. // this is 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 // 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 actualWidth = (int) JRenderer::GetInstance()->GetActualWidth();
int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight(); int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight();
if (lastPosy() >= m_viewPort.top() && if (lastPos.y() >= m_viewPort.top() &&
lastPosy() <= m_viewPort.bottom() && lastPos.y() <= m_viewPort.bottom() &&
lastPosx() <= m_viewPort.right() && lastPos.x() <= m_viewPort.right() &&
lastPosx() >= m_viewPort.left()) { lastPos.x() >= m_viewPort.left()) {
m_engine->LeftClicked( m_engine->LeftClicked(
((lastPosx()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth, ((lastPos.x()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
((lastPosy()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight); ((lastPos.y()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight);
#if (!defined Q_WS_MAEMO_5) && (!defined MEEGO_EDITION_HARMATTAN) && (!defined Q_WS_ANDROID) #if (!defined Q_WS_MAEMO_5) && (!defined MEEGO_EDITION_HARMATTAN) && (!defined Q_WS_ANDROID)
m_engine->HoldKey_NoRepeat(JGE_BTN_OK); m_engine->HoldKey_NoRepeat(JGE_BTN_OK);
#else #else
mMouseDownX = lastPosx(); mMouseDownX = lastPos.x();
mMouseDownY = lastPosy(); mMouseDownY = lastPos.y();
mLastFingerDownTime = g_startTimer.elapsed(); mLastFingerDownTime = g_startTimer.elapsed();
#endif #endif
} else if(lastPosy()<m_viewPort.top()) { } else if(lastPos.y()<m_viewPort.top()) {
m_engine->HoldKey_NoRepeat(JGE_BTN_MENU); m_engine->HoldKey_NoRepeat(JGE_BTN_MENU);
} else if(lastPosy()>m_viewPort.bottom()) { } else if(lastPos.y()>m_viewPort.bottom()) {
m_engine->HoldKey_NoRepeat(JGE_BTN_NEXT); m_engine->HoldKey_NoRepeat(JGE_BTN_NEXT);
} }
event->accept(); event->accept();
@@ -465,33 +465,33 @@ void WagicCore::mouseReleaseEvent(QMouseEvent *event)
{ {
if(event->button() == Qt::LeftButton) if(event->button() == Qt::LeftButton)
{ {
m_lastPos = event->pos(); QPoint lastPos = event->pos();
if (lastPosy() >= m_viewPort.top() && if (lastPos.y() >= m_viewPort.top() &&
lastPosy() <= m_viewPort.bottom() && lastPos.y() <= m_viewPort.bottom() &&
lastPosx() <= m_viewPort.right() && lastPos.x() <= m_viewPort.right() &&
lastPosx() >= m_viewPort.left()) { lastPos.x() >= m_viewPort.left()) {
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID) #if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID)
if(g_startTimer.elapsed() - mLastFingerDownTime <= kTapEventTimeout ) if(g_startTimer.elapsed() - mLastFingerDownTime <= kTapEventTimeout )
{ {
if(abs(mMouseDownX - lastPosx()) < kHitzonePliancy && if(abs(mMouseDownX - lastPos.x()) < kHitzonePliancy &&
abs(mMouseDownY - lastPosy()) < kHitzonePliancy) abs(mMouseDownY - lastPos.y()) < kHitzonePliancy)
{ {
m_engine->HoldKey_NoRepeat(JGE_BTN_OK); m_engine->HoldKey_NoRepeat(JGE_BTN_OK);
} }
} }
else if (g_startTimer.elapsed() - mLastFingerDownTime >= kSwipeEventMinDuration) else if (g_startTimer.elapsed() - mLastFingerDownTime >= kSwipeEventMinDuration)
{ // Let's swipe { // Let's swipe
m_engine->Scroll(lastPosx()-mMouseDownX, lastPosy()-mMouseDownY); m_engine->Scroll(lastPos.x()-mMouseDownX, lastPos.y()-mMouseDownY);
} }
#else #else
//#if (!defined Q_WS_MAEMO_5) && (!defined MEEGO_EDITION_HARMATTAN) //#if (!defined Q_WS_MAEMO_5) && (!defined MEEGO_EDITION_HARMATTAN)
m_engine->ReleaseKey(JGE_BTN_OK); m_engine->ReleaseKey(JGE_BTN_OK);
#endif #endif
m_engine->ReleaseKey(JGE_BTN_MENU); m_engine->ReleaseKey(JGE_BTN_MENU);
} else if(lastPosy() < m_viewPort.top()) { } else if(lastPos.y() < m_viewPort.top()) {
m_engine->ReleaseKey(JGE_BTN_MENU); m_engine->ReleaseKey(JGE_BTN_MENU);
} else if(lastPosy() > m_viewPort.bottom()) { } else if(lastPos.y() > m_viewPort.bottom()) {
m_engine->ReleaseKey(JGE_BTN_NEXT); m_engine->ReleaseKey(JGE_BTN_NEXT);
} }
event->accept(); event->accept();
@@ -517,15 +517,15 @@ void WagicCore::mouseMoveEvent(QMouseEvent *event)
int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth(); int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth();
int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight(); int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight();
m_lastPos = event->pos(); QPoint lastPos = event->pos();
if (lastPosy() >= m_viewPort.top() && if (lastPos.y() >= m_viewPort.top() &&
lastPosy() <= m_viewPort.bottom() && lastPos.y() <= m_viewPort.bottom() &&
lastPosx() <= m_viewPort.right() && lastPos.x() <= m_viewPort.right() &&
lastPosx() >= m_viewPort.left()) { lastPos.x() >= m_viewPort.left()) {
m_engine->LeftClicked( m_engine->LeftClicked(
((lastPosx()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth, ((lastPos.x()-m_viewPort.left())*SCREEN_WIDTH)/actualWidth,
((lastPosy()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight); ((lastPos.y()-m_viewPort.top())*SCREEN_HEIGHT)/actualHeight);
event->accept(); event->accept();
} else { } else {
super::mouseMoveEvent(event); super::mouseMoveEvent(event);
-2
View File
@@ -106,7 +106,6 @@ public:
virtual int overflow(int c = EOF); virtual int overflow(int c = EOF);
virtual int underflow(); virtual int underflow();
virtual int sync(); virtual int sync();
using std::streambuf::setbuf;
virtual std::streambuf * setbuf(char * pr, int nLength); virtual std::streambuf * setbuf(char * pr, int nLength);
virtual std::streampos seekoff(std::streamoff, std::ios::seekdir, std::ios::openmode); virtual std::streampos seekoff(std::streamoff, std::ios::seekdir, std::ios::openmode);
@@ -132,7 +131,6 @@ public:
virtual int overflow(int c = EOF); virtual int overflow(int c = EOF);
virtual int underflow(); virtual int underflow();
virtual int sync(); virtual int sync();
using std::streambuf::setbuf;
virtual std::streambuf * setbuf(char * pr, int nLength); virtual std::streambuf * setbuf(char * pr, int nLength);
virtual std::streampos seekoff(std::streamoff, std::ios::seekdir, std::ios::openmode); virtual std::streampos seekoff(std::streamoff, std::ios::seekdir, std::ios::openmode);
+1 -1
View File
@@ -16,6 +16,6 @@ Wagic, the Homebrew, is a C++ game engine that allows to play card games against
It is highly customizable and allows the player to tweak the rules / create their own cards, their own themes, etc... It is highly customizable and allows the player to tweak the rules / create their own cards, their own themes, etc...
Info, downloads, discussions and more at http://wololo.net/forum/index.php Info, Downloads, and more at http://wololo.net
-![alt text](http://wololo.net/wagic/wp-content/uploads/2009/10/shop.jpg "Screenshot") -![alt text](http://wololo.net/wagic/wp-content/uploads/2009/10/shop.jpg "Screenshot")
+1 -4
View File
@@ -14,7 +14,7 @@ PNG_PATH := $(JGE_PATH)/Dependencies/libpng
DEBUG ?= DEBUG DEBUG ?= DEBUG
LOCAL_CFLAGS += -DLINUX -DANDROID -DSDL_CONFIG -D_$(DEBUG) LOCAL_CFLAGS += -DLINUX -DANDROID -DSDL_CONFIG -D_$(DEBUG)
LOCAL_CFLAGS += -D_STLP_USE_SIMPLE_NODE_ALLOC -DTIXML_USE_STL LOCAL_CFLAGS += -D_STLP_USE_SIMPLE_NODE_ALLOC
LOCAL_CFLAGS += -D__arm__ -D_REENTRANT -D_GLIBCXX__PTHREADS LOCAL_CFLAGS += -D__arm__ -D_REENTRANT -D_GLIBCXX__PTHREADS
LOCAL_STATIC_LIBRARIES := libpng libjpeg LOCAL_STATIC_LIBRARIES := libpng libjpeg
LOCAL_SHARED_LIBRARIES := SDL LOCAL_SHARED_LIBRARIES := SDL
@@ -136,9 +136,6 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
$(MTG_PATH)/src/WFont.cpp \ $(MTG_PATH)/src/WFont.cpp \
$(MTG_PATH)/src/WGui.cpp \ $(MTG_PATH)/src/WGui.cpp \
$(MTG_PATH)/src/WResourceManager.cpp \ $(MTG_PATH)/src/WResourceManager.cpp \
$(MTG_PATH)/src/DeckView.cpp \
$(MTG_PATH)/src/CarouselDeckView.cpp \
$(MTG_PATH)/src/GridDeckView.cpp \
$(JGE_PATH)/src/SDLmain.cpp \ $(JGE_PATH)/src/SDLmain.cpp \
$(JGE_PATH)/src/Encoding.cpp \ $(JGE_PATH)/src/Encoding.cpp \
$(JGE_PATH)/src/JAnimator.cpp \ $(JGE_PATH)/src/JAnimator.cpp \
+2 -2
View File
@@ -27,7 +27,7 @@ OBJS = objs/InteractiveButton.o objs/AbilityParser.o objs/ActionElement.o\
objs/ThisDescriptor.o objs/Token.o objs/Translate.o objs/TranslateKeys.o\ objs/ThisDescriptor.o objs/Token.o objs/Translate.o objs/TranslateKeys.o\
objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o\ objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o\
objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o\ objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o\
objs/WFont.o objs/CarouselDeckView.o objs/GridDeckView.o objs/DeckView.o objs/WFont.o
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS)) DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache) RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
@@ -73,7 +73,7 @@ PSP_EBOOT_UNKPNG = pic0.png
PSP_EBOOT_PIC1 = pic1.png PSP_EBOOT_PIC1 = pic1.png
INCDIR = ../../JGE/include ../../JGE/src/zipFS ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src ../../projects/mtg/include ../../Boost INCDIR = ../../JGE/include ../../JGE/src/zipFS ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src ../../projects/mtg/include ../../Boost
LIBDIR = ../../JGE/lib/psp LIBDIR = ../../JGE/lib/psp
CFLAGS = -O2 -G0 -DPSPFW3XX -DDEVHOOK -DUSE_PRECOMPILED_HEADERS=1 -DPSP -DTIXML_USE_STL CFLAGS = -O2 -G0 -DPSPFW3XX -DDEVHOOK -DUSE_PRECOMPILED_HEADERS=1 -DPSP
else else
OBJS += objs/TestSuiteAI.o OBJS += objs/TestSuiteAI.o
INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include -I../../projects/mtg/include -I../../Boost -I../../JGE/src/zipFS INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include -I../../projects/mtg/include -I../../Boost -I../../JGE/src/zipFS
+4 -61
View File
@@ -7,13 +7,10 @@ from optparse import OptionParser
def createResZipFile(filename): def createResZipFile(filename):
utilities = ZipUtilities() utilities = ZipUtilities()
rename = False
if not os.path.isfile('settings/options.txt'): if not os.path.isfile('settings/options.txt'):
os.rename('settings/options.orig.txt', 'settings/options.txt') os.rename('settings/options.orig.txt', 'settings/options.txt')
remame = True
if not os.path.isfile('player/options.txt'): if not os.path.isfile('player/options.txt'):
os.rename('player/options.orig.txt', 'player/options.txt') os.rename('player/options.orig.txt', 'player/options.txt')
rename = True
zip_file = zipfile.ZipFile(filename, 'w', zipfile.ZIP_STORED) zip_file = zipfile.ZipFile(filename, 'w', zipfile.ZIP_STORED)
utilities.addFolderToZip(zip_file, 'themes') utilities.addFolderToZip(zip_file, 'themes')
@@ -29,10 +26,6 @@ def createResZipFile(filename):
utilities.addFolderToZip(zip_file, 'ai') utilities.addFolderToZip(zip_file, 'ai')
zip_file.close() 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(): def getFilename():
p = Properties(); p = Properties();
p.load(open('../../build.number.properties')); p.load(open('../../build.number.properties'));
@@ -42,39 +35,6 @@ def getFilename():
filename = 'core_' + major + minor + point filename = 'core_' + major + minor + point
return filename 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(): def createStandardResFile():
@@ -117,37 +77,20 @@ class ZipUtilities:
print 'Entering folder: ' + str(full_path) print 'Entering folder: ' + str(full_path)
self.addFolderToZip(zip_file, 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(): def main():
## using optparse instead of argParse for now since python 2.7 may not be installed. ## using optparse instead of argParse for now since python 2.7 may not be installed.
parser = OptionParser() parser = OptionParser()
parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg qt, ios, android, etc)", metavar="PLATFORM", dest="platform") parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg ios, android, etc)", metavar="PLATFORM", dest="platform")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if (options.platform): if (options.platform):
print "reading %s..." % options.platform if (options.platform == "ios"):
if (options.platform == 'ios'): createIosResFile()
createIosResFile()
elif (options.platform == 'qt'):
createQrcFile()
else: else:
createStandardResFile() createStandardResFile()
else: else:
createStandardResFile() createStandardResFile()
-1
View File
@@ -16,7 +16,6 @@ auto=flashbackrule
auto=retracerule auto=retracerule
auto=suspendrule auto=suspendrule
auto=morphrule auto=morphrule
auto=playfromgraveyardrule
auto=attackrule auto=attackrule
auto=blockrule auto=blockrule
auto=combattriggerrule auto=combattriggerrule
-5
View File
@@ -1513,8 +1513,3 @@ primitive=Zephyr Net
id=142357 id=142357
rarity=C rarity=C
[/card] [/card]
[card]
primitive=Avatar Token
id=-140233
rarity=T
[/card]
-5
View File
@@ -1248,8 +1248,3 @@ primitive=Zombie Goliath
id=190545 id=190545
rarity=C rarity=C
[/card] [/card]
[card]
primitive=Avatar Token
id=-191239
rarity=T
[/card]
-5
View File
@@ -1258,8 +1258,3 @@ primitive=Yavimaya Wurm
id=205221 id=205221
rarity=C rarity=C
[/card] [/card]
[card]
primitive=Avatar Token
id=-205957
rarity=T
[/card]
File diff suppressed because it is too large Load Diff
+7 -19
View File
@@ -18104,13 +18104,6 @@ mana={3}{R}
type=Enchantment type=Enchantment
[/card] [/card]
[card] [card]
name=Crucible of Worlds
auto=lord(land|mygraveyard) CanPlayFromGraveyard
text=You may play land cards from your graveyard.
mana={3}
type=Artifact
[/card]
[card]
name=Crude Rampart name=Crude Rampart
abilities=defender abilities=defender
facedown={3} facedown={3}
@@ -31457,7 +31450,7 @@ toughness=2
[/card] [/card]
[card] [card]
name=Flourishing Defenses name=Flourishing Defenses
auto=@counteradded(-1/-1) from(creature):may token(Elf Warrior,Creature elf warrior,1/1,green) auto=@counteradded(-1/-1) from(creature|mybattlefield):may token(Elf Warrior,Creature elf warrior,1/1,green)
text=Whenever a -1/-1 counter is placed on a creature, you may put a 1/1 green Elf Warrior creature token onto the battlefield. 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} mana={4}{G}
type=Enchantment type=Enchantment
@@ -73586,7 +73579,7 @@ toughness=6
###The 2 cards below should stay together (Flip Card)### ###The 2 cards below should stay together (Flip Card)###
[card] [card]
name=Rune-Tail, Kitsune Ascendant name=Rune-Tail, Kitsune Ascendant
auto=this(controllerlife > 29) transforms((,newability[flip(Rune-Tail's Essence)])) auto=this(controllerlife >30) all(this) flip(Rune-Tail's Essence)
text=When you have 30 or more life, flip Rune-Tail, Kitsune Ascendant. text=When you have 30 or more life, flip Rune-Tail, Kitsune Ascendant.
mana={2}{W} mana={2}{W}
type=Legendary Creature type=Legendary Creature
@@ -78444,7 +78437,11 @@ toughness=2
[/card] [/card]
[card] [card]
name=Shifting Sky name=Shifting Sky
auto=chooseacolor lord(*[-land]) becomes(,chosencolor) chooseend auto=choice name(choose white) all(this) transforms((,newability[lord(*[-land]) becomes(,white)])) forever
auto=choice name(choose blue) all(this) transforms((,newability[lord(*[-land]) becomes(,blue)])) forever
auto=choice name(choose black) all(this) transforms((,newability[lord(*[-land]) becomes(,black)])) forever
auto=choice name(choose red) all(this) transforms((,newability[lord(*[-land]) becomes(,red)])) forever
auto=choice name(choose green) all(this) transforms((,newability[lord(*[-land]) becomes(,green)])) forever
text=As Shifting Sky enters the battlefield, choose a color. -- All nonland permanents are the chosen color. text=As Shifting Sky enters the battlefield, choose a color. -- All nonland permanents are the chosen color.
mana={2}{U} mana={2}{U}
type=Enchantment type=Enchantment
@@ -103471,15 +103468,6 @@ mana={1}{B}
type=Enchantment type=Enchantment
[/card] [/card]
[card] [card]
name=Yawgmoth's Will
auto=lord(*|mygraveyard) canPlayFromGraveyard
auto=emblem transforms((,newability[@movedTo(*|mygraveyard):all(trigger[to]) moveTo(exile)])) ueot
auto=moveTo(exile)
text=Until end of turn, you may play cards from your graveyard. -- If a card would be put into your graveyard from anywhere this turn, exile that card instead.
mana={2}{B}
type=Sorcery
[/card]
[card]
name=Yawning Fissure name=Yawning Fissure
auto=ability$!name(sacrifice land) notatarget(land|mybattlefield) sacrifice!$ opponent auto=ability$!name(sacrifice land) notatarget(land|mybattlefield) sacrifice!$ opponent
text=Each opponent sacrifices a land. text=Each opponent sacrifices a land.
@@ -3187,6 +3187,19 @@ mana={2}
type=Artifact type=Artifact
[/card] [/card]
[card] [card]
name=Crucible of Worlds
auto={0}:may moveTo(myBattlefield) target(land|mygraveyard) limit:1 myTurnOnly
# Above line does not work: "May moveto" from graveyards does
# not work due to interface issues. The "limit:1" doesn't work
# here either. Even if both worked, then the card would allow
# you to play lands *in addition* to the 1 land you can play per
# turn. Instead it should just give you the option to play this
# 1 land from your hand or your graveyard.
text=You may play land cards from your graveyard.
mana={3}
type=Artifact
[/card]
[card]
name=Cruel Deceiver name=Cruel Deceiver
text={1}: Look at the top card of your library. -- {2}: Reveal the top card of your library. If it's a land card, Cruel Deceiver gains "Whenever Cruel Deceiver deals damage to a creature, destroy that creature" until end of turn. Activate this ability only once each turn. text={1}: Look at the top card of your library. -- {2}: Reveal the top card of your library. If it's a land card, Cruel Deceiver gains "Whenever Cruel Deceiver deals damage to a creature, destroy that creature" until end of turn. Activate this ability only once each turn.
mana={1}{B} mana={1}{B}
-1
View File
@@ -249,7 +249,6 @@ curiosity2_i217.txt
crimson_kobolds.txt crimson_kobolds.txt
crosis_s_catacombs_1.txt crosis_s_catacombs_1.txt
crosis_s_catacombs_2.txt crosis_s_catacombs_2.txt
crucible_of_worlds.txt
crumble.txt crumble.txt
crystal_rod_i172.txt crystal_rod_i172.txt
cursed_land1_i188.txt cursed_land1_i188.txt
@@ -1,26 +0,0 @@
# Testing crucible of worlds (keyword: CANPLAYFROMGRAVEYARD)
# name=Crucible of Worlds
# text=You may play land cards from your graveyard.
[INIT]
FIRSTMAIN
[PLAYER1]
hand:island,plains
inplay:crucible of worlds
graveyard:forest,mountain
[PLAYER2]
[DO]
forest
# all next lands shouldn't be played
island
mountain
plains
[ASSERT]
FIRSTMAIN
[PLAYER1]
inplay:crucible of worlds,forest
hand:island,plains
graveyard:mountain
[PLAYER2]
[END]
+3 -5
View File
@@ -2,7 +2,6 @@
<!-- build.properties should contain the values for major, minor and point --> <!-- build.properties should contain the values for major, minor and point -->
<property file="build.properties" /> <property file="build.properties" />
<property file="build.number.properties" /> <property file="build.number.properties" />
<property environment="env"/>
<path id="groovy.class.path" > <path id="groovy.class.path" >
<fileset dir="${groovy.dir}" /> <fileset dir="${groovy.dir}" />
@@ -77,16 +76,15 @@ Author: Michael Nguyen
#define WAGIC_VERSION_MAJOR ${build.major} #define WAGIC_VERSION_MAJOR ${build.major}
#define WAGIC_VERSION_MEDIUM ${build.minor} #define WAGIC_VERSION_MEDIUM ${build.minor}
#define WAGIC_VERSION_MINOR ${build.point} #define WAGIC_VERSION_MINOR ${build.point}
#define WAGIC_VERSION_REVISION ${env.TRAVIS_BUILD_NUMBER}
#define VERSION_DOT(a, b, c, d) a ##.## b ##.## c ##.## d #define VERSION_DOT(a, b, c) a ##.## b ##.## c
#define VERSION_WITHOUT_DOT(a, b, c) a ## b ## c #define VERSION_WITHOUT_DOT(a, b, c) a ## b ## c
#define VERSION_GAME(a, b, c, d) VERSION_DOT(a, b, c, d) #define VERSION_GAME(a, b, c) VERSION_DOT(a, b, c)
#define VERSION_FILE(a, b, c) VERSION_WITHOUT_DOT(a, b, c) #define VERSION_FILE(a, b, c) VERSION_WITHOUT_DOT(a, b, c)
#define VERSION_TOSTRING(a) #a #define VERSION_TOSTRING(a) #a
#define VERSION_STRINGIFY(a) VERSION_TOSTRING(a) #define VERSION_STRINGIFY(a) VERSION_TOSTRING(a)
#define WAGIC_VERSION VERSION_GAME(WAGIC_VERSION_MAJOR, WAGIC_VERSION_MEDIUM, WAGIC_VERSION_MINOR, WAGIC_VERSION_REVISION) #define WAGIC_VERSION VERSION_GAME(WAGIC_VERSION_MAJOR, WAGIC_VERSION_MEDIUM, WAGIC_VERSION_MINOR)
#define WAGIC_RESOURCE_VERSION VERSION_FILE(WAGIC_VERSION_MAJOR, WAGIC_VERSION_MEDIUM, WAGIC_VERSION_MINOR) #define WAGIC_RESOURCE_VERSION VERSION_FILE(WAGIC_VERSION_MAJOR, WAGIC_VERSION_MEDIUM, WAGIC_VERSION_MINOR)
#define WAGIC_VERSION_STRING VERSION_STRINGIFY(WAGIC_VERSION) #define WAGIC_VERSION_STRING VERSION_STRINGIFY(WAGIC_VERSION)
#define WAGIC_CORE_VERSION_STRING "core_" VERSION_STRINGIFY(WAGIC_RESOURCE_VERSION) #define WAGIC_CORE_VERSION_STRING "core_" VERSION_STRINGIFY(WAGIC_RESOURCE_VERSION)
+14
View File
@@ -0,0 +1,14 @@
//
// UIScreen+Util.h
// wagic
//
// Created by Michael Nguyen on 11/27/13.
//
//
#import <UIKit/UIKit.h>
@interface UIScreen (Util)
+(BOOL)isRetinaDisplay;
@end
+23
View File
@@ -0,0 +1,23 @@
//
// UIScreen+Util.m
// wagic
//
// Created by Michael Nguyen on 11/27/13.
//
//
#include "UIScreen+Util.h"
static BOOL isRetinaScreen = NO;
static BOOL didRetinaCheck = NO;
@implementation UIScreen (Util)
+ (BOOL)isRetinaDisplay
{
if (!didRetinaCheck) {
isRetinaScreen = ([[self mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] &&
([self mainScreen].scale == 2.0));
didRetinaCheck = YES;
}
return isRetinaScreen;
}
@end
+1 -1
View File
@@ -72,7 +72,7 @@ public:
{ {
return 0; return 0;
} }
virtual const string getMenuText() virtual const char * getMenuText()
{ {
return "Ability"; return "Ability";
} }
+91 -93
View File
@@ -1081,7 +1081,7 @@ public:
ManaCost * cost = NULL); ManaCost * cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
AACounter * clone() const; AACounter * clone() const;
}; };
@@ -1100,7 +1100,7 @@ public:
bool all,ManaCost * cost = NULL); bool all,ManaCost * cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
AARemoveAllCounter * clone() const; AARemoveAllCounter * clone() const;
}; };
@@ -1110,7 +1110,7 @@ class AAResetDamage: public ActivatedAbility
public: public:
AAResetDamage(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, ManaCost * cost = NULL); AAResetDamage(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, ManaCost * cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
AAResetDamage * clone() const; AAResetDamage * clone() const;
}; };
@@ -1120,7 +1120,7 @@ public:
string named; string named;
AAFakeAbility(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target,string _newName, ManaCost * cost = NULL); AAFakeAbility(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target,string _newName, ManaCost * cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
AAFakeAbility * clone() const; AAFakeAbility * clone() const;
}; };
@@ -1131,7 +1131,7 @@ public:
AAFizzler(GameObserver* observer, int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost = NULL); AAFizzler(GameObserver* observer, int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AAFizzler* clone() const; AAFizzler* clone() const;
}; };
@@ -1160,7 +1160,7 @@ public:
string Cond; string Cond;
IfThenAbility(GameObserver* observer, int _id,MTGAbility * delayedAbility = NULL,MTGAbility * delayedElseAbility = NULL, MTGCardInstance * _source=NULL, Targetable * target = NULL, int type = 1,string Cond = ""); IfThenAbility(GameObserver* observer, int _id,MTGAbility * delayedAbility = NULL,MTGAbility * delayedElseAbility = NULL, MTGCardInstance * _source=NULL, Targetable * target = NULL, int type = 1,string Cond = "");
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
IfThenAbility * clone() const; IfThenAbility * clone() const;
~IfThenAbility(); ~IfThenAbility();
}; };
@@ -1179,7 +1179,7 @@ public:
void Update(float dt); void Update(float dt);
const string getMenuText(); const char * getMenuText();
int testDestroy(); int testDestroy();
int isReactingToTargetClick(Targetable * card); int isReactingToTargetClick(Targetable * card);
@@ -1209,7 +1209,7 @@ public:
bool CheckUserInput(JButton key); bool CheckUserInput(JButton key);
void Update(float dt); void Update(float dt);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
int testDestroy(); int testDestroy();
int isReactingToTargetClick(Targetable * card); int isReactingToTargetClick(Targetable * card);
int reactToTargetClick(Targetable * object); int reactToTargetClick(Targetable * object);
@@ -1225,7 +1225,7 @@ class AAProliferate: public ActivatedAbility
public: public:
AAProliferate(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,ManaCost * cost = NULL); AAProliferate(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,ManaCost * cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
AAProliferate * clone() const; AAProliferate * clone() const;
~AAProliferate(); ~AAProliferate();
}; };
@@ -1243,7 +1243,7 @@ public:
int resolve(); int resolve();
int addToGame(); int addToGame();
int destroy(); int destroy();
const string getMenuText(); const char * getMenuText();
MultiAbility * clone() const; MultiAbility * clone() const;
~MultiAbility(); ~MultiAbility();
}; };
@@ -1258,9 +1258,8 @@ public:
GenericActivatedAbility(GameObserver* observer, string newName,string castRestriction,int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "", GenericActivatedAbility(GameObserver* observer, string newName,string castRestriction,int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "",
int restrictions = 0, MTGGameZone * dest = NULL); int restrictions = 0, MTGGameZone * dest = NULL);
GenericActivatedAbility(const GenericActivatedAbility& other);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
void Update(float dt); void Update(float dt);
int testDestroy(); int testDestroy();
@@ -1275,7 +1274,7 @@ class AALibraryBottom: public ActivatedAbility
public: public:
AALibraryBottom(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); AALibraryBottom(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AALibraryBottom * clone() const; AALibraryBottom * clone() const;
}; };
@@ -1285,7 +1284,7 @@ class AACopier: public ActivatedAbility
public: public:
AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AACopier * clone() const; AACopier * clone() const;
}; };
//imprint //imprint
@@ -1294,7 +1293,7 @@ class AAPhaseOut: public ActivatedAbility
public: public:
AAPhaseOut(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); AAPhaseOut(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AAPhaseOut * clone() const; AAPhaseOut * clone() const;
}; };
//cloning...this makes a token thats a copy of the target. //cloning...this makes a token thats a copy of the target.
@@ -1311,7 +1310,7 @@ public:
AACloner(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL, int who = 0, AACloner(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL, int who = 0,
string abilitiesStringList = "",string typeslist = ""); string abilitiesStringList = "",string typeslist = "");
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
AACloner * clone() const; AACloner * clone() const;
~AACloner(); ~AACloner();
@@ -1327,7 +1326,7 @@ public:
AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string _name, ManaCost * _cost = NULL); AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string _name, ManaCost * _cost = NULL);
MTGGameZone * destinationZone(Targetable * target = NULL); MTGGameZone * destinationZone(Targetable * target = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
const char * getMenuText(TargetChooser * fromTc); const char * getMenuText(TargetChooser * fromTc);
AAMover * clone() const; AAMover * clone() const;
~AAMover(); ~AAMover();
@@ -1343,7 +1342,7 @@ public:
AARandomMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string tcs, string from, string to); AARandomMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string tcs, string from, string to);
MTGGameZone * destinationZone(Targetable * target = NULL,string zone = ""); MTGGameZone * destinationZone(Targetable * target = NULL,string zone = "");
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AARandomMover * clone() const; AARandomMover * clone() const;
~AARandomMover(); ~AARandomMover();
}; };
@@ -1357,7 +1356,7 @@ public:
string menu; string menu;
AABuryCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target); AABuryCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AABuryCard * clone() const; AABuryCard * clone() const;
~AABuryCard(); ~AABuryCard();
}; };
@@ -1368,7 +1367,7 @@ public:
MTGAbility * andAbility; MTGAbility * andAbility;
AADestroyCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target); AADestroyCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AADestroyCard * clone() const; AADestroyCard * clone() const;
~AADestroyCard(); ~AADestroyCard();
}; };
@@ -1379,7 +1378,7 @@ public:
MTGAbility * andAbility; MTGAbility * andAbility;
AASacrificeCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target); AASacrificeCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AASacrificeCard * clone() const; AASacrificeCard * clone() const;
~AASacrificeCard(); ~AASacrificeCard();
}; };
@@ -1390,7 +1389,7 @@ public:
MTGAbility * andAbility; MTGAbility * andAbility;
AADiscardCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target); AADiscardCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AADiscardCard * clone() const; AADiscardCard * clone() const;
~AADiscardCard(); ~AADiscardCard();
}; };
@@ -1410,7 +1409,7 @@ public:
string tcString; string tcString;
GenericTargetAbility(GameObserver* observer, string newName, string castRestriction, int _id, MTGCardInstance * _source, TargetChooser * _tc, MTGAbility * a, ManaCost * _cost = NULL, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "", int restrictions = 0, MTGGameZone * dest = NULL,string tcString =""); GenericTargetAbility(GameObserver* observer, string newName, string castRestriction, int _id, MTGCardInstance * _source, TargetChooser * _tc, MTGAbility * a, ManaCost * _cost = NULL, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "", int restrictions = 0, MTGGameZone * dest = NULL,string tcString ="");
const string getMenuText(); const char * getMenuText();
~GenericTargetAbility(); ~GenericTargetAbility();
GenericTargetAbility * clone() const; GenericTargetAbility * clone() const;
int resolve(); int resolve();
@@ -1448,7 +1447,7 @@ public:
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
return "Ninjutsu"; return "Ninjutsu";
} }
@@ -1480,7 +1479,7 @@ public:
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
return "Remove From Combat"; return "Remove From Combat";
} }
@@ -1502,7 +1501,7 @@ public:
AADrawer(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost,string nbcardsStr, int who = AADrawer(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost,string nbcardsStr, int who =
TargetChooser::UNSET,bool noReplace = false); TargetChooser::UNSET,bool noReplace = false);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AADrawer * clone() const; AADrawer * clone() const;
int getNumCards(); int getNumCards();
}; };
@@ -1522,7 +1521,7 @@ public:
ACastRestriction(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, TargetChooser * _restrictionsScope, WParsedInt * _value, bool _modifyExisting, int _zoneId, int who = TargetChooser::UNSET); ACastRestriction(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, TargetChooser * _restrictionsScope, WParsedInt * _value, bool _modifyExisting, int _zoneId, int who = TargetChooser::UNSET);
int addToGame(); int addToGame();
int destroy(); int destroy();
const string getMenuText(); const char * getMenuText();
ACastRestriction * clone() const; ACastRestriction * clone() const;
~ACastRestriction(); ~ACastRestriction();
@@ -1537,7 +1536,7 @@ public:
AInstantCastRestrictionUEOT(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, TargetChooser * _restrictionsScope, WParsedInt * _value, bool _modifyExisting, int _zoneId, int who = TargetChooser::UNSET); AInstantCastRestrictionUEOT(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, TargetChooser * _restrictionsScope, WParsedInt * _value, bool _modifyExisting, int _zoneId, int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AInstantCastRestrictionUEOT * clone() const; AInstantCastRestrictionUEOT * clone() const;
~AInstantCastRestrictionUEOT(); ~AInstantCastRestrictionUEOT();
}; };
@@ -1550,7 +1549,7 @@ public:
AALifer(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string life_s, ManaCost * _cost = NULL, AALifer(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string life_s, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET); int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AALifer * clone() const; AALifer * clone() const;
int getLife(); int getLife();
@@ -1563,7 +1562,7 @@ public:
AAWinGame(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost = NULL, int who = AAWinGame(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost = NULL, int who =
TargetChooser::UNSET); TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AAWinGame * clone() const; AAWinGame * clone() const;
}; };
@@ -1604,7 +1603,7 @@ public:
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
return Constants::MTGBasicAbilities[ability]; return Constants::MTGBasicAbilities[ability];
} }
@@ -1646,7 +1645,7 @@ public:
return InstantAbility::addToGame(); return InstantAbility::addToGame();
} }
const string getMenuText() const char * getMenuText()
{ {
return Constants::MTGBasicAbilities[ability]; return Constants::MTGBasicAbilities[ability];
} }
@@ -1707,7 +1706,7 @@ public:
return ActivatedAbility::addToGame(); return ActivatedAbility::addToGame();
} }
const string getMenuText() const char * getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -1863,7 +1862,7 @@ public:
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
sprintf(menuText,"Protection from %s",tcstr.c_str()); sprintf(menuText,"Protection from %s",tcstr.c_str());
return menuText; return menuText;
@@ -2055,7 +2054,7 @@ public:
((MTGCardInstance *) target)->addToToughness(-wppt->toughness.getValue()); ((MTGCardInstance *) target)->addToToughness(-wppt->toughness.getValue());
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
if(PT.size()) if(PT.size())
{ {
@@ -2148,7 +2147,7 @@ public:
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -2190,7 +2189,7 @@ public:
return toAdd->addToGame(); return toAdd->addToGame();
} }
const string getMenuText() const char * getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -2288,7 +2287,7 @@ public:
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
return "Regenerate"; return "Regenerate";
} }
@@ -2495,7 +2494,7 @@ public:
SAFE_DELETE(ability); SAFE_DELETE(ability);
} }
const string getMenuText() const char * getMenuText()
{ {
if(ability) if(ability)
{ {
@@ -2524,13 +2523,13 @@ public:
ALord(GameObserver* observer, int _id, MTGCardInstance * card, TargetChooser * _tc, int _includeSelf, MTGAbility * a) : ALord(GameObserver* observer, int _id, MTGCardInstance * card, TargetChooser * _tc, int _includeSelf, MTGAbility * a) :
ListMaintainerAbility(observer, _id, card), NestedAbility(a) ListMaintainerAbility(observer, _id, card), NestedAbility(a)
{ {
tc = _tc; tc = _tc;
tc->targetter = NULL; tc->targetter = NULL;
includeSelf = _includeSelf; includeSelf = _includeSelf;
if(ability->aType == MTGAbility::STANDARD_PREVENT) if(ability->aType == MTGAbility::STANDARD_PREVENT)
aType = MTGAbility::STANDARD_PREVENT; aType = MTGAbility::STANDARD_PREVENT;
} }
//returns true if it is me who created ability a attached to Damageable d //returns true if it is me who created ability a attached to Damageable d
bool isParentOf(Damageable * d, MTGAbility * a) bool isParentOf(Damageable * d, MTGAbility * a)
@@ -2608,8 +2607,7 @@ public:
int removed(MTGCardInstance * card) int removed(MTGCardInstance * card)
{ {
if (abilities.find(card) != abilities.end() if (abilities.find(card) != abilities.end() && !(forceDestroy == -1 && forcedAlive == 1))//only embelms have forcedestroy = -1 and forcedalive = 1
&& !(forceDestroy == -1 && forcedAlive == 1)) //only embelms have forcedestroy = -1 and forcedalive = 1
{ {
game->removeObserver(abilities[card]); game->removeObserver(abilities[card]);
abilities.erase(card); abilities.erase(card);
@@ -2622,7 +2620,7 @@ public:
SAFE_DELETE(ability); SAFE_DELETE(ability);
} }
const string getMenuText() const char * getMenuText()
{ {
//Special case for move //Special case for move
if (AAMover * move = dynamic_cast<AAMover *>(ability)) if (AAMover * move = dynamic_cast<AAMover *>(ability))
@@ -2808,7 +2806,7 @@ public:
int equip(MTGCardInstance * equipped); int equip(MTGCardInstance * equipped);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
int testDestroy(); int testDestroy();
int destroy(); int destroy();
@@ -3036,7 +3034,7 @@ public:
card->setAttacker(1); card->setAttacker(1);
} }
const string getMenuText() const char * getMenuText()
{ {
sprintf(menuText, "Create %s", name.c_str()); sprintf(menuText, "Create %s", name.c_str());
return menuText; return menuText;
@@ -3137,7 +3135,7 @@ public:
} }
} }
const string getMenuText() const char * getMenuText()
{ {
if(name.size()) if(name.size())
return name.c_str(); return name.c_str();
@@ -3310,7 +3308,7 @@ public:
return 0; return 0;
} }
const string getMenuText() const char * getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -3522,7 +3520,7 @@ public:
} }
} }
const string getMenuText() const char * getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -3545,7 +3543,7 @@ public:
AASetHand(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int hand, ManaCost * _cost = NULL, AASetHand(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int hand, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET); int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AASetHand * clone() const; AASetHand * clone() const;
}; };
@@ -3559,7 +3557,7 @@ public:
AALifeSet(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * life, ManaCost * _cost = NULL, AALifeSet(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * life, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET); int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AALifeSet * clone() const; AALifeSet * clone() const;
~AALifeSet(); ~AALifeSet();
@@ -3576,7 +3574,7 @@ public:
AADamager(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, string d, ManaCost * _cost = NULL, AADamager(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, string d, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET); int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
int getDamage(); int getDamage();
AADamager * clone() const; AADamager * clone() const;
@@ -3590,7 +3588,7 @@ public:
AADamagePrevent(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int preventing, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); AADamagePrevent(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int preventing, ManaCost * _cost = NULL, int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AADamagePrevent * clone() const; AADamagePrevent * clone() const;
~AADamagePrevent(); ~AADamagePrevent();
}; };
@@ -3604,7 +3602,7 @@ public:
AAAlterPoison(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int poison, ManaCost * _cost = NULL, AAAlterPoison(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int poison, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET); int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AAAlterPoison * clone() const; AAAlterPoison * clone() const;
~AAAlterPoison(); ~AAAlterPoison();
}; };
@@ -3632,7 +3630,7 @@ class AATapper: public ActivatedAbility
public: public:
AATapper(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL); AATapper(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AATapper * clone() const; AATapper * clone() const;
}; };
@@ -3642,7 +3640,7 @@ class AAUntapper: public ActivatedAbility
public: public:
AAUntapper(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL); AAUntapper(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AAUntapper * clone() const; AAUntapper * clone() const;
}; };
@@ -3663,7 +3661,7 @@ class AAFrozen: public ActivatedAbility
public: public:
AAFrozen(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL); AAFrozen(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AAFrozen * clone() const; AAFrozen * clone() const;
}; };
/* ghetto new target*/ /* ghetto new target*/
@@ -3673,7 +3671,7 @@ public:
bool retarget; bool retarget;
AANewTarget(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,bool retarget = false, ManaCost * _cost = NULL); AANewTarget(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,bool retarget = false, ManaCost * _cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AANewTarget * clone() const; AANewTarget * clone() const;
}; };
/* morph*/ /* morph*/
@@ -3684,7 +3682,7 @@ public:
AAMorph(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL); AAMorph(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL);
int resolve(); int resolve();
int testDestroy(); int testDestroy();
const string getMenuText(); const char * getMenuText();
AAMorph * clone() const; AAMorph * clone() const;
}; };
/* flip*/ /* flip*/
@@ -3696,7 +3694,7 @@ public:
AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats); AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats);
int resolve(); int resolve();
int testDestroy(); int testDestroy();
const string getMenuText(); const char * getMenuText();
AAFlip * clone() const; AAFlip * clone() const;
}; };
/* dynamic ability build*/ /* dynamic ability build*/
@@ -3761,7 +3759,7 @@ string menu;
int resolve(); int resolve();
int activateMainAbility(MTGAbility * toActivate,MTGCardInstance * source , Damageable * target); int activateMainAbility(MTGAbility * toActivate,MTGCardInstance * source , Damageable * target);
int activateStored(); int activateStored();
const string getMenuText(); const char * getMenuText();
AADynamic * clone() const; AADynamic * clone() const;
~AADynamic(); ~AADynamic();
}; };
@@ -3814,7 +3812,7 @@ public:
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
return "Swap power and toughness"; return "Swap power and toughness";
} }
@@ -3830,7 +3828,7 @@ public:
AAExchangeLife(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, ManaCost * _cost = NULL, AAExchangeLife(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET); int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AAExchangeLife * clone() const; AAExchangeLife * clone() const;
}; };
@@ -4066,7 +4064,7 @@ public:
int reapplyCountersBonus(MTGCardInstance * rtarget= NULL,bool powerapplied=false,bool toughnessapplied=false); int reapplyCountersBonus(MTGCardInstance * rtarget= NULL,bool powerapplied=false,bool toughnessapplied=false);
int testDestroy(); int testDestroy();
int destroy(); int destroy();
const string getMenuText(); const char * getMenuText();
ATransformer * clone() const; ATransformer * clone() const;
~ATransformer(); ~ATransformer();
}; };
@@ -4089,7 +4087,7 @@ public:
ATransformerInstant(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, string types = "", string abilities = "",string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<string>newAbilitiesList = vector<string>(),bool newAbilityFound = false,bool aForever = false, bool UYNT = false,string menutext = ""); ATransformerInstant(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, string types = "", string abilities = "",string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<string>newAbilitiesList = vector<string>(),bool newAbilityFound = false,bool aForever = false, bool UYNT = false,string menutext = "");
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
ATransformerInstant * clone() const; ATransformerInstant * clone() const;
~ATransformerInstant(); ~ATransformerInstant();
}; };
@@ -4105,7 +4103,7 @@ public:
WParsedPT * newWppt; WParsedPT * newWppt;
PTInstant(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, WParsedPT * wppt,string s = "",bool nonstatic = false); PTInstant(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, WParsedPT * wppt,string s = "",bool nonstatic = false);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
PTInstant * clone() const; PTInstant * clone() const;
~PTInstant(); ~PTInstant();
}; };
@@ -4164,7 +4162,7 @@ public:
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
return "Exalted"; return "Exalted";
} }
@@ -4182,7 +4180,7 @@ public:
ASwapPT * ability; ASwapPT * ability;
ASwapPTUEOT(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target); ASwapPTUEOT(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
ASwapPTUEOT * clone() const; ASwapPTUEOT * clone() const;
~ASwapPTUEOT(); ~ASwapPTUEOT();
}; };
@@ -4259,7 +4257,7 @@ public:
APreventDamageTypesUEOT(GameObserver* observer, int id, MTGCardInstance * source, string to, string from, int type = 0); APreventDamageTypesUEOT(GameObserver* observer, int id, MTGCardInstance * source, string to, string from, int type = 0);
int resolve(); int resolve();
int destroy(); int destroy();
const string getMenuText(); const char * getMenuText();
APreventDamageTypesUEOT * clone() const; APreventDamageTypesUEOT * clone() const;
~APreventDamageTypesUEOT(); ~APreventDamageTypesUEOT();
}; };
@@ -4276,7 +4274,7 @@ public:
AVanishing(GameObserver* observer, int _id, MTGCardInstance * card, ManaCost * _cost, int restrictions = 0,int amount = 0,string counterName = ""); AVanishing(GameObserver* observer, int _id, MTGCardInstance * card, ManaCost * _cost, int restrictions = 0,int amount = 0,string counterName = "");
void Update(float dt); void Update(float dt);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AVanishing * clone() const; AVanishing * clone() const;
~AVanishing(); ~AVanishing();
}; };
@@ -4298,7 +4296,7 @@ public:
void Update(float dt); void Update(float dt);
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
AUpkeep * clone() const; AUpkeep * clone() const;
~AUpkeep(); ~AUpkeep();
@@ -4324,7 +4322,7 @@ public:
MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = true,bool opponentturn = true,bool once = false); MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = true,bool opponentturn = true,bool once = false);
void Update(float dt); void Update(float dt);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
APhaseAction * clone() const; APhaseAction * clone() const;
~APhaseAction(); ~APhaseAction();
}; };
@@ -4338,7 +4336,7 @@ public:
APhaseActionGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions = 0, int _phase = APhaseActionGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions = 0, int _phase =
MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = false,bool opponentturn = false,bool once = false); MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = false,bool opponentturn = false,bool once = false);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
APhaseActionGeneric * clone() const; APhaseActionGeneric * clone() const;
~APhaseActionGeneric(); ~APhaseActionGeneric();
@@ -4358,7 +4356,7 @@ public:
void Update(float dt); void Update(float dt);
void resolveBlink(); void resolveBlink();
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
ABlink * clone() const; ABlink * clone() const;
~ABlink(); ~ABlink();
private: private:
@@ -4376,7 +4374,7 @@ public:
MTGAbility * stored; MTGAbility * stored;
ABlinkGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * _target,bool blinkueot=false,bool blinkForSource = false,bool blinkhand = false,MTGAbility * stored = NULL); ABlinkGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * _target,bool blinkueot=false,bool blinkForSource = false,bool blinkhand = false,MTGAbility * stored = NULL);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
ABlinkGeneric * clone() const; ABlinkGeneric * clone() const;
~ABlinkGeneric(); ~ABlinkGeneric();
@@ -5282,7 +5280,7 @@ public:
return 1; return 1;
} }
const string getMenuText() const char * getMenuText()
{ {
return "phase alter"; return "phase alter";
} }
@@ -5301,7 +5299,7 @@ public:
AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL, AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET); int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AADepleter * clone() const; AADepleter * clone() const;
}; };
@@ -5314,7 +5312,7 @@ public:
AAModTurn(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbTurnStr, ManaCost * _cost = NULL, AAModTurn(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbTurnStr, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET); int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AAModTurn * clone() const; AAModTurn * clone() const;
}; };
@@ -5325,7 +5323,7 @@ public:
AAShuffle(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost = NULL, int who = AAShuffle(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost = NULL, int who =
TargetChooser::UNSET); TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AAShuffle * clone() const; AAShuffle * clone() const;
}; };
@@ -5338,7 +5336,7 @@ public:
AARemoveMana(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, string ManaDesc, int who = TargetChooser::UNSET); AARemoveMana(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, string ManaDesc, int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AARemoveMana * clone() const; AARemoveMana * clone() const;
~AARemoveMana(); ~AARemoveMana();
@@ -5353,7 +5351,7 @@ public:
AARandomDiscarder(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL, AARandomDiscarder(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET); int who = TargetChooser::UNSET);
int resolve(); int resolve();
const string getMenuText(); const char * getMenuText();
AARandomDiscarder * clone() const; AARandomDiscarder * clone() const;
}; };
@@ -5525,7 +5523,7 @@ public:
int testDestroy(){return 0;}; int testDestroy(){return 0;};
void Update(float dt); void Update(float dt);
const string getMenuText(); const char * getMenuText();
int isReactingToTargetClick(Targetable * card); int isReactingToTargetClick(Targetable * card);
int reactToTargetClick(Targetable * object); int reactToTargetClick(Targetable * object);
MTGCardInstance * makeCard(); MTGCardInstance * makeCard();
@@ -5642,7 +5640,7 @@ public:
MTGAbility * abilityAltered; MTGAbility * abilityAltered;
AASetColorChosen(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, int _color = 0 ,string toAdd = ""); AASetColorChosen(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, int _color = 0 ,string toAdd = "");
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
AASetColorChosen * clone() const; AASetColorChosen * clone() const;
~AASetColorChosen(); ~AASetColorChosen();
}; };
@@ -5655,7 +5653,7 @@ public:
MTGAbility * abilityAltered; MTGAbility * abilityAltered;
AASetTypeChosen(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, int _type = 0,string menu = "error" ,string toAdd = ""); AASetTypeChosen(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, int _type = 0,string menu = "error" ,string toAdd = "");
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
AASetTypeChosen * clone() const; AASetTypeChosen * clone() const;
~AASetTypeChosen(); ~AASetTypeChosen();
}; };
@@ -5669,7 +5667,7 @@ public:
bool ANonWall; bool ANonWall;
GenericChooseTypeColor(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string toAdd = "",bool chooseColor = false,bool nonwall = false, ManaCost * cost = NULL); GenericChooseTypeColor(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string toAdd = "",bool chooseColor = false,bool nonwall = false, ManaCost * cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
GenericChooseTypeColor * clone() const; GenericChooseTypeColor * clone() const;
~GenericChooseTypeColor(); ~GenericChooseTypeColor();
@@ -5686,7 +5684,7 @@ public:
MTGAbility * abilityAltered; MTGAbility * abilityAltered;
AASetCoin(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, int side = -1,string toAdd = ""); AASetCoin(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, int side = -1,string toAdd = "");
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
AASetCoin * clone() const; AASetCoin * clone() const;
~AASetCoin(); ~AASetCoin();
}; };
@@ -5697,7 +5695,7 @@ public:
AASetCoin * setCoin; AASetCoin * setCoin;
GenericFlipACoin(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string toAdd = "", ManaCost * cost = NULL); GenericFlipACoin(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string toAdd = "", ManaCost * cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
GenericFlipACoin * clone() const; GenericFlipACoin * clone() const;
~GenericFlipACoin(); ~GenericFlipACoin();
@@ -5716,7 +5714,7 @@ public:
GenericPaidAbility(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,string _newName,string _castRestriction,string _mayCost, string toAdd, ManaCost * cost = NULL); GenericPaidAbility(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,string _newName,string _castRestriction,string _mayCost, string toAdd, ManaCost * cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
GenericPaidAbility * clone() const; GenericPaidAbility * clone() const;
~GenericPaidAbility(); ~GenericPaidAbility();
+3 -3
View File
@@ -33,7 +33,7 @@ protected:
/* /*
** Tries to render the Big version of a card picture, backups to text version in case of failure ** Tries to render the Big version of a card picture, backups to text version in case of failure
*/ */
static void RenderBig(MTGCard * card, const Pos& pos, bool thumb = false); static void RenderBig(MTGCard * card, const Pos& pos);
static void RenderCountersBig(MTGCard * card, const Pos& pos, int drawMode = DrawMode::kNormal); static void RenderCountersBig(MTGCard * card, const Pos& pos, int drawMode = DrawMode::kNormal);
static void AlternateRender(MTGCard * card, const Pos& pos); static void AlternateRender(MTGCard * card, const Pos& pos);
@@ -55,8 +55,8 @@ public:
virtual void Render(); virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);
void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false); void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal);
static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false); static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal);
static JQuadPtr AlternateThumbQuad(MTGCard * card); static JQuadPtr AlternateThumbQuad(MTGCard * card);
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
+2 -1
View File
@@ -101,9 +101,10 @@ public:
int removeType(string value, int removeAll = 0); int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0); int removeType(int value, int removeAll = 0);
bool hasSubtype(int _subtype); bool hasSubtype(int _subtype);
bool hasSubtype(const char * _subtype);
bool hasSubtype(const string& _subtype); bool hasSubtype(const string& _subtype);
bool hasType(int _type); bool hasType(int _type);
bool hasType(const string& type); bool hasType(const char * type);
void setManaCost(const string& value); void setManaCost(const string& value);
ManaCost * getManaCost(); ManaCost * getManaCost();
-45
View File
@@ -1,45 +0,0 @@
#ifndef _CAROUSEL_DECK_VIEW_H_
#define _CAROUSEL_DECK_VIEW_H_
#include "DeckView.h"
#include "Easing.h"
class CarouselDeckView : public DeckView
{
private:
static const float max_scale;
static const float x_center;
static const float right_border;
static const float slide_animation_duration;
static const float scroll_animation_duration;
public:
CarouselDeckView();
virtual ~CarouselDeckView();
void Reset();
void UpdateViewState(float dt);
void UpdateCardPosition(int index);
void renderCard(int index)
{
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 changePositionAnimated(int offset);
void changeFilterAnimated(int offset);
MTGCard *getActiveCard();
private:
float mScrollOffset, mSlideOffset;
InOutQuadEasing mScrollEasing;
InOutQuadEasing mSlideEasing;
};
#endif //_CAROUSEL_DECK_VIEW_H_
+1 -1
View File
@@ -17,7 +17,7 @@ private:
StatsWrapper *stw; StatsWrapper *stw;
public: public:
DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const string& _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL); DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const char * _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL);
void Render(); void Render();
virtual ~DeckEditorMenu(); virtual ~DeckEditorMenu();
}; };
+1 -1
View File
@@ -79,7 +79,7 @@ public:
virtual void Render(); virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);
using JGuiController::Add; using JGuiController::Add;
virtual void Add(int id, const string& Text, const string& desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL); virtual void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
virtual void Close(); virtual void Close();
void updateScroller(); void updateScroller();
void RenderBackground(); void RenderBackground();
+3 -1
View File
@@ -77,7 +77,9 @@ public:
} }
// Setters // Setters
void setDescription( const string& description ) { mDescription = description; } void setDescription( const string description ) { mDescription = description; };
;
}; };
#endif #endif
+1 -1
View File
@@ -98,7 +98,7 @@ public:
string getManaColorIndex(); string getManaColorIndex();
void updateStats(string filename, MTGAllCards * collection); void updateStats(string filename, MTGAllCards * collection);
void updateStats(DeckDataWrapper *mtgDeck); void updateStats(DeckDataWrapper *mtgDeck);
int countCardsByType(const string& _type, DeckDataWrapper * myDeck); int countCardsByType(const char * _type, DeckDataWrapper * myDeck);
float noLuck(int n, int a, int x); float noLuck(int n, int a, int x);
vector<string> aiDeckNames; vector<string> aiDeckNames;
-241
View File
@@ -1,241 +0,0 @@
#ifndef _DECK_VIEW_H_
#define _DECK_VIEW_H_
#include <vector>
#include "MTGCard.h"
#include "DeckDataWrapper.h"
#include "WFont.h"
#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;
/*! \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();
/*! \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);
/*! \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();
/*! \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;
/*! \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;
/*! \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;
/*! \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;
/*! \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_
-245
View File
@@ -1,245 +0,0 @@
#ifndef _EASING_H_
#define _EASING_H_
/*! \brief A class for eased floats for use in animations
*
* Animations often defines values a floating point variable
* should have at given times and interpolates between them to
* calculate the value of that variable at any given intermediate
* time step.
*
* The simplest case would be linear interpolation:
* Suppose a float "position" should be a at time = 0 and
* b at time = x. If the current time is y, the value of
* "position" is then a + (b-a)*y/x.
*
* This class defines the interface needed to implement different
* kind of interpolations with a common interface. See
* http://www.gizma.com/easing/ for more information for a few
* examples.
*/
class Easing
{
public:
/*! \brief The value at the start of an animation.
*
* start_value is undefined if no animation is running.
*/
float start_value;
/*! \brief The amount the value should change during the animation.
*
* delta_value is undefined if no animation is running.
*/
float delta_value;
/*! \brief The current value.
*
* Use this member to read the value or to write the value without
* to animate intermediate values and. Make sure that the easing
* is not used once value is deleted.
*/
float& value;
/*! \brief The duration the animation should take
*
* It is not relevant which unit is used. This value is undefined
* if no animation is running.
*/
float duration;
/*! \brief The accumulated time the animation did run until now.
*
* It is not relevant which unit is used. This values is undefined
* if no animation is running.
*/
float time_acc;
/*! \brief Sets Easing::float to val and sets the animation as not running.
*
* Make sure that the easing is not used once value is deleted.
*
* \param val The value to ease
*/
Easing(float& val): start_value(val), delta_value(0), value(val), duration(0), time_acc(0)
{
}
/*! \brief Resets the animation to its initial value
*
* This method does set the value to the start value and sets the passed time to 0.
* If there is no animation animation running, the resulting value is undefined.
*/
void reset()
{
value = start_value;
time_acc = 0;
}
/*! \brief Finishes the animation immediately
*
* Sets the value to the animations target value and the passed time to the
* animations duration. If there is no animation running, the behaviour is undefined.
*/
void finish()
{
value = start_value + delta_value;
time_acc = duration;
}
/*! \brief Lets dt time pass
*
* Advances the animation by dt time units and updates the value accordingly.
*
* \val dt The amount of time to jump forward
*/
void update(float dt)
{
if(time_acc < duration)
{
time_acc += dt;
if(time_acc > duration)
{
time_acc = duration;
value = start_value + delta_value;
}
else
{
updateValue();
}
}
}
/*! \brief Calculates the value from all other members.
*
* This method gets implemented by all specific easing classes.
*/
virtual void updateValue() = 0;
/*! \brief Starts the animation.
*
* Starts the interpolation from the current value (now) to
* targetValue (in now + _duration).
*
* If the animation is currently running, it gets replaced.
*
* \param targetValue The value to interpolate to
* \param _duration The duration the interpolation should take
*/
void start(float targetValue, float _duration)
{
start_value = value;
delta_value = targetValue - start_value;
time_acc = 0;
duration = _duration;
}
/*! \brief Translates the current value and the target value by delta_value
*
* This method is mainly used for trickery. Suppose there is one object in the
* middle of the screen that should move to the top until it is outside of the
* screen and gets replaced by a second one entering the screen from the lower
* side once the first one disappeared. This method can be used to simulate this
* effect with one animation by translating (i.e. moving) the animation from the
* top to the bottom:
*
* Object1 and object2 are the same object: object1 whose y position is bound to value
* To start the transition, use start(SCREEN_HEIGHT, desired time); Once the first
* object left the screen (i.e. object.y < 0), change objects appearance to object2
* and translate the easing by (SCREEN_HEIGHT).
*
* \param delta_value The change in start_value and value
*/
void translate(float delta_value)
{
start_value += delta_value;
value += delta_value;
}
/*! \brief Returns if the passed time exceeds duration.
*
* If ther is no animation running, it is ensured that this is true.
*/
bool finished()
{
return time_acc >= duration;
}
};
/*! \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
{
public:
/*! \brief Calls Easing::Easing(val).
*
* \see Easing::Easing(float& val)
*/
InOutQuadEasing(float& val): Easing(val) {}
/*! \brief Implements the value calculation.
*
* \see Easing::updateValue()
*/
void updateValue()
{
float time_tmp = (time_acc * 2) / duration;
if (time_tmp < 1)
{
value = (float)(delta_value * 0.5 * time_tmp * time_tmp + start_value);
}
else
{
time_tmp -= 1;
value = (float)(- delta_value * 0.5 * (time_tmp * (time_tmp - 2) - 1) + start_value);
}
}
};
#endif //_EASING_H_
+2 -2
View File
@@ -98,8 +98,8 @@ class GameObserver{
int cardClick(MTGCardInstance * card,Targetable * _object = NULL, bool log = true); int cardClick(MTGCardInstance * card,Targetable * _object = NULL, bool log = true);
GamePhase getCurrentGamePhase(); GamePhase getCurrentGamePhase();
void setCurrentGamePhase(GamePhase phase) { mCurrentGamePhase = phase; }; void setCurrentGamePhase(GamePhase phase) { mCurrentGamePhase = phase; };
const string& getCurrentGamePhaseName(); const char * getCurrentGamePhaseName();
const string& getNextGamePhaseName(); const char * getNextGamePhaseName();
void nextCombatStep(); void nextCombatStep();
void userRequestNextGamePhase(bool allowInterrupt = true, bool log = true); void userRequestNextGamePhase(bool allowInterrupt = true, bool log = true);
void cleanupPhase(); void cleanupPhase();
+1
View File
@@ -17,6 +17,7 @@ private:
WSrcCards * setSrc; WSrcCards * setSrc;
SimpleMenu * menu; SimpleMenu * menu;
bool showMenu; bool showMenu;
bool showAlt;
bool saveMe; bool saveMe;
int mState; int mState;
int mDetailItem; int mDetailItem;
+54 -26
View File
@@ -19,7 +19,22 @@
#include "WGui.h" #include "WGui.h"
#include "InteractiveButton.h" #include "InteractiveButton.h"
class DeckView; #define NO_USER_ACTIVITY_HELP_DELAY 10
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
enum
{
STAGE_TRANSITION_RIGHT = 0,
STAGE_TRANSITION_LEFT = 1,
STAGE_WAITING = 2,
STAGE_TRANSITION_UP = 3,
STAGE_TRANSITION_DOWN = 4,
STAGE_ONSCREEN_MENU = 5,
STAGE_WELCOME = 6,
STAGE_MENU = 7,
STAGE_FILTERS = 8,
STAGE_TRANSITION_SELECTED = 9
};
// TODO: need a better name for MENU_FIRST_MENU, this is reused for the 1st submenu of // TODO: need a better name for MENU_FIRST_MENU, this is reused for the 1st submenu of
// available options in the duel menu // available options in the duel menu
@@ -29,7 +44,7 @@ enum
MENU_DECK_SELECTION = 10, MENU_DECK_SELECTION = 10,
MENU_DECK_BUILDER = 11, MENU_DECK_BUILDER = 11,
MENU_FIRST_DUEL_SUBMENU = 102, MENU_FIRST_DUEL_SUBMENU = 102,
MENU_LANGUAGE_SELECTION = 103 MENU_LANGUAGE_SELECTION = 103,
}; };
// enums for menu options // enums for menu options
@@ -49,69 +64,79 @@ enum DECK_VIEWER_MENU_ITEMS
MENU_ITEM_NO = 21, MENU_ITEM_NO = 21,
MENU_ITEM_FILTER_BY = 22, MENU_ITEM_FILTER_BY = 22,
MENUITEM_MORE_INFO = kInfoMenuID MENUITEM_MORE_INFO = kInfoMenuID
}; };
#define ALL_COLORS -1
#define ROTATE_LEFT 1;
#define ROTATE_RIGHT 0;
#define HIGH_SPEED 15.0
#define MED_SPEED 5.0f
#define LOW_SPEED 1.5
#define MAX_SAVED_FILTERS Constants::NB_Colors + 1
#define CARDS_DISPLAYED 10
class GameStateDeckViewer: public GameState, public JGuiListener class GameStateDeckViewer: public GameState, public JGuiListener
{ {
private: private:
enum DeckViewerStages
{
STAGE_WAITING = 0,
STAGE_ONSCREEN_MENU,
STAGE_WELCOME,
STAGE_MENU,
STAGE_FILTERS
};
vector<JQuadPtr> mIcons; vector<JQuadPtr> mIcons;
JQuadPtr pspIcons[8]; JQuadPtr pspIcons[8];
JTexture * pspIconsTexture; JTexture * pspIconsTexture;
float last_user_activity; float last_user_activity;
float onScreenTransition; float onScreenTransition;
DeckViewerStages mStage; float mRotation;
float mSlide;
int mAlpha;
int mStage;
int useFilter;
JMusic * bgMusic; JMusic * bgMusic;
int lastPos;
int lastTotal;
int mSelected;
InteractiveButton *toggleDeckButton, *sellCardButton, *statsPrevButton, *filterButton, *toggleViewButton; InteractiveButton *toggleDeckButton, *sellCardButton, *statsPrevButton, *filterButton;
WGuiFilters * filterMenu; WGuiFilters * filterMenu;
WSrcDeckViewer * source; WSrcDeckViewer * source;
DeckEditorMenu * welcome_menu; DeckEditorMenu * welcome_menu;
SimpleMenu * subMenu; SimpleMenu * subMenu;
DeckEditorMenu * deckMenu; DeckEditorMenu * menu;
PriceList* pricelist; PriceList* pricelist;
PlayerData * playerdata; PlayerData * playerdata;
int price;
DeckDataWrapper * displayed_deck;
DeckDataWrapper * myDeck; DeckDataWrapper * myDeck;
DeckDataWrapper * myCollection; DeckDataWrapper * myCollection;
StatsWrapper * mStatsWrapper; MTGCard * cardIndex[CARDS_DISPLAYED];
StatsWrapper *stw;
int hudAlpha; int hudAlpha;
string newDeckname; string newDeckname;
bool isAIDeckSave; bool isAIDeckSave;
bool mSwitching; bool mSwitching;
enum AvailableView{
CAROUSEL_VIEW,
GRID_VIEW
};
DeckView* mView;
AvailableView mCurrentView;
void saveDeck(); //Saves the deck and additional necessary information void saveDeck(); //Saves the deck and additional necessary information
void saveAsAIDeck(string deckName); // saves deck as an AI Deck void saveAsAIDeck(string deckName); // saves deck as an AI Deck
int getCurrentPos();
void sellCard(); void sellCard();
void setButtonState(bool state); void setButtonState(bool state);
bool userPressedButton(); bool userPressedButton();
void RenderButtons(); void RenderButtons();
void setupView(AvailableView view, DeckDataWrapper *deck);
void toggleView(); pair<float, float> cardsCoordinates[CARDS_DISPLAYED];
public: public:
GameStateDeckViewer(GameApp* parent); GameStateDeckViewer(GameApp* parent);
virtual ~GameStateDeckViewer(); virtual ~GameStateDeckViewer();
void updateDecks(); void updateDecks();
void rotateCards(int direction);
void loadIndexes();
void updateFilters(); void updateFilters();
void rebuildFilters(); void rebuildFilters();
void toggleCollection(); void switchDisplay();
void Start(); void Start();
virtual void End(); virtual void End();
void addRemove(MTGCard * card); void addRemove(MTGCard * card);
@@ -120,8 +145,11 @@ public:
void renderSlideBar(); void renderSlideBar();
void renderDeckBackground(); void renderDeckBackground();
void renderOnScreenMenu(); void renderOnScreenMenu();
virtual void renderCard(int id, float rotation);
virtual void renderCard(int id);
virtual void Render(); virtual void Render();
int loadDeck(int deckid); int loadDeck(int deckid);
void LoadDeckStatistics(int deckId);
void OnScroll(int inXVelocity, int inYVelocity); void OnScroll(int inXVelocity, int inYVelocity);
+1
View File
@@ -65,6 +65,7 @@ private:
JQuadPtr pspIcons[8]; JQuadPtr pspIcons[8];
WSrcCards * srcCards; WSrcCards * srcCards;
TaskList * taskList; TaskList * taskList;
float mElapsed;
WGuiMenu * shopMenu; WGuiMenu * shopMenu;
WGuiFilters * filterMenu; //Filter menu slides in sideways from right, or up from bottom. WGuiFilters * filterMenu; //Filter menu slides in sideways from right, or up from bottom.
WGuiCardImage * bigDisplay; WGuiCardImage * bigDisplay;
-154
View File
@@ -1,154 +0,0 @@
#ifndef _GRID_DECK_VIEW_H
#define _GRID_DECK_VIEW_H
#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:
static const float scroll_animation_duration;
static const float slide_animation_duration;
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);
/*! \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);
/*! \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:
/*! \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
+1 -2
View File
@@ -6,9 +6,8 @@
#include <hge/hgeparticle.h> #include <hge/hgeparticle.h>
#include "JGE.h" #include "JGE.h"
#include "MTGDefinitions.h" #include "MTGDefinitions.h"
#include "Pos.h" #include "GameApp.h"
#include "GuiLayers.h" #include "GuiLayers.h"
#include "WResource_Fwd.h"
class ManaIcon : public Pos class ManaIcon : public Pos
{ {
+3 -13
View File
@@ -4,25 +4,15 @@
#include "GuiLayers.h" #include "GuiLayers.h"
#include "PhaseRing.h" #include "PhaseRing.h"
#include "WEvent.h" #include "WEvent.h"
#include "PlayGuiObject.h"
#include "Easing.h"
class GuiPhaseBar: public GuiLayer, public PlayGuiObject class GuiPhaseBar: public GuiLayer, public PlayGuiObject
{ {
private: protected:
static const float zoom_big; Phase* phase;
static const float zoom_small;
static const float step;
int displayedPhaseId;
float angle; float angle;
float zoomFactor; float zoomFactor;
OutQuadEasing angleEasing; DuelLayers* mpDuelLayers;
InOutQuadEasing zoomFactorEasing;
DuelLayers* mpDuelLayers;
void DrawGlyph(JQuad *inQuad, int phaseId, float x, float y, float scale);
public: public:
GuiPhaseBar(DuelLayers* duelLayers); GuiPhaseBar(DuelLayers* duelLayers);
~GuiPhaseBar(); ~GuiPhaseBar();
+1
View File
@@ -47,6 +47,7 @@ protected:
{ {
static const float HEIGHT; static const float HEIGHT;
unsigned attackers; unsigned attackers;
unsigned blockers;
unsigned currentAttacker; unsigned currentAttacker;
float height; float height;
-1
View File
@@ -28,7 +28,6 @@ const int kNextStatsButtonId = 10005;
const int kPrevStatsButtonId = 10006; const int kPrevStatsButtonId = 10006;
const int kCycleCardsButtonId = 10007; const int kCycleCardsButtonId = 10007;
const int kShowCardListButtonId = 10008; const int kShowCardListButtonId = 10008;
const int kSwitchViewButton = 10009;
class InteractiveButton: public SimpleButton class InteractiveButton: public SimpleButton
{ {
+3 -3
View File
@@ -317,7 +317,7 @@ public:
virtual TargetAbility* clone() const = 0; virtual TargetAbility* clone() const = 0;
virtual void Render(); virtual void Render();
virtual int resolve(); virtual int resolve();
virtual const string getMenuText(); virtual const char * getMenuText();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
@@ -436,7 +436,7 @@ public:
void Update(float dt); void Update(float dt);
virtual GenericTriggeredAbility* clone() const; virtual GenericTriggeredAbility* clone() const;
const string getMenuText(); const char * getMenuText();
~GenericTriggeredAbility(); ~GenericTriggeredAbility();
}; };
@@ -525,7 +525,7 @@ public:
int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL); int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL);
int resolve(); int resolve();
int reactToClick(MTGCardInstance* _card); int reactToClick(MTGCardInstance* _card);
const string getMenuText(); const char * getMenuText();
~AManaProducer(); ~AManaProducer();
virtual AManaProducer * clone() const; virtual AManaProducer * clone() const;
}; };
+4 -4
View File
@@ -129,11 +129,11 @@ public:
//types //types
void addType(const string& type_text); void addType(char * type_text);
virtual void addType(int id); virtual void addType(int id);
void setType(const string& type_text); void setType(const char * type_text);
void setSubtype(const string &value); void setSubtype( string value);
int removeType(const string &value, int removeAll = 0); int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0); int removeType(int value, int removeAll = 0);
//dangerranking is a hint to Ai which creatures are the ones it should be targetting for effects. //dangerranking is a hint to Ai which creatures are the ones it should be targetting for effects.
+8 -9
View File
@@ -4,6 +4,7 @@
#define MTG_ERROR -1 #define MTG_ERROR -1
#include "MTGDefinitions.h" #include "MTGDefinitions.h"
#include "GameApp.h"
#include "WResourceManager.h" #include "WResourceManager.h"
#include <dirent.h> #include <dirent.h>
#include <Threading.h> #include <Threading.h>
@@ -18,7 +19,7 @@ class MTGPack;
class MTGSetInfo class MTGSetInfo
{ {
public: public:
MTGSetInfo(const string& _id); MTGSetInfo(string _id);
~MTGSetInfo(); ~MTGSetInfo();
string id; //Short name: 10E, RAV, etc. Automatic from folder. string id; //Short name: 10E, RAV, etc. Automatic from folder.
string author; //Author of set, for crediting mod makers, etc. string author; //Author of set, for crediting mod makers, etc.
@@ -69,7 +70,7 @@ public:
MTGSets(); MTGSets();
~MTGSets(); ~MTGSets();
int Add(const string& subtype); int Add(const char * subtype);
int findSet(string value); int findSet(string value);
int findBlock(string s); int findBlock(string s);
int size(); int size();
@@ -126,10 +127,8 @@ public:
MTGCard * getCardByName(string name); MTGCard * getCardByName(string name);
void loadFolder(const string& folder, const string& filename="" ); void loadFolder(const string& folder, const string& filename="" );
int load(const string& config_file); int load(const char * config_file, const char * setName = NULL, int autoload = 1);
int load(const string& config_file, const string& setName); int countByType(const char * _type);
int load(const string& config_file, int set_id);
int countByType(const string& _type);
int countByColor(int color); int countByColor(int color);
int countBySet(int setId); int countBySet(int setId);
int totalCards(); int totalCards();
@@ -137,7 +136,7 @@ public:
static int findType(string subtype, bool forceAdd = true) { static int findType(string subtype, bool forceAdd = true) {
boost::mutex::scoped_lock lock(instance->mMutex); boost::mutex::scoped_lock lock(instance->mMutex);
int result = instance->subtypesList.find(subtype, forceAdd); int result = instance->subtypesList.find(subtype, forceAdd);
return result; return result;
}; };
static int add(string value, unsigned int parentType) { static int add(string value, unsigned int parentType) {
@@ -219,8 +218,8 @@ public:
int totalCards(); int totalCards();
int totalPrice(); int totalPrice();
MTGDeck(MTGAllCards * _allcards); MTGDeck(MTGAllCards * _allcards);
MTGDeck(const string& config_file, MTGAllCards * _allcards, int meta_only = 0,int difficultySetting = 0); MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0,int difficultySetting = 0);
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const string& subtype = "", int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL,
int * colors = NULL, int nbcolors = 0); int * colors = NULL, int nbcolors = 0);
int add(int cardid); int add(int cardid);
int add(MTGDeck * deck); // adds the contents of "deck" into myself int add(MTGDeck * deck); // adds the contents of "deck" into myself
+2 -3
View File
@@ -218,8 +218,7 @@ class Constants
soulbond = 100, soulbond = 100,
LURE = 101, LURE = 101,
NOLEGEND = 102, NOLEGEND = 102,
CANPLAYFROMGRAVEYARD = 103, NB_BASIC_ABILITIES = 103,
NB_BASIC_ABILITIES = 104,
RARITY_S = 'S', //Special Rarity RARITY_S = 'S', //Special Rarity
@@ -294,7 +293,7 @@ class Constants
static map<string,int> MTGBasicAbilitiesMap; static map<string,int> MTGBasicAbilitiesMap;
static const char* MTGBasicAbilities[]; static const char* MTGBasicAbilities[];
static const string MTGPhaseNames[]; static const char* MTGPhaseNames[];
static const char* MTGPhaseCodeNames[]; static const char* MTGPhaseCodeNames[];
static int GetBasicAbilityIndex(string mtgAbility); static int GetBasicAbilityIndex(string mtgAbility);
+1 -1
View File
@@ -95,7 +95,7 @@ class MTGGameZone {
void cleanupPhase(); void cleanupPhase();
void beforeBeginPhase(); void beforeBeginPhase();
unsigned int countByType(const string &value); unsigned int countByType(const char * value);
unsigned int countByCanTarget(TargetChooser * tc); unsigned int countByCanTarget(TargetChooser * tc);
unsigned int countTotalManaSymbols(TargetChooser * tc, int color); unsigned int countTotalManaSymbols(TargetChooser * tc, int color);
MTGCardInstance * findByName(string name); MTGCardInstance * findByName(string name);
+16 -32
View File
@@ -66,7 +66,6 @@ public:
MTGEventBonus(GameObserver* observer, int _id); MTGEventBonus(GameObserver* observer, int _id);
virtual MTGEventBonus * clone() const; virtual MTGEventBonus * clone() const;
}; };
class MTGPutInPlayRule: public PermanentAbility class MTGPutInPlayRule: public PermanentAbility
{ {
public: public:
@@ -74,7 +73,7 @@ public:
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGPutInPlayRule(GameObserver* observer, int _id); MTGPutInPlayRule(GameObserver* observer, int _id);
const string getMenuText() const char * getMenuText()
{ {
return "cast card normally"; return "cast card normally";
} }
@@ -88,7 +87,7 @@ public:
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGKickerRule(GameObserver* observer, int _id); MTGKickerRule(GameObserver* observer, int _id);
const string getMenuText() const char * getMenuText()
{ {
return "pay kicker"; return "pay kicker";
} }
@@ -106,7 +105,7 @@ public:
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGAlternativeCostRule(GameObserver* observer, int _id); MTGAlternativeCostRule(GameObserver* observer, int _id);
const string getMenuText() const char * getMenuText()
{ {
if(alternativeName.size()) if(alternativeName.size())
return alternativeName.c_str(); return alternativeName.c_str();
@@ -122,7 +121,7 @@ public:
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGBuyBackRule(GameObserver* observer, int _id); MTGBuyBackRule(GameObserver* observer, int _id);
const string getMenuText() const char * getMenuText()
{ {
return "cast and buy back"; return "cast and buy back";
} }
@@ -137,7 +136,7 @@ public:
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGFlashBackRule(GameObserver* observer, int _id); MTGFlashBackRule(GameObserver* observer, int _id);
const string getMenuText() const char * getMenuText()
{ {
return "flash back"; return "flash back";
} }
@@ -151,7 +150,7 @@ public:
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGRetraceRule(GameObserver* observer, int _id); MTGRetraceRule(GameObserver* observer, int _id);
const string getMenuText() const char * getMenuText()
{ {
return "retrace"; return "retrace";
} }
@@ -166,28 +165,13 @@ public:
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGMorphCostRule(GameObserver* observer, int _id); MTGMorphCostRule(GameObserver* observer, int _id);
const string getMenuText() const char * getMenuText()
{ {
return "play morphed"; return "play morphed";
} }
virtual MTGMorphCostRule * clone() const; virtual MTGMorphCostRule * clone() const;
}; };
class MTGPlayFromGraveyardRule: public MTGAlternativeCostRule
{
public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const;
MTGPlayFromGraveyardRule(GameObserver* observer, int _id);
const string getMenuText()
{
return "cast card from graveyard";
}
virtual MTGPlayFromGraveyardRule * clone() const;
};
class MTGSuspendRule: public MTGAlternativeCostRule class MTGSuspendRule: public MTGAlternativeCostRule
{ {
public: public:
@@ -197,7 +181,7 @@ public:
string suspendmenu; string suspendmenu;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGSuspendRule(GameObserver* observer, int _id); MTGSuspendRule(GameObserver* observer, int _id);
const string getMenuText(); const char * getMenuText();
virtual MTGSuspendRule * clone() const; virtual MTGSuspendRule * clone() const;
}; };
@@ -211,7 +195,7 @@ public:
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGAttackRule(GameObserver* observer, int _id); MTGAttackRule(GameObserver* observer, int _id);
const string getMenuText() const char * getMenuText()
{ {
return "Attacker"; return "Attacker";
} }
@@ -229,7 +213,7 @@ public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
MTGPlaneswalkerAttackRule(GameObserver* observer, int _id); MTGPlaneswalkerAttackRule(GameObserver* observer, int _id);
const string getMenuText() const char * getMenuText()
{ {
return "Attack Planeswalker"; return "Attack Planeswalker";
} }
@@ -242,7 +226,7 @@ public:
MTGCardInstance* attacker; MTGCardInstance* attacker;
AAPlaneswalkerAttacked(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target); AAPlaneswalkerAttacked(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target);
int resolve(); int resolve();
const string getMenuText(); const char* getMenuText();
AAPlaneswalkerAttacked * clone() const; AAPlaneswalkerAttacked * clone() const;
~AAPlaneswalkerAttacked(); ~AAPlaneswalkerAttacked();
}; };
@@ -268,7 +252,7 @@ public:
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGBlockRule(GameObserver* observer, int _id); MTGBlockRule(GameObserver* observer, int _id);
const string getMenuText(); const char * getMenuText();
virtual MTGBlockRule * clone() const; virtual MTGBlockRule * clone() const;
~MTGBlockRule(); ~MTGBlockRule();
}; };
@@ -402,7 +386,7 @@ public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card, int id); int reactToClick(MTGCardInstance * card, int id);
const string getMenuText() const char * getMenuText()
{ {
return "Momir"; return "Momir";
} }
@@ -422,7 +406,7 @@ public:
MTGCardInstance * genEquip(int id); MTGCardInstance * genEquip(int id);
MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCards * _collection); MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCards * _collection);
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
const string getMenuText() const char * getMenuText()
{ {
return "Stone Hewer"; return "Stone Hewer";
} }
@@ -435,7 +419,7 @@ class MTGHermitRule: public PermanentAbility
public: public:
MTGHermitRule(GameObserver* observer, int _id); MTGHermitRule(GameObserver* observer, int _id);
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
const string getMenuText() const char * getMenuText()
{ {
return "Hermit"; return "Hermit";
} }
@@ -463,7 +447,7 @@ public:
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
const string getMenuText() const char * getMenuText()
{ {
return "Deathtouch"; return "Deathtouch";
} }
-2
View File
@@ -1,8 +1,6 @@
#ifndef OBJECTANALYTICS_H #ifndef OBJECTANALYTICS_H
#define OBJECTANALYTICS_H #define OBJECTANALYTICS_H
#include <boost/cstdint.hpp>
#ifdef _DEBUG #ifdef _DEBUG
#define TRACK_OBJECT_USAGE #define TRACK_OBJECT_USAGE
#endif #endif
+1
View File
@@ -7,6 +7,7 @@
#include <JGui.h> #include <JGui.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include "GameApp.h"
#include "GameStateOptions.h" #include "GameStateOptions.h"
#include "WFilter.h" #include "WFilter.h"
#include "WDataSrc.h" #include "WDataSrc.h"
+1 -1
View File
@@ -62,7 +62,7 @@ public:
int addCombatAfter(Player* player, int after_id, bool withMain = false); int addCombatAfter(Player* player, int after_id, bool withMain = false);
int addPhaseAfter(GamePhase id, Player* player, int after_id); int addPhaseAfter(GamePhase id, Player* player, int after_id);
int removePhase(int id); int removePhase(int id);
const string& phaseName(int id); const char * phaseName(int id);
static GamePhase phaseStrToInt(string s); static GamePhase phaseStrToInt(string s);
static string phaseIntToStr(int id); static string phaseIntToStr(int id);
+1 -3
View File
@@ -20,18 +20,16 @@ public:
~PriceList(); ~PriceList();
int save(); int save();
int getSellPrice(int cardid); int getSellPrice(int cardid);
int getSellPrice(MTGCard* card);
int getPurchasePrice(int cardid); int getPurchasePrice(int cardid);
int getPrice(MTGCard *card);
int getPrice(int cardId); int getPrice(int cardId);
int setPrice(int cardId, int price); int setPrice(int cardId, int price);
int setPrice(MTGCard *card, int price);
int getOtherPrice(int amt); int getOtherPrice(int amt);
static float difficultyScalar(float price, int cardid = 0); static float difficultyScalar(float price, int cardid = 0);
static void updateKey() static void updateKey()
{ {
randomKey = rand(); randomKey = rand();
} }
;
}; };
#endif #endif
+1 -1
View File
@@ -43,7 +43,7 @@ public:
virtual bool CheckUserInput(JButton key); virtual bool CheckUserInput(JButton key);
virtual void Update(float dt); virtual void Update(float dt);
using JGuiController::Add; using JGuiController::Add;
virtual void Add(int id, const string &Text, string desc = "", bool forceFocus = false); virtual void Add(int id, const char * Text, string desc = "", bool forceFocus = false);
int getmCurr(){return mCurr;} int getmCurr(){return mCurr;}
float getWidth(){return mWidth; } float getWidth(){return mWidth; }
virtual void Close(); virtual void Close();
+1
View File
@@ -20,6 +20,7 @@ class SimplePopup: public JGuiController
private: private:
float mWidth, mX, mY; float mWidth, mX, mY;
int mMaxLines; int mMaxLines;
int mFontId;
DeckMetaData * mDeckInformation; DeckMetaData * mDeckInformation;
string mTitle; string mTitle;
WFont *mTextFont; WFont *mTextFont;
+2 -13
View File
@@ -2,15 +2,6 @@
#define TASK_H #define TASK_H
#include <vector> #include <vector>
#include <string>
#include "Easing.h"
using namespace std;
class GameObserver;
class JQuad;
class JTexture;
// Task type constant // Task type constant
@@ -79,11 +70,8 @@ class TaskList
{ {
protected: protected:
string fileName; string fileName;
float vPos; float vPos;
OutQuadEasing vPosInEasing; float mElapsed;
InQuadEasing vPosOutEasing;
int mState; int mState;
JQuad * mBg[9]; JQuad * mBg[9];
JTexture * mBgTex; JTexture * mBgTex;
@@ -107,6 +95,7 @@ public:
{ {
return mState; return mState;
} }
;
void addTask(string params, bool rand = false); void addTask(string params, bool rand = false);
void addTask(Task *task); void addTask(Task *task);
void addRandomTask(int diff = 100); void addRandomTask(int diff = 100);
-2
View File
@@ -1,5 +1,3 @@
#include "MTGDeck.h"
#ifndef _WFILTER_H_ #ifndef _WFILTER_H_
#define _WFILTER_H_ #define _WFILTER_H_
/** /**
-1
View File
@@ -8,7 +8,6 @@
class hgeDistortionMesh; class hgeDistortionMesh;
class GameStateOptions; class GameStateOptions;
class SimpleMenu;
/** /**
@defgroup WGui Basic Gui @defgroup WGui Basic Gui
+4 -4
View File
@@ -1,12 +1,12 @@
#ifndef WRESOURCE_FWD_H #ifndef WRESOURCE_FWD_H
#define WRESOURCE_FWD_H #define WRESOURCE_FWD_H
#if (__cplusplus > 199711L) #ifndef WP8
#include <memory>
typedef std::shared_ptr<JQuad> JQuadPtr;
#else
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
typedef boost::shared_ptr<JQuad> JQuadPtr; typedef boost::shared_ptr<JQuad> JQuadPtr;
#else
#include <memory>
typedef std::shared_ptr<JQuad> JQuadPtr;
#endif #endif
#endif #endif
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef _DEBUG_H_ #ifndef _DEBUG_H_
#define _DEBUG_H_ #define _DEBUG_H_
#if ((defined WIN32) || (defined WP8)) && !defined(__MINGW32__) #if ((defined WIN32) || (defined WP8))
#define snprintf sprintf_s #define snprintf sprintf_s
#endif #endif
-17
View File
@@ -26,7 +26,6 @@
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <stdlib.h> #include <stdlib.h>
#include <list>
#include "DebugRoutines.h" #include "DebugRoutines.h"
@@ -141,20 +140,4 @@ template <class T> istream& operator>>(istream& in, T& p)
/* replace_all ... replacement to avoid depending on boost for that */ /* replace_all ... replacement to avoid depending on boost for that */
void ReplaceString(std::string& subject, const std::string& search, const std::string& replace); void ReplaceString(std::string& subject, const std::string& search, const std::string& replace);
/*! \brief Returns true if base starts with start, otherwise false
*
* Compares the first strlen(start) characters of base with start and
* returns true if both match.
*/
bool StartsWith(const std::string& base, const char *start);
/*! \brief Returns true if base starts with start, otherwise false
*
* This version is slightly more efficient as strlen does not need to
* get called. Otherwise, it behaves exactly like
* StartsWith(const std::string& base, const char *start)
*
* \see StartsWith(const std::string& base, const char *start)
*/
bool StartsWith(const std::string& base, const std::string& start);
#endif #endif
+1 -1
View File
@@ -314,7 +314,7 @@ bool AIHints::canWeCombo(GameObserver* observer,MTGCardInstance * card,AIPlayerB
int comboPartsRestriction = 0; int comboPartsRestriction = 0;
if(gotCombo) if(gotCombo)
return gotCombo;//because more than one might be possible at any time. return gotCombo;//because more then one might be possible at any time.
if (hints[i]->hold.size()) if (hints[i]->hold.size())
{ {
for(unsigned int hPart = 0; hPart < hints[i]->hold.size(); hPart++) for(unsigned int hPart = 0; hPart < hints[i]->hold.size(); hPart++)
+2 -2
View File
@@ -445,7 +445,7 @@ int OrderedAIAction::getEfficiency()
} }
if ((drawer->getNumCards() >= p->game->library->nb_cards && (Targetable*)p == drawer->getTarget()) || (p->game->hand->nb_cards > 10 && (Targetable*)p == drawer->getTarget())) if ((drawer->getNumCards() >= p->game->library->nb_cards && (Targetable*)p == drawer->getTarget()) || (p->game->hand->nb_cards > 10 && (Targetable*)p == drawer->getTarget()))
{ {
//if the amount im drawing will mill me to death or i have more than 10 cards in hand, eff is 0; //if the amount im drawing will mill me to death or i have more then 10 cards in hand, eff is 0;
efficiency = 0; efficiency = 0;
} }
break; break;
@@ -853,7 +853,7 @@ ManaCost * AIPlayerBaka::getPotentialMana(MTGCardInstance * target)
if (card == target) if (card == target)
used[card] = true; //http://code.google.com/p/wagic/issues/detail?id=76 used[card] = true; //http://code.google.com/p/wagic/issues/detail?id=76
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() == 1) if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() == 1)
{//ai can't use cards which produce more than 1 converted while using the old pMana method. {//ai can't use cards which produce more then 1 converted while using the old pMana method.
result->add(amp->output); result->add(amp->output);
used[card] = true; used[card] = true;
} }
+1 -2
View File
@@ -57,7 +57,7 @@ void NextGamePhase::Render()
if (observer->currentActionPlayer == observer->players[1]) if (observer->currentActionPlayer == observer->players[1])
playerId = 2; playerId = 2;
sprintf(buffer, "%s %i : %s", _("Player").c_str(), playerId, observer->getNextGamePhaseName().c_str()); sprintf(buffer, "%s %i : %s", _("Player").c_str(), playerId, observer->getNextGamePhaseName());
mFont->DrawString(buffer, x + 15, y+10, JGETEXT_LEFT); mFont->DrawString(buffer, x + 15, y+10, JGETEXT_LEFT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
@@ -675,7 +675,6 @@ ActionStack::ActionStack(GameObserver* game)
currentState = -1; currentState = -1;
mode = ACTIONSTACK_STANDARD; mode = ACTIONSTACK_STANDARD;
checked = 0; checked = 0;
lastActionController = NULL;
if(!observer->getResourceManager()) return; if(!observer->getResourceManager()) return;
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
+140 -143
View File
@@ -55,12 +55,6 @@ GenericActivatedAbility::GenericActivatedAbility(GameObserver* observer, string
target = ability->target; target = ability->target;
} }
GenericActivatedAbility::GenericActivatedAbility(const GenericActivatedAbility &other):
ActivatedAbility(other), NestedAbility(other), activeZone(other.activeZone), newName(other.newName)
{
}
int GenericActivatedAbility::resolve() int GenericActivatedAbility::resolve()
{ {
//Note: I've seen a similar block in some other MTGAbility, can this be refactored . //Note: I've seen a similar block in some other MTGAbility, can this be refactored .
@@ -77,7 +71,7 @@ int GenericActivatedAbility::resolve()
return 0; return 0;
} }
const string GenericActivatedAbility::getMenuText() const char * GenericActivatedAbility::getMenuText()
{ {
if(newName.size()) if(newName.size())
return newName.c_str(); return newName.c_str();
@@ -111,7 +105,6 @@ int GenericActivatedAbility::testDestroy()
GenericActivatedAbility * GenericActivatedAbility::clone() const GenericActivatedAbility * GenericActivatedAbility::clone() const
{ {
GenericActivatedAbility * a = NEW GenericActivatedAbility(*this); GenericActivatedAbility * a = NEW GenericActivatedAbility(*this);
a->ability = ability->clone(); a->ability = ability->clone();
return a; return a;
} }
@@ -140,7 +133,7 @@ int AAAlterPoison::resolve()
return 0; return 0;
} }
const string AAAlterPoison::getMenuText() const char * AAAlterPoison::getMenuText()
{ {
return "Poison"; return "Poison";
} }
@@ -172,7 +165,7 @@ int AADamagePrevent::resolve()
return 0; return 0;
} }
const string AADamagePrevent::getMenuText() const char * AADamagePrevent::getMenuText()
{ {
return "Prevent Damage"; return "Prevent Damage";
} }
@@ -244,7 +237,7 @@ AADamager::AADamager(GameObserver* observer, int _id, MTGCardInstance * _source,
return damage.getValue(); return damage.getValue();
} }
const string AADamager::getMenuText() const char * AADamager::getMenuText()
{ {
MTGCardInstance * _target = dynamic_cast<MTGCardInstance*>(target); MTGCardInstance * _target = dynamic_cast<MTGCardInstance*>(target);
if(_target && _target->hasType(Subtypes::TYPE_PLANESWALKER)) if(_target && _target->hasType(Subtypes::TYPE_PLANESWALKER))
@@ -283,7 +276,7 @@ AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card,
return 1; return 1;
} }
const string AADepleter::getMenuText() const char * AADepleter::getMenuText()
{ {
return "Deplete"; return "Deplete";
} }
@@ -318,7 +311,7 @@ AAModTurn::AAModTurn(GameObserver* observer, int _id, MTGCardInstance * card, Ta
return 1; return 1;
} }
const string AAModTurn::getMenuText() const char * AAModTurn::getMenuText()
{ {
WParsedInt numTurns(nbTurnStr, NULL, source); WParsedInt numTurns(nbTurnStr, NULL, source);
if(numTurns.getValue() > 0) if(numTurns.getValue() > 0)
@@ -361,7 +354,7 @@ int AALibraryBottom::resolve()
return 0; return 0;
} }
const string AALibraryBottom::getMenuText() const char * AALibraryBottom::getMenuText()
{ {
return "Bottom Of Library"; return "Bottom Of Library";
} }
@@ -389,7 +382,7 @@ int AACopier::resolve()
return 0; return 0;
} }
const string AACopier::getMenuText() const char * AACopier::getMenuText()
{ {
return "Copy"; return "Copy";
} }
@@ -422,7 +415,7 @@ int AAPhaseOut::resolve()
return 0; return 0;
} }
const string AAPhaseOut::getMenuText() const char * AAPhaseOut::getMenuText()
{ {
return "Phase Out"; return "Phase Out";
} }
@@ -513,7 +506,7 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M
return 0; return 0;
} }
const string AACounter::getMenuText() const char* AACounter::getMenuText()
{ {
if (menu.size()) if (menu.size())
{ {
@@ -702,7 +695,7 @@ int AARemoveAllCounter::resolve()
return nb; return nb;
} }
const string AARemoveAllCounter::getMenuText() const char* AARemoveAllCounter::getMenuText()
{ {
if (menu.size()) if (menu.size())
{ {
@@ -780,7 +773,7 @@ int AAProliferate::resolve()
} }
const string AAProliferate::getMenuText() const char* AAProliferate::getMenuText()
{ {
return "Proliferate"; return "Proliferate";
} }
@@ -823,13 +816,13 @@ int GenericChooseTypeColor::resolve()
for (size_t i = 0; i < values.size(); ++i) for (size_t i = 0; i < values.size(); ++i)
{ {
string menu = values[i]; string menu = values[i];
if (!ANonWall || (menu != "wall" && menu != "Wall")) if(!ANonWall || (menu != "wall" && menu != "Wall"))
{ {
setType = NEW AASetTypeChosen(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, i,menu,baseAbility); setType = NEW AASetTypeChosen(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, i,menu,baseAbility);
MTGAbility * set = setType->clone(); MTGAbility * set = setType->clone();
set->oneShot = true; set->oneShot = true;
selection.push_back(set); selection.push_back(set);
SAFE_DELETE(setType); SAFE_DELETE(setType);
} }
} }
} }
@@ -844,7 +837,7 @@ int GenericChooseTypeColor::resolve()
} }
const string GenericChooseTypeColor::getMenuText() const char* GenericChooseTypeColor::getMenuText()
{ {
if(chooseColor) if(chooseColor)
return "Choose a color"; return "Choose a color";
@@ -906,7 +899,7 @@ int AASetColorChosen::resolve()
return 1; return 1;
} }
const string AASetColorChosen::getMenuText() const char* AASetColorChosen::getMenuText()
{ {
return Constants::MTGColorStrings[color]; return Constants::MTGColorStrings[color];
} }
@@ -963,7 +956,7 @@ int AASetTypeChosen::resolve()
return 1; return 1;
} }
const string AASetTypeChosen::getMenuText() const char* AASetTypeChosen::getMenuText()
{ {
return menutext.c_str(); return menutext.c_str();
} }
@@ -1010,7 +1003,7 @@ int GenericFlipACoin::resolve()
} }
const string GenericFlipACoin::getMenuText() const char* GenericFlipACoin::getMenuText()
{ {
return "Flip A Coin"; return "Flip A Coin";
} }
@@ -1102,7 +1095,7 @@ int AASetCoin::resolve()
return 1; return 1;
} }
const string AASetCoin::getMenuText() const char* AASetCoin::getMenuText()
{ {
if(side == 1) if(side == 1)
return "Tails"; return "Tails";
@@ -1193,7 +1186,7 @@ int GenericPaidAbility::resolve()
return 1; return 1;
} }
const string GenericPaidAbility::getMenuText() const char* GenericPaidAbility::getMenuText()
{ {
if (newName.size()) if (newName.size())
return newName.c_str(); return newName.c_str();
@@ -1295,7 +1288,7 @@ int AAResetDamage::resolve()
return 1; return 1;
} }
const string AAResetDamage::getMenuText() const char* AAResetDamage::getMenuText()
{ {
return "Reset Damages"; return "Reset Damages";
} }
@@ -1316,7 +1309,7 @@ int AAFakeAbility::resolve()
return 1; return 1;
} }
const string AAFakeAbility::getMenuText() const char* AAFakeAbility::getMenuText()
{ {
if(named.size()) if(named.size())
return named.c_str(); return named.c_str();
@@ -1363,7 +1356,7 @@ int AAFizzler::resolve()
return 1; return 1;
} }
const string AAFizzler::getMenuText() const char * AAFizzler::getMenuText()
{ {
return "Fizzle"; return "Fizzle";
} }
@@ -1410,7 +1403,7 @@ int AABuryCard::resolve()
return 0; return 0;
} }
const string AABuryCard::getMenuText() const char * AABuryCard::getMenuText()
{ {
if(menu.size()) if(menu.size())
return menu.c_str(); return menu.c_str();
@@ -1466,7 +1459,7 @@ int AADestroyCard::resolve()
return 0; return 0;
} }
const string AADestroyCard::getMenuText() const char * AADestroyCard::getMenuText()
{ {
return "Destroy"; return "Destroy";
} }
@@ -1522,7 +1515,7 @@ int AASacrificeCard::resolve()
return 0; return 0;
} }
const string AASacrificeCard::getMenuText() const char * AASacrificeCard::getMenuText()
{ {
return "Sacrifice"; return "Sacrifice";
} }
@@ -1577,7 +1570,7 @@ int AADiscardCard::resolve()
return 0; return 0;
} }
const string AADiscardCard::getMenuText() const char * AADiscardCard::getMenuText()
{ {
return "Discard"; return "Discard";
} }
@@ -1641,7 +1634,7 @@ AADrawer::AADrawer(GameObserver* observer, int _id, MTGCardInstance * card, Targ
return numCards.getValue(); return numCards.getValue();
} }
const string AADrawer::getMenuText() const char * AADrawer::getMenuText()
{ {
return "Draw"; return "Draw";
} }
@@ -1670,7 +1663,7 @@ int AAFrozen::resolve()
return 1; return 1;
} }
const string AAFrozen::getMenuText() const char * AAFrozen::getMenuText()
{ {
return "Freeze"; return "Freeze";
} }
@@ -1735,7 +1728,7 @@ int AANewTarget::resolve()
return 1; return 1;
} }
const string AANewTarget::getMenuText() const char * AANewTarget::getMenuText()
{ {
return "New Target"; return "New Target";
} }
@@ -1816,7 +1809,7 @@ int AAMorph::testDestroy()
return 0; return 0;
} }
const string AAMorph::getMenuText() const char * AAMorph::getMenuText()
{ {
return "Morph"; return "Morph";
} }
@@ -1953,7 +1946,7 @@ int AAFlip::testDestroy()
return 0; return 0;
} }
const string AAFlip::getMenuText() const char * AAFlip::getMenuText()
{ {
string s = flipStats; string s = flipStats;
sprintf(menuText, "Transform:%s", s.c_str()); sprintf(menuText, "Transform:%s", s.c_str());
@@ -1994,23 +1987,28 @@ int AADynamic::resolve()
break; break;
case DYNAMIC_ABILITY_WHO_ITSELF: case DYNAMIC_ABILITY_WHO_ITSELF:
source = ((MTGCardInstance *) _target); source = ((MTGCardInstance *) _target);
_target = _target;
break; break;
case DYNAMIC_ABILITY_WHO_TARGETCONTROLLER: case DYNAMIC_ABILITY_WHO_TARGETCONTROLLER:
_target = _target;
secondaryTarget = ((MTGCardInstance *) _target)->controller(); secondaryTarget = ((MTGCardInstance *) _target)->controller();
break; break;
case DYNAMIC_ABILITY_WHO_TARGETOPPONENT: case DYNAMIC_ABILITY_WHO_TARGETOPPONENT:
_target = _target;
secondaryTarget = ((MTGCardInstance *) _target)->controller()->opponent(); secondaryTarget = ((MTGCardInstance *) _target)->controller()->opponent();
break; break;
case DYNAMIC_ABILITY_WHO_TOSOURCE: case DYNAMIC_ABILITY_WHO_TOSOURCE:
tosrc = true; tosrc = true;
break; break;
case DYNAMIC_ABILITY_WHO_SOURCECONTROLLER: case DYNAMIC_ABILITY_WHO_SOURCECONTROLLER:
_target = _target;
secondaryTarget = ((MTGCardInstance *) OriginalSrc)->controller(); secondaryTarget = ((MTGCardInstance *) OriginalSrc)->controller();
break; break;
case DYNAMIC_ABILITY_WHO_SOURCEOPPONENT: case DYNAMIC_ABILITY_WHO_SOURCEOPPONENT:
secondaryTarget = OriginalSrc->controller()->opponent(); secondaryTarget = OriginalSrc->controller()->opponent();
break; break;
default: default:
_target = _target;
break; break;
} }
if(amountsource == DYNAMIC_MYSELF_AMOUNT) if(amountsource == DYNAMIC_MYSELF_AMOUNT)
@@ -2254,7 +2252,7 @@ int AADynamic::activateStored()
return 1; return 1;
} }
const string AADynamic::getMenuText() const char * AADynamic::getMenuText()
{ {
if (menu.size()) if (menu.size())
{ {
@@ -2369,7 +2367,7 @@ int AALifer::getLife()
return life.getValue(); return life.getValue();
} }
const string AALifer::getMenuText() const char * AALifer::getMenuText()
{ {
if(getLife() < 0) if(getLife() < 0)
return "Life Loss"; return "Life Loss";
@@ -2402,7 +2400,7 @@ int AASetHand::resolve()
return 1; return 1;
} }
const string AASetHand::getMenuText() const char * AASetHand::getMenuText()
{ {
return "Set Hand Size"; return "Set Hand Size";
} }
@@ -2433,7 +2431,7 @@ int AALifeSet::resolve()
return 1; return 1;
} }
const string AALifeSet::getMenuText() const char * AALifeSet::getMenuText()
{ {
return "Set Life"; return "Set Life";
} }
@@ -2515,7 +2513,7 @@ int AACloner::resolve()
} }
const string AACloner::getMenuText() const char * AACloner::getMenuText()
{ {
if (who == 1) if (who == 1)
return "Clone For Opponent"; return "Clone For Opponent";
@@ -2590,7 +2588,7 @@ int ACastRestriction::destroy()
return 1; return 1;
} }
const string ACastRestriction::getMenuText() const char * ACastRestriction::getMenuText()
{ {
if (modifyExisting) if (modifyExisting)
return "Additional Lands"; //hardoced because only the lands rule allows to modify existing rule for now return "Additional Lands"; //hardoced because only the lands rule allows to modify existing rule for now
@@ -2625,7 +2623,7 @@ int AInstantCastRestrictionUEOT::resolve()
wrapper->addToGame(); wrapper->addToGame();
return 1; return 1;
} }
const string AInstantCastRestrictionUEOT::getMenuText() const char * AInstantCastRestrictionUEOT::getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -2719,14 +2717,14 @@ int AAMover::resolve()
return 0; return 0;
} }
const string AAMover::getMenuText() const char * AAMover::getMenuText()
{ {
if(named.size()) if(named.size())
return named.c_str(); return named.c_str();
return "Move"; return "Move";
} }
const char* AAMover::getMenuText(TargetChooser * tc) const char * AAMover::getMenuText(TargetChooser * tc)
{ {
if(named.size()) if(named.size())
return named.c_str(); return named.c_str();
@@ -2866,7 +2864,7 @@ int AARandomMover::resolve()
return 0; return 0;
} }
const string AARandomMover::getMenuText() const char * AARandomMover::getMenuText()
{ {
return "Dig"; return "Dig";
} }
@@ -2904,7 +2902,7 @@ int AARandomDiscarder::resolve()
return 1; return 1;
} }
const string AARandomDiscarder::getMenuText() const char * AARandomDiscarder::getMenuText()
{ {
return "Discard Random"; return "Discard Random";
} }
@@ -2931,7 +2929,7 @@ int AAShuffle::resolve()
return 1; return 1;
} }
const string AAShuffle::getMenuText() const char * AAShuffle::getMenuText()
{ {
return "Shuffle"; return "Shuffle";
} }
@@ -3029,7 +3027,7 @@ int AARemoveMana::resolve()
return 1; return 1;
} }
const string AARemoveMana::getMenuText() const char * AARemoveMana::getMenuText()
{ {
if (mRemoveAll && !mManaDesc) if (mRemoveAll && !mManaDesc)
return "Empty Manapool"; return "Empty Manapool";
@@ -3068,7 +3066,7 @@ int AATapper::resolve()
return 1; return 1;
} }
const string AATapper::getMenuText() const char * AATapper::getMenuText()
{ {
return "Tap"; return "Tap";
} }
@@ -3098,7 +3096,7 @@ int AAUntapper::resolve()
return 1; return 1;
} }
const string AAUntapper::getMenuText() const char * AAUntapper::getMenuText()
{ {
return "Untap"; return "Untap";
} }
@@ -3179,7 +3177,7 @@ int AAWinGame::resolve()
return 1; return 1;
} }
const string AAWinGame::getMenuText() const char * AAWinGame::getMenuText()
{ {
return "Win Game"; return "Win Game";
} }
@@ -3270,7 +3268,7 @@ int IfThenAbility::resolve()
return 0; return 0;
} }
const string IfThenAbility::getMenuText() const char * IfThenAbility::getMenuText()
{ {
return ""; return "";
} }
@@ -3322,7 +3320,7 @@ void MayAbility::Update(float dt)
} }
} }
const string MayAbility::getMenuText() const char * MayAbility::getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -3458,7 +3456,7 @@ int MenuAbility::resolve()
return a->addToGame(); return a->addToGame();
} }
const string MenuAbility::getMenuText() const char * MenuAbility::getMenuText()
{ {
if((abilities.size() > 1 && must)||(abilities.size() > 2 && !must)) if((abilities.size() > 1 && must)||(abilities.size() > 2 && !must))
return "choose one"; return "choose one";
@@ -3659,7 +3657,7 @@ int MultiAbility::destroy()
return ActivatedAbility::destroy(); return ActivatedAbility::destroy();
} }
const string MultiAbility::getMenuText() const char * MultiAbility::getMenuText()
{ {
if (abilities.size() && abilities[0]) if (abilities.size() && abilities[0])
return abilities[0]->getMenuText(); return abilities[0]->getMenuText();
@@ -3698,7 +3696,7 @@ GenericTargetAbility::GenericTargetAbility(GameObserver* observer, string newNam
counters = 0; counters = 0;
} }
const string GenericTargetAbility::getMenuText() const char * GenericTargetAbility::getMenuText()
{ {
if (!ability) if (!ability)
return "Error"; return "Error";
@@ -4251,7 +4249,7 @@ int ATransformer::destroy()
return 1; return 1;
} }
const string ATransformer::getMenuText() const char * ATransformer::getMenuText()
{ {
if(menutext.size()) if(menutext.size())
return menutext.c_str(); return menutext.c_str();
@@ -4284,7 +4282,7 @@ int ATransformerInstant::resolve()
wrapper->addToGame(); wrapper->addToGame();
return 1; return 1;
} }
const string ATransformerInstant::getMenuText() const char * ATransformerInstant::getMenuText()
{ {
if(menu.size()) if(menu.size())
return menu.c_str(); return menu.c_str();
@@ -4318,7 +4316,7 @@ int PTInstant::resolve()
wrapper->addToGame(); wrapper->addToGame();
return 1; return 1;
} }
const string PTInstant::getMenuText() const char * PTInstant::getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -4349,7 +4347,7 @@ int ASwapPTUEOT::resolve()
return 1; return 1;
} }
const string ASwapPTUEOT::getMenuText() const char * ASwapPTUEOT::getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -4419,7 +4417,7 @@ int AAExchangeLife::resolve()
return 0; return 0;
} }
const string AAExchangeLife::getMenuText() const char * AAExchangeLife::getMenuText()
{ {
return "Exchange life"; return "Exchange life";
} }
@@ -4657,7 +4655,7 @@ int APreventDamageTypesUEOT::destroy()
return 1; return 1;
} }
const string APreventDamageTypesUEOT::getMenuText() const char * APreventDamageTypesUEOT::getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -4727,7 +4725,7 @@ int AVanishing::resolve()
return 1; return 1;
} }
const string AVanishing::getMenuText() const char * AVanishing::getMenuText()
{ {
if(counterName.find("fade") != string::npos) if(counterName.find("fade") != string::npos)
return "Fading"; return "Fading";
@@ -4823,7 +4821,7 @@ int AUpkeep::resolve()
return 1; return 1;
} }
const string AUpkeep::getMenuText() const char * AUpkeep::getMenuText()
{ {
return "Upkeep"; return "Upkeep";
} }
@@ -4923,7 +4921,7 @@ int APhaseAction::resolve()
return 0; return 0;
} }
const string APhaseAction::getMenuText() const char * APhaseAction::getMenuText()
{ {
if(psMenuText.size()) if(psMenuText.size())
return psMenuText.c_str(); return psMenuText.c_str();
@@ -4960,7 +4958,7 @@ int APhaseActionGeneric::resolve()
return 1; return 1;
} }
const string APhaseActionGeneric::getMenuText() const char * APhaseActionGeneric::getMenuText()
{ {
return ability->getMenuText(); return ability->getMenuText();
} }
@@ -5118,7 +5116,7 @@ int ABlink::resolve()
{ {
return 0; return 0;
} }
const string ABlink::getMenuText() const char * ABlink::getMenuText()
{ {
return "Blink"; return "Blink";
} }
@@ -5149,7 +5147,7 @@ int ABlinkGeneric::resolve()
return 1; return 1;
} }
const string ABlinkGeneric::getMenuText() const char * ABlinkGeneric::getMenuText()
{ {
return "Blink"; return "Blink";
} }
@@ -5318,7 +5316,6 @@ int AEquip::unequip()
{ {
MTGAbility * a = currentAbilities[i]; MTGAbility * a = currentAbilities[i];
if (dynamic_cast<AEquip *> (a) || dynamic_cast<ATeach *> (a) || dynamic_cast<AAConnect *> (a) if (dynamic_cast<AEquip *> (a) || dynamic_cast<ATeach *> (a) || dynamic_cast<AAConnect *> (a)
|| dynamic_cast<AANewTarget *> (AbilityFactory::getCoreAbility(a))
|| (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot)) || (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot))
{ {
SAFE_DELETE(a); SAFE_DELETE(a);
@@ -5372,7 +5369,7 @@ int AEquip::resolve()
return 1; return 1;
} }
const string AEquip::getMenuText() const char * AEquip::getMenuText()
{ {
if (isAttach) if (isAttach)
return "Attach"; return "Attach";
@@ -5414,83 +5411,83 @@ AACastCard::AACastCard(GameObserver* observer, int _id, MTGCardInstance * _sourc
} }
void AACastCard::Update(float dt) void AACastCard::Update(float dt)
{
MTGAbility::Update(dt);
if (processed)
return;
if(cardNamed.size() && !theNamedCard)
{
theNamedCard = makeCard();
}
if (restricted)
{ {
MTGAbility::Update(dt);
if (processed)
return;
if(cardNamed.size() && !theNamedCard)
{
theNamedCard = makeCard();
}
if (restricted)
{
MTGCardInstance * toCheck = (MTGCardInstance*)target;
if(theNamedCard)
toCheck = theNamedCard;
if (game->currentActionPlayer->game->playRestrictions->canPutIntoZone(toCheck, source->controller()->game->stack) == PlayRestriction::CANT_PLAY)
{
processed = true;
this->forceDestroy = 1;
return ;
}
if(!allowedToCast(toCheck,source->controller()))
{
processed = true;
this->forceDestroy = 1;
return;
}
if(!toCheck->hasType(Subtypes::TYPE_INSTANT) && !(game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN || game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))
{
processed = true;
this->forceDestroy = 1;
return;
}
}
MTGCardInstance * toCheck = (MTGCardInstance*)target; MTGCardInstance * toCheck = (MTGCardInstance*)target;
if(theNamedCard) if(theNamedCard)
toCheck = theNamedCard; toCheck = theNamedCard;
if (game->currentActionPlayer->game->playRestrictions->canPutIntoZone(toCheck, source->controller()->game->stack) == PlayRestriction::CANT_PLAY) if (Spell * checkSpell = dynamic_cast<Spell*>(target))
{ {
processed = true; toCheck = checkSpell->source;
this->forceDestroy = 1;
return ;
} }
if(!allowedToCast(toCheck,source->controller())) if (!game->targetListIsSet(toCheck))
{ {
processed = true; if(game->targetChooser)
this->forceDestroy = 1; game->targetChooser->Owner = source->controller();//sources controller is the caster
return; return;
} }
if(!toCheck->hasType(Subtypes::TYPE_INSTANT) && !(game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN || game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN)) resolveSpell();
{ this->forceDestroy = 1;
processed = true;
this->forceDestroy = 1;
return;
}
}
MTGCardInstance * toCheck = (MTGCardInstance*)target;
if(theNamedCard)
toCheck = theNamedCard;
if (Spell * checkSpell = dynamic_cast<Spell*>(target))
{
toCheck = checkSpell->source;
}
if (!game->targetListIsSet(toCheck))
{
if(game->targetChooser)
game->targetChooser->Owner = source->controller();//sources controller is the caster
return; return;
} }
resolveSpell(); int AACastCard::isReactingToTargetClick(Targetable * card){return 0;}
this->forceDestroy = 1; int AACastCard::reactToTargetClick(Targetable * object)
return;
}
int AACastCard::isReactingToTargetClick(Targetable * card){return 0;}
int AACastCard::reactToTargetClick(Targetable * object)
{
if (MTGCardInstance * cObject = dynamic_cast<MTGCardInstance *>(object))
return reactToClick(cObject);
if (waitingForAnswer)
{ {
if (tc->toggleTarget(object) == TARGET_OK_FULL) if (MTGCardInstance * cObject = dynamic_cast<MTGCardInstance *>(object))
{ return reactToClick(cObject);
waitingForAnswer = 0;
game->mLayers->actionLayer()->setCurrentWaitingAction(NULL);
return MTGAbility::reactToClick(source);
}
return 1;
}
return 0;
}
MTGCardInstance * AACastCard::makeCard() if (waitingForAnswer)
{ {
MTGCardInstance * card = NULL; if (tc->toggleTarget(object) == TARGET_OK_FULL)
MTGCard * cardData = MTGCollection()->getCardByName(cardNamed); {
card = NEW MTGCardInstance(cardData, source->controller()->game); waitingForAnswer = 0;
source->controller()->game->temp->addCard(card); game->mLayers->actionLayer()->setCurrentWaitingAction(NULL);
return card; return MTGAbility::reactToClick(source);
} }
return 1;
}
return 0;
}
MTGCardInstance * AACastCard::makeCard()
{
MTGCardInstance * card = NULL;
MTGCard * cardData = MTGCollection()->getCardByName(cardNamed);
card = NEW MTGCardInstance(cardData, source->controller()->game);
source->controller()->game->temp->addCard(card);
return card;
}
int AACastCard::resolveSpell() int AACastCard::resolveSpell()
{ {
@@ -5586,7 +5583,7 @@ int AACastCard::resolveSpell()
return 0; return 0;
} }
const string AACastCard::getMenuText() const char * AACastCard::getMenuText()
{ {
if(nameThis.size()) if(nameThis.size())
return nameThis.c_str(); return nameThis.c_str();
+6 -8
View File
@@ -17,7 +17,6 @@
#include "Counters.h" #include "Counters.h"
#include "ModRules.h" #include "ModRules.h"
#include "CardDescriptor.h" #include "CardDescriptor.h"
#include "GameApp.h"
const float CardGui::Width = 28.0; const float CardGui::Width = 28.0;
const float CardGui::Height = 40.0; const float CardGui::Height = 40.0;
@@ -111,17 +110,17 @@ void CardGui::Update(float dt)
PlayGuiObject::Update(dt); PlayGuiObject::Update(dt);
} }
void CardGui::DrawCard(const Pos& inPosition, int inMode, bool thumb) void CardGui::DrawCard(const Pos& inPosition, int inMode)
{ {
DrawCard(card, inPosition, inMode, thumb); DrawCard(card, inPosition, inMode);
} }
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode, bool thumb) void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode)
{ {
switch (inMode) switch (inMode)
{ {
case DrawMode::kNormal: case DrawMode::kNormal:
RenderBig(inCard, inPosition, thumb); RenderBig(inCard, inPosition);
break; break;
case DrawMode::kText: case DrawMode::kText:
AlternateRender(inCard, inPosition); AlternateRender(inCard, inPosition);
@@ -958,7 +957,7 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad)
} }
//Renders a big card on screen. Defaults to the "alternate" rendering if no image is found //Renders a big card on screen. Defaults to the "alternate" rendering if no image is found
void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb) void CardGui::RenderBig(MTGCard* card, const Pos& pos)
{ {
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
//GameObserver * game = GameObserver::GetInstance(); //GameObserver * game = GameObserver::GetInstance();
@@ -967,8 +966,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb)
//i want this but ai targets cards so quickly that it can crash the game. //i want this but ai targets cards so quickly that it can crash the game.
float x = pos.actX; float x = pos.actX;
JQuadPtr quad = thumb ? WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_THUMB) JQuadPtr quad = WResourceManager::Instance()->RetrieveCard(card);
: WResourceManager::Instance()->RetrieveCard(card);
MTGCardInstance * kcard = dynamic_cast<MTGCardInstance*>(card); MTGCardInstance * kcard = dynamic_cast<MTGCardInstance*>(card);
if(kcard && !kcard->isToken && kcard->name != kcard->model->data->name) if(kcard && !kcard->isToken && kcard->name != kcard->model->data->name)
{ {
+7 -8
View File
@@ -6,7 +6,6 @@
#include "MTGDeck.h" #include "MTGDeck.h"
#include "Subtypes.h" #include "Subtypes.h"
#include "Translate.h" #include "Translate.h"
#include "GameApp.h"
using std::string; using std::string;
@@ -85,9 +84,6 @@ int CardPrimitive::init()
alias = 0; alias = 0;
restrictions = NULL; restrictions = NULL;
dredgeAmount = 0; dredgeAmount = 0;
power = 0;
toughness = 0;
return 1; return 1;
} }
@@ -229,9 +225,6 @@ void CardPrimitive::setSubtype(const string& value)
} }
} }
// "Artifact Creature" should have "Creature" as parent type
if (parentType == Subtypes::TYPE_ARTIFACT && isCreature())
parentType = Subtypes::TYPE_CREATURE;
int id = MTGAllCards::add(value, parentType); int id = MTGAllCards::add(value, parentType);
addType(id); addType(id);
@@ -351,12 +344,18 @@ bool CardPrimitive::hasSubtype(int _subtype)
return hasType(_subtype); return hasType(_subtype);
} }
bool CardPrimitive::hasType(const string& _type) bool CardPrimitive::hasType(const char * _type)
{ {
int id = MTGAllCards::findType(_type); int id = MTGAllCards::findType(_type);
return hasType(id); return hasType(id);
} }
bool CardPrimitive::hasSubtype(const char * _subtype)
{
int id = MTGAllCards::findType(_subtype);
return hasType(id);
}
bool CardPrimitive::hasSubtype(const string& _subtype) bool CardPrimitive::hasSubtype(const string& _subtype)
{ {
int id = MTGAllCards::findType(_subtype); int id = MTGAllCards::findType(_subtype);
+1 -1
View File
@@ -66,7 +66,7 @@ CardSelector::SelectorMemory::SelectorMemory()
} }
CardSelector::CardSelector(GameObserver *observer, DuelLayers* duel) : CardSelector::CardSelector(GameObserver *observer, DuelLayers* duel) :
CardSelectorBase(observer), active(NULL), duel(duel), limitor(NULL), bigpos(300, 145, 1.0, 0.0, 220), timer(0.0f) CardSelectorBase(observer), active(NULL), duel(duel), limitor(NULL), bigpos(300, 145, 1.0, 0.0, 220)
{ {
} }
-200
View File
@@ -1,200 +0,0 @@
#include "CarouselDeckView.h"
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)
{
}
CarouselDeckView::~CarouselDeckView()
{}
void CarouselDeckView::UpdateViewState(float dt)
{
if(!mScrollEasing.finished())
{
mScrollEasing.update(dt);
if(mScrollOffset <= -1.0f)
{
changePosition(-1);
mScrollEasing.translate(1.0f);
}
else if(mScrollOffset >= 1.0f)
{
changePosition(1);
mScrollEasing.translate(-1.0f);
}
dirtyCardPos = true;
}
if(!mSlideEasing.finished())
{
mSlideEasing.update(dt);
if(mSlideOffset < mSlideEasing.start_value)
{
//going downwards
if(mSlideOffset < -1.0f)
{
mSlideEasing.translate(2.0f);
changeFilter(1);
}
}
else if(mSlideOffset > mSlideEasing.start_value)
{
//upwards
if(mSlideOffset > 1.0f)
{
mSlideEasing.translate(-2.0f);
changeFilter(-1);
}
}
dirtyCardPos = true;
}
}
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);
rep.scale = max_scale / 1.12f * cos((rep.x - x_center) * 1.5f / (right_border - x_center)) + 0.2f * max_scale * cos(
cos((rep.x - x_center) * 0.15f / (right_border - x_center)));
rep.y = (SCREEN_HEIGHT_F) / 2.0f + SCREEN_HEIGHT_F * mSlideOffset * (rep.scale + 0.2f);
}
void CarouselDeckView::Reset()
{
mSlideEasing.finish();
mScrollEasing.finish();
DeckView::Reset();
}
void CarouselDeckView::Render()
{
// even though we want to draw the cards in a particular z order for layering, we want to prefetch them
// in a different order, ie the center card should appear first, then the adjacent ones
if (WResourceManager::Instance()->IsThreaded())
{
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);
renderCard(5);
renderCard(4);
renderCard(0);
if (mScrollOffset < 0.5 && mScrollOffset > -0.5)
{
renderCard(1);
renderCard(3);
renderCard(2);
}
else if (mScrollOffset < -0.5)
{
renderCard(3);
renderCard(2);
renderCard(1);
}
else
{
renderCard(1);
renderCard(2);
renderCard(3);
}
}
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);
last_user_activity = 0;
//clicked active card, and no animation is running
if(mSlideEasing.finished() && mScrollEasing.finished())
{
if(n == 2)
{
return getActiveCard();
}
else
{
changePositionAnimated(n - 2);
}
}
return NULL;
}
MTGCard *CarouselDeckView::Click()
{
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::changeFilterAnimated(int offset)
{
if(mSlideEasing.finished())
mSlideEasing.start(2.0f * float(offset), float(slide_animation_duration * abs(offset)));
last_user_activity = 0;
}
MTGCard *CarouselDeckView::getActiveCard()
{
return mCards[2].card;
}
+1 -1
View File
@@ -386,7 +386,7 @@ void Credits::computeTournament(GameObserver* g, GameApp * _app,bool tournament,
} }
if (mGamesWon>mGamesPlayed*0.80 && mGamesWon<mGamesPlayed) if (mGamesWon>mGamesPlayed*0.80 && mGamesWon<mGamesPlayed)
{ {
CreditBonus * b = NEW CreditBonus(250, _("Won more than 80 percentage of games")); CreditBonus * b = NEW CreditBonus(250, _("Won more then 80 percentage of games"));
bonus.push_back(b); bonus.push_back(b);
} }
+1 -1
View File
@@ -7,7 +7,7 @@
#include <iomanip> #include <iomanip>
#include "Translate.h" #include "Translate.h"
DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const string& _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) : DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const char * _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) :
DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats) DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats)
{ {
backgroundName = "DeckEditorMenuBackdrop"; backgroundName = "DeckEditorMenuBackdrop";

Some files were not shown because too many files have changed in this diff Show More