Skip to content

Commit

Permalink
Make some more stuff shared in the themes. Make the room theme functi…
Browse files Browse the repository at this point in the history
…onal by bringing in its branch-specific images.
  • Loading branch information
CaspianA1 committed Oct 8, 2024
1 parent bfd29a2 commit f3d75e1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 84 deletions.
Binary file added assets/alternative_text_bubble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dashboard_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 1 addition & 28 deletions src/dashboard_defs/themes/barebones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,33 +338,6 @@ pub async fn make_dashboard(

////////// Making some static texture windows

type StaticTextureSetInfo = [(&'static str, Vec2f, Vec2f, bool)];

async fn make_creation_info_for_static_texture_set(all_info: &StaticTextureSetInfo) -> GenericResult<Vec<TextureCreationInfo>> {
TextureCreationInfo::from_paths_async(all_info.iter().map(|&(path, ..)| path)).await
}

fn add_static_texture_set(set: &mut Vec<Window>, all_info: &StaticTextureSetInfo,
all_creation_info: &[TextureCreationInfo<'_>], texture_pool: &mut TexturePool<'_>) {

set.extend(all_info.iter().zip(all_creation_info).map(
|(&(_, tl, size, skip_ar_correction), creation_info)| {

let mut window = Window::new(
None,
DynamicOptional::NONE,
WindowContents::make_texture_contents(creation_info, texture_pool).unwrap(),
None,
tl,
size,
None
);

window.set_aspect_ratio_correction_skipping(skip_ar_correction);
window
}));
}

let mut all_main_windows = vec![twilio_window, weather_window, credit_window];
all_main_windows.extend(spinitron_windows);
add_static_texture_set(&mut all_main_windows, &main_static_texture_info, &main_static_texture_creation_info, texture_pool);
Expand Down Expand Up @@ -408,7 +381,7 @@ pub async fn make_dashboard(
let all_windows_window = Window::new(
None,
DynamicOptional::NONE,
WindowContents::Nothing,
WindowContents::Color(ColorSDL::RGB(23, 23, 23)),
None,
Vec2f::ZERO,
Vec2f::ONE,
Expand Down
39 changes: 37 additions & 2 deletions src/dashboard_defs/themes/shared_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ use std::sync::atomic::{AtomicUsize, Ordering};

use crate::{
error_msg,
texture::TextureCreationInfo,
utility_types::generic_result::*
window_tree::{Window, WindowContents},
texture::{TextureCreationInfo, TexturePool},

utility_types::{
vec2f::Vec2f,
generic_result::*,
dynamic_optional::DynamicOptional
}
};

//////////
Expand Down Expand Up @@ -58,3 +64,32 @@ pub fn run_command(command: &str, args: &[&str]) -> GenericResult<String> {
String::from_utf8(output.stdout).to_generic().map(|s| s.trim().to_owned())
}
}

//////////

pub type StaticTextureSetInfo = [(&'static str, Vec2f, Vec2f, bool)];

pub async fn make_creation_info_for_static_texture_set(all_info: &StaticTextureSetInfo) -> GenericResult<Vec<TextureCreationInfo>> {
TextureCreationInfo::from_paths_async(all_info.iter().map(|&(path, ..)| path)).await
}

pub fn add_static_texture_set(set: &mut Vec<Window>, all_info: &StaticTextureSetInfo,
all_creation_info: &[TextureCreationInfo<'_>], texture_pool: &mut TexturePool<'_>) {

set.extend(all_info.iter().zip(all_creation_info).map(
|(&(_, tl, size, skip_ar_correction), creation_info)| {

let mut window = Window::new(
None,
DynamicOptional::NONE,
WindowContents::make_texture_contents(creation_info, texture_pool).unwrap(),
None,
tl,
size,
None
);

window.set_aspect_ratio_correction_skipping(skip_ar_correction);
window
}));
}
27 changes: 0 additions & 27 deletions src/dashboard_defs/themes/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,33 +342,6 @@ pub async fn make_dashboard(

////////// Making some static texture windows

type StaticTextureSetInfo = [(&'static str, Vec2f, Vec2f, bool)];

async fn make_creation_info_for_static_texture_set(all_info: &StaticTextureSetInfo) -> GenericResult<Vec<TextureCreationInfo>> {
TextureCreationInfo::from_paths_async(all_info.iter().map(|&(path, ..)| path)).await
}

fn add_static_texture_set(set: &mut Vec<Window>, all_info: &StaticTextureSetInfo,
all_creation_info: &[TextureCreationInfo<'_>], texture_pool: &mut TexturePool<'_>) {

set.extend(all_info.iter().zip(all_creation_info).map(
|(&(_, tl, size, skip_ar_correction), creation_info)| {

let mut window = Window::new(
None,
DynamicOptional::NONE,
WindowContents::make_texture_contents(creation_info, texture_pool).unwrap(),
None,
tl,
size,
None
);

window.set_aspect_ratio_correction_skipping(skip_ar_correction);
window
}));
}

let mut all_main_windows = vec![twilio_window, credit_window];
all_main_windows.extend(spinitron_windows);
add_static_texture_set(&mut all_main_windows, &main_static_texture_info, &main_static_texture_creation_info, texture_pool);
Expand Down
27 changes: 0 additions & 27 deletions src/dashboard_defs/themes/the_room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,33 +339,6 @@ pub async fn make_dashboard(

////////// Making some static texture windows

type StaticTextureSetInfo = [(&'static str, Vec2f, Vec2f, bool)];

async fn make_creation_info_for_static_texture_set(all_info: &StaticTextureSetInfo) -> GenericResult<Vec<TextureCreationInfo>> {
TextureCreationInfo::from_paths_async(all_info.iter().map(|&(path, ..)| path)).await
}

fn add_static_texture_set(set: &mut Vec<Window>, all_info: &StaticTextureSetInfo,
all_creation_info: &[TextureCreationInfo<'_>], texture_pool: &mut TexturePool<'_>) {

set.extend(all_info.iter().zip(all_creation_info).map(
|(&(_, tl, size, skip_ar_correction), creation_info)| {

let mut window = Window::new(
None,
DynamicOptional::NONE,
WindowContents::make_texture_contents(creation_info, texture_pool).unwrap(),
None,
tl,
size,
None
);

window.set_aspect_ratio_correction_skipping(skip_ar_correction);
window
}));
}

let mut all_main_windows = Vec::new();

all_main_windows.extend(spinitron_windows);
Expand Down

0 comments on commit f3d75e1

Please sign in to comment.