improved scrolling of simple menus. Now you can scroll up as well as down by activating the area above/below the menu items
removed the buttons when displaying the filter menus.
This commit is contained in:
@@ -181,6 +181,8 @@ bool JGuiController::CheckUserInput(JButton key)
|
|||||||
minDistance2 = distance2;
|
minDistance2 = distance2;
|
||||||
n = i;
|
n = i;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -723,6 +723,7 @@ void GameStateShop::Render()
|
|||||||
|
|
||||||
if (shopMenu)
|
if (shopMenu)
|
||||||
shopMenu->Render();
|
shopMenu->Render();
|
||||||
|
|
||||||
if (filterMenu && !filterMenu->isFinished())
|
if (filterMenu && !filterMenu->isFinished())
|
||||||
filterMenu->Render();
|
filterMenu->Render();
|
||||||
else
|
else
|
||||||
@@ -790,7 +791,8 @@ void GameStateShop::Render()
|
|||||||
if (menu)
|
if (menu)
|
||||||
menu->Render();
|
menu->Render();
|
||||||
|
|
||||||
renderButtons();
|
if (filterMenu && filterMenu->isFinished())
|
||||||
|
renderButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateShop::ButtonPressed(int controllerId, int controlId)
|
void GameStateShop::ButtonPressed(int controllerId, int controlId)
|
||||||
|
|||||||
@@ -240,25 +240,35 @@ bool SimpleMenu::CheckUserInput(JButton key)
|
|||||||
if (mObjects.size())
|
if (mObjects.size())
|
||||||
{
|
{
|
||||||
float top, left;
|
float top, left;
|
||||||
|
SimpleMenuItem * currentItem = static_cast<SimpleMenuItem *>(mObjects[mCurr]);
|
||||||
|
float fontHeight = WResourceManager::Instance()->GetWFont(currentItem->getFontId())->GetHeight();
|
||||||
|
float menuTopEdge = fontHeight + mY + spadeR->mHeight;
|
||||||
|
float menuBottomEdge = menuTopEdge + (maxItems * fontHeight);
|
||||||
|
|
||||||
for (int i = 0; i < mCount; i++)
|
for (int i = 0; i < mCount; i++)
|
||||||
{
|
{
|
||||||
if (mObjects[i]->getTopLeft(top, left))
|
if (mObjects[i]->getTopLeft(top, left))
|
||||||
{
|
{
|
||||||
distance2 = (unsigned int)((top - y) * (top - y) + (left - x) * (left - x));
|
distance2 = (unsigned int)((top - y) * (top - y) + (left - x) * (left - x));
|
||||||
if ( (distance2 < minDistance2) )
|
if ( (distance2 <= minDistance2) )
|
||||||
{
|
{
|
||||||
minDistance2 = distance2;
|
minDistance2 = distance2;
|
||||||
n = i;
|
if (y < menuTopEdge)
|
||||||
}
|
{
|
||||||
else if (y > mHeight) // this will scroll downwards in a list.
|
n = (mCurr - 1) > 0 ? mCurr - 1 : 0;
|
||||||
{
|
break;
|
||||||
if (mCurr < mCount-1)
|
}
|
||||||
n = mCurr + 1;
|
else if (y > menuBottomEdge)
|
||||||
|
{
|
||||||
|
n = (mCurr + 1) < mCount ? mCurr + 1 : mCount - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
n = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// check to see if the user clicked
|
||||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_DOWN))
|
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_DOWN))
|
||||||
{
|
{
|
||||||
mCurr = n;
|
mCurr = n;
|
||||||
|
|||||||
Reference in New Issue
Block a user