Add option to always launch through heroic (#156)

* Add option to always launch through heroic

* Default to launche through heroic
This commit is contained in:
Philip Kristoffersen
2022-05-24 19:46:12 +02:00
committed by GitHub
parent 5a26eec796
commit 5e8e4f2451
4 changed files with 66 additions and 46 deletions
+1
View File
@@ -39,6 +39,7 @@ flatpak = false
[heroic] [heroic]
enabled = true enabled = true
launch_games_through_heroic =[] launch_games_through_heroic =[]
default_launch_through_heroic = true
[amazon] [amazon]
enabled = true enabled = true
+10 -5
View File
@@ -138,17 +138,22 @@ impl HeroicPlatform {
if let Some(shortcuts) = shortcuts.as_mut() { if let Some(shortcuts) = shortcuts.as_mut() {
for shortcut in shortcuts { for shortcut in shortcuts {
shortcut.install_mode = Some(install_mode.clone()); shortcut.install_mode = Some(install_mode.clone());
if self
let game_in_list = self
.settings .settings
.launch_games_through_heroic .launch_games_through_heroic
.contains(&shortcut.app_name) .contains(&shortcut.app_name)
|| self || self
.settings .settings
.launch_games_through_heroic .launch_games_through_heroic
.contains(&shortcut.title) .contains(&shortcut.title);
{
shortcut.launch_through_heroic = true; shortcut.launch_through_heroic =
} if self.settings.default_launch_through_heroic {
!game_in_list
} else {
game_in_list
};
} }
} }
shortcuts shortcuts
+1
View File
@@ -4,4 +4,5 @@ use serde::{Deserialize, Serialize};
pub struct HeroicSettings { pub struct HeroicSettings {
pub enabled: bool, pub enabled: bool,
pub launch_games_through_heroic: Vec<String>, pub launch_games_through_heroic: Vec<String>,
pub default_launch_through_heroic: bool,
} }
+34 -21
View File
@@ -36,20 +36,49 @@ impl MyEguiApp {
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
{ {
self.render_heroic_settings(ui);
}
self.render_legendary_settings(ui);
self.render_itch_settings(ui);
self.render_origin_settings(ui);
self.render_gog_settings(ui);
self.render_uplay_settings(ui);
self.render_lutris_settings(ui);
#[cfg(windows)]
{
self.render_amazon_settings(ui);
}
ui.add_space(SECTION_SPACING);
ui.label(format!("Version: {}", VERSION));
});
}
fn render_heroic_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Heroic"); ui.heading("Heroic");
ui.checkbox(&mut self.settings.heroic.enabled, "Import from Heroic"); ui.checkbox(&mut self.settings.heroic.enabled, "Import from Heroic");
ui.checkbox(&mut self.settings.heroic.default_launch_through_heroic, "Always launch games through Heroic");
let safe_mode_header = match (self.settings.heroic.default_launch_through_heroic,self.settings.heroic.launch_games_through_heroic.len()) {
(false,0) => "Force games to launch through Heroic Launcher".to_string(),
(false,1) => "One game forced to launch through Heroic Launcher".to_string(),
(false,x) => format!("{} games forced to launch through Heroic Launcher", x),
(true,0) => "Force games to launch directly".to_string(),
(true,1) => "One game forced to launch directly".to_string(),
(true,x) => format!("{} games forced to launch directly", x),
let safe_mode_header = match self.settings.heroic.launch_games_through_heroic.len() {
0 => "Force games to launch through Heroic Launcher".to_string(),
1 => "One game forced to launch through Heroic Launcher".to_string(),
x => format!("{} games forced to launch through Heroic Launcher", x),
}; };
egui::CollapsingHeader::new(safe_mode_header) egui::CollapsingHeader::new(safe_mode_header)
.id_source("Heroic_Launcher_safe_launch") .id_source("Heroic_Launcher_safe_launch")
.show(ui, |ui| { .show(ui, |ui| {
if
self.settings.heroic.default_launch_through_heroic{
ui.label("Some games work best when launched directly, select those games below and BoilR will create shortcuts that launch the games directly.");
} else{
ui.label("Some games must be started from the Heroic Launcher, select those games below and BoilR will create shortcuts that opens the games through the Heroic Launcher."); ui.label("Some games must be started from the Heroic Launcher, select those games below and BoilR will create shortcuts that opens the games through the Heroic Launcher.");
}
let manifests =self.heroic_games.get_or_insert_with(||{ let manifests =self.heroic_games.get_or_insert_with(||{
let heroic_setting = self.settings.heroic.clone(); let heroic_setting = self.settings.heroic.clone();
@@ -75,25 +104,9 @@ impl MyEguiApp {
} }
} }
}) ; }) ;
ui.add_space(SECTION_SPACING); ui.add_space(SECTION_SPACING);
} }
self.render_legendary_settings(ui);
self.render_itch_settings(ui);
self.render_origin_settings(ui);
self.render_gog_settings(ui);
self.render_uplay_settings(ui);
self.render_lutris_settings(ui);
#[cfg(windows)]
{
self.render_amazon_settings(ui);
}
ui.add_space(SECTION_SPACING);
ui.label(format!("Version: {}", VERSION));
});
}
fn render_lutris_settings(&mut self, ui: &mut egui::Ui) { fn render_lutris_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Lutris"); ui.heading("Lutris");
ui.checkbox(&mut self.settings.lutris.enabled, "Import from Lutris"); ui.checkbox(&mut self.settings.lutris.enabled, "Import from Lutris");