Fixed #336 (disabled 'add competitor' button when max competitor reached) (r3353 didn't fixed it at all, my mistake)

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3354 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 4cd42ade060591ab72974c1d44751f081df0482c
Former-commit-id: bf5cc18b099e1ecd007cb2543825089b160d250f
This commit is contained in:
pouillot 2011-02-11 19:53:15 +00:00
parent a43917bbc1
commit 6cd272b584

View file

@ -159,6 +159,10 @@ rmdsReloadCompetitorsScrollList()
// Add its name to the Competitors scroll list.
GfuiScrollListInsertElement(ScrHandle, CompetitorsScrollListId, (*itComp)->getName().c_str(),
MenuData->pRace->getCompetitorsCount(), (void*)(*itComp));
// Be carefull with max nb of competitors.
GfuiEnable(ScrHandle, SelectButtonId,
MenuData->pRace->acceptsMoreCompetitors() ? GFUI_ENABLE : GFUI_DISABLE);
}
// Screen activation call-back.
@ -347,7 +351,8 @@ rmdsClickOnDriver(void * /* dummy */)
else if (GfuiScrollListGetSelectedElement(ScrHandle, CandidatesScrollListId, (void**)&pDriver))
{
// A driver from the Candidates scroll-list.
GfuiEnable(ScrHandle, SelectButtonId, GFUI_ENABLE);
GfuiEnable(ScrHandle, SelectButtonId,
MenuData->pRace->acceptsMoreCompetitors() ? GFUI_ENABLE : GFUI_DISABLE);
GfuiEnable(ScrHandle, DeselectButtonId, GFUI_DISABLE);
GfuiEnable(ScrHandle, ChangeCarButtonId, GFUI_DISABLE);
GfuiVisibilitySet(ScrHandle, SkinEditId, GFUI_VISIBLE);
@ -473,24 +478,32 @@ rmdsSelectDeselectDriver(void * /* dummy */ )
// Focused driver management (inhibited for the moment : what is it useful for ?)
const GfDriver* pFocDriver = MenuData->pRace->getFocusedCompetitor();
if (bSelect) {
if (MenuData->pRace->isCompetitorFocused(pDriver)) {
if (bSelect)
{
if (MenuData->pRace->isCompetitorFocused(pDriver))
{
/* the focused element was deselected : select a new one */
name = GfuiScrollListGetElement(ScrHandle, CompetitorsScrollListId, 0, (void**)&pDriver);
if (name) {
if (name)
{
MenuData->pRace->setFocusedCompetitor(pDriver);
#ifdef FOCUS
GfuiLabelSetText(ScrHandle, FocusedDriverLabelId, pDriver->getName.c_str());
#endif
} else {
}
else
{
MenuData->pRace->setFocusedCompetitor(0);
#ifdef FOCUS
GfuiLabelSetText(ScrHandle, FocusedDriverLabelId, "");
#endif
}
}
} else {
if (!pFocDriver || pDriver->isHuman()) {
}
else
{
if (!pFocDriver || pDriver->isHuman())
{
MenuData->pRace->setFocusedCompetitor(pDriver);
#ifdef FOCUS
GfuiLabelSetText(ScrHandle, FocusedDriverLabelId, pDriver->getName().c_str());
@ -502,7 +515,8 @@ rmdsSelectDeselectDriver(void * /* dummy */ )
rmdsClickOnDriver(0);
// Don't allow user to Accept 0 drivers, this would cause a crash.
GfuiEnable(ScrHandle, NextButtonId, MenuData->pRace->getCompetitorsCount() > 0 ? GFUI_ENABLE : GFUI_DISABLE);
GfuiEnable(ScrHandle, NextButtonId,
MenuData->pRace->getCompetitorsCount() > 0 ? GFUI_ENABLE : GFUI_DISABLE);
// For a smart display refresh, when automatically called multiple time.
GfuiDisplay();
@ -750,7 +764,6 @@ rmdsFilterCandidatesScrollList(const std::string& strCarCatId, const std::string
{
// Empty the unselected scroll-list
GfuiScrollListClear(ScrHandle, CandidatesScrollListId);
GfuiEnable(ScrHandle, SelectButtonId, GFUI_DISABLE);
// Fill it with drivers that match the filter criteria,
// are accepted by the race and are not already among competitors.