J :
* Fix issue 378, where the particles would not appear upon the second opening of an existing menu. * Fix for one of the issues of issue 380, where the selectionY attribute would be used uninitialized - reported by valgrind as an access to an uninitialized value in sinf and cosf.
This commit is contained in:
@@ -40,6 +40,7 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, int fontId, int x, int y,
|
|||||||
timeOpen = 0;
|
timeOpen = 0;
|
||||||
closed = false;
|
closed = false;
|
||||||
++refCount;
|
++refCount;
|
||||||
|
selectionTargetY = selectionY = y + VMARGIN;
|
||||||
|
|
||||||
JRenderer* renderer = JRenderer::GetInstance();
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
|
|
||||||
@@ -52,13 +53,10 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, int fontId, int x, int y,
|
|||||||
if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3);
|
if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3);
|
||||||
if (NULL == side) side = resources.RetrieveQuad("menuside.png", 1, 1, 1, 7,"menuside", RETRIEVE_MANAGE);
|
if (NULL == side) side = resources.RetrieveQuad("menuside.png", 1, 1, 1, 7,"menuside", RETRIEVE_MANAGE);
|
||||||
|
|
||||||
if (NULL == stars) {
|
if (NULL == stars)
|
||||||
JQuad * starQuad = resources.GetQuad("stars");
|
stars = NEW hgeParticleSystem(resources.RetrievePSI("stars.psi", resources.GetQuad("stars")));
|
||||||
hgeParticleSystemInfo * psi = resources.RetrievePSI("stars.psi", starQuad);
|
|
||||||
if(psi) stars = NEW hgeParticleSystem(psi);
|
|
||||||
}
|
|
||||||
|
|
||||||
stars->MoveTo(mX, mY);
|
stars->FireAt(mX, mY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenu::drawHorzPole(int x, int y, int width) {
|
void SimpleMenu::drawHorzPole(int x, int y, int width) {
|
||||||
@@ -133,9 +131,8 @@ void SimpleMenu::Render() {
|
|||||||
if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus()){
|
if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus()){
|
||||||
resources.GetJLBFont(Constants::MAIN_FONT)->DrawString(static_cast<SimpleMenuItem*>(mObjects[i])->desc.c_str(),mX+mWidth+10,mY+15);
|
resources.GetJLBFont(Constants::MAIN_FONT)->DrawString(static_cast<SimpleMenuItem*>(mObjects[i])->desc.c_str(),mX+mWidth+10,mY+15);
|
||||||
mFont->SetColor(ARGB(255,255,255,0));
|
mFont->SetColor(ARGB(255,255,255,0));
|
||||||
} else {
|
} else
|
||||||
mFont->SetColor(ARGB(150,255,255,255));
|
mFont->SetColor(ARGB(150,255,255,255));
|
||||||
}
|
|
||||||
(static_cast<SimpleMenuItem*>(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId);
|
(static_cast<SimpleMenuItem*>(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,18 +141,20 @@ void SimpleMenu::Render() {
|
|||||||
|
|
||||||
void SimpleMenu::Update(float dt){
|
void SimpleMenu::Update(float dt){
|
||||||
JGuiController::Update(dt);
|
JGuiController::Update(dt);
|
||||||
if (mCurr > startId + maxItems-1){
|
if (mCurr > startId + maxItems-1)
|
||||||
startId = mCurr - maxItems +1;
|
startId = mCurr - maxItems +1;
|
||||||
}else if (mCurr < startId){
|
else if (mCurr < startId)
|
||||||
startId = mCurr;
|
startId = mCurr;
|
||||||
}
|
|
||||||
stars->Update(dt);
|
stars->Update(dt);
|
||||||
selectionT += 3*dt;
|
selectionT += 3*dt;
|
||||||
selectionY += (selectionTargetY - selectionY) * 8 * dt;
|
selectionY += (selectionTargetY - selectionY) * 8 * dt;
|
||||||
|
printf("%f\n", selectionY);
|
||||||
|
printf("%f\n", selectionT);
|
||||||
|
printf("%i\n", startId);
|
||||||
stars->MoveTo(mX + HMARGIN + ((mWidth-2*HMARGIN)*(1+cos(selectionT))/2), selectionY + 5 * cos(selectionT*2.35) + LINE_HEIGHT / 2 - LINE_HEIGHT * startId);
|
stars->MoveTo(mX + HMARGIN + ((mWidth-2*HMARGIN)*(1+cos(selectionT))/2), selectionY + 5 * cos(selectionT*2.35) + LINE_HEIGHT / 2 - LINE_HEIGHT * startId);
|
||||||
if (timeOpen < 0) {
|
if (timeOpen < 0) {
|
||||||
timeOpen += dt * 10;
|
timeOpen += dt * 10;
|
||||||
if (timeOpen >= 0) { timeOpen = 0; closed = true; }
|
if (timeOpen >= 0) { timeOpen = 0; closed = true; stars->FireAt(mX, mY); }
|
||||||
} else {
|
} else {
|
||||||
closed = false;
|
closed = false;
|
||||||
timeOpen += dt * 10;
|
timeOpen += dt * 10;
|
||||||
@@ -163,7 +162,7 @@ void SimpleMenu::Update(float dt){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenu::Add(int id, const char * text,string desc, bool forceFocus){
|
void SimpleMenu::Add(int id, const char * text,string desc, bool forceFocus){
|
||||||
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, fontId, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0),autoTranslate);
|
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, fontId, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0), autoTranslate);
|
||||||
smi->desc = desc;
|
smi->desc = desc;
|
||||||
JGuiController::Add(smi);
|
JGuiController::Add(smi);
|
||||||
if (mCount <= maxItems) mHeight += LINE_HEIGHT;
|
if (mCount <= maxItems) mHeight += LINE_HEIGHT;
|
||||||
|
|||||||
Reference in New Issue
Block a user