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 Render();
|
||||||
virtual void Update(float dt);
|
virtual void Update(float dt);
|
||||||
|
virtual bool CheckUserInput(u32 key);
|
||||||
|
|
||||||
void Add(JGuiObject* ctrl);
|
void Add(JGuiObject* ctrl);
|
||||||
void RemoveAt(int i);
|
void RemoveAt(int i);
|
||||||
|
|||||||
100
JGE/src/JGui.cpp
100
JGE/src/JGui.cpp
@@ -94,13 +94,61 @@ JGuiController::~JGuiController()
|
|||||||
|
|
||||||
void JGuiController::Render()
|
void JGuiController::Render()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
for (int i=0;i<mCount;i++)
|
for (int i=0;i<mCount;i++)
|
||||||
if (mObjects[i]!=NULL)
|
if (mObjects[i]!=NULL)
|
||||||
mObjects[i]->Render();
|
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)
|
void JGuiController::Update(float dt)
|
||||||
{
|
{
|
||||||
for (int i=0;i<mCount;i++)
|
for (int i=0;i<mCount;i++)
|
||||||
@@ -108,53 +156,7 @@ void JGuiController::Update(float dt)
|
|||||||
mObjects[i]->Update(dt);
|
mObjects[i]->Update(dt);
|
||||||
|
|
||||||
u32 key = mEngine->ReadButton();
|
u32 key = mEngine->ReadButton();
|
||||||
if (key == mActionButton)
|
CheckUserInput(key);
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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))
|
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
||||||
|
|
||||||
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
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
|
#define GAME_TYPE_RANDOM2 3
|
||||||
|
|
||||||
class MTGAllCards;
|
class MTGAllCards;
|
||||||
|
class TransitionBase;
|
||||||
|
|
||||||
class GameApp: public JApp
|
class GameApp: public JApp
|
||||||
{
|
{
|
||||||
@@ -57,7 +58,6 @@ class GameApp: public JApp
|
|||||||
GameState* mCurrentState;
|
GameState* mCurrentState;
|
||||||
GameState* mNextState;
|
GameState* mNextState;
|
||||||
GameState* mGameStates[GAME_STATE_MAX];
|
GameState* mGameStates[GAME_STATE_MAX];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
@@ -74,15 +74,18 @@ class GameApp: public JApp
|
|||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual void Pause();
|
virtual void Pause();
|
||||||
virtual void Resume();
|
virtual void Resume();
|
||||||
|
|
||||||
|
|
||||||
void LoadGameStates();
|
void LoadGameStates();
|
||||||
void SetNextState(int state);
|
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 hgeParticleSystem * Particles[6];
|
||||||
static int HasMusic;
|
static int HasMusic;
|
||||||
static string systemError;
|
static string systemError;
|
||||||
static JMusic* music;
|
static JMusic* music;
|
||||||
static MTGAllCards * collection;
|
static MTGAllCards * collection;
|
||||||
static int players[2];
|
static int players[2];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,15 +11,23 @@ using namespace std;
|
|||||||
|
|
||||||
enum ENUM_GAME_STATE
|
enum ENUM_GAME_STATE
|
||||||
{
|
{
|
||||||
|
GAME_STATE_NONE = -1,
|
||||||
GAME_STATE_MENU = 1,
|
GAME_STATE_MENU = 1,
|
||||||
GAME_STATE_DUEL = 2,
|
GAME_STATE_DUEL = 2,
|
||||||
GAME_STATE_DECK_VIEWER = 3,
|
GAME_STATE_DECK_VIEWER = 3,
|
||||||
GAME_STATE_SHOP = 4,
|
GAME_STATE_SHOP = 4,
|
||||||
GAME_STATE_OPTIONS = 5,
|
GAME_STATE_OPTIONS = 5,
|
||||||
GAME_STATE_AWARDS = 6,
|
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 GameApp;
|
||||||
class SimpleMenu;
|
class SimpleMenu;
|
||||||
|
|||||||
@@ -13,12 +13,12 @@
|
|||||||
#define STAGE_SHOP_MENU 3
|
#define STAGE_SHOP_MENU 3
|
||||||
#define STAGE_SHOP_SHOP 4
|
#define STAGE_SHOP_SHOP 4
|
||||||
#define STAGE_SHOP_TASKS 5
|
#define STAGE_SHOP_TASKS 5
|
||||||
|
#define STAGE_FADE_IN 6
|
||||||
|
|
||||||
|
|
||||||
class GameStateShop: public GameState, public JGuiListener
|
class GameStateShop: public GameState, public JGuiListener
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ShopItems * shop;
|
ShopItems * shop;
|
||||||
JTexture * altThumb[8];
|
JTexture * altThumb[8];
|
||||||
JQuad * mBack;
|
JQuad * mBack;
|
||||||
@@ -43,10 +43,6 @@ class GameStateShop: public GameState, public JGuiListener
|
|||||||
virtual void Update(float dt);
|
virtual void Update(float dt);
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual void ButtonPressed(int controllerId, int controlId);
|
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;
|
float mTargetScale;
|
||||||
hgeDistortionMesh* mesh;
|
hgeDistortionMesh* mesh;
|
||||||
|
|
||||||
|
void updateThumb();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int nameCount;
|
int nameCount;
|
||||||
@@ -83,6 +84,7 @@ class ShopItems:public JGuiController,public JGuiListener{
|
|||||||
void Add(char * text, JQuad * quad, JQuad * thumb,int _price);
|
void Add(char * text, JQuad * quad, JQuad * thumb,int _price);
|
||||||
void pricedialog(int id, int mode=1);
|
void pricedialog(int id, int mode=1);
|
||||||
virtual void ButtonPressed(int controllerId, int controlId);
|
virtual void ButtonPressed(int controllerId, int controlId);
|
||||||
|
bool CheckUserInput(u32 key);
|
||||||
void savePriceList();
|
void savePriceList();
|
||||||
void saveAll();
|
void saveAll();
|
||||||
static float _x1[],_y1[],_x2[],_y2[],_x3[],_y3[],_x4[],_y4[];
|
static float _x1[],_y1[],_x2[],_y2[],_x3[],_y3[],_x4[],_y4[];
|
||||||
|
|||||||
@@ -1,194 +1,211 @@
|
|||||||
#ifndef TASK_H
|
#ifndef TASK_H
|
||||||
#define TASK_H
|
#define TASK_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// Task type constant
|
// Task type constant
|
||||||
|
|
||||||
#define TASK_BASIC 'B'
|
#define TASK_BASIC 'B'
|
||||||
|
|
||||||
#define TASK_WIN_AGAINST 'W'
|
#define TASK_WIN_AGAINST 'W'
|
||||||
#define TASK_SLAUGHTER 'S'
|
#define TASK_SLAUGHTER 'S'
|
||||||
#define TASK_DELAY 'D'
|
#define TASK_DELAY 'D'
|
||||||
#define TASK_IMMORTAL 'I'
|
#define TASK_IMMORTAL 'I'
|
||||||
#define TASK_MASSIVE_BURIAL 'M'
|
#define TASK_MASSIVE_BURIAL 'M'
|
||||||
#define TASK_WISDOM 'O'
|
#define TASK_WISDOM 'O'
|
||||||
#define TASKS_ALL "WSDIMO"
|
#define TASKS_ALL "WSDIMO"
|
||||||
|
|
||||||
#define ITEM_SEPARATOR "|"
|
#define ITEM_SEPARATOR "|"
|
||||||
|
|
||||||
#define COMMON_ATTRIBS_COUNT 7
|
#define COMMON_ATTRIBS_COUNT 7
|
||||||
|
|
||||||
class Task {
|
class Task {
|
||||||
protected:
|
protected:
|
||||||
int reward; // TODO: Complex rewards. Be consistent with other planned modes with rewards.
|
int reward; // TODO: Complex rewards. Be consistent with other planned modes with rewards.
|
||||||
int opponent;
|
int opponent;
|
||||||
bool accepted;
|
bool accepted;
|
||||||
char type;
|
char type;
|
||||||
int expiresIn;
|
int expiresIn;
|
||||||
string description;
|
string description;
|
||||||
string opponentName;
|
string opponentName;
|
||||||
vector<string> persistentAttribs; // persistentAttributes
|
vector<string> persistentAttribs; // persistentAttributes
|
||||||
|
|
||||||
void storeCommonAttribs();
|
void storeCommonAttribs();
|
||||||
int restoreCommonAttribs();
|
int restoreCommonAttribs();
|
||||||
string getOpponentName();
|
string getOpponentName();
|
||||||
virtual void storeCustomAttribs();
|
virtual void storeCustomAttribs();
|
||||||
virtual void restoreCustomAttribs();
|
virtual void restoreCustomAttribs();
|
||||||
virtual void randomize();
|
virtual void randomize();
|
||||||
|
|
||||||
virtual int computeReward() = 0;
|
virtual int computeReward() = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// variable to store and method to obtain names of AI decks
|
// variable to store and method to obtain names of AI decks
|
||||||
//!! Todo: This should _really_ be handled elsewhere (dedicated class?)
|
//!! Todo: This should _really_ be handled elsewhere (dedicated class?)
|
||||||
static vector<string> AIDeckNames;
|
static vector<string> AIDeckNames;
|
||||||
static void loadAIDeckNames();
|
static void loadAIDeckNames();
|
||||||
static int getAIDeckCount();
|
static int getAIDeckCount();
|
||||||
static string getAIDeckName(int id);
|
static string getAIDeckName(int id);
|
||||||
// End of AI deck buffering code
|
// End of AI deck buffering code
|
||||||
|
|
||||||
Task(char _type = ' ');
|
Task(char _type = ' ');
|
||||||
|
|
||||||
static Task* createFromStr(string params, bool rand = FALSE);
|
static Task* createFromStr(string params, bool rand = FALSE);
|
||||||
virtual string toString();
|
virtual string toString();
|
||||||
string getDesc();
|
string getDesc();
|
||||||
virtual string createDesc() = 0;
|
virtual string createDesc() = 0;
|
||||||
virtual string getShortDesc() = 0;
|
virtual string getShortDesc() = 0;
|
||||||
int getExpiration();
|
int getExpiration();
|
||||||
int getReward();
|
int getReward();
|
||||||
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app) = 0;
|
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app) = 0;
|
||||||
bool isExpired();
|
bool isExpired();
|
||||||
void setExpiration(int _expiresIn);
|
void setExpiration(int _expiresIn);
|
||||||
void passOneDay();
|
void passOneDay();
|
||||||
};
|
};
|
||||||
|
|
||||||
class TaskList {
|
class TaskList {
|
||||||
protected:
|
protected:
|
||||||
string fileName;
|
string fileName;
|
||||||
|
float vPos;
|
||||||
public:
|
float mElapsed;
|
||||||
vector<Task*> tasks;
|
int mState;
|
||||||
|
JQuad * mBg[9];
|
||||||
TaskList(string _fileName = "");
|
JTexture * mBgTex;
|
||||||
int load(string _fileName = "");
|
|
||||||
int save(string _fileName = "");
|
|
||||||
void addTask(string params, bool rand = FALSE);
|
public:
|
||||||
void addTask(Task *task);
|
vector<Task*> tasks;
|
||||||
void addRandomTask(int diff = 100);
|
|
||||||
void removeTask(Task *task);
|
enum{
|
||||||
void passOneDay();
|
TASKS_IN,
|
||||||
void getDoneTasks(Player * _p1, Player * _p2, GameApp * _app, vector<Task*>* result);
|
TASKS_ACTIVE,
|
||||||
int getTaskCount();
|
TASKS_OUT,
|
||||||
|
TASKS_INACTIVE,
|
||||||
//!!virtual void Update(float dt);
|
};
|
||||||
virtual void Render();
|
|
||||||
//!!virtual void ButtonPressed(int controllerId, int controlId);
|
TaskList(string _fileName = "");
|
||||||
|
int load(string _fileName = "");
|
||||||
~TaskList();
|
int save(string _fileName = "");
|
||||||
};
|
int getState() {return mState;};
|
||||||
|
void addTask(string params, bool rand = FALSE);
|
||||||
class TaskWinAgainst : public Task {
|
void addTask(Task *task);
|
||||||
protected:
|
void addRandomTask(int diff = 100);
|
||||||
virtual int computeReward();
|
void removeTask(Task *task);
|
||||||
public:
|
void passOneDay();
|
||||||
TaskWinAgainst(int _opponent = 0);
|
void getDoneTasks(Player * _p1, Player * _p2, GameApp * _app, vector<Task*>* result);
|
||||||
virtual string createDesc();
|
int getTaskCount();
|
||||||
virtual string getShortDesc();
|
|
||||||
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
void Start();
|
||||||
};
|
void End();
|
||||||
|
|
||||||
class TaskSlaughter : public TaskWinAgainst {
|
void Update(float dt);
|
||||||
protected:
|
void Render();
|
||||||
int targetLife;
|
//!!virtual void ButtonPressed(int controllerId, int controlId);
|
||||||
virtual int computeReward();
|
|
||||||
public:
|
~TaskList();
|
||||||
TaskSlaughter(int _opponent = 0, int _targetLife = -15);
|
};
|
||||||
virtual string createDesc();
|
|
||||||
virtual string getShortDesc();
|
class TaskWinAgainst : public Task {
|
||||||
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
protected:
|
||||||
virtual void storeCustomAttribs();
|
virtual int computeReward();
|
||||||
virtual void restoreCustomAttribs();
|
public:
|
||||||
virtual void randomize();
|
TaskWinAgainst(int _opponent = 0);
|
||||||
};
|
virtual string createDesc();
|
||||||
|
virtual string getShortDesc();
|
||||||
class TaskDelay : public TaskWinAgainst {
|
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
||||||
protected:
|
};
|
||||||
int turn;
|
|
||||||
bool afterTurn;
|
class TaskSlaughter : public TaskWinAgainst {
|
||||||
virtual int computeReward();
|
protected:
|
||||||
public:
|
int targetLife;
|
||||||
TaskDelay(int _opponent = 0, int _turn = 20);
|
virtual int computeReward();
|
||||||
virtual string createDesc();
|
public:
|
||||||
virtual string getShortDesc();
|
TaskSlaughter(int _opponent = 0, int _targetLife = -15);
|
||||||
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
virtual string createDesc();
|
||||||
virtual void storeCustomAttribs();
|
virtual string getShortDesc();
|
||||||
virtual void restoreCustomAttribs();
|
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
||||||
virtual void randomize();
|
virtual void storeCustomAttribs();
|
||||||
};
|
virtual void restoreCustomAttribs();
|
||||||
|
virtual void randomize();
|
||||||
class TaskImmortal : public Task {
|
};
|
||||||
protected:
|
|
||||||
int targetLife;
|
class TaskDelay : public TaskWinAgainst {
|
||||||
int level;
|
protected:
|
||||||
virtual int computeReward();
|
int turn;
|
||||||
public:
|
bool afterTurn;
|
||||||
TaskImmortal(int _targetLife = 20);
|
virtual int computeReward();
|
||||||
|
public:
|
||||||
virtual string createDesc();
|
TaskDelay(int _opponent = 0, int _turn = 20);
|
||||||
virtual string getShortDesc();
|
virtual string createDesc();
|
||||||
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
virtual string getShortDesc();
|
||||||
virtual void storeCustomAttribs();
|
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
||||||
virtual void restoreCustomAttribs();
|
virtual void storeCustomAttribs();
|
||||||
virtual void randomize();
|
virtual void restoreCustomAttribs();
|
||||||
};
|
virtual void randomize();
|
||||||
|
};
|
||||||
class TaskMassiveBurial : public Task {
|
|
||||||
protected:
|
class TaskImmortal : public Task {
|
||||||
int color;
|
protected:
|
||||||
int bodyCount;
|
int targetLife;
|
||||||
virtual int computeReward();
|
int level;
|
||||||
public:
|
virtual int computeReward();
|
||||||
TaskMassiveBurial(int _color = 0, int _bodyCount = 0);
|
public:
|
||||||
|
TaskImmortal(int _targetLife = 20);
|
||||||
virtual string createDesc();
|
|
||||||
virtual string getShortDesc();
|
virtual string createDesc();
|
||||||
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
virtual string getShortDesc();
|
||||||
virtual void storeCustomAttribs();
|
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
||||||
virtual void restoreCustomAttribs();
|
virtual void storeCustomAttribs();
|
||||||
virtual void randomize();
|
virtual void restoreCustomAttribs();
|
||||||
};
|
virtual void randomize();
|
||||||
|
};
|
||||||
class TaskWisdom : public Task {
|
|
||||||
protected:
|
class TaskMassiveBurial : public Task {
|
||||||
int color;
|
protected:
|
||||||
int cardCount;
|
int color;
|
||||||
virtual int computeReward();
|
int bodyCount;
|
||||||
public:
|
virtual int computeReward();
|
||||||
TaskWisdom(int _color = 0, int _cardCount = 0);
|
public:
|
||||||
|
TaskMassiveBurial(int _color = 0, int _bodyCount = 0);
|
||||||
virtual string createDesc();
|
|
||||||
virtual string getShortDesc();
|
virtual string createDesc();
|
||||||
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
virtual string getShortDesc();
|
||||||
virtual void storeCustomAttribs();
|
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
||||||
virtual void restoreCustomAttribs();
|
virtual void storeCustomAttribs();
|
||||||
virtual void randomize();
|
virtual void restoreCustomAttribs();
|
||||||
};
|
virtual void randomize();
|
||||||
/* ------------ Task template ------------
|
};
|
||||||
|
|
||||||
class TaskXX : public Task {
|
class TaskWisdom : public Task {
|
||||||
protected:
|
protected:
|
||||||
virtual int computeReward();
|
int color;
|
||||||
public:
|
int cardCount;
|
||||||
TaskXX();
|
virtual int computeReward();
|
||||||
|
public:
|
||||||
virtual string createDesc();
|
TaskWisdom(int _color = 0, int _cardCount = 0);
|
||||||
virtual string getShortDesc();
|
|
||||||
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
virtual string createDesc();
|
||||||
virtual void storeCustomAttribs();
|
virtual string getShortDesc();
|
||||||
virtual void restoreCustomAttribs();
|
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
||||||
virtual void randomize();
|
virtual void storeCustomAttribs();
|
||||||
};
|
virtual void restoreCustomAttribs();
|
||||||
*/
|
virtual void randomize();
|
||||||
|
};
|
||||||
#endif
|
/* ------------ 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/WResourceManager.h"
|
||||||
#include "../include/GameApp.h"
|
#include "../include/GameApp.h"
|
||||||
#include "../include/Subtypes.h"
|
#include "../include/Subtypes.h"
|
||||||
|
#include "../include/GameStateTransitions.h"
|
||||||
#include "../include/GameStateDeckViewer.h"
|
#include "../include/GameStateDeckViewer.h"
|
||||||
#include "../include/GameStateMenu.h"
|
#include "../include/GameStateMenu.h"
|
||||||
#include "../include/GameStateDuel.h"
|
#include "../include/GameStateDuel.h"
|
||||||
@@ -20,6 +21,8 @@
|
|||||||
#include "../include/DeckMetaData.h"
|
#include "../include/DeckMetaData.h"
|
||||||
#include "../include/Translate.h"
|
#include "../include/Translate.h"
|
||||||
|
|
||||||
|
#define DEFAULT_DURATION .25
|
||||||
|
|
||||||
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
||||||
MTGAllCards * GameApp::collection = NULL;
|
MTGAllCards * GameApp::collection = NULL;
|
||||||
int GameApp::players[] = {0,0};
|
int GameApp::players[] = {0,0};
|
||||||
@@ -180,6 +183,8 @@ void GameApp::Create()
|
|||||||
mGameStates[GAME_STATE_AWARDS] = NEW GameStateAwards(this);
|
mGameStates[GAME_STATE_AWARDS] = NEW GameStateAwards(this);
|
||||||
mGameStates[GAME_STATE_AWARDS]->Create();
|
mGameStates[GAME_STATE_AWARDS]->Create();
|
||||||
|
|
||||||
|
mGameStates[GAME_STATE_TRANSITION] = NULL;
|
||||||
|
|
||||||
mCurrentState = NULL;
|
mCurrentState = NULL;
|
||||||
mNextState = mGameStates[GAME_STATE_MENU];
|
mNextState = mGameStates[GAME_STATE_MENU];
|
||||||
|
|
||||||
@@ -263,16 +268,31 @@ void GameApp::Update()
|
|||||||
if (dt > 35.0f) // min 30 FPS ;)
|
if (dt > 35.0f) // min 30 FPS ;)
|
||||||
dt = 35.0f;
|
dt = 35.0f;
|
||||||
|
|
||||||
if (mCurrentState != NULL)
|
TransitionBase * mTrans = NULL;
|
||||||
mCurrentState->Update(dt);
|
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 (mNextState != NULL)
|
||||||
{
|
{
|
||||||
if (mCurrentState != NULL)
|
if (mCurrentState != NULL)
|
||||||
mCurrentState->End();
|
mCurrentState->End();
|
||||||
|
|
||||||
mCurrentState = mNextState;
|
mCurrentState = mNextState;
|
||||||
|
|
||||||
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
#else
|
#else
|
||||||
@@ -285,7 +305,6 @@ void GameApp::Update()
|
|||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
mCurrentState->Start();
|
mCurrentState->Start();
|
||||||
|
|
||||||
mNextState = NULL;
|
mNextState = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,10 +321,9 @@ void GameApp::Render()
|
|||||||
if (mFont) mFont->DrawString(systemError.c_str(),1,1);
|
if (mFont) mFont->DrawString(systemError.c_str(),1,1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mCurrentState != NULL)
|
|
||||||
{
|
if (mCurrentState)
|
||||||
mCurrentState->Render();
|
mCurrentState->Render();
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_CACHE
|
#ifdef DEBUG_CACHE
|
||||||
resources.DebugRender();
|
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()
|
void GameStateAwards::Start()
|
||||||
{
|
{
|
||||||
|
mParent->DoAnimation(TRANSITION_FADE_IN);
|
||||||
char buf[256];
|
char buf[256];
|
||||||
mState = STATE_LISTVIEW;
|
mState = STATE_LISTVIEW;
|
||||||
options.checkProfile();
|
options.checkProfile();
|
||||||
@@ -177,11 +178,11 @@ void GameStateAwards::Update(float dt)
|
|||||||
menu->Add(3, "Cancel");
|
menu->Add(3, "Cancel");
|
||||||
break;
|
break;
|
||||||
case PSP_CTRL_LTRIGGER:
|
case PSP_CTRL_LTRIGGER:
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||||
break;
|
break;
|
||||||
case PSP_CTRL_CROSS:
|
case PSP_CTRL_CROSS:
|
||||||
if(mState == STATE_LISTVIEW)
|
if(mState == STATE_LISTVIEW)
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||||
else{
|
else{
|
||||||
mState = STATE_LISTVIEW;
|
mState = STATE_LISTVIEW;
|
||||||
SAFE_DELETE(detailview);
|
SAFE_DELETE(detailview);
|
||||||
@@ -321,7 +322,7 @@ void GameStateAwards::ButtonPressed(int controllerId, int controlId)
|
|||||||
if(controllerId == -102)
|
if(controllerId == -102)
|
||||||
switch (controlId){
|
switch (controlId){
|
||||||
case 1:
|
case 1:
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||||
showMenu = false;
|
showMenu = false;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|||||||
@@ -1409,7 +1409,7 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
|||||||
case 10: //Deck menu
|
case 10: //Deck menu
|
||||||
if (controlId == -1){
|
if (controlId == -1){
|
||||||
if(!mSwitching)
|
if(!mSwitching)
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||||
else
|
else
|
||||||
mStage = STAGE_WAITING;
|
mStage = STAGE_WAITING;
|
||||||
|
|
||||||
@@ -1446,7 +1446,7 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
|||||||
mSwitching = true;
|
mSwitching = true;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
mStage = STAGE_WAITING;
|
mStage = STAGE_WAITING;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum ENUM_DUEL_STATEseems
|
enum ENUM_DUEL_STATE
|
||||||
{
|
{
|
||||||
DUEL_STATE_START,
|
DUEL_STATE_START,
|
||||||
DUEL_STATE_END,
|
DUEL_STATE_END,
|
||||||
@@ -97,11 +97,14 @@ void GameStateDuel::Start()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(deckmenu){
|
||||||
if (decksneeded){
|
if (decksneeded){
|
||||||
deckmenu->Add(-1,_("Create your Deck!").c_str(),"Highly recommended to get\nthe full Wagic experience!");
|
deckmenu->Add(-1,_("Create your Deck!").c_str(),"Highly recommended to get\nthe full Wagic experience!");
|
||||||
premadeDeck = true;
|
premadeDeck = true;
|
||||||
fillDeckMenu(deckmenu,RESPATH"/player/premade");
|
fillDeckMenu(deckmenu,RESPATH"/player/premade");
|
||||||
}
|
}
|
||||||
|
deckmenu->Add(-1,_("New Deck...").c_str());
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 2; ++i){
|
for (int i = 0; i < 2; ++i){
|
||||||
mPlayers[i] = NULL;
|
mPlayers[i] = NULL;
|
||||||
@@ -364,13 +367,16 @@ void GameStateDuel::Update(float dt)
|
|||||||
mGamePhase = DUEL_STATE_PLAY;
|
mGamePhase = DUEL_STATE_PLAY;
|
||||||
break;
|
break;
|
||||||
case DUEL_STATE_BACK_TO_MAIN_MENU:
|
case DUEL_STATE_BACK_TO_MAIN_MENU:
|
||||||
menu->Update(dt);
|
if(menu){
|
||||||
if (menu->closed) {
|
menu->Update(dt);
|
||||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
if (menu->closed) {
|
||||||
playerdata->taskList->passOneDay();
|
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||||
playerdata->taskList->save();
|
playerdata->taskList->passOneDay();
|
||||||
SAFE_DELETE(playerdata);
|
playerdata->taskList->save();
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
SAFE_DELETE(playerdata);
|
||||||
|
SAFE_DELETE(menu);
|
||||||
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU,1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -456,7 +462,8 @@ void GameStateDuel::Render()
|
|||||||
sprintf(buffer,_("Turn:%i").c_str(),game->turn);
|
sprintf(buffer,_("Turn:%i").c_str(),game->turn);
|
||||||
mFont->DrawString(buffer,SCREEN_WIDTH/2,0,JGETEXT_CENTER);
|
mFont->DrawString(buffer,SCREEN_WIDTH/2,0,JGETEXT_CENTER);
|
||||||
}
|
}
|
||||||
menu->Render();
|
if(menu)
|
||||||
|
menu->Render();
|
||||||
}
|
}
|
||||||
LOG("End Render\n");
|
LOG("End Render\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ enum ENUM_MENU_STATE_MINOR
|
|||||||
{
|
{
|
||||||
MENU_STATE_MINOR_NONE = 0,
|
MENU_STATE_MINOR_NONE = 0,
|
||||||
MENU_STATE_MINOR_SUBMENU_CLOSING = 0x100,
|
MENU_STATE_MINOR_SUBMENU_CLOSING = 0x100,
|
||||||
|
MENU_STATE_MINOR_FADEIN = 0x200,
|
||||||
MENU_STATE_MINOR = 0xF00
|
MENU_STATE_MINOR = 0xF00
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ void GameStateMenu::Start(){
|
|||||||
JRenderer::GetInstance()->EnableVSync(true);
|
JRenderer::GetInstance()->EnableVSync(true);
|
||||||
subMenuController = NULL;
|
subMenuController = NULL;
|
||||||
SAFE_DELETE(mGuiController);
|
SAFE_DELETE(mGuiController);
|
||||||
|
|
||||||
if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0){
|
if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0){
|
||||||
GameApp::music = resources.ssLoadMusic("Track0.mp3");
|
GameApp::music = resources.ssLoadMusic("Track0.mp3");
|
||||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
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 = resources.RetrieveQuad("menutitle.png", 0, 0, 256, 166); // Create background quad for rendering.
|
||||||
|
|
||||||
mBg->SetHotSpot(128,50);
|
mBg->SetHotSpot(128,50);
|
||||||
|
genNbCardsStr();
|
||||||
|
|
||||||
genNbCardsStr();
|
|
||||||
|
|
||||||
|
if(currentState == MENU_STATE_MAJOR_MAINMENU){
|
||||||
|
currentState = currentState | MENU_STATE_MINOR_FADEIN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateMenu::genNbCardsStr(){
|
void GameStateMenu::genNbCardsStr(){
|
||||||
@@ -431,7 +434,7 @@ void GameStateMenu::Update(float dt)
|
|||||||
if (mGuiController)
|
if (mGuiController)
|
||||||
mGuiController->Update(dt);
|
mGuiController->Update(dt);
|
||||||
if(mEngine->GetButtonState(PSP_CTRL_RTRIGGER)) //Hook for GameStateAward state
|
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;
|
break;
|
||||||
case MENU_STATE_MAJOR_SUBMENU :
|
case MENU_STATE_MAJOR_SUBMENU :
|
||||||
subMenuController->Update(dt);
|
subMenuController->Update(dt);
|
||||||
@@ -453,7 +456,7 @@ void GameStateMenu::Update(float dt)
|
|||||||
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
|
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
mParent->SetNextState(GAME_STATE_DUEL);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_DUEL);
|
||||||
currentState = MENU_STATE_MAJOR_MAINMENU;
|
currentState = MENU_STATE_MAJOR_MAINMENU;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,15 +502,11 @@ void GameStateMenu::Update(float dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
scroller->Update(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()
|
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));
|
renderer->ClearScreen(ARGB(0,0,0,0));
|
||||||
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
||||||
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LANG){
|
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LANG){
|
||||||
@@ -571,7 +570,6 @@ void GameStateMenu::Render()
|
|||||||
if (subMenuController){
|
if (subMenuController){
|
||||||
subMenuController->Render();
|
subMenuController->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -612,25 +610,25 @@ JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENUITEM_DECKEDITOR:
|
case MENUITEM_DECKEDITOR:
|
||||||
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_DECK_VIEWER);
|
||||||
break;
|
break;
|
||||||
case MENUITEM_SHOP:
|
case MENUITEM_SHOP:
|
||||||
mParent->SetNextState(GAME_STATE_SHOP);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_SHOP);
|
||||||
break;
|
break;
|
||||||
case MENUITEM_OPTIONS:
|
case MENUITEM_OPTIONS:
|
||||||
mParent->SetNextState(GAME_STATE_OPTIONS);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_OPTIONS);
|
||||||
break;
|
break;
|
||||||
case MENUITEM_EXIT:
|
case MENUITEM_EXIT:
|
||||||
mEngine->End();
|
mEngine->End();
|
||||||
break;
|
break;
|
||||||
case SUBMENUITEM_1PLAYER:
|
case SUBMENUITEM_1PLAYER:
|
||||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||||
mParent->players[1] = PLAYER_TYPE_CPU;
|
mParent->players[1] = PLAYER_TYPE_CPU;
|
||||||
subMenuController->Close();
|
subMenuController->Close();
|
||||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||||
break;
|
break;
|
||||||
case SUBMENUITEM_2PLAYER:
|
case SUBMENUITEM_2PLAYER:
|
||||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||||
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
||||||
subMenuController->Close();
|
subMenuController->Close();
|
||||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
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()->SetSfxVolume(options[Options::SFXVOLUME].number);
|
||||||
JSoundSystem::GetInstance()->SetMusicVolume(options[Options::MUSICVOLUME].number);
|
JSoundSystem::GetInstance()->SetMusicVolume(options[Options::MUSICVOLUME].number);
|
||||||
case 2:
|
case 2:
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
mState = SHOW_OPTIONS;
|
mState = SHOW_OPTIONS;
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ void GameStateShop::Create(){
|
|||||||
void GameStateShop::Start()
|
void GameStateShop::Start()
|
||||||
{
|
{
|
||||||
menu = NULL;
|
menu = NULL;
|
||||||
|
mStage = STAGE_FADE_IN;
|
||||||
|
|
||||||
mStage = STAGE_SHOP_SHOP;
|
|
||||||
|
|
||||||
//alternateRender doesn't lock, so lock our thumbnails for hgeDistort.
|
//alternateRender doesn't lock, so lock our thumbnails for hgeDistort.
|
||||||
altThumb[0] = resources.RetrieveTexture("artifact_thumb.jpg", RETRIEVE_LOCK);
|
altThumb[0] = resources.RetrieveTexture("artifact_thumb.jpg", RETRIEVE_LOCK);
|
||||||
@@ -53,7 +51,6 @@ void GameStateShop::Start()
|
|||||||
shop = NULL;
|
shop = NULL;
|
||||||
taskList = NULL;
|
taskList = NULL;
|
||||||
load();
|
load();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -138,7 +135,9 @@ void GameStateShop::Update(float dt)
|
|||||||
{
|
{
|
||||||
// mParent->effect->UpdateSmall(dt);
|
// mParent->effect->UpdateSmall(dt);
|
||||||
// mParent->effect->UpdateBig(dt);
|
// mParent->effect->UpdateBig(dt);
|
||||||
if (mStage == STAGE_SHOP_MENU){
|
u32 btn;
|
||||||
|
switch(mStage){
|
||||||
|
case STAGE_SHOP_MENU:
|
||||||
if (menu){
|
if (menu){
|
||||||
menu->Update(dt);
|
menu->Update(dt);
|
||||||
}else{
|
}else{
|
||||||
@@ -147,16 +146,32 @@ void GameStateShop::Update(float dt)
|
|||||||
menu->Add(14,"See available tasks");
|
menu->Add(14,"See available tasks");
|
||||||
menu->Add(13, "Cancel");
|
menu->Add(13, "Cancel");
|
||||||
}
|
}
|
||||||
}else{
|
break;
|
||||||
if (mEngine->GetButtonClick(PSP_CTRL_START)){
|
case STAGE_SHOP_TASKS:
|
||||||
mStage = STAGE_SHOP_MENU;
|
if(menu){
|
||||||
}
|
menu->Update(dt);
|
||||||
if (mStage == STAGE_SHOP_TASKS){
|
|
||||||
if ( (mEngine->GetButtonClick(PSP_CTRL_CROSS)) ||
|
|
||||||
(mEngine->GetButtonClick(PSP_CTRL_TRIANGLE)) ) {
|
|
||||||
mStage = STAGE_SHOP_SHOP;
|
|
||||||
return;
|
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
|
#ifdef TESTSUITE
|
||||||
if ((mEngine->GetButtonClick(PSP_CTRL_SQUARE)) && (taskList)) {
|
if ((mEngine->GetButtonClick(PSP_CTRL_SQUARE)) && (taskList)) {
|
||||||
taskList->passOneDay();
|
taskList->passOneDay();
|
||||||
@@ -167,15 +182,25 @@ void GameStateShop::Update(float dt)
|
|||||||
taskList->save();
|
taskList->save();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
break;
|
||||||
if (mEngine->GetButtonClick(PSP_CTRL_SQUARE)){
|
case STAGE_SHOP_SHOP:
|
||||||
|
btn = mEngine->ReadButton();
|
||||||
|
if (btn == PSP_CTRL_START){
|
||||||
|
mStage = STAGE_SHOP_MENU;
|
||||||
|
return;
|
||||||
|
}else if(btn == PSP_CTRL_SQUARE){
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
if (shop)
|
if (shop){
|
||||||
|
shop->CheckUserInput(btn);
|
||||||
shop->Update(dt);
|
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
|
//Erase
|
||||||
JRenderer * r = JRenderer::GetInstance();
|
JRenderer * r = JRenderer::GetInstance();
|
||||||
r->ClearScreen(ARGB(0,0,0,0));
|
r->ClearScreen(ARGB(0,0,0,0));
|
||||||
|
if(mStage == STAGE_FADE_IN)
|
||||||
|
return;
|
||||||
|
|
||||||
if (mBg) r->RenderQuad(mBg,0,0);
|
if (mBg) r->RenderQuad(mBg,0,0);
|
||||||
|
|
||||||
|
|
||||||
if (shop)
|
if (shop)
|
||||||
shop->Render();
|
shop->Render();
|
||||||
|
|
||||||
if (mStage == STAGE_SHOP_TASKS) {
|
if (mStage == STAGE_SHOP_TASKS && taskList) {
|
||||||
if (!taskList) {
|
|
||||||
taskList = NEW TaskList();
|
|
||||||
}
|
|
||||||
taskList->Render();
|
taskList->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStage == STAGE_SHOP_MENU && menu){
|
if (menu){
|
||||||
menu->Render();
|
menu->Render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateShop::ButtonPressed(int controllerId, int controlId)
|
void GameStateShop::ButtonPressed(int controllerId, int controlId)
|
||||||
{
|
{
|
||||||
switch (controllerId){
|
if (controllerId == 10){
|
||||||
case 10:
|
if (shop)
|
||||||
if (shop) shop->pricedialog(controlId);
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
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;
|
if (card->getRarity() == Constants::RARITY_L) quantity = 50;
|
||||||
quad = NULL;
|
quad = NULL;
|
||||||
|
|
||||||
thumb = resources.RetrieveCard(card,RETRIEVE_LOCK,TEXTURE_SUB_THUMB);
|
mesh = NULL;
|
||||||
#if defined (WIN32) || defined (LINUX)
|
thumb = NULL;
|
||||||
//On pcs we render the big image if the thumbnail is not available
|
updateThumb();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,6 +94,49 @@ const char * ShopItem::getText(){
|
|||||||
return mText.c_str();
|
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(){
|
void ShopItem::Render(){
|
||||||
if (mHasFocus){
|
if (mHasFocus){
|
||||||
@@ -251,9 +269,9 @@ void ShopItems::Add(char * text, JQuad * quad,JQuad * thumb, int price){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ShopItems::Update(float dt){
|
void ShopItems::Update(float dt){
|
||||||
|
|
||||||
if (display){
|
if (display){
|
||||||
while (u32 key = JGE::GetInstance()->ReadButton()) display->CheckUserInput(key);
|
display->Update(dt);
|
||||||
if (display) display->Update(dt);
|
|
||||||
}else{
|
}else{
|
||||||
if (showPriceDialog!=-1){
|
if (showPriceDialog!=-1){
|
||||||
ShopItem * item = ((ShopItem *)mObjects[showPriceDialog]);
|
ShopItem * item = ((ShopItem *)mObjects[showPriceDialog]);
|
||||||
@@ -272,19 +290,6 @@ void ShopItems::Update(float dt){
|
|||||||
dialog->Update(dt);
|
dialog->Update(dt);
|
||||||
}
|
}
|
||||||
}else{
|
}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);
|
SAFE_DELETE(dialog);
|
||||||
JGuiController::Update(dt);
|
JGuiController::Update(dt);
|
||||||
}
|
}
|
||||||
@@ -319,9 +324,7 @@ void ShopItems::Render(){
|
|||||||
|
|
||||||
if (display) display->Render();
|
if (display) display->Render();
|
||||||
|
|
||||||
if (showPriceDialog==-1){
|
if (showPriceDialog!=-1){
|
||||||
|
|
||||||
}else{
|
|
||||||
if(dialog){
|
if(dialog){
|
||||||
dialog->Render();
|
dialog->Render();
|
||||||
}
|
}
|
||||||
@@ -518,3 +521,31 @@ ostream& ShopItem::toString(ostream& out) const
|
|||||||
<< " ; card : " << card
|
<< " ; card : " << card
|
||||||
<< " ; price : " << price;
|
<< " ; 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"
|
RelativePath=".\src\GameStateShop.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\GameStateTransitions.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\GuiAvatars.cpp"
|
RelativePath=".\src\GuiAvatars.cpp"
|
||||||
>
|
>
|
||||||
@@ -849,6 +853,10 @@
|
|||||||
RelativePath=".\include\GameStateShop.h"
|
RelativePath=".\include\GameStateShop.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\GameStateTransitions.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\GuiAvatars.h"
|
RelativePath=".\include\GuiAvatars.h"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user