2024-01-31 10:42:26 -06:00
|
|
|
use eframe::egui::{self, Slider};
|
|
|
|
use egui_modal::Modal;
|
|
|
|
|
2024-01-31 11:28:56 -06:00
|
|
|
use crate::{state::EmuState, window::Window, Options};
|
2024-01-31 10:42:26 -06:00
|
|
|
|
|
|
|
pub struct OptionWindow {
|
|
|
|
options: Options,
|
|
|
|
category: OptionsCategory,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq)]
|
|
|
|
enum OptionsCategory {
|
|
|
|
General,
|
|
|
|
Cards,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl OptionWindow {
|
|
|
|
pub fn new(ctx: &egui::Context, state: &EmuState) -> Self {
|
|
|
|
Modal::new(ctx, "options_modal").open();
|
|
|
|
Self {
|
2024-01-31 15:23:48 -06:00
|
|
|
options: state.options(),
|
2024-01-31 10:42:26 -06:00
|
|
|
category: OptionsCategory::General,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Window for OptionWindow {
|
|
|
|
fn draw(&mut self, ctx: &egui::Context, state: &mut EmuState) -> bool {
|
|
|
|
let modal = Modal::new(ctx, "options_modal");
|
|
|
|
modal.show(|ui| {
|
|
|
|
modal.title(ui, "Options");
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
ui.selectable_value(&mut self.category, OptionsCategory::General, "General");
|
|
|
|
ui.selectable_value(&mut self.category, OptionsCategory::Cards, "Cards");
|
|
|
|
});
|
|
|
|
match self.category {
|
|
|
|
OptionsCategory::General => {
|
|
|
|
ui.checkbox(&mut self.options.mute, "Mute");
|
|
|
|
ui.checkbox(&mut self.options.fan_enabled, "Fan enabled");
|
|
|
|
ui.add(Slider::new(&mut self.options.volume, 0.0..=100.0).text("Volume"));
|
|
|
|
}
|
|
|
|
OptionsCategory::Cards => {
|
|
|
|
ui.heading("TODO");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
modal.buttons(ui, |ui| {
|
|
|
|
if ui.button("Apply").clicked() {
|
|
|
|
state.update_options(self.options);
|
|
|
|
}
|
|
|
|
if modal.button(ui, "OK").clicked() {
|
|
|
|
state.update_options(self.options);
|
|
|
|
}
|
|
|
|
modal.caution_button(ui, "Cancel");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
!modal.is_open()
|
|
|
|
}
|
|
|
|
}
|