client persistence
This commit is contained in:
parent
164eb4ba43
commit
b011b13180
10 changed files with 200 additions and 38 deletions
50
Cargo.lock
generated
50
Cargo.lock
generated
|
@ -23,6 +23,10 @@ name = "accesskit"
|
||||||
version = "0.17.1"
|
version = "0.17.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d3d3b8f9bae46a948369bc4a03e815d4ed6d616bd00de4051133a5019dc31c5a"
|
checksum = "d3d3b8f9bae46a948369bc4a03e815d4ed6d616bd00de4051133a5019dc31c5a"
|
||||||
|
dependencies = [
|
||||||
|
"enumn",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "accesskit_atspi_common"
|
name = "accesskit_atspi_common"
|
||||||
|
@ -138,7 +142,7 @@ dependencies = [
|
||||||
"actix-service",
|
"actix-service",
|
||||||
"actix-utils",
|
"actix-utils",
|
||||||
"ahash",
|
"ahash",
|
||||||
"base64",
|
"base64 0.22.1",
|
||||||
"bitflags 2.9.0",
|
"bitflags 2.9.0",
|
||||||
"brotli",
|
"brotli",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -317,6 +321,7 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
"serde",
|
||||||
"version_check",
|
"version_check",
|
||||||
"zerocopy",
|
"zerocopy",
|
||||||
]
|
]
|
||||||
|
@ -708,6 +713,12 @@ dependencies = [
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base64"
|
||||||
|
version = "0.21.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.22.1"
|
version = "0.22.1"
|
||||||
|
@ -1221,6 +1232,7 @@ checksum = "bc4feb366740ded31a004a0e4452fbf84e80ef432ecf8314c485210229672fd1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"emath",
|
"emath",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1239,6 +1251,7 @@ dependencies = [
|
||||||
"glow",
|
"glow",
|
||||||
"glutin",
|
"glutin",
|
||||||
"glutin-winit",
|
"glutin-winit",
|
||||||
|
"home",
|
||||||
"image",
|
"image",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"log",
|
"log",
|
||||||
|
@ -1249,6 +1262,8 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"profiling",
|
"profiling",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
|
"ron",
|
||||||
|
"serde",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
|
@ -1273,6 +1288,8 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
"profiling",
|
"profiling",
|
||||||
|
"ron",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1309,6 +1326,7 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"profiling",
|
"profiling",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
|
"serde",
|
||||||
"smithay-clipboard",
|
"smithay-clipboard",
|
||||||
"web-time",
|
"web-time",
|
||||||
"webbrowser",
|
"webbrowser",
|
||||||
|
@ -1360,6 +1378,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9e4cadcff7a5353ba72b7fea76bf2122b5ebdbc68e8155aa56dfdea90083fe1b"
|
checksum = "9e4cadcff7a5353ba72b7fea76bf2122b5ebdbc68e8155aa56dfdea90083fe1b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1404,6 +1423,17 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "enumn"
|
||||||
|
version = "0.1.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "epaint"
|
name = "epaint"
|
||||||
version = "0.31.1"
|
version = "0.31.1"
|
||||||
|
@ -1420,6 +1450,7 @@ dependencies = [
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"profiling",
|
"profiling",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3404,7 +3435,7 @@ version = "0.12.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b"
|
checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64 0.22.1",
|
||||||
"bytes",
|
"bytes",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
@ -3462,6 +3493,18 @@ dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ron"
|
||||||
|
version = "0.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
||||||
|
dependencies = [
|
||||||
|
"base64 0.21.7",
|
||||||
|
"bitflags 2.9.0",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.24"
|
version = "0.1.24"
|
||||||
|
@ -4382,7 +4425,7 @@ version = "2.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a"
|
checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64 0.22.1",
|
||||||
"flate2",
|
"flate2",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
@ -5200,6 +5243,7 @@ dependencies = [
|
||||||
"image",
|
"image",
|
||||||
"nalgebra-glm",
|
"nalgebra-glm",
|
||||||
"poll-promise",
|
"poll-promise",
|
||||||
|
"serde",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"tracing-web",
|
"tracing-web",
|
||||||
|
|
|
@ -6,7 +6,7 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = "0.3"
|
||||||
eframe = { version = "0.31" }
|
eframe = { version = "0.31", features = ["persistence"] }
|
||||||
glow = "*"
|
glow = "*"
|
||||||
egui_glow = "0.31"
|
egui_glow = "0.31"
|
||||||
egui = "0.31"
|
egui = "0.31"
|
||||||
|
@ -15,6 +15,7 @@ ehttp = "0.5"
|
||||||
image = "0.25"
|
image = "0.25"
|
||||||
bytemuck = "1.22"
|
bytemuck = "1.22"
|
||||||
nalgebra-glm = "0.19"
|
nalgebra-glm = "0.19"
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
tracing-web = "0.1"
|
tracing-web = "0.1"
|
||||||
|
|
6
crates/client/dist/index.html
vendored
6
crates/client/dist/index.html
vendored
|
@ -94,7 +94,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<link rel="modulepreload" href="/wxbox-client-80142735797f0966.js" crossorigin="anonymous" integrity="sha384-Vt83Dej0N3ylPemIHXzytyKIxG97APHZN9wiDVs0l/Ke7cJAIwuTt06P9cfxlScr"><link rel="preload" href="/wxbox-client-80142735797f0966_bg.wasm" crossorigin="anonymous" integrity="sha384-cgdrHf785ZWa2q7jeTewH7zPTO9blVxrrz8Om8M6boiYE0iolbNJAoWkNUNbIZoe" as="fetch" type="application/wasm"></head>
|
<link rel="modulepreload" href="/wxbox-client-4ab39f9996332d21.js" crossorigin="anonymous" integrity="sha384-RKP0HUDiGQfxWXl6hL/T+kQcdd+6hIRZz4x4PNzYIAWRzd1ftTPsFDz037h+Ro9x"><link rel="preload" href="/wxbox-client-4ab39f9996332d21_bg.wasm" crossorigin="anonymous" integrity="sha384-g4SnoQkXzKtsR/R3fR6ezczl6JgHv1+4YeAHafD3wGDFal64pg3O9U8GePtlnVXu" as="fetch" type="application/wasm"></head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<!-- The WASM code will resize the canvas dynamically -->
|
<!-- The WASM code will resize the canvas dynamically -->
|
||||||
|
@ -111,8 +111,8 @@
|
||||||
|
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import init, * as bindings from '/wxbox-client-80142735797f0966.js';
|
import init, * as bindings from '/wxbox-client-4ab39f9996332d21.js';
|
||||||
const wasm = await init({ module_or_path: '/wxbox-client-80142735797f0966_bg.wasm' });
|
const wasm = await init({ module_or_path: '/wxbox-client-4ab39f9996332d21_bg.wasm' });
|
||||||
|
|
||||||
|
|
||||||
window.wasmBindings = bindings;
|
window.wasmBindings = bindings;
|
||||||
|
|
|
@ -212,7 +212,7 @@ function debugString(val) {
|
||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
function __wbg_adapter_32(arg0, arg1, arg2) {
|
function __wbg_adapter_32(arg0, arg1, arg2) {
|
||||||
wasm.closure72_externref_shim(arg0, arg1, arg2);
|
wasm.closure1033_externref_shim(arg0, arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
function takeFromExternrefTable0(idx) {
|
function takeFromExternrefTable0(idx) {
|
||||||
|
@ -221,12 +221,16 @@ function takeFromExternrefTable0(idx) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
function __wbg_adapter_37(arg0, arg1) {
|
function __wbg_adapter_37(arg0, arg1) {
|
||||||
const ret = wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0fb7ada914653eaa_multivalue_shim(arg0, arg1);
|
const ret = wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf569355bc10ba4a3_multivalue_shim(arg0, arg1);
|
||||||
if (ret[1]) {
|
if (ret[1]) {
|
||||||
throw takeFromExternrefTable0(ret[0]);
|
throw takeFromExternrefTable0(ret[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function __wbg_adapter_40(arg0, arg1, arg2) {
|
||||||
|
wasm.closure1746_externref_shim(arg0, arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chroma subsampling format
|
* Chroma subsampling format
|
||||||
* @enum {0 | 1 | 2 | 3}
|
* @enum {0 | 1 | 2 | 3}
|
||||||
|
@ -1166,10 +1170,34 @@ function __wbg_get_imports() {
|
||||||
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_newwithbyteoffsetandlength_4b01f207bed23fc0 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = new Int8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_newwithbyteoffsetandlength_5910bdf845a168eb = function(arg0, arg1, arg2) {
|
||||||
|
const ret = new Uint32Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_newwithbyteoffsetandlength_6991ab0478cc4a43 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = new Int32Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_newwithbyteoffsetandlength_69ec77b20853ae02 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = new Uint16Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_newwithbyteoffsetandlength_b0192e1adfca2df1 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = new Int16Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
imports.wbg.__wbg_newwithbyteoffsetandlength_ba35896968751d91 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbg_newwithbyteoffsetandlength_ba35896968751d91 = function(arg0, arg1, arg2) {
|
||||||
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_newwithbyteoffsetandlength_f113a96374814bb2 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = new Float32Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
imports.wbg.__wbg_newwithrecordfromstrtoblobpromise_43dee664be2df4ab = function() { return handleError(function (arg0) {
|
imports.wbg.__wbg_newwithrecordfromstrtoblobpromise_43dee664be2df4ab = function() { return handleError(function (arg0) {
|
||||||
const ret = new ClipboardItem(arg0);
|
const ret = new ClipboardItem(arg0);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1277,6 +1305,9 @@ function __wbg_get_imports() {
|
||||||
imports.wbg.__wbg_readPixels_33f7af7601585ec6 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
imports.wbg.__wbg_readPixels_33f7af7601585ec6 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
||||||
arg0.readPixels(arg1, arg2, arg3, arg4, arg5 >>> 0, arg6 >>> 0, arg7);
|
arg0.readPixels(arg1, arg2, arg3, arg4, arg5 >>> 0, arg6 >>> 0, arg7);
|
||||||
}, arguments) };
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_readPixels_bc526324b691316a = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
||||||
|
arg0.readPixels(arg1, arg2, arg3, arg4, arg5 >>> 0, arg6 >>> 0, arg7);
|
||||||
|
}, arguments) };
|
||||||
imports.wbg.__wbg_readPixels_ca434c18552fc5bc = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
imports.wbg.__wbg_readPixels_ca434c18552fc5bc = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
||||||
arg0.readPixels(arg1, arg2, arg3, arg4, arg5 >>> 0, arg6 >>> 0, arg7);
|
arg0.readPixels(arg1, arg2, arg3, arg4, arg5 >>> 0, arg6 >>> 0, arg7);
|
||||||
}, arguments) };
|
}, arguments) };
|
||||||
|
@ -1466,6 +1497,9 @@ function __wbg_get_imports() {
|
||||||
imports.wbg.__wbg_texParameteri_d550886a76f21258 = function(arg0, arg1, arg2, arg3) {
|
imports.wbg.__wbg_texParameteri_d550886a76f21258 = function(arg0, arg1, arg2, arg3) {
|
||||||
arg0.texParameteri(arg1 >>> 0, arg2 >>> 0, arg3);
|
arg0.texParameteri(arg1 >>> 0, arg2 >>> 0, arg3);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_texSubImage2D_0eeb9856a37cc769 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
|
||||||
|
arg0.texSubImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9);
|
||||||
|
}, arguments) };
|
||||||
imports.wbg.__wbg_texSubImage2D_355ed8d7c2b07c22 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
|
imports.wbg.__wbg_texSubImage2D_355ed8d7c2b07c22 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
|
||||||
arg0.texSubImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9);
|
arg0.texSubImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9);
|
||||||
}, arguments) };
|
}, arguments) };
|
||||||
|
@ -1599,20 +1633,20 @@ function __wbg_get_imports() {
|
||||||
const ret = false;
|
const ret = false;
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper2730 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper3798 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 73, __wbg_adapter_32);
|
const ret = makeMutClosure(arg0, arg1, 1034, __wbg_adapter_32);
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper633 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper3800 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 73, __wbg_adapter_32);
|
const ret = makeMutClosure(arg0, arg1, 1034, __wbg_adapter_32);
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper635 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper3802 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 73, __wbg_adapter_32);
|
const ret = makeMutClosure(arg0, arg1, 1034, __wbg_adapter_37);
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper841 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper6521 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 73, __wbg_adapter_37);
|
const ret = makeMutClosure(arg0, arg1, 1747, __wbg_adapter_40);
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
BIN
crates/client/dist/wxbox-client-4ab39f9996332d21_bg.wasm
vendored
Normal file
BIN
crates/client/dist/wxbox-client-4ab39f9996332d21_bg.wasm
vendored
Normal file
Binary file not shown.
Binary file not shown.
|
@ -1,33 +1,61 @@
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use eframe::{Frame, Storage};
|
use eframe::{Frame, Storage};
|
||||||
use egui::{Context, Event, MouseWheelUnit, Sense, Vec2};
|
use egui::{Context, Event, MouseWheelUnit, Sense, Vec2};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use crate::map::{Map};
|
use crate::map::{Map};
|
||||||
use crate::map::osm::OSMBaselayer;
|
use crate::map::osm::OSMBaselayer;
|
||||||
use crate::map::tiles::{LayerManager, LayerSource};
|
use crate::map::tiles::{LayerManager, LayerSource};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct App {
|
pub struct App {
|
||||||
map: Map
|
map: Map
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
|
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
|
||||||
|
if let Some(storage) = cc.storage {
|
||||||
|
if let Some(stored) = eframe::get_value(storage, eframe::APP_KEY) {
|
||||||
|
let mut stored: Self = stored;
|
||||||
|
stored.map.init(cc);
|
||||||
|
return stored;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut layer_manager = LayerManager::default();
|
let mut layer_manager = LayerManager::default();
|
||||||
layer_manager.layers.insert(0, OSMBaselayer::SOURCE_ID);
|
layer_manager.layers.insert(0, OSMBaselayer::SOURCE_ID);
|
||||||
|
|
||||||
|
let mut map = Map::new(cc).unwrap();
|
||||||
|
map.layer_manager = layer_manager;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
map: Map::new(layer_manager, cc).unwrap(),
|
map,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl eframe::App for App {
|
impl eframe::App for App {
|
||||||
|
fn save(&mut self, storage: &mut dyn Storage) {
|
||||||
|
eframe::set_value(storage, eframe::APP_KEY, self);
|
||||||
|
}
|
||||||
|
|
||||||
fn update(&mut self, ctx: &Context, frame: &mut Frame) {
|
fn update(&mut self, ctx: &Context, frame: &mut Frame) {
|
||||||
egui::SidePanel::left("sidebar")
|
egui::SidePanel::left("sidebar")
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
|
.min_width(ctx.input(|i| i.screen_rect).width() / 6.0)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ui.heading("wxbox");
|
ui.heading("wxbox");
|
||||||
ui.checkbox(&mut self.map.allow_nonint_zoom, "Allow non-integer zoom (broken)?");
|
|
||||||
|
ui.collapsing("Map internals", |ui| {
|
||||||
|
ui.label(format!("Position: {}, {} @ {}", &self.map.lat, &self.map.long, &self.map.zoom));
|
||||||
|
ui.label(format!("Inertia: {}, {}", &self.map.x_inertia, &self.map.y_inertia));
|
||||||
|
ui.checkbox(&mut self.map.allow_nonint_zoom, "Allow non-integer zoom (broken)?");
|
||||||
|
ui.label("Inertia falloff:");
|
||||||
|
ui.add(egui::DragValue::new(&mut self.map.inertia_falloff).speed(0.01).range(1.1_f64..=2.0));
|
||||||
|
ui.label("Inertia scale:");
|
||||||
|
ui.add(egui::DragValue::new(&mut self.map.inertia_scale).speed(0.01).range(0.1_f64..=1.9))
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
egui::CentralPanel::default()
|
egui::CentralPanel::default()
|
||||||
|
@ -38,7 +66,7 @@ impl eframe::App for App {
|
||||||
|
|
||||||
fn on_exit(&mut self, gl: Option<&glow::Context>) {
|
fn on_exit(&mut self, gl: Option<&glow::Context>) {
|
||||||
if let Some(gl) = gl {
|
if let Some(gl) = gl {
|
||||||
self.map.render.lock().unwrap().destroy(gl);
|
self.map.render.as_ref().unwrap().lock().unwrap().destroy(gl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,35 +8,58 @@ use std::sync::{Arc, Mutex};
|
||||||
use egui::{Event, MouseWheelUnit, Rect, Sense, Ui};
|
use egui::{Event, MouseWheelUnit, Rect, Sense, Ui};
|
||||||
use image::{DynamicImage, ImageReader};
|
use image::{DynamicImage, ImageReader};
|
||||||
use poll_promise::Promise;
|
use poll_promise::Promise;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
use crate::map::osm::OSMBaselayer;
|
use crate::map::osm::OSMBaselayer;
|
||||||
use crate::map::render::{ExtraRenderOptions, MapRender};
|
use crate::map::render::{ExtraRenderOptions, MapRender};
|
||||||
use crate::map::tiles::{LayerId, LayerManager, LayerSource, Tile, XCoord, YCoord, ZoomLevel};
|
use crate::map::tiles::{LayerId, LayerManager, LayerSource, Tile, XCoord, YCoord, ZoomLevel};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(default)]
|
||||||
pub struct Map {
|
pub struct Map {
|
||||||
pub layer_manager: LayerManager,
|
pub layer_manager: LayerManager,
|
||||||
pub lat: f64,
|
pub lat: f64,
|
||||||
pub long: f64,
|
pub long: f64,
|
||||||
pub zoom: f64,
|
pub zoom: f64,
|
||||||
pub render: Arc<Mutex<MapRender>>,
|
#[serde(skip)]
|
||||||
|
pub render: Option<Arc<Mutex<MapRender>>>,
|
||||||
pub options: ExtraRenderOptions,
|
pub options: ExtraRenderOptions,
|
||||||
pub allow_nonint_zoom: bool
|
pub allow_nonint_zoom: bool,
|
||||||
|
pub x_inertia: f64,
|
||||||
|
pub y_inertia: f64,
|
||||||
|
pub inertia_falloff: f64,
|
||||||
|
pub inertia_scale: f64
|
||||||
}
|
}
|
||||||
|
impl Default for Map {
|
||||||
impl Map {
|
fn default() -> Self {
|
||||||
pub fn new<'a>(layer_manager: LayerManager, cc: &'a eframe::CreationContext<'a>) -> Option<Self> {
|
Self {
|
||||||
let gl = cc.gl.as_ref().unwrap();
|
layer_manager: LayerManager::default(),
|
||||||
Some(Self {
|
|
||||||
layer_manager: layer_manager,
|
|
||||||
lat: 35.227085,
|
lat: 35.227085,
|
||||||
long: -80.843124,
|
long: -80.843124,
|
||||||
zoom: 12.0,
|
zoom: 12.0,
|
||||||
render: Arc::new(Mutex::new(MapRender::new(gl)?)),
|
render: None,
|
||||||
options: ExtraRenderOptions {
|
options: ExtraRenderOptions {},
|
||||||
},
|
allow_nonint_zoom: false,
|
||||||
allow_nonint_zoom: false
|
x_inertia: 0.0,
|
||||||
})
|
y_inertia: 0.0,
|
||||||
|
inertia_falloff: 1.25,
|
||||||
|
inertia_scale: 0.16
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Map {
|
||||||
|
pub fn new<'a>(cc: &'a eframe::CreationContext<'a>) -> Option<Self> {
|
||||||
|
let mut new = Self::default();
|
||||||
|
new.init(cc);
|
||||||
|
Some(new)
|
||||||
|
}
|
||||||
|
pub fn init<'a>(&mut self, cc: &'a eframe::CreationContext) {
|
||||||
|
let gl = cc.gl.as_ref().unwrap();
|
||||||
|
self.render = Some(Arc::new(Mutex::new(MapRender::new(gl).unwrap())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn process_input(&mut self, ctx: &egui::Context, ui: &mut Ui, rect: Rect, response: egui::Response) {
|
pub fn process_input(&mut self, ctx: &egui::Context, ui: &mut Ui, rect: Rect, response: egui::Response) {
|
||||||
let xy_delta = response.drag_delta();
|
let xy_delta = response.drag_delta();
|
||||||
let z_delta = if ui.rect_contains_pointer(rect) {
|
let z_delta = if ui.rect_contains_pointer(rect) {
|
||||||
|
@ -67,8 +90,36 @@ impl Map {
|
||||||
let mut x = x * n;
|
let mut x = x * n;
|
||||||
let mut y = y * n;
|
let mut y = y * n;
|
||||||
|
|
||||||
x -= xy_delta.x as f64 * 1.0 / 256.0;
|
const MIN_INERTIA: f64 = 0.01;
|
||||||
y -= xy_delta.y as f64 * 1.0 / 256.0;
|
|
||||||
|
let x_delta = xy_delta.x as f64 * 1.0 / 256.0;
|
||||||
|
x -= x_delta;
|
||||||
|
|
||||||
|
if self.x_inertia.abs() > MIN_INERTIA {
|
||||||
|
self.x_inertia /= self.inertia_falloff;
|
||||||
|
|
||||||
|
if !response.dragged() {
|
||||||
|
x -= self.x_inertia;
|
||||||
|
|
||||||
|
}
|
||||||
|
ctx.request_repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
self.x_inertia += x_delta * self.inertia_scale;
|
||||||
|
|
||||||
|
let y_delta = xy_delta.y as f64 * 1.0 / 256.0;
|
||||||
|
y -= y_delta;
|
||||||
|
|
||||||
|
if self.y_inertia.abs() > MIN_INERTIA {
|
||||||
|
if !response.dragged() {
|
||||||
|
y -= self.y_inertia;
|
||||||
|
ctx.request_repaint();
|
||||||
|
}
|
||||||
|
self.y_inertia /= self.inertia_falloff;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.y_inertia += y_delta * self.inertia_scale;
|
||||||
|
|
||||||
|
|
||||||
let long_deg = x / n * 360.0 - 180.0;
|
let long_deg = x / n * 360.0 - 180.0;
|
||||||
let lat_rad = (std::f64::consts::PI * (1.0 - 2.0 * y / n)).sinh().atan();
|
let lat_rad = (std::f64::consts::PI * (1.0 - 2.0 * y / n)).sinh().atan();
|
||||||
|
@ -203,7 +254,7 @@ impl Map {
|
||||||
);
|
);
|
||||||
self.process_input(ctx, ui, rect, response);
|
self.process_input(ctx, ui, rect, response);
|
||||||
let tileset = self.load_tiles(ctx, rect.width() as usize, rect.height() as usize);
|
let tileset = self.load_tiles(ctx, rect.width() as usize, rect.height() as usize);
|
||||||
let render = self.render.clone();
|
let render = self.render.as_ref().unwrap().clone();
|
||||||
let options = self.options;
|
let options = self.options;
|
||||||
let width = rect.width();
|
let width = rect.width();
|
||||||
let height = rect.height();
|
let height = rect.height();
|
||||||
|
|
|
@ -4,6 +4,7 @@ use std::io::Cursor;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use glow::{Buffer, HasContext, PixelUnpackData, Program, Texture, VertexArray};
|
use glow::{Buffer, HasContext, PixelUnpackData, Program, Texture, VertexArray};
|
||||||
use image::{DynamicImage, EncodableLayout, ImageReader};
|
use image::{DynamicImage, EncodableLayout, ImageReader};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
use crate::map::tiles::{LayerId, XCoord, YCoord, ZoomLevel};
|
use crate::map::tiles::{LayerId, XCoord, YCoord, ZoomLevel};
|
||||||
use crate::map::Tileset;
|
use crate::map::Tileset;
|
||||||
|
@ -224,6 +225,6 @@ impl MapRender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, Serialize, Deserialize)]
|
||||||
pub struct ExtraRenderOptions {
|
pub struct ExtraRenderOptions {
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
use std::collections::{BTreeMap, HashMap};
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use image::DynamicImage;
|
use image::DynamicImage;
|
||||||
use poll_promise::Promise;
|
use poll_promise::Promise;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
// type aliases to make the tile map less hellish
|
// type aliases to make the tile map less hellish
|
||||||
pub type ZoomLevel = usize;
|
pub type ZoomLevel = usize;
|
||||||
|
@ -8,9 +9,11 @@ pub type XCoord = usize;
|
||||||
pub type YCoord = usize;
|
pub type YCoord = usize;
|
||||||
pub type LayerId = u64;
|
pub type LayerId = u64;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Serialize, Deserialize)]
|
||||||
|
#[serde(default)]
|
||||||
pub struct LayerManager {
|
pub struct LayerManager {
|
||||||
pub layers: Vec<LayerId>,
|
pub layers: Vec<LayerId>,
|
||||||
|
#[serde(skip)]
|
||||||
pub tiles: HashMap<(ZoomLevel, XCoord, YCoord, LayerId), Tile>,
|
pub tiles: HashMap<(ZoomLevel, XCoord, YCoord, LayerId), Tile>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue