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

@@ -1,2 +1,2 @@
language: cpp language: cpp
script: "qmake projects/mtg/wagic-qt.pro && make -j 8" script: "qmake projects/mtg/wagic-qt.pro CONFIG+=testsuite CONFIG+=debug && make -j 8 && ./wagic testsuite"

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,6 +3,13 @@
#include "corewrapper.h" #include "corewrapper.h"
#include <QElapsedTimer> #include <QElapsedTimer>
#ifdef TESTSUITE
#include "TestSuiteAI.h"
#include "GameOptions.h"
#include "MTGDeck.h"
#endif
#include "DebugRoutines.h"
#if (defined FORCE_GLES) #if (defined FORCE_GLES)
#undef GL_ES_VERSION_2_0 #undef GL_ES_VERSION_2_0
#undef GL_VERSION_2_0 #undef GL_VERSION_2_0
@@ -72,6 +79,64 @@ WagicCore::WagicCore(super *parent) :
#endif #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() void WagicCore::initApp()
{ {
if(!m_engine) if(!m_engine)

View File

@@ -8,7 +8,7 @@ A class for very simple menus structure
#include <JGui.h> #include <JGui.h>
#include "WFont.h" #include "WFont.h"
#include "hge/hgeparticle.h" #include "hge/hgeparticle.h"
#include "WResourceManager.h"
#include "WResource_Fwd.h" #include "WResource_Fwd.h"
class SimpleMenu: public JGuiController class SimpleMenu: public JGuiController
@@ -37,7 +37,7 @@ private:
public: public:
bool autoTranslate; bool autoTranslate;
bool isMultipleChoice; bool isMultipleChoice;
SimpleMenu(JGE*, int id, JGuiListener* listener, int fontId, float x, float y, const char * _title = "", int _maxItems = 7, bool centerHorizontal = true, bool centerVertical = true); SimpleMenu(JGE*, WResourceManager*, int id, JGuiListener* listener, int fontId, float x, float y, const char * _title = "", int _maxItems = 7, bool centerHorizontal = true, bool centerVertical = true);
virtual ~SimpleMenu(); virtual ~SimpleMenu();
virtual void Render(); virtual void Render();
virtual bool CheckUserInput(JButton key); virtual bool CheckUserInput(JButton key);

View File

@@ -1,6 +1,6 @@
/* /*
This file was auto-generated by ant build script on Sun, 06-May-2012 11::58:10 This file was auto-generated by ant build script on Sat, 26-Oct-2013 23::59:07
To make changes please edit the ant build script, otherwise your changes will be lost To make changes please edit the ant build script, otherwise your changes will be lost
Author: Michael Nguyen Author: Michael Nguyen

View File

@@ -109,10 +109,12 @@ bool AutoLineMacro::AddMacro(const string& s)
void AutoLineMacro::Destroy() void AutoLineMacro::Destroy()
{ {
for (size_t i = 0; i < gAutoLineMacros.size(); ++i) while(gAutoLineMacros.size())
{ {
SAFE_DELETE(gAutoLineMacros[i]); SAFE_DELETE(gAutoLineMacros.back());
gAutoLineMacros.pop_back();
} }
gAutoLineMacrosIndex.clear();
} }
string AutoLineMacro::Process(const string& s) string AutoLineMacro::Process(const string& s)

View File

@@ -384,8 +384,8 @@ void ActionLayer::setMenuObject(Targetable * object, bool must)
SAFE_DELETE(abilitiesMenu); SAFE_DELETE(abilitiesMenu);
abilitiesTriggered = NULL; abilitiesTriggered = NULL;
abilitiesMenu = NEW SimpleMenu(observer->getInput(), 10, this, Fonts::MAIN_FONT, 100, 100, object->getDisplayName().c_str()); abilitiesMenu = NEW SimpleMenu(observer->getInput(), observer->getResourceManager(), 10, this, Fonts::MAIN_FONT, 100, 100, object->getDisplayName().c_str());
abilitiesTriggered = NEW SimpleMenu(observer->getInput(), 10, this, Fonts::MAIN_FONT, 100, 100, object->getDisplayName().c_str()); abilitiesTriggered = NEW SimpleMenu(observer->getInput(), observer->getResourceManager(), 10, this, Fonts::MAIN_FONT, 100, 100, object->getDisplayName().c_str());
currentActionCard = (MTGCardInstance*)object; currentActionCard = (MTGCardInstance*)object;
for (size_t i = 0; i < mObjects.size(); i++) for (size_t i = 0; i < mObjects.size(); i++)
{ {
@@ -434,7 +434,7 @@ void ActionLayer::setCustomMenuObject(Targetable * object, bool must,vector<MTGA
} }
menuObject = object; menuObject = object;
SAFE_DELETE(abilitiesMenu); SAFE_DELETE(abilitiesMenu);
abilitiesMenu = NEW SimpleMenu(observer->getInput(), 10, this, Fonts::MAIN_FONT, 100, 100, customName.size()?customName.c_str():object->getDisplayName().c_str()); abilitiesMenu = NEW SimpleMenu(observer->getInput(), observer->getResourceManager(), 10, this, Fonts::MAIN_FONT, 100, 100, customName.size()?customName.c_str():object->getDisplayName().c_str());
currentActionCard = NULL; currentActionCard = NULL;
abilitiesMenu->isMultipleChoice = false; abilitiesMenu->isMultipleChoice = false;
if(abilities.size()) if(abilities.size())

View File

@@ -184,7 +184,7 @@ void GameStateAwards::Update(float dt)
case JGE_BTN_MENU: case JGE_BTN_MENU:
showMenu = true; showMenu = true;
SAFE_DELETE(menu); SAFE_DELETE(menu);
menu = NEW SimpleMenu(JGE::GetInstance(), EXIT_AWARDS_MENU, this, Fonts::MENU_FONT, 50, 170); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), EXIT_AWARDS_MENU, this, Fonts::MENU_FONT, 50, 170);
if (mState == STATE_DETAILS) if (mState == STATE_DETAILS)
menu->Add(kBackToTrophiesID, "Back to Trophies"); menu->Add(kBackToTrophiesID, "Back to Trophies");
menu->Add(kBackToMainMenuID, "Back to Main Menu"); menu->Add(kBackToMainMenuID, "Back to Main Menu");

View File

@@ -363,7 +363,7 @@ void GameStateDeckViewer::sellCard()
sprintf(buffer, "%s : %i %s", _(card->data->getName()).c_str(), price, _("credits").c_str()); sprintf(buffer, "%s : %i %s", _(card->data->getName()).c_str(), price, _("credits").c_str());
const float menuXOffset = SCREEN_WIDTH_F - 300; const float menuXOffset = SCREEN_WIDTH_F - 300;
const float menuYOffset = SCREEN_HEIGHT_F / 2; const float menuYOffset = SCREEN_HEIGHT_F / 2;
subMenu = NEW SimpleMenu(JGE::GetInstance(), MENU_CARD_PURCHASE, this, Fonts::MAIN_FONT, menuXOffset, menuYOffset, buffer); subMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_CARD_PURCHASE, this, Fonts::MAIN_FONT, menuXOffset, menuYOffset, buffer);
subMenu->Add(MENU_ITEM_YES, "Yes"); subMenu->Add(MENU_ITEM_YES, "Yes");
subMenu->Add(MENU_ITEM_NO, "No", "", true); subMenu->Add(MENU_ITEM_NO, "No", "", true);
} }

View File

@@ -497,7 +497,7 @@ void GameStateDuel::Update(float dt)
case DUEL_STATE_PREPARE_CNOGMENU: case DUEL_STATE_PREPARE_CNOGMENU:
SAFE_DELETE(cnogmenu); SAFE_DELETE(cnogmenu);
cnogmenu = NEW SimpleMenu(JGE::GetInstance(),DUEL_MENU_CHOOSE_NUMBER_OF_GAMES, this, Fonts::MENU_FONT,35,25,"How many games per match?"); cnogmenu = NEW SimpleMenu(JGE::GetInstance(),WResourceManager::Instance(), DUEL_MENU_CHOOSE_NUMBER_OF_GAMES, this, Fonts::MENU_FONT,35,25,"How many games per match?");
cnogmenu->Add(CNOGMENU_ITEM_SINGLE_GAME,"Single Game",""); cnogmenu->Add(CNOGMENU_ITEM_SINGLE_GAME,"Single Game","");
if (tournament->checkTournamentFile(mParent->players[0] == PLAYER_TYPE_CPU)) if (tournament->checkTournamentFile(mParent->players[0] == PLAYER_TYPE_CPU))
cnogmenu->Add(CNOGMENU_ITEM_CONTINUE_TOURNAMENT,"Continue Tournament",""); cnogmenu->Add(CNOGMENU_ITEM_CONTINUE_TOURNAMENT,"Continue Tournament","");
@@ -924,7 +924,7 @@ void GameStateDuel::Update(float dt)
{ {
if (!menu) if (!menu)
{ {
menu = NEW SimpleMenu(JGE::GetInstance(), DUEL_MENU_GAME_MENU, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), DUEL_MENU_GAME_MENU, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25);
int cardsinhand = game->currentPlayer->game->hand->nb_cards; int cardsinhand = game->currentPlayer->game->hand->nb_cards;
//almosthumane - mulligan //almosthumane - mulligan
@@ -971,7 +971,7 @@ void GameStateDuel::Update(float dt)
setGamePhase(DUEL_STATE_PLAY); setGamePhase(DUEL_STATE_PLAY);
} else if(menu == NULL) } else if(menu == NULL)
{ {
menu = NEW SimpleMenu(JGE::GetInstance(), DUEL_STATE_OPPONENT_WAIT, this, Fonts::MENU_FONT, 150, 60); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), DUEL_STATE_OPPONENT_WAIT, this, Fonts::MENU_FONT, 150, 60);
if (menu) if (menu)
{ {
menu->Add(MENUITEM_MAIN_MENU, "Back to main menu"); menu->Add(MENUITEM_MAIN_MENU, "Back to main menu");

View File

@@ -344,7 +344,7 @@ void GameStateMenu::setLang(int id)
void GameStateMenu::loadLangMenu() void GameStateMenu::loadLangMenu()
{ {
LOG("GameStateMenu::loadLangMenu"); LOG("GameStateMenu::loadLangMenu");
subMenuController = NEW SimpleMenu(JGE::GetInstance(), MENU_LANGUAGE_SELECTION, this, Fonts::MENU_FONT, 150, 60); subMenuController = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_LANGUAGE_SELECTION, this, Fonts::MENU_FONT, 150, 60);
if (!subMenuController) if (!subMenuController)
return; return;
@@ -590,7 +590,7 @@ void GameStateMenu::Update(float dt)
if(MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) if(MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR))
{ {
currentState = MENU_STATE_MAJOR_SUBMENU; currentState = MENU_STATE_MAJOR_SUBMENU;
subMenuController = NEW SimpleMenu(JGE::GetInstance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60); subMenuController = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
if (subMenuController) if (subMenuController)
{ {
subMenuController->Add(SUBMENUITEM_HOST_GAME, "Host a game"); subMenuController->Add(SUBMENUITEM_HOST_GAME, "Host a game");
@@ -613,7 +613,7 @@ void GameStateMenu::Update(float dt)
mParent->mpNetwork->getServerIp(aString); mParent->mpNetwork->getServerIp(aString);
aString = "Waiting for connection to " + aString; aString = "Waiting for connection to " + aString;
subMenuController = NEW SimpleMenu(JGE::GetInstance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60, aString.c_str()); subMenuController = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60, aString.c_str());
if (subMenuController) if (subMenuController)
{ {
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel"); subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
@@ -641,7 +641,7 @@ void GameStateMenu::Update(float dt)
if (!hasChosenGameType) if (!hasChosenGameType)
{ {
currentState = MENU_STATE_MAJOR_SUBMENU; currentState = MENU_STATE_MAJOR_SUBMENU;
subMenuController = NEW SimpleMenu(JGE::GetInstance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60); subMenuController = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
if (subMenuController) if (subMenuController)
{ {
for (size_t i = 0; i < Rules::RulesList.size(); ++i) for (size_t i = 0; i < Rules::RulesList.size(); ++i)
@@ -823,7 +823,7 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
switch (controlId) switch (controlId)
{ {
case MENUITEM_PLAY: case MENUITEM_PLAY:
subMenuController = NEW SimpleMenu(JGE::GetInstance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60); subMenuController = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
if (subMenuController) if (subMenuController)
{ {
#ifdef NETWORK_SUPPORT #ifdef NETWORK_SUPPORT

View File

@@ -117,7 +117,7 @@ void GameStateOptions::Start()
optionsList->failMsg = ""; optionsList->failMsg = "";
optionsTabs->Add(optionsList); optionsTabs->Add(optionsList);
optionsMenu = NEW SimpleMenu(JGE::GetInstance(), -102, this, Fonts::MAIN_FONT, 50, 170); optionsMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -102, this, Fonts::MAIN_FONT, 50, 170);
optionsMenu->Add(kBackToMainMenuID, "Back to Main Menu"); optionsMenu->Add(kBackToMainMenuID, "Back to Main Menu");
optionsMenu->Add(kSaveAndBackToMainMenuID, "Save And Exit"); optionsMenu->Add(kSaveAndBackToMainMenuID, "Save And Exit");
optionsMenu->Add(kCancelMenuID, "Cancel"); optionsMenu->Add(kCancelMenuID, "Cancel");

View File

@@ -212,12 +212,12 @@ void GameStateShop::beginPurchase(int controlId)
SAFE_DELETE(menu); SAFE_DELETE(menu);
if (mInventory[controlId] <= 0) if (mInventory[controlId] <= 0)
{ {
menu = NEW SimpleMenu(JGE::GetInstance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Sold Out").c_str()); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Sold Out").c_str());
menu->Add(-1, "Ok"); menu->Add(-1, "Ok");
} }
else if (playerdata->credits - mPrices[controlId] < 0) else if (playerdata->credits - mPrices[controlId] < 0)
{ {
menu = NEW SimpleMenu(JGE::GetInstance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Not enough credits").c_str()); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Not enough credits").c_str());
menu->Add(-1, "Ok"); menu->Add(-1, "Ok");
if (options[Options::CHEATMODE].number) if (options[Options::CHEATMODE].number)
{ {
@@ -231,7 +231,7 @@ void GameStateShop::beginPurchase(int controlId)
sprintf(buf, _("Purchase Booster: %i credits").c_str(), mPrices[controlId]); sprintf(buf, _("Purchase Booster: %i credits").c_str(), mPrices[controlId]);
else else
sprintf(buf, _("Purchase Card: %i credits").c_str(), mPrices[controlId]); sprintf(buf, _("Purchase Card: %i credits").c_str(), mPrices[controlId]);
menu = NEW SimpleMenu(JGE::GetInstance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, buf); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, buf);
menu->Add(controlId, "Yes"); menu->Add(controlId, "Yes");
menu->Add(-1, "No"); menu->Add(-1, "No");
@@ -486,7 +486,7 @@ void GameStateShop::Update(float dt)
menu->Update(dt); menu->Update(dt);
else else
{ {
menu = NEW SimpleMenu(JGE::GetInstance(), 11, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 20); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 11, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 20);
menu->Add(22, _("Ask about...").c_str()); menu->Add(22, _("Ask about...").c_str());
menu->Add(14, _("Check task board").c_str()); menu->Add(14, _("Check task board").c_str());
if (options[Options::CHEATMODE].number) if (options[Options::CHEATMODE].number)
@@ -516,7 +516,7 @@ void GameStateShop::Update(float dt)
{ {
if (!menu) if (!menu)
{ {
menu = NEW SimpleMenu(JGE::GetInstance(), 11, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 20); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 11, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 20);
menu->Add(15, "Return to shop"); menu->Add(15, "Return to shop");
menu->Add(12, "Save And Exit"); menu->Add(12, "Save And Exit");
menu->Add(kCancelMenuID, "Cancel"); menu->Add(kCancelMenuID, "Cancel");

View File

@@ -44,7 +44,7 @@ void GameStateStory::loadStoriesMenu(const char * root)
flow = NEW StoryFlow(stories[0]); flow = NEW StoryFlow(stories[0]);
break; break;
default: default:
menu = NEW SimpleMenu(JGE::GetInstance(), 103, this, Fonts::MENU_FONT, 150, 60); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 103, this, Fonts::MENU_FONT, 150, 60);
for (size_t i = 0; i < stories.size(); ++i) for (size_t i = 0; i < stories.size(); ++i)
{ {
menu->Add(i, stories[i].c_str()); menu->Add(i, stories[i].c_str());
@@ -64,7 +64,7 @@ void GameStateStory::Update(float dt)
{ {
if (!menu && mEngine->GetButtonClick(JGE_BTN_MENU)) if (!menu && mEngine->GetButtonClick(JGE_BTN_MENU))
{ {
menu = NEW SimpleMenu(JGE::GetInstance(), 100, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 100, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25);
menu->Add(0, "Back to main menu"); menu->Add(0, "Back to main menu");
menu->Add(kCancelMenuID, "Cancel"); menu->Add(kCancelMenuID, "Cancel");
} }
@@ -142,4 +142,4 @@ void GameStateStory::OnScroll(int, int inYVelocity)
velocity -= 100; velocity -= 100;
} }
} }
} }

View File

@@ -45,14 +45,18 @@ GuiPhaseBar::GuiPhaseBar(DuelLayers* duelLayers) :
GuiLayer(duelLayers->getObserver()), PlayGuiObject(0, 0, 106, 0, false), GuiLayer(duelLayers->getObserver()), PlayGuiObject(0, 0, 106, 0, false),
phase(NULL), angle(0.0f), zoomFactor(ICONSCALE), mpDuelLayers(duelLayers) phase(NULL), angle(0.0f), zoomFactor(ICONSCALE), mpDuelLayers(duelLayers)
{ {
JQuadPtr quad = WResourceManager::Instance()->GetQuad("phasebar"); if(duelLayers->getObserver()->getResourceManager())
if (quad.get() != NULL)
{ {
quad->mHeight = kHeight; JQuadPtr quad = WResourceManager::Instance()->GetQuad("phasebar");
quad->mWidth = kWidth; if (quad.get() != NULL)
{
quad->mHeight = kHeight;
quad->mWidth = kWidth;
}
else
GameApp::systemError = "Error loading phasebar texture : " __FILE__;
} }
else
GameApp::systemError = "Error loading phasebar texture : " __FILE__;
zoom = ICONSCALE; zoom = ICONSCALE;
mpDuelLayers->getCardSelector()->Add(this); mpDuelLayers->getCardSelector()->Add(this);

View File

@@ -354,12 +354,12 @@ void MTGAllCards::loadFolder(const string& folder, const string& filename )
if(files[i] == "." || files[i] == "..") if(files[i] == "." || files[i] == "..")
continue; continue;
if(JFileSystem::GetInstance()->DirExists(afile))
loadFolder(string(afile).c_str(), filename);
if (!JFileSystem::GetInstance()->FileExists(afile)) if (!JFileSystem::GetInstance()->FileExists(afile))
continue; continue;
if(JFileSystem::GetInstance()->DirExists(afile))
loadFolder(string(afile+"/").c_str(), filename);
if(filename.size()) if(filename.size())
{ {
if(filename == files[i]) if(filename == files[i])

View File

@@ -614,7 +614,7 @@ void OptionKey::KeyPressed(LocalKeySym key)
g->UngrabKeyboard(this); g->UngrabKeyboard(this);
grabbed = false; grabbed = false;
btnMenu = NEW SimpleMenu(JGE::GetInstance(), 0, this, Fonts::MENU_FONT, 80, 10); btnMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 0, this, Fonts::MENU_FONT, 80, 10);
for (int i = sizeof(btnList) / sizeof(btnList[0]) - 1; i >= 0; --i) for (int i = sizeof(btnList) / sizeof(btnList[0]) - 1; i >= 0; --i)
{ {
const KeyRep& rep = translateKey(btnList[i]); const KeyRep& rep = translateKey(btnList[i]);

View File

@@ -33,8 +33,8 @@ JTexture* SimpleMenu::spadeLTex = NULL;
JTexture* SimpleMenu::jewelTex = NULL; JTexture* SimpleMenu::jewelTex = NULL;
JTexture* SimpleMenu::sideTex = NULL; JTexture* SimpleMenu::sideTex = NULL;
SimpleMenu::SimpleMenu(JGE* jge, int id, JGuiListener* listener, int fontId, float x, float y, const char * _title, int _maxItems, bool centerHorizontal, bool centerVertical) SimpleMenu::SimpleMenu(JGE* jge, WResourceManager* resourceManager, int id, JGuiListener* listener, int fontId, float x, float y, const char * _title, int _maxItems, bool centerHorizontal, bool centerVertical)
: JGuiController(jge, id, listener), fontId(fontId), mCenterHorizontal(centerHorizontal), mCenterVertical(centerVertical) : JGuiController(jge, id, listener), fontId(fontId), mCenterHorizontal(centerHorizontal), mCenterVertical(centerVertical), stars(0)
{ {
autoTranslate = true; autoTranslate = true;
isMultipleChoice = false; isMultipleChoice = false;
@@ -50,20 +50,23 @@ SimpleMenu::SimpleMenu(JGE* jge, int id, JGuiListener* listener, int fontId, flo
mClosed = false; mClosed = false;
selectionTargetY = selectionY = y + kVerticalMargin; selectionTargetY = selectionY = y + kVerticalMargin;
JRenderer* renderer = JRenderer::GetInstance(); if(resourceManager)
{
JRenderer* renderer = JRenderer::GetInstance();
if (!spadeLTex) spadeLTex = WResourceManager::Instance()->RetrieveTexture("spade_ul.png", RETRIEVE_MANAGE); if (!spadeLTex) spadeLTex = resourceManager->RetrieveTexture("spade_ul.png", RETRIEVE_MANAGE);
if (!spadeRTex) spadeRTex = WResourceManager::Instance()->RetrieveTexture("spade_ur.png", RETRIEVE_MANAGE); if (!spadeRTex) spadeRTex = resourceManager->RetrieveTexture("spade_ur.png", RETRIEVE_MANAGE);
if (!jewelTex) jewelTex = renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM); if (!jewelTex) jewelTex = renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM);
if (!sideTex) sideTex = WResourceManager::Instance()->RetrieveTexture("menuside.png", RETRIEVE_MANAGE); if (!sideTex) sideTex = resourceManager->RetrieveTexture("menuside.png", RETRIEVE_MANAGE);
spadeL = WResourceManager::Instance()->RetrieveQuad("spade_ul.png", 0, 0, 0, 0, "spade_ul", RETRIEVE_MANAGE); spadeL = resourceManager->RetrieveQuad("spade_ul.png", 0, 0, 0, 0, "spade_ul", RETRIEVE_MANAGE);
spadeR = WResourceManager::Instance()->RetrieveQuad("spade_ur.png", 0, 0, 0, 0, "spade_ur", RETRIEVE_MANAGE); spadeR = resourceManager->RetrieveQuad("spade_ur.png", 0, 0, 0, 0, "spade_ur", RETRIEVE_MANAGE);
jewel.reset(NEW JQuad(jewelTex, 1, 1, 3, 3)); jewel.reset(NEW JQuad(jewelTex, 1, 1, 3, 3));
side = WResourceManager::Instance()->RetrieveQuad("menuside.png", 1, 1, 1, kPoleWidth, "menuside", RETRIEVE_MANAGE); side = resourceManager->RetrieveQuad("menuside.png", 1, 1, 1, kPoleWidth, "menuside", RETRIEVE_MANAGE);
stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars").get())); stars = NEW hgeParticleSystem(resourceManager->RetrievePSI("stars.psi", resourceManager->GetQuad("stars").get()));
stars->FireAt(mX, mY); stars->FireAt(mX, mY);
}
} }
SimpleMenu::~SimpleMenu() SimpleMenu::~SimpleMenu()
@@ -300,10 +303,12 @@ void SimpleMenu::Update(float dt)
startId = mCurr - maxItems + 1; startId = mCurr - maxItems + 1;
else if (mCurr < startId) startId = mCurr; else if (mCurr < startId) startId = mCurr;
stars->Update(dt); if(stars)
stars->Update(dt);
selectionT += 3 * dt; selectionT += 3 * dt;
selectionY += (selectionTargetY - selectionY) * 8 * dt; selectionY += (selectionTargetY - selectionY) * 8 * dt;
stars->MoveTo(mX + kHorizontalMargin + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2), selectionY + 5 * cos( if(stars)
stars->MoveTo(mX + kHorizontalMargin + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2), selectionY + 5 * cos(
selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId); selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId);
if (timeOpen < 0) if (timeOpen < 0)
{ {
@@ -312,7 +317,8 @@ void SimpleMenu::Update(float dt)
{ {
timeOpen = 0; timeOpen = 0;
mClosed = true; mClosed = true;
stars->FireAt(mX, mY); if(stars)
stars->FireAt(mX, mY);
} }
} }
else else

View File

@@ -610,7 +610,7 @@ void TestSuite::ThreadProc(void* inParam)
int TestSuite::run() int TestSuite::run()
{ {
mProcessing = false; mProcessing = true;
loadNext(); loadNext();
ThreadProc(this); ThreadProc(this);

View File

@@ -552,7 +552,7 @@ void WDecoConfirm::Entering(JButton key)
SAFE_DELETE(confirmMenu); SAFE_DELETE(confirmMenu);
mState = OP_CONFIRMED; mState = OP_CONFIRMED;
confirmMenu = NEW SimpleMenu(JGE::GetInstance(), 444, listener, Fonts::MENU_FONT, 50, 170); confirmMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 444, listener, Fonts::MENU_FONT, 50, 170);
confirmMenu->Add(1, confirm.c_str()); confirmMenu->Add(1, confirm.c_str());
confirmMenu->Add(2, cancel.c_str()); confirmMenu->Add(2, cancel.c_str());
} }
@@ -1976,7 +1976,7 @@ void WGuiFilterItem::updateValue()
SAFE_DELETE(mParent->subMenu); SAFE_DELETE(mParent->subMenu);
mState = STATE_CHOOSE_TYPE; mState = STATE_CHOOSE_TYPE;
SAFE_DELETE(mParent->subMenu); SAFE_DELETE(mParent->subMenu);
mParent->subMenu = NEW SimpleMenu(JGE::GetInstance(), -1234, this, Fonts::MENU_FONT, 20, 20, "Filter By...", 6); mParent->subMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -1234, this, Fonts::MENU_FONT, 20, 20, "Filter By...", 6);
if (mParent->isAvailable(FILTER_SET)) if (mParent->isAvailable(FILTER_SET))
{ {
@@ -2045,7 +2045,7 @@ void WGuiFilterItem::updateValue()
SAFE_DELETE(mParent->subMenu); SAFE_DELETE(mParent->subMenu);
mParent->clearArgs(); mParent->clearArgs();
mState = STATE_CHOOSE_VAL; mState = STATE_CHOOSE_VAL;
mParent->subMenu = NEW SimpleMenu(JGE::GetInstance(), -1234, this, Fonts::MAIN_FONT, 20, 20, "Filter:"); mParent->subMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -1234, this, Fonts::MAIN_FONT, 20, 20, "Filter:");
if (filterType == FILTER_TYPE) if (filterType == FILTER_TYPE)
{ {
mParent->addArg("Artifact", "t:Artifact;"); mParent->addArg("Artifact", "t:Artifact;");
@@ -2354,7 +2354,7 @@ WGuiBase::CONFIRM_TYPE WGuiKeyBinder::needsConfirm()
confirmationString = ss.str(); confirmationString = ss.str();
// Then create the menu. // Then create the menu.
confirmMenu = NEW SimpleMenu(JGE::GetInstance(), 0, this, Fonts::MENU_FONT, 40, 130, "Conflict"); confirmMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 0, this, Fonts::MENU_FONT, 40, 130, "Conflict");
confirmMenu->Add(1, _("Cancel and return to the options menu").c_str()); confirmMenu->Add(1, _("Cancel and return to the options menu").c_str());
confirmMenu->Add(2, _("This is okay, validate and save").c_str()); confirmMenu->Add(2, _("This is okay, validate and save").c_str());
return CONFIRM_NEED; return CONFIRM_NEED;
@@ -2382,7 +2382,7 @@ WGuiBase::CONFIRM_TYPE WGuiKeyBinder::needsConfirm()
confirmationString = s; confirmationString = s;
confirmingButton = btnToCheck[i]; confirmingButton = btnToCheck[i];
confirmMenu = NEW SimpleMenu(JGE::GetInstance(), 1, this, Fonts::MENU_FONT, 40, 130, "Binding missing"); confirmMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 1, this, Fonts::MENU_FONT, 40, 130, "Binding missing");
confirmMenu->Add(1, _("Cancel and return to the options menu").c_str()); confirmMenu->Add(1, _("Cancel and return to the options menu").c_str());
confirmMenu->Add(2, _("This is okay, validate and save").c_str()); confirmMenu->Add(2, _("This is okay, validate and save").c_str());
return CONFIRM_NEED; return CONFIRM_NEED;

View File

@@ -15,10 +15,18 @@ unix|macx:QMAKE_CXXFLAGS += -Wno-unused-parameter
unix|macx:QMAKE_CXXFLAGS += -Wno-unused-but-set-parameter unix|macx:QMAKE_CXXFLAGS += -Wno-unused-but-set-parameter
unix|macx:QMAKE_CXXFLAGS += -Wno-unused-but-set-variable unix|macx:QMAKE_CXXFLAGS += -Wno-unused-but-set-variable
unix|macx:QMAKE_CXXFLAGS += -Wno-unused-value unix|macx:QMAKE_CXXFLAGS += -Wno-unused-value
unix|macx:!maemo5:!symbian:QMAKE_CXXFLAGS += -Werror #unix|macx:!maemo5:!symbian:QMAKE_CXXFLAGS += -Werror
windows:DEFINES += _CRT_SECURE_NO_WARNINGS windows:DEFINES += _CRT_SECURE_NO_WARNINGS
unix|macx:DEFINES += LINUX unix|macx:DEFINES += LINUX
CONFIG(debug, debug|release):DEFINES += _DEBUG CONFIG(debug, debug|release) {
DEFINES += _DEBUG
}
CONFIG(testsuite)
{
DEFINES += TESTSUITE
}
#CONFIG(debug, debug|release):DEFINES += _DEBUG
DEFINES += QT_CONFIG DEFINES += QT_CONFIG
#!android:!symbian:DEFINES += USE_PHONON #!android:!symbian:DEFINES += USE_PHONON
android:INCLUDEPATH += $$ANDROID_NDK_ROOT/platforms/android-9/arch-arm/usr/include android:INCLUDEPATH += $$ANDROID_NDK_ROOT/platforms/android-9/arch-arm/usr/include
@@ -49,7 +57,6 @@ INCLUDEPATH += include
unix:!symbian:LIBS += -lz unix:!symbian:LIBS += -lz
PRECOMPILED_HEADER = include/PrecompiledHeader.h PRECOMPILED_HEADER = include/PrecompiledHeader.h
#DEFINES += TESTSUITE
#DEFINES += TRACK_OBJECT_USAGE #DEFINES += TRACK_OBJECT_USAGE
#DEFINES += AI_CHANGE_TESTING #DEFINES += AI_CHANGE_TESTING
#DEFINES += ACTION_LOGGING_TESTING #DEFINES += ACTION_LOGGING_TESTING
@@ -162,10 +169,8 @@ SOURCES += \
src/WFont.cpp\ src/WFont.cpp\
src/WGui.cpp\ src/WGui.cpp\
src/WResourceManager.cpp \ src/WResourceManager.cpp \
src/AIPlayerBakaB.cpp src/AIPlayerBakaB.cpp \
src/TestSuiteAI.cpp
CONFIG(debug, debug|release):
SOURCES += src/TestSuiteAI.cpp
HEADERS += \ HEADERS += \
include/CacheEngine.h\ include/CacheEngine.h\