Merge branch 'master' of https://github.com/supertuxkart/stk-code into ScriptEngine

This commit is contained in:
Sachith Hasaranga Seneviratne
2014-05-29 10:40:36 +05:30
10 changed files with 113 additions and 133 deletions

View File

@@ -297,33 +297,6 @@ public:
return true;
} // operator<
// ------------------------------------------------------------------------
/** Compares two addons according to the sort order currently defined.
* Comparison is done for sorting in descending order.
* \param a The addon to compare this addon to.
*/
bool operator>(const Addon &a) const
{
switch(m_sort_order)
{
case SO_DEFAULT:
if(testStatus(AS_FEATURED) &&
!a.testStatus(AS_FEATURED)) return true;
if(!testStatus(AS_FEATURED) &&
a.testStatus(AS_FEATURED)) return false;
// Otherwise fall through to name comparison!
case SO_NAME:
// m_id is the lower case name
return m_id > a.m_id;
break;
case SO_DATE:
return m_date < a.m_date;
break;
} // switch
// Fix compiler warning.
return true;
} // operator>
}; // Addon

View File

@@ -266,11 +266,4 @@ bool PlayerProfile::operator<(const PlayerProfile &other)
} // operator<
// -----------------------------------------------------------------------------
/** \brief Needed for toggling sort order **/
bool PlayerProfile::operator>(const PlayerProfile &other)
{
return m_use_frequency > other.m_use_frequency;
} // operator>
// -----------------------------------------------------------------------------

View File

@@ -116,7 +116,6 @@ public:
void initRemainingData();
void incrementUseFrequency();
bool operator<(const PlayerProfile &other);
bool operator>(const PlayerProfile &other);
void raceFinished();
void saveSession(int user_id, const std::string &token);
void clearSession();

View File

@@ -100,7 +100,7 @@ namespace Online{
break;
case SO_NAME:
// m_id is the lower case name
return m_name < server.getName();
return m_lower_case_name < server.m_lower_case_name;
break;
case SO_PLAYERS:
return m_current_players < server.getCurrentPlayers();
@@ -109,28 +109,6 @@ namespace Online{
return true;
} // operator<
// ------------------------------------------------------------------------
/** Compares two addons according to the sort order currently defined.
* Comparison is done for sorting in descending order.
* \param a The addon to compare this addon to.
*/
bool operator>(const Server &server) const
{
switch(m_sort_order)
{
case SO_SCORE:
return m_satisfaction_score > server.getScore();
break;
case SO_NAME:
return m_lower_case_name > server.getLowerCaseName();
break;
case SO_PLAYERS:
return m_current_players > server.getCurrentPlayers();
break;
} // switch
return true;
} // operator>
}; // Server
} // namespace Online

View File

@@ -555,13 +555,6 @@ namespace computeGPRanksData
(m_score == a.m_score && m_race_time < a.m_race_time) );
}
// --------------------------------------------------------------------
bool operator>(const SortData &a)
{
return ( (m_score < a.m_score) ||
(m_score == a.m_score && m_race_time > a.m_race_time) );
}
}; // SortData
} // namespace

View File

@@ -135,7 +135,8 @@ SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
}
else
{
const wchar_t* track_name = track_manager->getTrack(c->getData()->getTrackId())->getName();
const core::stringw track_name =
track_manager->getTrack(c->getData()->getTrackId())->getName();
getWidget<LabelWidget>("title")->setText( track_name, true );
}

View File

@@ -282,7 +282,9 @@ void TracksScreen::init()
} // init
// -----------------------------------------------------------------------------
/** Rebuild the list of tracks and GPs. This need to be recomputed e.g. to
* take unlocked tracks into account.
*/
void TracksScreen::buildTrackList()
{
DynamicRibbonWidget* tracks_widget = getWidget<DynamicRibbonWidget>("tracks");
@@ -295,71 +297,44 @@ void TracksScreen::buildTrackList()
tracks_widget->clearItems();
m_random_track_list.clear();
const std::string curr_group_name = tabs->getSelectionIDString(0);
const std::string& curr_group_name = tabs->getSelectionIDString(0);
// Build track list
if (curr_group_name == ALL_TRACK_GROUPS_ID)
const int track_amount = track_manager->getNumberOfTracks();
// First build a list of all tracks to be displayed
// (e.g. exclude arenas, ...)
PtrVector<Track, REF> tracks;
for (int n = 0; n < track_amount; n++)
{
const int trackAmount = track_manager->getNumberOfTracks();
Track* curr = track_manager->getTrack(n);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG
&& !curr->hasEasterEggs())
continue;
if (curr->isArena() || curr->isSoccer()||curr->isInternal()) continue;
if (curr_group_name != ALL_TRACK_GROUPS_ID &&
!curr->isInGroup(curr_group_name)) continue;
for (int n=0; n<trackAmount; n++)
tracks.push_back(curr);
} // for n<track_amount
tracks.insertionSort();
for (unsigned int i = 0; i < tracks.size(); i++)
{
Track *curr = tracks.get(i);
if (PlayerManager::getCurrentPlayer()->isLocked(curr->getIdent()))
{
Track* curr = track_manager->getTrack( n );
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG
&& !curr->hasEasterEggs())
continue;
if (curr->isArena() || curr->isSoccer()) continue;
if (curr->isInternal()) continue;
if(PlayerManager::getCurrentPlayer()->isLocked(curr->getIdent()))
{
tracks_widget->addItem(
_("Locked : solve active challenges to gain access to more!"),
"locked", curr->getScreenshotFile(), LOCKED_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}
else
{
tracks_widget->addItem(translations->fribidize(curr->getName()),
curr->getIdent(),
curr->getScreenshotFile(), 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
m_random_track_list.push_back(curr->getIdent());
}
tracks_widget->addItem(
_("Locked : solve active challenges to gain access to more!"),
"locked", curr->getScreenshotFile(), LOCKED_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}
}
else
{
const std::vector<int>& curr_group =
track_manager->getTracksInGroup( curr_group_name );
const int trackAmount = curr_group.size();
for (int n=0; n<trackAmount; n++)
else
{
Track* curr = track_manager->getTrack( curr_group[n] );
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG
&& !curr->hasEasterEggs())
continue;
if (curr->isArena()) continue;
if (curr->isSoccer()) continue;
if (curr->isInternal()) continue;
if (PlayerManager::getCurrentPlayer()->isLocked(curr->getIdent()))
{
tracks_widget->addItem(
_("Locked : solve active challenges to gain access to more!"),
"locked", curr->getScreenshotFile(), LOCKED_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}
else
{
tracks_widget->addItem(translations->fribidize(curr->getName()),
curr->getIdent(),
curr->getScreenshotFile(), 0 /* no badge */,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
m_random_track_list.push_back(curr->getIdent());
}
tracks_widget->addItem(translations->fribidize(curr->getName()),
curr->getIdent(),
curr->getScreenshotFile(), 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
m_random_track_list.push_back(curr->getIdent());
}
}

View File

@@ -73,6 +73,7 @@
#include <iostream>
#include <stdexcept>
#include <sstream>
#include <wchar.h>
using namespace irr;
@@ -152,6 +153,69 @@ Track::~Track()
#endif
} // ~Track
//-----------------------------------------------------------------------------
/** A < comparison of tracks. This is used to sort the tracks when displaying
* them in the gui.
*/
bool Track::operator<(const Track &other) const
{
PlayerProfile *p = PlayerManager::getCurrentPlayer();
bool this_is_locked = p->isLocked(getIdent());
bool other_is_locked = p->isLocked(other.getIdent());
if(this_is_locked == other_is_locked)
{
return getSortName() < other.getSortName();
}
else
return other_is_locked;
} // operator<
//-----------------------------------------------------------------------------
/** Returns the name of the track, which is e.g. displayed on the screen.
\note this is the LTR name, invoke fribidi as needed. */
core::stringw Track::getName() const
{
core::stringw translated = translations->w_gettext(m_name.c_str());
int index = translated.find("|");
if(index>-1)
{
translated = translated.subString(0, index);
}
return translated;
} // getName
//-----------------------------------------------------------------------------
/** Returns the name of the track used to sort the tracks alphabetically.
* This can be used to e.g. sort 'The Island' as 'Island,The'; or
* to replace certain language-specific characters (e.g. German 'ae' with 'a')
* The sort name can be specified by setting the name of a track to:
* "normal name|sort name"
*/
core::stringw Track::getSortName() const
{
core::stringw translated = translations->w_gettext(m_name.c_str());
translated.make_lower();
int index = translated.find("|");
if(index>-1)
{
translated = translated.subString(index+1, translated.size());
}
return translated;
} // getSortName
//-----------------------------------------------------------------------------
/** Returns true if this track belongs to the specified track group.
* \param group_name Group name to test for.
*/
bool Track::isInGroup(const std::string &group_name)
{
for(unsigned int i=0; i<m_groups.size(); i++)
{
if(m_groups[i]==group_name) return true;
}
return false;
} // isInGroup
//-----------------------------------------------------------------------------
/** Returns number of completed challenges */
unsigned int Track::getNumOfCompletedChallenges()

View File

@@ -350,6 +350,9 @@ private:
/** Name of the track to display. */
std::string m_name;
/** The name used in sorting the track. */
core::stringw m_sort_name;
bool m_use_fog;
/** True if this track supports using smoothed normals. */
bool m_smooth_normals;
@@ -428,6 +431,11 @@ public:
void adjustForFog(scene::IMesh* mesh,
scene::ISceneNode* parent_scene_node);
void itemCommand(const XMLNode *node);
core::stringw getName() const;
core::stringw getSortName() const;
// ------------------------------------------------------------------------
bool isInGroup(const std::string &group_name);
// ------------------------------------------------------------------------
const core::vector3df& getSunRotation();
/** Sets the current ambient color for a kart with index k. */
void setAmbientColor(const video::SColor &color,
@@ -472,11 +480,6 @@ public:
/** Returns a unique identifier for this track (the directory name). */
const std::string& getIdent () const {return m_ident; }
// ------------------------------------------------------------------------
/** Returns the name of the track, which is e.g. displayed on the screen.
\note this is the LTR name, invoke fribidi as needed. */
const wchar_t* getName () const
{return translations->w_gettext(m_name.c_str()); }
// ------------------------------------------------------------------------
/** Returns all groups this track belongs to. */
const std::vector<std::string>&
getGroups () const {return m_groups; }
@@ -612,6 +615,7 @@ public:
float getDisplacementSpeed() const { return m_displacement_speed; }
float getCausticsSpeed() const { return m_caustics_speed; }
bool operator<(const Track &other) const;
}; // class Track
#endif

View File

@@ -277,7 +277,7 @@ public:
{
for(int j=(int)start; j<(int)m_contents_vector.size()-1; j++)
{
if(*(m_contents_vector[j])>*(m_contents_vector[j+1])) continue;
if(*(m_contents_vector[j+1])<*(m_contents_vector[j])) continue;
// Now search the proper place for m_contents_vector[j+1]
// in the sorted section contentsVectot[start:j]
TYPE* t=m_contents_vector[j+1];
@@ -286,7 +286,7 @@ public:
{
m_contents_vector[i] = m_contents_vector[i-1];
i--;
} while (i>start && *t>*(m_contents_vector[i-1]));
} while (i>start && *(m_contents_vector[i-1]) <*t);
m_contents_vector[i]=t;
}
}