Skip to content

Commit 20937a4

Browse files
Ghost race info
1 parent 64d36b2 commit 20937a4

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

data/gui/dialogs/ghost_replay_info_dialog.stkgui

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
<spacer width="1%"/>
3535
<label proportion="1" id="compare-ghost-text" height="100%" text_align="left" I18N="Ghost replay info action" text="Compare to another ghost"/>
3636
</div>
37+
<bubble id="info" width="100%" proportion="1" word_wrap="true"/>
3738
</div>
38-
39+
<spacer width="10" height="5%"/>
3940
<div width="95%" height="40%" align="center">
4041
<buttonbar id="actions" x="0" y="0" height="100%" width="100%" align="center">
4142
<icon-button id="back" width="128" height="128"
@@ -52,7 +53,7 @@
5253
I18N="Ghost replay info screen action" text="Start Race" word_wrap="true" />
5354
</buttonbar>
5455
</div>
55-
<spacer width="10" height="10%"/>
56+
<spacer width="10" height="5%"/>
5657
</div>
5758
</div>
5859

data/replay/benchmark_black_forest.replay

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ reverse: 0
77
difficulty: 3
88
mode: time-trial
99
track: black_forest
10+
info: Sped up 2x for benchmarking purpose.
1011
laps: 1
1112
min_time: 73.286743
1213
replay_uid: 564944495606616311

src/replay/replay_play.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,18 @@ bool ReplayPlay::addReplayFile(const std::string& fn, bool custom_replay, int ca
284284
rd.m_track = t;
285285

286286
fgets(s, 1023, fd);
287+
if (sscanf(s, "info: %1023s", s1) == 1)
288+
{
289+
int last = strlen(s);
290+
if (s[last - 1] == '\n')
291+
s[last - 1] = '\0';
292+
293+
rd.m_info = s + 6;
294+
if (rd.m_info.empty())
295+
rd.m_info = L" ";
296+
297+
fgets(s, 1023, fd);
298+
}
287299
if (sscanf(s, "laps: %u", &rd.m_laps) != 1)
288300
{
289301
Log::warn("Replay", "No number of laps found in replay file, '%s'.", fn.c_str());
@@ -359,7 +371,7 @@ void ReplayPlay::loadFile(bool second_replay)
359371
ReplayData &rd = m_replay_file_list[replay_index];
360372
unsigned int num_kart = (unsigned int)m_replay_file_list.at(replay_index)
361373
.m_kart_list.size();
362-
unsigned int lines_to_skip = (rd.m_replay_version == 3) ? 7 : 10;
374+
unsigned int lines_to_skip = (rd.m_replay_version == 3) ? 7 : 10 + !rd.m_info.empty();
363375
lines_to_skip += (rd.m_replay_version == 3) ? num_kart : 2*num_kart;
364376

365377
for (unsigned int i = 0; i < lines_to_skip; i++)

src/replay/replay_play.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class ReplayPlay : public ReplayBase
6262
std::string m_minor_mode;
6363
core::stringw m_stk_version;
6464
core::stringw m_user_name;
65+
core::stringw m_info;
6566
std::vector<std::string> m_kart_list;
6667
std::vector<core::stringw> m_name_list;
6768
std::vector<float> m_kart_color; //no sorting for this

src/states_screens/dialogs/ghost_replay_info_dialog.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "config/player_manager.hpp"
2222
#include "guiengine/CGUISpriteBank.hpp"
2323
#include "graphics/stk_tex_manager.hpp"
24+
#include "guiengine/widgets/bubble_widget.hpp"
2425
#include "guiengine/widgets/check_box_widget.hpp"
2526
#include "guiengine/widgets/icon_button_widget.hpp"
2627
#include "guiengine/widgets/label_widget.hpp"
@@ -43,7 +44,7 @@ using namespace irr::core;
4344
// -----------------------------------------------------------------------------
4445
GhostReplayInfoDialog::GhostReplayInfoDialog(unsigned int replay_id,
4546
uint64_t compare_replay_uid, bool compare_ghost)
46-
: ModalDialog(0.95f,0.75f), m_replay_id(replay_id)
47+
: ModalDialog(0.95f,0.9f), m_replay_id(replay_id)
4748
{
4849
m_self_destroy = false;
4950
m_record_race = false;
@@ -56,6 +57,9 @@ GhostReplayInfoDialog::GhostReplayInfoDialog(unsigned int replay_id,
5657

5758
loadFromFile("ghost_replay_info_dialog.stkgui");
5859

60+
m_info_widget = getWidget<BubbleWidget>("info");
61+
m_info_widget->setText(m_rd.m_info);
62+
5963
Track* track = track_manager->getTrack(m_rd.m_track_name);
6064

6165
m_track_screenshot_widget = getWidget<IconButtonWidget>("track_screenshot");

src/states_screens/dialogs/ghost_replay_info_dialog.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
namespace GUIEngine
2626
{
27+
class BubbleWidget;
2728
class CheckBoxWidget; class IconButtonWidget; class ListWidget;
2829
class RibbonWidget;
2930
}
@@ -48,6 +49,7 @@ class GhostReplayInfoDialog : public GUIEngine::ModalDialog
4849

4950
ReplayPlay::ReplayData m_rd;
5051

52+
GUIEngine::BubbleWidget* m_info_widget;
5153
GUIEngine::RibbonWidget* m_action_widget;
5254
GUIEngine::IconButtonWidget* m_back_widget;
5355
GUIEngine::CheckBoxWidget* m_record_widget;

0 commit comments

Comments
 (0)