Opened 2 years ago

Closed 20 months ago

Last modified 19 months ago

#3437 closed enhancement (fixed)

Add link from summary screen to replay

Reported by: elexis Owned by: Imarok
Priority: Nice to Have Milestone: Alpha 21
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

Adding a link to replay the game you just played (or replayed) to the summary screen would be great.

In case the user played a lobby game, it should display a message box confirming that the user wants to leave the lobby. Don't forget to actually end the XmppConnection in that case.

Attachments (8)

replaybutton_v2.patch (4.8 KB) - added by Imarok 20 months ago.
Adds a button which replays the game to the summary of a quit game or the summary preview of a replay
replaybutton_v3.patch (5.5 KB) - added by Imarok 20 months ago.
Adds a button which replays the game to the summary of a quit game or the summary preview of a replay or the summary of a replay
replaybutton_v3.1.patch (5.4 KB) - added by Imarok 20 months ago.
Adds a button which replays the game to the summary of a quit game or the summary preview of a replay or the summary of a replay
replaybutton_v3.2.patch (5.3 KB) - added by Imarok 20 months ago.
Adds a button which replays the game to the summary of a quit game or the summary preview of a replay or the summary of a replay
replaybutton_v3.3.patch (5.4 KB) - added by Imarok 20 months ago.
Adds a button which replays the game to the summary of a quit game or the summary preview of a replay or the summary of a replay
replaybutton_v3.4.patch (5.4 KB) - added by Imarok 20 months ago.
Adding suggestions of elexis
rejoining_replay.patch (1.1 KB) - added by Imarok 19 months ago.
Don't show the replay button when game was rejoined
rejoining_replay_v2.patch (1.1 KB) - added by Imarok 19 months ago.
Added semikolon and whitespace.

Download all attachments as: .zip

Change History (21)

comment:1 Changed 23 months ago by leper

Keywords: simple added

comment:2 Changed 20 months ago by Imarok

Owner: set to Imarok

comment:3 Changed 20 months ago by Imarok

How can I call the right replay in this situation?

comment:4 Changed 20 months ago by elexis

The replaylogger determines the filename in CReplayLogger::StartGame of Replay.cpp (which is called from CGame::StartGame).

It should be sufficient to add a new function GetCurrentReplayFile to ScriptFunctions.cpp, which returns that path (likely need to add getter-function to access the path).

When session.js is loaded, the game had been started already. So before ending the game in leaveGame, you can learn the filename with Engine.GetCurrentReplayFile(); and pass it to the summary screen data created in that function.

The summary screen should have a new button to start the given replay.

In case of being connected to the lobby (Engine.HasXmppClient()) you should either disconnect (Engine.StopXmppClient();) before starting the replay or return to the lobby after it has ended.

comment:5 Changed 20 months ago by Imarok

This returns an absolute path like C:\Users\username\Documents\My Games\0ad\replays\0.0.21\2016-04-13_0008 I need just 2016-04-13_0008 Is there a way to get this relative path?

comment:6 Changed 20 months ago by sanderd17

str.split(/[\/\\]/).pop() ?

comment:7 Changed 20 months ago by elexis

As it's an OsPath, you should be able to use functions from path.h like Parent and Filename. The latter looks like it would do that.

Changed 20 months ago by Imarok

Attachment: replaybutton_v2.patch added

Adds a button which replays the game to the summary of a quit game or the summary preview of a replay

comment:8 Changed 20 months ago by Imarok

Keywords: review patch added
Milestone: BacklogAlpha 21

Changed 20 months ago by Imarok

Attachment: replaybutton_v3.patch added

Adds a button which replays the game to the summary of a quit game or the summary preview of a replay or the summary of a replay

Changed 20 months ago by Imarok

Attachment: replaybutton_v3.1.patch added

Adds a button which replays the game to the summary of a quit game or the summary preview of a replay or the summary of a replay

Changed 20 months ago by Imarok

Attachment: replaybutton_v3.2.patch added

Adds a button which replays the game to the summary of a quit game or the summary preview of a replay or the summary of a replay

Changed 20 months ago by Imarok

Attachment: replaybutton_v3.3.patch added

Adds a button which replays the game to the summary of a quit game or the summary preview of a replay or the summary of a replay

comment:9 Changed 20 months ago by elexis

Keywords: simple removed

Thanks for the patch, few minor style issues remaining, then it should be ready to go:

  • Since you need the directory but not the file, you should rename GetCurrentReplayFile to GetCurrentReplayDirectory
  • Check for if (!g_Game) instead of if (g_Game == NULL) (as all the other places in that file do)
  • Return an empty string (std::wstring()) instead of NULL
  • The new scriptfunction seems to fit better below IsVisualReplay
  • (The other places in Game.h have the braces and the return in the same line, so you may or may not conform to this).
  • Adding the same sentence to the ticket for every uploaded patch doesn't help much.

As mentioned before in IRC:

  • missing space: "local":{ (wiki:Coding_Conventions)
  • If you are going to use a ternary operator there, then add a newline after ? and :, so that the conditions are easy to read (operators should be at the end of a newline, not in the beginning of the newline) (An if-return-return pattern like in the other scriptfunctions would also work)
Last edited 20 months ago by elexis (previous) (diff)

comment:10 in reply to:  9 Changed 20 months ago by Imarok

Replying to elexis:

  • Adding the same sentence to the ticket for every uploaded patch doesn't help much.

I thought this would be the sentence displayed in the changeset, when you add the patch to svn. So I just described the overall functionality of the patch, which hasn't changed since v3.

Changed 20 months ago by Imarok

Attachment: replaybutton_v3.4.patch added

Adding suggestions of elexis

comment:11 Changed 20 months ago by elexis

Resolution: fixed
Status: newclosed

In 18031:

Add a button to the summary screen to replay the game that was just played (or replayed). Patch by Imarok, fixes #3437.

comment:12 Changed 20 months ago by elexis

Keywords: review removed

Thanks!

Changed 19 months ago by Imarok

Attachment: rejoining_replay.patch added

Don't show the replay button when game was rejoined

Changed 19 months ago by Imarok

Attachment: rejoining_replay_v2.patch added

Added semikolon and whitespace.

comment:13 Changed 19 months ago by elexis

In 18103:

Hide the link to the replay in the summary screen if the client rejoined, since the replay doesn't work in that case.
Patch by Imarok, refs #3437.

Note: See TracTickets for help on using tickets.