config improvements
This commit is contained in:
parent
ffe677088f
commit
167d461c35
3 changed files with 47 additions and 7 deletions
|
@ -133,29 +133,49 @@ impl EmulatorHandler {
|
|||
)
|
||||
.expect("Error parsing rom");
|
||||
|
||||
let shader_path = if rom.rom_type == CgbRomType::CgbOnly || config.prefer_cgb {
|
||||
let will_be_cgb = rom.rom_type == CgbRomType::CgbOnly || config.prefer_cgb;
|
||||
|
||||
let shader_path = if will_be_cgb {
|
||||
config.vulkan_config.cgb_shader_path.as_ref()
|
||||
} else {
|
||||
config.vulkan_config.dmg_shader_path.as_ref()
|
||||
}
|
||||
.map(|v| config_manager.dir().join(v));
|
||||
|
||||
let resizable = shader_path.is_some()
|
||||
&& if will_be_cgb {
|
||||
config.vulkan_config.cgb_shader_resizable
|
||||
} else {
|
||||
config.vulkan_config.dmg_shader_resizable
|
||||
};
|
||||
|
||||
let scale_override = match if will_be_cgb {
|
||||
config.vulkan_config.cgb_resolution_override
|
||||
} else {
|
||||
config.vulkan_config.dmg_resolution_override
|
||||
} {
|
||||
gb_emu_lib::config::ResolutionOverride::Scale(scale) => Some(scale),
|
||||
gb_emu_lib::config::ResolutionOverride::Default => None,
|
||||
}
|
||||
.unwrap_or(standalone_config.scale_factor);
|
||||
|
||||
let mut window_manager = WindowManager::new(sender);
|
||||
|
||||
let window = window_manager.add(
|
||||
standalone_config.scale_factor,
|
||||
scale_override,
|
||||
Some(Gilrs::new().unwrap()),
|
||||
shader_path,
|
||||
resizable,
|
||||
);
|
||||
|
||||
let tile_window: Option<WindowRenderer> = if args.tile_window {
|
||||
Some(window_manager.add(standalone_config.scale_factor, None, None))
|
||||
Some(window_manager.add(standalone_config.scale_factor, None, None, false))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let layer_window: Option<WindowRenderer> = if args.layer_window {
|
||||
Some(window_manager.add(standalone_config.scale_factor.min(2), None, None))
|
||||
Some(window_manager.add(standalone_config.scale_factor.min(2), None, None, false))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -64,6 +64,7 @@ impl WindowManager {
|
|||
factor: usize,
|
||||
gamepad_handler: Option<Gilrs>,
|
||||
shader_path: Option<PathBuf>,
|
||||
resizable: bool,
|
||||
) -> WindowRenderer {
|
||||
let (r, info) = WindowRenderer::new(
|
||||
factor,
|
||||
|
@ -72,6 +73,7 @@ impl WindowManager {
|
|||
&self.event_loop,
|
||||
self.window_data_manager.clone(),
|
||||
shader_path,
|
||||
resizable,
|
||||
);
|
||||
self.windows.insert(info.id, info.data);
|
||||
r
|
||||
|
@ -137,10 +139,11 @@ impl WindowRenderer {
|
|||
event_loop: &EventLoop<()>,
|
||||
manager: Arc<RendererBackendManager>,
|
||||
shader_path: Option<PathBuf>,
|
||||
resizable: bool,
|
||||
) -> (Self, WindowInfo) {
|
||||
let window = WindowBuilder::new()
|
||||
.with_title("Gameboy")
|
||||
.with_resizable(shader_path.is_some())
|
||||
.with_resizable(resizable)
|
||||
.build(event_loop)
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -34,8 +34,11 @@ impl ConfigManager {
|
|||
where
|
||||
C: Serialize + DeserializeOwned + Default + Clone,
|
||||
{
|
||||
match self.load_custom_config(name) {
|
||||
Some(v) => v,
|
||||
match self.load_custom_config::<C>(name) {
|
||||
Some(v) => {
|
||||
let _ = self.save_custom_config(name, v.clone());
|
||||
v
|
||||
}
|
||||
None => {
|
||||
let config = C::default();
|
||||
if let Ok(true) = self.path.join(name).try_exists() {
|
||||
|
@ -86,7 +89,17 @@ pub struct Config {
|
|||
#[serde(default)]
|
||||
pub struct VulkanRendererConfig {
|
||||
pub dmg_shader_path: Option<String>,
|
||||
pub dmg_shader_resizable: bool,
|
||||
pub dmg_resolution_override: ResolutionOverride,
|
||||
pub cgb_shader_path: Option<String>,
|
||||
pub cgb_shader_resizable: bool,
|
||||
pub cgb_resolution_override: ResolutionOverride,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
|
||||
pub enum ResolutionOverride {
|
||||
Scale(usize),
|
||||
Default,
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
|
@ -107,7 +120,11 @@ impl Default for VulkanRendererConfig {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
dmg_shader_path: None,
|
||||
dmg_shader_resizable: false,
|
||||
dmg_resolution_override: ResolutionOverride::Default,
|
||||
cgb_shader_path: None,
|
||||
cgb_shader_resizable: false,
|
||||
cgb_resolution_override: ResolutionOverride::Default,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue