Complete fix to arena selection menu (handle random arenas)
This commit is contained in:
parent
cebefcf374
commit
8f6a529531
@ -116,6 +116,7 @@ void ArenasScreen::beforeAddingWidget()
|
|||||||
|
|
||||||
void ArenasScreen::init()
|
void ArenasScreen::init()
|
||||||
{
|
{
|
||||||
|
m_unsupported_arena.clear();
|
||||||
Screen::init();
|
Screen::init();
|
||||||
buildTrackList();
|
buildTrackList();
|
||||||
DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks");
|
DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks");
|
||||||
@ -161,6 +162,16 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const
|
|||||||
curr_group = track_manager->getArenasInGroup(
|
curr_group = track_manager->getArenasInGroup(
|
||||||
tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER), soccer_mode );
|
tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER), soccer_mode );
|
||||||
}
|
}
|
||||||
|
// Remove unsupported arena
|
||||||
|
if (m_unsupported_arena.size() > 0)
|
||||||
|
{
|
||||||
|
for (std::set<int>::iterator it = m_unsupported_arena.begin();
|
||||||
|
it != m_unsupported_arena.end(); ++it)
|
||||||
|
{
|
||||||
|
curr_group.erase(std::remove(curr_group.begin(),
|
||||||
|
curr_group.end(), *it), curr_group.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RandomGenerator random;
|
RandomGenerator random;
|
||||||
const int randomID = random.get((int)curr_group.size());
|
const int randomID = random.get((int)curr_group.size());
|
||||||
@ -218,7 +229,6 @@ void ArenasScreen::buildTrackList()
|
|||||||
|
|
||||||
bool soccer_mode = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
|
bool soccer_mode = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
|
||||||
bool arenas_have_navmesh = false;
|
bool arenas_have_navmesh = false;
|
||||||
int skipped = 0;
|
|
||||||
|
|
||||||
if (curr_group_name == ALL_ARENA_GROUPS_ID)
|
if (curr_group_name == ALL_ARENA_GROUPS_ID)
|
||||||
{
|
{
|
||||||
@ -240,7 +250,11 @@ void ArenasScreen::buildTrackList()
|
|||||||
(!(curr->hasNavMesh() ||
|
(!(curr->hasNavMesh() ||
|
||||||
race_manager->getNumLocalPlayers() > 1 ||
|
race_manager->getNumLocalPlayers() > 1 ||
|
||||||
UserConfigParams::m_artist_debug_mode)))
|
UserConfigParams::m_artist_debug_mode)))
|
||||||
|
{
|
||||||
|
if (curr->isArena())
|
||||||
|
m_unsupported_arena.insert(n);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlayerManager::getCurrentPlayer()->isLocked(curr->getIdent()))
|
if (PlayerManager::getCurrentPlayer()->isLocked(curr->getIdent()))
|
||||||
@ -278,7 +292,8 @@ void ArenasScreen::buildTrackList()
|
|||||||
race_manager->getNumLocalPlayers() > 1 ||
|
race_manager->getNumLocalPlayers() > 1 ||
|
||||||
UserConfigParams::m_artist_debug_mode)))
|
UserConfigParams::m_artist_debug_mode)))
|
||||||
{
|
{
|
||||||
skipped++;
|
if (curr->isArena())
|
||||||
|
m_unsupported_arena.insert(currArenas[n]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,13 +310,15 @@ void ArenasScreen::buildTrackList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((arenas_have_navmesh || race_manager->getNumLocalPlayers() > 1 ||
|
if (arenas_have_navmesh || race_manager->getNumLocalPlayers() > 1 ||
|
||||||
UserConfigParams::m_artist_debug_mode) && !skipped)
|
UserConfigParams::m_artist_debug_mode)
|
||||||
w->addItem(_("Random Arena"), "random_track", "/gui/track_random.png");
|
w->addItem(_("Random Arena"), "random_track", "/gui/track_random.png");
|
||||||
w->updateItemDisplay();
|
w->updateItemDisplay();
|
||||||
|
|
||||||
if (skipped > 0)
|
if (m_unsupported_arena.size() > 0)
|
||||||
w->setText( _("%i arenas unavailable in single player", skipped) );
|
w->setText( _P("%d arena unavailable in single player.",
|
||||||
|
"%d arenas unavailable in single player.",
|
||||||
|
m_unsupported_arena.size()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------------
|
||||||
@ -312,6 +329,7 @@ void ArenasScreen::setFocusOnTrack(const std::string& trackName)
|
|||||||
assert( w != NULL );
|
assert( w != NULL );
|
||||||
|
|
||||||
w->setSelection(trackName, PLAYER_ID_GAME_MASTER, true);
|
w->setSelection(trackName, PLAYER_ID_GAME_MASTER, true);
|
||||||
|
|
||||||
} // setFOxuOnTrack
|
} // setFOxuOnTrack
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
@ -34,6 +34,9 @@ class ArenasScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton
|
|||||||
ArenasScreen();
|
ArenasScreen();
|
||||||
void buildTrackList();
|
void buildTrackList();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::set<int> m_unsupported_arena;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||||
|
Loading…
Reference in New Issue
Block a user