Ticket #3446: t3446_catch_SDL_QUIT_v1.patch
File t3446_catch_SDL_QUIT_v1.patch, 2.1 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/replaymenu/replay_menu.js
function init() 41 41 42 42 // By default, sort replays by date in descending order 43 43 Engine.GetGUIObjectByName("replaySelection").selected_column_order = -1; 44 44 45 45 loadReplays(); 46 47 if (!g_Replays) 48 { 49 Engine.SwitchGuiPage("page_pregame.xml"); 50 return; 51 } 52 46 53 displayReplayList(); 47 54 } 48 55 49 56 /** 50 57 * Store the list of replays loaded in C++ in g_Replays. … … function init() 52 59 */ 53 60 function loadReplays() 54 61 { 55 62 g_Replays = Engine.GetReplays(); 56 63 64 if (!g_Replays) 65 return; 66 57 67 g_Playernames = []; 58 68 for (let replay of g_Replays) 59 69 { 60 70 // Use time saved in file, otherwise file mod date 61 71 replay.timestamp = replay.attribs.timestamp ? +replay.attribs.timestamp : +replay.filemod_timestamp; -
source/ps/VisualReplay.cpp
19 19 20 20 #include "VisualReplay.h" 21 21 #include "graphics/GameView.h" 22 22 #include "gui/GUIManager.h" 23 23 #include "lib/allocators/shared_ptr.h" 24 #include "lib/external_libraries/libsdl.h" 24 25 #include "lib/utf8.h" 25 26 #include "ps/CLogger.h" 26 27 #include "ps/Filesystem.h" 27 28 #include "ps/Game.h" 28 29 #include "ps/Pyrogenesis.h" … … JS::Value VisualReplay::GetReplays(Scrip 50 51 JSContext* cx = scriptInterface.GetContext(); 51 52 JSAutoRequest rq(cx); 52 53 53 54 u32 i = 0; 54 55 DirectoryNames directories; 56 57 SDL_Event event; 55 58 JS::RootedObject replays(cx, JS_NewArrayObject(cx, 0)); 59 56 60 if (GetDirectoryEntries(GetDirectoryName(), NULL, &directories) == INFO::OK) 57 61 for (OsPath& directory : directories) 58 62 { 63 if (SDL_PollEvent(&event) && event.type == SDL_QUIT) 64 return JSVAL_NULL; 65 59 66 JS::RootedValue replayData(cx, LoadReplayData(scriptInterface, directory)); 60 67 if (!replayData.isNull()) 61 68 JS_SetElement(cx, replays, i++, replayData); 62 69 } 63 70 return JS::ObjectValue(*replays);