Skip to content

Commit

Permalink
Add art change day to the theming
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Nov 3, 2024
1 parent fdec544 commit 1f1cbe8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
Binary file added truncate_client/img/truncate_packed_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 14 additions & 5 deletions truncate_client/src/app_outer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use truncate_core::{
rules::GameRules,
};

pub const ART_CHANGE_DAY: u32 = 280;

/// A way to communicate with an outer host, if one exists. (Typically Browser JS)
pub struct Backchannel {
#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -158,7 +160,7 @@ impl OuterApplication {
cc.egui_ctx.set_fonts(fonts);

let glypher = Glypher::new();
let map_texture = load_textures(&cc.egui_ctx, &glypher);
let map_texture = load_textures(&cc.egui_ctx, &glypher, launched_at_day);
_ = GLYPHER.set(glypher);

let mut game_status = app_inner::GameStatus::None("".into(), None);
Expand Down Expand Up @@ -239,7 +241,11 @@ impl OuterApplication {
}
}

let theme = Theme::day();
let theme = if launched_at_day >= ART_CHANGE_DAY {
Theme::day()
} else {
Theme::old_day()
};

{
use egui::FontFamily;
Expand Down Expand Up @@ -354,9 +360,12 @@ pub struct TextureMeasurement {
pub y_padding_pct: f32,
}

fn load_textures(ctx: &egui::Context, glypher: &Glypher) -> TextureHandle {
let image_bytes = include_bytes!("../img/truncate_packed.png");
let image = image::load_from_memory(image_bytes).unwrap();
fn load_textures(ctx: &egui::Context, glypher: &Glypher, launched_at_day: u32) -> TextureHandle {
let image = if launched_at_day >= ART_CHANGE_DAY {
image::load_from_memory(include_bytes!("../img/truncate_packed.png")).unwrap()
} else {
image::load_from_memory(include_bytes!("../img/truncate_packed_old.png")).unwrap()
};
let image_width = image.width();
let image_height = image.height();
let size = [image_width as _, image_height as _];
Expand Down
16 changes: 14 additions & 2 deletions truncate_client/src/utils/mapper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,24 @@ impl MappedBoard {
.map(|square| {
square
.as_ref()
.map(Into::into)
.map(|sq| {
if aesthetics.theme.use_old_art {
if matches!(sq, Square::Artifact { .. }) {
return BGTexType::WaterOrFog;
}
}
sq.into()
})
.unwrap_or(BGTexType::WaterOrFog)
})
.collect();

let tile_base_type = BGTexType::from(square);
let mut tile_base_type = BGTexType::from(square);
if aesthetics.theme.use_old_art {
if matches!(square, Square::Artifact { .. }) {
tile_base_type = BGTexType::WaterOrFog;
}
}
let tile_layer_type = FGTexType::from((square, player_colors));

let wind_at_coord = self
Expand Down
32 changes: 32 additions & 0 deletions truncate_client/src/utils/theming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use epaint::{hex_color, Color32, Hsva};

#[derive(Debug, Clone)]
pub struct Theme {
pub use_old_art: bool, // TODO: Remove after art change has flushed through
pub daytime: bool,
pub water: Color32,
pub grass: Color32,
Expand Down Expand Up @@ -32,6 +33,7 @@ pub struct Theme {
impl Theme {
pub fn day() -> Self {
Self {
use_old_art: false,
daytime: true,
water: hex_color!("#0BADFF"),
grass: hex_color!("#7BCB69"),
Expand All @@ -57,8 +59,37 @@ impl Theme {
}
}

pub fn old_day() -> Self {
Self {
use_old_art: true,
daytime: true,
water: hex_color!("#50a7e8"),
grass: hex_color!("#7BCB69"),
text: hex_color!("#333333"),
faded: hex_color!("#777777"),
button_primary: hex_color!("#FFDE85"),
button_secondary: hex_color!("#B1DAF9"),
button_scary: hex_color!("#FF8E8E"),
ring_selected: hex_color!("#FFBE0B"),
ring_selected_hovered: hex_color!("#FFDE85"),
ring_hovered: hex_color!("#CDF7F6"),
ring_added: hex_color!("#0AFFC6"),
ring_modified: hex_color!("#FC3692"),
word_valid: hex_color!("#00A37D"),
word_invalid: hex_color!("#89043D"),
gold_medal: hex_color!("#E0A500"),
grid_size: 50.0,
letter_size: 25.0,
tile_margin: 4.0,
rounding: 10.0,
animation_time: 0.05,
mobile_breakpoint: 800.0,
}
}

pub fn fog() -> Self {
Self {
use_old_art: false,
daytime: true,
water: hex_color!("#000000"),
grass: hex_color!("#7BCB69"),
Expand Down Expand Up @@ -86,6 +117,7 @@ impl Theme {

pub fn night() -> Self {
Self {
use_old_art: false,
daytime: false,
water: hex_color!("#000000"),
grass: hex_color!("#112b15"),
Expand Down

0 comments on commit 1f1cbe8

Please sign in to comment.