Erwan
- bug fix in JGE++ audio (improve HBL compatibility) - Added new rewards in story mode: random card, card (either by "name" or id), specific set - Story mode: added possibility to choose music, and bg for duel. -- See "01. Where it all begins" for examples of new features
This commit is contained in:
@@ -403,6 +403,8 @@ void audioInit() // 初始化
|
|||||||
|
|
||||||
void audioDestroy()
|
void audioDestroy()
|
||||||
{
|
{
|
||||||
|
pspAudioEndPre();
|
||||||
|
sceKernelDelayThread(100000);
|
||||||
pspAudioEnd();
|
pspAudioEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<page id="start">
|
<page id="start">
|
||||||
<type>dialog</type>
|
<type>dialog</type>
|
||||||
|
<music>_sfx/siege.mp3</music>
|
||||||
<title>Welcome young adventurer...</title>
|
<title>Welcome young adventurer...</title>
|
||||||
<img>_gfx/shopkeeper.jpg</img>
|
<img>_gfx/shopkeeper.jpg</img>
|
||||||
<text>So you want to become a sorcerer?</text>
|
<text>So you want to become a sorcerer?</text>
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
<page id="tap_mana_intro">
|
<page id="tap_mana_intro">
|
||||||
<type>dialog</type>
|
<type>dialog</type>
|
||||||
<title>Tapping lands for mana</title>
|
<title>Tapping lands for mana</title>
|
||||||
|
<reward type="unlockset" value="RV">I unlocked ${SET} for you</reward>
|
||||||
<text>In your quests you will have to fight against other wizards.</text>
|
<text>In your quests you will have to fight against other wizards.</text>
|
||||||
<text>You will only have your brain and your spells to help you.</text>
|
<text>You will only have your brain and your spells to help you.</text>
|
||||||
<text>The basic Energy to cast your spells in Wagic is called mana.</text>
|
<text>The basic Energy to cast your spells in Wagic is called mana.</text>
|
||||||
@@ -26,6 +28,7 @@
|
|||||||
|
|
||||||
<page id="tap_mana">
|
<page id="tap_mana">
|
||||||
<type>duel</type>
|
<type>duel</type>
|
||||||
|
<bg>_gfx/back_green.jpg</bg>
|
||||||
<onwin>tap_mana_ok</onwin>
|
<onwin>tap_mana_ok</onwin>
|
||||||
<onlose>tap_mana_try_again</onlose>
|
<onlose>tap_mana_try_again</onlose>
|
||||||
</page>
|
</page>
|
||||||
@@ -41,8 +44,10 @@
|
|||||||
|
|
||||||
<page id="tap_mana_ok">
|
<page id="tap_mana_ok">
|
||||||
<type>dialog</type>
|
<type>dialog</type>
|
||||||
|
<music>none</music>
|
||||||
<title>Well done...now let's cast a spell</title>
|
<title>Well done...now let's cast a spell</title>
|
||||||
<text>That was too easy for you!</text>
|
<text>That was too easy for you!</text>
|
||||||
|
<reward type="card" value="Forest (10E)">As a reward, I give you a ${CARD}</reward>
|
||||||
<text>Now let's see if you can cast a spell...</text>
|
<text>Now let's see if you can cast a spell...</text>
|
||||||
<text>Spells have a cost represented by mana symbols on the top right corner</text>
|
<text>Spells have a cost represented by mana symbols on the top right corner</text>
|
||||||
<text>of the card. For example, 2 white mana icons on the top right of the card</text>
|
<text>of the card. For example, 2 white mana icons on the top right of the card</text>
|
||||||
@@ -169,6 +174,7 @@
|
|||||||
<type>dialog</type>
|
<type>dialog</type>
|
||||||
<title>Great!</title>
|
<title>Great!</title>
|
||||||
<text>You now understand the basics of the combat phase</text>
|
<text>You now understand the basics of the combat phase</text>
|
||||||
|
<reward type="unlockset" value="RV">I unlocked ${SET} for you</reward>
|
||||||
<answer goto="first_duel_1">Continue</answer>
|
<answer goto="first_duel_1">Continue</answer>
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ Documentation for the Basic campaign system in Wagic
|
|||||||
Each subfolder that contains a "story.xml" is considered as a "story". Stories appear in the menu and represent
|
Each subfolder that contains a "story.xml" is considered as a "story". Stories appear in the menu and represent
|
||||||
a series of dialogs and duels.
|
a series of dialogs and duels.
|
||||||
|
|
||||||
|
*: 0 to n
|
||||||
|
?: 0 to 1
|
||||||
|
|
||||||
#################################
|
#################################
|
||||||
1.Structure of story.xml:
|
1.Structure of story.xml:
|
||||||
#################################
|
#################################
|
||||||
@@ -20,6 +23,7 @@ Elements of the page node
|
|||||||
===========================================
|
===========================================
|
||||||
|
|
||||||
type (dialog,duel,end)
|
type (dialog,duel,end)
|
||||||
|
music ? (path to a music file)
|
||||||
|
|
||||||
|
|
||||||
===========================================
|
===========================================
|
||||||
@@ -30,6 +34,7 @@ title *
|
|||||||
img *
|
img *
|
||||||
text *
|
text *
|
||||||
answer *
|
answer *
|
||||||
|
reward *
|
||||||
|
|
||||||
title, img, text, answer have the following common attributes:
|
title, img, text, answer have the following common attributes:
|
||||||
x (optional - default 0)
|
x (optional - default 0)
|
||||||
@@ -53,14 +58,22 @@ answer specific attributes:
|
|||||||
goto
|
goto
|
||||||
id of a page to go to
|
id of a page to go to
|
||||||
|
|
||||||
|
reward attributes:
|
||||||
|
type
|
||||||
|
unlockset , card, credits
|
||||||
|
value
|
||||||
|
number of credits, or name/id of the card (random if undef), or name of the set (random if undef)
|
||||||
|
Additionally, the fowllowing variables can be used in the reward text : ${SET}, ${CARD}
|
||||||
|
|
||||||
===========================================
|
===========================================
|
||||||
Additional Elmts of the "page" node if type == dialog
|
Additional Elmts of the "page" node if type == duel
|
||||||
===========================================
|
===========================================
|
||||||
onwin
|
onwin
|
||||||
id of a page to go to if duel lost
|
id of a page to go to if duel lost
|
||||||
onlose
|
onlose
|
||||||
id of a page to go to if duel won
|
id of a page to go to if duel won
|
||||||
|
bg
|
||||||
|
path to a background file
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ public:
|
|||||||
void compute(Player * _p1, Player * _p2, GameApp * _app);
|
void compute(Player * _p1, Player * _p2, GameApp * _app);
|
||||||
void Render();
|
void Render();
|
||||||
static int unlockRandomSet(bool force = false);
|
static int unlockRandomSet(bool force = false);
|
||||||
|
static int unlockSetByName(string name);
|
||||||
static int addCreditBonus(int value);
|
static int addCreditBonus(int value);
|
||||||
|
static int addCardToCollection(int cardId, MTGDeck * collection);
|
||||||
|
static int addCardToCollection(int cardId);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ class GameApp: public JApp
|
|||||||
static int HasMusic;
|
static int HasMusic;
|
||||||
static string systemError;
|
static string systemError;
|
||||||
static JMusic* music;
|
static JMusic* music;
|
||||||
|
static void playMusic(string filename, bool loop = true);
|
||||||
static MTGAllCards * collection;
|
static MTGAllCards * collection;
|
||||||
static int players[2];
|
static int players[2];
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class GameObserver{
|
|||||||
Player * gameOver;
|
Player * gameOver;
|
||||||
Player * players[2]; //created outside
|
Player * players[2]; //created outside
|
||||||
time_t startedAt;
|
time_t startedAt;
|
||||||
|
Rules * mRules;
|
||||||
|
|
||||||
TargetChooser * getCurrentTargetChooser();
|
TargetChooser * getCurrentTargetChooser();
|
||||||
void stackObjectClicked(Interruptible * action);
|
void stackObjectClicked(Interruptible * action);
|
||||||
|
|||||||
@@ -60,7 +60,10 @@ public:
|
|||||||
PARSE_PLAYER2,
|
PARSE_PLAYER2,
|
||||||
PARSE_PLAYERS
|
PARSE_PLAYERS
|
||||||
};
|
};
|
||||||
Rules(string filename);
|
|
||||||
|
string bg;
|
||||||
|
|
||||||
|
Rules(string filename, string bg = "");
|
||||||
int load(string filename);
|
int load(string filename);
|
||||||
int gamemode;
|
int gamemode;
|
||||||
void initPlayers();
|
void initPlayers();
|
||||||
@@ -71,6 +74,7 @@ public:
|
|||||||
RulesState initState;
|
RulesState initState;
|
||||||
static int getMTGId(string name);
|
static int getMTGId(string name);
|
||||||
static MTGCardInstance * getCardByMTGId(int mtgid);
|
static MTGCardInstance * getCardByMTGId(int mtgid);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using namespace std;
|
|||||||
#include "../../../JGE/src/tinyxml/tinyxml.h"
|
#include "../../../JGE/src/tinyxml/tinyxml.h"
|
||||||
#include <JGui.h>
|
#include <JGui.h>
|
||||||
class GameObserver;
|
class GameObserver;
|
||||||
|
class MTGDeck;
|
||||||
#define CAMPAIGNS_FOLDER "Res/campaigns/"
|
#define CAMPAIGNS_FOLDER "Res/campaigns/"
|
||||||
|
|
||||||
|
|
||||||
@@ -49,7 +50,8 @@ class StoryReward:public StoryText {
|
|||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
STORY_REWARD_CREDITS,
|
STORY_REWARD_CREDITS,
|
||||||
STORY_REWARD_SET
|
STORY_REWARD_SET,
|
||||||
|
STORY_REWARD_CARD,
|
||||||
};
|
};
|
||||||
|
|
||||||
int rewardDone;
|
int rewardDone;
|
||||||
@@ -62,6 +64,7 @@ public:
|
|||||||
|
|
||||||
static bool rewardSoundPlayed;
|
static bool rewardSoundPlayed;
|
||||||
static bool rewardsEnabled;
|
static bool rewardsEnabled;
|
||||||
|
static MTGDeck * collection;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StoryChoice:public StoryText {
|
class StoryChoice:public StoryText {
|
||||||
@@ -85,18 +88,21 @@ public:
|
|||||||
|
|
||||||
class StoryFlow;
|
class StoryFlow;
|
||||||
class StoryPage {
|
class StoryPage {
|
||||||
|
protected:
|
||||||
|
string safeAttribute(TiXmlElement* element, string attribute);
|
||||||
public:
|
public:
|
||||||
StoryFlow * mParent;
|
StoryFlow * mParent;
|
||||||
|
string musicFile;
|
||||||
StoryPage(StoryFlow * mParent);
|
StoryPage(StoryFlow * mParent);
|
||||||
virtual void Update(float dt)=0;
|
virtual void Update(float dt)=0;
|
||||||
virtual void Render()=0;
|
virtual void Render()=0;
|
||||||
virtual ~StoryPage(){};
|
virtual ~StoryPage(){};
|
||||||
|
int loadElement(TiXmlElement* element);
|
||||||
};
|
};
|
||||||
|
|
||||||
class StoryDialog:public StoryPage, public JGuiListener,public JGuiController {
|
class StoryDialog:public StoryPage, public JGuiListener,public JGuiController {
|
||||||
private:
|
private:
|
||||||
vector<StoryDialogElement *>graphics;
|
vector<StoryDialogElement *>graphics;
|
||||||
string safeAttribute(TiXmlElement* element, string attribute);
|
|
||||||
void RenderElement(StoryDialogElement * elmt);
|
void RenderElement(StoryDialogElement * elmt);
|
||||||
public:
|
public:
|
||||||
StoryDialog(TiXmlElement* el,StoryFlow * mParent);
|
StoryDialog(TiXmlElement* el,StoryFlow * mParent);
|
||||||
@@ -115,6 +121,7 @@ class StoryDuel:public StoryPage {
|
|||||||
public:
|
public:
|
||||||
string pageId;
|
string pageId;
|
||||||
string onWin, onLose;
|
string onWin, onLose;
|
||||||
|
string bg; //background file
|
||||||
GameObserver * game;
|
GameObserver * game;
|
||||||
Rules * rules;
|
Rules * rules;
|
||||||
StoryDuel(TiXmlElement* el,StoryFlow * mParent);
|
StoryDuel(TiXmlElement* el,StoryFlow * mParent);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "../include/MTGDeck.h"
|
#include "../include/MTGDeck.h"
|
||||||
#include "../include/GameObserver.h"
|
#include "../include/GameObserver.h"
|
||||||
#include "../include/GameStateShop.h"
|
#include "../include/GameStateShop.h"
|
||||||
|
#include "../include/PlayerData.h"
|
||||||
|
|
||||||
CreditBonus::CreditBonus(int _value, string _text){
|
CreditBonus::CreditBonus(int _value, string _text){
|
||||||
value = _value;
|
value = _value;
|
||||||
@@ -289,6 +290,37 @@ int Credits::addCreditBonus(int value){
|
|||||||
SAFE_DELETE(playerdata);
|
SAFE_DELETE(playerdata);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* adds a Card to a deck
|
||||||
|
* @param cardId id of the card
|
||||||
|
* @param collection deck representing player's collection
|
||||||
|
*/
|
||||||
|
int Credits::addCardToCollection(int cardId, MTGDeck * collection) {
|
||||||
|
return collection->add(cardId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* adds a Card to player's collection
|
||||||
|
* prefer to call the above function if you want to add several cards, since saving is expensive
|
||||||
|
*/
|
||||||
|
int Credits::addCardToCollection(int cardId) {
|
||||||
|
MTGAllCards * ac = GameApp::collection;
|
||||||
|
PlayerData * playerdata = NEW PlayerData(ac);
|
||||||
|
int result = addCardToCollection(cardId, playerdata->collection);
|
||||||
|
playerdata->collection->save();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Credits::unlockSetByName(string name){
|
||||||
|
int setId = setlist.findSet(name);
|
||||||
|
if (setId < 0) return 0;
|
||||||
|
|
||||||
|
GameOptionAward* goa = (GameOptionAward*) &options[Options::optionSet(setId)];
|
||||||
|
goa->giveAward();
|
||||||
|
options.save();
|
||||||
|
return setId + 1; //We add 1 here to show success/failure. Be sure to subtract later.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int Credits::unlockRandomSet(bool force){
|
int Credits::unlockRandomSet(bool force){
|
||||||
int setId = WRand() % setlist.size();
|
int setId = WRand() % setlist.size();
|
||||||
|
|||||||
@@ -254,7 +254,8 @@ void GameApp::Destroy()
|
|||||||
SAFE_DELETE(Subtypes::subtypesList);
|
SAFE_DELETE(Subtypes::subtypesList);
|
||||||
SAFE_DELETE(DeckMetaDataList::decksMetaData);
|
SAFE_DELETE(DeckMetaDataList::decksMetaData);
|
||||||
|
|
||||||
SAFE_DELETE(music);
|
playMusic("none");
|
||||||
|
|
||||||
Translator::EndInstance();
|
Translator::EndInstance();
|
||||||
WCFilterFactory::Destroy();
|
WCFilterFactory::Destroy();
|
||||||
SimpleMenu::destroy();
|
SimpleMenu::destroy();
|
||||||
@@ -426,3 +427,15 @@ void GameApp::DoTransition(int trans, int tostate, float dur, bool animonly){
|
|||||||
void GameApp::DoAnimation(int trans, float dur){
|
void GameApp::DoAnimation(int trans, float dur){
|
||||||
DoTransition(trans,GAME_STATE_NONE,dur,true);
|
DoTransition(trans,GAME_STATE_NONE,dur,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameApp::playMusic(string filename, bool loop) {
|
||||||
|
if (music) {
|
||||||
|
JSoundSystem::GetInstance()->StopMusic(music);
|
||||||
|
SAFE_DELETE(music);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HasMusic && options[Options::MUSICVOLUME].number > 0){
|
||||||
|
music = resources.ssLoadMusic(filename.c_str());
|
||||||
|
if (music) JSoundSystem::GetInstance()->PlayMusic(music, loop);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,6 +46,7 @@ GameObserver::GameObserver(Player * _players[], int _nb_players){
|
|||||||
phaseRing = NULL;
|
phaseRing = NULL;
|
||||||
replacementEffects = NEW ReplacementEffects();
|
replacementEffects = NEW ReplacementEffects();
|
||||||
combatStep = BLOCKERS;
|
combatStep = BLOCKERS;
|
||||||
|
mRules = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameObserver::getCurrentGamePhase(){
|
int GameObserver::getCurrentGamePhase(){
|
||||||
@@ -187,6 +188,7 @@ int GameObserver::forceShuffleLibraries(){
|
|||||||
|
|
||||||
void GameObserver::startGame(Rules * rules){
|
void GameObserver::startGame(Rules * rules){
|
||||||
turn = 0;
|
turn = 0;
|
||||||
|
mRules = rules;
|
||||||
if (rules)
|
if (rules)
|
||||||
rules->initPlayers();
|
rules->initPlayers();
|
||||||
|
|
||||||
@@ -201,6 +203,7 @@ void GameObserver::startGame(Rules * rules){
|
|||||||
rules->initGame();
|
rules->initGame();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Preload images from hand
|
//Preload images from hand
|
||||||
if (!players[0]->isAI()){
|
if (!players[0]->isAI()){
|
||||||
for (int i=0; i< players[0]->game->hand->nb_cards; i++){
|
for (int i=0; i< players[0]->game->hand->nb_cards; i++){
|
||||||
|
|||||||
@@ -168,16 +168,7 @@ void GameStateDeckViewer::Start()
|
|||||||
//init welcome menu
|
//init welcome menu
|
||||||
updateDecks();
|
updateDecks();
|
||||||
|
|
||||||
if (GameApp::HasMusic && options[Options::MUSICVOLUME].number > 0){
|
GameApp::playMusic("track1.mp3");
|
||||||
if (GameApp::music){
|
|
||||||
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
|
|
||||||
SAFE_DELETE(GameApp::music);
|
|
||||||
}
|
|
||||||
GameApp::music = resources.ssLoadMusic("track1.mp3");
|
|
||||||
if (GameApp::music){
|
|
||||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loadIndexes();
|
loadIndexes();
|
||||||
mEngine->ResetInput();
|
mEngine->ResetInput();
|
||||||
@@ -188,10 +179,7 @@ void GameStateDeckViewer::Start()
|
|||||||
void GameStateDeckViewer::End()
|
void GameStateDeckViewer::End()
|
||||||
{
|
{
|
||||||
JRenderer::GetInstance()->EnableVSync(false);
|
JRenderer::GetInstance()->EnableVSync(false);
|
||||||
if (GameApp::music){
|
|
||||||
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
|
|
||||||
SAFE_DELETE(GameApp::music);
|
|
||||||
}
|
|
||||||
SAFE_DELETE(welcome_menu);
|
SAFE_DELETE(welcome_menu);
|
||||||
SAFE_DELETE(menu);
|
SAFE_DELETE(menu);
|
||||||
SAFE_DELETE(subMenu);
|
SAFE_DELETE(subMenu);
|
||||||
|
|||||||
@@ -173,11 +173,7 @@ void GameStateDuel::End()
|
|||||||
OutputDebugString("Ending GamestateDuel\n");
|
OutputDebugString("Ending GamestateDuel\n");
|
||||||
#endif
|
#endif
|
||||||
SAFE_DELETE(deckmenu);
|
SAFE_DELETE(deckmenu);
|
||||||
//stop game music
|
|
||||||
if (GameApp::music){
|
|
||||||
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
|
|
||||||
SAFE_DELETE(GameApp::music);
|
|
||||||
}
|
|
||||||
JRenderer::GetInstance()->EnableVSync(false);
|
JRenderer::GetInstance()->EnableVSync(false);
|
||||||
if (mPlayers[0] && mPlayers[1]) mPlayers[0]->End();
|
if (mPlayers[0] && mPlayers[1]) mPlayers[0]->End();
|
||||||
GameObserver::EndInstance();
|
GameObserver::EndInstance();
|
||||||
@@ -304,13 +300,8 @@ void GameStateDuel::Update(float dt)
|
|||||||
if (mParent->gameType == GAME_TYPE_MOMIR){
|
if (mParent->gameType == GAME_TYPE_MOMIR){
|
||||||
game->addObserver(NEW MTGMomirRule(-1, mParent->collection));
|
game->addObserver(NEW MTGMomirRule(-1, mParent->collection));
|
||||||
}
|
}
|
||||||
//stop menu music
|
|
||||||
if (GameApp::music){
|
|
||||||
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
|
|
||||||
SAFE_DELETE(GameApp::music);
|
|
||||||
}
|
|
||||||
//start of in game music code
|
//start of in game music code
|
||||||
if (GameApp::HasMusic && options[Options::MUSICVOLUME].number > 0){
|
|
||||||
musictrack = "";
|
musictrack = "";
|
||||||
//check opponent id and choose the music track based on it
|
//check opponent id and choose the music track based on it
|
||||||
if(OpponentsDeckid) {
|
if(OpponentsDeckid) {
|
||||||
@@ -328,12 +319,7 @@ void GameStateDuel::Update(float dt)
|
|||||||
if(!MusicExist(musictrack))
|
if(!MusicExist(musictrack))
|
||||||
musictrack = "ai_baka_music.mp3";
|
musictrack = "ai_baka_music.mp3";
|
||||||
|
|
||||||
if (MusicExist(musictrack)){
|
GameApp::playMusic(musictrack);
|
||||||
GameApp::music = resources.ssLoadMusic(musictrack.c_str());
|
|
||||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//end of music code
|
|
||||||
}
|
}
|
||||||
game->Update(dt);
|
game->Update(dt);
|
||||||
if (game->gameOver){
|
if (game->gameOver){
|
||||||
|
|||||||
@@ -135,15 +135,7 @@ void GameStateMenu::Start(){
|
|||||||
subMenuController = NULL;
|
subMenuController = NULL;
|
||||||
SAFE_DELETE(mGuiController);
|
SAFE_DELETE(mGuiController);
|
||||||
|
|
||||||
if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0){
|
GameApp::playMusic("Track0.mp3");
|
||||||
GameApp::music = resources.ssLoadMusic("Track0.mp3");
|
|
||||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameApp::HasMusic && GameApp::music && options[Options::MUSICVOLUME].number == 0){
|
|
||||||
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
|
|
||||||
SAFE_DELETE(GameApp::music);
|
|
||||||
}
|
|
||||||
|
|
||||||
hasChosenGameType = 0;
|
hasChosenGameType = 0;
|
||||||
mParent->gameType = GAME_TYPE_CLASSIC;
|
mParent->gameType = GAME_TYPE_CLASSIC;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ GameStateShop::GameStateShop(GameApp* parent): GameState(parent) {
|
|||||||
|
|
||||||
GameStateShop::~GameStateShop() {
|
GameStateShop::~GameStateShop() {
|
||||||
End();
|
End();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateShop::Create(){
|
void GameStateShop::Create(){
|
||||||
@@ -74,7 +75,7 @@ void GameStateShop::Start(){
|
|||||||
bigSync = 0;
|
bigSync = 0;
|
||||||
shopMenu = NEW WGuiMenu(JGE_BTN_DOWN, JGE_BTN_UP, true, &bigSync);
|
shopMenu = NEW WGuiMenu(JGE_BTN_DOWN, JGE_BTN_UP, true, &bigSync);
|
||||||
MTGAllCards * ac = GameApp::collection;
|
MTGAllCards * ac = GameApp::collection;
|
||||||
playerdata = NEW PlayerData(ac);;
|
playerdata = NEW PlayerData(ac);
|
||||||
myCollection = NEW DeckDataWrapper(playerdata->collection);
|
myCollection = NEW DeckDataWrapper(playerdata->collection);
|
||||||
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",ac);
|
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",ac);
|
||||||
for(int i=0;i<SHOP_SLOTS;i++){
|
for(int i=0;i<SHOP_SLOTS;i++){
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include "../include/GameApp.h"
|
#include "../include/GameApp.h"
|
||||||
#include "../include/GuiBackground.h"
|
#include "../include/GuiBackground.h"
|
||||||
|
#include "../include/GameObserver.h"
|
||||||
|
#include "../include/Rules.h"
|
||||||
|
|
||||||
GuiBackground::GuiBackground()
|
GuiBackground::GuiBackground()
|
||||||
{
|
{
|
||||||
@@ -13,5 +15,14 @@ GuiBackground::~GuiBackground()
|
|||||||
void GuiBackground::Render()
|
void GuiBackground::Render()
|
||||||
{
|
{
|
||||||
JRenderer* renderer = JRenderer::GetInstance();
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
renderer->RenderQuad(resources.RetrieveTempQuad("backdrop.jpg"), 0, 18);
|
JQuad * quad = NULL;
|
||||||
|
GameObserver * go = GameObserver::GetInstance();
|
||||||
|
if (go && go->mRules && go->mRules->bg.size()) {
|
||||||
|
quad = resources.RetrieveTempQuad(go->mRules->bg);
|
||||||
|
}
|
||||||
|
if (!quad) {
|
||||||
|
quad = resources.RetrieveTempQuad("backdrop.jpg");
|
||||||
|
}
|
||||||
|
if (!quad) return;
|
||||||
|
renderer->RenderQuad(quad, 0, 18);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -426,6 +426,12 @@ MTGCard * MTGAllCards::_(int index){
|
|||||||
MTGCard * MTGAllCards::getCardByName(string name){
|
MTGCard * MTGAllCards::getCardByName(string name){
|
||||||
if (!name.size()) return NULL;
|
if (!name.size()) return NULL;
|
||||||
if (name[0] == '#') return NULL;
|
if (name[0] == '#') return NULL;
|
||||||
|
|
||||||
|
int cardnb = atoi(name.c_str());
|
||||||
|
if (cardnb){
|
||||||
|
return getCardById(cardnb);
|
||||||
|
}
|
||||||
|
|
||||||
std::transform(name.begin(), name.end(), name.begin(),::tolower );
|
std::transform(name.begin(), name.end(), name.begin(),::tolower );
|
||||||
int setId = -1;
|
int setId = -1;
|
||||||
size_t found = name.find(" (");
|
size_t found = name.find(" (");
|
||||||
|
|||||||
@@ -330,9 +330,9 @@ void Rules::cleanup(){
|
|||||||
initState.cleanup();
|
initState.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
Rules::Rules(string filename){
|
Rules::Rules(string filename, string _bg){
|
||||||
|
bg = _bg;
|
||||||
load(filename);
|
load(filename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Rules::load(string _filename){
|
int Rules::load(string _filename){
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "../include/Rules.h"
|
#include "../include/Rules.h"
|
||||||
#include "../include/Credits.h"
|
#include "../include/Credits.h"
|
||||||
#include "../include/PlayerData.h"
|
#include "../include/PlayerData.h"
|
||||||
|
#include "../include/MTGDeck.h"
|
||||||
#include <JLBFont.h>
|
#include <JLBFont.h>
|
||||||
#include <JGE.h>
|
#include <JGE.h>
|
||||||
#include <JFileSystem.h>
|
#include <JFileSystem.h>
|
||||||
@@ -18,6 +19,7 @@ float StoryDialog::currentY = 2;
|
|||||||
float StoryDialog::previousY = 2;
|
float StoryDialog::previousY = 2;
|
||||||
bool StoryReward::rewardSoundPlayed = false;
|
bool StoryReward::rewardSoundPlayed = false;
|
||||||
bool StoryReward::rewardsEnabled = true;
|
bool StoryReward::rewardsEnabled = true;
|
||||||
|
MTGDeck * StoryReward::collection = NULL;
|
||||||
|
|
||||||
StoryDialogElement::StoryDialogElement(float x, float y, int id): JGuiObject(id), mX(x),mY(y) {
|
StoryDialogElement::StoryDialogElement(float x, float y, int id): JGuiObject(id), mX(x),mY(y) {
|
||||||
}
|
}
|
||||||
@@ -58,6 +60,8 @@ float StoryText::getHeight() {
|
|||||||
type = STORY_REWARD_CREDITS;
|
type = STORY_REWARD_CREDITS;
|
||||||
if (_type.compare("unlockset") == 0) {
|
if (_type.compare("unlockset") == 0) {
|
||||||
type = STORY_REWARD_SET;
|
type = STORY_REWARD_SET;
|
||||||
|
} else if (_type.compare("card") == 0) {
|
||||||
|
type = STORY_REWARD_CARD;
|
||||||
}
|
}
|
||||||
value = _value;
|
value = _value;
|
||||||
rewardDone = 0;
|
rewardDone = 0;
|
||||||
@@ -82,7 +86,12 @@ void StoryReward::Update(float dt){
|
|||||||
break;
|
break;
|
||||||
case STORY_REWARD_SET:
|
case STORY_REWARD_SET:
|
||||||
{
|
{
|
||||||
|
if (value.size()) {
|
||||||
|
result = Credits::unlockSetByName(value);
|
||||||
|
} else {
|
||||||
result = Credits::unlockRandomSet(true);
|
result = Credits::unlockRandomSet(true);
|
||||||
|
}
|
||||||
|
if (!result) break;
|
||||||
MTGSetInfo * si = setlist.getInfo(result - 1);
|
MTGSetInfo * si = setlist.getInfo(result - 1);
|
||||||
if(si) {
|
if(si) {
|
||||||
string unlockedString = si->getName();
|
string unlockedString = si->getName();
|
||||||
@@ -93,6 +102,33 @@ void StoryReward::Update(float dt){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case STORY_REWARD_CARD:
|
||||||
|
{
|
||||||
|
int cardId = 0;
|
||||||
|
MTGCard * card = NULL;
|
||||||
|
if (value.size()) {
|
||||||
|
card = GameApp::collection->getCardByName(value);
|
||||||
|
if (card) {
|
||||||
|
cardId = card->getId();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cardId = GameApp::collection->randomCardId();
|
||||||
|
card = GameApp::collection->getCardById(cardId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cardId) break;
|
||||||
|
|
||||||
|
if (!collection) {
|
||||||
|
collection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), GameApp::collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = Credits::addCardToCollection(cardId, collection);
|
||||||
|
size_t pos = text.find("${CARD}");
|
||||||
|
if (pos != string::npos && card) {
|
||||||
|
text.replace(pos,pos + 7,card->data->getName());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -228,7 +264,7 @@ StoryChoice::StoryChoice(string pageId, string text, int JGOid, float mX, float
|
|||||||
if(hasFocus) mTargetScale = 1.2f;
|
if(hasFocus) mTargetScale = 1.2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Actually loads "game"
|
//Actually loads a duel
|
||||||
void StoryDuel::init(){
|
void StoryDuel::init(){
|
||||||
Player * players[2];
|
Player * players[2];
|
||||||
|
|
||||||
@@ -249,7 +285,7 @@ void StoryDuel::init(){
|
|||||||
|
|
||||||
string rulesFile = folder;
|
string rulesFile = folder;
|
||||||
rulesFile.append("/rules.txt");
|
rulesFile.append("/rules.txt");
|
||||||
rules = NEW Rules(rulesFile);
|
rules = NEW Rules(rulesFile, bg);
|
||||||
|
|
||||||
GameObserver::Init(players, 2);
|
GameObserver::Init(players, 2);
|
||||||
game = GameObserver::GetInstance();
|
game = GameObserver::GetInstance();
|
||||||
@@ -263,15 +299,18 @@ StoryDuel::StoryDuel(TiXmlElement* root,StoryFlow * mParent): StoryPage(mParent)
|
|||||||
for (TiXmlNode* node = root->FirstChild(); node; node = node->NextSibling()) {
|
for (TiXmlNode* node = root->FirstChild(); node; node = node->NextSibling()) {
|
||||||
TiXmlElement* element = node->ToElement();
|
TiXmlElement* element = node->ToElement();
|
||||||
if (element) {
|
if (element) {
|
||||||
if (strcmp(element->Value(), "onwin")==0) {
|
|
||||||
const char* textC = element->GetText();
|
const char* textC = element->GetText();
|
||||||
|
if (strcmp(element->Value(), "onwin")==0) {
|
||||||
onWin = textC;
|
onWin = textC;
|
||||||
}
|
}
|
||||||
else if (strcmp(element->Value(), "onlose")==0) {
|
else if (strcmp(element->Value(), "onlose")==0) {
|
||||||
const char* textC = element->GetText();
|
|
||||||
onLose = textC;
|
onLose = textC;
|
||||||
}else {
|
} else if (strcmp(element->Value(), "bg")==0) {
|
||||||
//Error
|
string text = textC;
|
||||||
|
bg = string("campaigns/").append(mParent->folder).append("/").append(text);
|
||||||
|
if (!fileExists(bg.c_str())) bg = text;
|
||||||
|
} else {
|
||||||
|
StoryPage::loadElement(element); //Father
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,7 +338,7 @@ void StoryDuel::Render(){
|
|||||||
game->Render();
|
game->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
string StoryDialog::safeAttribute(TiXmlElement* element, string attribute) {
|
string StoryPage::safeAttribute(TiXmlElement* element, string attribute) {
|
||||||
string s;
|
string s;
|
||||||
if (element->Attribute(attribute.c_str())){
|
if (element->Attribute(attribute.c_str())){
|
||||||
s = element->Attribute(attribute.c_str());
|
s = element->Attribute(attribute.c_str());
|
||||||
@@ -307,6 +346,18 @@ string StoryDialog::safeAttribute(TiXmlElement* element, string attribute) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int StoryPage::loadElement(TiXmlElement* element) {
|
||||||
|
if (!element) return 0;
|
||||||
|
const char* textC = element->GetText();
|
||||||
|
string text = textC;
|
||||||
|
if (strcmp(element->Value(), "music")==0) {
|
||||||
|
musicFile = string("campaigns/").append(mParent->folder).append("/").append(text);
|
||||||
|
if (!fileExists(musicFile.c_str()))
|
||||||
|
musicFile = text;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent):StoryPage(mParent), JGuiListener(), JGuiController(1,NULL) {
|
StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent):StoryPage(mParent), JGuiListener(), JGuiController(1,NULL) {
|
||||||
|
|
||||||
@@ -357,7 +408,7 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent):StoryPage(mPar
|
|||||||
string value = safeAttribute(element,"value");
|
string value = safeAttribute(element,"value");
|
||||||
graphics.push_back(NEW StoryReward(type, value, text,x,y,align, font));
|
graphics.push_back(NEW StoryReward(type, value, text,x,y,align, font));
|
||||||
}else {
|
}else {
|
||||||
//Error
|
StoryPage::loadElement(element); //Father
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,6 +421,11 @@ void StoryDialog::Update(float dt){
|
|||||||
graphics[i]->Update(dt);
|
graphics[i]->Update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StoryReward::collection) {
|
||||||
|
StoryReward::collection->save();
|
||||||
|
SAFE_DELETE(StoryReward::collection);
|
||||||
|
}
|
||||||
|
|
||||||
JButton key = mEngine->ReadButton();
|
JButton key = mEngine->ReadButton();
|
||||||
CheckUserInput(key);
|
CheckUserInput(key);
|
||||||
|
|
||||||
@@ -441,6 +497,9 @@ bool StoryFlow::_gotoPage(string id){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
currentPageId = id;
|
currentPageId = id;
|
||||||
|
if (pages[currentPageId]->musicFile.size()) {
|
||||||
|
GameApp::playMusic(pages[currentPageId]->musicFile);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,9 +535,15 @@ bool StoryFlow::parse(string path)
|
|||||||
if (element != NULL) {
|
if (element != NULL) {
|
||||||
if (strcmp(element->Value(), "page")==0) {
|
if (strcmp(element->Value(), "page")==0) {
|
||||||
string id = element->Attribute("id");
|
string id = element->Attribute("id");
|
||||||
|
|
||||||
|
OutputDebugString("\nparsing ");
|
||||||
|
OutputDebugString(id.c_str());
|
||||||
|
OutputDebugString("...\n");
|
||||||
|
|
||||||
StoryPage * sp = loadPage(element);
|
StoryPage * sp = loadPage(element);
|
||||||
pages[id] = sp;
|
pages[id] = sp;
|
||||||
if (!currentPageId.size()) gotoPage(id);
|
if (!currentPageId.size()) gotoPage(id);
|
||||||
|
OutputDebugString("OK\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Error
|
//Error
|
||||||
|
|||||||
@@ -701,8 +701,14 @@ string WResourceManager::musicFile(const string filename){
|
|||||||
if(fileOK(defdir,true))
|
if(fileOK(defdir,true))
|
||||||
return defdir;
|
return defdir;
|
||||||
|
|
||||||
//Complete abject failure. Probably a crash...
|
//Failure. Check raw faile.
|
||||||
|
sprintf(defdir,"%s",filename.c_str());
|
||||||
|
if(fileOK(defdir,true))
|
||||||
return defdir;
|
return defdir;
|
||||||
|
|
||||||
|
|
||||||
|
//Complete abject failure. Probably a crash...
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
string WResourceManager::sfxFile(const string filename){
|
string WResourceManager::sfxFile(const string filename){
|
||||||
@@ -826,7 +832,9 @@ void WResourceManager::autoResize(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
JMusic * WResourceManager::ssLoadMusic(const char *fileName){
|
JMusic * WResourceManager::ssLoadMusic(const char *fileName){
|
||||||
return JSoundSystem::GetInstance()->LoadMusic(musicFile(fileName).c_str());
|
string file = musicFile(fileName);
|
||||||
|
if (!file.size()) return NULL;
|
||||||
|
return JSoundSystem::GetInstance()->LoadMusic(file.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user