Changeset 28145
- Timestamp:
- Jul 8, 2024, 9:07:04 PM (3 weeks ago)
- Location:
- ps/trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/binaries/data/mods/_test.gui/gui/regainFocus/pushWithPopOnInit.js
r25616 r28145 1 Engine.PushGuiPage("regainFocus/page_emptyPage.xml" , {}, () => Engine.PopGuiPage());1 Engine.PushGuiPage("regainFocus/page_emptyPage.xml"); -
ps/trunk/binaries/data/mods/mod/gui/common/functions_msgbox.js
r27188 r28145 1 function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbButtonCaptions, mbBtnCode, mbCallbackArgs) 1 async function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbButtonCaptions, mbBtnCode, 2 mbCallbackArgs) 2 3 { 3 Engine.PushGuiPage(4 Engine.PushGuiPage( 4 5 "page_msgbox.xml", 5 6 { … … 9 10 "title": mbTitle, 10 11 "buttonCaptions": mbButtonCaptions 11 },12 btnCode => {13 if (mbBtnCode !== undefined && mbBtnCode[btnCode])14 mbBtnCode[btnCode](mbCallbackArgs ? mbCallbackArgs[btnCode] : undefined);15 12 }); 13 14 15 16 16 } 17 17 18 function timedConfirmation(width, height, message, timeParameter, timeout, title, buttonCaptions, btnCode, callbackArgs) 18 async function timedConfirmation(width, height, message, timeParameter, timeout, title, buttonCaptions, 19 btnCode, callbackArgs) 19 20 { 20 Engine.PushGuiPage(21 Engine.PushGuiPage( 21 22 "page_timedconfirmation.xml", 22 23 { … … 28 29 "title": title, 29 30 "buttonCaptions": buttonCaptions 30 },31 button => {32 if (btnCode !== undefined && btnCode[button])33 btnCode[button](callbackArgs ? callbackArgs[button] : undefined);34 31 }); 35 }36 32 37 function colorMixer(color, callback) 38 { 39 Engine.PushGuiPage( 40 "page_colormixer.xml", 41 color, 42 result => { 43 callback(result); 44 } 45 ); 33 if (btnCode !== undefined && btnCode[button]) 34 btnCode[button](callbackArgs ? callbackArgs[button] : undefined); 46 35 } 47 36 -
ps/trunk/binaries/data/mods/mod/gui/common/terms.js
r27195 r28145 6 6 } 7 7 8 function openTerms(page)8 function openTerms(page) 9 9 { 10 Engine.PushGuiPage(10 Engine.PushGuiPage( 11 11 "page_termsdialog.xml", 12 12 { … … 17 17 "termsURL": g_Terms[page].termsURL || undefined, 18 18 "page": page 19 }, 20 data => { 21 g_Terms[data.page].accepted = data.accepted; 19 }); 22 20 23 Engine.ConfigDB_CreateAndSaveValue( 24 "user", 25 g_Terms[data.page].config, 26 data.accepted ? getTermsHash(data.page) : "0"); 21 g_Terms[data.page].accepted = data.accepted; 27 22 28 if (g_Terms[data.page].callback) 29 g_Terms[data.page].callback(data); 30 } 31 ); 23 Engine.ConfigDB_CreateAndSaveValue( 24 "user", 25 g_Terms[data.page].config, 26 data.accepted ? getTermsHash(data.page) : "0"); 27 28 if (g_Terms[data.page].callback) 29 g_Terms[data.page].callback(data); 32 30 } 33 31 -
ps/trunk/binaries/data/mods/mod/gui/modmod/modmodio.js
r22676 r28145 24 24 } 25 25 26 function openModIo(data)26 function openModIo(data) 27 27 { 28 if (data.accepted) 29 Engine.PushGuiPage("page_modio.xml", {}, initMods); 28 if (!data.accepted) 29 return; 30 31 await Engine.PushGuiPage("page_modio.xml"); 32 initMods(); 30 33 } -
ps/trunk/binaries/data/mods/public/gui/campaigns/default_menu/CampaignMenu.js
r27867 r28145 20 20 Engine.GetGUIObjectByName('startButton').onPress = () => this.startScenario(); 21 21 Engine.GetGUIObjectByName('backToMain').onPress = () => this.goBackToMainMenu(); 22 Engine.GetGUIObjectByName('savedGamesButton').onPress = Engine.PushGuiPage.bind(Engine, 23 'page_loadgame.xml', { "campaignRun": this.run.filename }, this.loadSavegame.bind(this)); 22 Engine.GetGUIObjectByName('savedGamesButton').onPress = this.loadSavegame.bind(this); 24 23 25 24 this.mapCache = new MapCache(); … … 28 27 } 29 28 30 loadSavegame(gameId) 31 { 29 async loadSavegame() 30 { 31 const gameId = await Engine.PushGuiPage( 32 'page_loadgame.xml', 33 { 34 "campaignRun": this.run.filename 35 }); 36 32 37 if (!gameId) 33 38 return; -
ps/trunk/binaries/data/mods/public/gui/common/functions_utility.js
r28085 r28145 289 289 * That continues untill there is no @a nextPage property in the completion 290 290 * value. If there is no @a nextPage in the completion value the 291 * @a co ntinuation is called with the completion value.291 * @a co. 292 292 * @param {String} page - The page first opened. 293 293 * @param args - passed to the first page opened. 294 * @param continuation {function | undefined} - Completion callback, called when 295 * there is no @a nextPage property in the completion value. 296 */ 297 function pageLoop(page, args, continuation) 298 { 299 (function recursiveFunction(completionValue) 300 { 301 if (completionValue?.nextPage != null) 302 Engine.PushGuiPage(completionValue.nextPage, completionValue.args, recursiveFunction); 303 else 304 continuation?.(completionValue); 305 })({ "nextPage": page, "args": args }); 306 } 294 */ 295 async function pageLoop(page, args) 296 { 297 let completionValue = { "nextPage": page, "args": args }; 298 while (completionValue?.nextPage != null) 299 completionValue = await Engine.PushGuiPage(completionValue.nextPage, completionValue.args); 300 301 return completionValue; 302 } -
ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CivInfoButton.js
r28085 r28145 24 24 } 25 25 26 openPage(page)26 openPage(page) 27 27 { 28 pageLoop(page, this.civInfo.args, data => this.civInfo = data);28 ); 29 29 } 30 30 } -
ps/trunk/binaries/data/mods/public/gui/locale/locale.js
r22966 r28145 53 53 } 54 54 55 function openAdvancedMenu()55 function openAdvancedMenu() 56 56 { 57 57 let localeText = Engine.GetGUIObjectByName("localeText"); 58 Engine.PushGuiPage("page_locale_advanced.xml", { "locale": localeText.caption }, applyFromAdvancedMenu); 59 } 58 const locale = await Engine.PushGuiPage("page_locale_advanced.xml", { "locale": localeText.caption }); 60 59 61 function applyFromAdvancedMenu(locale)62 {63 60 if (!locale) 64 61 return; … … 73 70 languageList.selected = index; 74 71 75 var localeText = Engine.GetGUIObjectByName("localeText");76 72 localeText.caption = locale; 77 73 } -
ps/trunk/binaries/data/mods/public/gui/options/options.js
r28010 r28145 81 81 }, 82 82 "initGUI": (option, control) => { 83 control.children[2].onPress = () => { 84 colorMixer( 85 control.caption, 86 (color) => { 87 if (color != control.caption) 88 { 89 control.caption = color; 90 control.onTextEdit(); 91 } 92 } 93 ); 83 control.children[2].onPress = async() => { 84 const color = await Engine.PushGuiPage("page_colormixer.xml", control.caption); 85 86 if (color != control.caption) 87 { 88 control.caption = color; 89 control.onTextEdit(); 90 } 94 91 }; 95 92 }, -
ps/trunk/binaries/data/mods/public/gui/pregame/MainMenuItems.js
r28085 r28145 91 91 "caption": translate("Load Game"), 92 92 "tooltip": translate("Load a saved game."), 93 "onPress": Engine.PushGuiPage.bind(Engine, "page_loadgame.xml", {}, (gameId) => 93 "onPress": async() => { 94 const gameId = await Engine.PushGuiPage("page_loadgame.xml"); 95 96 if (!gameId) 97 return; 98 99 const metadata = Engine.StartSavedGame(gameId); 100 if (!metadata) 94 101 { 95 if (!gameId) 96 return; 102 error("Could not load saved game: " + gameId); 103 return; 104 } 97 105 98 const metadata = Engine.StartSavedGame(gameId); 99 if (!metadata) 100 { 101 error("Could not load saved game: " + gameId); 102 return; 103 } 104 105 Engine.SwitchGuiPage("page_loading.xml", { 106 "attribs": metadata.initAttributes, 107 "playerAssignments": { 108 "local": { 109 "name": metadata.initAttributes.settings. 110 PlayerData[metadata.playerID]?.Name ?? 111 singleplayerName(), 112 "player": metadata.playerID 113 } 114 }, 115 "savedGUIData": metadata.gui 116 }); 117 }) 106 Engine.SwitchGuiPage("page_loading.xml", { 107 "attribs": metadata.initAttributes, 108 "playerAssignments": { 109 "local": { 110 "name": metadata.initAttributes.settings. 111 PlayerData[metadata.playerID]?.Name ?? 112 singleplayerName(), 113 "player": metadata.playerID 114 } 115 }, 116 "savedGUIData": metadata.gui 117 }); 118 } 118 119 }, 119 120 { … … 222 223 "caption": translate("Options"), 223 224 "tooltip": translate("Adjust game settings."), 224 "onPress": () => { 225 Engine.PushGuiPage( 226 "page_options.xml", 227 {}, 228 fireConfigChangeHandlers); 225 "onPress": async() => { 226 fireConfigChangeHandlers(await Engine.PushGuiPage("page_options.xml")); 229 227 } 230 228 }, -
ps/trunk/binaries/data/mods/public/gui/session/MenuButtons.js
r25083 r28145 17 17 } 18 18 19 onPress() 20 { 21 closeOpenDialogs(); 22 this.pauseControl.implicitPause(); 23 Engine.PushGuiPage("page_manual.xml", {}, resumeGame); 19 async onPress() 20 { 21 closeOpenDialogs(); 22 this.pauseControl.implicitPause(); 23 await Engine.PushGuiPage("page_manual.xml"); 24 resumeGame(); 24 25 } 25 26 }; … … 55 56 } 56 57 57 onPress()58 { 59 closeOpenDialogs(); 60 this.pauseControl.implicitPause(); 61 62 Engine.PushGuiPage(58 onPress() 59 { 60 closeOpenDialogs(); 61 this.pauseControl.implicitPause(); 62 63 Engine.PushGuiPage( 63 64 "page_loadgame.xml", 64 65 { 65 66 "savedGameData": getSavedGameData(), 66 67 "campaignRun": g_CampaignSession ? g_CampaignSession.run.filename : null 67 } ,68 resumeGame);68 } 69 ); 69 70 } 70 71 }; … … 93 94 } 94 95 95 onPress()96 onPress() 96 97 { 97 98 if (Engine.IsAtlasRunning()) … … 103 104 // If they have shared ally vision researched, they are able to see the summary of there allies too. 104 105 let simState = Engine.GuiInterfaceCall("GetExtendedSimulationState"); 105 Engine.PushGuiPage(106 Engine.PushGuiPage( 106 107 "page_summary.xml", 107 108 { … … 118 119 "summarySelection": this.summarySelection 119 120 }, 120 },121 data => {122 this.summarySelection = data.summarySelection;123 this.pauseControl.implicitResume();124 121 }); 122 123 124 125 125 } 126 126 }; … … 163 163 } 164 164 165 onPress() 166 { 167 closeOpenDialogs(); 168 this.pauseControl.implicitPause(); 169 170 Engine.PushGuiPage( 171 "page_options.xml", 172 {}, 173 changes => { 174 fireConfigChangeHandlers(changes); 175 resumeGame(); 176 }); 165 async onPress() 166 { 167 closeOpenDialogs(); 168 this.pauseControl.implicitPause(); 169 170 fireConfigChangeHandlers(await Engine.PushGuiPage("page_options.xml")); 171 resumeGame(); 177 172 } 178 173 }; … … 187 182 } 188 183 189 onPress() 190 { 191 closeOpenDialogs(); 192 this.pauseControl.implicitPause(); 193 194 Engine.PushGuiPage( 195 "hotkeys/page_hotkeys.xml", 196 {}, 197 () => { resumeGame(); }); 184 async onPress() 185 { 186 closeOpenDialogs(); 187 this.pauseControl.implicitPause(); 188 189 await Engine.PushGuiPage("hotkeys/page_hotkeys.xml"); 190 resumeGame(); 198 191 } 199 192 }; -
ps/trunk/binaries/data/mods/public/gui/session/SessionMessageBox.js
r27883 r28145 5 5 class SessionMessageBox 6 6 { 7 display()7 display() 8 8 { 9 this.onPageOpening(); 9 closeOpenDialogs(); 10 g_PauseControl.implicitPause(); 10 11 11 Engine.PushGuiPage(12 Engine.PushGuiPage( 12 13 "page_msgbox.xml", 13 14 { … … 17 18 "message": this.Caption, 18 19 "buttonCaptions": this.Buttons ? this.Buttons.map(button => button.caption) : undefined, 19 }, 20 this.onPageClosed.bind(this)); 21 } 20 }); 22 21 23 onPageOpening()24 {25 closeOpenDialogs();26 g_PauseControl.implicitPause();27 }28 29 onPageClosed(buttonId)30 {31 22 if (this.Buttons && this.Buttons[buttonId].onPress) 32 23 this.Buttons[buttonId].onPress.call(this); -
ps/trunk/binaries/data/mods/public/gui/session/selection_panels.js
r27886 r28145 1263 1263 * @param {string} [civCode] - The template name of the entity that researches the selected technology. 1264 1264 */ 1265 function showTemplateDetails(templateName, civCode)1265 function showTemplateDetails(templateName, civCode) 1266 1266 { 1267 1267 if (inputState != INPUT_NORMAL) … … 1269 1269 g_PauseControl.implicitPause(); 1270 1270 1271 Engine.PushGuiPage(1271 Engine.PushGuiPage( 1272 1272 "page_viewer.xml", 1273 1273 { 1274 1274 "templateName": templateName, 1275 1275 "civ": civCode 1276 } ,1277 resumeGame);1276 } 1277 ); 1278 1278 } 1279 1279 -
ps/trunk/binaries/data/mods/public/gui/session/top_panel/CivIcon.js
r28085 r28145 30 30 } 31 31 32 openPage(page)32 openPage(page) 33 33 { 34 34 closeOpenDialogs(); 35 35 g_PauseControl.implicitPause(); 36 36 37 pageLoop(37 pageLoop( 38 38 page, 39 39 { … … 43 43 44 44 // TODO add info about researched techs and unlocked entities 45 },46 data =>47 {48 this.dialogSelection = data;49 resumeGame();50 45 }); 46 51 47 } 52 48 -
ps/trunk/source/gui/GUIManager.cpp
r28131 r28145 31 31 #include "scriptinterface/FunctionWrapper.h" 32 32 #include "scriptinterface/Object.h" 33 33 34 #include "scriptinterface/ScriptContext.h" 34 35 #include "scriptinterface/ScriptInterface.h" … … 113 114 } 114 115 115 PushPage(pageName, initDataClone , JS::UndefinedHandleValue);116 } 117 118 void CGUIManager::PushPage(const CStrW& pageName, Script::StructuredClone initData, JS::HandleValue callbackFunction)116 PushPage(pageName, initDataClone); 117 } 118 119 ) 119 120 { 120 121 // Store the callback handler in the current GUI page before opening the new one 121 if (!m_PageStack.empty() && !callbackFunction.isUndefined()) 122 { 123 m_PageStack.back().SetCallbackFunction(m_ScriptInterface, callbackFunction); 124 125 // Make sure we unfocus anything on the current page. 126 m_PageStack.back().gui->SendFocusMessage(GUIM_LOST_FOCUS); 127 } 122 JS::RootedValue promise{m_ScriptInterface.GetGeneralJSContext(), [&] 123 { 124 if (m_PageStack.empty()) 125 return JS::UndefinedValue(); 126 127 // Make sure we unfocus anything on the current page. 128 m_PageStack.back().gui->SendFocusMessage(GUIM_LOST_FOCUS); 129 return m_PageStack.back().ReplacePromise(m_ScriptInterface); 130 }()}; 128 131 129 132 // Push the page prior to loading its contents, because that may push … … 131 134 m_PageStack.emplace_back(pageName, initData); 132 135 m_PageStack.back().LoadPage(m_ScriptContext); 136 137 133 138 } 134 139 … … 145 150 146 151 m_PageStack.pop_back(); 147 m_PageStack.back(). PerformCallbackFunction(args);152 m_PageStack.back().(args); 148 153 149 154 // We return to a page where some object might have been focused. … … 246 251 } 247 252 248 void CGUIManager::SGUIPage::SetCallbackFunction(ScriptInterface& scriptInterface, JS::HandleValue callbackFunc) 249 { 250 if (!callbackFunc.isObject()) 251 { 252 LOGERROR("Given callback handler is not an object!"); 253 return; 254 } 255 256 ScriptRequest rq(scriptInterface); 257 258 if (!JS_ObjectIsFunction(&callbackFunc.toObject())) 259 { 260 LOGERROR("Given callback handler is not a function!"); 261 return; 262 } 263 264 callbackFunction = std::make_shared<JS::PersistentRootedValue>(scriptInterface.GetGeneralJSContext(), callbackFunc); 265 } 266 267 void CGUIManager::SGUIPage::PerformCallbackFunction(Script::StructuredClone args) 253 JS::Value CGUIManager::SGUIPage::ReplacePromise(ScriptInterface& scriptInterface) 254 { 255 JSContext* generalContext{scriptInterface.GetGeneralJSContext()}; 256 callbackFunction = std::make_shared<JS::PersistentRootedObject>(generalContext, 257 JS::NewPromiseObject(generalContext, nullptr)); 258 return JS::ObjectValue(**callbackFunction); 259 } 260 261 void CGUIManager::SGUIPage::ResolvePromise(Script::StructuredClone args) 268 262 { 269 263 if (!callbackFunction) … … 275 269 JS::RootedObject globalObj(rq.cx, rq.glob); 276 270 277 JS::Rooted ValuefuncVal(rq.cx, *callbackFunction);271 JS::Rooted funcVal(rq.cx, *callbackFunction); 278 272 279 273 // Delete the callback function, so that it is not called again … … 284 278 Script::ReadStructuredClone(rq, args, &argVal); 285 279 286 JS::RootedValueVector paramData(rq.cx); 287 ignore_result(paramData.append(argVal)); 288 289 JS::RootedValue result(rq.cx); 290 291 if(!JS_CallFunctionValue(rq.cx, globalObj, funcVal, paramData, &result)) 292 ScriptException::CatchPending(rq); 280 // This only resolves the promise, it doesn't call the continuation. 281 JS::ResolvePromise(rq.cx, funcVal, argVal); 293 282 } 294 283 … … 389 378 for (const SGUIPage& p : pageStack) 390 379 p.gui->TickObjects(); 380 381 391 382 } 392 383 -
ps/trunk/source/gui/GUIManager.h
r28131 r28145 69 69 * and will still be drawn and receive tick events, but will not receive 70 70 * user inputs. 71 * If given, the callbackHandler function will be executed once thispage is closed.72 */ 73 void PushPage(const CStrW& pageName, Script::StructuredClone initData, JS::HandleValue callbackFunc);71 * page is closed. 72 */ 73 ); 74 74 75 75 /** … … 147 147 148 148 /** 149 * Sets the callback handler when a new page is opened that will be performed when the page is closed. 150 */ 151 void SetCallbackFunction(ScriptInterface& scriptInterface, JS::HandleValue callbackFunc); 149 * A new promise gets set. A reference to that promise is returned. The promise will settle when 150 * the page is closed. 151 */ 152 JS::Value ReplacePromise(ScriptInterface& scriptInterface); 152 153 153 154 /** 154 155 * Execute the stored callback function with the given arguments. 155 156 */ 156 void PerformCallbackFunction(Script::StructuredClone args);157 158 CStrWm_Name;157 void (Script::StructuredClone args); 158 159 m_Name; 159 160 std::unordered_set<VfsPath> inputs; // for hotloading 160 161 Script::StructuredClone initData; // data to be passed to the init() function … … 165 166 * Notice that storing it in the SGUIPage instead of CGUI means that it will survive the hotloading CGUI reset. 166 167 */ 167 std::shared_ptr<JS::PersistentRooted Value> callbackFunction;168 std::shared_ptr<JS::PersistentRooted> callbackFunction; 168 169 }; 169 170 … … 177 178 * may crash (as the pusher page will suddenly have moved, and the stack will be confused). 178 179 * Therefore use std::deque over std::vector. 179 */ 180 using PageStackType = std::deque<SGUIPage>; 180 * Also the elements have to be destructed back to front. 181 */ 182 class PageStackType : public std::deque<SGUIPage> 183 { 184 public: 185 ~PageStackType() 186 { 187 clear(); 188 } 189 190 void clear() 191 { 192 while (!std::deque<SGUIPage>::empty()) 193 std::deque<SGUIPage>::pop_back(); 194 } 195 }; 181 196 PageStackType m_PageStack; 182 197 -
ps/trunk/source/gui/Scripting/JSInterface_GUIManager.cpp
r27965 r28145 1 /* Copyright (C) 202 1Wildfire Games.1 /* Copyright (C) 202 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 33 33 // Note that the initData argument may only contain clonable data. 34 34 // Functions aren't supported for example! 35 void PushGuiPage(const ScriptRequest& rq, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction) 35 // It returns a promise. 36 JS::Value PushGuiPage(const ScriptRequest& rq, const std::wstring& name, JS::HandleValue initData) 36 37 { 37 g_GUI->PushPage(name, Script::WriteStructuredClone(rq, initData), callbackFunction);38 ); 38 39 } 39 40 -
ps/trunk/source/gui/tests/test_GuiManager.h
r28131 r28145 27 27 #include "ps/Hotkey.h" 28 28 #include "ps/XML/Xeromyces.h" 29 29 30 #include "scriptinterface/ScriptRequest.h" 30 31 #include "scriptinterface/ScriptInterface.h" … … 73 74 74 75 Script::StructuredClone data = Script::WriteStructuredClone(rq, JS::NullHandleValue); 75 g_GUI->PushPage(L"event/page_event.xml", data , JS::UndefinedHandleValue);76 g_GUI->PushPage(L"event/page_event.xml", data); 76 77 77 78 const ScriptInterface& pageScriptInterface = *(g_GUI->GetActiveGUI()->GetScriptInterface()); … … 136 137 137 138 Script::StructuredClone data = Script::WriteStructuredClone(rq, JS::NullHandleValue); 138 g_GUI->PushPage(L"hotkey/page_hotkey.xml", data , JS::UndefinedHandleValue);139 g_GUI->PushPage(L"hotkey/page_hotkey.xml", data); 139 140 140 141 // Press 'a'. … … 209 210 Script::CreateObject(rq, &val); 210 211 212 211 213 Script::StructuredClone data = Script::WriteStructuredClone(rq, JS::NullHandleValue); 212 g_GUI->PushPage(L"regainFocus/page_emptyPage.xml", data , JS::UndefinedHandleValue);214 g_GUI->PushPage(L"regainFocus/page_emptyPage.xml", data); 213 215 214 216 const ScriptInterface& pageScriptInterface = *(g_GUI->GetActiveGUI()->GetScriptInterface()); … … 216 218 JS::RootedValue global(prq.cx, prq.globalValue()); 217 219 218 g_GUI->PushPage(L"regainFocus/page_emptyPage.xml", data, JS::UndefinedHandleValue); 220 TS_ASSERT_EQUALS(g_GUI->GetPageCount(), 1); 221 g_GUI->PushPage(L"regainFocus/page_emptyPage.xml", data); 222 TS_ASSERT_EQUALS(g_GUI->GetPageCount(), 2); 219 223 g_GUI->PopPage(data); 224 220 225 221 226 // This page instantly pushes an empty page with a callback that pops another page again. 222 g_GUI->PushPage(L"regainFocus/page_pushWithPopOnInit.xml", data, JS::UndefinedHandleValue); 223 224 // Pop the empty page and trigger the callback (effectively pops twice). 227 g_GUI->PushPage(L"regainFocus/page_pushWithPopOnInit.xml", data); 228 TS_ASSERT_EQUALS(g_GUI->GetPageCount(), 3); 229 230 // Pop the empty page 225 231 g_GUI->PopPage(data); 232 233 234 226 235 } 227 236 }; -
ps/trunk/source/scriptinterface/ScriptContext.cpp
r27965 r28145 1 /* Copyright (C) 202 3Wildfire Games.1 /* Copyright (C) 202 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 23 23 #include "ps/GameSetup/Config.h" 24 24 #include "ps/Profile.h" 25 25 26 #include "scriptinterface/ScriptExtraHeaders.h" 26 27 #include "scriptinterface/ScriptEngine.h" … … 84 85 85 86 ScriptContext::ScriptContext(int contextSize, int heapGrowthBytesGCTrigger): 86 m_LastGCBytes(0), 87 m_LastGCCheck(0.0f), 88 m_HeapGrowthBytesGCTrigger(heapGrowthBytesGCTrigger), 89 m_ContextSize(contextSize) 87 m_JobQueue{std::make_unique<Script::JobQueue>()}, 88 m_ContextSize{contextSize}, 89 m_HeapGrowthBytesGCTrigger{heapGrowthBytesGCTrigger} 90 90 { 91 91 ENSURE(ScriptEngine::IsInitialised() && "The ScriptEngine must be initialized before constructing any ScriptContexts!"); … … 131 131 132 132 ScriptEngine::GetSingleton().RegisterContext(m_cx); 133 134 133 135 } 134 136 … … 269 271 } 270 272 273 274 275 276 277 271 278 void ScriptContext::PrepareZonesForIncrementalGC() const 272 279 { -
ps/trunk/source/scriptinterface/ScriptContext.h
r27965 r28145 1 /* Copyright (C) 202 3Wildfire Games.1 /* Copyright (C) 202 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 27 27 constexpr int DEFAULT_CONTEXT_SIZE = 16 * 1024 * 1024; 28 28 constexpr int DEFAULT_HEAP_GROWTH_BYTES_GCTRIGGER = 2 * 1024 * 1024; 29 30 31 32 33 29 34 30 35 /** … … 76 81 77 82 /** 83 84 85 86 87 88 89 90 78 91 * GetGeneralJSContext returns the context without starting a GC request and without 79 92 * entering any compartment. It should only be used in specific situations, such as … … 87 100 88 101 JSContext* m_cx; 102 89 103 90 104 void PrepareZonesForIncrementalGC() const; … … 93 107 int m_ContextSize; 94 108 int m_HeapGrowthBytesGCTrigger; 95 int m_LastGCBytes ;96 double m_LastGCCheck ;109 int m_LastGCBytes; 110 double m_LastGCCheck; 97 111 }; 98 112 -
ps/trunk/source/scriptinterface/ScriptInterface.cpp
r27965 r28145 1 /* Copyright (C) 202 3Wildfire Games.1 /* Copyright (C) 202 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 385 385 ScriptInterface::~ScriptInterface() 386 386 { 387 387 388 if (Threading::IsMainThread()) 388 389 { -
ps/trunk/source/simulation2/Simulation2.cpp
r28138 r28145 586 586 cmpPathfinder->StartProcessingMoves(false); 587 587 } 588 589 588 590 } 589 591
Note:
See TracChangeset
for help on using the changeset viewer.