Compare commits

...

16 Commits

Author SHA1 Message Date
6251c2d1b2 hack camera offset 2026-01-22 09:51:04 -08:00
21a90438f9 marble 2026-01-22 09:51:04 -08:00
edf1d8b699 bot file playback 2026-01-22 09:51:04 -08:00
fbd0f26958 add strafesnet_roblox_bot_file dep 2026-01-22 09:51:04 -08:00
848874d889 fix release build 2026-01-22 09:51:04 -08:00
6eae3bc350 optional directories 2026-01-22 09:51:04 -08:00
ae369085e3 toc 2026-01-22 09:51:04 -08:00
d86d7259d7 include map in binary 2026-01-22 09:51:04 -08:00
7843b414e7 use existing canvas 2026-01-22 09:51:04 -08:00
f9d4a8c344 use chrono instead of std::time 2026-01-22 09:51:04 -08:00
594684aea4 pick up wasm dep 2026-01-22 09:51:04 -08:00
fab7349b3e color functions 2026-01-22 09:51:04 -08:00
1c4a58de8b attach canvas 2026-01-22 09:51:04 -08:00
a310173182 replace enumerate_adapters with request_adapter 2026-01-22 09:51:04 -08:00
448b12f353 drop Send requirement 2026-01-22 09:51:04 -08:00
a4acb87a0d Initial trunk 2026-01-22 09:51:04 -08:00
15 changed files with 296 additions and 79 deletions

18
Cargo.lock generated
View File

@@ -3834,6 +3834,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
name = "strafe-client"
version = "0.11.0"
dependencies = [
"chrono",
"glam",
"parking_lot",
"pollster",
@@ -3843,9 +3844,13 @@ dependencies = [
"strafesnet_graphics",
"strafesnet_physics",
"strafesnet_rbx_loader",
"strafesnet_roblox_bot_file",
"strafesnet_session",
"strafesnet_settings",
"strafesnet_snf",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"wgpu",
"winit",
]
@@ -3926,6 +3931,17 @@ dependencies = [
"strafesnet_deferred_loader",
]
[[package]]
name = "strafesnet_roblox_bot_file"
version = "0.8.1"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "33d0fa524476d8b6cf23269b0c9cff6334b70585546b807cb8ec193858defecd"
dependencies = [
"binrw 0.15.0",
"bitflags 2.10.0",
"itertools 0.14.0",
]
[[package]]
name = "strafesnet_session"
version = "0.1.0"
@@ -4991,7 +5007,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.61.2",
"windows-sys 0.48.0",
]
[[package]]

View File

@@ -262,6 +262,15 @@ pub struct PhysicsCamera{
impl PhysicsCamera{
const ANGLE_PITCH_LOWER_LIMIT:Angle32=Angle32::NEG_FRAC_PI_2;
const ANGLE_PITCH_UPPER_LIMIT:Angle32=Angle32::FRAC_PI_2;
pub fn new(
sensitivity:Ratio64Vec2,
clamped_mouse_pos:glam::IVec2,
)->Self{
Self{
sensitivity,
clamped_mouse_pos,
}
}
pub fn move_mouse(&mut self,mouse_delta:glam::IVec2){
let mut unclamped_mouse_pos=self.clamped_mouse_pos+mouse_delta;
unclamped_mouse_pos.y=unclamped_mouse_pos.y.clamp(
@@ -874,7 +883,7 @@ pub struct PhysicsState{
//input_state
input_state:InputState,
//style
style:StyleModifiers,//mode style with custom style updates applied
pub style:StyleModifiers,//mode style with custom style updates applied
//gameplay_state
mode_state:ModeState,
move_state:MoveState,

View File

@@ -149,7 +149,7 @@ enum ViewState{
}
pub struct Session{
directories:Directories,
directories:Option<Directories>,
user_settings:UserSettings,
mouse_interpolator:MouseInterpolator,
view_state:ViewState,
@@ -164,7 +164,7 @@ pub struct Session{
impl Session{
pub fn new(
user_settings:UserSettings,
directories:Directories,
directories:Option<Directories>,
simulation:Simulation,
)->Self{
Self{
@@ -305,7 +305,8 @@ impl InstructionConsumer<Instruction<'_>> for Session{
match view_state{
ViewState::Play=>(),
ViewState::Replay(bot_id)=>if let Some(replay)=self.replays.remove(&bot_id){
let mut replays_path=self.directories.replays.clone();
if let Some(directories)=&self.directories{
let mut replays_path=directories.replays.clone();
let file_name=format!("{}.snfb",ins.time);
std::thread::spawn(move ||{
std::fs::create_dir_all(replays_path.as_path()).unwrap();
@@ -318,6 +319,7 @@ impl InstructionConsumer<Instruction<'_>> for Session{
).unwrap();
println!("Finished writing bot file!");
});
}
},
}
_=self.simulation.timer.set_paused(ins.time,false);

View File

@@ -16,6 +16,7 @@ source = ["dep:strafesnet_deferred_loader", "dep:strafesnet_bsp_loader"]
roblox = ["dep:strafesnet_deferred_loader", "dep:strafesnet_rbx_loader"]
[dependencies]
chrono = "0.4.39"
glam = "0.30.0"
parking_lot = "0.12.1"
pollster = "0.4.0"
@@ -25,9 +26,13 @@ strafesnet_deferred_loader = { path = "../lib/deferred_loader", registry = "stra
strafesnet_graphics = { path = "../engine/graphics", registry = "strafesnet" }
strafesnet_physics = { path = "../engine/physics", registry = "strafesnet" }
strafesnet_rbx_loader = { path = "../lib/rbx_loader", registry = "strafesnet", optional = true }
strafesnet_roblox_bot_file = { version = "0.8.1", registry = "strafesnet" }
strafesnet_session = { path = "../engine/session", registry = "strafesnet" }
strafesnet_settings = { path = "../engine/settings", registry = "strafesnet" }
strafesnet_snf = { path = "../lib/snf", registry = "strafesnet", optional = true }
wasm-bindgen = "0.2.99"
wasm-bindgen-futures = "0.4.49"
web-sys = { version = "0.3.76", features = ["console"] }
wgpu = "28.0.0"
winit = "0.30.7"

View File

@@ -4,12 +4,12 @@ use strafesnet_common::instruction::TimedInstruction;
use strafesnet_common::session::Time as SessionTime;
pub struct App<'a>{
root_time:std::time::Instant,
root_time:chrono::DateTime<chrono::Utc>,
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
}
impl<'a> App<'a>{
pub fn new(
root_time:std::time::Instant,
root_time:chrono::DateTime<chrono::Utc>,
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
)->App<'a>{
Self{
@@ -18,7 +18,7 @@ impl<'a> App<'a>{
}
}
fn send_timed_instruction(&mut self,instruction:Instruction){
let time=integer::Time::from_nanos(self.root_time.elapsed().as_nanos() as i64);
let time=integer::Time::from_nanos((chrono::Utc::now()-self.root_time).num_nanoseconds().unwrap());
self.window_thread.send(TimedInstruction{time,instruction}).unwrap();
}
}

View File

@@ -2,11 +2,11 @@ pub type QNWorker<'a,Task>=CompatNWorker<'a,Task>;
pub type INWorker<'a,Task>=CompatNWorker<'a,Task>;
pub struct CompatNWorker<'a,Task>{
f:Box<dyn FnMut(Task)+Send+'a>,
f:Box<dyn FnMut(Task)+'a>,
}
impl<'a,Task> CompatNWorker<'a,Task>{
pub fn new(f:impl FnMut(Task)+Send+'a)->CompatNWorker<'a,Task>{
pub fn new(f:impl FnMut(Task)+'a)->CompatNWorker<'a,Task>{
Self{
f:Box::new(f),
}

View File

@@ -87,10 +87,13 @@ pub enum LoadFormat{
Bot(strafesnet_snf::bot::Segment),
}
pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<LoadFormat,LoadError>{
pub fn load_file<P:AsRef<std::path::Path>>(path:P)->Result<LoadFormat,LoadError>{
//blocking because it's simpler...
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<LoadFormat,LoadError>{
match read(reader).map_err(LoadError::ReadError)?{
#[cfg(feature="snf")]
ReadFormat::SNFB(bot)=>Ok(LoadFormat::Bot(bot)),
#[cfg(feature="snf")]

View File

@@ -33,12 +33,12 @@ pub fn new(
},
Instruction::Resize(size,user_settings)=>{
println!("Resizing to {:?}",size);
let t0=std::time::Instant::now();
//let t0=std::time::Instant::now();
config.width=size.width.max(1);
config.height=size.height.max(1);
surface.configure(&device,&config);
graphics.resize(&device,&config,&user_settings);
println!("Resize took {:?}",t0.elapsed());
//println!("Resize took {:?}",t0.elapsed());
}
Instruction::Render(frame_state)=>{
//this has to go deeper somehow

View File

@@ -9,5 +9,8 @@ mod graphics_worker;
const TITLE:&'static str=concat!("Strafe Client v",env!("CARGO_PKG_VERSION"));
fn main(){
setup::setup_and_start(TITLE);
#[cfg(target_arch="wasm32")]
wasm_bindgen_futures::spawn_local(setup::setup_and_start(TITLE));
#[cfg(not(target_arch="wasm32"))]
pollster::block_on(setup::setup_and_start(TITLE));
}

View File

@@ -1,13 +1,15 @@
use crate::graphics_worker::Instruction as GraphicsInstruction;
use strafesnet_settings::{directories::Directories,settings};
use strafesnet_session::session::{
FrameState,
Session,Simulation,SessionInputInstruction,SessionControlInstruction,SessionPlaybackInstruction,ImplicitModeInstruction,
Instruction as SessionInstruction,
};
use strafesnet_common::instruction::{TimedInstruction,InstructionConsumer};
use strafesnet_common::physics::Time as PhysicsTime;
use strafesnet_common::session::Time as SessionTime;
use strafesnet_common::timer::Timer;
use strafesnet_common::instruction::TimedInstruction;
use strafesnet_common::physics::{Time as PhysicsTime,TimeInner as PhysicsTimeInner};
use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner};
use strafesnet_common::timer::{Scaled,Timer,TimerState};
use strafesnet_physics::physics::PhysicsData;
pub enum Instruction{
SessionInput(SessionInputInstruction),
@@ -19,12 +21,136 @@ pub enum Instruction{
LoadReplay(strafesnet_snf::bot::Segment),
}
fn vector3_to_glam(v:&strafesnet_roblox_bot_file::v0::Vector3)->glam::Vec3{
glam::vec3(v.x,v.y,v.z)
}
fn f32_to_p64(f:f32)->strafesnet_common::integer::Planar64{
f.try_into().unwrap_or(strafesnet_common::integer::Planar64::ZERO)
}
struct PlayBacker{
//Instructions
timelines:strafesnet_roblox_bot_file::v0::Block,
//"Simulation"
event_id:usize,
offset:f64,
duration:f64,
timer:Timer<Scaled<SessionTimeInner,PhysicsTimeInner>>,
physics_data:PhysicsData,
camera_offset:strafesnet_common::integer::Planar64Vec3,
}
impl PlayBacker{
pub fn new(
physics_data:PhysicsData,
timelines:strafesnet_roblox_bot_file::v0::Block,
camera_offset:strafesnet_common::integer::Planar64Vec3,
)->Self{
let first=timelines.output_events.first().unwrap();
let last=timelines.output_events.last().unwrap();
Self{
offset:first.time,
duration:last.time-first.time,
timelines,
event_id:0,
timer:Timer::from_state(Scaled::identity(),false),
physics_data,
camera_offset,
}
}
pub fn handle_instruction(&mut self,TimedInstruction{time,instruction}:&TimedInstruction<SessionInstruction,SessionTime>){
//match the instruction so the playback is pausable :D
match instruction{
&SessionInstruction::Control(SessionControlInstruction::SetPaused(paused))=>{
let _=self.timer.set_paused(*time,paused);
},
_=>(),
}
let simulation_time=self.timer.time(*time);
let mut time_float=simulation_time.get() as f64/PhysicsTime::ONE_SECOND.get() as f64+self.offset;
loop{
match self.timelines.output_events.get(self.event_id+1){
Some(next_event)=>{
if next_event.time<time_float{
self.event_id+=1;
}else{
break;
}
},
None=>{
//reset playback
self.event_id=0;
self.offset-=self.duration;
time_float-=self.duration;
},
}
}
}
pub fn get_frame_state(&self,time:SessionTime)->FrameState{
use strafesnet_physics::physics::{Body,PhysicsCamera};
let time=self.timer.time(time);
let event0=&self.timelines.output_events[self.event_id];
let event1=&self.timelines.output_events[self.event_id+1];
let p0=vector3_to_glam(&event0.event.position);
let p1=vector3_to_glam(&event1.event.position);
let v0=vector3_to_glam(&event0.event.velocity);
let v1=vector3_to_glam(&event1.event.velocity);
let a0=vector3_to_glam(&event0.event.acceleration);
let a1=vector3_to_glam(&event1.event.acceleration);
let t0=event0.time;
let t1=event1.time;
let time_float=time.get() as f64/PhysicsTime::ONE_SECOND.get() as f64;
let t=((time_float+self.offset-t0)/(t1-t0)) as f32;
let p=p0.lerp(p1,t).to_array().map(f32_to_p64);
let v=v0.lerp(v1,t).to_array().map(f32_to_p64);
let a=a0.lerp(a1,t).to_array().map(f32_to_p64);
//println!("position={:?}",p);
let angles0=vector3_to_glam(&event0.event.angles);
let angles1=vector3_to_glam(&event1.event.angles);
let angles=angles0.lerp(angles1,t);
// mask mantissa out and set it to minimum value
// let ax_epsilon=f32::from_bits(angles.x.to_bits()&!((1<<23)-1)|1);
// let ay_epsilon=f32::from_bits(angles.y.to_bits()&!((1<<23)-1)|1);
let body=Body{
time,
position:strafesnet_common::integer::Planar64Vec3::new(p)+self.camera_offset,
velocity:strafesnet_common::integer::Planar64Vec3::new(v),
acceleration:strafesnet_common::integer::Planar64Vec3::new(a),
};
const FLOAT64_TO_ANGLE32_RADIANS:f64=((1i64<<31) as f64)/std::f64::consts::PI;
// xy is reversed in strafe client for some reason
let (ax,ay)=(
-angles.y as f64*FLOAT64_TO_ANGLE32_RADIANS,
-angles.x as f64*FLOAT64_TO_ANGLE32_RADIANS,
);
let camera=PhysicsCamera::new(
strafesnet_common::integer::Ratio64Vec2::new(1.0f32.try_into().unwrap(),1.0f32.try_into().unwrap()),
glam::ivec2(ax as i64 as i32,ay as i64 as i32)
);
FrameState{
body,
camera,
time,
}
}
pub fn user_settings(&self)->settings::UserSettings{
//oof, settings ignored
settings::UserSettings::default()
}
pub fn change_map(&mut self,_time:SessionTime,map:&strafesnet_common::map::CompleteMap){
self.physics_data=PhysicsData::new(&map);
}
}
pub fn new<'a>(
mut graphics_worker:crate::compat_worker::INWorker<'a,crate::graphics_worker::Instruction>,
directories:Directories,
directories:Option<Directories>,
user_settings:settings::UserSettings,
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>{
let physics=strafesnet_physics::physics::PhysicsState::default();
let camera_offset=physics.style.camera_offset;
let timer=Timer::unpaused(SessionTime::ZERO,PhysicsTime::ZERO);
let simulation=Simulation::new(timer,physics);
let mut session=Session::new(
@@ -32,11 +158,20 @@ pub fn new<'a>(
directories,
simulation,
);
//load bot
let physics=PhysicsData::empty();
let data=include_bytes!("/home/quat/strafesnet/roblox_bot_file/files/bhop_marble_7cf33a64-7120-4514-b9fa-4fe29d9523d");
let bot_file=strafesnet_roblox_bot_file::v0::read_all_to_block(std::io::Cursor::new(data)).unwrap();
let mut interpolator=PlayBacker::new(
physics,
bot_file,
camera_offset,
);
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction,SessionTime>|{
// excruciating pain
macro_rules! run_session_instruction{
($time:expr,$instruction:expr)=>{
session.process_instruction(TimedInstruction{
interpolator.handle_instruction(&TimedInstruction{
time:$time,
instruction:$instruction,
});
@@ -59,16 +194,17 @@ pub fn new<'a>(
},
Instruction::Render=>{
run_session_instruction!(ins.time,SessionInstruction::Idle);
if let Some(frame_state)=session.get_frame_state(ins.time){
if let Some(frame_state)=Some(interpolator.get_frame_state(ins.time)){
run_graphics_worker_instruction!(GraphicsInstruction::Render(frame_state));
}
},
Instruction::Resize(physical_size)=>{
run_session_instruction!(ins.time,SessionInstruction::Idle);
let user_settings=session.user_settings().clone();
let user_settings=interpolator.user_settings().clone();
run_graphics_worker_instruction!(GraphicsInstruction::Resize(physical_size,user_settings));
},
Instruction::ChangeMap(complete_map)=>{
interpolator.change_map(ins.time,&complete_map);
run_session_instruction!(ins.time,SessionInstruction::ChangeMap(&complete_map));
run_session_instruction!(ins.time,SessionInstruction::Input(SessionInputInstruction::Mode(ImplicitModeInstruction::ResetAndSpawn(strafesnet_common::gameplay_modes::ModeId::MAIN,strafesnet_common::gameplay_modes::StageId::FIRST))));
run_graphics_worker_instruction!(GraphicsInstruction::ChangeMap(complete_map));

View File

@@ -20,6 +20,16 @@ struct SetupContextPartial1{
fn create_window(title:&str,event_loop:&winit::event_loop::EventLoop<()>)->Result<winit::window::Window,winit::error::OsError>{
let mut attr=winit::window::WindowAttributes::default();
attr=attr.with_title(title);
#[cfg(target_arch="wasm32")]
{
use wasm_bindgen::JsCast;
use winit::platform::web::WindowAttributesExtWebSys;
let canvas=web_sys::window().unwrap()
.document().unwrap()
.get_element_by_id("canvas").unwrap()
.dyn_into::<web_sys::HtmlCanvasElement>().unwrap();
attr=attr.with_canvas(Some(canvas));
}
event_loop.create_window(attr)
}
fn create_instance()->SetupContextPartial1{
@@ -44,43 +54,20 @@ struct SetupContextPartial2<'a>{
surface:wgpu::Surface<'a>,
}
impl<'a> SetupContextPartial2<'a>{
fn pick_adapter(self)->SetupContextPartial3<'a>{
async fn pick_adapter(self)->SetupContextPartial3<'a>{
let adapter;
//TODO: prefer adapter that implements optional features
//let optional_features=optional_features();
let required_features=required_features();
//no helper function smh gotta write it myself
let adapters=pollster::block_on(self.instance.enumerate_adapters(self.backends));
let mut chosen_adapter=None;
let mut chosen_adapter_score=0;
for adapter in adapters {
if !adapter.is_surface_supported(&self.surface) {
continue;
}
let score=match adapter.get_info().device_type{
wgpu::DeviceType::IntegratedGpu=>3,
wgpu::DeviceType::DiscreteGpu=>4,
wgpu::DeviceType::VirtualGpu=>2,
wgpu::DeviceType::Other|wgpu::DeviceType::Cpu=>1,
};
let adapter_features=adapter.features();
if chosen_adapter_score<score&&adapter_features.contains(required_features) {
chosen_adapter_score=score;
chosen_adapter=Some(adapter);
}
}
if let Some(maybe_chosen_adapter)=chosen_adapter{
adapter=maybe_chosen_adapter;
}else{
panic!("No suitable GPU adapters found on the system!");
}
let chosen_adapter=self.instance.request_adapter(&wgpu::RequestAdapterOptions{
power_preference:wgpu::PowerPreference::HighPerformance,
force_fallback_adapter:false,
compatible_surface:Some(&self.surface),
}).await;
adapter=chosen_adapter.unwrap();
let adapter_info=adapter.get_info();
println!("Using {} ({:?})", adapter_info.name, adapter_info.backend);
@@ -110,14 +97,15 @@ struct SetupContextPartial3<'a>{
adapter:wgpu::Adapter,
}
impl<'a> SetupContextPartial3<'a>{
fn request_device(self)->SetupContextPartial4<'a>{
async fn request_device(self)->SetupContextPartial4<'a>{
let optional_features=optional_features();
let required_features=required_features();
// Make sure we use the texture resolution limits from the adapter, so we can support images the size of the surface.
let needed_limits=strafesnet_graphics::graphics::required_limits().using_resolution(self.adapter.limits());
let (device, queue)=pollster::block_on(self.adapter
let trace_dir=std::env::var("WGPU_TRACE");
let (device, queue)=self.adapter
.request_device(
&wgpu::DeviceDescriptor{
label:None,
@@ -127,7 +115,7 @@ impl<'a> SetupContextPartial3<'a>{
trace:wgpu::Trace::Off,
experimental_features:wgpu::ExperimentalFeatures::disabled(),
},
))
).await
.expect("Unable to find a suitable GPU adapter!");
SetupContextPartial4{
@@ -169,7 +157,7 @@ pub struct SetupContext<'a>{
pub config:wgpu::SurfaceConfiguration,
}
pub fn setup_and_start(title:&str){
pub async fn setup_and_start(title:&str){
let event_loop=winit::event_loop::EventLoop::new().unwrap();
println!("Initializing the surface...");
@@ -180,9 +168,9 @@ pub fn setup_and_start(title:&str){
let partial_2=partial_1.create_surface(&window).unwrap();
let partial_3=partial_2.pick_adapter();
let partial_3=partial_2.pick_adapter().await;
let partial_4=partial_3.request_device();
let partial_4=partial_3.request_device().await;
let size=window.inner_size();
@@ -196,16 +184,16 @@ pub fn setup_and_start(title:&str){
setup_context,
);
for arg in std::env::args().skip(1){
//for arg in std::env::args().skip(1){
window_thread.send(strafesnet_common::instruction::TimedInstruction{
time:strafesnet_common::integer::Time::ZERO,
instruction:crate::window::Instruction::WindowEvent(winit::event::WindowEvent::DroppedFile(arg.into())),
instruction:crate::window::Instruction::WindowEvent(winit::event::WindowEvent::DroppedFile("".into())),
}).unwrap();
};
//};
println!("Entering event loop...");
let mut app=crate::app::App::new(
std::time::Instant::now(),
chrono::Utc::now(),
window_thread
);
event_loop.run_app(&mut app).unwrap();

View File

@@ -57,7 +57,8 @@ impl WindowContext<'_>{
fn window_event(&mut self,time:SessionTime,event:winit::event::WindowEvent){
match event{
winit::event::WindowEvent::DroppedFile(path)=>{
match crate::file::load(path.as_path()){
let data=include_bytes!("/run/media/quat/Files/Documents/map-files/strafesnet/maps/bhop_snfm/5692093612.snfm");
match crate::file::load(std::io::Cursor::new(data)){
Ok(LoadFormat::Map(map))=>self.physics_thread.send(TimedInstruction{time,instruction:PhysicsWorkerInstruction::ChangeMap(map)}).unwrap(),
Ok(LoadFormat::Bot(bot))=>self.physics_thread.send(TimedInstruction{time,instruction:PhysicsWorkerInstruction::LoadReplay(bot)}).unwrap(),
Err(e)=>println!("Failed to load file: {e}"),
@@ -236,17 +237,21 @@ impl WindowContext<'_>{
}
}
}
pub fn worker<'a>(
window:&'a winit::window::Window,
setup_context:crate::setup::SetupContext<'a>,
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>{
// WindowContextSetup::new
#[cfg(feature="user-install")]
let directories=Directories::user().unwrap();
let directories=Directories::user();
#[cfg(not(feature="user-install"))]
let directories=Directories::portable().unwrap();
let directories=Directories::portable().ok();
let user_settings=directories.settings();
let user_settings=match &directories{
Some(directories)=>directories.settings(),
None=>strafesnet_settings::settings::UserSettings::default(),
};
let mut graphics=strafesnet_graphics::graphics::GraphicsState::new(&setup_context.device,&setup_context.queue,&setup_context.config);
graphics.load_user_settings(&user_settings);

1
web-client/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/dist

2
web-client/Trunk.toml Normal file
View File

@@ -0,0 +1,2 @@
[build]
target = "index.html"

47
web-client/index.html Normal file
View File

@@ -0,0 +1,47 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, height=device-height, initial-scale=1"
/>
<title>Strafe Client</title>
<base data-trunk-public-url />
<style type="text/css">
:focus {
outline: none;
}
body {
margin: 0px;
background: #fff;
width: 100%;
height: 100%;
}
#content {
/* This allows the flexbox to grow to max size, this is needed for WebGPU */
flex: 1 1 100%;
/* This forces CSS to ignore the width/height of the canvas, this is needed for WebGL */
contain: size;
}
.main-canvas {
margin: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<canvas class="main-canvas" id="canvas"></canvas>
<link
data-trunk
rel="rust"
href="../strafe-client/Cargo.toml"
data-wasm-opt-params="--enable-bulk-memory --enable-nontrapping-float-to-int"
/>
</body>
</html>