From dc745ea8af01172167184346392279a9cb80afe6 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Wed, 18 Jan 2023 09:19:55 +0100 Subject: [PATCH] Restructure elements --- build.rs | 4 ++-- src/overlay/elements/{ui_files => }/gui.xsd | 0 src/overlay/elements/leaderboard/leaderboard_entry.xml | 10 ++++++++++ .../{ui_files => leaderboard}/leaderboard_grid.xml | 2 +- .../elements/{leaderboard.rs => leaderboard/mod.rs} | 4 ++-- src/overlay/elements/mod.rs | 1 - src/overlay/elements/{pedals.rs => pedals/mod.rs} | 2 +- src/overlay/elements/{ui_files => pedals}/pedals.xml | 2 +- src/overlay/elements/{radar.rs => radar/mod.rs} | 4 +++- src/overlay/elements/{ => radar}/pipeline.rs | 6 +++--- .../elements/{shader => radar}/single_color.frag | 0 .../elements/{shader => radar}/single_color.vert | 0 src/overlay/elements/ui_files/leaderboard_entry.xml | 7 ------- .../elements/{watermark.rs => watermark/mod.rs} | 2 +- .../elements/{ui_files => watermark}/watermark.xml | 2 +- 15 files changed, 25 insertions(+), 21 deletions(-) rename src/overlay/elements/{ui_files => }/gui.xsd (100%) create mode 100644 src/overlay/elements/leaderboard/leaderboard_entry.xml rename src/overlay/elements/{ui_files => leaderboard}/leaderboard_grid.xml (69%) rename src/overlay/elements/{leaderboard.rs => leaderboard/mod.rs} (98%) rename src/overlay/elements/{pedals.rs => pedals/mod.rs} (96%) rename src/overlay/elements/{ui_files => pedals}/pedals.xml (86%) rename src/overlay/elements/{radar.rs => radar/mod.rs} (99%) rename src/overlay/elements/{ => radar}/pipeline.rs (94%) rename src/overlay/elements/{shader => radar}/single_color.frag (100%) rename src/overlay/elements/{shader => radar}/single_color.vert (100%) delete mode 100644 src/overlay/elements/ui_files/leaderboard_entry.xml rename src/overlay/elements/{watermark.rs => watermark/mod.rs} (92%) rename src/overlay/elements/{ui_files => watermark}/watermark.xml (78%) diff --git a/build.rs b/build.rs index d5ffc56..1fadb6f 100644 --- a/build.rs +++ b/build.rs @@ -10,8 +10,8 @@ const VK_HEADER: &[&str] = &[ const FN_PREFIX: &str = "PFN_"; const SHADER: &[&str] = &[ - "src/overlay/elements/shader/single_color.vert", - "src/overlay/elements/shader/single_color.frag", + "src/overlay/elements/pedals/single_color.vert", + "src/overlay/elements/pedals/single_color.frag", ]; fn query_vulkan_function_typedefs() { diff --git a/src/overlay/elements/ui_files/gui.xsd b/src/overlay/elements/gui.xsd similarity index 100% rename from src/overlay/elements/ui_files/gui.xsd rename to src/overlay/elements/gui.xsd diff --git a/src/overlay/elements/leaderboard/leaderboard_entry.xml b/src/overlay/elements/leaderboard/leaderboard_entry.xml new file mode 100644 index 0000000..83d81a9 --- /dev/null +++ b/src/overlay/elements/leaderboard/leaderboard_entry.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/src/overlay/elements/ui_files/leaderboard_grid.xml b/src/overlay/elements/leaderboard/leaderboard_grid.xml similarity index 69% rename from src/overlay/elements/ui_files/leaderboard_grid.xml rename to src/overlay/elements/leaderboard/leaderboard_grid.xml index 5a2a63d..65e6394 100644 --- a/src/overlay/elements/ui_files/leaderboard_grid.xml +++ b/src/overlay/elements/leaderboard/leaderboard_grid.xml @@ -1,4 +1,4 @@ - + diff --git a/src/overlay/elements/leaderboard.rs b/src/overlay/elements/leaderboard/mod.rs similarity index 98% rename from src/overlay/elements/leaderboard.rs rename to src/overlay/elements/leaderboard/mod.rs index 2d0abb0..bebc478 100644 --- a/src/overlay/elements/leaderboard.rs +++ b/src/overlay/elements/leaderboard/mod.rs @@ -26,8 +26,8 @@ pub struct LeaderBoard { } impl LeaderBoard { - const GRID: &str = include_str!("ui_files/leaderboard_grid.xml"); - const ENTRY: &str = include_str!("ui_files/leaderboard_entry.xml"); + const GRID: &str = include_str!("leaderboard_grid.xml"); + const ENTRY: &str = include_str!("leaderboard_entry.xml"); pub fn new(gui_handler: &Arc) -> Result { let gui = GuiBuilder::from_str(gui_handler, Self::GRID)?; diff --git a/src/overlay/elements/mod.rs b/src/overlay/elements/mod.rs index 7af9c8b..bc1376d 100644 --- a/src/overlay/elements/mod.rs +++ b/src/overlay/elements/mod.rs @@ -1,6 +1,5 @@ mod leaderboard; mod pedals; -mod pipeline; mod radar; mod watermark; diff --git a/src/overlay/elements/pedals.rs b/src/overlay/elements/pedals/mod.rs similarity index 96% rename from src/overlay/elements/pedals.rs rename to src/overlay/elements/pedals/mod.rs index 1869bf7..51ccbb6 100644 --- a/src/overlay/elements/pedals.rs +++ b/src/overlay/elements/pedals/mod.rs @@ -22,7 +22,7 @@ pub struct Pedals { impl Pedals { pub fn new(gui_handler: &Arc) -> Result { - const DESC: &str = include_str!("ui_files/pedals.xml"); + const DESC: &str = include_str!("pedals.xml"); let gui = GuiBuilder::from_str(gui_handler, DESC)?; diff --git a/src/overlay/elements/ui_files/pedals.xml b/src/overlay/elements/pedals/pedals.xml similarity index 86% rename from src/overlay/elements/ui_files/pedals.xml rename to src/overlay/elements/pedals/pedals.xml index 6f36f94..a05d5f7 100644 --- a/src/overlay/elements/ui_files/pedals.xml +++ b/src/overlay/elements/pedals/pedals.xml @@ -1,4 +1,4 @@ - + diff --git a/src/overlay/elements/radar.rs b/src/overlay/elements/radar/mod.rs similarity index 99% rename from src/overlay/elements/radar.rs rename to src/overlay/elements/radar/mod.rs index 04d9a45..7b2b0f2 100644 --- a/src/overlay/elements/radar.rs +++ b/src/overlay/elements/radar/mod.rs @@ -1,3 +1,5 @@ +mod pipeline; + use anyhow::Result; use cgmath::{ortho, vec2, vec3, vec4, Deg, InnerSpace, Matrix4, Rad, Vector2, Vector3, Vector4}; use rfactor_sm_reader::*; @@ -6,7 +8,7 @@ use vulkan_rs::prelude::*; use std::sync::{Arc, Mutex}; -use super::pipeline::SingleColorPipeline; +use pipeline::SingleColorPipeline; use crate::{ overlay::{ diff --git a/src/overlay/elements/pipeline.rs b/src/overlay/elements/radar/pipeline.rs similarity index 94% rename from src/overlay/elements/pipeline.rs rename to src/overlay/elements/radar/pipeline.rs index ee729a2..dd9c885 100644 --- a/src/overlay/elements/pipeline.rs +++ b/src/overlay/elements/radar/pipeline.rs @@ -3,7 +3,7 @@ use vulkan_rs::prelude::*; use std::{mem, sync::Arc}; -use super::radar::PositionOnlyVertex; +use super::PositionOnlyVertex; pub struct SingleColorPipeline { pipeline: Arc, @@ -19,12 +19,12 @@ impl SingleColorPipeline { ) -> Result { let vertex_shader = ShaderModule::from_slice( device.clone(), - include_bytes!("shader/single_color.vert.spv"), + include_bytes!("single_color.vert.spv"), ShaderType::Vertex, )?; let fragment_shader = ShaderModule::from_slice( device.clone(), - include_bytes!("shader/single_color.frag.spv"), + include_bytes!("single_color.frag.spv"), ShaderType::Fragment, )?; diff --git a/src/overlay/elements/shader/single_color.frag b/src/overlay/elements/radar/single_color.frag similarity index 100% rename from src/overlay/elements/shader/single_color.frag rename to src/overlay/elements/radar/single_color.frag diff --git a/src/overlay/elements/shader/single_color.vert b/src/overlay/elements/radar/single_color.vert similarity index 100% rename from src/overlay/elements/shader/single_color.vert rename to src/overlay/elements/radar/single_color.vert diff --git a/src/overlay/elements/ui_files/leaderboard_entry.xml b/src/overlay/elements/ui_files/leaderboard_entry.xml deleted file mode 100644 index 78de1e5..0000000 --- a/src/overlay/elements/ui_files/leaderboard_entry.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/overlay/elements/watermark.rs b/src/overlay/elements/watermark/mod.rs similarity index 92% rename from src/overlay/elements/watermark.rs rename to src/overlay/elements/watermark/mod.rs index 608be46..7eaec0b 100644 --- a/src/overlay/elements/watermark.rs +++ b/src/overlay/elements/watermark/mod.rs @@ -15,7 +15,7 @@ pub struct Watermark { impl Watermark { pub fn new(gui_handler: &Arc) -> Result { - const DESC: &str = include_str!("ui_files/watermark.xml"); + const DESC: &str = include_str!("watermark.xml"); let gui = GuiBuilder::from_str(gui_handler, DESC)?; diff --git a/src/overlay/elements/ui_files/watermark.xml b/src/overlay/elements/watermark/watermark.xml similarity index 78% rename from src/overlay/elements/ui_files/watermark.xml rename to src/overlay/elements/watermark/watermark.xml index 299c7f2..6b4b81a 100644 --- a/src/overlay/elements/ui_files/watermark.xml +++ b/src/overlay/elements/watermark/watermark.xml @@ -1,4 +1,4 @@ - +