1) Added getTracksInGroup() method.
2) Removed unnecessary leader-result files. 3) Minor code cleanup. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2176 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -125,7 +125,6 @@ supertuxkart_SOURCES = main.cpp \
|
||||
gui/game_mode.cpp gui/game_mode.hpp \
|
||||
gui/race_options.cpp gui/race_options.hpp \
|
||||
gui/char_sel.cpp gui/char_sel.hpp \
|
||||
gui/leader_result.cpp gui/leader_result.hpp \
|
||||
gui/start_race_feedback.cpp gui/start_race_feedback.hpp \
|
||||
gui/main_menu.cpp gui/main_menu.hpp \
|
||||
gui/help_page_one.cpp gui/help_page_one.hpp \
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
int m_offset; // index of first racer displayed
|
||||
unsigned int m_num_entries; // number of entries to display
|
||||
std::vector<int> m_index_avail_karts;
|
||||
static const int m_max_entries=7;
|
||||
static const unsigned int m_max_entries=7;
|
||||
bool kartAvailable(int kart);
|
||||
void updateScrollPosition();
|
||||
int computeIndent(int n) {return 40+abs((int)(m_max_entries-1)/2 - n)*3;}
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
// $Id: grand_prix_ending.cpp 1681 2008-04-09 13:52:48Z hikerstk $
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2008 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#include "leader_result.hpp"
|
||||
#include "loader.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "kart_properties_manager.hpp"
|
||||
#include "unlock_manager.hpp"
|
||||
#include "widget_manager.hpp"
|
||||
#include "race_manager.hpp"
|
||||
#include "game_manager.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "menu_manager.hpp"
|
||||
#include "kart_properties.hpp"
|
||||
#include "translation.hpp"
|
||||
#include "kart.hpp"
|
||||
#include "world.hpp"
|
||||
#include "scene.hpp"
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
enum WidgetTokens
|
||||
{
|
||||
WTOK_TITLE,
|
||||
WTOK_QUIT,
|
||||
|
||||
WTOK_FIRSTKART
|
||||
};
|
||||
|
||||
|
||||
LeaderResult::LeaderResult()
|
||||
: m_kart(0)
|
||||
{
|
||||
// for some strange reasons plib calls makeCurrent() in ssgContext
|
||||
// constructor, so we have to save the old one here and restore it
|
||||
ssgContext* oldContext = ssgGetCurrentContext();
|
||||
m_context = new ssgContext;
|
||||
oldContext->makeCurrent();
|
||||
|
||||
const unsigned int MAX_STR_LEN = 60;
|
||||
const unsigned int NUM_KARTS = race_manager->getNumKarts();
|
||||
|
||||
int *scores = new int[NUM_KARTS];
|
||||
int *position = new int[NUM_KARTS];
|
||||
double *race_time = new double[NUM_KARTS];
|
||||
|
||||
// Ignore kart 0, since it was the leader
|
||||
for( unsigned int kart_id = 1; kart_id < NUM_KARTS; ++kart_id )
|
||||
{
|
||||
position[kart_id] = kart_id;
|
||||
scores[kart_id] = race_manager->getKartScore(kart_id);
|
||||
race_time[kart_id] = race_manager->getOverallTime(kart_id);
|
||||
}
|
||||
|
||||
//Bubblesort
|
||||
bool sorted;
|
||||
do
|
||||
{
|
||||
sorted = true;
|
||||
for( unsigned int i = 1; i < NUM_KARTS - 1; ++i )
|
||||
{
|
||||
if( scores[i] < scores[i+1] || (scores[i] == scores[i+1]
|
||||
&& race_time[i] > race_time[i+1]))
|
||||
{
|
||||
int tmp_score[2];
|
||||
double tmp_time;
|
||||
|
||||
tmp_score[0] = position[i];
|
||||
tmp_score[1] = scores[i];
|
||||
tmp_time = race_time[i];
|
||||
|
||||
position[i] = position[i+1];
|
||||
scores[i] = scores[i+1];
|
||||
race_time[i] = race_time[i+1];
|
||||
|
||||
position[i+1] = tmp_score[0];
|
||||
scores[i+1] = tmp_score[1];
|
||||
race_time[i+1] = tmp_time;
|
||||
|
||||
sorted = false;
|
||||
}
|
||||
}
|
||||
} while(!sorted);
|
||||
|
||||
static char output[MAX_MESSAGE_LENGTH];
|
||||
snprintf(output, sizeof(output),
|
||||
_("The winner is %s!"),race_manager->getKartName(position[1]).c_str());
|
||||
widget_manager->addWgt( WTOK_TITLE, 60, 10);
|
||||
widget_manager->showWgtRect(WTOK_TITLE);
|
||||
widget_manager->showWgtText(WTOK_TITLE);
|
||||
widget_manager->setWgtText(WTOK_TITLE, output);
|
||||
widget_manager->setWgtTextSize(WTOK_TITLE, WGT_FNT_LRG);
|
||||
widget_manager->breakLine();
|
||||
|
||||
m_score = new char[MAX_STR_LEN*NUM_KARTS];
|
||||
|
||||
for(unsigned int i=1; i < NUM_KARTS; ++i)
|
||||
{
|
||||
// char sTime[20];
|
||||
// For now: don't display the time, since it's not correctly
|
||||
// set in follow-the-leader
|
||||
//TimeToString(race_time[i], sTime);
|
||||
sprintf((char*)(m_score + MAX_STR_LEN * i), "%d. %s %d",
|
||||
i , race_manager->getKartName(position[i]).c_str(), scores[i]);
|
||||
|
||||
widget_manager->addWgt(WTOK_FIRSTKART + i, 40, 5);
|
||||
widget_manager->showWgtRect(WTOK_FIRSTKART + i);
|
||||
widget_manager->showWgtText(WTOK_FIRSTKART + i);
|
||||
widget_manager->setWgtText(WTOK_FIRSTKART + i,
|
||||
(char*)(m_score + MAX_STR_LEN * i));
|
||||
widget_manager->setWgtTextSize(WTOK_FIRSTKART + i, WGT_FNT_SML);
|
||||
widget_manager->breakLine();
|
||||
}
|
||||
const std::string KART_NAME = race_manager->getKartName(position[1]);
|
||||
const KartProperties* WINNING_KART = kart_properties_manager->getKart(KART_NAME);
|
||||
delete []scores;
|
||||
delete []position;
|
||||
delete []race_time;
|
||||
|
||||
widget_manager->addWgt(WTOK_QUIT, 50, 7);
|
||||
widget_manager->activateWgt(WTOK_QUIT);
|
||||
widget_manager->showWgtRect(WTOK_QUIT);
|
||||
widget_manager->showWgtText(WTOK_QUIT);
|
||||
if(unlock_manager->getUnlockedFeatures().size()>0)
|
||||
{
|
||||
widget_manager->setWgtText(WTOK_QUIT, _("Continue"));
|
||||
}
|
||||
else
|
||||
{
|
||||
widget_manager->setWgtText(WTOK_QUIT, _("Back to the main menu"));
|
||||
}
|
||||
|
||||
widget_manager->layout(WGT_AREA_TOP);
|
||||
|
||||
m_kart = new ssgTransform;
|
||||
m_kart->ref();
|
||||
ssgEntity* kartentity = WINNING_KART->getModel();
|
||||
m_kart->addKid(kartentity);
|
||||
|
||||
sound_manager->playSfx(SOUND_WINNER);
|
||||
|
||||
m_clock = 0;
|
||||
|
||||
//FIXME: this is taken from RaceMode::exit_race,
|
||||
//this should be organized better.
|
||||
scene->clear();
|
||||
delete world;
|
||||
world = 0;
|
||||
race_manager->m_active_race = false;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
LeaderResult::~LeaderResult()
|
||||
{
|
||||
widget_manager->reset();
|
||||
ssgDeRefDelete(m_kart);
|
||||
|
||||
delete m_context;
|
||||
delete[] m_score;
|
||||
|
||||
//The next line prevents textures like the background of the main menu from
|
||||
//going white after finishing the grandprix
|
||||
// FIXME: I think this is not necessary anymore after the
|
||||
// texture bug fix (r733) - but I can't currently test this.
|
||||
loader->shared_textures.removeAll();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void LeaderResult::update(float dt)
|
||||
{
|
||||
m_clock += dt * 40.0f;
|
||||
|
||||
glClearColor (0.1f, 0.1f, 0.1f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
ssgContext* oldContext = ssgGetCurrentContext();
|
||||
m_context -> makeCurrent();
|
||||
|
||||
// FIXME: A bit hackish...
|
||||
glViewport ( 0, 0, 800, 320);
|
||||
|
||||
m_context -> setFOV ( 45.0f, 45.0f * 320.0f/800.0f ) ;
|
||||
m_context -> setNearFar ( 0.05f, 1000.0f ) ;
|
||||
|
||||
sgCoord cam_pos;
|
||||
sgSetCoord(&cam_pos, 0, 0, 0, 0, 0, 0);
|
||||
m_context -> setCamera ( &cam_pos ) ;
|
||||
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
sgCoord trans;
|
||||
sgSetCoord(&trans, 0, 3, -.4f, m_clock, 0, 0);
|
||||
m_kart->setTransform (&trans) ;
|
||||
//glShadeModel(GL_SMOOTH);
|
||||
ssgCullAndDraw ( m_kart ) ;
|
||||
glViewport ( 0, 0, user_config->m_width, user_config->m_height ) ;
|
||||
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
oldContext->makeCurrent();
|
||||
BaseGUI::update(dt);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void LeaderResult::select()
|
||||
{
|
||||
// If a new feature was unlocked, display the new feature first
|
||||
// before returning to the main menu
|
||||
if(unlock_manager->getUnlockedFeatures().size()>0)
|
||||
{
|
||||
// This removes this menu from the stack, and adds the main menu.
|
||||
// Then we push the new feature menu on top, so that it will be
|
||||
// displayed next, and on return the main menu is shown.
|
||||
menu_manager->switchToMainMenu();
|
||||
menu_manager->pushMenu(MENUID_UNLOCKED_FEATURE);
|
||||
return;
|
||||
}
|
||||
|
||||
menu_manager->switchToMainMenu();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void LeaderResult::handle(GameAction ga, int value)
|
||||
{
|
||||
// Attempts to close the menu are silently discarded
|
||||
// since they do not make sense at this point.
|
||||
if (ga == GA_LEAVE)
|
||||
return;
|
||||
else
|
||||
BaseGUI::handle(ga, value);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
// $Id: grand_prix_ending.hpp 1023 2007-04-29 22:23:46Z coz $
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2008 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_LEADER_RESULT_H
|
||||
#define HEADER_LEADER_RESULT_H
|
||||
|
||||
#include "base_gui.hpp"
|
||||
|
||||
class ssgBranch;
|
||||
class ssgTransform;
|
||||
class ssgContext;
|
||||
|
||||
class LeaderResult: public BaseGUI
|
||||
{
|
||||
private:
|
||||
ssgContext* m_context;
|
||||
ssgTransform* m_kart;
|
||||
int m_current_kart;
|
||||
int m_kart_name_label;
|
||||
char* m_score;
|
||||
float m_clock;
|
||||
|
||||
public:
|
||||
LeaderResult();
|
||||
~LeaderResult();
|
||||
|
||||
void update(float dt);
|
||||
void select();
|
||||
void handle(GameAction ga, int value);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -53,7 +53,6 @@
|
||||
#include "widget_manager.hpp"
|
||||
#include "challenges_menu.hpp"
|
||||
#include "feature_unlocked.hpp"
|
||||
#include "leader_result.hpp"
|
||||
#include "start_race_feedback.hpp"
|
||||
|
||||
using namespace std;
|
||||
@@ -184,9 +183,6 @@ void MenuManager::update()
|
||||
case MENUID_RACERESULT:
|
||||
m_current_menu= new RaceResultsGUI();
|
||||
break;
|
||||
case MENUID_LEADERRESULT:
|
||||
m_current_menu= new LeaderResult();
|
||||
break;
|
||||
case MENUID_GRANDPRIXEND:
|
||||
m_current_menu= new GrandPrixEnd();
|
||||
break;
|
||||
|
||||
@@ -36,7 +36,6 @@ enum MenuManagerIDs
|
||||
MENUID_RACE_OPTIONS,
|
||||
MENUID_GAMEMODE,
|
||||
MENUID_RACERESULT,
|
||||
MENUID_LEADERRESULT,
|
||||
MENUID_GRANDPRIXEND,
|
||||
MENUID_RACEMENU,
|
||||
MENUID_TRACKSEL,
|
||||
|
||||
@@ -56,14 +56,14 @@ TrackSel::TrackSel()
|
||||
prev_widget = w;
|
||||
for (unsigned int i = 0; i <m_max_entries; i++)
|
||||
{
|
||||
int offset = (m_max_entries-1)/2-abs((int)(i-(m_max_entries-1)/2))+1;
|
||||
int offset = (m_max_entries-1)/2-abs((int)(i-(m_max_entries-1)/2))+1;
|
||||
w = widget_manager->addTextButtonWgt(WTOK_TRACK0+i, 30, HEIGHT, "");
|
||||
widget_manager->setWgtTextSize(WTOK_TRACK0+i, WGT_FNT_SML);
|
||||
w->setPosition(WGT_DIR_FROM_RIGHT, 0.03f*offset, NULL,
|
||||
WGT_DIR_UNDER_WIDGET, 0.f, prev_widget);
|
||||
WGT_DIR_UNDER_WIDGET, 0.f, prev_widget);
|
||||
prev_widget = w;
|
||||
} // for i
|
||||
widget_manager->sameWidth(WTOK_TRACK0, WTOK_TRACK0+m_max_entries-1);
|
||||
widget_manager->sameWidth(WTOK_TRACK0, WTOK_TRACK0+m_max_entries-1);
|
||||
|
||||
w = widget_manager->addTextButtonWgt(WTOK_DOWN, 20, HEIGHT/2, "v");
|
||||
w->setPosition(WGT_DIR_FROM_RIGHT, 0.05f, NULL, WGT_DIR_UNDER_WIDGET, 0, prev_widget);
|
||||
@@ -71,7 +71,7 @@ TrackSel::TrackSel()
|
||||
w = widget_manager->addImgWgt(WTOK_IMG0, 35, 35, 0);
|
||||
w->setPosition(WGT_DIR_FROM_LEFT, 0.1f, WGT_DIR_FROM_TOP, 0.2f);
|
||||
prev_widget = w;
|
||||
w = widget_manager->addImgWgt(WTOK_IMG1, 35, 35, 0);
|
||||
w = widget_manager->addImgWgt(WTOK_IMG1, 35, 35, 0);
|
||||
w->setPosition(WGT_DIR_FROM_LEFT, 0.1f, NULL, WGT_DIR_UNDER_WIDGET,0, prev_widget);
|
||||
prev_widget = w;
|
||||
w = widget_manager->addTextWgt(WTOK_AUTHOR, 50, 9, "" );
|
||||
@@ -87,7 +87,7 @@ TrackSel::TrackSel()
|
||||
|
||||
m_offset = 0;
|
||||
m_current_track = -1;
|
||||
switchGroup();
|
||||
switchGroup();
|
||||
updateScrollPosition();
|
||||
|
||||
widget_manager->layout(WGT_AREA_TOP);
|
||||
@@ -108,28 +108,28 @@ TrackSel::~TrackSel()
|
||||
//-----------------------------------------------------------------------------
|
||||
void TrackSel::updateScrollPosition()
|
||||
{
|
||||
unsigned int start = 0, end=m_max_entries;
|
||||
if(m_index_avail_tracks.size()<m_max_entries)
|
||||
{
|
||||
start = (unsigned int)(m_max_entries-m_index_avail_tracks.size()+1)/2;
|
||||
end = start+m_index_avail_tracks.size()-1;
|
||||
}
|
||||
|
||||
for(unsigned int i=0; i<(unsigned int)m_max_entries; i++)
|
||||
unsigned int start = 0, end=m_max_entries;
|
||||
if(m_index_avail_tracks.size()<m_max_entries)
|
||||
{
|
||||
if(i<start || i>end)
|
||||
{
|
||||
widget_manager->hideWgtRect(WTOK_TRACK0+i);
|
||||
widget_manager->hideWgtText(WTOK_TRACK0+i);
|
||||
start = (unsigned int)(m_max_entries-m_index_avail_tracks.size()+1)/2;
|
||||
end = start+m_index_avail_tracks.size()-1;
|
||||
}
|
||||
|
||||
for(unsigned int i=0; i<(unsigned int)m_max_entries; i++)
|
||||
{
|
||||
if(i<start || i>end)
|
||||
{
|
||||
widget_manager->hideWgtRect(WTOK_TRACK0+i);
|
||||
widget_manager->hideWgtText(WTOK_TRACK0+i);
|
||||
widget_manager->deactivateWgt(WTOK_TRACK0+i);
|
||||
continue;
|
||||
}
|
||||
// Make them visible again (e.g. after a change of groups)
|
||||
continue;
|
||||
}
|
||||
// Make them visible again (e.g. after a change of groups)
|
||||
widget_manager->activateWgt(WTOK_TRACK0+i);
|
||||
widget_manager->showWgtRect(WTOK_TRACK0+i);
|
||||
widget_manager->showWgtText(WTOK_TRACK0+i);
|
||||
int indx = (i+m_offset)%m_index_avail_tracks.size();
|
||||
indx = m_index_avail_tracks[indx];
|
||||
widget_manager->showWgtText(WTOK_TRACK0+i);
|
||||
int indx = (i+m_offset)%m_index_avail_tracks.size();
|
||||
indx = m_index_avail_tracks[indx];
|
||||
if(indx>=0)
|
||||
{
|
||||
const Track *track = track_manager->getTrack(indx);
|
||||
@@ -140,23 +140,23 @@ void TrackSel::updateScrollPosition()
|
||||
const std::vector<std::string>& g=track_manager->getAllGroups();
|
||||
widget_manager->setWgtText(WTOK_TRACK0+i, g[-indx-1]);
|
||||
}
|
||||
} // for i
|
||||
} // for i
|
||||
m_current_track = -1; // force new display of tracks
|
||||
} // updateScrollPosition
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void TrackSel::switchGroup()
|
||||
{
|
||||
m_index_avail_tracks.clear();
|
||||
// This loop is too long (since getNumberOfKarts returns all karts in all groups),
|
||||
// but the loop is left if no more kart is found.
|
||||
for(unsigned int i=0; i<track_manager->getNumberOfTracks(); i++)
|
||||
m_index_avail_tracks.clear();
|
||||
|
||||
const std::vector<int> &tracks =
|
||||
track_manager->getTracksInGroup(user_config->m_track_group);
|
||||
|
||||
for(unsigned int i=0; i<tracks.size(); i++)
|
||||
{
|
||||
int globalIndex = track_manager->getTrackByGroup(user_config->m_track_group, i);
|
||||
if(globalIndex==-1) break;
|
||||
if(!unlock_manager->isLocked(track_manager->getTrack(globalIndex)->getIdent()))
|
||||
{
|
||||
m_index_avail_tracks.push_back(globalIndex);
|
||||
if(!unlock_manager->isLocked(track_manager->getTrack(tracks[i])->getIdent()))
|
||||
{
|
||||
m_index_avail_tracks.push_back(tracks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,27 +165,27 @@ void TrackSel::switchGroup()
|
||||
const std::vector<std::string>& groups=track_manager->getAllGroups();
|
||||
for(int i =0; i<(int)groups.size(); i++)
|
||||
{
|
||||
// Only add groups other than the current one
|
||||
if(groups[i]!=user_config->m_track_group) m_index_avail_tracks.push_back(-i-1);
|
||||
// Only add groups other than the current one
|
||||
if(groups[i]!=user_config->m_track_group) m_index_avail_tracks.push_back(-i-1);
|
||||
}
|
||||
if(m_index_avail_tracks.size()>=m_max_entries)
|
||||
{
|
||||
m_offset = 0;
|
||||
widget_manager->showWgtRect(WTOK_DOWN);
|
||||
widget_manager->showWgtText(WTOK_DOWN);
|
||||
widget_manager->showWgtRect(WTOK_UP);
|
||||
widget_manager->showWgtText(WTOK_UP);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Less entries than maximum -> set m_offset to a negative number, so
|
||||
// that the actual existing entries are displayed
|
||||
m_offset = - (int)(1+m_max_entries-m_index_avail_tracks.size())/2;
|
||||
widget_manager->hideWgtRect(WTOK_DOWN);
|
||||
widget_manager->hideWgtText(WTOK_DOWN);
|
||||
widget_manager->hideWgtRect(WTOK_UP);
|
||||
widget_manager->hideWgtText(WTOK_UP);
|
||||
}
|
||||
{
|
||||
m_offset = 0;
|
||||
widget_manager->showWgtRect(WTOK_DOWN);
|
||||
widget_manager->showWgtText(WTOK_DOWN);
|
||||
widget_manager->showWgtRect(WTOK_UP);
|
||||
widget_manager->showWgtText(WTOK_UP);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Less entries than maximum -> set m_offset to a negative number, so
|
||||
// that the actual existing entries are displayed
|
||||
m_offset = - (int)(1+m_max_entries-m_index_avail_tracks.size())/2;
|
||||
widget_manager->hideWgtRect(WTOK_DOWN);
|
||||
widget_manager->hideWgtText(WTOK_DOWN);
|
||||
widget_manager->hideWgtRect(WTOK_UP);
|
||||
widget_manager->hideWgtText(WTOK_UP);
|
||||
}
|
||||
} // switchGroup
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -340,13 +340,13 @@ void TrackSel::select()
|
||||
if(indx<0) // group selected
|
||||
{
|
||||
user_config->m_track_group = track_manager->getAllGroups()[-indx-1];
|
||||
switchGroup();
|
||||
// forces redraw of the model, otherwise (if m_current_kart=0) the new
|
||||
// model would not be displayed.
|
||||
//m_current_kart = -1;
|
||||
updateScrollPosition();
|
||||
return;
|
||||
}
|
||||
switchGroup();
|
||||
// forces redraw of the model, otherwise (if m_current_kart=0) the new
|
||||
// model would not be displayed.
|
||||
//m_current_kart = -1;
|
||||
updateScrollPosition();
|
||||
return;
|
||||
}
|
||||
|
||||
const Track* TRACK = track_manager->getTrack(m_index_avail_tracks[track_number]);
|
||||
bool isAvailable = !unlock_manager->isLocked(TRACK->getIdent());
|
||||
|
||||
@@ -990,10 +990,6 @@
|
||||
RelativePath="..\..\gui\help_page_two.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\leader_result.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\gui\main_menu.cpp"
|
||||
>
|
||||
@@ -1500,10 +1496,6 @@
|
||||
RelativePath="..\..\gui\help_page_two.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\leader_result.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\gui\main_menu.hpp"
|
||||
>
|
||||
|
||||
@@ -90,23 +90,10 @@ void TrackManager::updateGroups(const Track* track)
|
||||
const std::vector<std::string>& new_groups = track->getGroups();
|
||||
for(unsigned int i=0; i<new_groups.size(); i++)
|
||||
{
|
||||
if(std::find(m_all_groups.begin(), m_all_groups.end(), new_groups[i])
|
||||
!= m_all_groups.end()) continue;
|
||||
m_all_groups.push_back(new_groups[i]);
|
||||
if(m_groups.find(new_groups[i])==m_groups.end())
|
||||
m_all_groups.push_back(new_groups[i]);
|
||||
m_groups[new_groups[i]].push_back(m_tracks.size()-1);
|
||||
}
|
||||
} // updateGroups
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
int TrackManager::getTrackByGroup(const std::string& group, int n) const
|
||||
{
|
||||
int count=0;
|
||||
for(Tracks::const_iterator i = m_tracks.begin(); i != m_tracks.end(); i++)
|
||||
{
|
||||
std::vector<std::string> groups=(*i)->getGroups();
|
||||
if (std::find(groups.begin(), groups.end(), group)==groups.end()) continue;
|
||||
if(count==n) return (int)(i-m_tracks.begin());
|
||||
count=count+1;
|
||||
}
|
||||
return -1;
|
||||
|
||||
} // getTrackByGroup
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class Track;
|
||||
|
||||
/** Simple class to load and manage track data, track names and
|
||||
@@ -31,8 +33,8 @@ class TrackManager
|
||||
private:
|
||||
typedef std::vector<Track*> Tracks;
|
||||
Tracks m_tracks;
|
||||
std::vector<std::string>
|
||||
m_all_groups;
|
||||
std::map<std::string, std::vector<int> > m_groups;
|
||||
std::vector<std::string> m_all_groups;
|
||||
void updateGroups(const Track* track);
|
||||
|
||||
public:
|
||||
@@ -41,12 +43,13 @@ public:
|
||||
|
||||
/** get TrackData by the track ident (aka filename without .track) */
|
||||
const std::vector<std::string>&
|
||||
getAllGroups() const { return m_all_groups; }
|
||||
size_t getNumberOfTracks() const { return m_tracks.size(); }
|
||||
Track *getTrack(size_t id) const { return m_tracks[id]; }
|
||||
getAllGroups() const { return m_all_groups; }
|
||||
size_t getNumberOfTracks() const { return m_tracks.size(); }
|
||||
Track *getTrack(size_t id) const { return m_tracks[id]; }
|
||||
Track *getTrack(const std::string& ident) const;
|
||||
int getTrackByGroup(const std::string& group, int n) const;
|
||||
|
||||
const std::vector<int>&
|
||||
getTracksInGroup(const std::string& g) {return m_groups[g];}
|
||||
|
||||
/** load all .track files from all directories */
|
||||
void loadTrackList ();
|
||||
};
|
||||
|
||||
@@ -254,7 +254,7 @@ void World::resetAllKarts()
|
||||
if(!material)
|
||||
{
|
||||
fprintf(stderr, "ERROR: no valid starting position for kart %d on track %s.\n",
|
||||
i-m_kart.begin(), m_track->getIdent().c_str());
|
||||
(int)(i-m_kart.begin()), m_track->getIdent().c_str());
|
||||
exit(-1);
|
||||
}
|
||||
all_finished=false;
|
||||
|
||||
Reference in New Issue
Block a user