Allow showing same difficulty of ghost replay only
This commit is contained in:
parent
ff10bfd07a
commit
55278122fe
@ -12,7 +12,15 @@
|
||||
<list id="replay_list" x="0" y="0" width="100%" height="100%"/>
|
||||
</box>
|
||||
|
||||
<spacer width="100%" height="2%" />
|
||||
<button x="1%" id="record-ghost" I18N="In the ghost replay selection screen" text="Record ghost replay" />
|
||||
<div width="99%" align="center" layout="vertical-row" height="fit">
|
||||
<div width="100%" height="fit" layout="horizontal-row" >
|
||||
<checkbox width="fit" id="replay_difficulty_toggle" text_align="left"/>
|
||||
<spacer width="10"/>
|
||||
<label proportion="1" height="100%" text_align="left" I18N="In the ghost replay selection screen" text="Same difficulty of ghost replay"/>
|
||||
</div>
|
||||
</div>
|
||||
<spacer width="100%" height="1%" />
|
||||
<button x="1%" id="record-ghost" I18N="In the ghost replay selection screen" text="Record ghost replay"/>
|
||||
|
||||
</div>
|
||||
</stkgui>
|
||||
|
@ -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;
|
||||
|
@ -62,6 +62,10 @@ void GhostReplaySelection::loadedFromFile()
|
||||
m_replay_list_widget = getWidget<GUIEngine::ListWidget>("replay_list");
|
||||
assert(m_replay_list_widget != NULL);
|
||||
m_replay_list_widget->setColumnListener(this);
|
||||
m_replay_difficulty_toggle_widget =
|
||||
getWidget<GUIEngine::CheckBoxWidget>("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<GUIEngine::ListWidget::ListCell> 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
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user