Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Instances in Custom Directories #443

Open
wants to merge 6 commits into
base: settings-tab
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 61 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ espim = "0.2"
flate2 = "1.0"
fs_extra = "1.3.0"
futures = "0.3"
iced_aw = { git = "https://github.com/iced-rs/iced_aw.git", rev = "9ed46bffd0d819f22e07db6c282fbef733007df5", default-features = false, features = ["tabs", "icons"] }
iced_aw = { git = "https://github.com/iced-rs/iced_aw.git", rev = "9ed46bffd0d819f22e07db6c282fbef733007df5", default-features = false, features = [
"tabs",
"icons",
] }
lazy_static = "1.5"
log = { version = "0.4.22", features = ["std"] }
open = "5"
Expand All @@ -41,17 +44,29 @@ time = "0.3"
tokio = { version = "1", default-features = false, features = ["fs"] }
ureq = { version = "2.9", default-features = false, features = ["json", "tls"] }
version = "3"
zip-extract = { version = "0.1.3", default-features = false, features = ["deflate"] }
zip-extract = { version = "0.1.3", default-features = false, features = [
"deflate",
] }
rfd = { version = "0.14.1", default-features = false, features = [
"tokio",
"xdg-portal",
] }

[dependencies.iced]
version = "0.12.1"
default-features = false
features = ["web-colors", "advanced", "image", "tokio"]
features = [
"web-colors",
"advanced",
"image",
"tokio",
"wgpu", # tiny-skia backend panics with text in rows: https://github.com/iced-rs/iced/issues/2332
]

[target.'cfg(windows)'.build-dependencies]
winres = "0.1"

[profile.release]
strip = true
opt-level = 'z' # Optimize for size.
opt-level = 'z' # Optimize for size.
lto = true
13 changes: 11 additions & 2 deletions src/install_frame.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::instance::{get_instances_dir, InstanceType};
use crate::settings::Settings;
use crate::style::text_button;
use crate::{instance, Message};
use core::fmt;
Expand Down Expand Up @@ -57,10 +58,18 @@ impl fmt::Display for InstanceSourceType {
}

impl InstallFrame {
pub fn update(&mut self, message: InstallFrameMessage) -> Command<Message> {
pub fn update(
&mut self,
message: InstallFrameMessage,
settings: &mut Settings,
) -> Command<Message> {
match message {
InstallFrameMessage::StartInstallation(instance_type) => {
if let Some(mut destination) = get_instances_dir() {
if let Some(mut destination) = if settings.use_custom_install_dir {
settings.custom_install_dir.clone()
} else {
get_instances_dir()
} {
destination.push(&self.name);
return Command::perform(
instance::perform_install(
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ impl Application for ESLauncher {

fn update(&mut self, message: Self::Message) -> Command<Message> {
match message {
Message::InstallFrameMessage(msg) => return self.install_frame.update(msg),
Message::InstallFrameMessage(msg) => {
return self.install_frame.update(msg, &mut self.settings)
}
Message::InstanceMessage(name, msg) => {
match self.instances_frame.instances.get_mut(&name) {
None => error!("Failed to find internal Instance with name {}", &name),
Expand All @@ -174,7 +176,7 @@ impl Application for ESLauncher {
}
}
}
Message::SettingsMessage(msg) => self.settings.update(msg),
Message::SettingsMessage(msg) => return self.settings.update(msg),
Message::AddInstance(instance) => {
let is_ready = instance.state.is_ready();
self.instances_frame
Expand All @@ -197,9 +199,7 @@ impl Application for ESLauncher {
MusicCommand::Play => MusicState::Playing,
_ => self.settings.music_state,
};
if let Err(e) = self.settings.save() {
error!("Failed to save settings.json: {:#?}", e);
};
self.settings.save();
}
Message::TabSelected(active_tab) => self.active_tab = active_tab,
Message::PluginFrameLoaded(plugins) => {
Expand Down
Loading