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