integrate hui-winit

This commit is contained in:
griffi-gh 2024-05-02 02:20:54 +02:00
parent 8e907a9fbc
commit 8c5b0aa47e
5 changed files with 34 additions and 2 deletions

12
Cargo.lock generated
View file

@ -960,6 +960,17 @@ dependencies = [
"log", "log",
] ]
[[package]]
name = "hui-winit"
version = "0.1.0-alpha.4"
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
dependencies = [
"glam",
"hui",
"log",
"winit",
]
[[package]] [[package]]
name = "humantime" name = "humantime"
version = "2.1.0" version = "2.1.0"
@ -1148,6 +1159,7 @@ dependencies = [
"hashbrown 0.14.3", "hashbrown 0.14.3",
"hui", "hui",
"hui-glium", "hui-glium",
"hui-winit",
"image", "image",
"kubi-logging", "kubi-logging",
"kubi-shared", "kubi-shared",

View file

@ -13,6 +13,7 @@ kubi-shared = { path = "../kubi-shared" }
kubi-logging = { path = "../kubi-logging" } kubi-logging = { path = "../kubi-logging" }
hui = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" } hui = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
hui-glium = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" } hui-glium = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
hui-winit = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
log = "0.4" log = "0.4"
glium = { git = "https://github.com/glium/glium", rev = "a352c667" } glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
glutin = "0.31" glutin = "0.31"

View file

@ -41,3 +41,10 @@ pub fn kubi_ui_draw(
) { ) {
ui.renderer.draw(&mut target.0, size.0.as_vec2()); ui.renderer.draw(&mut target.0, size.0.as_vec2());
} }
pub fn hui_process_winit_events(
event: &winit::event::Event<()>,
mut ui: NonSendSync<UniqueViewMut<UiState>>,
) {
hui_winit::handle_winit_event(&mut ui.hui, event);
}

View file

@ -95,6 +95,8 @@ use chat::init_chat_manager;
use crosshair_ui::{init_crosshair_image, draw_crosshair}; use crosshair_ui::{init_crosshair_image, draw_crosshair};
use settings_ui::render_settings_ui; use settings_ui::render_settings_ui;
use crate::hui_integration::hui_process_winit_events;
/// stuff required to init the renderer and other basic systems /// stuff required to init the renderer and other basic systems
fn pre_startup() -> Workload { fn pre_startup() -> Workload {
( (
@ -280,6 +282,7 @@ pub fn kubi_main(
window_target.set_control_flow(ControlFlow::Poll); window_target.set_control_flow(ControlFlow::Poll);
world.run_with_data(hui_process_winit_events, &event);
process_winit_events(&mut world, &event); process_winit_events(&mut world, &event);
#[allow(clippy::collapsible_match, clippy::single_match)] #[allow(clippy::collapsible_match, clippy::single_match)]

View file

@ -1,4 +1,9 @@
use hui::{color, element::{br::Break, container::Container, slider::Slider, text::Text, UiElementExt}, layout::{Alignment, Direction}, signal::Signal, size}; use hui::{
element::{br::Break, container::Container, slider::Slider, text::Text, UiElementExt},
layout::{Alignment, Direction},
signal::Signal,
frame_rect, size,
};
use shipyard::{NonSendSync, UniqueView, UniqueViewMut}; use shipyard::{NonSendSync, UniqueView, UniqueViewMut};
use winit::keyboard::KeyCode; use winit::keyboard::KeyCode;
use crate::{hui_integration::UiState, input::RawKbmInputState, rendering::WindowSize, settings::GameSettings}; use crate::{hui_integration::UiState, input::RawKbmInputState, rendering::WindowSize, settings::GameSettings};
@ -20,10 +25,14 @@ pub fn render_settings_ui(
} }
Container::default() Container::default()
.with_size(size!(100%)) .with_size(size!(100%))
.with_background((0., 0., 0., 0.5))
.with_align(Alignment::Center) .with_align(Alignment::Center)
.with_children(|ui| { .with_children(|ui| {
Container::default() Container::default()
.with_background(color::BLACK) .with_background(frame_rect! {
color: (0.2, 0.2, 0.2),
corner_radius: 8.
})
.with_size(size!(50%, 50%)) .with_size(size!(50%, 50%))
.with_direction(Direction::Horizontal) .with_direction(Direction::Horizontal)
.with_gap(10.) .with_gap(10.)