diff --git a/data/gui/ghost_replay_selection.stkgui b/data/gui/ghost_replay_selection.stkgui
index 98d587070..c8f69ad0a 100644
--- a/data/gui/ghost_replay_selection.stkgui
+++ b/data/gui/ghost_replay_selection.stkgui
@@ -12,7 +12,15 @@
-
-
+
+
+
+
diff --git a/src/states_screens/dialogs/ghost_replay_info_dialog.cpp b/src/states_screens/dialogs/ghost_replay_info_dialog.cpp
index 3e48ea3ff..5fc2eda53 100644
--- a/src/states_screens/dialogs/ghost_replay_info_dialog.cpp
+++ b/src/states_screens/dialogs/ghost_replay_info_dialog.cpp
@@ -81,7 +81,7 @@ GUIEngine::EventPropagation
if(selection == "start")
{
- bool reverse = m_rd.m_reverse;
+ bool reverse = m_rd.m_reverse;
std::string track_name = m_rd.m_track_name;
int laps = m_rd.m_laps;
int replay_id = m_replay_id;
diff --git a/src/states_screens/ghost_replay_selection.cpp b/src/states_screens/ghost_replay_selection.cpp
index 9186b6c78..7828efc4a 100644
--- a/src/states_screens/ghost_replay_selection.cpp
+++ b/src/states_screens/ghost_replay_selection.cpp
@@ -62,6 +62,10 @@ void GhostReplaySelection::loadedFromFile()
m_replay_list_widget = getWidget("replay_list");
assert(m_replay_list_widget != NULL);
m_replay_list_widget->setColumnListener(this);
+ m_replay_difficulty_toggle_widget =
+ getWidget("replay_difficulty_toggle");
+ m_replay_difficulty_toggle_widget->setState(true);
+ m_same_difficulty = m_replay_difficulty_toggle_widget->getState();
} // loadedFromFile
// ----------------------------------------------------------------------------
@@ -82,6 +86,7 @@ void GhostReplaySelection::beforeAddingWidget()
void GhostReplaySelection::init()
{
Screen::init();
+ m_cur_difficulty = race_manager->getDifficulty();
refresh(/*forced_update*/false);
} // init
@@ -97,6 +102,10 @@ void GhostReplaySelection::loadList()
{
const ReplayPlay::ReplayData& rd = ReplayPlay::get()->getReplayData(i);
+ if (m_same_difficulty && m_cur_difficulty !=
+ (RaceManager::Difficulty)rd.m_difficulty)
+ continue;
+
std::vector row;
Track* t = track_manager->getTrack(rd.m_track_name);
row.push_back(GUIEngine::ListWidget::ListCell
@@ -113,7 +122,7 @@ void GhostReplaySelection::loadList()
(StringUtils::toWString(rd.m_laps), -1, 1, true));
row.push_back(GUIEngine::ListWidget::ListCell
(StringUtils::toWString(rd.m_min_time) + L"s", -1, 1, true));
- m_replay_list_widget->addItem("replay", row);
+ m_replay_list_widget->addItem(StringUtils::toString(i), row);
}
} // loadList
@@ -132,11 +141,13 @@ void GhostReplaySelection::eventCallback(GUIEngine::Widget* widget,
}
else if (name == m_replay_list_widget->m_properties[GUIEngine::PROP_ID])
{
- int selected_index = m_replay_list_widget->getSelectionID();
+ int selected_index = -1;
+ const bool success = StringUtils::fromString(m_replay_list_widget
+ ->getSelectionInternalName(), selected_index);
// This can happen e.g. when the list is empty and the user
// clicks somewhere.
if (selected_index >= (signed)ReplayPlay::get()->getNumReplayFile() ||
- selected_index < 0)
+ selected_index < 0 || !success)
{
return;
}
@@ -148,6 +159,11 @@ void GhostReplaySelection::eventCallback(GUIEngine::Widget* widget,
TracksScreen::getInstance()->setOfficalTrack(false);
TracksScreen::getInstance()->push();
}
+ else if (name == "replay_difficulty_toggle")
+ {
+ m_same_difficulty = m_replay_difficulty_toggle_widget->getState();
+ refresh(/*forced_update*/false);
+ }
} // eventCallback
diff --git a/src/states_screens/ghost_replay_selection.hpp b/src/states_screens/ghost_replay_selection.hpp
index 0ac86a611..bd21f260c 100644
--- a/src/states_screens/ghost_replay_selection.hpp
+++ b/src/states_screens/ghost_replay_selection.hpp
@@ -21,6 +21,7 @@
#include "guiengine/screen.hpp"
#include "guiengine/widgets.hpp"
+#include "race/race_manager.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
namespace GUIEngine { class Widget; }
@@ -41,9 +42,12 @@ private:
GhostReplaySelection();
~GhostReplaySelection();
- GUIEngine::ListWidget* m_replay_list_widget;
- std::string m_file_to_be_deleted;
- bool m_sort_desc;
+ GUIEngine::ListWidget* m_replay_list_widget;
+ GUIEngine::CheckBoxWidget* m_replay_difficulty_toggle_widget;
+ RaceManager::Difficulty m_cur_difficulty;
+ std::string m_file_to_be_deleted;
+ bool m_same_difficulty;
+ bool m_sort_desc;
public: