Opened 9 years ago

Closed 8 years ago

Last modified 8 years 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 8 years 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 8 years 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 8 years 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 8 years 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 8 years 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 8 years ago.
Adding suggestions of elexis
rejoining_replay.patch (1.1 KB ) - added by Imarok 8 years ago.
Don't show the replay button when game was rejoined
rejoining_replay_v2.patch (1.1 KB ) - added by Imarok 8 years ago.
Added semikolon and whitespace.

Download all attachments as: .zip

Change History (21)

comment:1 by leper, 8 years ago

Keywords: simple added

comment:2 by Imarok, 8 years ago

Owner: set to Imarok

comment:3 by Imarok, 8 years ago

How can I call the right replay in this situation?

comment:4 by elexis, 8 years ago

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 by Imarok, 8 years ago

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 by sanderd17, 8 years ago

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

comment:7 by elexis, 8 years ago

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.

by Imarok, 8 years ago

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 by Imarok, 8 years ago

Keywords: review patch added
Milestone: BacklogAlpha 21

by Imarok, 8 years ago

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

by Imarok, 8 years ago

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

by Imarok, 8 years ago

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

by Imarok, 8 years ago

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 by elexis, 8 years ago

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
  • 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)
Version 0, edited 8 years ago by elexis (next)

in reply to:  9 comment:10 by Imarok, 8 years ago

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.

by Imarok, 8 years ago

Attachment: replaybutton_v3.4.patch added

Adding suggestions of elexis

comment:11 by elexis, 8 years ago

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 by elexis, 8 years ago

Keywords: review removed

Thanks!

by Imarok, 8 years ago

Attachment: rejoining_replay.patch added

Don't show the replay button when game was rejoined

by Imarok, 8 years ago

Attachment: rejoining_replay_v2.patch added

Added semikolon and whitespace.

comment:13 by elexis, 8 years ago

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.