more refactor

This commit is contained in:
2025-11-18 02:38:23 -05:00
parent db15f43610
commit 01cd02c0f9
11 changed files with 39 additions and 24 deletions

View File

@@ -18,3 +18,11 @@ winit = "0.30.12"
bincode = "2.0.1" bincode = "2.0.1"
zstd = "0.13.3" zstd = "0.13.3"
ron = "0.12.0" ron = "0.12.0"
[[bin]]
name = "openworm-client"
path = "src/bin/client/main.rs"
[[bin]]
name = "openworm-server"
path = "src/bin/server/main.rs"

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@@ -1,13 +1,18 @@
#![windows_subsystem = "windows"] #![windows_subsystem = "windows"]
use crate::{app::App, net::NetSender, ui::*}; use crate::{
app::App,
net::NetSender,
rsc::{CLIENT_DATA, ClientData},
ui::*,
};
pub use app::AppHandle; pub use app::AppHandle;
use arboard::Clipboard; use arboard::Clipboard;
use input::Input; use input::Input;
use iris::prelude::*; use iris::prelude::*;
use openworm::{ use openworm::{
net::{ClientMsg, ServerMsg, install_crypto_provider}, net::{ClientMsg, ServerMsg, install_crypto_provider},
rsc::{CLIENT_DATA, ClientData, DataDir}, rsc::DataDir,
}; };
use render::Renderer; use render::Renderer;
use std::sync::Arc; use std::sync::Arc;
@@ -17,17 +22,18 @@ use winit::{
window::Window, window::Window,
}; };
fn main() {
install_crypto_provider();
App::run();
}
mod app; mod app;
mod input; mod input;
mod net; mod net;
mod render; mod render;
mod rsc;
mod ui; mod ui;
fn main() {
install_crypto_provider();
App::run();
}
pub enum ClientEvent { pub enum ClientEvent {
Connect { send: NetSender, username: String }, Connect { send: NetSender, username: String },
ServerMsg(ServerMsg), ServerMsg(ServerMsg),

16
src/bin/client/rsc.rs Normal file
View File

@@ -0,0 +1,16 @@
pub const CLIENT_DATA: &str = "client_data";
#[derive(bincode::Encode, bincode::Decode)]
pub struct ClientData {
pub ip: String,
pub username: String,
}
impl Default for ClientData {
fn default() -> Self {
Self {
ip: "localhost:39420".to_string(),
username: "your [NOVEMBER]".to_string(),
}
}
}

View File

@@ -1,3 +1,5 @@
// stolen default impl from example
use quinn::rustls::{self, pki_types::*}; use quinn::rustls::{self, pki_types::*};
use std::sync::Arc; use std::sync::Arc;

View File

@@ -7,8 +7,6 @@ use directories_next::ProjectDirs;
use crate::net::BINCODE_CONFIG; use crate::net::BINCODE_CONFIG;
pub const CLIENT_DATA: &str = "client_data";
pub struct DataDir { pub struct DataDir {
dirs: ProjectDirs, dirs: ProjectDirs,
} }
@@ -44,18 +42,3 @@ impl DataDir {
bincode::encode_into_std_write(data, &mut file, BINCODE_CONFIG).unwrap(); bincode::encode_into_std_write(data, &mut file, BINCODE_CONFIG).unwrap();
} }
} }
#[derive(bincode::Encode, bincode::Decode)]
pub struct ClientData {
pub ip: String,
pub username: String,
}
impl Default for ClientData {
fn default() -> Self {
Self {
ip: "localhost:39420".to_string(),
username: "your [NOVEMBER]".to_string(),
}
}
}