mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-22 06:48:43 -06:00
start fixing stuff
This commit is contained in:
parent
014e0e7824
commit
d50f4323b1
|
@ -1,5 +1,5 @@
|
||||||
use shipyard::{UniqueViewMut, UniqueView, View, IntoIter, ViewMut, EntitiesViewMut, Workload, IntoWorkload};
|
use shipyard::{UniqueViewMut, UniqueView, View, IntoIter, ViewMut, EntitiesViewMut, Workload, IntoWorkload};
|
||||||
use glium::glutin::event::VirtualKeyCode;
|
use winit::keyboard::KeyCode;
|
||||||
use kubi_shared::{
|
use kubi_shared::{
|
||||||
block::Block,
|
block::Block,
|
||||||
queue::QueuedBlock,
|
queue::QueuedBlock,
|
||||||
|
@ -7,20 +7,26 @@ use kubi_shared::{
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
player::MainPlayer,
|
player::MainPlayer,
|
||||||
world::{raycast::{LookingAtBlock, RAYCAST_STEP}, queue::BlockUpdateQueue},
|
world::{
|
||||||
|
raycast::{LookingAtBlock, RAYCAST_STEP},
|
||||||
|
queue::BlockUpdateQueue
|
||||||
|
},
|
||||||
input::{Inputs, PrevInputs, RawKbmInputState},
|
input::{Inputs, PrevInputs, RawKbmInputState},
|
||||||
events::{EventComponent, player_actions::PlayerActionEvent},
|
events::{
|
||||||
|
EventComponent,
|
||||||
|
player_actions::PlayerActionEvent
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const BLOCK_KEY_MAP: &[(VirtualKeyCode, Block)] = &[
|
const BLOCK_KEY_MAP: &[(KeyCode, Block)] = &[
|
||||||
(VirtualKeyCode::Key1, Block::Cobblestone),
|
(KeyCode::Digit1, Block::Cobblestone),
|
||||||
(VirtualKeyCode::Key2, Block::Planks),
|
(KeyCode::Digit2, Block::Planks),
|
||||||
(VirtualKeyCode::Key3, Block::Dirt),
|
(KeyCode::Digit3, Block::Dirt),
|
||||||
(VirtualKeyCode::Key4, Block::Grass),
|
(KeyCode::Digit4, Block::Grass),
|
||||||
(VirtualKeyCode::Key5, Block::Sand),
|
(KeyCode::Digit5, Block::Sand),
|
||||||
(VirtualKeyCode::Key6, Block::Stone),
|
(KeyCode::Digit6, Block::Stone),
|
||||||
(VirtualKeyCode::Key7, Block::Torch),
|
(KeyCode::Digit7, Block::Torch),
|
||||||
(VirtualKeyCode::Key8, Block::Leaf),
|
(KeyCode::Digit8, Block::Leaf),
|
||||||
];
|
];
|
||||||
|
|
||||||
fn pick_block_with_number_keys(
|
fn pick_block_with_number_keys(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use shipyard::{UniqueView, UniqueViewMut, Unique, AllStoragesView};
|
use shipyard::{UniqueView, UniqueViewMut, Unique, AllStoragesView};
|
||||||
use glium::glutin::{event::VirtualKeyCode, event_loop::ControlFlow};
|
use winit::{keyboard::KeyCode, event_loop::ControlFlow};
|
||||||
use crate::input::RawKbmInputState;
|
use crate::input::RawKbmInputState;
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique)]
|
||||||
|
@ -9,8 +9,9 @@ pub fn exit_on_esc(
|
||||||
raw_inputs: UniqueView<RawKbmInputState>,
|
raw_inputs: UniqueView<RawKbmInputState>,
|
||||||
mut control_flow: UniqueViewMut<SetControlFlow>
|
mut control_flow: UniqueViewMut<SetControlFlow>
|
||||||
) {
|
) {
|
||||||
if raw_inputs.keyboard_state.contains(VirtualKeyCode::Escape as u32) {
|
if raw_inputs.keyboard_state.contains(KeyCode::Escape as u32) {
|
||||||
control_flow.0 = Some(ControlFlow::Exit);
|
//TODO MIGRATION: fix exit on esc
|
||||||
|
//control_flow.0 = Some(ControlFlow::Exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
use glium::backend::Facade;
|
||||||
use shipyard::{AllStoragesView, Unique, NonSendSync, UniqueView, UniqueViewMut};
|
use shipyard::{AllStoragesView, Unique, NonSendSync, UniqueView, UniqueViewMut};
|
||||||
use crate::rendering::Renderer;
|
use crate::rendering::Renderer;
|
||||||
use glium::glutin::window::CursorGrabMode;
|
use winit::window::CursorGrabMode;
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique)]
|
||||||
pub struct CursorLock(pub bool);
|
pub struct CursorLock(pub bool);
|
||||||
|
@ -13,7 +14,7 @@ pub fn update_cursor_lock_state(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if lock.is_inserted_or_modified() {
|
if lock.is_inserted_or_modified() {
|
||||||
let gl_window = display.display.gl_window();
|
let gl_window = display.display.;
|
||||||
let window = gl_window.window();
|
let window = gl_window.window();
|
||||||
window.set_cursor_grab(match lock.0 {
|
window.set_cursor_grab(match lock.0 {
|
||||||
true => CursorGrabMode::Confined,
|
true => CursorGrabMode::Confined,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use glam::UVec2;
|
use glam::UVec2;
|
||||||
use shipyard::{World, Component, AllStoragesViewMut, SparseSet, NonSendSync, UniqueView};
|
use shipyard::{World, Component, AllStoragesViewMut, SparseSet, NonSendSync, UniqueView};
|
||||||
use glium::glutin::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch};
|
use winit::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch};
|
||||||
use crate::rendering::Renderer;
|
use crate::rendering::Renderer;
|
||||||
|
|
||||||
pub mod player_actions;
|
pub mod player_actions;
|
||||||
|
@ -24,7 +24,7 @@ pub struct TouchEvent(pub Touch);
|
||||||
#[derive(Component, Clone, Copy, Debug, Default)]
|
#[derive(Component, Clone, Copy, Debug, Default)]
|
||||||
pub struct WindowResizedEvent(pub UVec2);
|
pub struct WindowResizedEvent(pub UVec2);
|
||||||
|
|
||||||
pub fn process_glutin_events(world: &mut World, event: &Event<'_, ()>) {
|
pub fn process_glutin_events(world: &mut World, event: &Event<()>) {
|
||||||
#[allow(clippy::collapsible_match, clippy::single_match)]
|
#[allow(clippy::collapsible_match, clippy::single_match)]
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent { window_id: _, event } => match event {
|
Event::WindowEvent { window_id: _, event } => match event {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
use gilrs::{Gilrs, GamepadId, Button, Event, Axis};
|
use gilrs::{Gilrs, GamepadId, Button, Event, Axis};
|
||||||
use glam::{Vec2, DVec2, vec2, dvec2};
|
use glam::{Vec2, DVec2, vec2, dvec2};
|
||||||
use glium::glutin::event::{DeviceEvent, DeviceId, VirtualKeyCode, ElementState, TouchPhase};
|
use winit::{
|
||||||
|
keyboard::Key,
|
||||||
|
event::{DeviceEvent, DeviceId, ElementState, TouchPhase}
|
||||||
|
};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use tinyset::{SetU32, SetU64};
|
use tinyset::{SetU32, SetU64};
|
||||||
use nohash_hasher::BuildNoHashHasher;
|
use nohash_hasher::BuildNoHashHasher;
|
||||||
|
@ -173,10 +176,10 @@ fn update_input_state (
|
||||||
mut inputs: UniqueViewMut<Inputs>,
|
mut inputs: UniqueViewMut<Inputs>,
|
||||||
) {
|
) {
|
||||||
inputs.movement += Vec2::new(
|
inputs.movement += Vec2::new(
|
||||||
raw_inputs.keyboard_state.contains(VirtualKeyCode::D as u32) as u32 as f32 -
|
raw_inputs.keyboard_state.contains(Key::D as u32) as u32 as f32 -
|
||||||
raw_inputs.keyboard_state.contains(VirtualKeyCode::A as u32) as u32 as f32,
|
raw_inputs.keyboard_state.contains(Key::A as u32) as u32 as f32,
|
||||||
raw_inputs.keyboard_state.contains(VirtualKeyCode::W as u32) as u32 as f32 -
|
raw_inputs.keyboard_state.contains(Key::W as u32) as u32 as f32 -
|
||||||
raw_inputs.keyboard_state.contains(VirtualKeyCode::S as u32) as u32 as f32
|
raw_inputs.keyboard_state.contains(Key::S as u32) as u32 as f32
|
||||||
);
|
);
|
||||||
inputs.look += raw_inputs.mouse_delta.as_vec2();
|
inputs.look += raw_inputs.mouse_delta.as_vec2();
|
||||||
inputs.action_a |= raw_inputs.button_state[1];
|
inputs.action_a |= raw_inputs.button_state[1];
|
||||||
|
|
|
@ -6,7 +6,7 @@ use shipyard::{
|
||||||
NonSendSync, WorkloadModificator,
|
NonSendSync, WorkloadModificator,
|
||||||
SystemModificator
|
SystemModificator
|
||||||
};
|
};
|
||||||
use glium::glutin::{
|
use winit::{
|
||||||
event_loop::{EventLoop, ControlFlow},
|
event_loop::{EventLoop, ControlFlow},
|
||||||
event::{Event, WindowEvent}
|
event::{Event, WindowEvent}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use shipyard::{UniqueView, UniqueViewMut, Workload, IntoWorkload, EntityId, Unique, AllStoragesViewMut, ViewMut, Get, SystemModificator, track};
|
use shipyard::{UniqueView, UniqueViewMut, Workload, IntoWorkload, EntityId, Unique, AllStoragesViewMut, ViewMut, Get, SystemModificator, track};
|
||||||
use glium::glutin::event::VirtualKeyCode;
|
use winit::keyboard::Key;
|
||||||
use glam::{Mat3, vec2};
|
use glam::{Mat3, vec2};
|
||||||
use crate::{
|
use crate::{
|
||||||
world::ChunkStorage,
|
world::ChunkStorage,
|
||||||
|
@ -76,7 +76,7 @@ fn override_loading(
|
||||||
kbm_state: UniqueView<RawKbmInputState>,
|
kbm_state: UniqueView<RawKbmInputState>,
|
||||||
mut state: UniqueViewMut<NextState>
|
mut state: UniqueViewMut<NextState>
|
||||||
) {
|
) {
|
||||||
if kbm_state.keyboard_state.contains(VirtualKeyCode::F as u32) {
|
if kbm_state.keyboard_state.contains(Key::F as u32) {
|
||||||
state.0 = Some(GameState::InGame);
|
state.0 = Some(GameState::InGame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use shipyard::{Unique, AllStoragesView, UniqueView, UniqueViewMut, Workload, IntoWorkload, EntitiesViewMut, Component, ViewMut, SystemModificator, View, IntoIter, WorkloadModificator};
|
use shipyard::{Unique, AllStoragesView, UniqueView, UniqueViewMut, Workload, IntoWorkload, EntitiesViewMut, Component, ViewMut, SystemModificator, View, IntoIter, WorkloadModificator};
|
||||||
use glium::glutin::event_loop::ControlFlow;
|
use winit::event_loop::ControlFlow;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use uflow::{
|
use uflow::{
|
||||||
client::{Client, Config as ClientConfig, Event as ClientEvent},
|
client::{Client, Config as ClientConfig, Event as ClientEvent},
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
use shipyard::{Unique, NonSendSync, UniqueView, UniqueViewMut, View, IntoIter, AllStoragesView};
|
use shipyard::{Unique, NonSendSync, UniqueView, UniqueViewMut, View, IntoIter, AllStoragesView};
|
||||||
use glium::{
|
use winit::{
|
||||||
Display, Surface,
|
|
||||||
Version, Api,
|
|
||||||
glutin::{
|
|
||||||
event_loop::EventLoop,
|
event_loop::EventLoop,
|
||||||
window::{WindowBuilder, Fullscreen},
|
window::{WindowBuilder, Fullscreen},
|
||||||
ContextBuilder, GlProfile, GlRequest, dpi::PhysicalSize
|
dpi::PhysicalSize
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
use glium::{Display, Surface, Version, Api};
|
||||||
|
use glutin::surface::WindowSurface;
|
||||||
use glam::{Vec3, UVec2};
|
use glam::{Vec3, UVec2};
|
||||||
use crate::{events::WindowResizedEvent, settings::{GameSettings, FullscreenMode}};
|
use crate::{events::WindowResizedEvent, settings::{GameSettings, FullscreenMode}};
|
||||||
|
|
||||||
|
@ -30,8 +28,9 @@ pub struct WindowSize(pub UVec2);
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique)]
|
||||||
pub struct Renderer {
|
pub struct Renderer {
|
||||||
pub display: Display
|
pub display: Display<WindowSurface>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Renderer {
|
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");
|
||||||
|
@ -82,15 +81,15 @@ impl Renderer {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let cb = ContextBuilder::new()
|
// let cb = ContextBuilder::new()
|
||||||
//.with_srgb(false)
|
// //.with_srgb(false)
|
||||||
.with_depth_buffer(24)
|
// .with_depth_buffer(24)
|
||||||
.with_multisampling(settings.msaa.unwrap_or_default())
|
// .with_multisampling(settings.msaa.unwrap_or_default())
|
||||||
.with_vsync(settings.vsync)
|
// .with_vsync(settings.vsync)
|
||||||
.with_gl_profile(GlProfile::Core)
|
// .with_gl_profile(GlProfile::Core)
|
||||||
.with_gl(GlRequest::Latest);
|
// .with_gl(GlRequest::Latest);
|
||||||
|
|
||||||
let display = Display::new(wb, cb, event_loop)
|
let display = Display::new(wb, cb)
|
||||||
.expect("Failed to create a glium Display");
|
.expect("Failed to create a glium Display");
|
||||||
|
|
||||||
log::info!("Vendor: {}", display.get_opengl_vendor_string());
|
log::info!("Vendor: {}", display.get_opengl_vendor_string());
|
||||||
|
|
Loading…
Reference in a new issue