* Input fix.
* A lot of code cleaning spread across a lot of files.
This commit is contained in:
jean.chalard
2008-11-24 12:11:16 +00:00
parent 3721247bee
commit 3518166189
28 changed files with 405 additions and 438 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
TARGET = template TARGET = template
OBJS = src/ActionElement.o src/ActionLayer.o src/ActionStack.o src/AIPlayer.o src/AIStats.o src/Blocker.o src/CardGui.o src/CardDescriptor.o src/CardDisplay.o src/ConstraintResolver.o src/Counters.o src/Damage.o src/DamagerDamaged.o src/DamageResolverLayer.o src/DeckDataWrapper.o src/DuelLayers.o src/GameApp.o src/GameLauncher.o src/GameObserver.o src/GameOptions.o src/GameStateDuel.o src/GameStateOptions.o src/GameStateShop.o src/GuiCardsController.o src/GuiLayers.o src/Logger.o src/ManaCost.o src/ManaCostHybrid.o src/MenuItem.o src/MTGAbility.o src/MTGCardInstance.o src/MTGCard.o src/MTGDeck.o src/MTGGamePhase.o src/MTGGameZones.o src/MTGGuiHand.o src/MTGGuiPlay.o src/MTGRules.o src/OptionItem.o src/PhaseRing.o src/Player.o src/PlayerData.o src/PlayGuiObjectController.o src/PlayGuiObject.o src/PriceList.o src/ShopItem.o src/SimpleMenu.o src/SimpleMenuItem.o src/Subtypes.o src/TargetChooser.o src/TargetsList.o src/TestSuiteAI.o src/TexturesCache.o src/utils.o OBJS = src/ActionElement.o src/ActionLayer.o src/ActionStack.o src/AIPlayer.o src/AIStats.o src/Blocker.o src/CardGui.o src/CardDescriptor.o src/CardDisplay.o src/ConstraintResolver.o src/Counters.o src/Damage.o src/DamagerDamaged.o src/DamageResolverLayer.o src/DeckDataWrapper.o src/DeckStats.o src/DuelLayers.o src/GameApp.o src/GameLauncher.o src/GameObserver.o src/GameOptions.o src/GameStateDuel.o src/GameStateOptions.o src/GameStateShop.o src/GuiCardsController.o src/GuiLayers.o src/Logger.o src/ManaCost.o src/ManaCostHybrid.o src/MenuItem.o src/MTGAbility.o src/MTGCardInstance.o src/MTGCard.o src/MTGDeck.o src/MTGGamePhase.o src/MTGGameZones.o src/MTGGuiHand.o src/MTGGuiPlay.o src/MTGRules.o src/OptionItem.o src/PhaseRing.o src/Player.o src/PlayerData.o src/PlayGuiObjectController.o src/PlayGuiObject.o src/PriceList.o src/ShopItem.o src/SimpleMenu.o src/SimpleMenuItem.o src/Subtypes.o src/TargetChooser.o src/TargetsList.o src/TestSuiteAI.o src/TexturesCache.o src/utils.o
INCDIR = -I ../../JGE/include -I ../../JGE/src INCDIR = -I ../../JGE/include -I ../../JGE/src
+1 -1
View File
@@ -34,7 +34,7 @@ class ActionElement: public JGuiObject{
virtual void Render(){}; virtual void Render(){};
virtual int testDestroy(){return 0;}; virtual int testDestroy(){return 0;};
virtual int destroy(){return 0;}; virtual int destroy(){return 0;};
virtual void CheckUserInput(float dt){}; virtual bool CheckUserInput(u32 key){return false;};
ActionElement(int id); ActionElement(int id);
virtual int isReactingToTargetClick(Targetable * card); virtual int isReactingToTargetClick(Targetable * card);
virtual int reactToTargetClick(Targetable * card); virtual int reactToTargetClick(Targetable * card);
+1 -2
View File
@@ -21,14 +21,13 @@ class ActionLayer: public GuiLayer, public JGuiListener{
virtual void Render(); virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);
int unstopableRenderInProgress(); int unstopableRenderInProgress();
void CheckUserInput(float dt); bool CheckUserInput(u32 key);
ActionLayer(int id, GameObserver* _game):GuiLayer(id, _game){ menuObject = NULL; abilitiesMenu = NULL;}; ActionLayer(int id, GameObserver* _game):GuiLayer(id, _game){ menuObject = NULL; abilitiesMenu = NULL;};
int isWaitingForAnswer(); int isWaitingForAnswer();
int isReactingToTargetClick(Targetable * card); int isReactingToTargetClick(Targetable * card);
int reactToTargetClick(Targetable * card); int reactToTargetClick(Targetable * card);
int isReactingToClick(MTGCardInstance * card); int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
int isModal();
void setMenuObject(Targetable * object); void setMenuObject(Targetable * object);
void ButtonPressed(int controllerid, int controlid); void ButtonPressed(int controllerid, int controlid);
TargetChooser * getCurrentTargetChooser(); TargetChooser * getCurrentTargetChooser();
+2 -2
View File
@@ -104,7 +104,7 @@ class DrawAction: public Interruptible {
class ActionStack :public GuiLayer{ class ActionStack :public GuiLayer{
protected: protected:
int interruptDecision[2]; int interruptDecision[2];
int timer; float timer;
int currentState; int currentState;
int mode; int mode;
int checked; int checked;
@@ -135,7 +135,7 @@ class ActionStack :public GuiLayer{
int addDamage(MTGCardInstance * _source, Damageable * target, int _damage); int addDamage(MTGCardInstance * _source, Damageable * target, int _damage);
int addAbility(MTGAbility * ability); int addAbility(MTGAbility * ability);
void Update(float dt); void Update(float dt);
void CheckUserInput(float dt); bool CheckUserInput(u32 key);
virtual void Render(); virtual void Render();
ActionStack(int id, GameObserver* _game); ActionStack(int id, GameObserver* _game);
int resolve(); int resolve();
+13 -11
View File
@@ -1228,7 +1228,7 @@ class AAladdinsLamp: public TargetAbility{
init = 1; init = 1;
} }
cd.Update(dt); cd.Update(dt);
cd.CheckUserInput(dt); // cd.CheckUserInput(dt);
} }
} }
@@ -1604,28 +1604,30 @@ class AFarmstead:public ActivatedAbility{
class AGlassesOfUrza:public MTGAbility{ class AGlassesOfUrza:public MTGAbility{
public: public:
CardDisplay * display; CardDisplay * display;
AGlassesOfUrza(int _id, MTGCardInstance * _source):MTGAbility(_id, _source){ bool isActive;
AGlassesOfUrza(int _id, MTGCardInstance * _source):MTGAbility(_id, _source),isActive(false){
display = NEW CardDisplay(0, game,SCREEN_WIDTH/2, SCREEN_HEIGHT/2,NULL); display = NEW CardDisplay(0, game,SCREEN_WIDTH/2, SCREEN_HEIGHT/2,NULL);
} }
void Update(float dt){ void Update(float dt){
if(modal){ if(isActive){
display->Update(dt); display->Update(dt);
} }
} }
void CheckUserInput(float dt){ bool CheckUserInput(u32 key){
if (modal){ if (isActive){
display->CheckUserInput(dt); if (display->CheckUserInput(key)) return true;
JGE * mEngine = JGE::GetInstance(); if (PSP_CTRL_CROSS == key){
if (mEngine->GetButtonClick(PSP_CTRL_CROSS)){ isActive = false;
modal = 0; return true;
} }
} }
return false;
} }
void Render(float dt){ void Render(float dt){
if (modal){ if (isActive){
display->Render(); display->Render();
} }
@@ -1642,7 +1644,7 @@ class AGlassesOfUrza:public MTGAbility{
int reactToClick(MTGCardInstance * card){ int reactToClick(MTGCardInstance * card){
if (!isReactingToClick(card)) return 0; if (!isReactingToClick(card)) return 0;
source->tapped = 1; source->tapped = 1;
modal = 1; isActive = true;
return 1; return 1;
} }
+1 -1
View File
@@ -17,7 +17,7 @@ class CardDisplay:public PlayGuiObjectController{
void AddCard(MTGCardInstance * _card); void AddCard(MTGCardInstance * _card);
void rotateLeft(); void rotateLeft();
void rotateRight(); void rotateRight();
void CheckUserInput(float dt); bool CheckUserInput(u32 key);
void Render(); void Render();
void init(MTGGameZone * zone); void init(MTGGameZone * zone);
}; };
+1 -1
View File
@@ -31,7 +31,7 @@ class DamageResolverLayer:public PlayGuiObjectController{
int isOpponent(DamagerDamaged * a, DamagerDamaged * b); int isOpponent(DamagerDamaged * a, DamagerDamaged * b);
void nextPlayer(); void nextPlayer();
virtual void Update(float dt); virtual void Update(float dt);
virtual void CheckUserInput(float dt); virtual bool CheckUserInput(u32 key);
virtual void Render(); virtual void Render();
}; };
+21 -20
View File
@@ -17,14 +17,17 @@
#define NO_USER_ACTIVITY_HELP_DELAY 10 #define NO_USER_ACTIVITY_HELP_DELAY 10
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1 #define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
#define STAGE_WAITING 2 enum
#define STAGE_TRANSITION_LEFT 1 {
#define STAGE_TRANSITION_RIGHT 0 STAGE_TRANSITION_RIGHT = 0,
#define STAGE_TRANSITION_UP 3 STAGE_TRANSITION_LEFT = 1,
#define STAGE_TRANSITION_DOWN 4 STAGE_WAITING = 2,
#define STAGE_ONSCREEN_MENU 5 STAGE_TRANSITION_UP = 3,
#define STAGE_WELCOME 6 STAGE_TRANSITION_DOWN = 4,
#define STAGE_MENU 7 STAGE_ONSCREEN_MENU = 5,
STAGE_WELCOME = 6,
STAGE_MENU = 7
};
#define ALL_COLORS -1 #define ALL_COLORS -1
@@ -32,7 +35,9 @@
#define ROTATE_LEFT 1; #define ROTATE_LEFT 1;
#define ROTATE_RIGHT 0; #define ROTATE_RIGHT 0;
#define HIGH_SPEED 15.0
#define MED_SPEED 5.0
#define LOW_SPEED 1.5
class GameStateDeckViewer: public GameState, public JGuiListener class GameStateDeckViewer: public GameState, public JGuiListener
@@ -72,7 +77,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
GameStateDeckViewer(GameApp* parent): GameState(parent) { GameStateDeckViewer(GameApp* parent): GameState(parent) {
bgMusic = NULL; bgMusic = NULL;
scrollSpeed = 10.0; scrollSpeed = HIGH_SPEED;
} }
virtual ~GameStateDeckViewer() { virtual ~GameStateDeckViewer() {
SAFE_DELETE(bgMusic); SAFE_DELETE(bgMusic);
@@ -289,7 +294,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
case PSP_CTRL_UP : case PSP_CTRL_UP :
last_user_activity = 0; last_user_activity = 0;
mStage = STAGE_TRANSITION_UP; mStage = STAGE_TRANSITION_UP;
colorFilter --; colorFilter--;
if (colorFilter < -1) colorFilter = MTG_COLOR_LAND; if (colorFilter < -1) colorFilter = MTG_COLOR_LAND;
break; break;
case PSP_CTRL_DOWN : case PSP_CTRL_DOWN :
@@ -338,13 +343,12 @@ class GameStateDeckViewer: public GameState, public JGuiListener
mStage = STAGE_MENU; mStage = STAGE_MENU;
break; break;
case PSP_CTRL_SELECT : case PSP_CTRL_SELECT :
printf("%f\n", scrollSpeed); if (scrollSpeed == HIGH_SPEED)
if (scrollSpeed == 10.0) scrollSpeed = MED_SPEED;
scrollSpeed = 5.0; else if (scrollSpeed == MED_SPEED)
else if (scrollSpeed == 5.0) scrollSpeed = LOW_SPEED;
scrollSpeed = 1.0;
else else
scrollSpeed = 10.0; scrollSpeed = HIGH_SPEED;
break; break;
default : // no keypress default : // no keypress
if (last_user_activity > NO_USER_ACTIVITY_HELP_DELAY){ if (last_user_activity > NO_USER_ACTIVITY_HELP_DELAY){
@@ -790,7 +794,4 @@ class GameStateDeckViewer: public GameState, public JGuiListener
}; };
#endif #endif
+10 -8
View File
@@ -6,17 +6,19 @@
#include "_includeAll.h" #include "_includeAll.h"
#include "../include/SimpleMenu.h" #include "../include/SimpleMenu.h"
enum
{
DUEL_START,
DUEL_END,
DUEL_CHOOSE_DECK1,
DUEL_CHOOSE_DECK2,
ERROR_NO_DECK,
DUEL_PLAY,
DUEL_MENU
};
#define DUEL_START 0
#define DUEL_END 1
#define DUEL_CHOOSE_DECK1 2
#define DUEL_CHOOSE_DECK2 3
#define ERROR_NO_DECK 4
#define DUEL_PLAY 5
#define DUEL_MENU 6
#define CHOOSE_OPPONENT 7 #define CHOOSE_OPPONENT 7
#ifdef TESTSUITE #ifdef TESTSUITE
class TestSuite; class TestSuite;
#endif #endif
+1 -3
View File
@@ -25,11 +25,9 @@ class GuiLayer: public JGuiController{
void RenderMessageBackground(float x0, float y0, float width, int height); void RenderMessageBackground(float x0, float y0, float width, int height);
void RenderMessageBackground(float y0, int height); void RenderMessageBackground(float y0, int height);
GuiLayer(int id, GameObserver* _game); GuiLayer(int id, GameObserver* _game);
virtual int isModal();
void setModal(int _modal);
virtual ~GuiLayer(); virtual ~GuiLayer();
virtual void Update(float dt); virtual void Update(float dt);
virtual void CheckUserInput(float dt){}; virtual bool CheckUserInput(u32 key){ return false; };
virtual int unstopableRenderInProgress(){return 0;}; virtual int unstopableRenderInProgress(){return 0;};
int getIndexOf(JGuiObject * object); int getIndexOf(JGuiObject * object);
JGuiObject * getByIndex (int index); JGuiObject * getByIndex (int index);
+1 -1
View File
@@ -17,7 +17,7 @@ class MTGGamePhase: public ActionElement {
MTGGamePhase(int id); MTGGamePhase(int id);
virtual void Render(); virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);
void CheckUserInput(float dt); bool CheckUserInput(u32 key);
}; };
+1 -1
View File
@@ -25,7 +25,7 @@ class MTGGuiHand: public GuiCardsController{
public: public:
MTGGuiHand(int id, GameObserver * _game); MTGGuiHand(int id, GameObserver * _game);
void Update(float dt); void Update(float dt);
void CheckUserInput(float dt); bool CheckUserInput(u32 key);
virtual void Render(); virtual void Render();
void updateCards(); void updateCards();
+1 -1
View File
@@ -47,7 +47,7 @@ class MTGGuiPlay: public PlayGuiObjectController {
MTGGuiPlay(int id, GameObserver * game); MTGGuiPlay(int id, GameObserver * game);
~MTGGuiPlay(); ~MTGGuiPlay();
void Update(float dt); void Update(float dt);
void CheckUserInput(float dt); bool CheckUserInput(u32 key);
virtual void Render(); virtual void Render();
void updateCards(); void updateCards();
}; };
@@ -13,7 +13,7 @@ class PlayGuiObjectController : public GuiLayer{
static int showBigCards;// 0 hide, 1 show, 2 show text static int showBigCards;// 0 hide, 1 show, 2 show text
public: public:
virtual void Update(float dt); virtual void Update(float dt);
virtual void CheckUserInput(float dt); virtual bool CheckUserInput(u32 key);
PlayGuiObjectController(int id, GameObserver* _game):GuiLayer(id, _game){last_user_move=0;}; PlayGuiObjectController(int id, GameObserver* _game):GuiLayer(id, _game){last_user_move=0;};
virtual void Render(){GuiLayer::Render();}; virtual void Render(){GuiLayer::Render();};
}; };
+1
View File
@@ -1,6 +1,7 @@
#ifndef _SIMPLEMENU_ITEM_H #ifndef _SIMPLEMENU_ITEM_H
#define _SIMPLEMENU_ITEM_H #define _SIMPLEMENU_ITEM_H
#include <string>
#include <JLBFont.h> #include <JLBFont.h>
#include <JGui.h> #include <JGui.h>
+5 -15
View File
@@ -17,22 +17,23 @@ int ActionLayer::unstopableRenderInProgress(){
} }
void ActionLayer::CheckUserInput(float dt){ bool ActionLayer::CheckUserInput(u32 key){
if (menuObject){ if (menuObject){
abilitiesMenu->Update(dt); return false;
return;
} }
for (int i=0;i<mCount;i++){ for (int i=0;i<mCount;i++){
if (mObjects[i]!=NULL){ if (mObjects[i]!=NULL){
ActionElement * currentAction = (ActionElement *)mObjects[i]; ActionElement * currentAction = (ActionElement *)mObjects[i];
currentAction->CheckUserInput(dt); if (currentAction->CheckUserInput(key)) return true;
} }
} }
return false;
} }
void ActionLayer::Update(float dt){ void ActionLayer::Update(float dt){
if (menuObject){ if (menuObject){
abilitiesMenu->Update(dt);
return; return;
} }
modal = 0; modal = 0;
@@ -157,17 +158,6 @@ int ActionLayer::reactToClick(MTGCardInstance * card){
} }
int ActionLayer::isModal(){
if (modal) return 1;
if (menuObject) return 1;
for (int i=0; i<mCount; i++){
ActionElement * currentAction = (ActionElement *)mObjects[i];
if (currentAction->modal) return 1;
}
return 0;
}
void ActionLayer::setMenuObject(Targetable * object){ void ActionLayer::setMenuObject(Targetable * object){
menuObject = object; menuObject = object;
if (abilitiesMenu){ if (abilitiesMenu){
+47 -42
View File
@@ -475,6 +475,14 @@ void ActionStack::Update(float dt){
}else if (mode == ACTIONSTACK_TARGET){ }else if (mode == ACTIONSTACK_TARGET){
GuiLayer::Update(dt); GuiLayer::Update(dt);
} }
if (askIfWishesToInterrupt)
{
if (timer < 0) timer = 3;
timer -= dt;
if (timer < 0){
cancelInterruptOffer();
}
}
} }
void ActionStack::cancelInterruptOffer(int cancelMode){ void ActionStack::cancelInterruptOffer(int cancelMode){
@@ -498,76 +506,73 @@ void ActionStack::endOfInterruption(){
} }
void ActionStack::CheckUserInput(float dt){ bool ActionStack::CheckUserInput(u32 key){
if (mode == ACTIONSTACK_STANDARD){ if (mode == ACTIONSTACK_STANDARD){
if (askIfWishesToInterrupt){ if (askIfWishesToInterrupt){
if (timer < 0) timer = 300; if (PSP_CTRL_CROSS == key){
if (mEngine->GetButtonClick(PSP_CTRL_CROSS)){
setIsInterrupting(askIfWishesToInterrupt); setIsInterrupting(askIfWishesToInterrupt);
}else if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE) ||mEngine->GetButtonClick(PSP_CTRL_RTRIGGER) ){ return true;
}else if ((PSP_CTRL_CIRCLE == key) || (PSP_CTRL_RTRIGGER == key) ){
cancelInterruptOffer(); cancelInterruptOffer();
}else if (mEngine->GetButtonClick(PSP_CTRL_SQUARE)){ return true;
}else if ((PSP_CTRL_SQUARE == key)){
cancelInterruptOffer(2); cancelInterruptOffer(2);
}else{ return true;
timer --;
if (timer < 0){
cancelInterruptOffer();
}
} }
}else if (game->isInterrupting){ }else if (game->isInterrupting){
if (mEngine->GetButtonClick(PSP_CTRL_CROSS)){ if (PSP_CTRL_CROSS == key){
endOfInterruption(); endOfInterruption();
return true;
} }
} }
}else if (mode == ACTIONSTACK_TARGET){ }else if (mode == ACTIONSTACK_TARGET){
if (modal){ if (modal){
if (mEngine->GetButtonState(PSP_CTRL_UP)){ if (PSP_CTRL_UP == key){
if (KeyRepeated(PSP_CTRL_UP, dt)) if( mObjects[mCurr]){
{ int n = getPreviousIndex(((Interruptible *) mObjects[mCurr]), 0, 0, 1);
if( mObjects[mCurr]){ if (n != -1 && n != mCurr && mObjects[mCurr]->Leaving(PSP_CTRL_UP))
int n = getPreviousIndex(((Interruptible *) mObjects[mCurr]), 0, 0, 1); {
if (n != -1 && n != mCurr && mObjects[mCurr]->Leaving(PSP_CTRL_UP)) mCurr = n;
{ mObjects[mCurr]->Entering();
mCurr = n;
mObjects[mCurr]->Entering();
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
char buf[4096]; char buf[4096];
sprintf(buf, "Stack UP TO mCurr = %i\n", mCurr); sprintf(buf, "Stack UP TO mCurr = %i\n", mCurr);
OutputDebugString(buf); OutputDebugString(buf);
#endif #endif
}
} }
} }
}else if (mEngine->GetButtonState(PSP_CTRL_DOWN)){ return true;
if (KeyRepeated(PSP_CTRL_DOWN, dt)) }else if (PSP_CTRL_DOWN == key){
{ if( mObjects[mCurr]){
if( mObjects[mCurr]){ int n = getNextIndex(((Interruptible *) mObjects[mCurr]), 0, 0, 1);
int n = getNextIndex(((Interruptible *) mObjects[mCurr]), 0, 0, 1); if (n!= -1 && n != mCurr && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
if (n!= -1 && n != mCurr && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN)) {
{ mCurr = n;
mCurr = n; mObjects[mCurr]->Entering();
mObjects[mCurr]->Entering();
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
char buf[4096]; char buf[4096];
sprintf(buf, "Stack DOWN TO mCurr = %i\n", mCurr); sprintf(buf, "Stack DOWN TO mCurr = %i\n", mCurr);
OutputDebugString(buf); OutputDebugString(buf);
#endif #endif
}
} }
} }
}else if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)){ return true;
}else if (PSP_CTRL_CIRCLE == key){
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
char buf[4096]; char buf[4096];
sprintf(buf, "Stack CLIKED mCurr = %i\n", mCurr); sprintf(buf, "Stack CLIKED mCurr = %i\n", mCurr);
OutputDebugString(buf); OutputDebugString(buf);
#endif #endif
game->stackObjectClicked(((Interruptible *) mObjects[mCurr])); game->stackObjectClicked(((Interruptible *) mObjects[mCurr]));
return true;
} }
} }
if (mEngine->GetButtonClick(PSP_CTRL_TRIANGLE)){ if (PSP_CTRL_TRIANGLE == key){
if (modal) {modal = 0;} else {modal = 1;} if (modal) {modal = 0;} else {modal = 1;}
return true;
} }
} }
return false;
} }
@@ -658,7 +663,7 @@ void ActionStack::Render(){
} }
char buffer[200]; char buffer[200];
sprintf(buffer, "interrupt ? %i", timer/100); sprintf(buffer, "interrupt ? %i", static_cast<int>(timer));
mFont->DrawString(buffer, x0 + 5 , currenty - 40 - ((Interruptible *)mObjects[mCount-1])->mHeight); mFont->DrawString(buffer, x0 + 5 , currenty - 40 - ((Interruptible *)mObjects[mCount-1])->mHeight);
if (mCount > 1){ if (mCount > 1){
+36 -41
View File
@@ -54,73 +54,68 @@ void CardDisplay::rotateRight(){
} }
void CardDisplay::CheckUserInput(float dt){ bool CardDisplay::CheckUserInput(u32 key){
if (mEngine->GetButtonClick(PSP_CTRL_CROSS)) if (PSP_CTRL_CROSS == key)
{ {
if (listener != NULL) if (listener != NULL)
{ {
listener->ButtonPressed(mId, 0); listener->ButtonPressed(mId, 0);
return; return true;
} }
} }
if (!mCount) if (!mCount)
return; return false;
if (mEngine->GetButtonClick(mActionButton)) if (mActionButton == key)
{ {
if (mObjects[mCurr] && mObjects[mCurr]->ButtonPressed()){ if (mObjects[mCurr] && mObjects[mCurr]->ButtonPressed()){
CardGui * cardg = (CardGui *)mObjects[mCurr]; CardGui * cardg = (CardGui *)mObjects[mCurr];
if (tc) if (tc)
{ {
tc->toggleTarget(cardg->card); tc->toggleTarget(cardg->card);
return; return true;
}else{ }else{
if (game) game->ButtonPressed(mId, cardg); if (game) game->ButtonPressed(mId, cardg);
return; return true;
} }
} }
return true;
} }
if (mEngine->GetButtonState(PSP_CTRL_LEFT)) switch(key)
{ {
if (KeyRepeated(PSP_CTRL_LEFT, dt)) case PSP_CTRL_LEFT :
{ {
int n = mCurr; int n = mCurr;
n--; n--;
if (n<start_item){ if (n<start_item){
if (n< 0){n = 0;} if (n< 0){n = 0;}
else{ rotateLeft();} else{ rotateLeft();}
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_LEFT)){
mCurr = n;
mObjects[mCurr]->Entering();
}
} }
} if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_LEFT)){
else if (mEngine->GetButtonState(PSP_CTRL_RIGHT)) mCurr = n;
{ mObjects[mCurr]->Entering();
if (KeyRepeated(PSP_CTRL_RIGHT, dt))
{
int n = mCurr;
n++;
if (n>= mCount){n = mCount-1;}
if (n>= start_item + nb_displayed_items){
rotateRight();
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_RIGHT)){
mCurr = n;
mObjects[mCurr]->Entering();
}
} }
return true;
}
case PSP_CTRL_RIGHT :
{
int n = mCurr;
n++;
if (n>= mCount){n = mCount-1;}
if (n>= start_item + nb_displayed_items){
rotateRight();
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_RIGHT)){
mCurr = n;
mObjects[mCurr]->Entering();
}
}
return true;
} }
return false;
else{
mLastKey = 0;
}
} }
+10 -6
View File
@@ -281,9 +281,9 @@ void DamageResolverLayer::nextPlayer(){
} }
} }
void DamageResolverLayer::CheckUserInput(float dt){ bool DamageResolverLayer::CheckUserInput(u32 key){
if (!mCount) return; if (!mCount) return false;
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)){ if (PSP_CTRL_CIRCLE == key){
if (mObjects[mCurr] && mObjects[mCurr]->ButtonPressed()){ if (mObjects[mCurr] && mObjects[mCurr]->ButtonPressed()){
DamagerDamaged * current = (DamagerDamaged *) mObjects[mCurr]; DamagerDamaged * current = (DamagerDamaged *) mObjects[mCurr];
if (!currentSource || !isOpponent(current,currentSource)){ if (!currentSource || !isOpponent(current,currentSource)){
@@ -311,21 +311,25 @@ void DamageResolverLayer::CheckUserInput(float dt){
buttonOk = 0; buttonOk = 0;
if (canStopDealDamages()) buttonOk = 1; if (canStopDealDamages()) buttonOk = 1;
} }
}else if (mEngine->GetButtonClick(PSP_CTRL_CROSS)){ return true;
}else if (PSP_CTRL_CROSS == key){
if (mObjects[mCurr] && mObjects[mCurr]->ButtonPressed()){ if (mObjects[mCurr] && mObjects[mCurr]->ButtonPressed()){
DamagerDamaged * current = (DamagerDamaged *) mObjects[mCurr]; DamagerDamaged * current = (DamagerDamaged *) mObjects[mCurr];
if (current->damageSelecter == currentChoosingPlayer){ if (current->damageSelecter == currentChoosingPlayer){
currentSource = current; currentSource = current;
} }
return true;
} }
}else if (mEngine->GetButtonClick(PSP_CTRL_SQUARE)){ }else if (PSP_CTRL_SQUARE == key){
if (canStopDealDamages()){ if (canStopDealDamages()){
nextPlayer(); nextPlayer();
//switch to next player or end of selection //switch to next player or end of selection
} }
return true;
}else{ }else{
PlayGuiObjectController::CheckUserInput(dt); return PlayGuiObjectController::CheckUserInput(key);
} }
return false;
} }
void DamageResolverLayer::Render(){ void DamageResolverLayer::Render(){
+117 -124
View File
@@ -160,132 +160,132 @@ void GameStateDuel::End()
void GameStateDuel::Update(float dt) void GameStateDuel::Update(float dt)
{ {
if (mGamePhase == ERROR_NO_DECK){ switch (mGamePhase)
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)){ {
mParent->SetNextState(GAME_STATE_DECK_VIEWER); case ERROR_NO_DECK:
} if (PSP_CTRL_CIRCLE == mEngine->ReadButton())
}else if (mGamePhase == DUEL_CHOOSE_DECK1){ mParent->SetNextState(GAME_STATE_DECK_VIEWER);
if (mParent->players[0] == PLAYER_TYPE_HUMAN){ break;
deckmenu->Update(dt); case DUEL_CHOOSE_DECK1:
} if (mParent->players[0] == PLAYER_TYPE_HUMAN)
deckmenu->Update(dt);
#ifdef TESTSUITE #ifdef TESTSUITE
else if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){ else if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
if (testSuite && testSuite->loadNext()){ if (testSuite && testSuite->loadNext()){
loadTestSuitePlayers();
mGamePhase = DUEL_PLAY;
testSuite->initGame();
char buf[4096];
sprintf(buf, "nb cards in player2's graveyard : %i\n",mPlayers[1]->game->graveyard->nb_cards);
LOG(buf);
}else{
mGamePhase = DUEL_END;
}
}
#endif
else{
loadPlayer(0);
mGamePhase = DUEL_CHOOSE_DECK2;
}
}else if(mGamePhase == DUEL_CHOOSE_DECK2){
if (mParent->players[1] == PLAYER_TYPE_HUMAN){
deckmenu->Update(dt);
}
else{
if (mParent->players[0] == PLAYER_TYPE_HUMAN){
if (!opponentMenu){
opponentMenu = NEW SimpleMenu(13,this,opponentMenuFont,10,10,SCREEN_WIDTH/2,"choose Opponent");
opponentMenu->Add(0,"Random");
nbAIDecks = 0;
int found = 1;
while (found){
found = 0;
char buffer[512];
char aiSmallDeckName[512];
char deckDesc[512];
sprintf(buffer, "Res/ai/baka/deck%i.txt",nbAIDecks+1);
if(fileExists(buffer)){
found = 1;
nbAIDecks++;
sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks);
DeckStats * stats = DeckStats::GetInstance();
stats->load(mPlayers[0]);
int percentVictories = stats->percentVictories(string(aiSmallDeckName));
string difficulty;
if (percentVictories < 34){
difficulty = "(hard)";
}else if (percentVictories < 67){
difficulty = "";
}else{
difficulty = "(easy)";
}
sprintf(deckDesc, "Deck %i %s",nbAIDecks, difficulty.c_str());
opponentMenu->Add(nbAIDecks,deckDesc);
}
}
}
opponentMenu->Update(dt);
}else{
loadPlayer(1);
mGamePhase = DUEL_PLAY;
}
}
}else if (mGamePhase == DUEL_PLAY){
//Stop the music before starting the game
if (GameApp::music){
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
SAFE_DELETE(GameApp::music);
}
if (!game){
GameObserver::Init(mPlayers, 2);
game = GameObserver::GetInstance();
game->startGame();
}
game->Update(dt);
if (game->gameOver){
if (!mPlayers[0]->isAI() && mPlayers[1]->isAI() && mPlayers[0]!= game->gameOver){
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "%p - %p", mPlayers[0], game->gameOver);
OutputDebugString(buf);
#endif
PlayerData * playerdata = NEW PlayerData(mParent->collection);
playerdata->credits+= 500;
playerdata->save();
delete playerdata;
}
mGamePhase = DUEL_END;
#ifdef TESTSUITE
if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
if (testSuite->loadNext()){
loadTestSuitePlayers(); loadTestSuitePlayers();
mGamePhase = DUEL_PLAY; mGamePhase = DUEL_PLAY;
testSuite->initGame(); testSuite->initGame();
char buf[4096];
sprintf(buf, "nb cards in player2's graveyard : %i\n",mPlayers[1]->game->graveyard->nb_cards);
LOG(buf);
}else{ }else{
mGamePhase = DUEL_END; mGamePhase = DUEL_END;
} }
}else
#endif
if (mParent->players[0] == PLAYER_TYPE_CPU && mParent->players[1] == PLAYER_TYPE_CPU){
End();
Start();
} }
#endif
mFont->SetColor(ARGB(255,255,255,255)); else{
loadPlayer(0);
mGamePhase = DUEL_CHOOSE_DECK2;
}
break;
case DUEL_CHOOSE_DECK2:
if (mParent->players[1] == PLAYER_TYPE_HUMAN){
deckmenu->Update(dt);
}
else{
if (mParent->players[0] == PLAYER_TYPE_HUMAN){
if (!opponentMenu){
opponentMenu = NEW SimpleMenu(13,this,opponentMenuFont,10,10,SCREEN_WIDTH/2,"choose Opponent");
opponentMenu->Add(0,"Random");
nbAIDecks = 0;
int found = 1;
while (found){
found = 0;
char buffer[512];
char aiSmallDeckName[512];
char deckDesc[512];
sprintf(buffer, "Res/ai/baka/deck%i.txt",nbAIDecks+1);
if(fileExists(buffer)){
found = 1;
nbAIDecks++;
sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks);
DeckStats * stats = DeckStats::GetInstance();
stats->load(mPlayers[0]);
int percentVictories = stats->percentVictories(string(aiSmallDeckName));
string difficulty;
if (percentVictories < 34){
difficulty = "(hard)";
}else if (percentVictories < 67){
difficulty = "";
}else{
difficulty = "(easy)";
}
sprintf(deckDesc, "Deck %i %s",nbAIDecks, difficulty.c_str());
opponentMenu->Add(nbAIDecks,deckDesc);
}
}
}
opponentMenu->Update(dt);
}else{
loadPlayer(1);
mGamePhase = DUEL_PLAY;
}
}
break;
case DUEL_PLAY:
//Stop the music before starting the game
if (GameApp::music){
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
SAFE_DELETE(GameApp::music);
}
if (!game){
GameObserver::Init(mPlayers, 2);
game = GameObserver::GetInstance();
game->startGame();
}
game->Update(dt);
if (game->gameOver){
if (!mPlayers[0]->isAI() && mPlayers[1]->isAI() && mPlayers[0]!= game->gameOver){
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "%p - %p", mPlayers[0], game->gameOver);
OutputDebugString(buf);
#endif
PlayerData * playerdata = NEW PlayerData(mParent->collection);
playerdata->credits+= 500;
playerdata->save();
delete playerdata;
}
mGamePhase = DUEL_END;
#ifdef TESTSUITE
if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
if (testSuite->loadNext()){
loadTestSuitePlayers();
mGamePhase = DUEL_PLAY;
testSuite->initGame();
}else{
mGamePhase = DUEL_END;
}
}else
#endif
if (mParent->players[0] == PLAYER_TYPE_CPU && mParent->players[1] == PLAYER_TYPE_CPU){
End();
Start();
}
mFont->SetColor(ARGB(255,255,255,255));
}
if (mEngine->GetButtonClick(PSP_CTRL_START)){
mGamePhase = DUEL_MENU;
}
break;
case DUEL_MENU:
menu->Update(dt);
break;
default:
if (PSP_CTRL_CIRCLE == mEngine->ReadButton()){
mParent->SetNextState(GAME_STATE_MENU);
}
} }
if (mEngine->GetButtonClick(PSP_CTRL_START)){
mGamePhase = DUEL_MENU;
}
}else if (mGamePhase == DUEL_MENU){
menu->Update(dt);
}else{
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)){
mParent->SetNextState(GAME_STATE_MENU);
}
}
} }
@@ -377,10 +377,3 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
} }
} }
} }
+1 -1
View File
@@ -47,7 +47,7 @@ void GameStateOptions::Update(float dt)
timer+= dt; timer+= dt;
if (mState == SHOW_OPTIONS){ if (mState == SHOW_OPTIONS){
if (mEngine->GetButtonClick(PSP_CTRL_START)){ if (PSP_CTRL_START == mEngine->ReadButton()){
mState = SHOW_OPTIONS_MENU; mState = SHOW_OPTIONS_MENU;
} }
+15 -16
View File
@@ -62,15 +62,6 @@ void GuiLayer::RenderMessageBackground(float y0, int height){
} }
int GuiLayer::isModal(){
return modal;
}
void GuiLayer::setModal(int _modal){
modal=_modal;
}
int GuiLayer::getIndexOf(JGuiObject * object){ int GuiLayer::getIndexOf(JGuiObject * object){
for (int i=0; i<mCount; i++){ for (int i=0; i<mCount; i++){
if (mObjects[i] == object) if (mObjects[i] == object)
@@ -120,17 +111,25 @@ void GuiLayers::Remove(){
void GuiLayers::Update(float dt, Player * currentPlayer){ void GuiLayers::Update(float dt, Player * currentPlayer){
int i; int i;
int modal = 0;
int isAI = currentPlayer->isAI(); int isAI = currentPlayer->isAI();
for (i=0; i<nbitems; i++){ for (i=0; i<nbitems; i++){
objects[i]->hasFocus = 0;
objects[i]->Update(dt); objects[i]->Update(dt);
if (!isAI && !modal){
objects[i]->hasFocus = 1;
objects[i]->CheckUserInput(dt);
modal = objects[i]->isModal();
}
} }
u32 key;
while ((key = JGE::GetInstance()->ReadButton()))
{
for (i=0; i<nbitems; i++){
if (!isAI){
if (0 != key)
{
objects[i]->hasFocus = 1;
if (objects[i]->CheckUserInput(key))
break;
}
}
}
}
for (++i; i<nbitems; ++i) objects[i]->hasFocus = 0;
if (isAI){ if (isAI){
currentPlayer->Act(dt); currentPlayer->Act(dt);
} }
+34 -40
View File
@@ -1,61 +1,55 @@
#include "GuiMessageBox.h" #include "GuiMessageBox.h"
bool GuiMessageBox::CheckUserInput(u32 key){
void GuiMessageBox::CheckUserInput(){ if (mActionButton == key)
if (mEngine->GetButtonClick(mActionButton))
{ {
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed()) if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
{ {
if (mListener != NULL) if (mListener != NULL)
{ {
mListener->ButtonPressed(mId, mObjects[mCurr]->GetId()); mListener->ButtonPressed(mId, mObjects[mCurr]->GetId());
return; return true;
} }
} }
} }
if (mEngine->GetButtonState(PSP_CTRL_LEFT) || mEngine->GetButtonState(PSP_CTRL_UP) || mEngine->GetAnalogY()<64) if ((PSP_CTRL_LEFT == key) || (PSP_CTRL_UP == key)) // || mEngine->GetAnalogY()<64)
{ {
if (KeyRepeated(PSP_CTRL_UP, dt)) int n = mCurr;
n--;
if (n<0)
{ {
int n = mCurr; if ((mStyle&JGUI_STYLE_WRAPPING))
n--; n = mCount-1;
if (n<0) else
{ 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();
}
} }
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_UP))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
} }
else if (mEngine->GetButtonState(PSP_CTRL_RIGHT) || mEngine->GetButtonState(PSP_CTRL_DOWN) || mEngine->GetAnalogY()>192) else if ((PSP_CTRL_RIGHT == key) || (PSP_CTRL_DOWN == key)) // || mEngine->GetAnalogY()>192)
{ {
if (KeyRepeated(PSP_CTRL_DOWN, dt)) int n = mCurr;
n++;
if (n>mCount-1)
{ {
int n = mCurr; if ((mStyle&JGUI_STYLE_WRAPPING))
n++; n = 0;
if (n>mCount-1) else
{ 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();
}
} }
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
} }
else return false;
mLastKey = 0;
} }
+4 -3
View File
@@ -42,14 +42,15 @@ void MTGGamePhase::Update(float dt){
} }
void MTGGamePhase::CheckUserInput(float dt){ bool MTGGamePhase::CheckUserInput(u32 key){
GameObserver * game = GameObserver::GetInstance(); GameObserver * game = GameObserver::GetInstance();
if (activeState == INACTIVE){ if (activeState == INACTIVE){
if (mEngine->GetButtonClick(PSP_CTRL_RTRIGGER) && game->currentActionPlayer == game->currentlyActing()) if ((PSP_CTRL_RTRIGGER == key) && game->currentActionPlayer == game->currentlyActing())
{ {
activeState = ACTIVE; activeState = ACTIVE;
game->userRequestNextGamePhase(); game->userRequestNextGamePhase();
return true;
} }
} }
return false;
} }
+22 -21
View File
@@ -41,24 +41,6 @@ void MTGGuiHand::Update(float dt){
} }
} }
GuiCardsController::Update(dt);
currentId[game->currentlyActing()->getId()] = mCurr;
}
void MTGGuiHand::CheckUserInput(float dt){
if (mEngine->GetButtonClick(PSP_CTRL_LTRIGGER)) {
if (mShowHand == HAND_HIDE){
mShowHand = HAND_SHOW_ANIMATION;
}
if (mShowHand == HAND_SHOW){
mShowHand = HAND_HIDE_ANIMATION;
}
}else if (mEngine->GetButtonState(PSP_CTRL_LEFT)){
//mGamePhase = NO_USER_INPUT;
}
if (mShowHand == HAND_SHOW_ANIMATION){ if (mShowHand == HAND_SHOW_ANIMATION){
mAnimState +=7 *dt; mAnimState +=7 *dt;
if (mAnimState > 1){ if (mAnimState > 1){
@@ -73,11 +55,30 @@ void MTGGuiHand::CheckUserInput(float dt){
} }
} }
GuiCardsController::Update(dt);
currentId[game->currentlyActing()->getId()] = mCurr;
}
bool MTGGuiHand::CheckUserInput(u32 key){
if (PSP_CTRL_LTRIGGER == key) {
if (mShowHand == HAND_HIDE){
mShowHand = HAND_SHOW_ANIMATION;
}
if (mShowHand == HAND_SHOW){
mShowHand = HAND_HIDE_ANIMATION;
}
return true;
}else if (PSP_CTRL_LEFT == key){
//mGamePhase = NO_USER_INPUT;
}
if (mShowHand == HAND_HIDE || currentPlayer->isAI()){ if (mShowHand == HAND_HIDE || currentPlayer->isAI()){
modal = 0; return false;
}else{ }else{
modal = 1; GuiCardsController::CheckUserInput(key);
GuiCardsController::CheckUserInput(dt); return true;
} }
} }
+3 -6
View File
@@ -259,17 +259,14 @@ void MTGGuiPlay::Update(float dt){
void MTGGuiPlay::CheckUserInput(float dt){ bool MTGGuiPlay::CheckUserInput(u32 key){
for (int i = 2; i<6;i++){ for (int i = 2; i<6;i++){
GuiGameZone * zone = (GuiGameZone *)mObjects[i]; GuiGameZone * zone = (GuiGameZone *)mObjects[i];
if (zone->showCards){ if (zone->showCards){
zone->cd->CheckUserInput(dt); return zone->cd->CheckUserInput(key);
return;
} }
} }
PlayGuiObjectController::CheckUserInput(dt); return PlayGuiObjectController::CheckUserInput(key);
} }
+53 -68
View File
@@ -168,6 +168,7 @@ int PlayGuiObjectController::getClosestItem(int direction, float tolerance){
} }
*/ */
void PlayGuiObjectController::Update(float dt){ void PlayGuiObjectController::Update(float dt){
last_user_move +=dt;
for (int i=0;i<mCount;i++){ for (int i=0;i<mCount;i++){
if (mObjects[i]!=NULL){ if (mObjects[i]!=NULL){
mObjects[i]->Update(dt); mObjects[i]->Update(dt);
@@ -176,84 +177,68 @@ void PlayGuiObjectController::Update(float dt){
} }
void PlayGuiObjectController::CheckUserInput(float dt){ bool PlayGuiObjectController::CheckUserInput(u32 key){
last_user_move +=dt;
if (!mCount) if (!mCount)
return; return false;
if (game != NULL){ if (game != NULL){
if (mEngine->GetButtonClick(mActionButton)){ if (mActionButton == key){
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed()){ if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed()){
game->ButtonPressed(mId, (PlayGuiObject *)mObjects[mCurr]); game->ButtonPressed(mId, (PlayGuiObject *)mObjects[mCurr]);
return; return true;
} }
} }
if (mEngine->GetButtonClick(PSP_CTRL_CROSS)){ if (PSP_CTRL_CROSS == key){
game->cancelCurrentAction(); game->cancelCurrentAction();
return true;
} }
} }
if (mEngine->GetButtonState(PSP_CTRL_LEFT)) last_user_move = 0;
switch (key)
{ {
case PSP_CTRL_LEFT:
last_user_move = 0; {
if (KeyRepeated(PSP_CTRL_LEFT, dt)) int n = getClosestItem(DIR_LEFT);
{ if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_LEFT))
int n = getClosestItem(DIR_LEFT); {
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_LEFT)) mCurr = n;
{ mObjects[mCurr]->Entering();
mCurr = n; }
mObjects[mCurr]->Entering(); return true;
} }
} case PSP_CTRL_RIGHT:
{
int n = getClosestItem(DIR_RIGHT);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_RIGHT))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
case PSP_CTRL_UP:
{
int n = getClosestItem(DIR_UP);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_UP))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
case PSP_CTRL_DOWN:
{
int n = getClosestItem(DIR_DOWN);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
case PSP_CTRL_TRIANGLE:
showBigCards = (showBigCards + 1) % 3;
return true;
} }
else if (mEngine->GetButtonState(PSP_CTRL_RIGHT)) return false;
{
last_user_move = 0;
if (KeyRepeated(PSP_CTRL_RIGHT, dt))
{
int n = getClosestItem(DIR_RIGHT);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_RIGHT))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
}
}
else if (mEngine->GetButtonState(PSP_CTRL_UP))
{
last_user_move = 0;
if (KeyRepeated(PSP_CTRL_UP, dt))
{
int n = getClosestItem(DIR_UP);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_UP))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
}
}
else if (mEngine->GetButtonState(PSP_CTRL_DOWN))
{
last_user_move = 0;
if (KeyRepeated(PSP_CTRL_DOWN, dt))
{
int n = getClosestItem(DIR_DOWN);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
}
}else if (mEngine->GetButtonClick(PSP_CTRL_TRIANGLE)){
showBigCards = (++showBigCards) %3;
}
else{
mLastKey = 0;
}
} }
+1 -1
View File
@@ -153,7 +153,7 @@ 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){
display->CheckUserInput(dt); // display->CheckUserInput(dt);
if (display) display->Update(dt); if (display) display->Update(dt);
}else{ }else{
if (showPriceDialog!=-1){ if (showPriceDialog!=-1){