J :
* Use readbutton in the JGuiController.
This commit is contained in:
+4
-42
@@ -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;
|
||||
|
||||
@@ -102,38 +101,14 @@ void JGuiController::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)
|
||||
{
|
||||
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++;
|
||||
@@ -187,10 +156,6 @@ void JGuiController::Update(float dt)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
mLastKey = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JGuiController::Add(JGuiObject* ctrl)
|
||||
@@ -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; }
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user