- fixed bugs introduced in revision 2034 (Giant Growth)
- Extended Story mode xml: much easier to write basic thing, font selection, possibility to position answers, answers now in correct order
- moved story in the menu because it is not major for now
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-05-06 13:47:56 +00:00
parent f7e55bbc9e
commit 0149512412
13 changed files with 315 additions and 281 deletions

View File

@@ -2,25 +2,26 @@
<page id="start">
<type>dialog</type>
<text align="center">WELCOME YOUNG ADVENTURER...</text>
<img y="15">_gfx/shopkeeper.jpg</img>
<text y="115">So you want to become a sorcerer?</text>
<text y="130">You've come to the right place. I'm myself just</text>
<text y="145">a humble retailer, but I've met a lot of adventurers like you</text>
<text y="160">in my life, enough to understand the basics of their craft...</text>
<title>WELCOME YOUNG ADVENTURER...</title>
<img>_gfx/shopkeeper.jpg</img>
<text>So you want to become a sorcerer?</text>
<text>You've come to the right place. I'm myself just</text>
<text>a humble retailer, but I've met a lot of adventurers like you</text>
<text>in my life, enough to understand the basics of their craft...</text>
<answer goto="tap_mana_intro">Interested?</answer>
<answer goto="tap_mana_intro" align="center" x="0.30" font="1">I want to know more</answer>
<answer goto="tap_mana_intro" x="0.80" y="-1">Take me back to the menu</answer>
</page>
<page id="tap_mana_intro">
<type>dialog</type>
<text align="center">TAPPING LANDS FOR MANA</text>
<text y="15">In your quests you will have to fight against other wizards.</text>
<text y="30">You will only have your brain and your spells to help you.</text>
<text y="45">The basic Energy to cast your spells in Wagic is called mana.</text>
<text y="60">The most frequent sources of Mana are called "Lands".</text>
<text y="90">For a land to produce mana,</text>
<text y="105">you just have to click on it with the action button (CIRCLE by default)</text>
<title>TAPPING LANDS FOR MANA</title>
<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>The basic Energy to cast your spells in Wagic is called mana.</text>
<text>The most frequent sources of Mana are called "Lands".</text>
<text>For a land to produce mana,</text>
<text>you just have to click on it with the action button (CIRCLE by default)</text>
<answer goto="tap_mana">Go ahead and tap some mana!</answer>
</page>
@@ -32,22 +33,22 @@
<page id="tap_mana_try_again">
<type>dialog</type>
<text align="center">HMMM...</text>
<text y="15">It seems you didn't get that right</text>
<text y="30">Simply navigate (with the D-Pad) to the land that appears on your screen,</text>
<text y="45">then click on the action button (CIRCLE by default)</text>
<title>HMMM...</title>
<text>It seems you didn't get that right</text>
<text>Simply navigate (with the D-Pad) to the land that appears on your screen,</text>
<text>then click on the action button (CIRCLE by default)</text>
<answer goto="tap_mana">Let's try again!</answer>
</page>
<page id="tap_mana_ok">
<type>dialog</type>
<text align="center">WELL DONE...NOW LET'S CAST A SPELL</text>
<text y="15">That was too easy for you!</text>
<text y="30">Now let's see if you can cast a spell...</text>
<text y="45">Spells have a cost represented by mana symbols on the top right corner</text>
<text y="60">of the card. For example, 2 white mana icons on the top right of the card</text>
<text y="75">means that you have to produce 2 white manas (by activating 2 plains)</text>
<text y="90">in order to put it into play.</text>
<title>WELL DONE...NOW LET'S CAST A SPELL</title>
<text>That was too easy for you!</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>of the card. For example, 2 white mana icons on the top right of the card</text>
<text>means that you have to produce 2 white manas (by activating 2 plains)</text>
<text>in order to put it into play.</text>
<answer goto="cast_spell_1">Try to produce 2 white mana and put a white knight in play</answer>
</page>
@@ -59,24 +60,24 @@
<page id="cast_spell_1_try_again">
<type>dialog</type>
<text align="center">HMMM...</text>
<text y="15">It seems you didn't get that right</text>
<text y="30">Simply navigate (with the D-Pad) to the lands that appear on your screen,</text>
<text y="45">then click on the action button (CIRCLE by default) on each of them to produce 2 white mana.</text>
<text y="60">Once this is done, navigate to the White Knight in your hand and click (CIRCLE by default) on it.</text>
<text y="75">Depending on your configuration, you might need to display your hand (RTRIGGER by default)</text>
<title>HMMM...</title>
<text>It seems you didn't get that right</text>
<text>Simply navigate (with the D-Pad) to the lands that appear on your screen,</text>
<text>then click on the action button (CIRCLE by default) on each of them to produce 2 white mana.</text>
<text>Once this is done, navigate to the White Knight in your hand and click (CIRCLE by default) on it.</text>
<text>Depending on your configuration, you might need to display your hand (RTRIGGER by default)</text>
<answer goto="cast_spell_1">Let's try again!</answer>
</page>
<page id="cast_spell_1_ok">
<type>dialog</type>
<text align="center">PERFECT...BUT THERE'S MORE TO IT</text>
<text y="15">You did great, young adventurer!</text>
<text y="30">But you will see that some spells have slighlty different costs.</text>
<text y="45">Sometimes the cost contains a number with no mana color. It means you can</text>
<text y="60">pay with mana of whatever color you want.</text>
<text y="75">for example a card which cost has a number "1" and a green icon</text>
<text y="90">needs you to pay 1 green mana + a mana of any color if you want to play it.</text>
<title>PERFECT...BUT THERE'S MORE TO IT</title>
<text>You did great, young adventurer!</text>
<text>But you will see that some spells have slighlty different costs.</text>
<text>Sometimes the cost contains a number with no mana color. It means you can</text>
<text>pay with mana of whatever color you want.</text>
<text>for example a card which cost has a number "1" and a green icon</text>
<text>needs you to pay 1 green mana + a mana of any color if you want to play it.</text>
<answer goto="cast_spell_2">Try to put a grizzly bear card in play.</answer>
</page>
@@ -88,25 +89,25 @@
<page id="cast_spell_2_try_again">
<type>dialog</type>
<text align="center">HMMM...</text>
<text y="15">It seems you didn't get that right</text>
<text y="30">Simply navigate (with the D-Pad) to the lands that appear on your screen,</text>
<text y="45">then click on the action button (CIRCLE by default) on some of them to produce some mana.</text>
<text y="60">Remember, you need 1 green mana and one other mana of any color.</text>
<text y="75">Once this is done, navigate to the Grizzly Bears in your hand and click (CIRCLE by default) on it.</text>
<title>HMMM...</title>
<text>It seems you didn't get that right</text>
<text>Simply navigate (with the D-Pad) to the lands that appear on your screen,</text>
<text>then click on the action button (CIRCLE by default) on some of them to produce some mana.</text>
<text>Remember, you need 1 green mana and one other mana of any color.</text>
<text>Once this is done, navigate to the Grizzly Bears in your hand and click (CIRCLE by default) on it.</text>
<answer goto="cast_spell_2">Let's try again!</answer>
</page>
<page id="cast_spell_2_ok">
<type>dialog</type>
<text align="center">GREAT. NOW LET'S TALK ABOUT PHASES</text>
<text y="15">Once you put them into play, you will want your creatures to attack your opponent.</text>
<text y="30">After all, they are here to help you defeat other sorcerers!</text>
<text y="45">Your creatures can't attack anytime they want, however,</text>
<text y="60">they must wait for the combat phase of your turn.</text>
<text y="75">Your turn is divided into several phases. You can go through the phases by</text>
<text y="90">clicking on LTRIGGER by default. The name of the current phase is displayed on the</text>
<text y="105">top right corner of the screen.</text>
<title>GREAT. NOW LET'S TALK ABOUT PHASES</title>
<text>Once you put them into play, you will want your creatures to attack your opponent.</text>
<text>After all, they are here to help you defeat other sorcerers!</text>
<text>Your creatures can't attack anytime they want, however,</text>
<text>they must wait for the combat phase of your turn.</text>
<text>Your turn is divided into several phases. You can go through the phases by</text>
<text>clicking on LTRIGGER by default. The name of the current phase is displayed on the</text>
<text>top right corner of the screen.</text>
<answer goto="attack">Go to the "Attackers" phase, then click on your White Knight to attack.</answer>
</page>
@@ -119,31 +120,31 @@
<page id="attack_try_again">
<type>dialog</type>
<text align="center">HMMM...</text>
<text y="15">It seems you didn't get that right</text>
<text y="30">Go to the "Attackers" phase by clicking on LTRIGGER several times,</text>
<text y="45">then click on your White Knight (with CIRCLE by default) to attack your opponent.</text>
<title>HMMM...</title>
<text>It seems you didn't get that right</text>
<text>Go to the "Attackers" phase by clicking on LTRIGGER several times,</text>
<text>then click on your White Knight (with CIRCLE by default) to attack your opponent.</text>
<answer goto="attack">Let's try again!</answer>
</page>
<page id="attack_ok">
<type>dialog</type>
<text align="center">GOOD!</text>
<text y="15">Let me tell you a bit more about phases.</text>
<text y="30">Your turn is divided into several phases. The actions you can perform</text>
<text y="45">Depend on the phase you're in. For now, let's say that you can:</text>
<text y="60">- Play creatures during the "main phase 1" and the "main phase 2" phases of your turn.</text>
<text y="75">- Attack with your creatures during the "Attackers" phase of your turn.</text>
<text y="90">- Block your opponent's attacking creatures during the "blockers" phase of his turn.</text>
<text y="120">There are lots of other phases but we'll discuss them later</text>
<title>GOOD!</title>
<text>Let me tell you a bit more about phases.</text>
<text>Your turn is divided into several phases. The actions you can perform</text>
<text>Depend on the phase you're in. For now, let's say that you can:</text>
<text>- Play creatures during the "main phase 1" and the "main phase 2" phases of your turn.</text>
<text>- Attack with your creatures during the "Attackers" phase of your turn.</text>
<text>- Block your opponent's attacking creatures during the "blockers" phase of his turn.</text>
<text>There are lots of other phases but we'll discuss them later</text>
<answer goto="End">Continue</answer>
</page>
<page id="End">
<type>End</type>
<text align="center">CONGRATULATIONS!</text>
<text y="15">This is the end of this tutorial,</text>
<text y="30">now time for you to fight some real ennemies!</text>
<text y="60">Click on the action button to go back to the main menu</text>
<title>CONGRATULATIONS!</title>
<text>This is the end of this tutorial,</text>
<text>now time for you to fight some real ennemies!</text>
<text>Click on the action button to go back to the main menu</text>
</page>

View File

@@ -0,0 +1,69 @@
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
a series of dialogs and duels.
#################################
1.Structure of story.xml:
#################################
===========================================
Elements of the root node
===========================================
page *
attributes:
id (compulsory)
===========================================
Elements of the page node
===========================================
type (dialog,duel,end)
===========================================
Additional Elmts of the "page" node if type == dialog
===========================================
title *
img *
text *
answer *
title, img, text, answer have the following common attributes:
x (optional - default 0)
0 means auto
0 < x < 1 means percentage of screen width
other value = absolute position
y (optional - default 0)
-1 means: go to previous line
0 means: auto
0 < y < 1 means: percentage of screen height
other value = absolute position
font (optional - default 0)
0, 1, or 2
align (optional - default left)
left, center, right
font and align not supported by title, which is equivalent to <text font="1" align="center">
answer specific attributes:
goto
id of a page to go to
===========================================
Additional Elmts of the "page" node if type == dialog
===========================================
onwin
id of a page to go to if duel lost
onlose
id of a page to go to if duel won
#################################
2.Duel mode
#################################

View File

@@ -8662,7 +8662,7 @@ name=Corpse Hatch
target=creature[-black]
auto=destroy
auto=Token(-193507)*2
text=Destroy target nonblack creature. -- Put two 0/1 colorless Eldrazi Spawn creature tokens onto the battlefield. They have “Sacrifice this creature: Add {1} to your mana pool.
text=Destroy target nonblack creature. -- Put two 0/1 colorless Eldrazi Spawn creature tokens onto the battlefield. They have “Sacrifice this creature: Add {1} to your mana pool.<EFBFBD>E
mana={3}{B}{B}
type=Sorcery
[/card]
@@ -14631,30 +14631,30 @@ type=Creature
subtype=Faerie Soldier
power=3
toughness=2
[/card]
[/card]
[card]
[card]
name=Feral Hydra
type=Creature
subtype=Hydra Beast
mana={X}{G}
power=0
toughness=0
toughness=0
text=Feral Hydra enters the battlefield with X +1/+1 counters on it. -- {3}: Put a +1/+1 counter on Feral Hydra. Any player may play this ability
auto=counter(1/1,X)
auto={3}:counter(1/1)
grade=borderline
[/card]
[card]
name=Feral Instinct
@@ -17052,6 +17052,8 @@ toughness=3
name=Giant Growth
text=Target creature gets +3/+3 until end of turn.
mana={G}
target=creature
auto=3/3
type=Instant
[/card]
[card]
@@ -18876,7 +18878,7 @@ name=Grizzly Fate
auto=token(Bear,creature bear, 2/2,green)*2
auto=aslongas(*|mygraveyard) token(Bear,creature bear, 2/2,green)*2 >6
autograveyard={5}{G}{G}:copy(this) && moveTo(mystack) asSorcery
text=Put two 2/2 green Bear creature tokens onto the battlefield. -- Threshold Put four 2/2 green Bear creature tokens onto the battlefield instead if seven or more cards are in your graveyard. -- Flashback {2}{G}{G} (You may cast this card from your graveyard for its flashback cost. Then exile it.)
text=Put two 2/2 green Bear creature tokens onto the battlefield. -- Threshold <EFBFBD>EPut four 2/2 green Bear creature tokens onto the battlefield instead if seven or more cards are in your graveyard. -- Flashback {2}{G}{G} (You may cast this card from your graveyard for its flashback cost. Then exile it.)
mana={3}{G}{G}
type=Sorcery
[/card]
@@ -21713,7 +21715,7 @@ type=Enchantment
name=Ior Ruin Expedition
auto=@movedTo(land|myBattlefield):may counter(0/0,1,Quest)
auto={C(0/0,-3,Quest)}{S}:draw:2
text=Landfall Whenever a land enters the battlefield under your control, you may put a quest counter on Ior Ruin Expedition. -- Remove three quest counters from Ior Ruin Expedition and sacrifice it: Draw two cards.
text=Landfall <EFBFBD>EWhenever a land enters the battlefield under your control, you may put a quest counter on Ior Ruin Expedition. -- Remove three quest counters from Ior Ruin Expedition and sacrifice it: Draw two cards.
mana={1}{U}
type=Enchantment
[/card]
@@ -43026,7 +43028,7 @@ toughness=1
name=Sunspring Expedition
auto=@movedTo(land|myBattlefield):may counter(0/0,1,Quest)
auto={C(0/0,-3,Quest)}{S}:life:8
text=Landfall Whenever a land enters the battlefield under your control, you may put a quest counter on Sunspring Expedition. -- Remove three quest counters from Sunspring Expedition and sacrifice it: You gain 8 life.
text=Landfall <EFBFBD>EWhenever a land enters the battlefield under your control, you may put a quest counter on Sunspring Expedition. -- Remove three quest counters from Sunspring Expedition and sacrifice it: You gain 8 life.
mana={W}
type=Enchantment
[/card]
@@ -46531,7 +46533,7 @@ auto=foreach(other creature[red]|myBattlefield) counter(1/1,1)
auto=foreach(other creature[green]|myBattlefield) counter(1/1,1)
auto={1}{C(1/1,-1)}:damage:1 target(creature)
auto={1}{C(1/1,-1)}:token(Saproling,Creature Saproling,1/1,green)
text=Ulasht, the Hate Seed enters the battlefield with a +1/+1 counter on it for each other red creature you control and a +1/+1 counter on it for each other green creature you control. -- {1}, Remove a +1/+1 counter from Ulasht: Choose one Ulasht deals 1 damage to target creature; or put a 1/1 green Saproling creature token onto the battlefield.
text=Ulasht, the Hate Seed enters the battlefield with a +1/+1 counter on it for each other red creature you control and a +1/+1 counter on it for each other green creature you control. -- {1}, Remove a +1/+1 counter from Ulasht: Choose one <EFBFBD>EUlasht deals 1 damage to target creature; or put a 1/1 green Saproling creature token onto the battlefield.
mana={2}{R}{G}
type=Legendary Creature
subtype=Hellion Hydra
@@ -46557,7 +46559,7 @@ auto=@damaged(creature,player) from(mytgt):counter(0/0,2,Charge) all(this)
auto={C(0/0,-1,Charge)}:2/2
auto={C(0/0,-1,Charge)}:-1/-1 target(creature)
auto={C(0/0,-1,Charge)}:life:2 controller
text=Whenever equipped creature deals combat damage, put two charge counters on Umezawa's Jitte. -- Remove a charge counter from Umezawa's Jitte: Choose one Equipped creature gets +2/+2 until end of turn; or target creature gets -1/-1 until end of turn; or you gain 2 life. -- Equip {2}
text=Whenever equipped creature deals combat damage, put two charge counters on Umezawa's Jitte. -- Remove a charge counter from Umezawa's Jitte: Choose one <EFBFBD>EEquipped creature gets +2/+2 until end of turn; or target creature gets -1/-1 until end of turn; or you gain 2 life. -- Equip {2}
mana={2}
type=Legendary Artifact
subtype=Equipment

View File

@@ -389,7 +389,6 @@ shivan_hellkite.txt
shock.txt
shock2.txt
siege_gang_commander.txt
silent_arbiter.txt
simic_initiate.txt
slate_of_ancestry.txt
sleeper_agent.txt

View File

@@ -11,42 +11,48 @@ class GameObserver;
#define CAMPAIGNS_FOLDER "Res/campaigns/"
class StoryGraphicalElement:public JGuiObject {
class StoryDialogElement:public JGuiObject {
public:
float mX;
float mY;
StoryGraphicalElement(float x, float y);
StoryDialogElement(float x, float y, int id = 0);
void Entering(){};
bool Leaving(JButton key) {return false;};
bool ButtonPressed() {return false;};
bool hasFocus() {return false;};
virtual float getHeight() = 0;
};
class StoryText:public StoryGraphicalElement {
class StoryText:public StoryDialogElement {
public :
string text;
int align;
StoryText(string text, float mX, float mY, string align = "center");
int font;
StoryText(string text, float mX, float mY, string align = "center", int font = 0, int id = 0);
void Render();
void Update(float dt);
virtual ostream& toString(ostream& out) const;
float getHeight();
};
class StoryImage:public StoryGraphicalElement {
class StoryImage:public StoryDialogElement {
public :
string img;
StoryImage(string img, float mX, float mY);
void Render();
void Update(float dt);
virtual ostream& toString(ostream& out) const;
float getHeight();
};
class StoryChoice:public JGuiObject {
class StoryChoice:public StoryText {
public:
string pageId;
string text;
float mX;
float mY;
bool mHasFocus;
float mScale;
float mTargetScale;
StoryChoice(string id, string text, int JGOid, float mX, float mY, bool hasFocus);
StoryChoice(string id, string text, int JGOid, float mX, float mY, string _align, int _font, bool hasFocus);
void Render();
void Update(float dt);
@@ -55,11 +61,12 @@ public:
bool ButtonPressed();
bool hasFocus();
virtual ostream& toString(ostream& out) const;
float getHeight();
};
class StoryFlow;
class StoryPage {
public:
public:
StoryFlow * mParent;
StoryPage(StoryFlow * mParent);
virtual void Update(float dt)=0;
@@ -69,15 +76,18 @@ public:
class StoryDialog:public StoryPage, public JGuiListener,public JGuiController {
private:
vector<StoryGraphicalElement *>graphics;
vector<StoryDialogElement *>graphics;
string safeAttribute(TiXmlElement* element, string attribute);
void RenderElement(StoryDialogElement * elmt);
public:
StoryDialog(TiXmlElement* el,StoryFlow * mParent);
~StoryDialog();
void Update(float dt);
void Render();
void ButtonPressed(int,int);
static float currentY;
static float previousY;
};

View File

@@ -472,7 +472,6 @@ void GameStateMenu::Update(float dt)
currentState = MENU_STATE_MAJOR_SUBMENU;
subMenuController = NEW SimpleMenu(102, this, Constants::MENU_FONT, 150,60);
if (subMenuController){
subMenuController->Add(SUBMENUITEM_STORY,"Story");
subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic");
if (options[Options::MOMIR_MODE_UNLOCKED].number)
subMenuController->Add(SUBMENUITEM_MOMIR, "Momir Basic");
@@ -480,6 +479,7 @@ void GameStateMenu::Update(float dt)
subMenuController->Add(SUBMENUITEM_RANDOM1, "Random 1 Color");
subMenuController->Add(SUBMENUITEM_RANDOM2, "Random 2 Colors");
}
subMenuController->Add(SUBMENUITEM_STORY,"Story");
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
}
}else{

View File

@@ -9,26 +9,42 @@
#include <JFileSystem.h>
StoryGraphicalElement::StoryGraphicalElement(float x, float y): JGuiObject(0), mX(x),mY(y) {
#define LINE_SPACE 2
#define SPACE_BEFORE_CHOICES 10
float StoryDialog::currentY = 2;
float StoryDialog::previousY = 2;
StoryDialogElement::StoryDialogElement(float x, float y, int id): JGuiObject(id), mX(x),mY(y) {
}
StoryText::StoryText(string text, float _mX, float _mY, string _align):StoryGraphicalElement(_mX,_mY), text(text) {
StoryText::StoryText(string text, float _mX, float _mY, string _align, int _font, int id):StoryDialogElement(_mX,_mY, id), text(text), font(_font) {
align = JGETEXT_LEFT;
if (_align.compare("center") == 0) {
align = JGETEXT_CENTER;
if (mX == 0)
mX = SCREEN_WIDTH/2;
}else if (_align.compare("right") == 0) {
align = JGETEXT_RIGHT;
if (mX == 0)
mX = SCREEN_WIDTH - 10;
}
if (align == JGETEXT_CENTER && mX == 0){
mX = SCREEN_WIDTH/2;
if (align == JGETEXT_LEFT && mX <= 0){
mX += 10; //left margin
}
}
void StoryText::Render() {
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
JLBFont * mFont = resources.GetJLBFont(font);
mFont->SetColor(ARGB(200,255,255,255));
mFont->SetScale(1.0);
mFont->DrawString(text.c_str(), mX, mY, align);
}
float StoryText::getHeight() {
JLBFont * mFont = resources.GetJLBFont(font);
return mFont->GetHeight();
}
void StoryText::Update(float dt){
//Nothing for now
}
@@ -38,7 +54,7 @@ void StoryText::Render() {
return out << "StoryText ::: text : " << text;
}
StoryImage::StoryImage(string img, float mX, float mY):StoryGraphicalElement(mX,mY), img(img) {
StoryImage::StoryImage(string img, float mX, float mY):StoryDialogElement(mX,mY), img(img) {
}
void StoryImage::Render() {
@@ -52,6 +68,15 @@ void StoryImage::Render() {
JRenderer::GetInstance()->RenderQuad(quad,x, mY);
}
}
float StoryImage::getHeight() {
JQuad * quad = resources.RetrieveQuad(img);
if (quad) {
return quad->mHeight;
}
return 0;
}
void StoryImage::Update(float dt){
//Nothing for now
}
@@ -76,11 +101,16 @@ StoryFlow::StoryFlow(string folder): folder(folder){
void StoryChoice::Render()
{
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
JLBFont * mFont = resources.GetJLBFont(font);
mFont->SetColor(ARGB(200,255,255,255));
if (mHasFocus) mFont->SetColor(ARGB(255,255,255,0));
mFont->SetScale(mScale);
mFont->DrawString(text.c_str(), mX, mY, JGETEXT_CENTER);
mFont->DrawString(text.c_str(), mX, mY, align);
}
float StoryChoice::getHeight() {
JLBFont * mFont = resources.GetJLBFont(font);
return mFont->GetHeight() * mScale;
}
void StoryChoice::Update(float dt)
@@ -133,7 +163,7 @@ ostream& StoryChoice::toString(ostream& out) const
}
StoryChoice::StoryChoice(string pageId, string text, int JGOid, float mX, float mY, bool hasFocus):JGuiObject(JGOid),pageId(pageId),text(text),mX(mX),mY(mY),mHasFocus(hasFocus){
StoryChoice::StoryChoice(string pageId, string text, int JGOid, float mX, float mY, string _align, int _font, bool hasFocus):StoryText(text, mX, mY, _align, _font, JGOid),pageId(pageId),mHasFocus(hasFocus){
mScale = 1.0f;
mTargetScale = 1.0f;
if(hasFocus) mTargetScale = 1.2f;
@@ -221,39 +251,47 @@ string StoryDialog::safeAttribute(TiXmlElement* element, string attribute) {
StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent):StoryPage(mParent), JGuiListener(), JGuiController(1,NULL) {
currentY = 0;
for (TiXmlNode* node = root->FirstChild(); node; node = node->NextSibling()) {
TiXmlElement* element = node->ToElement();
if (element) {
string sX = safeAttribute(element, "x");
float x = atof(sX.c_str());
if (x>0 && x < 1){
x = SCREEN_WIDTH_F * x;
}
string sY = safeAttribute(element,"y");
float y = atof(sY.c_str());
if (y>0 && y < 1){
y = SCREEN_HEIGHT_F * y;
}
string align = safeAttribute(element,"align");
const char* textC = element->GetText();
string text = textC;
string sFont = safeAttribute(element,"font");
int font = atoi(sFont.c_str());
if (strcmp(element->Value(), "text")==0) {
string sX = safeAttribute(element, "x");
float x = atof(sX.c_str());
string sY = safeAttribute(element,"y");
float y = atof(sY.c_str());
string align = safeAttribute(element,"align");
const char* textC = element->GetText();
string text = textC;
graphics.push_back(NEW StoryText(text,x,y,align));
graphics.push_back(NEW StoryText(text,x,y,align, font));
}
else if (strcmp(element->Value(), "title")==0) {
graphics.push_back(NEW StoryText(text,x,y,"center", Constants::MENU_FONT));
}
else if (strcmp(element->Value(), "img")==0) {
string sX = safeAttribute(element,"x");
float x = atof(sX.c_str());
//special case to force center
if (sX.compare("") == 0 ){
x = -1;
}
string sY = safeAttribute(element,"y");
float y = atof(sY.c_str());
const char* imgC = element->GetText();
string img = imgC;
img = string("campaigns/").append(mParent->folder).append("/").append(img);
string img = string("campaigns/").append(mParent->folder).append("/").append(text);
graphics.push_back(NEW StoryImage(img,x,y));
}
else if (strcmp(element->Value(), "answer")==0){
string id = element->Attribute("goto");
const char* answerC = element->GetText();
string answer = answerC;
if (!align.size()) align = "center";
int i = mObjects.size();
StoryChoice * sc = NEW StoryChoice(id,answer,i,SCREEN_WIDTH/2, SCREEN_HEIGHT-20 - i *20 , (i==0));
StoryChoice * sc = NEW StoryChoice(id,text,i,x, y , align, font, (i==0));
graphics.push_back(sc);
Add(sc);
}else {
//Error
@@ -265,18 +303,38 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent):StoryPage(mPar
}
void StoryDialog::Update(float dt){
JGuiController::Update(dt);
for (size_t i = 0; i < graphics.size(); ++i){
graphics[i]->Update(dt);
}
JButton key = mEngine->ReadButton();
CheckUserInput(key);
}
void StoryDialog::RenderElement(StoryDialogElement * elmt) {
float mYBackup = elmt->mY;
if (! elmt->mY) elmt->mY = currentY;
if (elmt->mY == -1) {
elmt->mY = previousY;
}
elmt->Render();
previousY = currentY;
currentY = elmt->mY + elmt->getHeight() + LINE_SPACE;
elmt->mY = mYBackup;
}
void StoryDialog::Render() {
currentY = 2;
previousY = currentY;
for (size_t i = 0; i < graphics.size(); ++i){
graphics[i]->Render();
StoryDialogElement * elmt = (StoryDialogElement *)(graphics[i]);
if (elmt == mObjects[0])
currentY += SPACE_BEFORE_CHOICES;
RenderElement(elmt);
}
JGuiController::Render();
}
void StoryDialog::ButtonPressed(int controllerid,int controlid) {
@@ -284,7 +342,8 @@ void StoryDialog::ButtonPressed(int controllerid,int controlid) {
}
StoryDialog::~StoryDialog(){
for (size_t i = 0; i < graphics.size(); ++i){
mCount = 0; //avoid parent deleting
for (size_t i = 0; i < graphics.size(); ++i){
delete(graphics[i]);
}
}