Ticket #2385: modsloaded.diff
File modsloaded.diff, 5.8 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/gui/savedgames/load.js
3 3 var gameSelection = Engine.GetGUIObjectByName("gameSelection"); 4 4 5 5 var savedGames = Engine.GetSavedGames(); 6 7 var sameMods = Engine.GetGUIObjectByName("modsSelection").checked; 8 if (sameMods) 9 { 10 var modsLoaded = Engine.GetModsLoaded(); 11 savedGames = savedGames.filter(function(game) { 12 if (!game.metadata.mods) 13 return true; // temporary, for backward compatibility 14 var gameMods = game.metadata.mods; 15 if (modsLoaded.length != gameMods.length) 16 return false; 17 for (var i = 0; i < modsLoaded.length; ++i) 18 if (modsLoaded[i] != gameMods[i]) 19 return false; 20 return true; 21 }); 22 } 23 6 24 if (savedGames.length == 0) 7 25 { 8 26 gameSelection.list = [ "No saved games found" ]; -
binaries/data/mods/public/gui/savedgames/load.xml
21 21 size="24 24 100%-24 100%-100"> 22 22 </object> 23 23 24 <object type="image" size="50 100%-90 100%-50 100%-70"> 25 <object name="modsSelection" size="0 10% 16 90%" type="checkbox" style="StoneCrossBox"> 26 <action on="Load">this.checked = true;</action> 27 <action on="Press">init();</action> 28 </object> 29 <object size="25 0 100% 100%" type="text" style="LeftLabelText" ghost="true">Show only games with the current mod</object> 30 </object> 31 24 32 <object name="loadGameButton" type="button" size="0%+25 100%-60 33%+10 100%-32" style="StoneButton"> 25 33 Load 26 34 <action on="Press">loadGame();</action> -
source/gui/scripting/ScriptFunctions.cpp
194 194 g_Game->SetPlayerID(id); 195 195 } 196 196 197 std::vector<std::string> GetModsLoaded(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) 198 { 199 return g_modsLoaded; 200 } 201 197 202 void StartNetworkGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) 198 203 { 199 204 ENSURE(g_NetServer); … … 841 846 scriptInterface.RegisterFunction<void, &RestartInAtlas>("RestartInAtlas"); 842 847 scriptInterface.RegisterFunction<bool, &AtlasIsAvailable>("AtlasIsAvailable"); 843 848 scriptInterface.RegisterFunction<bool, &IsAtlasRunning>("IsAtlasRunning"); 849 scriptInterface.RegisterFunction<std::vector<std::string>, &GetModsLoaded>("GetModsLoaded"); 844 850 scriptInterface.RegisterFunction<CScriptVal, VfsPath, &LoadMapSettings>("LoadMapSettings"); 845 851 scriptInterface.RegisterFunction<CScriptVal, &GetMapSettings>("GetMapSettings"); 846 852 scriptInterface.RegisterFunction<float, &CameraGetX>("CameraGetX"); -
source/main.cpp
421 421 if(ran_atlas) 422 422 return; 423 423 424 g_modsLoaded.clear(); 424 425 // run non-visual simulation replay if requested 425 426 if (args.Has("replay")) 426 427 { … … 429 430 g_VFS = CreateVfs(20 * MiB); 430 431 g_VFS->Mount(L"cache/", paths.Cache(), VFS_MOUNT_ARCHIVABLE); 431 432 g_VFS->Mount(L"", paths.RData()/"mods"/"public", VFS_MOUNT_MUST_EXIST); 432 433 433 { 434 434 CReplayPlayer replay; 435 435 replay.Load(args.Get("replay")); … … 464 464 const double res = timer_Resolution(); 465 465 g_frequencyFilter = CreateFrequencyFilter(res, 30.0); 466 466 467 std::vector<CStr> modsLoaded = args.GetMultiple("mod"); 468 for (size_t i = 0; i < modsLoaded.size(); ++i) 469 g_modsLoaded.push_back((std::string)modsLoaded[i]); 467 470 // run the game 468 471 Init(args, 0); 469 472 InitGraphics(args, 0); -
source/ps/GameSetup/Config.cpp
76 76 // If non-empty, specified map will be automatically loaded 77 77 CStr g_AutostartMap = ""; 78 78 79 std::vector<std::string> g_modsLoaded; 79 80 81 80 82 //---------------------------------------------------------------------------- 81 83 // config 82 84 //---------------------------------------------------------------------------- -
source/ps/GameSetup/Config.h
90 90 91 91 extern CStrW g_CursorName; 92 92 93 // list of mods currently loaded 94 extern std::vector<std::string> g_modsLoaded; 95 93 96 class CmdLineArgs; 94 97 extern void CONFIG_Init(const CmdLineArgs& args); 95 98 -
source/ps/SavedGame.cpp
24 24 #include "lib/file/archive/archive_zip.h" 25 25 #include "ps/CLogger.h" 26 26 #include "ps/Filesystem.h" 27 #include "ps/GameSetup/Config.h" 27 28 #include "scriptinterface/ScriptInterface.h" 28 29 #include "simulation2/Simulation2.h" 29 30 … … 76 77 simulation.GetScriptInterface().Eval("({})", metadata); 77 78 simulation.GetScriptInterface().SetProperty(metadata.get(), "version_major", SAVED_GAME_VERSION_MAJOR); 78 79 simulation.GetScriptInterface().SetProperty(metadata.get(), "version_minor", SAVED_GAME_VERSION_MINOR); 80 simulation.GetScriptInterface().SetProperty(metadata.get(), "mods", g_modsLoaded); 79 81 simulation.GetScriptInterface().SetProperty(metadata.get(), "time", (double)now); 80 82 simulation.GetScriptInterface().SetProperty(metadata.get(), "player", playerID); 81 83 simulation.GetScriptInterface().SetProperty(metadata.get(), "initAttributes", simulation.GetInitAttributes());