Merge commit '224c94e89089317fac33aacb9319ab250301c98e' into develop

This commit is contained in:
Michael Nguyen
2013-10-28 15:37:24 -07:00
24 changed files with 183 additions and 74 deletions

View File

@@ -23,6 +23,19 @@
#include <QDBusInterface>
#endif //Q_WS_MAEMO_5
class WagicWrapper
{
public:
WagicWrapper();
virtual ~WagicWrapper();
private:
JGE* m_engine;
JApp* m_app;
JGameLauncher* m_launcher;
};
#ifdef QT_WIDGET
class WagicCore : public QGLWidget
#else
@@ -35,6 +48,7 @@ private:
#else
typedef QDeclarativeItem super;
#endif //QT_WIDGET
void initApp();
public:
Q_OBJECT
@@ -47,7 +61,7 @@ public:
public:
explicit WagicCore(super *parent = 0);
virtual ~WagicCore();
void initApp();
static int runTestSuite();
Q_INVOKABLE void doOK() {
doAndEnqueue(JGE_BTN_OK);

View File

@@ -124,8 +124,10 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
QDir dir(QDir::homePath());
dir.cd(USERDIR);
QDir sysDir("projects/mtg/bin/Res");
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
systemPath = "";
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
#else
//Find the Res.txt file and matching Res folders for backwards compatibility
ifstream mfile("Res.txt");

View File

@@ -68,6 +68,14 @@ int main(int argc, char* argv[])
(createApplication(argc, argv));
#endif //QT_WIDGET
if(argc >= 2 && strcmp(argv[1], "testsuite")==0)
{
int result = 0;
result += WagicCore::runTestSuite();
return result;
}
app->setApplicationName(WagicCore::getApplicationName());
FileDownloader fileDownloader(USERDIR, WAGIC_RESOURCE_NAME);
#ifdef QT_WIDGET

View File

@@ -310,10 +310,13 @@ void JQuad::SetTextureRect(float x, float y, float w, float h)
mWidth = w;
mHeight = h;
mTX0 = x/mTex->mTexWidth;
mTY0 = y/mTex->mTexHeight;
mTX1 = (x+w)/mTex->mTexWidth;
mTY1 = (y+h)/mTex->mTexHeight;
if(mTex)
{
mTX0 = x/mTex->mTexWidth;
mTY0 = y/mTex->mTexHeight;
mTX1 = (x+w)/mTex->mTexWidth;
mTY1 = (y+h)/mTex->mTexHeight;
}
}
@@ -840,7 +843,7 @@ void JRenderer::EndScene()
void JRenderer::BindTexture(JTexture *tex)
{
checkGlError();
if (mCurrentTex != tex->mTexId)
if (tex && mCurrentTex != tex->mTexId)
{
mCurrentTex = tex->mTexId;

View File

@@ -3,6 +3,13 @@
#include "corewrapper.h"
#include <QElapsedTimer>
#ifdef TESTSUITE
#include "TestSuiteAI.h"
#include "GameOptions.h"
#include "MTGDeck.h"
#endif
#include "DebugRoutines.h"
#if (defined FORCE_GLES)
#undef GL_ES_VERSION_2_0
#undef GL_VERSION_2_0
@@ -72,6 +79,64 @@ WagicCore::WagicCore(super *parent) :
#endif
}
WagicWrapper::WagicWrapper()
{
m_launcher = new JGameLauncher();
u32 flags = m_launcher->GetInitFlags();
if ((flags&JINIT_FLAG_ENABLE3D)!=0)
{
JRenderer::Set3DFlag(true);
}
JGECreateDefaultBindings();
m_engine = JGE::GetInstance();
m_app = m_launcher->GetGameApp();
m_app->Create();
m_engine->SetApp(m_app);
JRenderer::GetInstance()->Enable2D();
}
WagicWrapper::~WagicWrapper()
{
if(m_launcher)
{
delete m_launcher;
m_launcher = NULL;
}
if(m_engine)
m_engine->SetApp(NULL);
if (m_app)
{
m_app->Destroy();
delete m_app;
m_app = NULL;
}
JGE::Destroy();
m_engine = NULL;
}
int WagicCore::runTestSuite()
{
int result = 0;
#ifdef TESTSUITE
WagicWrapper* wagicCore = new WagicWrapper();
MTGCollection()->loadFolder("sets/primitives/");
MTGCollection()->loadFolder("sets/", "_cards.dat");
options.reloadProfile();
TestSuite testSuite("test/_tests.txt");
result = testSuite.run();
delete wagicCore;
#endif
DebugTrace("TestSuite done: failed test: " << result);
return result;
}
void WagicCore::initApp()
{
if(!m_engine)