- Added TutorialMessage ability

-- Tutorial Messages are an ability like any other, except it can only be displayed once. Subsequent calls are ignored, the ability is removed from the game as soon as it is added
-- This allows to add event triggered messages ingame. Messages are either text, or images (I don't have an image sample, but rules/classic.txt has a few examples that might help)
-- only tested on Windows, although I made sure the PSP version compiles. Hopefully I also made the necessary for it to work in the touch version (touching the screen should be enough to close the tuto message)
-- Room for improvement: possibility to choose a title in text mode, possibility to have some messages depending on others (e.g.: don't show message X until message Y has been shown), improve some of the abilities and triggers to give more flexibility, add events outside of game, to allow tuto messages in deck creator, etc...
This commit is contained in:
wagic.the.homebrew
2011-07-03 08:47:51 +00:00
parent 72c795c24b
commit 52b83a135c
25 changed files with 656 additions and 56 deletions

View File

@@ -18,6 +18,7 @@
#include "ThisDescriptor.h"
#include <JGui.h>
#include <hge/hgeparticle.h>
#include "IconButton.h"
#include <map>
using std::map;
@@ -829,6 +830,38 @@ public:
return a;
}
};
//Tutorial Messaging
class ATutorialMessage: public MTGAbility, public IconButtonsController
{
public:
string mMessage;
float mElapsed, mSH, mSW;
JTexture * mBgTex;
JQuad * mBg[9];
bool mUserCloseRequest, mDontShow;
bool mIsImage;
ATutorialMessage(MTGCardInstance * source, string message);
void Update(float dt);
bool CheckUserInput(JButton key);
void Render();
string getOptionName();
bool alreadyShown();
ATutorialMessage * clone() const;
~ATutorialMessage();
//JGuiListener Implementation
void ButtonPressed(int controllerId, int controlId);
static ATutorialMessage * Current;
};
//counters
class AACounter: public ActivatedAbility
{

View File

@@ -352,13 +352,15 @@ public:
int load();
GameOption * get(int);
GameOption * get(string optionName);
GameOption& operator[](int);
GameOption& operator[](string);
GameOptions(string filename);
~GameOptions();
private:
vector<GameOption*> values;
vector<string> unknown;
map<string,GameOption*> unknownMap;
};
class GameSettings
@@ -408,6 +410,7 @@ public:
GameOption* get(int);
GameOption& operator[](int);
GameOption& operator[](string);
GameOptions* profileOptions;
GameOptions* globalOptions;

View File

@@ -0,0 +1,50 @@
#ifndef _ICONBUTTON_H
#define _ICONBUTTON_H
#include <string>
#include <JGui.h>
using std::string;
class IconButtonsController: public JGuiController, public JGuiListener
{
public:
float mX;
float mY;
IconButtonsController(float x, float y);
void SetColor(PIXEL_TYPE color);
};
class IconButton: public JGuiObject
{
private:
PIXEL_TYPE mColor;
IconButtonsController * mParent;
bool mHasFocus;
int mFontId;
string mText;
float mScale, mCurrentScale, mTargetScale;
float mX, mY;
float mTextRelativeX, mTextRelativeY;
JTexture * mTex;
JQuad * mQuad;
public:
IconButton(int id, IconButtonsController * parent, string texture, float x, float y, float scale, int fontId, string text, float textRelativeX, float textRelativeY, bool hasFocus = false);
IconButton(int id, IconButtonsController * parent, JQuad * quad, float x, float y, float scale, int fontId, string text, float textRelativeX, float textRelativeY, bool hasFocus = false);
void init(IconButtonsController * parent, JQuad * quad, float x, float y, float scale, int fontId, string text, float textRelativeX, float textRelativeY, bool hasFocus);
~IconButton();
ostream& toString(ostream& out) const;
bool hasFocus();
virtual void Render();
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving(JButton key);
virtual bool ButtonPressed();
void SetColor(PIXEL_TYPE color);
};
#endif

View File

@@ -52,7 +52,7 @@ public:
Task(char _type = ' ');
static Task* createFromStr(string params, bool rand = false);
static Task* createFromStr(const string params, bool rand = false);
virtual string toString();
string getDesc();
virtual string createDesc() = 0;

View File

@@ -100,6 +100,9 @@ std::vector<std::string> parseBetween(const std::string& s, string start, string
std::string wordWrap(const std::string& s, float width, int fontId);
//basic hash function
unsigned long hash_djb2(const char *str);
int loadRandValues(string s);
int filesize(const char * filename);
int fileExists(const char * filename);