This commit is contained in:
dabreegster 2020-10-10 00:41:53 +00:00
parent 1f4c149cda
commit f7945329ba
22 changed files with 174 additions and 104 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `load` mod in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, load"><title>game::load - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../game/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Module load</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li></ul></div><p class='location'><a href='../index.html'>game</a></p><script>window.sidebarCurrent = {name: 'load', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><span class="help-button">?</span>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/game/load.rs.html#1-201' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>game</a>::<wbr><a class="mod" href=''>load</a></span></h1><div class='docblock'><p>Loading large resources (like maps, scenarios, and prebaked data) requires different strategies
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/game/load.rs.html#1-220' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>game</a>::<wbr><a class="mod" href=''>load</a></span></h1><div class='docblock'><p>Loading large resources (like maps, scenarios, and prebaked data) requires different strategies
on native and web. Both cases are wrapped up as a State that runs a callback when done.</p>
</div><h2 id='reexports' class='section-header'><a href="#reexports">Re-exports</a></h2>
<table><tr><td><code>pub use native_loader::<a class="struct" href="../../game/load/native_loader/struct.MapLoader.html" title="struct game::load::native_loader::MapLoader">MapLoader</a>;</code></td></tr></table><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
<table><tr><td><code>pub use native_loader::<a class="struct" href="../../game/load/native_loader/struct.FileLoader.html" title="struct game::load::native_loader::FileLoader">FileLoader</a>;</code></td></tr></table><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
<table><tr class='module-item'><td><a class="mod" href="native_loader/index.html" title='game::load::native_loader mod'>native_loader</a></td><td class='docblock-short'></td></tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.MapAlreadyLoaded.html" title='game::load::MapAlreadyLoaded struct'>MapAlreadyLoaded</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "game";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
<table><tr class='module-item'><td><a class="struct" href="struct.MapAlreadyLoaded.html" title='game::load::MapAlreadyLoaded struct'>MapAlreadyLoaded</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.MapLoader.html" title='game::load::MapLoader struct'>MapLoader</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "game";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>

View File

@ -1,3 +1,3 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `native_loader` mod in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, native_loader"><title>game::load::native_loader - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="shortcut icon" href="../../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../../game/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class='location'>Module native_loader</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class='location'><a href='../../index.html'>game</a>::<wbr><a href='../index.html'>load</a></p><script>window.sidebarCurrent = {name: 'native_loader', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><span class="help-button">?</span>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/game/load.rs.html#28-83' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../../index.html'>game</a>::<wbr><a href='../index.html'>load</a>::<wbr><a class="mod" href=''>native_loader</a></span></h1><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.MapLoader.html" title='game::load::native_loader::MapLoader struct'>MapLoader</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "game";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/game/load.rs.html#79-113' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../../index.html'>game</a>::<wbr><a href='../index.html'>load</a>::<wbr><a class="mod" href=''>native_loader</a></span></h1><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.FileLoader.html" title='game::load::native_loader::FileLoader struct'>FileLoader</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "game";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>

View File

@ -1 +1 @@
initSidebarItems({"struct":[["MapLoader",""]]});
initSidebarItems({"struct":[["FileLoader",""]]});

View File

@ -1 +1 @@
initSidebarItems({"mod":[["native_loader",""]],"struct":[["MapAlreadyLoaded",""]]});
initSidebarItems({"mod":[["native_loader",""]],"struct":[["MapAlreadyLoaded",""],["MapLoader",""]]});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `BUILT_TIME_UTC` constant in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, BUILT_TIME_UTC"><title>game::pregame::built_info::BUILT_TIME_UTC - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="shortcut icon" href="../../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc constant"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../../game/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class='location'><a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a></p><script>window.sidebarCurrent = {name: 'BUILT_TIME_UTC', ty: 'constant', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><span class="help-button">?</span>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/game/home/runner/work/abstreet/abstreet/target/debug/build/game-e788b46a21eaee2a/out/built.rs.html#49' title='goto source code'>[src]</a></span><span class='in-band'>Constant <a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a>::<wbr><a class="constant" href=''>BUILT_TIME_UTC</a></span></h1><pre class='rust const'>pub const BUILT_TIME_UTC: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a> = &quot;Fri, 09 Oct 2020 23:50:20 +0000&quot;;</pre><div class='docblock'><p>The built-time in RFC2822, UTC</p>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/game/home/runner/work/abstreet/abstreet/target/debug/build/game-e788b46a21eaee2a/out/built.rs.html#49' title='goto source code'>[src]</a></span><span class='in-band'>Constant <a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a>::<wbr><a class="constant" href=''>BUILT_TIME_UTC</a></span></h1><pre class='rust const'>pub const BUILT_TIME_UTC: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a> = &quot;Sat, 10 Oct 2020 00:39:47 +0000&quot;;</pre><div class='docblock'><p>The built-time in RFC2822, UTC</p>
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "game";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `map` mod in crate `map_model`."><meta name="keywords" content="rust, rustlang, rust-lang, map"><title>map_model::map - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../map_model/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Module map</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></div><p class='location'><a href='../index.html'>map_model</a></p><script>window.sidebarCurrent = {name: 'map', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><span class="help-button">?</span>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/map_model/map.rs.html#1-673' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>map_model</a>::<wbr><a class="mod" href=''>map</a></span></h1><div class='docblock'><p>A bunch of (mostly read-only) queries on a Map.</p>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/map_model/map.rs.html#1-679' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>map_model</a>::<wbr><a class="mod" href=''>map</a></span></h1><div class='docblock'><p>A bunch of (mostly read-only) queries on a Map.</p>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.MapConfig.html" title='map_model::map::MapConfig struct'>MapConfig</a></td><td class='docblock-short'></td></tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table><tr class='module-item'><td><a class="enum" href="enum.DrivingSide.html" title='map_model::map::DrivingSide enum'>DrivingSide</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "map_model";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -112,7 +112,7 @@
<span class="doccomment">/// The output of `rustdoc -V`</span>
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">RUSTDOC_VERSION</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;rustdoc 1.47.0 (18bf6b4f0 2020-10-07)&quot;</span>;
<span class="doccomment">/// The built-time in RFC2822, UTC</span>
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">BUILT_TIME_UTC</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;Fri, 09 Oct 2020 23:50:20 +0000&quot;</span>;
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">BUILT_TIME_UTC</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;Sat, 10 Oct 2020 00:39:47 +0000&quot;</span>;
<span class="doccomment">/// The target architecture, given by `cfg!(target_arch)`.</span>
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">CFG_TARGET_ARCH</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;x86_64&quot;</span>;
<span class="doccomment">/// The endianness, given by `cfg!(target_endian)`.</span>

View File

@ -200,11 +200,32 @@
<span id="199">199</span>
<span id="200">200</span>
<span id="201">201</span>
<span id="202">202</span>
<span id="203">203</span>
<span id="204">204</span>
<span id="205">205</span>
<span id="206">206</span>
<span id="207">207</span>
<span id="208">208</span>
<span id="209">209</span>
<span id="210">210</span>
<span id="211">211</span>
<span id="212">212</span>
<span id="213">213</span>
<span id="214">214</span>
<span id="215">215</span>
<span id="216">216</span>
<span id="217">217</span>
<span id="218">218</span>
<span id="219">219</span>
<span id="220">220</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="doccomment">//! Loading large resources (like maps, scenarios, and prebaked data) requires different strategies</span>
<span class="doccomment">//! on native and web. Both cases are wrapped up as a State that runs a callback when done.</span>
<span class="kw">use</span> <span class="ident">map_model</span>::<span class="ident">Map</span>;
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">de</span>::<span class="ident">DeserializeOwned</span>;
<span class="kw">use</span> <span class="ident">abstutil</span>::<span class="ident">Timer</span>;
<span class="kw">use</span> <span class="ident">sim</span>::<span class="ident">Sim</span>;
<span class="kw">use</span> <span class="ident">widgetry</span>::{<span class="ident">Color</span>, <span class="ident">EventCtx</span>, <span class="ident">GfxCtx</span>};
@ -212,10 +233,59 @@
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">game</span>::{<span class="ident">State</span>, <span class="ident">Transition</span>};
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">not</span>(<span class="ident">target_arch</span> <span class="op">=</span> <span class="string">&quot;wasm32&quot;</span>))]</span>
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">native_loader</span>::<span class="ident">MapLoader</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">native_loader</span>::<span class="ident">FileLoader</span>;
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">target_arch</span> <span class="op">=</span> <span class="string">&quot;wasm32&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">wasm_loader</span>::<span class="ident">MapLoader</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">wasm_loader</span>::<span class="ident">FileLoader</span>;
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">MapLoader</span>;
<span class="kw">impl</span> <span class="ident">MapLoader</span> {
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(
<span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>,
<span class="ident">app</span>: <span class="kw-2">&amp;</span><span class="ident">App</span>,
<span class="ident">name</span>: <span class="ident">String</span>,
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
) <span class="op">-&gt;</span> <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">State</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">app</span>.<span class="ident">primary</span>.<span class="ident">map</span>.<span class="ident">get_name</span>() <span class="op">==</span> <span class="kw-2">&amp;</span><span class="ident">name</span> {
<span class="kw">return</span> <span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">MapAlreadyLoaded</span> { <span class="ident">on_load</span> });
}
<span class="comment">// TODO If we want to load montlake on the web, just pull from bundled data.</span>
<span class="ident">FileLoader</span>::<span class="op">&lt;</span><span class="ident">map_model</span>::<span class="ident">Map</span><span class="op">&gt;</span>::<span class="ident">new</span>(
<span class="ident">ctx</span>,
<span class="ident">abstutil</span>::<span class="ident">path_map</span>(<span class="kw-2">&amp;</span><span class="ident">name</span>),
<span class="ident">Box</span>::<span class="ident">new</span>(<span class="kw">move</span> <span class="op">|</span><span class="ident">ctx</span>, <span class="ident">app</span>, <span class="ident">map</span><span class="op">|</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="kw-2">mut</span> <span class="ident">map</span>) <span class="op">=</span> <span class="ident">map</span> {
<span class="comment">// Kind of a hack. We can&#39;t generically call Map::new with the FileLoader.</span>
<span class="ident">map</span>.<span class="ident">map_loaded_directly</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">timer</span> <span class="op">=</span> <span class="ident">Timer</span>::<span class="ident">new</span>(<span class="string">&quot;finish loading map&quot;</span>);
<span class="kw">let</span> <span class="ident">sim</span> <span class="op">=</span> <span class="ident">Sim</span>::<span class="ident">new</span>(
<span class="kw-2">&amp;</span><span class="ident">map</span>,
<span class="ident">app</span>.<span class="ident">primary</span>.<span class="ident">current_flags</span>.<span class="ident">sim_flags</span>.<span class="ident">opts</span>.<span class="ident">clone</span>(),
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">timer</span>,
);
<span class="ident">app</span>.<span class="ident">map_switched</span>(<span class="ident">ctx</span>, <span class="ident">map</span>, <span class="ident">sim</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">timer</span>);
(<span class="ident">on_load</span>)(<span class="ident">ctx</span>, <span class="ident">app</span>)
} <span class="kw">else</span> {
<span class="comment">// TODO Some kind of UI for running the updater from here!</span>
<span class="comment">// TODO On the web, this shouldn&#39;t happen; display a different error message</span>
<span class="ident">Transition</span>::<span class="ident">Replace</span>(<span class="kw">crate</span>::<span class="ident">game</span>::<span class="ident">PopupMsg</span>::<span class="ident">new</span>(
<span class="ident">ctx</span>,
<span class="string">&quot;Missing data&quot;</span>,
<span class="macro">vec</span><span class="macro">!</span>[
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{} is missing&quot;</span>, <span class="ident">abstutil</span>::<span class="ident">path_map</span>(<span class="kw-2">&amp;</span><span class="ident">name</span>)),
<span class="string">&quot;You need to opt into this by modifying data/config and running the \
updater&quot;</span>
.<span class="ident">to_string</span>(),
],
))
}
}),
)
}
}
<span class="kw">struct</span> <span class="ident">MapAlreadyLoaded</span> {
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
@ -231,52 +301,31 @@
<span class="kw">mod</span> <span class="ident">native_loader</span> {
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">MapLoader</span> {
<span class="ident">name</span>: <span class="ident">String</span>,
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">FileLoader</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="ident">path</span>: <span class="ident">String</span>,
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>, <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
}
<span class="kw">impl</span> <span class="ident">MapLoader</span> {
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="lifetime">&#39;static</span> <span class="op">+</span> <span class="ident">DeserializeOwned</span><span class="op">&gt;</span> <span class="ident">FileLoader</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(
<span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>,
<span class="ident">app</span>: <span class="kw-2">&amp;</span><span class="ident">App</span>,
<span class="ident">name</span>: <span class="ident">String</span>,
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
<span class="ident">path</span>: <span class="ident">String</span>,
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>, <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
) <span class="op">-&gt;</span> <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">State</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">app</span>.<span class="ident">primary</span>.<span class="ident">map</span>.<span class="ident">get_name</span>() <span class="op">==</span> <span class="kw-2">&amp;</span><span class="ident">name</span> {
<span class="kw">return</span> <span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">MapAlreadyLoaded</span> { <span class="ident">on_load</span> });
}
<span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">MapLoader</span> { <span class="ident">name</span>, <span class="ident">on_load</span> })
<span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">FileLoader</span> { <span class="ident">path</span>, <span class="ident">on_load</span> })
}
}
<span class="kw">impl</span> <span class="ident">State</span> <span class="kw">for</span> <span class="ident">MapLoader</span> {
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="lifetime">&#39;static</span> <span class="op">+</span> <span class="ident">DeserializeOwned</span><span class="op">&gt;</span> <span class="ident">State</span> <span class="kw">for</span> <span class="ident">FileLoader</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">event</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="ident">app</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span> {
<span class="kw">if</span> <span class="ident">abstutil</span>::<span class="ident">file_exists</span>(<span class="ident">abstutil</span>::<span class="ident">path_map</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">name</span>)) {
<span class="ident">ctx</span>.<span class="ident">loading_screen</span>(<span class="string">&quot;load map&quot;</span>, <span class="op">|</span><span class="ident">ctx</span>, <span class="kw-2">mut</span> <span class="ident">timer</span><span class="op">|</span> {
<span class="kw">let</span> <span class="ident">map</span> <span class="op">=</span> <span class="ident">Map</span>::<span class="ident">new</span>(<span class="ident">abstutil</span>::<span class="ident">path_map</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">name</span>), <span class="ident">timer</span>);
<span class="kw">let</span> <span class="ident">sim</span> <span class="op">=</span> <span class="ident">Sim</span>::<span class="ident">new</span>(
<span class="kw-2">&amp;</span><span class="ident">map</span>,
<span class="ident">app</span>.<span class="ident">primary</span>.<span class="ident">current_flags</span>.<span class="ident">sim_flags</span>.<span class="ident">opts</span>.<span class="ident">clone</span>(),
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">timer</span>,
);
<span class="ident">app</span>.<span class="ident">map_switched</span>(<span class="ident">ctx</span>, <span class="ident">map</span>, <span class="ident">sim</span>, <span class="ident">timer</span>);
});
(<span class="self">self</span>.<span class="ident">on_load</span>)(<span class="ident">ctx</span>, <span class="ident">app</span>)
} <span class="kw">else</span> {
<span class="comment">// TODO Some kind of UI for running the updater from here!</span>
<span class="ident">Transition</span>::<span class="ident">Replace</span>(<span class="kw">crate</span>::<span class="ident">game</span>::<span class="ident">PopupMsg</span>::<span class="ident">new</span>(
<span class="ident">ctx</span>.<span class="ident">loading_screen</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;load {}&quot;</span>, <span class="self">self</span>.<span class="ident">path</span>), <span class="op">|</span><span class="ident">ctx</span>, <span class="ident">timer</span><span class="op">|</span> {
<span class="comment">// Assumes a binary file</span>
(<span class="self">self</span>.<span class="ident">on_load</span>)(
<span class="ident">ctx</span>,
<span class="string">&quot;Missing data&quot;</span>,
<span class="macro">vec</span><span class="macro">!</span>[
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{} is missing&quot;</span>, <span class="ident">abstutil</span>::<span class="ident">path_map</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">name</span>)),
<span class="string">&quot;You need to opt into this by modifying data/config and running the \
updater&quot;</span>
.<span class="ident">to_string</span>(),
],
))
}
<span class="ident">app</span>,
<span class="ident">abstutil</span>::<span class="ident">maybe_read_binary</span>(<span class="self">self</span>.<span class="ident">path</span>.<span class="ident">clone</span>(), <span class="ident">timer</span>).<span class="ident">ok</span>(),
)
})
}
<span class="kw">fn</span> <span class="ident">draw</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">g</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">GfxCtx</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="ident">App</span>) {
@ -293,7 +342,6 @@
<span class="kw">use</span> <span class="ident">wasm_bindgen_futures</span>::<span class="ident">JsFuture</span>;
<span class="kw">use</span> <span class="ident">web_sys</span>::{<span class="ident">Request</span>, <span class="ident">RequestInit</span>, <span class="ident">RequestMode</span>, <span class="ident">Response</span>};
<span class="kw">use</span> <span class="ident">abstutil</span>::<span class="ident">Timer</span>;
<span class="kw">use</span> <span class="ident">geom</span>::<span class="ident">Duration</span>;
<span class="kw">use</span> <span class="ident">widgetry</span>::{<span class="ident">Line</span>, <span class="ident">Panel</span>, <span class="ident">Text</span>, <span class="ident">UpdateType</span>};
@ -302,33 +350,30 @@
<span class="comment">// Instead of blockingly reading a file within ctx.loading_screen, on the web have to</span>
<span class="comment">// asynchronously make an HTTP request and keep &quot;polling&quot; for completion in a way that&#39;s</span>
<span class="comment">// compatible with winit&#39;s event loop.</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">MapLoader</span> {
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">FileLoader</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="ident">response</span>: <span class="ident">oneshot</span>::<span class="ident">Receiver</span><span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u8</span><span class="op">&gt;&gt;</span>,
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>, <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
<span class="ident">panel</span>: <span class="ident">Panel</span>,
<span class="ident">started</span>: <span class="ident">Instant</span>,
<span class="ident">url</span>: <span class="ident">String</span>,
}
<span class="kw">impl</span> <span class="ident">MapLoader</span> {
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="lifetime">&#39;static</span> <span class="op">+</span> <span class="ident">DeserializeOwned</span><span class="op">&gt;</span> <span class="ident">FileLoader</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(
<span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>,
<span class="ident">app</span>: <span class="kw-2">&amp;</span><span class="ident">App</span>,
<span class="ident">name</span>: <span class="ident">String</span>,
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
<span class="ident">path</span>: <span class="ident">String</span>,
<span class="ident">on_load</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>, <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span><span class="op">&gt;</span>,
) <span class="op">-&gt;</span> <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">State</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">app</span>.<span class="ident">primary</span>.<span class="ident">map</span>.<span class="ident">get_name</span>() <span class="op">==</span> <span class="kw-2">&amp;</span><span class="ident">name</span> {
<span class="kw">return</span> <span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">MapAlreadyLoaded</span> { <span class="ident">on_load</span> });
}
<span class="comment">// TODO If we want to load montlake, just pull from bundled data.</span>
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="kw">if</span> <span class="macro">cfg</span><span class="macro">!</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">&quot;wasm_s3&quot;</span>) {
<span class="macro">format</span><span class="macro">!</span>(
<span class="string">&quot;http://abstreet.s3-website.us-east-2.amazonaws.com/system/maps/{}.bin&quot;</span>,
<span class="ident">name</span>
<span class="string">&quot;http://abstreet.s3-website.us-east-2.amazonaws.com/{}&quot;</span>,
<span class="ident">path</span>.<span class="ident">strip_prefix</span>(<span class="kw-2">&amp;</span><span class="ident">abstutil</span>::<span class="ident">path</span>(<span class="string">&quot;&quot;</span>)).<span class="ident">unwrap</span>()
)
} <span class="kw">else</span> {
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;http://0.0.0.0:8000/system/maps/{}.bin&quot;</span>, <span class="ident">name</span>)
<span class="macro">format</span><span class="macro">!</span>(
<span class="string">&quot;http://0.0.0.0:8000/{}&quot;</span>,
<span class="ident">path</span>.<span class="ident">strip_prefix</span>(<span class="kw-2">&amp;</span><span class="ident">abstutil</span>::<span class="ident">path</span>(<span class="string">&quot;&quot;</span>)).<span class="ident">unwrap</span>()
)
};
<span class="comment">// Make the HTTP request nonblockingly. When the response is received, send it through</span>
@ -352,7 +397,7 @@
<span class="ident">tx</span>.<span class="ident">send</span>(<span class="ident">bytes</span>).<span class="ident">unwrap</span>();
});
<span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">MapLoader</span> {
<span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">FileLoader</span> {
<span class="ident">response</span>: <span class="ident">rx</span>,
<span class="ident">on_load</span>,
<span class="ident">panel</span>: <span class="ident">ctx</span>.<span class="ident">make_loading_screen</span>(<span class="ident">Text</span>::<span class="ident">from</span>(<span class="ident">Line</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Loading {}...&quot;</span>, <span class="ident">url</span>)))),
@ -362,23 +407,16 @@
}
}
<span class="kw">impl</span> <span class="ident">State</span> <span class="kw">for</span> <span class="ident">MapLoader</span> {
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="lifetime">&#39;static</span> <span class="op">+</span> <span class="ident">DeserializeOwned</span><span class="op">&gt;</span> <span class="ident">State</span> <span class="kw">for</span> <span class="ident">FileLoader</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">event</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="ident">app</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">App</span>) <span class="op">-&gt;</span> <span class="ident">Transition</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">resp</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">response</span>.<span class="ident">try_recv</span>().<span class="ident">unwrap</span>() {
<span class="comment">// TODO We stop drawing and start blocking at this point. It can take a</span>
<span class="comment">// while. Any way to make it still be nonblockingish? Maybe put some of the work</span>
<span class="comment">// inside that spawn_local?</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">timer</span> <span class="op">=</span> <span class="ident">Timer</span>::<span class="ident">new</span>(<span class="string">&quot;finish loading map&quot;</span>);
<span class="kw">let</span> <span class="ident">map</span>: <span class="ident">Map</span> <span class="op">=</span> <span class="ident">abstutil</span>::<span class="ident">from_binary</span>(<span class="kw-2">&amp;</span><span class="ident">resp</span>).<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">sim</span> <span class="op">=</span> <span class="ident">Sim</span>::<span class="ident">new</span>(
<span class="kw-2">&amp;</span><span class="ident">map</span>,
<span class="ident">app</span>.<span class="ident">primary</span>.<span class="ident">current_flags</span>.<span class="ident">sim_flags</span>.<span class="ident">opts</span>.<span class="ident">clone</span>(),
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">timer</span>,
);
<span class="ident">app</span>.<span class="ident">map_switched</span>(<span class="ident">ctx</span>, <span class="ident">map</span>, <span class="ident">sim</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">timer</span>);
<span class="kw">return</span> (<span class="self">self</span>.<span class="ident">on_load</span>)(<span class="ident">ctx</span>, <span class="ident">app</span>);
<span class="comment">// TODO Plumb failures</span>
<span class="kw">let</span> <span class="ident">obj</span>: <span class="ident">T</span> <span class="op">=</span> <span class="ident">abstutil</span>::<span class="ident">from_binary</span>(<span class="kw-2">&amp;</span><span class="ident">resp</span>).<span class="ident">unwrap</span>();
<span class="kw">return</span> (<span class="self">self</span>.<span class="ident">on_load</span>)(<span class="ident">ctx</span>, <span class="ident">app</span>, <span class="prelude-val">Some</span>(<span class="ident">obj</span>));
}
<span class="self">self</span>.<span class="ident">panel</span> <span class="op">=</span> <span class="ident">ctx</span>.<span class="ident">make_loading_screen</span>(<span class="ident">Text</span>::<span class="ident">from_multiline</span>(<span class="macro">vec</span><span class="macro">!</span>[

View File

@ -672,6 +672,12 @@
<span id="671">671</span>
<span id="672">672</span>
<span id="673">673</span>
<span id="674">674</span>
<span id="675">675</span>
<span id="676">676</span>
<span id="677">677</span>
<span id="678">678</span>
<span id="679">679</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="doccomment">//! A bunch of (mostly read-only) queries on a Map.</span>
@ -779,6 +785,12 @@
<span class="ident">Map</span>::<span class="ident">create_from_raw</span>(<span class="ident">raw</span>, <span class="bool-val">true</span>, <span class="ident">timer</span>)
}
<span class="doccomment">/// If you have to deserialize a `Map` directly, call this after. Prefer using `Map::new`</span>
<span class="doccomment">/// though.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">map_loaded_directly</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>) {
<span class="self">self</span>.<span class="ident">edits</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">new_edits</span>();
}
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">corrupt_err</span>(<span class="ident">path</span>: <span class="ident">String</span>, <span class="ident">err</span>: <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Error</span>) {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;\nError loading {}: {}\n&quot;</span>, <span class="ident">path</span>, <span class="ident">err</span>);
<span class="kw">if</span> <span class="ident">err</span>.<span class="ident">to_string</span>().<span class="ident">contains</span>(<span class="string">&quot;No such file&quot;</span>) {