Misc code improvements

This commit is contained in:
Marianne Gagnon 2014-01-29 19:20:57 -05:00
parent b7e7808500
commit 3e253be31e
12 changed files with 27 additions and 35 deletions

View File

@ -103,6 +103,8 @@ void AchievementsManager::parseAssetFile()
if(num_nodes != m_achievements_info.size())
Log::error("AchievementsManager::parseAchievements",
"Multiple achievements with the same id!");
delete root;
}

View File

@ -210,16 +210,16 @@ void ListWidget::addItem( const std::string& internal_name,
// -----------------------------------------------------------------------------
void ListWidget::addItem(const std::string& internal_name,
PtrVector<ListCell> * contents)
const std::vector<ListCell>& contents)
{
// May only be called AFTER this widget has been add()ed
assert(m_element != NULL);
ListItem newItem;
newItem.m_internal_name = internal_name;
for(int i = 0; i < (int)contents->size(); i++)
for (unsigned int i = 0; i < contents.size(); i++)
{
newItem.m_contents.push_back(*contents->get(i));
newItem.m_contents.push_back(contents[i]);
}
CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();

View File

@ -132,7 +132,7 @@ namespace GUIEngine
bool center = false);
void addItem( const std::string& internal_name,
PtrVector<ListCell> * contents);
const std::vector<ListCell>& contents);
/**
* \brief erases all items in the list

View File

@ -164,15 +164,6 @@ void OverWorld::getKartsDisplayInfo(
assert(false);
} // getKartsDisplayInfo
//-----------------------------------------------------------------------------
/** Override the base class method to change behavior. We don't want wrong
* direction messages in the overworld since there is no direction there.
* \param i Kart id.
*/
void OverWorld::checkForWrongDirection(unsigned int i)
{
} // checkForWrongDirection
//-----------------------------------------------------------------------------
void OverWorld::createRaceGUI()

View File

@ -54,8 +54,6 @@ public:
/** Returns if this race mode has laps. */
virtual bool raceHasLaps() OVERRIDE { return false; }
// ------------------------------------------------------------------------
virtual void checkForWrongDirection(unsigned int i) OVERRIDE;
// ------------------------------------------------------------------------
/** The overworld is not a race per se so it's never over */
virtual bool isRaceOver() OVERRIDE { return false; }
// ------------------------------------------------------------------------

View File

@ -202,7 +202,7 @@ public:
// ------------------------------------------------------------------------
/** Returns the number of rescue positions on a given track and game
* mode. */
virtual unsigned int getNumberOfRescuePositions() const OVERRIDE = 0;
virtual unsigned int getNumberOfRescuePositions() const = 0;
// ------------------------------------------------------------------------
/** Determines the rescue position index of the specified kart. */
virtual unsigned int getRescuePositionIndex(AbstractKart *kart) = 0;

View File

@ -358,9 +358,9 @@ void AddonsScreen::loadList()
icon += 2;
}
PtrVector<GUIEngine::ListWidget::ListCell> * row = new PtrVector<GUIEngine::ListWidget::ListCell>;
row->push_back(new GUIEngine::ListWidget::ListCell(s.c_str(), icon, 3, false));
row->push_back(new GUIEngine::ListWidget::ListCell(addon->getDateAsString().c_str(), -1, 1, true));
std::vector<GUIEngine::ListWidget::ListCell> row;
row.push_back(GUIEngine::ListWidget::ListCell(s.c_str(), icon, 3, false));
row.push_back(GUIEngine::ListWidget::ListCell(addon->getDateAsString().c_str(), -1, 1, true));
w_list->addItem(addon->getId(), row);
// Highlight if it's not approved in artists debug mode.

View File

@ -83,10 +83,11 @@ void OnlineProfileAchievements::init()
m_achievements_list_widget->clear();
const std::map<uint32_t, Achievement *> & all_achievements = AchievementsManager::get()->getActive()->getAllAchievements();
std::map<uint32_t, Achievement *>::const_iterator it;
for ( it = all_achievements.begin(); it != all_achievements.end(); ++it ) {
PtrVector<GUIEngine::ListWidget::ListCell> * row = new PtrVector<GUIEngine::ListWidget::ListCell>;
row->push_back(new GUIEngine::ListWidget::ListCell(it->second->getInfo()->getTitle(),-1,2));
row->push_back(new GUIEngine::ListWidget::ListCell(it->second->getProgressAsString(),-1,1, true));
for (it = all_achievements.begin(); it != all_achievements.end(); ++it )
{
std::vector<GUIEngine::ListWidget::ListCell> row;
row.push_back(GUIEngine::ListWidget::ListCell(it->second->getInfo()->getTitle(),-1,2));
row.push_back(GUIEngine::ListWidget::ListCell(it->second->getProgressAsString(),-1,1, true));
m_achievements_list_widget->addItem(StringUtils::toString(it->second->getInfo()->getID()), row);
}
}

View File

@ -114,13 +114,13 @@ void OnlineProfileFriends::onUpdate(float delta)
m_friends_list_widget->clear();
for(unsigned int i = 0; i < m_visiting_profile->getFriends().size(); i++)
{
PtrVector<GUIEngine::ListWidget::ListCell> * row = new PtrVector<GUIEngine::ListWidget::ListCell>;
Profile * friend_profile = ProfileManager::get()->getProfileByID(m_visiting_profile->getFriends()[i]);
row->push_back(new GUIEngine::ListWidget::ListCell(friend_profile->getUserName(),-1,2));
std::vector<GUIEngine::ListWidget::ListCell> row;
Profile* friend_profile = ProfileManager::get()->getProfileByID(m_visiting_profile->getFriends()[i]);
row.push_back(GUIEngine::ListWidget::ListCell(friend_profile->getUserName(),-1,2));
if(m_visiting_profile->isCurrentUser())
{
Profile::RelationInfo * relation_info = friend_profile->getRelationInfo();
row->push_back(new GUIEngine::ListWidget::ListCell(relation_info->getDate(),-1,1, true));
row.push_back(GUIEngine::ListWidget::ListCell(relation_info->getDate(),-1,1, true));
irr::core::stringw status("");
if(relation_info->isPending())
{
@ -128,7 +128,7 @@ void OnlineProfileFriends::onUpdate(float delta)
}
else
status = (relation_info->isOnline() ? _("Online") : _("Offline"));
row->push_back(new GUIEngine::ListWidget::ListCell(status,-1,2, true));
row.push_back(GUIEngine::ListWidget::ListCell(status,-1,2, true));
}
m_friends_list_widget->addItem("friend", row);
}

View File

@ -76,12 +76,12 @@ void OnlineUserSearch::parseResult(const XMLNode * input)
void OnlineUserSearch::showList()
{
m_user_list_widget->clear();
for(unsigned int i=0; i < m_users.size(); i++)
for (unsigned int i=0; i < m_users.size(); i++)
{
PtrVector<GUIEngine::ListWidget::ListCell> * row = new PtrVector<GUIEngine::ListWidget::ListCell>;
std::vector<GUIEngine::ListWidget::ListCell> row;
Profile * profile = ProfileManager::get()->getProfileByID(m_users[i]);
assert(profile != NULL);
row->push_back(new GUIEngine::ListWidget::ListCell(profile->getUserName(),-1,3));
row.push_back(GUIEngine::ListWidget::ListCell(profile->getUserName(),-1,3));
m_user_list_widget->addItem("user", row);
}
}

View File

@ -121,9 +121,9 @@ void ServerSelection::loadList()
num_players.append(StringUtils::toWString(server->getCurrentPlayers()));
num_players.append("/");
num_players.append(StringUtils::toWString(server->getMaxPlayers()));
PtrVector<GUIEngine::ListWidget::ListCell> * row = new PtrVector<GUIEngine::ListWidget::ListCell>;
row->push_back(new GUIEngine::ListWidget::ListCell(server->getName(),-1,3));
row->push_back(new GUIEngine::ListWidget::ListCell(num_players,-1,1,true));
std::vector<GUIEngine::ListWidget::ListCell> row;
row.push_back(GUIEngine::ListWidget::ListCell(server->getName(),-1,3));
row.push_back(GUIEngine::ListWidget::ListCell(num_players,-1,1,true));
m_server_list_widget->addItem("server", row);
}
} // loadList

View File

@ -1,5 +1,5 @@
#if __cplusplus >= 201103
#if __cplusplus >= 201103 || _MSC_VER >=1800
#define OVERRIDE override