Skip to content

Commit

Permalink
sdl: add dark grayscale pallete
Browse files Browse the repository at this point in the history
  • Loading branch information
griffi-gh committed Oct 1, 2023
1 parent ecef288 commit a41eb1c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions yarge-frontend-sdl/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,36 @@ const CONFIG_FILE_NAME: &str = "options.bin";
pub enum Palette {
#[default]
Grayscale,
GrayscaleDark,
Green,
Custom([u32; 4])
}
impl Palette {
pub fn get_map(&self) -> [u32; 4] {
match self {
Self::Grayscale => [0x00ffffff, 0x00aaaaaa, 0x00555555, 0x0000000],
Self::Green => [0x00e0f8d0, 0x0088c070, 0x00346856, 0x0081820],
Self::Grayscale => [0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000],
Self::GrayscaleDark => [0x00000000, 0x00555555, 0x00aaaaaa, 0x00ffffff],
Self::Green => [0x00e0f8d0, 0x0088c070, 0x00346856, 0x00081820],
Self::Custom(x) => *x
}
}
pub fn get_name(&self) -> &'static str {
match self {
Self::Grayscale => "Grayscale",
Self::GrayscaleDark => "Grayscale (Dark)",
Self::Green => "Green",
Self::Custom(_) => "Custom"
}
}
///Should overlay text be white?
pub fn is_dark(&self) -> bool {
match self {
Self::Grayscale => false,
Self::GrayscaleDark => true,
Self::Green => false,
Self::Custom(_) => false //TODO check color brightness
}
}
}

#[derive(Default, Serialize, Deserialize, Clone, Copy)]
Expand Down
2 changes: 1 addition & 1 deletion yarge-frontend-sdl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn main() {

//Allow skipping bootrom
if !gb.get_bios_disabled() {
text_renderer.set_color(Color::BLACK);
text_renderer.set_color(if config.palette.is_dark() {Color::WHITE} else {Color::BLACK});
text_renderer.render(&mut canvas, (0, 0), 1., "Press space to skip\n(Hold Alt to tick)");
if kb_state.is_scancode_pressed(Scancode::Space) {
if kb_state.is_scancode_pressed(Scancode::LAlt) | kb_state.is_scancode_pressed(Scancode::RAlt) {
Expand Down
1 change: 1 addition & 0 deletions yarge-frontend-sdl/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ impl Menu {
MenuLocation::PalettePicker => {
if define_radio_group!(&mut config.palette, {
define_radio_item!(Palette::Grayscale.get_name(), Palette::Grayscale, Palette::Grayscale);
define_radio_item!(Palette::GrayscaleDark.get_name(), Palette::GrayscaleDark, Palette::GrayscaleDark);
define_radio_item!(Palette::Green.get_name(), Palette::Green, Palette::Green);
}) {
config.save_dirty().unwrap();
Expand Down

0 comments on commit a41eb1c

Please sign in to comment.