* Use readbutton in the JGuiController.
This commit is contained in:
jean.chalard
2008-11-27 14:17:15 +00:00
parent b9e2980952
commit 5fec3d4a3d
+10 -48
View File
@@ -24,7 +24,7 @@ JGuiObject::JGuiObject(int id): mId(id)
JGuiObject::~JGuiObject()
{
// JGERelease();
// JGERelease();
}
@@ -71,7 +71,6 @@ JGuiController::JGuiController(int id, JGuiListener* listener) : mId(id), mListe
mShowCursor = false;
mActionButton = PSP_CTRL_CIRCLE;
mLastKey = 0;
mStyle = JGUI_STYLE_WRAPPING;
@@ -85,55 +84,31 @@ JGuiController::~JGuiController()
if (mObjects[i]!=NULL)
delete mObjects[i];
// JGERelease();
// JGERelease();
}
void JGuiController::Render()
{
// if (mShadingBg != NULL)
// jge->Gfx_BlendRect(mShadingBg, mShadingColor);
// if (mShadingBg != NULL)
// jge->Gfx_BlendRect(mShadingBg, mShadingColor);
// if (mBg != NULL)
// jge->Gfx_DrawImage(mBg, mBgX, mBgY);
// if (mBg != NULL)
// jge->Gfx_DrawImage(mBg, mBgX, mBgY);
for (int i=0;i<mCount;i++)
if (mObjects[i]!=NULL)
mObjects[i]->Render();
}
bool JGuiController::KeyRepeated(u32 key, float dt)
{
bool doKey = false;
if (mLastKey != key)
{
mLastKey = key;
doKey = true;
mKeyRepeatDelay = JGUI_INITIAL_DELAY;
}
else
{
mKeyRepeatDelay -= dt;
if (mKeyRepeatDelay <= 0.0f)
{
mKeyRepeatDelay = JGUI_REPEAT_DELAY;
doKey = true;
}
}
return doKey;
}
void JGuiController::Update(float dt)
{
for (int i=0;i<mCount;i++)
if (mObjects[i]!=NULL)
mObjects[i]->Update(dt);
if (mEngine->GetButtonClick(mActionButton))
u32 key = mEngine->ReadButton();
if (key == mActionButton)
{
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
{
@@ -144,10 +119,7 @@ void JGuiController::Update(float dt)
}
}
}
if (mEngine->GetButtonState(PSP_CTRL_LEFT) || mEngine->GetButtonState(PSP_CTRL_UP) || mEngine->GetAnalogY()<64 || mEngine->GetAnalogX()<64)
{
if (KeyRepeated(PSP_CTRL_UP, dt))
else if ((PSP_CTRL_LEFT == key) || (PSP_CTRL_UP == key)) // || mEngine->GetAnalogY() < 64 || mEngine->GetAnalogX() < 64)
{
int n = mCurr;
n--;
@@ -165,10 +137,7 @@ void JGuiController::Update(float dt)
mObjects[mCurr]->Entering();
}
}
}
else if (mEngine->GetButtonState(PSP_CTRL_RIGHT) || mEngine->GetButtonState(PSP_CTRL_DOWN) || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
{
if (KeyRepeated(PSP_CTRL_DOWN, dt))
else if ((PSP_CTRL_RIGHT == key) || (PSP_CTRL_DOWN == key)) // || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
{
int n = mCurr;
n++;
@@ -186,10 +155,6 @@ void JGuiController::Update(float dt)
mObjects[mCurr]->Entering();
}
}
}
else
mLastKey = 0;
}
@@ -249,6 +214,3 @@ void JGuiController::SetStyle(int style) { mStyle = style; }
void JGuiController::SetCursor(JSprite* cursor) { mCursor = cursor; }
bool JGuiController::IsActive() { return mActive; }
void JGuiController::SetActive(bool flag) { mActive = flag; }