Fixed random soccer arena selection + WIP GUI for soccer setup screen

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/christmas@12327 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
funto66
2013-01-02 18:11:11 +00:00
parent 9824370beb
commit 4c160eb065
5 changed files with 82 additions and 23 deletions

View File

@@ -20,6 +20,8 @@
<roundedbox x="2%" y="5%" width="100%" height="50%" layout="vertical-row" id="players-table">
<!-- Content is added programmatically -->
<!-- TODO: remove these tests and actually do this in the code -->
<!--
<div layout="horizontal-row" width="100%" height="50" align="center">
<spacer proportion="1" />
<icon-button id="kart-0" height="100%" icon="karts/beastie/beastie-icon.png"/>
@@ -28,7 +30,6 @@
<button id="team-0" I18N="In soccer setup screen" text="Team: blue" width="30%"/>
<spacer proportion="1" />
</div>
<div layout="horizontal-row" width="100%" height="50" align="center">
<spacer proportion="1" />
@@ -38,8 +39,11 @@
<button id="team-1" I18N="In soccer setup screen" text="Team: red" width="30%"/>
<spacer proportion="1" />
</div>
-->
<label proportion="1" height="100%"
I18N="In soccer setup menu" text="TODO" text_align="left" />
</roundedbox>

View File

@@ -63,7 +63,8 @@ void ArenasScreen::beforeAddingWidget()
tabs->clearAllChildren();
const std::vector<std::string>& groups = track_manager->getAllArenaGroups();
bool soccer_mode = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
const std::vector<std::string>& groups = track_manager->getAllArenaGroups(soccer_mode);
const int group_amount = groups.size();
if (group_amount > 1)
@@ -90,7 +91,7 @@ void ArenasScreen::beforeAddingWidget()
for (unsigned int n=0; n<track_manager->getNumberOfTracks(); n++) //iterate through tracks to find how many are arenas
{
Track* temp = track_manager->getTrack(n);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
if (soccer_mode)
{
if(temp->isSoccer())
num_of_arenas++;
@@ -137,6 +138,8 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const
{
RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups");
assert( tabs != NULL );
bool soccer_mode = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
std::vector<int> curr_group;
if (tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER) == ALL_ARENA_GROUPS_ID)
@@ -144,7 +147,7 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const
const std::vector<std::string>& groups = track_manager->getAllArenaGroups();
for (unsigned int i = 0; i < groups.size(); i++)
{
const std::vector<int>& tmp_group = track_manager->getArenasInGroup(groups[i]);
const std::vector<int>& tmp_group = track_manager->getArenasInGroup(groups[i], soccer_mode);
// Append to our main vector
curr_group.insert(curr_group.end(), tmp_group.begin(), tmp_group.end());
}
@@ -152,7 +155,7 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const
else
{
curr_group = track_manager->getArenasInGroup(
tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER) );
tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER), soccer_mode );
}
RandomGenerator random;
@@ -213,6 +216,8 @@ void ArenasScreen::buildTrackList()
assert( tabs != NULL );
const std::string curr_group_name = tabs->getSelectionIDString(0);
bool soccer_mode = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
if (curr_group_name == ALL_ARENA_GROUPS_ID)
{
const int trackAmount = track_manager->getNumberOfTracks();
@@ -220,7 +225,7 @@ void ArenasScreen::buildTrackList()
for (int n=0; n<trackAmount; n++)
{
Track* curr = track_manager->getTrack(n);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
if (soccer_mode)
{
if(!curr->isSoccer()) continue;
}
@@ -244,13 +249,13 @@ void ArenasScreen::buildTrackList()
}
else
{
const std::vector<int>& currArenas = track_manager->getArenasInGroup(curr_group_name);
const std::vector<int>& currArenas = track_manager->getArenasInGroup(curr_group_name, soccer_mode);
const int trackAmount = currArenas.size();
for (int n=0; n<trackAmount; n++)
{
Track* curr = track_manager->getTrack(currArenas[n]);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
if (soccer_mode)
{
if(!curr->isSoccer()) continue;
}

View File

@@ -52,4 +52,29 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name, c
void SoccerSetupScreen::init()
{
Screen::init();
Widget* players_table = getWidget<Widget>("players-table");
assert(players_table != NULL);
// BEGIN TODO
/*
Widget* div = new Widget(WTYPE_DIV);
div->m_properties[PROP_LAYOUT] = "horizontal-row";
//widget.m_properties[prop_flag] = core::stringc(prop_name).c_str(); else widget.m_properties[prop_flag] = ""
div->setParent(players_table->getIrrlichtElement());
players_table->getChildren().push_back(div);
//players_table->add();
*/
/* LabelWidget* lbl = new LabelWidget();
lbl->m_properties[PROP_PROPORTION] = "1";
lbl->m_properties[PROP_HEIGHT] = "100%";
lbl->setText(L"bouYou", false);
lbl->m_properties[PROP_TEXT_ALIGN] = "left";
//widget.m_properties[prop_flag] = core::stringc(prop_name).c_str(); else widget.m_properties[prop_flag] = ""
//lbl->setParent(players_table->getIrrlichtElement());
players_table->getChildren().push_back(lbl);
calculateLayout();
*/
// END TODO
}

View File

@@ -119,7 +119,9 @@ void TrackManager::loadTrackList()
m_track_group_names.clear();
m_track_groups.clear();
m_arena_group_names.clear();
m_soccer_arena_group_names.clear();
m_arena_groups.clear();
m_soccer_arena_groups.clear();
m_track_avail.clear();
m_tracks.clear();
@@ -215,11 +217,16 @@ void TrackManager::removeTrack(const std::string &ident)
int index = it - m_tracks.begin();
// Remove the track from all groups it belongs to
Group2Indices &group_2_indices = (track->isArena()||track->isSoccer()) ? m_arena_groups
: m_track_groups;
std::vector<std::string> &group_names = (track->isArena()||track->isSoccer())
? m_arena_group_names
: m_track_group_names;
Group2Indices &group_2_indices =
(track->isArena() ? m_arena_groups :
(track->isSoccer() ? m_soccer_arena_groups :
m_track_groups));
std::vector<std::string> &group_names =
(track->isArena() ? m_arena_group_names :
(track->isSoccer() ? m_soccer_arena_group_names :
m_track_group_names));
const std::vector<std::string>& groups=track->getGroups();
for(unsigned int i=0; i<groups.size(); i++)
{
@@ -245,9 +252,11 @@ void TrackManager::removeTrack(const std::string &ident)
// Adjust all indices of tracks with an index number higher than
// the removed track, since they have been moved down. This must
// be done for all tracks and all arenas
for(unsigned int i=0; i<2; i++) // i=0: arenas, i=1: tracks
for(unsigned int i=0; i<2; i++) // i=0: soccer arenas, i=0: arenas, i=1: tracks
{
Group2Indices &g2i = i==0 ? m_arena_groups : m_track_groups;
Group2Indices &g2i = (i==0 ? m_soccer_arena_groups :
(i==1 ? m_arena_groups :
m_track_groups));
Group2Indices::iterator j;
for(j=g2i.begin(); j!=g2i.end(); j++)
{
@@ -272,11 +281,15 @@ void TrackManager::updateGroups(const Track* track)
const std::vector<std::string>& new_groups = track->getGroups();
Group2Indices &group_2_indices = (track->isArena()||track->isSoccer()) ? m_arena_groups
: m_track_groups;
std::vector<std::string> &group_names = (track->isArena()||track->isSoccer())
? m_arena_group_names
: m_track_group_names;
Group2Indices &group_2_indices =
(track->isArena() ? m_arena_groups :
(track->isSoccer() ? m_soccer_arena_groups :
m_track_groups));
std::vector<std::string> &group_names =
(track->isArena() ? m_arena_group_names :
(track->isSoccer() ? m_soccer_arena_group_names :
m_track_group_names));
const unsigned int groups_amount = new_groups.size();
for(unsigned int i=0; i<groups_amount; i++)

View File

@@ -50,6 +50,9 @@ private:
/** List of all arena groups. */
Group2Indices m_arena_groups;
/** List of all soccer arena groups. */
Group2Indices m_soccer_arena_groups;
/** List of all groups (for both normal tracks and arenas) */
//std::vector<std::string> m_all_group_names;
@@ -58,6 +61,9 @@ private:
/** List of the names of all groups containing arenas */
std::vector<std::string> m_arena_group_names;
/** List of the names of all groups containing soccer arenas */
std::vector<std::string> m_soccer_arena_group_names;
/** Flag if this track is available or not. Tracks are set unavailable
* if they are not available on all clients (applies only to network mode)
@@ -83,7 +89,10 @@ public:
/** \brief Returns a list of the names of all used arena groups. */
const std::vector<std::string>&
getAllArenaGroups() const { return m_arena_group_names; }
getAllArenaGroups(bool soccer_arena=false) const
{
return soccer_arena ? m_soccer_arena_group_names : m_arena_group_names;
}
/** Returns the number of tracks. */
size_t getNumberOfTracks() const { return m_tracks.size(); }
@@ -111,7 +120,10 @@ public:
/** Returns a list of all arenas in a given group.
* \param g Name of the group. */
const std::vector<int>&
getArenasInGroup(const std::string& g) {return m_arena_groups[g];}
getArenasInGroup(const std::string& g, bool soccer_arena=false)
{
return soccer_arena ? m_soccer_arena_groups[g] : m_arena_groups[g];
}
/** Returns a list of all track identifiers. */
std::vector<std::string> getAllTrackIdentifiers();