- Adding DJardin's port to N900
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-09-16 13:12:05 +00:00
parent 46c499be5f
commit 3965505b15
15 changed files with 2379 additions and 180 deletions

View File

@@ -53,6 +53,12 @@
#define COSF(x) cosf(x*DEG2RAD)
#endif
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) || (defined WIN32)
typedef struct
{
GLfloat m[4][4];
} ESMatrix;
#endif // (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
//////////////////////////////////////////////////////////////////////////
/// A collection of core rendering functions.
@@ -541,8 +547,32 @@ private:
#if defined (WIN32) || defined (LINUX)
GLuint mCurrentTex;
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) || (defined WIN32)
// MVP matrix
ESMatrix theMvpMatrix;
// Handle to a program object
GLuint prog1;
// Attribute locations
GLint prog1_positionLoc;
GLint prog1_colorLoc;
// Uniform locations
GLint prog1_mvpLoc;
// Handle to a program object
GLuint prog2;
// Sampler location
GLint prog2_samplerLoc;
// Attribute locations
GLint prog2_positionLoc;
GLint prog2_texCoordLoc;
GLint prog2_colorLoc;
// MVP matrix
ESMatrix prog2_mvpMatrix;
// Uniform locations
GLint prog2_mvpLoc;
#endif // (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
#else
void *fbp0, *fbp1, *zbp;
PIXEL_TYPE* mVRAM;

View File

@@ -19,6 +19,10 @@
#include "JTypes.h"
#ifdef USE_PHONON
#include <phonon/AudioOutput>
#include <phonon/MediaObject>
#else
#ifdef WIN32
#include <windows.h>
@@ -43,16 +47,31 @@
#ifdef WITH_FMOD
#include "../Dependencies/include/fmod.h"
#endif
#endif
//------------------------------------------------------------------------------------------------
#ifdef USE_PHONON
class JMusic : public QObject
{
Q_OBJECT
#else
class JMusic
{
#endif
public:
JMusic();
~JMusic();
~JMusic();
void Update();
int getPlayTime();
#ifdef USE_PHONON
Phonon::AudioOutput* mOutput;
Phonon::MediaObject* mMediaObject;
public slots:
void seekAtTheBegining();
#else
#if defined (WIN32) || defined (LINUX)
#ifdef WITH_FMOD
FSOUND_SAMPLE* mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs
@@ -62,6 +81,7 @@ public:
#else
JMP3* mTrack;
#endif
#endif
};
@@ -80,6 +100,10 @@ class JSample
#ifdef WITH_FMOD
FSOUND_SAMPLE *mSample;
#else
#ifdef USE_PHONON
Phonon::AudioOutput* mOutput;
Phonon::MediaObject* mMediaObject;
#endif
void* mSample;
#endif
#else

View File

@@ -39,11 +39,11 @@
#define MAX_CHANNEL 128
enum {
JGE_ERR_CANT_OPEN_FILE = -1,
JGE_ERR_PNG = -2,
JGE_ERR_MALLOC_FAILED = -4,
JGE_ERR_GENERIC = -5,
enum {
JGE_ERR_CANT_OPEN_FILE = -1,
JGE_ERR_PNG = -2,
JGE_ERR_MALLOC_FAILED = -4,
JGE_ERR_GENERIC = -5,
};
@@ -88,10 +88,14 @@ enum {
typedef bool BOOL;
#endif
#ifndef QT_CONFIG
#if defined (WIN32) || defined (LINUX)
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#else
# include <QtOpenGL>
#endif
#if defined (WIN32) || defined (LINUX)

Binary file not shown.

View File

@@ -245,7 +245,11 @@ void JMD2Model::CalculateNormal(ScePspFVector3 *normal, float *p1, float *p2, fl
#if defined (WIN32) || defined (LINUX)
// normalize and specify the normal
#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
glNormal3f(result[0]/length, result[1]/length, result[2]/length);
#else
// FIXME
#endif //(!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
#else
if (length == 0.0f)
@@ -275,15 +279,45 @@ void JMD2Model::Render(int frameNum)
#if defined (WIN32) || defined (LINUX)
// display the textured model with proper lighting normals
glBegin(GL_TRIANGLES);
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#else
glBegin(GL_TRIANGLES);
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
for(i = 0; i < mModel->numTriangles; i++)
{
CalculateNormal(pointList[mModel->triIndex[i].meshIndex[0]].v,
pointList[mModel->triIndex[i].meshIndex[2]].v,
pointList[mModel->triIndex[i].meshIndex[1]].v);
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[0]].s,
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
float vertex_data[]={
pointList[mModel->triIndex[i].meshIndex[0]].x, pointList[mModel->triIndex[i].meshIndex[0]].y, pointList[mModel->triIndex[i].meshIndex[0]].z,
pointList[mModel->triIndex[i].meshIndex[2]].x, pointList[mModel->triIndex[i].meshIndex[2]].y, pointList[mModel->triIndex[i].meshIndex[2]].z,
pointList[mModel->triIndex[i].meshIndex[1]].x, pointList[mModel->triIndex[i].meshIndex[1]].y, pointList[mModel->triIndex[i].meshIndex[1]].z,
};
float texcoord_data[] = {
mModel->st[mModel->triIndex[i].stIndex[0]].s,
mModel->st[mModel->triIndex[i].stIndex[0]].t,
mModel->st[mModel->triIndex[i].stIndex[2]].s,
mModel->st[mModel->triIndex[i].stIndex[2]].t,
mModel->st[mModel->triIndex[i].stIndex[1]].s,
mModel->st[mModel->triIndex[i].stIndex[1]].t,
};
glVertexPointer(3,GL_FLOAT,0,vertex_data);
glTexCoordPointer(2,GL_FLOAT,0,texcoord_data);
#else
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[0]].s,
mModel->st[mModel->triIndex[i].stIndex[0]].t);
glVertex3fv(pointList[mModel->triIndex[i].meshIndex[0]].v);
@@ -294,8 +328,15 @@ void JMD2Model::Render(int frameNum)
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[1]].s,
mModel->st[mModel->triIndex[i].stIndex[1]].t);
glVertex3fv(pointList[mModel->triIndex[i].meshIndex[1]].v);
}
glEnd();
#endif //#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
}
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
glDrawArrays(GL_TRIANGLES,0,3); // seems suspicious to put that here, should probably be in the loop
#else
glEnd();
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
#else
@@ -442,9 +483,16 @@ void JMD2Model::Render()
#if defined (WIN32) || defined (LINUX)
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
// FIXME
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#else
glBegin(GL_TRIANGLES);
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
glBegin(GL_TRIANGLES);
for (i = 0; i < mModel->numTriangles; i++)
for (i = 0; i < mModel->numTriangles; i++)
{
// get first points of each frame
x1 = pointList[mModel->triIndex[i].meshIndex[0]].x;
@@ -489,19 +537,48 @@ void JMD2Model::Render()
//CalculateNormal(vertex[0].v, vertex[2].v, vertex[1].v);
// render properly textured triangle
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[0]].s,
mModel->st[mModel->triIndex[i].stIndex[0]].t);
glVertex3fv(vertex[0].v);
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[2]].s ,
mModel->st[mModel->triIndex[i].stIndex[2]].t);
glVertex3fv(vertex[2].v);
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
// FIXME
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
float vertex_data[]={
vertex[0].x, vertex[0].y, vertex[0].z,
vertex[2].x, vertex[2].y, vertex[2].z,
vertex[1].x, vertex[1].y, vertex[1].z,
};
float texcoord_data[] = {
mModel->st[mModel->triIndex[i].stIndex[0]].s,
mModel->st[mModel->triIndex[i].stIndex[0]].t,
mModel->st[mModel->triIndex[i].stIndex[2]].s,
mModel->st[mModel->triIndex[i].stIndex[2]].t,
mModel->st[mModel->triIndex[i].stIndex[1]].s,
mModel->st[mModel->triIndex[i].stIndex[1]].t,
};
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[1]].s,
mModel->st[mModel->triIndex[i].stIndex[1]].t);
glVertex3fv(vertex[1].v);
}
glEnd();
glVertexPointer(3,GL_FLOAT,0,vertex_data);
glTexCoordPointer(2,GL_FLOAT,0,texcoord_data);
#else
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[0]].s,
mModel->st[mModel->triIndex[i].stIndex[0]].t);
glVertex3fv(vertex[0].v);
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[2]].s ,
mModel->st[mModel->triIndex[i].stIndex[2]].t);
glVertex3fv(vertex[2].v);
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[1]].s,
mModel->st[mModel->triIndex[i].stIndex[1]].t);
glVertex3fv(vertex[1].v);
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
}
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
// FIXME
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
glDrawArrays(GL_TRIANGLES,0,3); // seems suspicious to put that here, should probably be in the loop
#else
glEnd();
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
#else

272
JGE/src/Qtmain.cpp Normal file
View File

@@ -0,0 +1,272 @@
#define GL_GLEXT_PROTOTYPES
#include <QtOpenGL>
#include <QTime>
#include "../include/JGE.h"
#include "../include/JTypes.h"
#include "../include/JApp.h"
#include "../include/JFileSystem.h"
#include "../include/JRenderer.h"
#include "../include/JGameLauncher.h"
#define ACTUAL_SCREEN_WIDTH (SCREEN_WIDTH)
#define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT)
#define ACTUAL_RATIO ((GLfloat)ACTUAL_SCREEN_WIDTH / (GLfloat)ACTUAL_SCREEN_HEIGHT)
class JGEQtRenderer : public QGLWidget
{
// Q_OBJECT // must include this if you use Qt signals/slots
public:
JGEQtRenderer(QWidget *parent);
protected:
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void timerEvent( QTimerEvent* );
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
};
uint64_t lastTickCount;
JGE* g_engine = NULL;
JApp* g_app = NULL;
JGameLauncher* g_launcher = NULL;
JGEQtRenderer *g_glwidget = NULL;
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
{
{ Qt::Key_Enter, JGE_BTN_MENU },
{ Qt::Key_Backspace, JGE_BTN_CTRL },
{ Qt::Key_Up, JGE_BTN_UP },
{ Qt::Key_Down, JGE_BTN_DOWN },
{ Qt::Key_Left, JGE_BTN_LEFT },
{ Qt::Key_Right, JGE_BTN_RIGHT },
{ Qt::Key_Space, JGE_BTN_OK },
{ Qt::Key_Tab, JGE_BTN_CANCEL },
{ Qt::Key_J, JGE_BTN_PRI },
{ Qt::Key_K, JGE_BTN_SEC },
{ Qt::Key_Q, JGE_BTN_PREV },
{ Qt::Key_A, JGE_BTN_NEXT },
// fullscreen management seems somehow broken in JGE, it works fine with Qt directly
// { Qt::Key_F, JGE_BTN_FULLSCREEN },
};
void JGECreateDefaultBindings()
{
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
g_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
}
int JGEGetTime()
{
QTime theTime = QTime::currentTime();
return theTime.second() * 1000 + theTime.msec();
}
bool JGEToggleFullscreen()
{
if(g_glwidget->isFullScreen())
{
g_glwidget->showNormal();
}
else
{
g_glwidget->showFullScreen();
}
return true;
}
bool InitGame(void)
{
g_engine = JGE::GetInstance();
g_app = g_launcher->GetGameApp();
g_app->Create();
g_engine->SetApp(g_app);
JRenderer::GetInstance()->Enable2D();
QTime theTime = QTime::currentTime();
lastTickCount = theTime.second() * 1000 + theTime.msec();
return true;
}
void DestroyGame(void)
{
g_engine->SetApp(NULL);
if (g_app)
{
g_app->Destroy();
delete g_app;
g_app = NULL;
}
JGE::Destroy();
g_engine = NULL;
}
JGEQtRenderer::JGEQtRenderer(QWidget *parent)
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
startTimer( 5 );
setWindowTitle(g_launcher->GetName());
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5AutoOrientation);
setAttribute(Qt::WA_Maemo5NonComposited);
#endif
}
void JGEQtRenderer::initializeGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background (yes that's the way fuckers)
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
#if (defined GL_ES_VERSION_2_0)
glClearDepthf(1.0f); // Depth Buffer Setup
#else
glClearDepth(1.0f); // Depth Buffer Setup
#endif// (defined GL_ES_VERSION_2_0)
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing (Less Or Equal)
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
#else
glClearDepth(1.0f); // Depth Buffer Setup
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing (Less Or Equal)
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
glShadeModel(GL_SMOOTH); // Select Smooth Shading
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Set Perspective Calculations To Most Accurate
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Set Line Antialiasing
glEnable(GL_LINE_SMOOTH); // Enable it!
#endif
glEnable(GL_CULL_FACE); // do not calculate inside of poly's
glFrontFace(GL_CCW); // counter clock-wise polygons are out
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_SCISSOR_TEST); // Enable Clipping
}
int actualWidth;
int actualHeight;
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize The GL Window
{
actualWidth = width;
actualHeight = height;
if ((GLfloat)width / (GLfloat)height < ACTUAL_RATIO)
glViewport(0, -((width/ACTUAL_RATIO)-height)/2, width, width / ACTUAL_RATIO); // Reset The Current Viewport
else
glViewport(-(height*ACTUAL_RATIO-width)/2, 0, height * ACTUAL_RATIO, height);
glScissor(0, 0, width, height);
}
void JGEQtRenderer::resizeGL(int width, int height)
{
ReSizeGLScene(width, height);
}
void JGEQtRenderer::paintGL()
{
g_engine->Render();
}
void JGEQtRenderer::timerEvent( QTimerEvent* )
{
QTime theTime = QTime::currentTime();
static uint64_t tickCount;
quint32 dt;
tickCount = theTime.second() * 1000 + theTime.msec();
dt = (tickCount - lastTickCount);
lastTickCount = tickCount;
if(g_engine->IsDone()) close();
//gPrevControllerState = gControllerState;
g_engine->SetDelta((float)dt / 1000.0f);
g_engine->Update((float)dt / 1000.0f);
updateGL();
}
void JGEQtRenderer::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_F)
{
JGEToggleFullscreen();
}
g_engine->HoldKey_NoRepeat(event->key());
event->accept();
QWidget::keyPressEvent(event);
return;
}
void JGEQtRenderer::keyReleaseEvent(QKeyEvent *event)
{
g_engine->ReleaseKey(event->key());
event->accept();
QWidget::keyReleaseEvent(event);
return;
}
int main(int argc, char* argv[])
{
char* path = argv[0];
while (*path) ++path;
while ((*path != '/') && (path > argv[0])) --path;
if ('/' == *path) *path = 0;
if (strlen(argv[0]) != 0) QDir::current().cd(argv[0]);
QApplication a( argc, argv );
g_launcher = new JGameLauncher();
u32 flags = g_launcher->GetInitFlags();
if ((flags&JINIT_FLAG_ENABLE3D)!=0)
JRenderer::Set3DFlag(true);
g_glwidget = new JGEQtRenderer(NULL);
g_glwidget->resize(ACTUAL_SCREEN_WIDTH, ACTUAL_SCREEN_HEIGHT);
g_glwidget->show();
if (!InitGame())
{
printf("Could not init the game\n");
return 1;
}
JGECreateDefaultBindings();
a.exec();
if (g_launcher)
delete g_launcher;
if(g_glwidget)
delete g_glwidget;
// Shutdown
DestroyGame();
return 0;
}

View File

@@ -112,7 +112,7 @@ int SetupCallbacks(void)
#ifdef DEVHOOK
//code by sakya, crazyc, samuraiX
//http://forums.ps2dev.org/viewtopic.php?t=9591&sid=2056889f6b9531194cab9b2d487df844
//http://forums.ps2dev.org/viewtopic.php?t=9591
PspDebugRegBlock exception_regs;
extern int _ftext;

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,6 @@
//
//-------------------------------------------------------------------------------------
#ifdef WITH_FMOD
#include "../../Dependencies/include/fmod.h"
#else
@@ -21,6 +20,9 @@
//////////////////////////////////////////////////////////////////////////
JMusic::JMusic()
#ifdef USE_PHONON
: mOutput(0), mMediaObject(0)
#endif
{
}
@@ -38,24 +40,47 @@ int JMusic::getPlayTime(){
JMusic::~JMusic()
{
#ifdef USE_PHONON
if(mOutput)
delete mOutput;
if(mMediaObject)
delete mMediaObject;
#else
#ifdef WITH_FMOD
JSoundSystem::GetInstance()->StopMusic(this);
if (mTrack) FSOUND_Sample_Free(mTrack);
#endif
#endif
}
#ifdef USE_PHONON
void JMusic::seekAtTheBegining()
{
mMediaObject->seek(0);
}
#endif
//////////////////////////////////////////////////////////////////////////
JSample::JSample()
#ifdef USE_PHONON
: mOutput(0), mMediaObject(0)
#endif
{
}
JSample::~JSample()
{
#ifdef USE_PHONON
if(mOutput)
delete mOutput;
if(mMediaObject)
delete mMediaObject;
#else
#ifdef WITH_FMOD
if (mSample) FSOUND_Sample_Free(mSample);
#endif
#endif
}
unsigned long JSample::fileSize()
@@ -96,7 +121,9 @@ JSoundSystem::JSoundSystem()
{
mVolume = 0;
mSampleVolume = 0;
#ifdef WITH_FMOD
mChannel = FSOUND_FREE;
#endif
}
JSoundSystem::~JSoundSystem()
@@ -121,6 +148,18 @@ void JSoundSystem::DestroySoundSystem()
JMusic *JSoundSystem::LoadMusic(const char *fileName)
{
#ifdef USE_PHONON
JMusic* music = new JMusic();
if (music)
{
music->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
music->mMediaObject = new Phonon::MediaObject(0);
music->mMediaObject->setCurrentSource("Res/" + QString(fileName));
Phonon::Path path = Phonon::createPath(music->mMediaObject, music->mOutput);
Q_ASSERT(path.isValid());
}
return music;
#else
#ifndef WITH_FMOD
return NULL;
#else
@@ -141,11 +180,24 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
}
return music;
#endif
#endif
}
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
{
#ifdef USE_PHONON
if (music && music->mMediaObject && music->mOutput)
{
if(looping)
{
music->mMediaObject->connect(music->mMediaObject, SIGNAL(aboutToFinish()), music, SLOT(seekAtTheBegining()));
}
music->mOutput->setVolume((qreal)mVolume*0.01);
music->mMediaObject->play();
}
#else
#ifdef WITH_FMOD
if (music && music->mTrack)
{
@@ -158,14 +210,22 @@ void JSoundSystem::PlayMusic(JMusic *music, bool looping)
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF);
}
#endif
#endif
}
void JSoundSystem::StopMusic(JMusic *music)
{
#ifdef USE_PHONON
if (music && music->mMediaObject && music->mOutput)
{
music->mMediaObject->stop();
}
#else
#ifdef WITH_FMOD
FSOUND_StopSound(mChannel);
#endif
#endif
}
@@ -195,6 +255,18 @@ void JSoundSystem::SetSfxVolume(int volume){
JSample *JSoundSystem::LoadSample(const char *fileName)
{
#ifdef USE_PHONON
JSample* sample = new JSample();
if (sample)
{
sample->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
sample->mMediaObject = new Phonon::MediaObject(0);
sample->mMediaObject->setCurrentSource("Res/" + QString(fileName));
Phonon::Path path = Phonon::createPath(sample->mMediaObject, sample->mOutput);
Q_ASSERT(path.isValid());
}
return sample;
#else
#ifndef WITH_FMOD
return NULL;
#else
@@ -217,16 +289,25 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
}
return sample;
#endif
#endif
}
void JSoundSystem::PlaySample(JSample *sample)
{
#ifdef USE_PHONON
if (sample && sample->mMediaObject && sample->mOutput)
{
sample->mOutput->setVolume((qreal)mSampleVolume*0.01);
sample->mMediaObject->play();
}
#else
#ifdef WITH_FMOD
if (sample && sample->mSample){
int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample);
FSOUND_SetVolumeAbsolute(channel,mSampleVolume * 2.55);
}
#endif
#endif
}

View File

@@ -69,7 +69,7 @@ protected:
int price; //Base price.
int minCards, maxCards;
vector<MTGPackSlot*> slots;
vector<MTGPackSlot*> slotss;
};
class MTGPacks{

View File

@@ -23,6 +23,10 @@
#define NEW new
#endif
#ifdef QT_CONFIG
#include <QtGlobal>
#define OutputDebugString(val) qDebug(val)
#else
#ifdef LINUX
#ifdef _DEBUG
#define OutputDebugString(val) (std::cerr << val);
@@ -30,6 +34,8 @@
#define OutputDebugString(val) {}
#endif
#endif
#endif
#ifndef RESPATH
#define RESPATH "Res"

View File

@@ -819,12 +819,15 @@ bool ShopBooster::unitTest(){
u+=ddw->count(c);
card++;
}
int count = ddw->getCount();
SAFE_DELETE(ddw);
SAFE_DELETE(d);
if(r != 1 || u != 3 ){
sprintf(result, "<span class=\"error\">==Unexpected rarity count==</span><br />");
TestSuite::Log(result);
res = false;
}
if(ddw->getCount() < 14) {
if(count < 14) {
sprintf(result, "<span class=\"error\">==Unexpected card count==</span><br />");
TestSuite::Log(result);
res = false;

View File

@@ -1095,16 +1095,21 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
ab = NEW ABecomes(id,card,target,stypes,pt,sabilities);
}return ab;
}
//bloodthirst
found = s.find("bloodthirst:");
if (found != string::npos){
size_t start = s.find(":",found);
size_t end = s.find(" ",start);
int amount;
if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());}
else{amount = atoi(s.substr(start+1).c_str());}
if (end != string::npos){
amount = atoi(s.substr(start+1,end-start-1).c_str());
} else {
amount = atoi(s.substr(start+1).c_str());
}
MTGAbility * a = NEW ABloodThirst(id,card,target,amount);
return a;}
return a;
}

View File

@@ -93,8 +93,8 @@ int MTGPack::assemblePack(MTGDeck *to){
if(!p) return -1;
p->Shuffle();
for(size_t i=0;i<slots.size();i++){
carryover = slots[i]->add(p,to,carryover);
for(size_t i=0;i<slotss.size();i++){
carryover = slotss[i]->add(p,to,carryover);
if(carryover > 0)
carryover = carryover; //This means we're failing.
}
@@ -104,8 +104,8 @@ int MTGPack::assemblePack(MTGDeck *to){
void MTGPack::countCards(){
minCards = 0;
maxCards = 0;
for(size_t i=0;i<slots.size();i++){
MTGPackSlot * ps = slots[i];
for(size_t i=0;i<slotss.size();i++){
MTGPackSlot * ps = slotss[i];
int top = 0;
int bot = 999999999;
for(size_t y=0;y<ps->entries.size();y++){
@@ -160,7 +160,7 @@ void MTGPack::load(string filename){
std::transform(tag.begin(),tag.end(),tag.begin(),::tolower);
if(tag != "slot") continue;
MTGPackSlot * s = NEW MTGPackSlot();
slots.push_back(s);
slotss.push_back(s);
holder = pSlot->Attribute("copies");
if(holder) s->copies = atoi(holder);
else s->copies = 1;
@@ -202,10 +202,10 @@ MTGPackSlot::~MTGPackSlot(){
entries.clear();
}
MTGPack::~MTGPack(){
for(size_t t=0;t<slots.size();t++){
SAFE_DELETE(slots[t]);
for(size_t t=0;t<slotss.size();t++){
SAFE_DELETE(slotss[t]);
}
slots.clear();
slotss.clear();
}
MTGPacks::~MTGPacks(){
for(size_t t=0;t<packs.size();t++){
@@ -283,16 +283,16 @@ MTGPack * MTGPacks::getDefault(){
ps->addEntry(NEW MTGPackEntryRandom("rarity:mythic;"));
for(int i=0;i<7;i++)
ps->addEntry(NEW MTGPackEntryRandom("rarity:rare;"));
defaultBooster.slots.push_back(ps);
defaultBooster.slotss.push_back(ps);
ps = NEW MTGPackSlot(); ps->copies = 3;
ps->addEntry(NEW MTGPackEntryRandom("rarity:uncommon;"));
defaultBooster.slots.push_back(ps);
defaultBooster.slotss.push_back(ps);
ps = NEW MTGPackSlot(); ps->copies = 1;
ps->addEntry(NEW MTGPackEntryRandom("rarity:land;&type:basic;"));
defaultBooster.slots.push_back(ps);
defaultBooster.slotss.push_back(ps);
ps = NEW MTGPackSlot(); ps->copies = 10;
ps->addEntry(NEW MTGPackEntryRandom("rarity:common;"));
defaultBooster.slots.push_back(ps);
defaultBooster.slotss.push_back(ps);
defaultBooster.bValid = true;
defaultBooster.unlockStatus = 1;
}

321
projects/mtg/wagic.pro Normal file
View File

@@ -0,0 +1,321 @@
#-------------------------------------------------
#
# Project created by QtCreator 2010-06-30T19:48:30
#
#-------------------------------------------------
QT += core gui opengl
VERSION = 1.2.3
TARGET = wagic
TEMPLATE = app
windows:DEFINES += WIN32
windows:DEFINES += _CRT_SECURE_NO_WARNINGS
windows:DEFINES += FORCE_GL2
unix:DEFINES += LINUX
DEFINES += QT_CONFIG
maemo5 {
DEFINES += USE_PHONON
QT += phonon
}
windows:INCLUDEPATH += ../../JGE/Dependencies/include
unix:INCLUDEPATH += /usr/include/GL
unix:INCLUDEPATH += /usr/include/freetype2
INCLUDEPATH += ../../JGE/include
INCLUDEPATH += include
unix:LIBS += -ljpeg -lgif -lpng12
windows:LIBS += -LD:\Projects\Wagic\JGE\Dependencies\lib -llibjpeg-static-mt-debug -lgiflib -llibpng -lfmodvc
# MGT
SOURCES += \
src/ActionElement.cpp\
src/ActionLayer.cpp\
src/ActionStack.cpp\
src/AIMomirPlayer.cpp\
src/AIPlayer.cpp\
src/AIStats.cpp\
src/CardDescriptor.cpp\
src/CardDisplay.cpp\
src/CardEffect.cpp\
src/CardGui.cpp\
src/CardPrimitive.cpp\
src/CardSelector.cpp\
src/Closest.cpp\
src/Counters.cpp\
src/Credits.cpp\
src/Damage.cpp\
src/DamagerDamaged.cpp\
src/DeckDataWrapper.cpp\
src/DeckMetaData.cpp\
src/DeckManager.cpp\
src/DeckStats.cpp\
src/DuelLayers.cpp\
src/Effects.cpp\
src/ExtraCost.cpp\
src/GameApp.cpp\
src/GameLauncher.cpp\
src/GameObserver.cpp\
src/GameOptions.cpp\
src/GameStateAwards.cpp\
src/GameState.cpp\
src/GameStateDeckViewer.cpp\
src/GameStateDuel.cpp\
src/GameStateMenu.cpp\
src/GameStateOptions.cpp\
src/GameStateShop.cpp\
src/GameStateStory.cpp\
src/GameStateTransitions.cpp\
src/GuiAvatars.cpp\
src/GuiBackground.cpp\
src/GuiCardsController.cpp\
src/GuiCombat.cpp\
src/GuiFrame.cpp\
src/GuiHand.cpp\
src/GuiLayers.cpp\
src/GuiMana.cpp\
src/GuiPhaseBar.cpp\
src/GuiPlay.cpp\
src/GuiStatic.cpp\
src/Logger.cpp\
src/ManaCost.cpp\
src/ManaCostHybrid.cpp\
src/MenuItem.cpp\
src/MTGAbility.cpp\
src/MTGCard.cpp\
src/MTGCardInstance.cpp\
src/MTGDeck.cpp\
src/MTGDefinitions.cpp\
src/MTGGamePhase.cpp\
src/MTGGameZones.cpp\
src/MTGPack.cpp\
src/MTGRules.cpp\
src/OptionItem.cpp\
src/PhaseRing.cpp\
src/Player.cpp\
src/PlayerData.cpp\
src/PlayGuiObject.cpp\
src/PlayGuiObjectController.cpp\
src/Pos.cpp\
src/PriceList.cpp\
src/ReplacementEffects.cpp\
src/Rules.cpp\
src/SimpleMenu.cpp\
src/SimpleMenuItem.cpp\
src/SimplePad.cpp\
src/StoryFlow.cpp\
src/Subtypes.cpp\
src/StyleManager.cpp\
src/TargetChooser.cpp\
src/TargetsList.cpp\
src/Tasks.cpp\
src/TestSuiteAI.cpp\
src/TextScroller.cpp\
src/ThisDescriptor.cpp\
src/Token.cpp\
src/Translate.cpp\
src/TranslateKeys.cpp\
src/Trash.cpp\
src/utils.cpp\
src/WCachedResource.cpp\
src/WDataSrc.cpp\
src/WEvent.cpp\
src/WFilter.cpp\
src/WFont.cpp\
src/WGui.cpp\
src/WResourceManager.cpp
HEADERS += \
include/ExtraCost.h\
include/ManaCost.h\
include/SimpleMenuItem.h\
include/GameApp.h\
include/ManaCostHybrid.h\
include/SimplePad.h\
include/ActionElement.h\
include/GameObserver.h\
include/MenuItem.h\
include/StoryFlow.h\
include/ActionLayer.h\
include/GameOptions.h\
include/MTGAbility.h\
include/Subtypes.h\
include/ActionStack.h\
include/GameStateAwards.h\
include/MTGCard.h\
include/AIMomirPlayer.h\
include/GameStateDeckViewer.h\
include/MTGCardInstance.h\
include/Targetable.h\
include/AIPlayer.h\
include/GameStateDuel.h\
include/MTGDeck.h\
include/TargetChooser.h\
include/AIStats.h\
include/GameState.h\
include/MTGDefinitions.h\
include/TargetsList.h\
include/AllAbilities.h\
include/GameStateMenu.h\
include/MTGGamePhase.h\
include/Tasks.h\
include/CardDescriptor.h\
include/GameStateOptions.h\
include/MTGGameZones.h\
include/TestSuiteAI.h\
include/CardDisplay.h\
include/GameStateShop.h\
include/MTGPack.h\
include/TextScroller.h\
include/CardEffect.h\
include/GameStateStory.h\
include/MTGRules.h\
include/ThisDescriptor.h\
include/CardGui.h\
include/GameStateTransitions.h\
include/OptionItem.h\
include/Token.h\
include/CardPrimitive.h\
include/GuiAvatars.h\
include/OSD.h\
include/Translate.h\
include/CardSelector.h\
include/GuiBackground.h\
include/PhaseRing.h\
include/TranslateKeys.h\
include/config.h\
include/GuiCardsController.h\
include/PlayerData.h\
include/Trash.h\
include/Counters.h\
include/GuiCombat.h\
include/Player.h\
include/utils.h\
include/Credits.h\
include/GuiFrame.h\
include/PlayGuiObjectController.h\
include/WCachedResource.h\
include/Damage.h\
include/GuiHand.h\
include/PlayGuiObject.h\
include/WDataSrc.h\
include/DamagerDamaged.h\
include/GuiLayers.h\
include/Pos.h\
include/WEvent.h\
include/DeckDataWrapper.h\
include/GuiMana.h\
include/PriceList.h\
include/WFilter.h\
include/DeckMetaData.h\
include/GuiPhaseBar.h\
include/ReplacementEffects.h\
include/WGui.h\
include/DeckStats.h\
include/GuiPlay.h\
include/Rules.h\
include/WResourceManager.h\
include/DuelLayers.h\
include/GuiStatic.h\
include/ShopItem.h\
include/Effects.h\
include/Logger.h\
include/StyleManager.h\
include/WFont.h\
include/DeckManager.h\
include/SimpleMenu.h
# JGE, could probably be moved outside
SOURCES += \
../../JGE/src/Qtmain.cpp\
../../JGE/src/Encoding.cpp\
../../JGE/src/JAnimator.cpp\
../../JGE/src/JApp.cpp\
../../JGE/src/JDistortionMesh.cpp\
../../JGE/src/JFileSystem.cpp\
../../JGE/src/JGameObject.cpp\
../../JGE/src/JGBKFont.cpp\
../../JGE/src/JGE.cpp\
../../JGE/src/JGui.cpp\
../../JGE/src/JLBFont.cpp\
../../JGE/src/JLogger.cpp\
../../JGE/src/JMD2Model.cpp\
../../JGE/src/JOBJModel.cpp\
../../JGE/src/JParticle.cpp\
../../JGE/src/JParticleEffect.cpp\
../../JGE/src/JParticleEmitter.cpp\
../../JGE/src/JParticleSystem.cpp\
../../JGE/src/JResourceManager.cpp\
../../JGE/src/JSpline.cpp\
../../JGE/src/JSprite.cpp\
../../JGE/src/JTTFont.cpp\
../../JGE/src/Vector2D.cpp\
../../JGE/src/tinyxml/tinystr.cpp\
../../JGE/src/tinyxml/tinyxml.cpp\
../../JGE/src/tinyxml/tinyxmlerror.cpp\
../../JGE/src/tinyxml/tinyxmlparser.cpp\
../../JGE/src/hge/hgecolor.cpp\
../../JGE/src/hge/hgedistort.cpp\
../../JGE/src/hge/hgefont.cpp\
../../JGE/src/hge/hgeparticle.cpp\
../../JGE/src/hge/hgerect.cpp\
../../JGE/src/hge/hgevector.cpp\
../../JGE/src/unzip/ioapi.c\
../../JGE/src/unzip/mztools.c\
../../JGE/src/unzip/unzip.c\
../../JGE/src/pc/JSfx.cpp\
../../JGE/src/pc/JGfx.cpp
HEADERS += \
../../JGE/include/decoder_prx.h\
../../JGE/include/Encoding.h\
../../JGE/include/JAnimator.h\
../../JGE/include/JApp.h\
../../JGE/include/JAssert.h\
../../JGE/include/JCooleyesMP3.h\
../../JGE/include/JDistortionMesh.h\
../../JGE/include/JFileSystem.h\
../../JGE/include/JGameLauncher.h\
../../JGE/include/JGameObject.h\
../../JGE/include/JGBKFont.h\
../../JGE/include/JGE.h\
../../JGE/include/JGui.h\
../../JGE/include/JLBFont.h\
../../JGE/include/JLogger.h\
../../JGE/include/JMD2Model.h\
../../JGE/include/JMP3.h\
../../JGE/include/JNetwork.h\
../../JGE/include/JOBJModel.h\
../../JGE/include/JParticleEffect.h\
../../JGE/include/JParticleEmitter.h\
../../JGE/include/JParticle.h\
../../JGE/include/JParticleSystem.h\
../../JGE/include/JRenderer.h\
../../JGE/include/JResourceManager.h\
../../JGE/include/JSocket.h\
../../JGE/include/JSoundSystem.h\
../../JGE/include/JSpline.h\
../../JGE/include/JSprite.h\
../../JGE/include/JTTFont.h\
../../JGE/include/JTypes.h\
../../JGE/include/Vector2D.h\
../../JGE/include/Vector3D.h\
../../JGE/include/vram.h\
../../JGE/src/tinyxml\tinystr.h\
../../JGE/src/tinyxml\tinyxml.h\
../../JGE/include/vram.h
FORMS +=
CONFIG += mobility
MOBILITY =
symbian {
TARGET.UID3 = 0xe3fa5a9c
# TARGET.CAPABILITY +=
TARGET.EPOCSTACKSIZE = 0x14000
TARGET.EPOCHEAPSIZE = 0x020000 0x800000
}
OTHER_FILES +=
RESOURCES +=