diff --git a/.travis.yml b/.travis.yml index f6a379676..333706528 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,2 @@ 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" diff --git a/JGE/include/qt/corewrapper.h b/JGE/include/qt/corewrapper.h index 522b44ea6..962f91bd4 100644 --- a/JGE/include/qt/corewrapper.h +++ b/JGE/include/qt/corewrapper.h @@ -23,6 +23,19 @@ #include #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); diff --git a/JGE/src/JFileSystem.cpp b/JGE/src/JFileSystem.cpp index b128a0c53..a85af2f87 100644 --- a/JGE/src/JFileSystem.cpp +++ b/JGE/src/JFileSystem.cpp @@ -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"); diff --git a/JGE/src/Qtmain.cpp b/JGE/src/Qtmain.cpp index bbdff7f8f..9aa849ead 100644 --- a/JGE/src/Qtmain.cpp +++ b/JGE/src/Qtmain.cpp @@ -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 diff --git a/JGE/src/pc/JGfx.cpp b/JGE/src/pc/JGfx.cpp index 190e1f530..9c8ba2d2b 100644 --- a/JGE/src/pc/JGfx.cpp +++ b/JGE/src/pc/JGfx.cpp @@ -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; diff --git a/JGE/src/qt/corewrapper.cpp b/JGE/src/qt/corewrapper.cpp index 8e862ad86..656a35132 100644 --- a/JGE/src/qt/corewrapper.cpp +++ b/JGE/src/qt/corewrapper.cpp @@ -3,6 +3,13 @@ #include "corewrapper.h" #include +#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) diff --git a/projects/mtg/include/SimpleMenu.h b/projects/mtg/include/SimpleMenu.h index 572daba3c..b68ca466c 100644 --- a/projects/mtg/include/SimpleMenu.h +++ b/projects/mtg/include/SimpleMenu.h @@ -8,7 +8,7 @@ A class for very simple menus structure #include #include "WFont.h" #include "hge/hgeparticle.h" - +#include "WResourceManager.h" #include "WResource_Fwd.h" class SimpleMenu: public JGuiController @@ -37,7 +37,7 @@ private: public: bool autoTranslate; 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 void Render(); virtual bool CheckUserInput(JButton key); diff --git a/projects/mtg/include/Wagic_Version.h b/projects/mtg/include/Wagic_Version.h index 8b3e45b2e..7ba2fb3eb 100644 --- a/projects/mtg/include/Wagic_Version.h +++ b/projects/mtg/include/Wagic_Version.h @@ -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 Author: Michael Nguyen diff --git a/projects/mtg/src/AbilityParser.cpp b/projects/mtg/src/AbilityParser.cpp index cc245d639..fbc75ee78 100644 --- a/projects/mtg/src/AbilityParser.cpp +++ b/projects/mtg/src/AbilityParser.cpp @@ -109,10 +109,12 @@ bool AutoLineMacro::AddMacro(const string& s) 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) diff --git a/projects/mtg/src/ActionLayer.cpp b/projects/mtg/src/ActionLayer.cpp index 083c3c6f9..4ea73402e 100644 --- a/projects/mtg/src/ActionLayer.cpp +++ b/projects/mtg/src/ActionLayer.cpp @@ -384,8 +384,8 @@ void ActionLayer::setMenuObject(Targetable * object, bool must) SAFE_DELETE(abilitiesMenu); abilitiesTriggered = NULL; - abilitiesMenu = NEW SimpleMenu(observer->getInput(), 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()); + abilitiesMenu = NEW SimpleMenu(observer->getInput(), observer->getResourceManager(), 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; for (size_t i = 0; i < mObjects.size(); i++) { @@ -434,7 +434,7 @@ void ActionLayer::setCustomMenuObject(Targetable * object, bool must,vectorgetInput(), 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; abilitiesMenu->isMultipleChoice = false; if(abilities.size()) diff --git a/projects/mtg/src/GameStateAwards.cpp b/projects/mtg/src/GameStateAwards.cpp index 2efa29aab..69c62d13e 100644 --- a/projects/mtg/src/GameStateAwards.cpp +++ b/projects/mtg/src/GameStateAwards.cpp @@ -184,7 +184,7 @@ void GameStateAwards::Update(float dt) case JGE_BTN_MENU: showMenu = true; 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) menu->Add(kBackToTrophiesID, "Back to Trophies"); menu->Add(kBackToMainMenuID, "Back to Main Menu"); diff --git a/projects/mtg/src/GameStateDeckViewer.cpp b/projects/mtg/src/GameStateDeckViewer.cpp index adc5b24f6..41a8a2f37 100644 --- a/projects/mtg/src/GameStateDeckViewer.cpp +++ b/projects/mtg/src/GameStateDeckViewer.cpp @@ -363,7 +363,7 @@ void GameStateDeckViewer::sellCard() sprintf(buffer, "%s : %i %s", _(card->data->getName()).c_str(), price, _("credits").c_str()); const float menuXOffset = SCREEN_WIDTH_F - 300; 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_NO, "No", "", true); } diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index 48c014094..c2b4174da 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -497,7 +497,7 @@ void GameStateDuel::Update(float dt) case DUEL_STATE_PREPARE_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",""); if (tournament->checkTournamentFile(mParent->players[0] == PLAYER_TYPE_CPU)) cnogmenu->Add(CNOGMENU_ITEM_CONTINUE_TOURNAMENT,"Continue Tournament",""); @@ -924,7 +924,7 @@ void GameStateDuel::Update(float dt) { 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; //almosthumane - mulligan @@ -971,7 +971,7 @@ void GameStateDuel::Update(float dt) setGamePhase(DUEL_STATE_PLAY); } 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) { menu->Add(MENUITEM_MAIN_MENU, "Back to main menu"); diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index 42c31533e..11327ce83 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -344,7 +344,7 @@ void GameStateMenu::setLang(int id) void 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) return; @@ -590,7 +590,7 @@ void GameStateMenu::Update(float dt) if(MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) { 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) { subMenuController->Add(SUBMENUITEM_HOST_GAME, "Host a game"); @@ -613,7 +613,7 @@ void GameStateMenu::Update(float dt) mParent->mpNetwork->getServerIp(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) { subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel"); @@ -641,7 +641,7 @@ void GameStateMenu::Update(float dt) if (!hasChosenGameType) { 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) { for (size_t i = 0; i < Rules::RulesList.size(); ++i) @@ -823,7 +823,7 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId) switch (controlId) { 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) { #ifdef NETWORK_SUPPORT diff --git a/projects/mtg/src/GameStateOptions.cpp b/projects/mtg/src/GameStateOptions.cpp index 314151aba..883568fc0 100644 --- a/projects/mtg/src/GameStateOptions.cpp +++ b/projects/mtg/src/GameStateOptions.cpp @@ -117,7 +117,7 @@ void GameStateOptions::Start() optionsList->failMsg = ""; 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(kSaveAndBackToMainMenuID, "Save And Exit"); optionsMenu->Add(kCancelMenuID, "Cancel"); diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index 716eb5a3b..2b780f5c7 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -212,12 +212,12 @@ void GameStateShop::beginPurchase(int controlId) SAFE_DELETE(menu); 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"); } 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"); if (options[Options::CHEATMODE].number) { @@ -231,7 +231,7 @@ void GameStateShop::beginPurchase(int controlId) sprintf(buf, _("Purchase Booster: %i credits").c_str(), mPrices[controlId]); else 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(-1, "No"); @@ -486,7 +486,7 @@ void GameStateShop::Update(float dt) menu->Update(dt); 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(14, _("Check task board").c_str()); if (options[Options::CHEATMODE].number) @@ -516,7 +516,7 @@ void GameStateShop::Update(float dt) { 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(12, "Save And Exit"); menu->Add(kCancelMenuID, "Cancel"); diff --git a/projects/mtg/src/GameStateStory.cpp b/projects/mtg/src/GameStateStory.cpp index 22c9bc987..621f66081 100644 --- a/projects/mtg/src/GameStateStory.cpp +++ b/projects/mtg/src/GameStateStory.cpp @@ -44,7 +44,7 @@ void GameStateStory::loadStoriesMenu(const char * root) flow = NEW StoryFlow(stories[0]); break; 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) { menu->Add(i, stories[i].c_str()); @@ -64,7 +64,7 @@ void GameStateStory::Update(float dt) { 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(kCancelMenuID, "Cancel"); } @@ -142,4 +142,4 @@ void GameStateStory::OnScroll(int, int inYVelocity) velocity -= 100; } } -} \ No newline at end of file +} diff --git a/projects/mtg/src/GuiPhaseBar.cpp b/projects/mtg/src/GuiPhaseBar.cpp index 73aa782d9..0accc8a08 100644 --- a/projects/mtg/src/GuiPhaseBar.cpp +++ b/projects/mtg/src/GuiPhaseBar.cpp @@ -45,14 +45,18 @@ GuiPhaseBar::GuiPhaseBar(DuelLayers* duelLayers) : GuiLayer(duelLayers->getObserver()), PlayGuiObject(0, 0, 106, 0, false), phase(NULL), angle(0.0f), zoomFactor(ICONSCALE), mpDuelLayers(duelLayers) { - JQuadPtr quad = WResourceManager::Instance()->GetQuad("phasebar"); - if (quad.get() != NULL) + if(duelLayers->getObserver()->getResourceManager()) { - quad->mHeight = kHeight; - quad->mWidth = kWidth; + JQuadPtr quad = WResourceManager::Instance()->GetQuad("phasebar"); + 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; mpDuelLayers->getCardSelector()->Add(this); diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 331d3092a..d44d04f44 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -354,12 +354,12 @@ void MTGAllCards::loadFolder(const string& folder, const string& filename ) if(files[i] == "." || files[i] == "..") continue; + if(JFileSystem::GetInstance()->DirExists(afile)) + loadFolder(string(afile).c_str(), filename); + if (!JFileSystem::GetInstance()->FileExists(afile)) continue; - if(JFileSystem::GetInstance()->DirExists(afile)) - loadFolder(string(afile+"/").c_str(), filename); - if(filename.size()) { if(filename == files[i]) diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index a75cda95b..df9edceab 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -614,7 +614,7 @@ void OptionKey::KeyPressed(LocalKeySym key) g->UngrabKeyboard(this); 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) { const KeyRep& rep = translateKey(btnList[i]); diff --git a/projects/mtg/src/SimpleMenu.cpp b/projects/mtg/src/SimpleMenu.cpp index a66584c33..5cf6ec947 100644 --- a/projects/mtg/src/SimpleMenu.cpp +++ b/projects/mtg/src/SimpleMenu.cpp @@ -33,8 +33,8 @@ JTexture* SimpleMenu::spadeLTex = NULL; JTexture* SimpleMenu::jewelTex = 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) - : JGuiController(jge, id, listener), fontId(fontId), mCenterHorizontal(centerHorizontal), mCenterVertical(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), stars(0) { autoTranslate = true; isMultipleChoice = false; @@ -50,20 +50,23 @@ SimpleMenu::SimpleMenu(JGE* jge, int id, JGuiListener* listener, int fontId, flo mClosed = false; 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 (!spadeRTex) spadeRTex = WResourceManager::Instance()->RetrieveTexture("spade_ur.png", RETRIEVE_MANAGE); - if (!jewelTex) jewelTex = renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM); - if (!sideTex) sideTex = WResourceManager::Instance()->RetrieveTexture("menuside.png", RETRIEVE_MANAGE); - spadeL = WResourceManager::Instance()->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); - jewel.reset(NEW JQuad(jewelTex, 1, 1, 3, 3)); - side = WResourceManager::Instance()->RetrieveQuad("menuside.png", 1, 1, 1, kPoleWidth, "menuside", RETRIEVE_MANAGE); + if (!spadeLTex) spadeLTex = resourceManager->RetrieveTexture("spade_ul.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 (!sideTex) sideTex = resourceManager->RetrieveTexture("menuside.png", RETRIEVE_MANAGE); + spadeL = resourceManager->RetrieveQuad("spade_ul.png", 0, 0, 0, 0, "spade_ul", 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)); + 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() @@ -300,10 +303,12 @@ void SimpleMenu::Update(float dt) startId = mCurr - maxItems + 1; else if (mCurr < startId) startId = mCurr; - stars->Update(dt); + if(stars) + stars->Update(dt); selectionT += 3 * 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); if (timeOpen < 0) { @@ -312,7 +317,8 @@ void SimpleMenu::Update(float dt) { timeOpen = 0; mClosed = true; - stars->FireAt(mX, mY); + if(stars) + stars->FireAt(mX, mY); } } else diff --git a/projects/mtg/src/TestSuiteAI.cpp b/projects/mtg/src/TestSuiteAI.cpp index b3669b53e..97ea53bd8 100644 --- a/projects/mtg/src/TestSuiteAI.cpp +++ b/projects/mtg/src/TestSuiteAI.cpp @@ -610,7 +610,7 @@ void TestSuite::ThreadProc(void* inParam) int TestSuite::run() { - mProcessing = false; + mProcessing = true; loadNext(); ThreadProc(this); diff --git a/projects/mtg/src/WGui.cpp b/projects/mtg/src/WGui.cpp index b518ec661..234b2c5a2 100644 --- a/projects/mtg/src/WGui.cpp +++ b/projects/mtg/src/WGui.cpp @@ -552,7 +552,7 @@ void WDecoConfirm::Entering(JButton key) SAFE_DELETE(confirmMenu); 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(2, cancel.c_str()); } @@ -1976,7 +1976,7 @@ void WGuiFilterItem::updateValue() SAFE_DELETE(mParent->subMenu); mState = STATE_CHOOSE_TYPE; 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)) { @@ -2045,7 +2045,7 @@ void WGuiFilterItem::updateValue() SAFE_DELETE(mParent->subMenu); mParent->clearArgs(); 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) { mParent->addArg("Artifact", "t:Artifact;"); @@ -2354,7 +2354,7 @@ WGuiBase::CONFIRM_TYPE WGuiKeyBinder::needsConfirm() confirmationString = ss.str(); // 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(2, _("This is okay, validate and save").c_str()); return CONFIRM_NEED; @@ -2382,7 +2382,7 @@ WGuiBase::CONFIRM_TYPE WGuiKeyBinder::needsConfirm() confirmationString = s; 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(2, _("This is okay, validate and save").c_str()); return CONFIRM_NEED; diff --git a/projects/mtg/wagic-qt.pro b/projects/mtg/wagic-qt.pro index 44d9d21db..5ee0074e5 100644 --- a/projects/mtg/wagic-qt.pro +++ b/projects/mtg/wagic-qt.pro @@ -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-variable 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 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 #!android:!symbian:DEFINES += USE_PHONON android:INCLUDEPATH += $$ANDROID_NDK_ROOT/platforms/android-9/arch-arm/usr/include @@ -49,7 +57,6 @@ INCLUDEPATH += include unix:!symbian:LIBS += -lz PRECOMPILED_HEADER = include/PrecompiledHeader.h -#DEFINES += TESTSUITE #DEFINES += TRACK_OBJECT_USAGE #DEFINES += AI_CHANGE_TESTING #DEFINES += ACTION_LOGGING_TESTING @@ -162,10 +169,8 @@ SOURCES += \ src/WFont.cpp\ src/WGui.cpp\ src/WResourceManager.cpp \ - src/AIPlayerBakaB.cpp - -CONFIG(debug, debug|release): -SOURCES += src/TestSuiteAI.cpp + src/AIPlayerBakaB.cpp \ + src/TestSuiteAI.cpp HEADERS += \ include/CacheEngine.h\