From a002e4d738535e6ca779c71231f7b84864b9a8d0 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Tue, 4 Jun 2024 15:00:16 -0400 Subject: Refactored + Renamed + Added Docs --- src/components.rs | 85 ------------------------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 src/components.rs (limited to 'src/components.rs') diff --git a/src/components.rs b/src/components.rs deleted file mode 100644 index 3814cc7..0000000 --- a/src/components.rs +++ /dev/null @@ -1,85 +0,0 @@ - -use bevy::{ - prelude::*, - render::render_resource::{ - Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, - }, -}; -use grex_dither_post_process::components::DitherPostProcessSettings; -use grex_framebuffer_extract::{ - components::{ExtractFramebufferBundle, FramebufferExtractDestination}, - render_assets::FramebufferExtractSource, -}; - -use crate::resources::TerminalWidget; - -#[derive(Component)] -pub struct TerminalDisplay; - -#[derive(Bundle)] -pub struct TerminalDisplayBundle { - _terminal_display: TerminalDisplay, - extract_framebuffer_bundle: ExtractFramebufferBundle, - dither_post_process_settings: DitherPostProcessSettings, - image_handle: Handle, -} - -impl TerminalDisplayBundle { - pub fn new(dither_level: u32, asset_server: &AssetServer) -> Self { - let terminal_size = crossterm::terminal::size().unwrap(); - let size = Extent3d { - width: (terminal_size.0 as u32) * 2, - height: (terminal_size.1 as u32) * 4, - depth_or_array_layers: 1, - }; - - let mut image = Image { - texture_descriptor: TextureDescriptor { - label: None, - size, - dimension: TextureDimension::D2, - format: TextureFormat::R8Unorm, - mip_level_count: 1, - sample_count: 1, - usage: TextureUsages::TEXTURE_BINDING - | TextureUsages::COPY_SRC - | TextureUsages::RENDER_ATTACHMENT, - view_formats: &[], - }, - ..default() - }; - - image.resize(size); - let image_handle = asset_server.add(image); - - let framebuffer_extract_source = - asset_server.add(FramebufferExtractSource(image_handle.clone())); - - Self { - _terminal_display: TerminalDisplay, - extract_framebuffer_bundle: ExtractFramebufferBundle { - source: framebuffer_extract_source, - dest: FramebufferExtractDestination::default(), - }, - image_handle, - dither_post_process_settings: DitherPostProcessSettings::new( - dither_level, - asset_server, - ), - } - } - - pub fn image_handle(&self) -> Handle { - self.image_handle.clone() - } -} - -#[derive(Component)] -pub struct Widget { - pub widget: Box, - pub depth: u32, - pub enabled: bool, -} - -#[derive(Component)] -pub struct Tooltip(pub String); -- cgit v1.2.3