* Fix u32 into JButtons.
* Add a few comments.
* Remove useless variables.
This commit is contained in:
jean.chalard
2010-02-24 17:28:17 +00:00
parent 3ac6bc3ec3
commit 39c5a3d465
38 changed files with 58 additions and 63 deletions

View File

@@ -95,7 +95,6 @@ class JGE
bool mCriticalAssert;
const char *mAssertFile;
int mAssertLine;
u32 tickFrequency;
static JGE* mInstance;

View File

@@ -51,7 +51,7 @@ class JGuiObject
virtual void Update(float dt);
virtual void Entering(); // when focus is transferring to this obj
virtual bool Leaving(u32 key); // when focus is transferring away from this obj, true to go ahead
virtual bool Leaving(JButton key); // when focus is transferring away from this obj, true to go ahead
virtual bool ButtonPressed(); // action button pressed, return false to ignore
int GetId();

View File

@@ -24,7 +24,6 @@
//////////////////////////////////////////////////////////////////////////
#if defined (WIN32) // WIN32 specific code
#include "../../Dependencies/include/png.h"
#include "../../Dependencies/include/fmod.h"
u8 JGE::GetAnalogX()
@@ -44,7 +43,6 @@ u8 JGE::GetAnalogY()
#elif defined (LINUX) // Unix specific code
#include <sys/time.h>
#include "png.h"
#include "../Dependencies/include/fmod.h"
@@ -253,7 +251,7 @@ void JGE::Init()
void JGE::SetDelta(float delta)
{
mDeltaTime = (float)delta;
mDeltaTime = delta;
}
float JGE::GetDelta()
@@ -279,12 +277,6 @@ void JGE::Init()
mDebug = false;
#endif
#if defined (WIN32) || defined (LINUX)
tickFrequency = 120;
#else
tickFrequency = sceRtcGetTickResolution();
#endif
if (mDebug)
pspDebugScreenInit(); // do this so that we can use pspDebugScreenPrintf

View File

@@ -28,7 +28,7 @@ JGuiObject::~JGuiObject()
}
bool JGuiObject::Leaving(u32 key __attribute__((unused)))
bool JGuiObject::Leaving(JButton key __attribute__((unused)))
{
return true;
}

View File

@@ -37,7 +37,7 @@ class ActionElement: public JGuiObject{
virtual void Render(){};
virtual int testDestroy(){return 0;};
virtual int destroy(){return 0;};
virtual bool CheckUserInput(u32 key){return false;};
virtual bool CheckUserInput(JButton key){return false;};
ActionElement(int id);
virtual ~ActionElement();
virtual int isReactingToTargetClick(Targetable * card);

View File

@@ -24,7 +24,7 @@ class ActionLayer: public GuiLayer, public JGuiListener{
int stuffHappened;
virtual void Render();
virtual void Update(float dt);
bool CheckUserInput(u32 key);
bool CheckUserInput(JButton key);
ActionLayer();
~ActionLayer();
int cancelCurrentAction();

View File

@@ -51,7 +51,7 @@ class Interruptible: public PlayGuiObject, public Targetable{
int state, display;
MTGCardInstance * source;
virtual void Entering(){mHasFocus = true;};
virtual bool Leaving(u32 key){mHasFocus = false;return true;};
virtual bool Leaving(JButton key){mHasFocus = false;return true;};
virtual bool ButtonPressed(){return true;};
virtual int resolve(){return 0;};
virtual void Render(){};
@@ -169,7 +169,7 @@ class ActionStack :public GuiLayer{
int addDamage(MTGCardInstance * _source, Damageable * target, int _damage);
int addAbility(MTGAbility * ability);
void Update(float dt);
bool CheckUserInput(u32 key);
bool CheckUserInput(JButton key);
virtual void Render();
ActionStack(GameObserver* game);
int resolve();

View File

@@ -20,7 +20,7 @@ class CardDisplay:public PlayGuiObjectController{
void AddCard(MTGCardInstance * _card);
void rotateLeft();
void rotateRight();
bool CheckUserInput(u32 key);
bool CheckUserInput(JButton key);
virtual void Update(float dt);
void Render();
void init(MTGGameZone * zone);

View File

@@ -57,7 +57,7 @@ class ObjectSelector : public GuiLayer
int bigMode;
void Add(T*);
void Remove(T*);
bool CheckUserInput(u32 key);
bool CheckUserInput(JButton key);
void Update(float dt);
void Render();
void Limit(LimitorFunctor<T>* limitor, SelectorZone);

View File

@@ -2,10 +2,7 @@
#define _DUELLAYERS_H_
#include "GuiLayers.h"
#include "PlayGuiObject.h"
template <typename T> class ObjectSelector;
typedef ObjectSelector<PlayGuiObject> CardSelector;
#include "CardSelector.h"
class MTGGuiHand;
class MTGGuiPlay;

View File

@@ -27,7 +27,7 @@ class GuiAvatars : public GuiLayer
void Deactivate(PlayGuiObject* c);
int receiveEventPlus(WEvent*);
int receiveEventMinus(WEvent*);
bool CheckUserInput(u32 key);
bool CheckUserInput(JButton key);
float LeftBoundarySelf();
};

View File

@@ -34,7 +34,7 @@ class GuiCombat : public GuiLayer
virtual void Update(float dt);
virtual void Render();
bool clickOK();
virtual bool CheckUserInput(u32 key);
virtual bool CheckUserInput(JButton key);
virtual int receiveEventPlus(WEvent* e);
virtual int receiveEventMinus(WEvent* e);

View File

@@ -72,7 +72,7 @@ class GuiHandSelf : public GuiHand
virtual int receiveEventMinus(WEvent* e);
void Repos();
bool CheckUserInput(u32 key);
bool CheckUserInput(JButton key);
virtual void Render();
void Update(float dt);
float LeftBoundary();

View File

@@ -14,7 +14,7 @@ class Player;
class GuiLayer{
protected:
u32 mActionButton;
JButton mActionButton;
public:
int mCount;
int mCurr;
@@ -28,7 +28,7 @@ class GuiLayer{
GuiLayer();
virtual ~GuiLayer();
virtual void Update(float dt);
virtual bool CheckUserInput(u32 key){ return false; };
virtual bool CheckUserInput(JButton key){ return false; };
int getIndexOf(JGuiObject * object);
JGuiObject * getByIndex (int index);
virtual void Render();

View File

@@ -13,7 +13,7 @@ struct GuiStatic : public PlayGuiObject{
GuiAvatars* parent;
GuiStatic(float desiredHeight, float x, float y, bool hasFocus, GuiAvatars* parent);
virtual void Entering();
virtual bool Leaving(u32 key);
virtual bool Leaving(JButton key);
};
struct GuiAvatar : public GuiStatic{
@@ -42,7 +42,7 @@ struct GuiGameZone : public GuiStatic{
CardDisplay * cd;
int showCards;
virtual void Render();
virtual bool CheckUserInput(u32 key);
virtual bool CheckUserInput(JButton key);
virtual void Update(float dt);
GuiGameZone(float x, float y, bool hasFocus, MTGGameZone * zone, GuiAvatars* parent);
~GuiGameZone();

View File

@@ -16,7 +16,7 @@ class MTGGamePhase: public ActionElement {
public:
MTGGamePhase(int id);
virtual void Update(float dt);
bool CheckUserInput(u32 key);
bool CheckUserInput(JButton key);
virtual MTGGamePhase * clone() const;
virtual ostream& toString(ostream& out) const;
};

View File

@@ -37,7 +37,7 @@ class MenuItem: public JGuiObject
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving(u32 key);
virtual bool Leaving(JButton key);
virtual bool ButtonPressed();
virtual ostream& toString(ostream& out) const;

View File

@@ -4,7 +4,7 @@
class OSDLayer : public PlayGuiObjectController
{
virtual void Update(float dt);
virtual bool CheckUserInput(u32 key);
virtual bool CheckUserInput(JButton key);
virtual void Render();
};

View File

@@ -25,8 +25,8 @@ class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos{
bool mHasFocus;
int type;
virtual void Entering(){mHasFocus = true; zoom = 1.4f;};
virtual bool Leaving(u32 key){mHasFocus = false; zoom = 1.0; return true;};
virtual bool CheckUserInput(u32 key) {return false;};
virtual bool Leaving(JButton key){mHasFocus = false; zoom = 1.0; return true;};
virtual bool CheckUserInput(JButton key) {return false;};
virtual bool ButtonPressed(){return true;};
virtual void Render();
virtual void Update(float dt);

View File

@@ -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 bool CheckUserInput(u32 key);
virtual bool CheckUserInput(JButton key);
PlayGuiObjectController(){last_user_move=0;};
virtual void Render(){GuiLayer::Render();};
};

View File

@@ -39,7 +39,7 @@ class SimpleMenuItem: public JGuiObject
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving(u32 key);
virtual bool Leaving(JButton key);
virtual bool ButtonPressed();
virtual ostream& toString(ostream& out) const;
};

View File

@@ -5,7 +5,7 @@
#include <map>
#include <vector>
using namespace std;
#include "../../../JGE/src/TinyXML/tinyxml.h"
#include "../../../JGE/src/tinyxml/tinyxml.h"
#include <JGui.h>
class GameObserver;
#define CAMPAIGNS_FOLDER "Res/campaigns/"
@@ -24,7 +24,7 @@ public:
void Update(float dt);
void Entering();
bool Leaving(u32 key);
bool Leaving(JButton key);
bool ButtonPressed();
bool hasFocus();
virtual ostream& toString(ostream& out) const;
@@ -83,4 +83,4 @@ public:
};
#endif
#endif

View File

@@ -50,7 +50,7 @@ int ActionLayer::reactToTargetClick(ActionElement* ability, Targetable * card){
return result;
}
bool ActionLayer::CheckUserInput(u32 key){
bool ActionLayer::CheckUserInput(JButton key){
GameObserver * g = GameObserver::GetInstance();
if (g->waitForExtraPayment && key == JGE_BTN_SEC){
g->waitForExtraPayment = NULL;

View File

@@ -620,8 +620,8 @@ void ActionStack::endOfInterruption(){
}
bool ActionStack::CheckUserInput(u32 key){
u32 trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
bool ActionStack::CheckUserInput(JButton key){
JButton trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
if (mode == ACTIONSTACK_STANDARD){
if (askIfWishesToInterrupt){
if (JGE_BTN_SEC == key){

View File

@@ -77,7 +77,7 @@ void CardDisplay::Update(float dt){
if (update) init(zone);
}
bool CardDisplay::CheckUserInput(u32 key){
bool CardDisplay::CheckUserInput(JButton key){
if (JGE_BTN_SEC == key)
{
if (listener){
@@ -136,6 +136,8 @@ bool CardDisplay::CheckUserInput(u32 key){
}
}
return true;
default:
;
}
return false;
}

View File

@@ -8,6 +8,9 @@
using std::cout;
// The X lib annoyingly defines True to be 1, leading to
// hard to understand syntax errors. Not using it, so it's
// safe to undefine it.
#ifdef True
#undef True
#endif
@@ -98,13 +101,13 @@ void CardSelector::Pop()
{
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; } //Is this needed, I think it is one in Leaving(0) ?
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; } //Is this needed, I think it is one in Entering() ?
if (oldactive) oldactive->Leaving(0);
if (oldactive) oldactive->Leaving(JGE_BTN_NONE);
if (active) active->Entering();
}
}
template<>
bool CardSelector::CheckUserInput(u32 key)
bool CardSelector::CheckUserInput(JButton key)
{
if (!active)
{
@@ -175,7 +178,7 @@ bool CardSelector::CheckUserInput(u32 key)
{
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; }
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; }
if (oldactive) oldactive->Leaving(0);
if (oldactive) oldactive->Leaving(JGE_BTN_NONE);
if (active) active->Entering();
}
return true;
@@ -248,7 +251,7 @@ void CardSelector::Limit(LimitorFunctor<Target>* limitor, SelectorZone destzone)
{
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; }
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; }
if (oldactive) oldactive->Leaving(0);
if (oldactive) oldactive->Leaving(JGE_BTN_NONE);
if (active) active->Entering();
}
}

View File

@@ -48,7 +48,7 @@ void DuelLayers::init(){
}
void DuelLayers::CheckUserInput(int isAI){
u32 key;
JButton key;
while ((key = JGE::GetInstance()->ReadButton())){
if ((!isAI) && (0 != key))
{

View File

@@ -66,7 +66,7 @@ int GuiAvatars::receiveEventMinus(WEvent* e)
return 1;
}
bool GuiAvatars::CheckUserInput(u32 key){
bool GuiAvatars::CheckUserInput(JButton key){
if (self->CheckUserInput(key)) return true;
if (opponent->CheckUserInput(key)) return true;
if (selfGraveyard->CheckUserInput(key)) return true;

View File

@@ -137,7 +137,7 @@ bool GuiCombat::clickOK(){
return false;
}
bool GuiCombat::CheckUserInput(u32 key)
bool GuiCombat::CheckUserInput(JButton key)
{
if (NONE == cursor_pos) return false;
DamagerDamaged* oldActive = active;
@@ -251,6 +251,8 @@ bool GuiCombat::CheckUserInput(u32 key)
if (options[Options::REVERSETRIGGERS].number) return false;
active = activeAtk = NULL; cursor_pos = OK;
break;
default:
;
}
if (oldActive != active)
{

View File

@@ -137,9 +137,9 @@ void GuiHandSelf::Repos()
}
}
bool GuiHandSelf::CheckUserInput(u32 key)
bool GuiHandSelf::CheckUserInput(JButton key)
{
u32 trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_PREV : JGE_BTN_NEXT);
JButton trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_PREV : JGE_BTN_NEXT);
if (trigger == key)
{
state = (Open == state ? Closed : Open);

View File

@@ -1,6 +1,6 @@
#include "GuiMessageBox.h"
bool GuiMessageBox::CheckUserInput(u32 key){
bool GuiMessageBox::CheckUserInput(JButton key){
if (mActionButton == key)
{
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())

View File

@@ -7,7 +7,7 @@ void GuiStatic::Entering()
{
parent->Activate(this);
}
bool GuiStatic::Leaving(u32 key)
bool GuiStatic::Leaving(JButton key)
{
parent->Deactivate(this);
return false;
@@ -151,7 +151,7 @@ void GuiGameZone::ButtonPressed(int controllerId, int controlId){
GameObserver::GetInstance()->ButtonPressed(this);
}
bool GuiGameZone::CheckUserInput(u32 key){
bool GuiGameZone::CheckUserInput(JButton key){
if (showCards) return cd->CheckUserInput(key);
return false;
}

View File

@@ -30,10 +30,10 @@ void MTGGamePhase::Update(float dt){
}
bool MTGGamePhase::CheckUserInput(u32 key){
bool MTGGamePhase::CheckUserInput(JButton key){
GameObserver * game = GameObserver::GetInstance();
if (activeState == INACTIVE){
u32 trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
JButton trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
if ((trigger == key) && game->currentActionPlayer == game->currentlyActing())
{
activeState = ACTIVE;

View File

@@ -94,7 +94,7 @@ void MenuItem::Entering()
}
bool MenuItem::Leaving(u32 key)
bool MenuItem::Leaving(JButton key)
{
mParticleSys->Stop(true);
mHasFocus = false;

View File

@@ -85,7 +85,7 @@ void PlayGuiObjectController::Update(float dt){
}
bool PlayGuiObjectController::CheckUserInput(u32 key){
bool PlayGuiObjectController::CheckUserInput(JButton key){
/*
if (!mCount)
return false;

View File

@@ -53,7 +53,7 @@ void SimpleMenuItem::Entering()
}
bool SimpleMenuItem::Leaving(u32 key)
bool SimpleMenuItem::Leaving(JButton key)
{
mHasFocus = false;
return true;

View File

@@ -196,7 +196,7 @@ void SimplePad::MoveSelection(unsigned char moveto)
void SimplePad::Update(float dt){
JGE * mEngine = JGE::GetInstance();
u32 key = mEngine->ReadButton();
JButton key = mEngine->ReadButton();
//Start button changes capslock setting.
if (key == JGE_BTN_MENU)

View File

@@ -52,7 +52,7 @@ void StoryChoice::Entering()
}
bool StoryChoice::Leaving(u32 key)
bool StoryChoice::Leaving(JButton key)
{
mHasFocus = false;
mTargetScale = 1.0f;
@@ -267,4 +267,4 @@ StoryFlow::~StoryFlow(){
SAFE_DELETE(i->second);
}
pages.clear();
}
}