Skip to content

Commit

Permalink
Support Ghost Replay Info
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingJellyfish committed Nov 7, 2024
1 parent d3cd41c commit 9805f0c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/gui/dialogs/ghost_replay_info_dialog.stkgui
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<spacer width="1%"/>
<label proportion="1" id="compare-ghost-text" height="100%" text_align="left" I18N="Ghost replay info action" text="Compare to another ghost"/>
</div>
<bubble id="info" width="100%" proportion="1" word_wrap="true"/>
</div>

<div width="95%" height="40%" align="center">
Expand Down
9 changes: 9 additions & 0 deletions src/replay/replay_play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ bool ReplayPlay::addReplayFile(const std::string& fn, bool custom_replay, int ca
rd.m_track = t;

fgets(s, 1023, fd);
if (sscanf(s, "info: %1023s", s1) == 1)
{
int last = strlen(s);
if (s[last - 1] == '\n')
s[last - 1] = '\0';

rd.m_info = s + 6;
fgets(s, 1023, fd);
}
if (sscanf(s, "laps: %u", &rd.m_laps) != 1)
{
Log::warn("Replay", "No number of laps found in replay file, '%s'.", fn.c_str());
Expand Down
1 change: 1 addition & 0 deletions src/replay/replay_play.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ReplayPlay : public ReplayBase
std::string m_minor_mode;
core::stringw m_stk_version;
core::stringw m_user_name;
core::stringw m_info;
std::vector<std::string> m_kart_list;
std::vector<core::stringw> m_name_list;
std::vector<float> m_kart_color; //no sorting for this
Expand Down
6 changes: 5 additions & 1 deletion src/states_screens/dialogs/ghost_replay_info_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "config/player_manager.hpp"
#include "guiengine/CGUISpriteBank.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "guiengine/widgets/bubble_widget.hpp"
#include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
Expand All @@ -43,7 +44,7 @@ using namespace irr::core;
// -----------------------------------------------------------------------------
GhostReplayInfoDialog::GhostReplayInfoDialog(unsigned int replay_id,
uint64_t compare_replay_uid, bool compare_ghost)
: ModalDialog(0.95f,0.75f), m_replay_id(replay_id)
: ModalDialog(0.95f,0.9f), m_replay_id(replay_id)
{
m_self_destroy = false;
m_record_race = false;
Expand All @@ -56,6 +57,9 @@ GhostReplayInfoDialog::GhostReplayInfoDialog(unsigned int replay_id,

loadFromFile("ghost_replay_info_dialog.stkgui");

m_info_widget = getWidget<BubbleWidget>("info");
m_info_widget->setText(m_rd.m_info);

Track* track = track_manager->getTrack(m_rd.m_track_name);

m_track_screenshot_widget = getWidget<IconButtonWidget>("track_screenshot");
Expand Down
2 changes: 2 additions & 0 deletions src/states_screens/dialogs/ghost_replay_info_dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace GUIEngine
{
class BubbleWidget;
class CheckBoxWidget; class IconButtonWidget; class ListWidget;
class RibbonWidget;
}
Expand All @@ -48,6 +49,7 @@ class GhostReplayInfoDialog : public GUIEngine::ModalDialog

ReplayPlay::ReplayData m_rd;

GUIEngine::BubbleWidget* m_info_widget;
GUIEngine::RibbonWidget* m_action_widget;
GUIEngine::IconButtonWidget* m_back_widget;
GUIEngine::CheckBoxWidget* m_record_widget;
Expand Down

0 comments on commit 9805f0c

Please sign in to comment.