J :
* Use readbutton in the JGuiController.
This commit is contained in:
+10
-48
@@ -24,7 +24,7 @@ JGuiObject::JGuiObject(int id): mId(id)
|
|||||||
|
|
||||||
JGuiObject::~JGuiObject()
|
JGuiObject::~JGuiObject()
|
||||||
{
|
{
|
||||||
// JGERelease();
|
// JGERelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,7 +71,6 @@ JGuiController::JGuiController(int id, JGuiListener* listener) : mId(id), mListe
|
|||||||
mShowCursor = false;
|
mShowCursor = false;
|
||||||
|
|
||||||
mActionButton = PSP_CTRL_CIRCLE;
|
mActionButton = PSP_CTRL_CIRCLE;
|
||||||
mLastKey = 0;
|
|
||||||
|
|
||||||
mStyle = JGUI_STYLE_WRAPPING;
|
mStyle = JGUI_STYLE_WRAPPING;
|
||||||
|
|
||||||
@@ -85,55 +84,31 @@ JGuiController::~JGuiController()
|
|||||||
if (mObjects[i]!=NULL)
|
if (mObjects[i]!=NULL)
|
||||||
delete mObjects[i];
|
delete mObjects[i];
|
||||||
|
|
||||||
// JGERelease();
|
// JGERelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGuiController::Render()
|
void JGuiController::Render()
|
||||||
{
|
{
|
||||||
// if (mShadingBg != NULL)
|
// if (mShadingBg != NULL)
|
||||||
// jge->Gfx_BlendRect(mShadingBg, mShadingColor);
|
// jge->Gfx_BlendRect(mShadingBg, mShadingColor);
|
||||||
|
|
||||||
// if (mBg != NULL)
|
// if (mBg != NULL)
|
||||||
// jge->Gfx_DrawImage(mBg, mBgX, mBgY);
|
// jge->Gfx_DrawImage(mBg, mBgX, mBgY);
|
||||||
|
|
||||||
for (int i=0;i<mCount;i++)
|
for (int i=0;i<mCount;i++)
|
||||||
if (mObjects[i]!=NULL)
|
if (mObjects[i]!=NULL)
|
||||||
mObjects[i]->Render();
|
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)
|
void JGuiController::Update(float 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);
|
||||||
|
|
||||||
if (mEngine->GetButtonClick(mActionButton))
|
u32 key = mEngine->ReadButton();
|
||||||
|
if (key == mActionButton)
|
||||||
{
|
{
|
||||||
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
|
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
|
||||||
{
|
{
|
||||||
@@ -144,10 +119,7 @@ void JGuiController::Update(float dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ((PSP_CTRL_LEFT == key) || (PSP_CTRL_UP == key)) // || mEngine->GetAnalogY() < 64 || mEngine->GetAnalogX() < 64)
|
||||||
if (mEngine->GetButtonState(PSP_CTRL_LEFT) || mEngine->GetButtonState(PSP_CTRL_UP) || mEngine->GetAnalogY()<64 || mEngine->GetAnalogX()<64)
|
|
||||||
{
|
|
||||||
if (KeyRepeated(PSP_CTRL_UP, dt))
|
|
||||||
{
|
{
|
||||||
int n = mCurr;
|
int n = mCurr;
|
||||||
n--;
|
n--;
|
||||||
@@ -165,10 +137,7 @@ void JGuiController::Update(float dt)
|
|||||||
mObjects[mCurr]->Entering();
|
mObjects[mCurr]->Entering();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if ((PSP_CTRL_RIGHT == key) || (PSP_CTRL_DOWN == key)) // || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
|
||||||
else if (mEngine->GetButtonState(PSP_CTRL_RIGHT) || mEngine->GetButtonState(PSP_CTRL_DOWN) || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
|
|
||||||
{
|
|
||||||
if (KeyRepeated(PSP_CTRL_DOWN, dt))
|
|
||||||
{
|
{
|
||||||
int n = mCurr;
|
int n = mCurr;
|
||||||
n++;
|
n++;
|
||||||
@@ -186,10 +155,6 @@ void JGuiController::Update(float dt)
|
|||||||
mObjects[mCurr]->Entering();
|
mObjects[mCurr]->Entering();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
mLastKey = 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -249,6 +214,3 @@ void JGuiController::SetStyle(int style) { mStyle = style; }
|
|||||||
void JGuiController::SetCursor(JSprite* cursor) { mCursor = cursor; }
|
void JGuiController::SetCursor(JSprite* cursor) { mCursor = cursor; }
|
||||||
bool JGuiController::IsActive() { return mActive; }
|
bool JGuiController::IsActive() { return mActive; }
|
||||||
void JGuiController::SetActive(bool flag) { mActive = flag; }
|
void JGuiController::SetActive(bool flag) { mActive = flag; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user