J :
* Input fix. * A lot of code cleaning spread across a lot of files.
This commit is contained in:
@@ -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(){
|
||||
|
||||
+117
-124
@@ -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