Compare commits
5 Commits
web-size-h
...
web-map
| Author | SHA1 | Date | |
|---|---|---|---|
| 265f2a2c70 | |||
| 3c516badd4 | |||
| 00dce54aea | |||
| 1c86219dbe | |||
| cee5731e6c |
@@ -59,10 +59,13 @@ impl std::fmt::Display for LoadError{
|
|||||||
}
|
}
|
||||||
impl std::error::Error for LoadError{}
|
impl std::error::Error for LoadError{}
|
||||||
|
|
||||||
pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::CompleteMap,LoadError>{
|
pub fn load_file<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::CompleteMap,LoadError>{
|
||||||
//blocking because it's simpler...
|
//blocking because it's simpler...
|
||||||
let file=std::fs::File::open(path).map_err(LoadError::File)?;
|
let file=std::fs::File::open(path).map_err(LoadError::File)?;
|
||||||
match read(file).map_err(LoadError::ReadError)?{
|
load(file)
|
||||||
|
}
|
||||||
|
pub fn load<R:Read+std::io::Seek>(reader:R)->Result<strafesnet_common::map::CompleteMap,LoadError>{
|
||||||
|
match read(reader).map_err(LoadError::ReadError)?{
|
||||||
#[cfg(feature="snf")]
|
#[cfg(feature="snf")]
|
||||||
DataStructure::StrafesNET(map)=>Ok(map),
|
DataStructure::StrafesNET(map)=>Ok(map),
|
||||||
#[cfg(feature="roblox")]
|
#[cfg(feature="roblox")]
|
||||||
|
|||||||
@@ -211,13 +211,13 @@ pub async fn setup_and_start(title:String){
|
|||||||
setup_context,
|
setup_context,
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(arg)=std::env::args().nth(1){
|
//if let Some(arg)=std::env::args().nth(1){
|
||||||
let path=std::path::PathBuf::from(arg);
|
//let path=std::path::PathBuf::from(arg);
|
||||||
window_thread.send(TimedInstruction{
|
window_thread.send(TimedInstruction{
|
||||||
time:integer::Time::ZERO,
|
time:integer::Time::ZERO,
|
||||||
instruction:WindowInstruction::WindowEvent(winit::event::WindowEvent::DroppedFile(path)),
|
instruction:WindowInstruction::WindowEvent(winit::event::WindowEvent::DroppedFile("".into())),
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
};
|
//};
|
||||||
|
|
||||||
println!("Entering event loop...");
|
println!("Entering event loop...");
|
||||||
let root_time=chrono::Utc::now();
|
let root_time=chrono::Utc::now();
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ impl WindowContext<'_>{
|
|||||||
}
|
}
|
||||||
fn window_event(&mut self,time:integer::Time,event:winit::event::WindowEvent){
|
fn window_event(&mut self,time:integer::Time,event:winit::event::WindowEvent){
|
||||||
match event{
|
match event{
|
||||||
winit::event::WindowEvent::DroppedFile(path)=>{
|
winit::event::WindowEvent::DroppedFile(_path)=>{
|
||||||
match crate::file::load(path.as_path()){
|
//match crate::file::load_file(path.as_path()){
|
||||||
|
let data=include_bytes!("/run/media/quat/Files/Documents/map-files/verify-scripts/maps/bhop_snfm/5692152916.snfm");
|
||||||
|
match crate::file::load(std::io::Cursor::new(data.as_slice())){
|
||||||
Ok(map)=>self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::ChangeMap(map)}).unwrap(),
|
Ok(map)=>self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::ChangeMap(map)}).unwrap(),
|
||||||
Err(e)=>println!("Failed to load map: {e}"),
|
Err(e)=>println!("Failed to load map: {e}"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1"/>
|
||||||
<title>Strafe Client</title>
|
<title>Strafe Client</title>
|
||||||
|
|
||||||
<base data-trunk-public-url />
|
<base data-trunk-public-url />
|
||||||
@@ -13,25 +13,13 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
.root {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
.main-canvas {
|
.main-canvas {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
/* This allows the flexbox to grow to max size, this is needed for WebGPU */
|
|
||||||
flex: 1;
|
|
||||||
/* This forces CSS to ignore the width/height of the canvas, this is needed for WebGL */
|
|
||||||
contain: size;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="root">
|
<canvas class="main-canvas" id="canvas"></canvas>
|
||||||
<canvas class="main-canvas" id="canvas"></canvas>
|
|
||||||
</div>
|
|
||||||
<link data-trunk rel="rust" href="../strafe-client/Cargo.toml"/>
|
<link data-trunk rel="rust" href="../strafe-client/Cargo.toml"/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user