mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 08:18:43 -06:00
fix some stuff
This commit is contained in:
parent
2656f5af21
commit
363dcddeca
|
@ -3,20 +3,19 @@ use winit::{keyboard::KeyCode, event_loop::ControlFlow};
|
|||
use crate::input::RawKbmInputState;
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct SetControlFlow(pub Option<ControlFlow>);
|
||||
pub struct RequestExit(pub bool);
|
||||
|
||||
pub fn exit_on_esc(
|
||||
raw_inputs: UniqueView<RawKbmInputState>,
|
||||
mut control_flow: UniqueViewMut<SetControlFlow>
|
||||
mut exit: UniqueViewMut<RequestExit>
|
||||
) {
|
||||
if raw_inputs.keyboard_state.contains(KeyCode::Escape as u32) {
|
||||
//TODO MIGRATION: fix exit on esc
|
||||
//control_flow.0 = Some(ControlFlow::Exit);
|
||||
exit.0 = true;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_control_flow_unique(
|
||||
storages: AllStoragesView
|
||||
) {
|
||||
storages.add_unique(SetControlFlow(None))
|
||||
storages.add_unique(RequestExit(false))
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ use rendering::{
|
|||
use block_placement::update_block_placement;
|
||||
use delta_time::{DeltaTime, init_delta_time};
|
||||
use cursor_lock::{insert_lock_state, update_cursor_lock_state, lock_cursor_now};
|
||||
use control_flow::{exit_on_esc, insert_control_flow_unique, SetControlFlow};
|
||||
use control_flow::{exit_on_esc, insert_control_flow_unique, RequestExit};
|
||||
use state::{is_ingame, is_ingame_or_loading, is_loading, init_state, update_state, is_connecting};
|
||||
use networking::{update_networking, update_networking_late, is_multiplayer, disconnect_on_exit, is_singleplayer};
|
||||
use init::initialize_from_args;
|
||||
|
@ -215,8 +215,8 @@ pub fn kubi_main() {
|
|||
|
||||
//Run the event loop
|
||||
let mut last_update = Instant::now();
|
||||
event_loop.run(move |event, target| {
|
||||
target.set_control_flow(ControlFlow::Poll);
|
||||
event_loop.run(move |event, window_target| {
|
||||
window_target.set_control_flow(ControlFlow::Poll);
|
||||
|
||||
process_glutin_events(&mut world, &event);
|
||||
#[allow(clippy::collapsible_match, clippy::single_match)]
|
||||
|
@ -224,7 +224,7 @@ pub fn kubi_main() {
|
|||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => {
|
||||
log::info!("exit requested");
|
||||
target.exit();
|
||||
window_target.exit();
|
||||
},
|
||||
_ => (),
|
||||
},
|
||||
|
@ -258,9 +258,8 @@ pub fn kubi_main() {
|
|||
world.run_workload(after_frame_end).unwrap();
|
||||
|
||||
//Process control flow changes
|
||||
if let Some(flow) = world.borrow::<UniqueView<SetControlFlow>>().unwrap().0 {
|
||||
//TODO MIGRATION
|
||||
//*control_flow = flow;
|
||||
if world.borrow::<UniqueView<RequestExit>>().unwrap().0 == true {
|
||||
window_target.exit();
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
|
|
|
@ -12,7 +12,7 @@ use kubi_shared::networking::{
|
|||
};
|
||||
use crate::{
|
||||
events::EventComponent,
|
||||
control_flow::SetControlFlow,
|
||||
control_flow::RequestExit,
|
||||
world::tasks::ChunkTaskManager,
|
||||
state::is_ingame_or_loading,
|
||||
fixed_timestamp::FixedTimestamp
|
||||
|
@ -155,20 +155,20 @@ pub fn update_networking_late() -> Workload {
|
|||
}
|
||||
|
||||
pub fn disconnect_on_exit(
|
||||
control_flow: UniqueView<SetControlFlow>,
|
||||
exit: UniqueView<RequestExit>,
|
||||
mut client: UniqueViewMut<UdpClient>,
|
||||
) {
|
||||
//TODO MIGRATION
|
||||
// if let Some(ControlFlow::ExitWithCode(_)) = control_flow.0 {
|
||||
// if client.0.is_active() {
|
||||
// client.0.flush();
|
||||
// client.0.disconnect();
|
||||
// while client.0.is_active() { client.0.step().for_each(|_|()); }
|
||||
// log::info!("Client disconnected");
|
||||
// } else {
|
||||
// log::info!("Client inactive")
|
||||
// }
|
||||
// }
|
||||
//TODO check if this works
|
||||
if exit.0 {
|
||||
if client.0.is_active() {
|
||||
client.0.flush();
|
||||
client.0.disconnect();
|
||||
while client.0.is_active() { client.0.step().for_each(|_|()); }
|
||||
log::info!("Client disconnected");
|
||||
} else {
|
||||
log::info!("Client inactive")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// conditions
|
||||
|
|
|
@ -36,7 +36,7 @@ impl Renderer {
|
|||
pub fn init(event_loop: &EventLoop<()>, settings: &GameSettings) -> Self {
|
||||
log::info!("initializing display");
|
||||
|
||||
let (window, display) = glium::backend::glutin::SimpleWindowBuilder::new().build(&event_loop);
|
||||
let (window, display) = glium::backend::glutin::SimpleWindowBuilder::new().build(event_loop);
|
||||
|
||||
// let wb = WindowBuilder::new()
|
||||
// .with_title("kubi")
|
||||
|
|
Loading…
Reference in a new issue