Files
wagic/projects/mtg/include/StoryFlow.h
wagic.the.homebrew@gmail.com a3cbbedd3c Erwan
- fix issue 392 (broken tests)
- Fix a bunch of memory leaks (guys please be careful!)
- Added Logging facility in JGE
- HBL Compatibility (cleaned up some code with MP3 in JGE)
- Added "winGame" ability. Currently used mostly by the story mode, but some cards could probably need it too
- Improved story mode and uncommented it from the source.
-- The current campaign is of course very basic, anybody who wants to improve it or create other ones feel free to do so
-- TODO (short term): save progress, rewards system, improve tutorial campaign
-- I'll talk a bit more about this on the forums/email after a night of sleep
2010-04-26 14:27:34 +00:00

116 lines
2.3 KiB
C++

#ifndef _STORYFLOW_H_
#define _STORYFLOW_H_
#include <string>
#include <map>
#include <vector>
using namespace std;
#include "../../../JGE/src/tinyxml/tinyxml.h"
#include <JGui.h>
class GameObserver;
#define CAMPAIGNS_FOLDER "Res/campaigns/"
class StoryGraphicalElement:public JGuiObject {
public:
float mX;
float mY;
StoryGraphicalElement(float x, float y);
};
class StoryText:public StoryGraphicalElement {
public :
string text;
int align;
StoryText(string text, float mX, float mY, string align = "center");
void Render();
void Update(float dt);
virtual ostream& toString(ostream& out) const;
};
class StoryImage:public StoryGraphicalElement {
public :
string img;
StoryImage(string img, float mX, float mY);
void Render();
void Update(float dt);
virtual ostream& toString(ostream& out) const;
};
class StoryChoice:public JGuiObject {
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);
void Render();
void Update(float dt);
void Entering();
bool Leaving(JButton key);
bool ButtonPressed();
bool hasFocus();
virtual ostream& toString(ostream& out) const;
};
class StoryFlow;
class StoryPage {
public:
StoryFlow * mParent;
StoryPage(StoryFlow * mParent);
virtual void Update(float dt)=0;
virtual void Render()=0;
virtual ~StoryPage(){};
};
class StoryDialog:public StoryPage, public JGuiListener,public JGuiController {
private:
vector<StoryGraphicalElement *>graphics;
string safeAttribute(TiXmlElement* element, string attribute);
public:
StoryDialog(TiXmlElement* el,StoryFlow * mParent);
~StoryDialog();
void Update(float dt);
void Render();
void ButtonPressed(int,int);
};
class Rules;
class StoryDuel:public StoryPage {
public:
string pageId;
string onWin, onLose;
GameObserver * game;
Rules * rules;
StoryDuel(TiXmlElement* el,StoryFlow * mParent);
virtual ~StoryDuel();
void Update(float dt);
void Render();
void init();
};
class StoryFlow{
private:
map<string,StoryPage *>pages;
bool parse(string filename);
StoryPage * loadPage(TiXmlElement* element);
public:
string currentPageId;
string folder;
StoryFlow(string folder);
~StoryFlow();
bool gotoPage(string id);
void Update(float dt);
void Render();
};
#endif