Erwan
-fix issue 85 (simpleMenu limitation) - this requires to recompile JGE
This commit is contained in:
+2
-1
@@ -86,7 +86,7 @@ class JGuiController
|
|||||||
//int mKeyHoldTime;
|
//int mKeyHoldTime;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JGuiObject* mObjects[MAX_GUIOBJECT];
|
vector<JGuiObject*> mObjects;
|
||||||
int mCount;
|
int mCount;
|
||||||
|
|
||||||
JGuiController(int id, JGuiListener* listener);
|
JGuiController(int id, JGuiListener* listener);
|
||||||
@@ -96,6 +96,7 @@ class JGuiController
|
|||||||
virtual void Update(float dt);
|
virtual void Update(float dt);
|
||||||
|
|
||||||
void Add(JGuiObject* ctrl);
|
void Add(JGuiObject* ctrl);
|
||||||
|
void RemoveAt(int i);
|
||||||
void Remove(int id);
|
void Remove(int id);
|
||||||
void Remove(JGuiObject* ctrl);
|
void Remove(JGuiObject* ctrl);
|
||||||
|
|
||||||
|
|||||||
+18
-34
@@ -89,17 +89,12 @@ JGuiController::~JGuiController()
|
|||||||
if (mObjects[i]!=NULL)
|
if (mObjects[i]!=NULL)
|
||||||
delete mObjects[i];
|
delete mObjects[i];
|
||||||
|
|
||||||
// JGERelease();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGuiController::Render()
|
void JGuiController::Render()
|
||||||
{
|
{
|
||||||
// if (mShadingBg != NULL)
|
|
||||||
// jge->Gfx_BlendRect(mShadingBg, mShadingColor);
|
|
||||||
|
|
||||||
// if (mBg != NULL)
|
|
||||||
// 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)
|
||||||
@@ -165,30 +160,28 @@ void JGuiController::Update(float dt)
|
|||||||
|
|
||||||
void JGuiController::Add(JGuiObject* ctrl)
|
void JGuiController::Add(JGuiObject* ctrl)
|
||||||
{
|
{
|
||||||
if (mCount<MAX_GUIOBJECT)
|
mObjects.push_back(ctrl);
|
||||||
{
|
mCount++;
|
||||||
mObjects[mCount++] = ctrl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JGuiController::RemoveAt(int i){
|
||||||
|
if (!mObjects[i]) return;
|
||||||
|
mObjects.erase(mObjects.begin()+i);
|
||||||
|
delete mObjects[i];
|
||||||
|
mCount--;
|
||||||
|
if (mCurr == mCount)
|
||||||
|
mCurr = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void JGuiController::Remove(int id)
|
void JGuiController::Remove(int id)
|
||||||
{
|
{
|
||||||
for (int i=0;i<mCount;i++)
|
for (int i=0;i<mCount;i++)
|
||||||
{
|
{
|
||||||
if (mObjects[i] != NULL && mObjects[i]->GetId()==id)
|
if (mObjects[i] != NULL && mObjects[i]->GetId()==id) {
|
||||||
{
|
RemoveAt(i);
|
||||||
delete mObjects[i];
|
return;
|
||||||
for (int j=i;j<mCount-1;j++)
|
}
|
||||||
{
|
|
||||||
mObjects[j] = mObjects[j+1];
|
|
||||||
}
|
|
||||||
mObjects[mCount-1] = NULL;
|
|
||||||
mCount--;
|
|
||||||
if (mCurr == mCount)
|
|
||||||
mCurr = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,19 +190,10 @@ void JGuiController::Remove(JGuiObject* ctrl)
|
|||||||
{
|
{
|
||||||
for (int i=0;i<mCount;i++)
|
for (int i=0;i<mCount;i++)
|
||||||
{
|
{
|
||||||
if (mObjects[i] != NULL && mObjects[i]==ctrl)
|
if (mObjects[i] != NULL && mObjects[i]==ctrl) {
|
||||||
{
|
RemoveAt(i);
|
||||||
delete mObjects[i];
|
return;
|
||||||
for (int j=i;j<mCount-1;j++)
|
|
||||||
{
|
|
||||||
mObjects[j] = mObjects[j+1];
|
|
||||||
}
|
}
|
||||||
mObjects[mCount-1] = NULL;
|
|
||||||
mCount--;
|
|
||||||
if (mCurr == mCount)
|
|
||||||
mCurr = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user