Jeck - [JGE recompile needed] Shop cleanup, Interface enhancements.

Added basic transition system that works with GameApp's phases. Currently does a fade-out between elements, which works well in some places and not-so-well in others. We'll definitely want to think about where and where not to use it... they'd work a lot better if we could spawn a thread to handle loading the next state while transitioning.

Also cleaned up the shop a bit, so it uses ReadButton() instead of GetButtonClick()-- hence the slight change to JGE. Added a tiled image for the task board, which loads conservatively (I tried 128x128, but it didn't look as good).
This commit is contained in:
wagic.jeck
2010-02-01 18:27:25 +00:00
parent e999da6ef7
commit 0a863bcbad
21 changed files with 1619 additions and 1291 deletions

View File

@@ -42,6 +42,7 @@
#define GAME_TYPE_RANDOM2 3
class MTGAllCards;
class TransitionBase;
class GameApp: public JApp
{
@@ -57,7 +58,6 @@ class GameApp: public JApp
GameState* mCurrentState;
GameState* mNextState;
GameState* mGameStates[GAME_STATE_MAX];
public:
@@ -74,15 +74,18 @@ class GameApp: public JApp
virtual void Render();
virtual void Pause();
virtual void Resume();
void LoadGameStates();
void SetNextState(int state);
void DoTransition(int trans, int tostate, float dur=-1, bool animonly = false);
void DoAnimation(int trans, float dur=-1);
static hgeParticleSystem * Particles[6];
static int HasMusic;
static string systemError;
static JMusic* music;
static MTGAllCards * collection;
static int players[2];
static int players[2];
};

View File

@@ -11,15 +11,23 @@ using namespace std;
enum ENUM_GAME_STATE
{
GAME_STATE_NONE = -1,
GAME_STATE_MENU = 1,
GAME_STATE_DUEL = 2,
GAME_STATE_DECK_VIEWER = 3,
GAME_STATE_SHOP = 4,
GAME_STATE_OPTIONS = 5,
GAME_STATE_AWARDS = 6,
GAME_STATE_MAX = 7,
GAME_STATE_TRANSITION = 7,
GAME_STATE_MAX = 8,
};
enum ENUM_GS_TRANSITION
{
TRANSITION_FADE = 0,
TRANSITION_FADE_IN = 1,
MAX_TRANSITION
};
class GameApp;
class SimpleMenu;

View File

@@ -13,12 +13,12 @@
#define STAGE_SHOP_MENU 3
#define STAGE_SHOP_SHOP 4
#define STAGE_SHOP_TASKS 5
#define STAGE_FADE_IN 6
class GameStateShop: public GameState, public JGuiListener
{
private:
ShopItems * shop;
JTexture * altThumb[8];
JQuad * mBack;
@@ -43,10 +43,6 @@ class GameStateShop: public GameState, public JGuiListener
virtual void Update(float dt);
virtual void Render();
virtual void ButtonPressed(int controllerId, int controlId);
};

View File

@@ -0,0 +1,33 @@
#ifndef _GAME_STATE_TRANSITIONS_H_
#define _GAME_STATE_TRANSITIONS_H_
#include <JGE.h>
#include <JGui.h>
#include "../include/GameState.h"
class TransitionBase: public GameState, public JGuiListener{
public:
TransitionBase(GameApp* parent, GameState* _from, GameState* _to, float duration);
virtual void Start();
virtual void End();
virtual bool Finished() {return (mElapsed >= mDuration);};
virtual void Update(float dt);
virtual void Render() = 0;
virtual void ButtonPressed(int controllerId, int controlId);
float mElapsed;
float mDuration;
GameState* from;
GameState* to;
bool bAnimationOnly; //Does not call start or end on subordinates.
};
class TransitionFade: public TransitionBase {
public:
TransitionFade(GameApp* p, GameState* f, GameState* t, float dur, bool reversed);
virtual void Render();
bool mReversed;
};
#endif

View File

@@ -31,6 +31,7 @@ class ShopItem:public JGuiObject{
float mTargetScale;
hgeDistortionMesh* mesh;
void updateThumb();
public:
int nameCount;
@@ -83,6 +84,7 @@ class ShopItems:public JGuiController,public JGuiListener{
void Add(char * text, JQuad * quad, JQuad * thumb,int _price);
void pricedialog(int id, int mode=1);
virtual void ButtonPressed(int controllerId, int controlId);
bool CheckUserInput(u32 key);
void savePriceList();
void saveAll();
static float _x1[],_y1[],_x2[],_y2[],_x3[],_y3[],_x4[],_y4[];

View File

@@ -1,194 +1,211 @@
#ifndef TASK_H
#define TASK_H
#include <vector>
// Task type constant
#define TASK_BASIC 'B'
#define TASK_WIN_AGAINST 'W'
#define TASK_SLAUGHTER 'S'
#define TASK_DELAY 'D'
#define TASK_IMMORTAL 'I'
#define TASK_MASSIVE_BURIAL 'M'
#define TASK_WISDOM 'O'
#define TASKS_ALL "WSDIMO"
#define ITEM_SEPARATOR "|"
#define COMMON_ATTRIBS_COUNT 7
class Task {
protected:
int reward; // TODO: Complex rewards. Be consistent with other planned modes with rewards.
int opponent;
bool accepted;
char type;
int expiresIn;
string description;
string opponentName;
vector<string> persistentAttribs; // persistentAttributes
void storeCommonAttribs();
int restoreCommonAttribs();
string getOpponentName();
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
virtual int computeReward() = 0;
public:
// variable to store and method to obtain names of AI decks
//!! Todo: This should _really_ be handled elsewhere (dedicated class?)
static vector<string> AIDeckNames;
static void loadAIDeckNames();
static int getAIDeckCount();
static string getAIDeckName(int id);
// End of AI deck buffering code
Task(char _type = ' ');
static Task* createFromStr(string params, bool rand = FALSE);
virtual string toString();
string getDesc();
virtual string createDesc() = 0;
virtual string getShortDesc() = 0;
int getExpiration();
int getReward();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app) = 0;
bool isExpired();
void setExpiration(int _expiresIn);
void passOneDay();
};
class TaskList {
protected:
string fileName;
public:
vector<Task*> tasks;
TaskList(string _fileName = "");
int load(string _fileName = "");
int save(string _fileName = "");
void addTask(string params, bool rand = FALSE);
void addTask(Task *task);
void addRandomTask(int diff = 100);
void removeTask(Task *task);
void passOneDay();
void getDoneTasks(Player * _p1, Player * _p2, GameApp * _app, vector<Task*>* result);
int getTaskCount();
//!!virtual void Update(float dt);
virtual void Render();
//!!virtual void ButtonPressed(int controllerId, int controlId);
~TaskList();
};
class TaskWinAgainst : public Task {
protected:
virtual int computeReward();
public:
TaskWinAgainst(int _opponent = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
};
class TaskSlaughter : public TaskWinAgainst {
protected:
int targetLife;
virtual int computeReward();
public:
TaskSlaughter(int _opponent = 0, int _targetLife = -15);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
class TaskDelay : public TaskWinAgainst {
protected:
int turn;
bool afterTurn;
virtual int computeReward();
public:
TaskDelay(int _opponent = 0, int _turn = 20);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
class TaskImmortal : public Task {
protected:
int targetLife;
int level;
virtual int computeReward();
public:
TaskImmortal(int _targetLife = 20);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
class TaskMassiveBurial : public Task {
protected:
int color;
int bodyCount;
virtual int computeReward();
public:
TaskMassiveBurial(int _color = 0, int _bodyCount = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
class TaskWisdom : public Task {
protected:
int color;
int cardCount;
virtual int computeReward();
public:
TaskWisdom(int _color = 0, int _cardCount = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
/* ------------ Task template ------------
class TaskXX : public Task {
protected:
virtual int computeReward();
public:
TaskXX();
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
*/
#endif
#ifndef TASK_H
#define TASK_H
#include <vector>
// Task type constant
#define TASK_BASIC 'B'
#define TASK_WIN_AGAINST 'W'
#define TASK_SLAUGHTER 'S'
#define TASK_DELAY 'D'
#define TASK_IMMORTAL 'I'
#define TASK_MASSIVE_BURIAL 'M'
#define TASK_WISDOM 'O'
#define TASKS_ALL "WSDIMO"
#define ITEM_SEPARATOR "|"
#define COMMON_ATTRIBS_COUNT 7
class Task {
protected:
int reward; // TODO: Complex rewards. Be consistent with other planned modes with rewards.
int opponent;
bool accepted;
char type;
int expiresIn;
string description;
string opponentName;
vector<string> persistentAttribs; // persistentAttributes
void storeCommonAttribs();
int restoreCommonAttribs();
string getOpponentName();
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
virtual int computeReward() = 0;
public:
// variable to store and method to obtain names of AI decks
//!! Todo: This should _really_ be handled elsewhere (dedicated class?)
static vector<string> AIDeckNames;
static void loadAIDeckNames();
static int getAIDeckCount();
static string getAIDeckName(int id);
// End of AI deck buffering code
Task(char _type = ' ');
static Task* createFromStr(string params, bool rand = FALSE);
virtual string toString();
string getDesc();
virtual string createDesc() = 0;
virtual string getShortDesc() = 0;
int getExpiration();
int getReward();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app) = 0;
bool isExpired();
void setExpiration(int _expiresIn);
void passOneDay();
};
class TaskList {
protected:
string fileName;
float vPos;
float mElapsed;
int mState;
JQuad * mBg[9];
JTexture * mBgTex;
public:
vector<Task*> tasks;
enum{
TASKS_IN,
TASKS_ACTIVE,
TASKS_OUT,
TASKS_INACTIVE,
};
TaskList(string _fileName = "");
int load(string _fileName = "");
int save(string _fileName = "");
int getState() {return mState;};
void addTask(string params, bool rand = FALSE);
void addTask(Task *task);
void addRandomTask(int diff = 100);
void removeTask(Task *task);
void passOneDay();
void getDoneTasks(Player * _p1, Player * _p2, GameApp * _app, vector<Task*>* result);
int getTaskCount();
void Start();
void End();
void Update(float dt);
void Render();
//!!virtual void ButtonPressed(int controllerId, int controlId);
~TaskList();
};
class TaskWinAgainst : public Task {
protected:
virtual int computeReward();
public:
TaskWinAgainst(int _opponent = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
};
class TaskSlaughter : public TaskWinAgainst {
protected:
int targetLife;
virtual int computeReward();
public:
TaskSlaughter(int _opponent = 0, int _targetLife = -15);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
class TaskDelay : public TaskWinAgainst {
protected:
int turn;
bool afterTurn;
virtual int computeReward();
public:
TaskDelay(int _opponent = 0, int _turn = 20);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
class TaskImmortal : public Task {
protected:
int targetLife;
int level;
virtual int computeReward();
public:
TaskImmortal(int _targetLife = 20);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
class TaskMassiveBurial : public Task {
protected:
int color;
int bodyCount;
virtual int computeReward();
public:
TaskMassiveBurial(int _color = 0, int _bodyCount = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
class TaskWisdom : public Task {
protected:
int color;
int cardCount;
virtual int computeReward();
public:
TaskWisdom(int _color = 0, int _cardCount = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
/* ------------ Task template ------------
class TaskXX : public Task {
protected:
virtual int computeReward();
public:
TaskXX();
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
*/
#endif