Ticket #3437: replaybutton_v3.1.patch
File replaybutton_v3.1.patch, 5.4 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/replaymenu/replay_actions.js
79 79 // Open summary screen 80 80 summary.isReplay = true; 81 81 summary.gameResult = translate("Scores at the end of the game."); 82 summary.replayDirectory = g_ReplaysFiltered[selected].directory; 82 83 Engine.SwitchGuiPage("page_summary.xml", summary); 83 84 } 84 85 -
binaries/data/mods/public/gui/session/session.js
472 472 if (!g_IsReplay) 473 473 Engine.SaveReplayMetadata(JSON.stringify(summary)); 474 474 475 summary.replayDirectory = Engine.GetCurrentReplayFile(); 476 475 477 Engine.EndGame(); 476 478 477 479 if (g_IsController && Engine.HasXmppClient()) -
binaries/data/mods/public/gui/summary/summary.js
129 129 teamCounterFn(panelInfo.counters); 130 130 } 131 131 132 function startReplay() 133 { 134 if (Engine.HasXmppClient()) 135 Engine.StopXmppClient(); 136 137 Engine.StartVisualReplay(g_GameData.replayDirectory); 138 Engine.SwitchGuiPage("page_loading.xml", { 139 "attribs": Engine.GetReplayAttributes(g_GameData.replayDirectory), 140 "isNetworked" : false, 141 "playerAssignments": { 142 "local":{ 143 "name": translate("You"), 144 "player": -1 145 } 146 }, 147 "savedGUIData": "", 148 "isReplay" : true 149 }); 150 } 151 132 152 function init(data) 133 153 { 134 154 updateObjectPlayerPosition(); … … 139 159 Engine.GetGUIObjectByName("timeElapsed").caption = sprintf(translate("Game time elapsed: %(time)s"), { "time": timeToString(data.timeElapsed) }); 140 160 Engine.GetGUIObjectByName("summaryText").caption = data.gameResult; 141 161 Engine.GetGUIObjectByName("mapName").caption = sprintf(translate("%(mapName)s - %(mapType)s"), { "mapName": translate(data.mapSettings.Name), "mapType": mapSize ? mapSize.LongName : (mapType ? mapType.Title : "") }); 162 Engine.GetGUIObjectByName("replayButton").hidden = g_GameData.isInGame || !g_GameData.replayDirectory; 142 163 143 164 // Panels 144 165 g_PlayerCount = data.playerStates.length - 1; -
binaries/data/mods/public/gui/summary/summary.xml
157 157 </object> 158 158 </object> 159 159 160 <object type="button" name="replayButton" style="ModernButtonRed" size="100%-310 100%-48 100%-170 100%-20"> 161 <translatableAttribute id="caption">Replay</translatableAttribute> 162 <action on="Press"><![CDATA[ 163 if (!g_GameData.isInGame) 164 { 165 if (Engine.HasXmppClient()) 166 messageBox( 167 400, 200, 168 translate("Are you sure you want to quit the lobby?"), 169 translate("Confirmation"), 170 0, 171 [translate("No"), translate("Yes")], 172 [null, startReplay] 173 ); 174 else 175 startReplay(); 176 } 177 ]]> 178 </action> 179 </object> 180 160 181 <object type="button" style="ModernButtonRed" size="100%-160 100%-48 100%-20 100%-20"> 161 182 <translatableAttribute id="caption">Continue</translatableAttribute> 162 183 <action on="Press"><![CDATA[ -
source/gui/scripting/ScriptFunctions.cpp
50 50 #include "ps/Hotkey.h" 51 51 #include "ps/ProfileViewer.h" 52 52 #include "ps/Pyrogenesis.h" 53 #include "ps/Replay.h" 53 54 #include "ps/SavedGame.h" 54 55 #include "ps/UserReport.h" 55 56 #include "ps/World.h" … … 902 903 return width; 903 904 } 904 905 906 OsPath GetCurrentReplayFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) 907 { 908 if (g_Game->GetReplayLogger().GetDirectory().Filename() != "") 909 return g_Game->GetReplayLogger().GetDirectory().Filename(); 910 else 911 { 912 OsPath dir = OsPath(g_Game->GetReplayPath()); 913 dir = dir.BeforeCommon(dir.Filename()); 914 dir = dir.Parent().Filename(); 915 return dir.Filename(); 916 } 917 } 918 905 919 //----------------------------------------------------------------------------- 906 920 // Timer 907 921 //----------------------------------------------------------------------------- … … 1079 1093 scriptInterface.RegisterFunction<bool, std::string, &TemplateExists>("TemplateExists"); 1080 1094 scriptInterface.RegisterFunction<CParamNode, std::string, &GetTemplate>("GetTemplate"); 1081 1095 scriptInterface.RegisterFunction<int, CStr, CStrW, &GetTextWidth>("GetTextWidth"); 1096 scriptInterface.RegisterFunction<OsPath, &GetCurrentReplayFile>("GetCurrentReplayFile"); 1082 1097 1083 1098 // User report functions 1084 1099 scriptInterface.RegisterFunction<bool, &IsUserReportEnabled>("IsUserReportEnabled"); -
source/ps/Game.h
161 161 inline float GetSimRate() const 162 162 { return m_SimRate; } 163 163 164 inline std::string GetReplayPath() const 165 { 166 return m_ReplayPath; 167 } 168 164 169 /** 165 170 * Replace the current turn manager. 166 171 * This class will take ownership of the pointer.