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:
@@ -94,6 +94,7 @@ class JGuiController
|
||||
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
virtual bool CheckUserInput(u32 key);
|
||||
|
||||
void Add(JGuiObject* ctrl);
|
||||
void RemoveAt(int i);
|
||||
|
||||
100
JGE/src/JGui.cpp
100
JGE/src/JGui.cpp
@@ -94,13 +94,61 @@ JGuiController::~JGuiController()
|
||||
|
||||
void JGuiController::Render()
|
||||
{
|
||||
|
||||
|
||||
for (int i=0;i<mCount;i++)
|
||||
if (mObjects[i]!=NULL)
|
||||
mObjects[i]->Render();
|
||||
}
|
||||
bool JGuiController::CheckUserInput(u32 key){
|
||||
|
||||
if (key == mActionButton)
|
||||
{
|
||||
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
|
||||
{
|
||||
if (mListener != NULL)
|
||||
mListener->ButtonPressed(mId, mObjects[mCurr]->GetId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ((PSP_CTRL_LEFT == key) || (PSP_CTRL_UP == key)) // || mEngine->GetAnalogY() < 64 || mEngine->GetAnalogX() < 64)
|
||||
{
|
||||
int n = mCurr;
|
||||
n--;
|
||||
if (n<0)
|
||||
{
|
||||
if ((mStyle&JGUI_STYLE_WRAPPING))
|
||||
n = mCount-1;
|
||||
else
|
||||
n = 0;
|
||||
}
|
||||
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_UP))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if ((PSP_CTRL_RIGHT == key) || (PSP_CTRL_DOWN == key)) // || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
|
||||
{
|
||||
int n = mCurr;
|
||||
n++;
|
||||
if (n>mCount-1)
|
||||
{
|
||||
if ((mStyle&JGUI_STYLE_WRAPPING))
|
||||
n = 0;
|
||||
else
|
||||
n = mCount-1;
|
||||
}
|
||||
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void JGuiController::Update(float dt)
|
||||
{
|
||||
for (int i=0;i<mCount;i++)
|
||||
@@ -108,53 +156,7 @@ void JGuiController::Update(float dt)
|
||||
mObjects[i]->Update(dt);
|
||||
|
||||
u32 key = mEngine->ReadButton();
|
||||
if (key == mActionButton)
|
||||
{
|
||||
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
|
||||
{
|
||||
if (mListener != NULL)
|
||||
{
|
||||
mListener->ButtonPressed(mId, mObjects[mCurr]->GetId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((PSP_CTRL_LEFT == key) || (PSP_CTRL_UP == key)) // || mEngine->GetAnalogY() < 64 || mEngine->GetAnalogX() < 64)
|
||||
{
|
||||
int n = mCurr;
|
||||
n--;
|
||||
if (n<0)
|
||||
{
|
||||
if ((mStyle&JGUI_STYLE_WRAPPING))
|
||||
n = mCount-1;
|
||||
else
|
||||
n = 0;
|
||||
}
|
||||
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_UP))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
}
|
||||
else if ((PSP_CTRL_RIGHT == key) || (PSP_CTRL_DOWN == key)) // || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
|
||||
{
|
||||
int n = mCurr;
|
||||
n++;
|
||||
if (n>mCount-1)
|
||||
{
|
||||
if ((mStyle&JGUI_STYLE_WRAPPING))
|
||||
n = 0;
|
||||
else
|
||||
n = mCount-1;
|
||||
}
|
||||
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
}
|
||||
CheckUserInput(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/Token.o objs/Translate.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/Tasks.o
|
||||
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GameStateTransitions.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/Token.o objs/Translate.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/Tasks.o
|
||||
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
||||
|
||||
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
||||
|
||||
BIN
projects/mtg/bin/Res/graphics/Taskboard.png
Normal file
BIN
projects/mtg/bin/Res/graphics/Taskboard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
@@ -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];
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
33
projects/mtg/include/GameStateTransitions.h
Normal file
33
projects/mtg/include/GameStateTransitions.h
Normal 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
|
||||
@@ -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[];
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "../include/WResourceManager.h"
|
||||
#include "../include/GameApp.h"
|
||||
#include "../include/Subtypes.h"
|
||||
#include "../include/GameStateTransitions.h"
|
||||
#include "../include/GameStateDeckViewer.h"
|
||||
#include "../include/GameStateMenu.h"
|
||||
#include "../include/GameStateDuel.h"
|
||||
@@ -20,6 +21,8 @@
|
||||
#include "../include/DeckMetaData.h"
|
||||
#include "../include/Translate.h"
|
||||
|
||||
#define DEFAULT_DURATION .25
|
||||
|
||||
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
||||
MTGAllCards * GameApp::collection = NULL;
|
||||
int GameApp::players[] = {0,0};
|
||||
@@ -180,6 +183,8 @@ void GameApp::Create()
|
||||
mGameStates[GAME_STATE_AWARDS] = NEW GameStateAwards(this);
|
||||
mGameStates[GAME_STATE_AWARDS]->Create();
|
||||
|
||||
mGameStates[GAME_STATE_TRANSITION] = NULL;
|
||||
|
||||
mCurrentState = NULL;
|
||||
mNextState = mGameStates[GAME_STATE_MENU];
|
||||
|
||||
@@ -263,16 +268,31 @@ void GameApp::Update()
|
||||
if (dt > 35.0f) // min 30 FPS ;)
|
||||
dt = 35.0f;
|
||||
|
||||
if (mCurrentState != NULL)
|
||||
mCurrentState->Update(dt);
|
||||
|
||||
TransitionBase * mTrans = NULL;
|
||||
if (mCurrentState){
|
||||
mCurrentState->Update(dt);
|
||||
if(mGameStates[GAME_STATE_TRANSITION] == mCurrentState)
|
||||
mTrans = (TransitionBase *) mGameStates[GAME_STATE_TRANSITION];
|
||||
}
|
||||
//Check for finished transitions.
|
||||
if(mTrans && mTrans->Finished()){
|
||||
mTrans->End();
|
||||
if(mTrans->to != NULL && !mTrans->bAnimationOnly){
|
||||
mCurrentState = mTrans->to;
|
||||
SAFE_DELETE(mGameStates[GAME_STATE_TRANSITION]);
|
||||
mCurrentState->Start();
|
||||
}
|
||||
else{
|
||||
mCurrentState = mTrans->from;
|
||||
SAFE_DELETE(mGameStates[GAME_STATE_TRANSITION]);
|
||||
}
|
||||
}
|
||||
if (mNextState != NULL)
|
||||
{
|
||||
{
|
||||
if (mCurrentState != NULL)
|
||||
mCurrentState->End();
|
||||
|
||||
mCurrentState = mNextState;
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#else
|
||||
@@ -285,7 +305,6 @@ void GameApp::Update()
|
||||
*/
|
||||
#endif
|
||||
mCurrentState->Start();
|
||||
|
||||
mNextState = NULL;
|
||||
}
|
||||
|
||||
@@ -302,10 +321,9 @@ void GameApp::Render()
|
||||
if (mFont) mFont->DrawString(systemError.c_str(),1,1);
|
||||
return;
|
||||
}
|
||||
if (mCurrentState != NULL)
|
||||
{
|
||||
|
||||
if (mCurrentState)
|
||||
mCurrentState->Render();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CACHE
|
||||
resources.DebugRender();
|
||||
@@ -340,3 +358,40 @@ void GameApp::Resume(){
|
||||
|
||||
}
|
||||
|
||||
void GameApp::DoTransition(int trans, int tostate, float dur, bool animonly){
|
||||
TransitionBase * tb = NULL;
|
||||
GameState * toState = NULL;
|
||||
if(tostate > GAME_STATE_NONE && tostate < GAME_STATE_MAX)
|
||||
toState = mGameStates[tostate];
|
||||
|
||||
if(mGameStates[GAME_STATE_TRANSITION]){
|
||||
tb =(TransitionBase*) mGameStates[GAME_STATE_TRANSITION];
|
||||
if(toState)
|
||||
tb->to = toState; //Additional calls to transition merely update the destination.
|
||||
return;
|
||||
}
|
||||
|
||||
if(dur < 0)
|
||||
dur = DEFAULT_DURATION; // Default to this value.
|
||||
switch(trans){
|
||||
case TRANSITION_FADE_IN:
|
||||
tb = NEW TransitionFade(this,mCurrentState,toState,dur,true);
|
||||
break;
|
||||
case TRANSITION_FADE:
|
||||
default:
|
||||
tb = NEW TransitionFade(this,mCurrentState,toState,dur,false);
|
||||
}
|
||||
if(tb){
|
||||
tb->bAnimationOnly = animonly;
|
||||
mGameStates[GAME_STATE_TRANSITION] = tb;
|
||||
mGameStates[GAME_STATE_TRANSITION]->Start();
|
||||
mCurrentState = tb; //The old current state is ended inside our transition.
|
||||
} else if(toState) { //Somehow failed, just do standard SetNextState behaviour
|
||||
mNextState = toState;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameApp::DoAnimation(int trans, float dur){
|
||||
DoTransition(trans,GAME_STATE_NONE,dur,true);
|
||||
}
|
||||
@@ -37,6 +37,7 @@ void GameStateAwards::End()
|
||||
}
|
||||
void GameStateAwards::Start()
|
||||
{
|
||||
mParent->DoAnimation(TRANSITION_FADE_IN);
|
||||
char buf[256];
|
||||
mState = STATE_LISTVIEW;
|
||||
options.checkProfile();
|
||||
@@ -177,11 +178,11 @@ void GameStateAwards::Update(float dt)
|
||||
menu->Add(3, "Cancel");
|
||||
break;
|
||||
case PSP_CTRL_LTRIGGER:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||
break;
|
||||
case PSP_CTRL_CROSS:
|
||||
if(mState == STATE_LISTVIEW)
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||
else{
|
||||
mState = STATE_LISTVIEW;
|
||||
SAFE_DELETE(detailview);
|
||||
@@ -321,7 +322,7 @@ void GameStateAwards::ButtonPressed(int controllerId, int controlId)
|
||||
if(controllerId == -102)
|
||||
switch (controlId){
|
||||
case 1:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||
showMenu = false;
|
||||
break;
|
||||
case 2:
|
||||
|
||||
@@ -1409,7 +1409,7 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
||||
case 10: //Deck menu
|
||||
if (controlId == -1){
|
||||
if(!mSwitching)
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||
else
|
||||
mStage = STAGE_WAITING;
|
||||
|
||||
@@ -1446,7 +1446,7 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
||||
mSwitching = true;
|
||||
break;
|
||||
case 3:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||
break;
|
||||
case 4:
|
||||
mStage = STAGE_WAITING;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
enum ENUM_DUEL_STATEseems
|
||||
enum ENUM_DUEL_STATE
|
||||
{
|
||||
DUEL_STATE_START,
|
||||
DUEL_STATE_END,
|
||||
@@ -97,11 +97,14 @@ void GameStateDuel::Start()
|
||||
}
|
||||
}
|
||||
|
||||
if(deckmenu){
|
||||
if (decksneeded){
|
||||
deckmenu->Add(-1,_("Create your Deck!").c_str(),"Highly recommended to get\nthe full Wagic experience!");
|
||||
premadeDeck = true;
|
||||
fillDeckMenu(deckmenu,RESPATH"/player/premade");
|
||||
}
|
||||
deckmenu->Add(-1,_("New Deck...").c_str());
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; ++i){
|
||||
mPlayers[i] = NULL;
|
||||
@@ -364,13 +367,16 @@ void GameStateDuel::Update(float dt)
|
||||
mGamePhase = DUEL_STATE_PLAY;
|
||||
break;
|
||||
case DUEL_STATE_BACK_TO_MAIN_MENU:
|
||||
menu->Update(dt);
|
||||
if (menu->closed) {
|
||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||
playerdata->taskList->passOneDay();
|
||||
playerdata->taskList->save();
|
||||
SAFE_DELETE(playerdata);
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
if(menu){
|
||||
menu->Update(dt);
|
||||
if (menu->closed) {
|
||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||
playerdata->taskList->passOneDay();
|
||||
playerdata->taskList->save();
|
||||
SAFE_DELETE(playerdata);
|
||||
SAFE_DELETE(menu);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU,1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -456,7 +462,8 @@ void GameStateDuel::Render()
|
||||
sprintf(buffer,_("Turn:%i").c_str(),game->turn);
|
||||
mFont->DrawString(buffer,SCREEN_WIDTH/2,0,JGETEXT_CENTER);
|
||||
}
|
||||
menu->Render();
|
||||
if(menu)
|
||||
menu->Render();
|
||||
}
|
||||
LOG("End Render\n");
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ enum ENUM_MENU_STATE_MINOR
|
||||
{
|
||||
MENU_STATE_MINOR_NONE = 0,
|
||||
MENU_STATE_MINOR_SUBMENU_CLOSING = 0x100,
|
||||
|
||||
MENU_STATE_MINOR_FADEIN = 0x200,
|
||||
MENU_STATE_MINOR = 0xF00
|
||||
};
|
||||
|
||||
@@ -133,7 +133,7 @@ void GameStateMenu::Start(){
|
||||
JRenderer::GetInstance()->EnableVSync(true);
|
||||
subMenuController = NULL;
|
||||
SAFE_DELETE(mGuiController);
|
||||
|
||||
|
||||
if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0){
|
||||
GameApp::music = resources.ssLoadMusic("Track0.mp3");
|
||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
||||
@@ -153,9 +153,12 @@ void GameStateMenu::Start(){
|
||||
mBg = resources.RetrieveQuad("menutitle.png", 0, 0, 256, 166); // Create background quad for rendering.
|
||||
|
||||
mBg->SetHotSpot(128,50);
|
||||
genNbCardsStr();
|
||||
|
||||
genNbCardsStr();
|
||||
|
||||
if(currentState == MENU_STATE_MAJOR_MAINMENU){
|
||||
currentState = currentState | MENU_STATE_MINOR_FADEIN;
|
||||
}
|
||||
}
|
||||
|
||||
void GameStateMenu::genNbCardsStr(){
|
||||
@@ -431,7 +434,7 @@ void GameStateMenu::Update(float dt)
|
||||
if (mGuiController)
|
||||
mGuiController->Update(dt);
|
||||
if(mEngine->GetButtonState(PSP_CTRL_RTRIGGER)) //Hook for GameStateAward state
|
||||
mParent->SetNextState(GAME_STATE_AWARDS);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_AWARDS); //TODO: A slide transition would be nice.
|
||||
break;
|
||||
case MENU_STATE_MAJOR_SUBMENU :
|
||||
subMenuController->Update(dt);
|
||||
@@ -453,7 +456,7 @@ void GameStateMenu::Update(float dt)
|
||||
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
|
||||
}
|
||||
}else{
|
||||
mParent->SetNextState(GAME_STATE_DUEL);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_DUEL);
|
||||
currentState = MENU_STATE_MAJOR_MAINMENU;
|
||||
}
|
||||
}
|
||||
@@ -499,15 +502,11 @@ void GameStateMenu::Update(float dt)
|
||||
}
|
||||
|
||||
scroller->Update(dt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if((currentState & MENU_STATE_MINOR) == MENU_STATE_MINOR_FADEIN){ currentState = currentState ^ MENU_STATE_MINOR_FADEIN; mParent->DoAnimation(TRANSITION_FADE_IN,.15); }}
|
||||
|
||||
void GameStateMenu::Render()
|
||||
{
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
if((currentState & MENU_STATE_MINOR) == MENU_STATE_MINOR_FADEIN) return; JRenderer * renderer = JRenderer::GetInstance();
|
||||
renderer->ClearScreen(ARGB(0,0,0,0));
|
||||
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
||||
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LANG){
|
||||
@@ -571,7 +570,6 @@ void GameStateMenu::Render()
|
||||
if (subMenuController){
|
||||
subMenuController->Render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -612,25 +610,25 @@ JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
||||
}
|
||||
break;
|
||||
case MENUITEM_DECKEDITOR:
|
||||
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_DECK_VIEWER);
|
||||
break;
|
||||
case MENUITEM_SHOP:
|
||||
mParent->SetNextState(GAME_STATE_SHOP);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_SHOP);
|
||||
break;
|
||||
case MENUITEM_OPTIONS:
|
||||
mParent->SetNextState(GAME_STATE_OPTIONS);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_OPTIONS);
|
||||
break;
|
||||
case MENUITEM_EXIT:
|
||||
mEngine->End();
|
||||
break;
|
||||
case SUBMENUITEM_1PLAYER:
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[1] = PLAYER_TYPE_CPU;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
case SUBMENUITEM_2PLAYER:
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
|
||||
@@ -218,7 +218,7 @@ void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
||||
JSoundSystem::GetInstance()->SetSfxVolume(options[Options::SFXVOLUME].number);
|
||||
JSoundSystem::GetInstance()->SetMusicVolume(options[Options::MUSICVOLUME].number);
|
||||
case 2:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||
break;
|
||||
case 3:
|
||||
mState = SHOW_OPTIONS;
|
||||
|
||||
@@ -26,9 +26,7 @@ void GameStateShop::Create(){
|
||||
void GameStateShop::Start()
|
||||
{
|
||||
menu = NULL;
|
||||
|
||||
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
mStage = STAGE_FADE_IN;
|
||||
|
||||
//alternateRender doesn't lock, so lock our thumbnails for hgeDistort.
|
||||
altThumb[0] = resources.RetrieveTexture("artifact_thumb.jpg", RETRIEVE_LOCK);
|
||||
@@ -53,7 +51,6 @@ void GameStateShop::Start()
|
||||
shop = NULL;
|
||||
taskList = NULL;
|
||||
load();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +135,9 @@ void GameStateShop::Update(float dt)
|
||||
{
|
||||
// mParent->effect->UpdateSmall(dt);
|
||||
// mParent->effect->UpdateBig(dt);
|
||||
if (mStage == STAGE_SHOP_MENU){
|
||||
u32 btn;
|
||||
switch(mStage){
|
||||
case STAGE_SHOP_MENU:
|
||||
if (menu){
|
||||
menu->Update(dt);
|
||||
}else{
|
||||
@@ -147,16 +146,32 @@ void GameStateShop::Update(float dt)
|
||||
menu->Add(14,"See available tasks");
|
||||
menu->Add(13, "Cancel");
|
||||
}
|
||||
}else{
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_START)){
|
||||
mStage = STAGE_SHOP_MENU;
|
||||
}
|
||||
if (mStage == STAGE_SHOP_TASKS){
|
||||
if ( (mEngine->GetButtonClick(PSP_CTRL_CROSS)) ||
|
||||
(mEngine->GetButtonClick(PSP_CTRL_TRIANGLE)) ) {
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
break;
|
||||
case STAGE_SHOP_TASKS:
|
||||
if(menu){
|
||||
menu->Update(dt);
|
||||
return;
|
||||
}
|
||||
if(taskList){
|
||||
btn = mEngine->ReadButton();
|
||||
taskList->Update(dt);
|
||||
if ( taskList->getState() != TaskList::TASKS_INACTIVE){
|
||||
if( btn == PSP_CTRL_CROSS || btn == PSP_CTRL_TRIANGLE ){
|
||||
taskList->End();
|
||||
return;
|
||||
}else if(taskList->getState() == TaskList::TASKS_ACTIVE && btn == PSP_CTRL_START ){
|
||||
if(!menu){
|
||||
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-100,20);
|
||||
menu->Add(12,"Save & Back to Main Menu");
|
||||
menu->Add(15,"Close tasks");
|
||||
menu->Add(13, "Cancel");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
}
|
||||
|
||||
#ifdef TESTSUITE
|
||||
if ((mEngine->GetButtonClick(PSP_CTRL_SQUARE)) && (taskList)) {
|
||||
taskList->passOneDay();
|
||||
@@ -167,15 +182,25 @@ void GameStateShop::Update(float dt)
|
||||
taskList->save();
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_SQUARE)){
|
||||
break;
|
||||
case STAGE_SHOP_SHOP:
|
||||
btn = mEngine->ReadButton();
|
||||
if (btn == PSP_CTRL_START){
|
||||
mStage = STAGE_SHOP_MENU;
|
||||
return;
|
||||
}else if(btn == PSP_CTRL_SQUARE){
|
||||
load();
|
||||
}
|
||||
if (shop)
|
||||
if (shop){
|
||||
shop->CheckUserInput(btn);
|
||||
shop->Update(dt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case STAGE_FADE_IN:
|
||||
mParent->DoAnimation(TRANSITION_FADE_IN);
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -184,43 +209,51 @@ void GameStateShop::Render()
|
||||
//Erase
|
||||
JRenderer * r = JRenderer::GetInstance();
|
||||
r->ClearScreen(ARGB(0,0,0,0));
|
||||
|
||||
if(mStage == STAGE_FADE_IN)
|
||||
return;
|
||||
|
||||
if (mBg) r->RenderQuad(mBg,0,0);
|
||||
|
||||
|
||||
if (shop)
|
||||
shop->Render();
|
||||
|
||||
if (mStage == STAGE_SHOP_TASKS) {
|
||||
if (!taskList) {
|
||||
taskList = NEW TaskList();
|
||||
}
|
||||
if (mStage == STAGE_SHOP_TASKS && taskList) {
|
||||
taskList->Render();
|
||||
}
|
||||
|
||||
if (mStage == STAGE_SHOP_MENU && menu){
|
||||
if (menu){
|
||||
menu->Render();
|
||||
}
|
||||
}
|
||||
|
||||
void GameStateShop::ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
switch (controllerId){
|
||||
case 10:
|
||||
if (shop) shop->pricedialog(controlId);
|
||||
break;
|
||||
case 11:
|
||||
if (controlId == 12){
|
||||
if (shop) shop->saveAll();
|
||||
if (taskList) taskList->save();
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
} else if (controlId == 14){
|
||||
mStage = STAGE_SHOP_TASKS;
|
||||
} else {
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
}
|
||||
break;
|
||||
if (controllerId == 10){
|
||||
if (shop)
|
||||
shop->pricedialog(controlId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else{
|
||||
switch(controlId){
|
||||
case 12:
|
||||
if (shop) shop->saveAll();
|
||||
if (taskList) taskList->save();
|
||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
break;
|
||||
case 14:
|
||||
mStage = STAGE_SHOP_TASKS;
|
||||
if (!taskList)
|
||||
taskList = NEW TaskList();
|
||||
taskList->Start();
|
||||
break;
|
||||
case 15:
|
||||
if(taskList)
|
||||
taskList->End();
|
||||
break;
|
||||
default:
|
||||
mStage = STAGE_SHOP_SHOP;
|
||||
}
|
||||
SAFE_DELETE(menu);
|
||||
}
|
||||
}
|
||||
56
projects/mtg/src/GameStateTransitions.cpp
Normal file
56
projects/mtg/src/GameStateTransitions.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "../include/config.h"
|
||||
#include <JRenderer.h>
|
||||
#include <JGui.h>
|
||||
#include "../include/GameApp.h"
|
||||
#include "../include/GameStateTransitions.h"
|
||||
#include "../include/MTGDeck.h"
|
||||
#include "../include/Translate.h"
|
||||
#include "../include/OptionItem.h"
|
||||
#include "../include/GameOptions.h"
|
||||
#include "../include/DeckDataWrapper.h"
|
||||
|
||||
TransitionBase::TransitionBase(GameApp* parent, GameState* _from, GameState* _to, float duration): GameState(parent){
|
||||
from = _from;
|
||||
to = _to;
|
||||
mDuration = duration;
|
||||
bAnimationOnly = false;
|
||||
}
|
||||
|
||||
void TransitionBase::Update(float dt){
|
||||
if(from && !Finished())
|
||||
from->Update(dt);
|
||||
mElapsed += dt;
|
||||
}
|
||||
|
||||
void TransitionBase::ButtonPressed(int controllerId, int controlId){
|
||||
if(!from) return;
|
||||
JGuiListener * jgl = dynamic_cast<JGuiListener*>(from);
|
||||
if(jgl)
|
||||
jgl->ButtonPressed(controllerId,controlId);
|
||||
}
|
||||
|
||||
void TransitionBase::Start() {
|
||||
mElapsed = 0;
|
||||
};
|
||||
|
||||
void TransitionBase::End() {
|
||||
mElapsed = 0;
|
||||
if(!bAnimationOnly){
|
||||
if(from)
|
||||
from->End();
|
||||
}
|
||||
};
|
||||
|
||||
void TransitionFade::Render(){
|
||||
if(from)
|
||||
from->Render();
|
||||
float fade = 255*mElapsed/mDuration;
|
||||
if(mReversed)
|
||||
fade = 255 - fade;
|
||||
JRenderer::GetInstance()->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB((int)fade,0,0,0));
|
||||
}
|
||||
|
||||
TransitionFade::TransitionFade(GameApp* p, GameState* f, GameState* t, float dur, bool reversed):
|
||||
TransitionBase(p, f,t,dur) {
|
||||
mReversed = reversed;
|
||||
};
|
||||
@@ -71,34 +71,9 @@ ShopItem::ShopItem(int id, JLBFont *font, int _cardid, float _xy[], bool hasFocu
|
||||
if (card->getRarity() == Constants::RARITY_L) quantity = 50;
|
||||
quad = NULL;
|
||||
|
||||
thumb = resources.RetrieveCard(card,RETRIEVE_LOCK,TEXTURE_SUB_THUMB);
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
//On pcs we render the big image if the thumbnail is not available
|
||||
if (!thumb) thumb = resources.RetrieveCard(card,RETRIEVE_LOCK);
|
||||
#endif
|
||||
if (!thumb)
|
||||
thumb = CardGui::alternateThumbQuad(card);
|
||||
else
|
||||
mRelease = true;
|
||||
|
||||
if (thumb){
|
||||
mesh=NEW hgeDistortionMesh(2,2);
|
||||
mesh->SetTexture(thumb->mTex);
|
||||
float x0,y0,w0,h0;
|
||||
thumb->GetTextureRect(&x0,&y0,&w0,&h0);
|
||||
mesh->SetTextureRect(x0,y0,w0,h0);
|
||||
mesh->Clear(ARGB(0xFF,0xFF,0xFF,0xFF));
|
||||
mesh->SetDisplacement(0, 0, xy[0],xy[1], HGEDISP_NODE);
|
||||
mesh->SetDisplacement(1, 0, xy[2] - w0,xy[3], HGEDISP_NODE);
|
||||
mesh->SetDisplacement(0, 1,xy[4],xy[5]-h0, HGEDISP_NODE);
|
||||
mesh->SetDisplacement(1, 1, xy[6]-w0,xy[7]-h0, HGEDISP_NODE);
|
||||
mesh->SetColor(1,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(1,0,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,0,ARGB(255,200,200,200));
|
||||
}else{
|
||||
mesh = NULL;
|
||||
}
|
||||
mesh = NULL;
|
||||
thumb = NULL;
|
||||
updateThumb();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +94,49 @@ const char * ShopItem::getText(){
|
||||
return mText.c_str();
|
||||
}
|
||||
|
||||
void ShopItem::updateThumb(){
|
||||
if(card == NULL)
|
||||
return;
|
||||
|
||||
if(thumb && mRelease)
|
||||
resources.Release(thumb->mTex);
|
||||
mRelease = false;
|
||||
|
||||
if(mesh)
|
||||
SAFE_DELETE(mesh);
|
||||
else if(thumb)
|
||||
SAFE_DELETE(thumb);
|
||||
|
||||
thumb = resources.RetrieveCard(card,RETRIEVE_LOCK,TEXTURE_SUB_THUMB);
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
//On pcs we render the big image if the thumbnail is not available
|
||||
if (!thumb) thumb = resources.RetrieveCard(card,RETRIEVE_LOCK);
|
||||
#endif
|
||||
if (!thumb)
|
||||
thumb = CardGui::alternateThumbQuad(card);
|
||||
else
|
||||
mRelease = true;
|
||||
|
||||
|
||||
if (thumb){
|
||||
mesh=NEW hgeDistortionMesh(2,2);
|
||||
mesh->SetTexture(thumb->mTex);
|
||||
float x0,y0,w0,h0;
|
||||
thumb->GetTextureRect(&x0,&y0,&w0,&h0);
|
||||
mesh->SetTextureRect(x0,y0,w0,h0);
|
||||
mesh->Clear(ARGB(0xFF,0xFF,0xFF,0xFF));
|
||||
mesh->SetDisplacement(0, 0, xy[0],xy[1], HGEDISP_NODE);
|
||||
mesh->SetDisplacement(1, 0, xy[2] - w0,xy[3], HGEDISP_NODE);
|
||||
mesh->SetDisplacement(0, 1,xy[4],xy[5]-h0, HGEDISP_NODE);
|
||||
mesh->SetDisplacement(1, 1, xy[6]-w0,xy[7]-h0, HGEDISP_NODE);
|
||||
mesh->SetColor(1,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,1,ARGB(255,100,100,100));
|
||||
mesh->SetColor(1,0,ARGB(255,100,100,100));
|
||||
mesh->SetColor(0,0,ARGB(255,200,200,200));
|
||||
}else{
|
||||
mesh = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ShopItem::Render(){
|
||||
if (mHasFocus){
|
||||
@@ -251,9 +269,9 @@ void ShopItems::Add(char * text, JQuad * quad,JQuad * thumb, int price){
|
||||
}
|
||||
|
||||
void ShopItems::Update(float dt){
|
||||
|
||||
if (display){
|
||||
while (u32 key = JGE::GetInstance()->ReadButton()) display->CheckUserInput(key);
|
||||
if (display) display->Update(dt);
|
||||
display->Update(dt);
|
||||
}else{
|
||||
if (showPriceDialog!=-1){
|
||||
ShopItem * item = ((ShopItem *)mObjects[showPriceDialog]);
|
||||
@@ -272,19 +290,6 @@ void ShopItems::Update(float dt){
|
||||
dialog->Update(dt);
|
||||
}
|
||||
}else{
|
||||
u32 buttons[] = {PSP_CTRL_LEFT,PSP_CTRL_DOWN,PSP_CTRL_RIGHT,PSP_CTRL_UP,PSP_CTRL_CIRCLE};
|
||||
for (int i = 0; i < 5; ++i){
|
||||
if (JGE::GetInstance()->GetButtonClick(buttons[i])){
|
||||
showCardList = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(JGE::GetInstance()->GetButtonClick(PSP_CTRL_TRIANGLE)){
|
||||
options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number;
|
||||
}
|
||||
if (JGE::GetInstance()->GetButtonClick(PSP_CTRL_CROSS)){
|
||||
showCardList = !showCardList;
|
||||
}
|
||||
SAFE_DELETE(dialog);
|
||||
JGuiController::Update(dt);
|
||||
}
|
||||
@@ -319,9 +324,7 @@ void ShopItems::Render(){
|
||||
|
||||
if (display) display->Render();
|
||||
|
||||
if (showPriceDialog==-1){
|
||||
|
||||
}else{
|
||||
if (showPriceDialog!=-1){
|
||||
if(dialog){
|
||||
dialog->Render();
|
||||
}
|
||||
@@ -518,3 +521,31 @@ ostream& ShopItem::toString(ostream& out) const
|
||||
<< " ; card : " << card
|
||||
<< " ; price : " << price;
|
||||
}
|
||||
|
||||
bool ShopItems::CheckUserInput(u32 key){
|
||||
if (display && display->CheckUserInput(key))
|
||||
return true;
|
||||
if(showPriceDialog==-1){
|
||||
u32 buttons[] = {PSP_CTRL_LEFT,PSP_CTRL_DOWN,PSP_CTRL_RIGHT,PSP_CTRL_UP,PSP_CTRL_CIRCLE};
|
||||
for (int i = 0; i < 5; ++i){
|
||||
if (key == buttons[i])
|
||||
showCardList = false;
|
||||
}
|
||||
|
||||
if(key == PSP_CTRL_TRIANGLE){
|
||||
options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number;
|
||||
vector<JGuiObject*>::iterator it;
|
||||
for(it=mObjects.begin();it!=mObjects.end();it++){
|
||||
ShopItem * si = dynamic_cast<ShopItem*>(*it);
|
||||
if(si)
|
||||
si->updateThumb();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (key == PSP_CTRL_CROSS){
|
||||
showCardList = !showCardList;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return JGuiController::CheckUserInput(key);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -492,6 +492,10 @@
|
||||
RelativePath=".\src\GameStateShop.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\GameStateTransitions.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\GuiAvatars.cpp"
|
||||
>
|
||||
@@ -849,6 +853,10 @@
|
||||
RelativePath=".\include\GameStateShop.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\GameStateTransitions.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\GuiAvatars.h"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user