J :
* Input fix. * A lot of code cleaning spread across a lot of files.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
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
|
||||
|
||||
@@ -34,7 +34,7 @@ class ActionElement: public JGuiObject{
|
||||
virtual void Render(){};
|
||||
virtual int testDestroy(){return 0;};
|
||||
virtual int destroy(){return 0;};
|
||||
virtual void CheckUserInput(float dt){};
|
||||
virtual bool CheckUserInput(u32 key){return false;};
|
||||
ActionElement(int id);
|
||||
virtual int isReactingToTargetClick(Targetable * card);
|
||||
virtual int reactToTargetClick(Targetable * card);
|
||||
|
||||
@@ -21,14 +21,13 @@ class ActionLayer: public GuiLayer, public JGuiListener{
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
int unstopableRenderInProgress();
|
||||
void CheckUserInput(float dt);
|
||||
bool CheckUserInput(u32 key);
|
||||
ActionLayer(int id, GameObserver* _game):GuiLayer(id, _game){ menuObject = NULL; abilitiesMenu = NULL;};
|
||||
int isWaitingForAnswer();
|
||||
int isReactingToTargetClick(Targetable * card);
|
||||
int reactToTargetClick(Targetable * card);
|
||||
int isReactingToClick(MTGCardInstance * card);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int isModal();
|
||||
void setMenuObject(Targetable * object);
|
||||
void ButtonPressed(int controllerid, int controlid);
|
||||
TargetChooser * getCurrentTargetChooser();
|
||||
|
||||
@@ -104,7 +104,7 @@ class DrawAction: public Interruptible {
|
||||
class ActionStack :public GuiLayer{
|
||||
protected:
|
||||
int interruptDecision[2];
|
||||
int timer;
|
||||
float timer;
|
||||
int currentState;
|
||||
int mode;
|
||||
int checked;
|
||||
@@ -135,7 +135,7 @@ class ActionStack :public GuiLayer{
|
||||
int addDamage(MTGCardInstance * _source, Damageable * target, int _damage);
|
||||
int addAbility(MTGAbility * ability);
|
||||
void Update(float dt);
|
||||
void CheckUserInput(float dt);
|
||||
bool CheckUserInput(u32 key);
|
||||
virtual void Render();
|
||||
ActionStack(int id, GameObserver* _game);
|
||||
int resolve();
|
||||
|
||||
@@ -1228,7 +1228,7 @@ class AAladdinsLamp: public TargetAbility{
|
||||
init = 1;
|
||||
}
|
||||
cd.Update(dt);
|
||||
cd.CheckUserInput(dt);
|
||||
// cd.CheckUserInput(dt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1604,28 +1604,30 @@ class AFarmstead:public ActivatedAbility{
|
||||
class AGlassesOfUrza:public MTGAbility{
|
||||
public:
|
||||
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);
|
||||
}
|
||||
|
||||
void Update(float dt){
|
||||
if(modal){
|
||||
if(isActive){
|
||||
display->Update(dt);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckUserInput(float dt){
|
||||
if (modal){
|
||||
display->CheckUserInput(dt);
|
||||
JGE * mEngine = JGE::GetInstance();
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_CROSS)){
|
||||
modal = 0;
|
||||
bool CheckUserInput(u32 key){
|
||||
if (isActive){
|
||||
if (display->CheckUserInput(key)) return true;
|
||||
if (PSP_CTRL_CROSS == key){
|
||||
isActive = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Render(float dt){
|
||||
if (modal){
|
||||
if (isActive){
|
||||
display->Render();
|
||||
}
|
||||
|
||||
@@ -1642,7 +1644,7 @@ class AGlassesOfUrza:public MTGAbility{
|
||||
int reactToClick(MTGCardInstance * card){
|
||||
if (!isReactingToClick(card)) return 0;
|
||||
source->tapped = 1;
|
||||
modal = 1;
|
||||
isActive = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class CardDisplay:public PlayGuiObjectController{
|
||||
void AddCard(MTGCardInstance * _card);
|
||||
void rotateLeft();
|
||||
void rotateRight();
|
||||
void CheckUserInput(float dt);
|
||||
bool CheckUserInput(u32 key);
|
||||
void Render();
|
||||
void init(MTGGameZone * zone);
|
||||
};
|
||||
|
||||
@@ -31,7 +31,7 @@ class DamageResolverLayer:public PlayGuiObjectController{
|
||||
int isOpponent(DamagerDamaged * a, DamagerDamaged * b);
|
||||
void nextPlayer();
|
||||
virtual void Update(float dt);
|
||||
virtual void CheckUserInput(float dt);
|
||||
virtual bool CheckUserInput(u32 key);
|
||||
virtual void Render();
|
||||
};
|
||||
|
||||
|
||||
@@ -17,14 +17,17 @@
|
||||
#define NO_USER_ACTIVITY_HELP_DELAY 10
|
||||
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
|
||||
|
||||
#define STAGE_WAITING 2
|
||||
#define STAGE_TRANSITION_LEFT 1
|
||||
#define STAGE_TRANSITION_RIGHT 0
|
||||
#define STAGE_TRANSITION_UP 3
|
||||
#define STAGE_TRANSITION_DOWN 4
|
||||
#define STAGE_ONSCREEN_MENU 5
|
||||
#define STAGE_WELCOME 6
|
||||
#define STAGE_MENU 7
|
||||
enum
|
||||
{
|
||||
STAGE_TRANSITION_RIGHT = 0,
|
||||
STAGE_TRANSITION_LEFT = 1,
|
||||
STAGE_WAITING = 2,
|
||||
STAGE_TRANSITION_UP = 3,
|
||||
STAGE_TRANSITION_DOWN = 4,
|
||||
STAGE_ONSCREEN_MENU = 5,
|
||||
STAGE_WELCOME = 6,
|
||||
STAGE_MENU = 7
|
||||
};
|
||||
|
||||
|
||||
#define ALL_COLORS -1
|
||||
@@ -32,7 +35,9 @@
|
||||
#define ROTATE_LEFT 1;
|
||||
#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
|
||||
@@ -72,7 +77,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
|
||||
GameStateDeckViewer(GameApp* parent): GameState(parent) {
|
||||
bgMusic = NULL;
|
||||
scrollSpeed = 10.0;
|
||||
scrollSpeed = HIGH_SPEED;
|
||||
}
|
||||
virtual ~GameStateDeckViewer() {
|
||||
SAFE_DELETE(bgMusic);
|
||||
@@ -289,7 +294,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
case PSP_CTRL_UP :
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_TRANSITION_UP;
|
||||
colorFilter --;
|
||||
colorFilter--;
|
||||
if (colorFilter < -1) colorFilter = MTG_COLOR_LAND;
|
||||
break;
|
||||
case PSP_CTRL_DOWN :
|
||||
@@ -338,13 +343,12 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
mStage = STAGE_MENU;
|
||||
break;
|
||||
case PSP_CTRL_SELECT :
|
||||
printf("%f\n", scrollSpeed);
|
||||
if (scrollSpeed == 10.0)
|
||||
scrollSpeed = 5.0;
|
||||
else if (scrollSpeed == 5.0)
|
||||
scrollSpeed = 1.0;
|
||||
if (scrollSpeed == HIGH_SPEED)
|
||||
scrollSpeed = MED_SPEED;
|
||||
else if (scrollSpeed == MED_SPEED)
|
||||
scrollSpeed = LOW_SPEED;
|
||||
else
|
||||
scrollSpeed = 10.0;
|
||||
scrollSpeed = HIGH_SPEED;
|
||||
break;
|
||||
default : // no keypress
|
||||
if (last_user_activity > NO_USER_ACTIVITY_HELP_DELAY){
|
||||
@@ -790,7 +794,4 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -6,17 +6,19 @@
|
||||
#include "_includeAll.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
|
||||
|
||||
|
||||
#ifdef TESTSUITE
|
||||
class TestSuite;
|
||||
#endif
|
||||
|
||||
@@ -25,11 +25,9 @@ class GuiLayer: public JGuiController{
|
||||
void RenderMessageBackground(float x0, float y0, float width, int height);
|
||||
void RenderMessageBackground(float y0, int height);
|
||||
GuiLayer(int id, GameObserver* _game);
|
||||
virtual int isModal();
|
||||
void setModal(int _modal);
|
||||
virtual ~GuiLayer();
|
||||
virtual void Update(float dt);
|
||||
virtual void CheckUserInput(float dt){};
|
||||
virtual bool CheckUserInput(u32 key){ return false; };
|
||||
virtual int unstopableRenderInProgress(){return 0;};
|
||||
int getIndexOf(JGuiObject * object);
|
||||
JGuiObject * getByIndex (int index);
|
||||
|
||||
@@ -17,7 +17,7 @@ class MTGGamePhase: public ActionElement {
|
||||
MTGGamePhase(int id);
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
void CheckUserInput(float dt);
|
||||
bool CheckUserInput(u32 key);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class MTGGuiHand: public GuiCardsController{
|
||||
public:
|
||||
MTGGuiHand(int id, GameObserver * _game);
|
||||
void Update(float dt);
|
||||
void CheckUserInput(float dt);
|
||||
bool CheckUserInput(u32 key);
|
||||
virtual void Render();
|
||||
void updateCards();
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class MTGGuiPlay: public PlayGuiObjectController {
|
||||
MTGGuiPlay(int id, GameObserver * game);
|
||||
~MTGGuiPlay();
|
||||
void Update(float dt);
|
||||
void CheckUserInput(float dt);
|
||||
bool CheckUserInput(u32 key);
|
||||
virtual void Render();
|
||||
void updateCards();
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ class PlayGuiObjectController : public GuiLayer{
|
||||
static int showBigCards;// 0 hide, 1 show, 2 show text
|
||||
public:
|
||||
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;};
|
||||
virtual void Render(){GuiLayer::Render();};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _SIMPLEMENU_ITEM_H
|
||||
#define _SIMPLEMENU_ITEM_H
|
||||
|
||||
#include <string>
|
||||
#include <JLBFont.h>
|
||||
#include <JGui.h>
|
||||
|
||||
|
||||
@@ -17,22 +17,23 @@ int ActionLayer::unstopableRenderInProgress(){
|
||||
}
|
||||
|
||||
|
||||
void ActionLayer::CheckUserInput(float dt){
|
||||
bool ActionLayer::CheckUserInput(u32 key){
|
||||
if (menuObject){
|
||||
abilitiesMenu->Update(dt);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
for (int i=0;i<mCount;i++){
|
||||
if (mObjects[i]!=NULL){
|
||||
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
||||
currentAction->CheckUserInput(dt);
|
||||
if (currentAction->CheckUserInput(key)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ActionLayer::Update(float dt){
|
||||
if (menuObject){
|
||||
abilitiesMenu->Update(dt);
|
||||
return;
|
||||
}
|
||||
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){
|
||||
menuObject = object;
|
||||
if (abilitiesMenu){
|
||||
|
||||
@@ -475,6 +475,14 @@ void ActionStack::Update(float dt){
|
||||
}else if (mode == ACTIONSTACK_TARGET){
|
||||
GuiLayer::Update(dt);
|
||||
}
|
||||
if (askIfWishesToInterrupt)
|
||||
{
|
||||
if (timer < 0) timer = 3;
|
||||
timer -= dt;
|
||||
if (timer < 0){
|
||||
cancelInterruptOffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (askIfWishesToInterrupt){
|
||||
if (timer < 0) timer = 300;
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_CROSS)){
|
||||
if (PSP_CTRL_CROSS == key){
|
||||
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();
|
||||
}else if (mEngine->GetButtonClick(PSP_CTRL_SQUARE)){
|
||||
return true;
|
||||
}else if ((PSP_CTRL_SQUARE == key)){
|
||||
cancelInterruptOffer(2);
|
||||
}else{
|
||||
timer --;
|
||||
if (timer < 0){
|
||||
cancelInterruptOffer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}else if (game->isInterrupting){
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_CROSS)){
|
||||
if (PSP_CTRL_CROSS == key){
|
||||
endOfInterruption();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else if (mode == ACTIONSTACK_TARGET){
|
||||
if (modal){
|
||||
if (mEngine->GetButtonState(PSP_CTRL_UP)){
|
||||
if (KeyRepeated(PSP_CTRL_UP, dt))
|
||||
{
|
||||
if( mObjects[mCurr]){
|
||||
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();
|
||||
if (PSP_CTRL_UP == key){
|
||||
if( mObjects[mCurr]){
|
||||
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();
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf, "Stack UP TO mCurr = %i\n", mCurr);
|
||||
OutputDebugString(buf);
|
||||
char buf[4096];
|
||||
sprintf(buf, "Stack UP TO mCurr = %i\n", mCurr);
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if (mEngine->GetButtonState(PSP_CTRL_DOWN)){
|
||||
if (KeyRepeated(PSP_CTRL_DOWN, dt))
|
||||
{
|
||||
if( mObjects[mCurr]){
|
||||
int n = getNextIndex(((Interruptible *) mObjects[mCurr]), 0, 0, 1);
|
||||
if (n!= -1 && n != mCurr && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
return true;
|
||||
}else if (PSP_CTRL_DOWN == key){
|
||||
if( mObjects[mCurr]){
|
||||
int n = getNextIndex(((Interruptible *) mObjects[mCurr]), 0, 0, 1);
|
||||
if (n!= -1 && n != mCurr && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf, "Stack DOWN TO mCurr = %i\n", mCurr);
|
||||
OutputDebugString(buf);
|
||||
char buf[4096];
|
||||
sprintf(buf, "Stack DOWN TO mCurr = %i\n", mCurr);
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)){
|
||||
}
|
||||
return true;
|
||||
}else if (PSP_CTRL_CIRCLE == key){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf, "Stack CLIKED mCurr = %i\n", mCurr);
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
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;}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -658,7 +663,7 @@ void ActionStack::Render(){
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (mCount > 1){
|
||||
|
||||
@@ -54,73 +54,68 @@ void CardDisplay::rotateRight(){
|
||||
}
|
||||
|
||||
|
||||
void CardDisplay::CheckUserInput(float dt){
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_CROSS))
|
||||
bool CardDisplay::CheckUserInput(u32 key){
|
||||
if (PSP_CTRL_CROSS == key)
|
||||
{
|
||||
if (listener != NULL)
|
||||
{
|
||||
listener->ButtonPressed(mId, 0);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!mCount)
|
||||
return;
|
||||
return false;
|
||||
|
||||
if (mEngine->GetButtonClick(mActionButton))
|
||||
if (mActionButton == key)
|
||||
{
|
||||
if (mObjects[mCurr] && mObjects[mCurr]->ButtonPressed()){
|
||||
CardGui * cardg = (CardGui *)mObjects[mCurr];
|
||||
if (tc)
|
||||
{
|
||||
tc->toggleTarget(cardg->card);
|
||||
return;
|
||||
return true;
|
||||
}else{
|
||||
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))
|
||||
{
|
||||
int n = mCurr;
|
||||
n--;
|
||||
if (n<start_item){
|
||||
if (n< 0){n = 0;}
|
||||
else{ rotateLeft();}
|
||||
}
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_LEFT)){
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
case PSP_CTRL_LEFT :
|
||||
{
|
||||
int n = mCurr;
|
||||
n--;
|
||||
if (n<start_item){
|
||||
if (n< 0){n = 0;}
|
||||
else{ rotateLeft();}
|
||||
}
|
||||
}
|
||||
else if (mEngine->GetButtonState(PSP_CTRL_RIGHT))
|
||||
{
|
||||
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();
|
||||
}
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_LEFT)){
|
||||
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;
|
||||
}
|
||||
|
||||
else{
|
||||
mLastKey = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -281,9 +281,9 @@ void DamageResolverLayer::nextPlayer(){
|
||||
}
|
||||
|
||||
}
|
||||
void DamageResolverLayer::CheckUserInput(float dt){
|
||||
if (!mCount) return;
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)){
|
||||
bool DamageResolverLayer::CheckUserInput(u32 key){
|
||||
if (!mCount) return false;
|
||||
if (PSP_CTRL_CIRCLE == key){
|
||||
if (mObjects[mCurr] && mObjects[mCurr]->ButtonPressed()){
|
||||
DamagerDamaged * current = (DamagerDamaged *) mObjects[mCurr];
|
||||
if (!currentSource || !isOpponent(current,currentSource)){
|
||||
@@ -311,21 +311,25 @@ void DamageResolverLayer::CheckUserInput(float dt){
|
||||
buttonOk = 0;
|
||||
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()){
|
||||
DamagerDamaged * current = (DamagerDamaged *) mObjects[mCurr];
|
||||
if (current->damageSelecter == currentChoosingPlayer){
|
||||
currentSource = current;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}else if (mEngine->GetButtonClick(PSP_CTRL_SQUARE)){
|
||||
}else if (PSP_CTRL_SQUARE == key){
|
||||
if (canStopDealDamages()){
|
||||
nextPlayer();
|
||||
//switch to next player or end of selection
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
PlayGuiObjectController::CheckUserInput(dt);
|
||||
return PlayGuiObjectController::CheckUserInput(key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DamageResolverLayer::Render(){
|
||||
|
||||
@@ -160,132 +160,132 @@ void GameStateDuel::End()
|
||||
|
||||
void GameStateDuel::Update(float dt)
|
||||
{
|
||||
if (mGamePhase == ERROR_NO_DECK){
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)){
|
||||
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
|
||||
}
|
||||
}else if (mGamePhase == DUEL_CHOOSE_DECK1){
|
||||
if (mParent->players[0] == PLAYER_TYPE_HUMAN){
|
||||
deckmenu->Update(dt);
|
||||
}
|
||||
switch (mGamePhase)
|
||||
{
|
||||
case ERROR_NO_DECK:
|
||||
if (PSP_CTRL_CIRCLE == mEngine->ReadButton())
|
||||
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
|
||||
break;
|
||||
case DUEL_CHOOSE_DECK1:
|
||||
if (mParent->players[0] == PLAYER_TYPE_HUMAN)
|
||||
deckmenu->Update(dt);
|
||||
#ifdef TESTSUITE
|
||||
else if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
|
||||
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()){
|
||||
else if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
|
||||
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;
|
||||
}
|
||||
}else
|
||||
#endif
|
||||
if (mParent->players[0] == PLAYER_TYPE_CPU && mParent->players[1] == PLAYER_TYPE_CPU){
|
||||
End();
|
||||
Start();
|
||||
}
|
||||
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
#endif
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ void GameStateOptions::Update(float dt)
|
||||
|
||||
timer+= dt;
|
||||
if (mState == SHOW_OPTIONS){
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_START)){
|
||||
if (PSP_CTRL_START == mEngine->ReadButton()){
|
||||
mState = SHOW_OPTIONS_MENU;
|
||||
}
|
||||
|
||||
|
||||
@@ -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){
|
||||
for (int i=0; i<mCount; i++){
|
||||
if (mObjects[i] == object)
|
||||
@@ -120,17 +111,25 @@ void GuiLayers::Remove(){
|
||||
|
||||
void GuiLayers::Update(float dt, Player * currentPlayer){
|
||||
int i;
|
||||
int modal = 0;
|
||||
int isAI = currentPlayer->isAI();
|
||||
for (i=0; i<nbitems; i++){
|
||||
objects[i]->hasFocus = 0;
|
||||
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){
|
||||
currentPlayer->Act(dt);
|
||||
}
|
||||
|
||||
@@ -1,61 +1,55 @@
|
||||
#include "GuiMessageBox.h"
|
||||
|
||||
|
||||
void GuiMessageBox::CheckUserInput(){
|
||||
if (mEngine->GetButtonClick(mActionButton))
|
||||
bool GuiMessageBox::CheckUserInput(u32 key){
|
||||
if (mActionButton == key)
|
||||
{
|
||||
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
|
||||
{
|
||||
if (mListener != NULL)
|
||||
{
|
||||
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;
|
||||
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();
|
||||
}
|
||||
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 (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;
|
||||
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();
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
mLastKey = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -42,14 +42,15 @@ void MTGGamePhase::Update(float dt){
|
||||
|
||||
}
|
||||
|
||||
void MTGGamePhase::CheckUserInput(float dt){
|
||||
bool MTGGamePhase::CheckUserInput(u32 key){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
if (activeState == INACTIVE){
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_RTRIGGER) && game->currentActionPlayer == game->currentlyActing())
|
||||
if ((PSP_CTRL_RTRIGGER == key) && game->currentActionPlayer == game->currentlyActing())
|
||||
{
|
||||
activeState = ACTIVE;
|
||||
game->userRequestNextGamePhase();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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){
|
||||
mAnimState +=7 *dt;
|
||||
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()){
|
||||
modal = 0;
|
||||
return false;
|
||||
}else{
|
||||
modal = 1;
|
||||
GuiCardsController::CheckUserInput(dt);
|
||||
GuiCardsController::CheckUserInput(key);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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++){
|
||||
GuiGameZone * zone = (GuiGameZone *)mObjects[i];
|
||||
if (zone->showCards){
|
||||
zone->cd->CheckUserInput(dt);
|
||||
return;
|
||||
return zone->cd->CheckUserInput(key);
|
||||
}
|
||||
}
|
||||
PlayGuiObjectController::CheckUserInput(dt);
|
||||
|
||||
|
||||
return PlayGuiObjectController::CheckUserInput(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ int PlayGuiObjectController::getClosestItem(int direction, float tolerance){
|
||||
}
|
||||
*/
|
||||
void PlayGuiObjectController::Update(float dt){
|
||||
last_user_move +=dt;
|
||||
for (int i=0;i<mCount;i++){
|
||||
if (mObjects[i]!=NULL){
|
||||
mObjects[i]->Update(dt);
|
||||
@@ -176,84 +177,68 @@ void PlayGuiObjectController::Update(float dt){
|
||||
}
|
||||
|
||||
|
||||
void PlayGuiObjectController::CheckUserInput(float dt){
|
||||
last_user_move +=dt;
|
||||
bool PlayGuiObjectController::CheckUserInput(u32 key){
|
||||
if (!mCount)
|
||||
return;
|
||||
return false;
|
||||
if (game != NULL){
|
||||
if (mEngine->GetButtonClick(mActionButton)){
|
||||
if (mActionButton == key){
|
||||
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed()){
|
||||
game->ButtonPressed(mId, (PlayGuiObject *)mObjects[mCurr]);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_CROSS)){
|
||||
if (PSP_CTRL_CROSS == key){
|
||||
game->cancelCurrentAction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (mEngine->GetButtonState(PSP_CTRL_LEFT))
|
||||
last_user_move = 0;
|
||||
switch (key)
|
||||
{
|
||||
|
||||
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))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
}
|
||||
case 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();
|
||||
}
|
||||
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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ void ShopItems::Add(char * text, JQuad * quad,JQuad * thumb, int price){
|
||||
|
||||
void ShopItems::Update(float dt){
|
||||
if (display){
|
||||
display->CheckUserInput(dt);
|
||||
// display->CheckUserInput(dt);
|
||||
if (display) display->Update(dt);
|
||||
}else{
|
||||
if (showPriceDialog!=-1){
|
||||
|
||||
Reference in New Issue
Block a user