mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 00:08:42 -06:00
drop legacy ui system
This commit is contained in:
parent
a53f6f9901
commit
d852c48e4a
|
@ -1,5 +1,4 @@
|
|||
use glam::vec2;
|
||||
use kubi_ui::{KubiUi, backend::glium::GliumUiRenderer, element::{progress_bar::ProgressBar, UiElement}, UiSize};
|
||||
use kubi_ui::{KubiUi, backend::glium::GliumUiRenderer};
|
||||
use shipyard::{AllStoragesView, Unique, UniqueView, NonSendSync, UniqueViewMut};
|
||||
use crate::rendering::{Renderer, RenderTarget, WindowSize};
|
||||
|
||||
|
@ -23,10 +22,6 @@ pub fn kubi_ui_begin(
|
|||
mut ui: NonSendSync<UniqueViewMut<UiState>>
|
||||
) {
|
||||
ui.ui.begin();
|
||||
ui.ui.add(ProgressBar {
|
||||
size: (UiSize::Pixels(300.), UiSize::Auto),
|
||||
..Default::default()
|
||||
}, vec2(999., 999.));
|
||||
}
|
||||
|
||||
pub fn kubi_ui_end(
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
use shipyard::{Component, Unique, Workload, IntoWorkload, AllStoragesView, View, UniqueViewMut, IntoIter};
|
||||
use glam::{Vec4, Mat4};
|
||||
use crate::{color::color_hex, events::WindowResizedEvent};
|
||||
|
||||
pub mod text_widget;
|
||||
pub mod progressbar;
|
||||
|
||||
use progressbar::render_progressbars;
|
||||
|
||||
//TODO compute gui scale on window resize
|
||||
#[derive(Unique, Clone, Copy, Debug, Default)]
|
||||
pub struct LegacyGuiView(pub Mat4);
|
||||
|
||||
#[derive(Component, Clone, Copy, Debug, Default)]
|
||||
pub struct LegacyGuiComponent;
|
||||
|
||||
#[derive(Component, Clone, Copy, Debug)]
|
||||
pub struct LegacyPrimaryColor(pub Vec4);
|
||||
impl Default for LegacyPrimaryColor {
|
||||
fn default() -> Self {
|
||||
Self(color_hex(0x156cddff))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component, Clone, Copy, Debug)]
|
||||
pub struct LegacySecondaryColor(pub Vec4);
|
||||
impl Default for LegacySecondaryColor {
|
||||
fn default() -> Self {
|
||||
Self(color_hex(0xc9d5e4ff))
|
||||
}
|
||||
}
|
||||
|
||||
fn update_legacy_gui_view(
|
||||
mut view: UniqueViewMut<LegacyGuiView>,
|
||||
resize: View<WindowResizedEvent>,
|
||||
) {
|
||||
let Some(&size) = resize.iter().next() else {
|
||||
return
|
||||
};
|
||||
let [w, h] = size.0.to_array();
|
||||
view.0 = Mat4::orthographic_rh_gl(0.0, w as f32, h as f32, 0.0, -1.0, 1.0);
|
||||
}
|
||||
|
||||
pub fn legacy_ui_init(
|
||||
storages: AllStoragesView
|
||||
) {
|
||||
storages.add_unique(LegacyGuiView::default());
|
||||
}
|
||||
|
||||
pub fn legacy_ui_update() -> Workload {
|
||||
(
|
||||
update_legacy_gui_view
|
||||
).into_sequential_workload()
|
||||
}
|
||||
|
||||
pub fn legacy_ui_render() -> Workload {
|
||||
(
|
||||
render_progressbars
|
||||
).into_sequential_workload()
|
||||
}
|
||||
|
||||
// pub fn gui_testing(
|
||||
// mut storages: AllStoragesViewMut,
|
||||
// ) {
|
||||
// storages.add_entity((
|
||||
// GuiComponent,
|
||||
// Transform2d(Mat3::from_scale_angle_translation(
|
||||
// vec2(1920., 16.),
|
||||
// 0.,
|
||||
// vec2(0., 0.)
|
||||
// )),
|
||||
// ProgressbarComponent {
|
||||
// progress: 0.33
|
||||
// },
|
||||
// PrimaryColor::default(),
|
||||
// SecondaryColor::default(),
|
||||
// ));
|
||||
// }
|
|
@ -1,46 +0,0 @@
|
|||
use shipyard::{UniqueView, UniqueViewMut, NonSendSync, View, Component, IntoIter, IntoWithId, Get, track};
|
||||
use glium::{Surface, uniform, DrawParameters};
|
||||
use crate::{
|
||||
prefabs::ProgressbarShaderPrefab,
|
||||
rendering::{
|
||||
RenderTarget,
|
||||
primitives::rect::RectPrimitive
|
||||
},
|
||||
transform::Transform2d,
|
||||
};
|
||||
use super::{LegacyGuiComponent, LegacyPrimaryColor, LegacySecondaryColor, LegacyGuiView};
|
||||
|
||||
#[derive(Component, Debug, Clone, Copy, Default)]
|
||||
pub struct ProgressbarComponent {
|
||||
pub progress: f32
|
||||
}
|
||||
|
||||
pub fn render_progressbars(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
rect: NonSendSync<UniqueView<RectPrimitive>>,
|
||||
program: NonSendSync<UniqueView<ProgressbarShaderPrefab>>,
|
||||
view: UniqueView<LegacyGuiView>,
|
||||
components: View<LegacyGuiComponent>,
|
||||
transforms: View<Transform2d, track::All>,
|
||||
progressbars: View<ProgressbarComponent>,
|
||||
primary: View<LegacyPrimaryColor>,
|
||||
secondary: View<LegacySecondaryColor>,
|
||||
) {
|
||||
for (eid, (_, transform, progress)) in (&components, &transforms, &progressbars).iter().with_id() {
|
||||
let primary_color = primary.get(eid).copied().unwrap_or_default();
|
||||
let secondary_color = secondary.get(eid).copied().unwrap_or_default();
|
||||
target.0.draw(
|
||||
&rect.0,
|
||||
&rect.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
transform: transform.0.to_cols_array_2d(),
|
||||
ui_view: view.0.to_cols_array_2d(),
|
||||
progress: progress.progress,
|
||||
color: primary_color.0.to_array(),
|
||||
bg_color: secondary_color.0.to_array(),
|
||||
},
|
||||
&DrawParameters::default()
|
||||
).unwrap();
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
//TODO text widget
|
|
@ -29,7 +29,6 @@ pub(crate) mod delta_time;
|
|||
pub(crate) mod cursor_lock;
|
||||
pub(crate) mod control_flow;
|
||||
pub(crate) mod state;
|
||||
pub(crate) mod legacy_gui;
|
||||
pub(crate) mod guiv2_integration;
|
||||
pub(crate) mod networking;
|
||||
pub(crate) mod init;
|
||||
|
@ -77,7 +76,6 @@ 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;
|
||||
use legacy_gui::{legacy_ui_render, legacy_ui_init, legacy_ui_update};
|
||||
use guiv2_integration::{kubi_ui_init, kubi_ui_begin, kubi_ui_end, kubi_ui_draw};
|
||||
use loading_screen::update_loading_screen;
|
||||
use connecting_screen::switch_to_loading_if_connected;
|
||||
|
@ -104,7 +102,6 @@ fn startup() -> Workload {
|
|||
initialize_from_args,
|
||||
lock_cursor_now,
|
||||
init_input,
|
||||
legacy_ui_init,
|
||||
insert_control_flow_unique,
|
||||
init_delta_time,
|
||||
).into_sequential_workload()
|
||||
|
@ -141,7 +138,6 @@ fn update() -> Workload {
|
|||
).into_sequential_workload().run_if(is_ingame),
|
||||
update_networking_late.run_if(is_multiplayer),
|
||||
compute_cameras,
|
||||
legacy_ui_update,
|
||||
kubi_ui_end,
|
||||
update_state,
|
||||
exit_on_esc,
|
||||
|
@ -158,7 +154,6 @@ fn render() -> Workload {
|
|||
render_selection_box,
|
||||
render_entities,
|
||||
).into_sequential_workload().run_if(is_ingame),
|
||||
legacy_ui_render,
|
||||
kubi_ui_draw,
|
||||
).into_sequential_workload()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue