Skip to content

Commit 41f614d

Browse files
committed
50 errors help
1 parent 411c2ca commit 41f614d

29 files changed

+500
-285
lines changed

crates/client/src/collections.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use nomi_modding::modrinth::{
99

1010
use crate::{
1111
errors_pool::ErrorPoolExt,
12-
views::{ProfilesConfig, SimpleDependency},
12+
views::{InstancesConfig, SimpleDependency},
1313
};
1414

1515
pub struct FabricDataCollection;
@@ -73,7 +73,7 @@ impl<'c> TasksCollection<'c> for JavaCollection {
7373
pub struct GameDownloadingCollection;
7474

7575
impl<'c> TasksCollection<'c> for GameDownloadingCollection {
76-
type Context = &'c ProfilesConfig;
76+
type Context = &'c InstancesConfig;
7777

7878
type Target = Option<()>;
7979

@@ -85,7 +85,7 @@ impl<'c> TasksCollection<'c> for GameDownloadingCollection {
8585

8686
fn handle(context: Self::Context) -> Handler<'c, Self::Target> {
8787
Handler::new(|_| {
88-
context.update_config().report_error();
88+
context.update_config_sync().report_error();
8989
})
9090
}
9191
}
@@ -182,7 +182,7 @@ impl<'c> TasksCollection<'c> for DependenciesCollection {
182182
pub struct ModsDownloadingCollection;
183183

184184
impl<'c> TasksCollection<'c> for ModsDownloadingCollection {
185-
type Context = &'c ProfilesConfig;
185+
type Context = &'c InstancesConfig;
186186

187187
type Target = Option<()>;
188188

@@ -194,7 +194,7 @@ impl<'c> TasksCollection<'c> for ModsDownloadingCollection {
194194

195195
fn handle(context: Self::Context) -> Handler<'c, Self::Target> {
196196
Handler::new(|_| {
197-
context.update_config().report_error();
197+
context.update_config_sync().report_error();
198198
})
199199
}
200200
}
@@ -220,7 +220,7 @@ impl<'c> TasksCollection<'c> for GameRunnerCollection {
220220
pub struct DownloadAddedModsCollection;
221221

222222
impl<'c> TasksCollection<'c> for DownloadAddedModsCollection {
223-
type Context = (&'c mut HashSet<ProjectId>, &'c ProfilesConfig);
223+
type Context = (&'c mut HashSet<ProjectId>, &'c InstancesConfig);
224224

225225
type Target = ProjectId;
226226

@@ -233,7 +233,7 @@ impl<'c> TasksCollection<'c> for DownloadAddedModsCollection {
233233
fn handle(context: Self::Context) -> Handler<'c, Self::Target> {
234234
Handler::new(|id| {
235235
context.0.remove(&id);
236-
context.1.update_config().report_error();
236+
context.1.update_config_sync().report_error();
237237
})
238238
}
239239
}

crates/client/src/context.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ impl TabViewer for MyContext {
6969
match &tab.kind {
7070
TabKind::Mods { profile } => {
7171
let profile = profile.read();
72-
self.states.profiles.profiles.find_profile(profile.profile.id).is_none()
72+
self.states.profiles.instances.find_instance(profile.profile.id).is_none()
7373
}
7474
TabKind::ProfileInfo { profile } => {
7575
let profile = profile.read();
76-
self.states.profiles.profiles.find_profile(profile.profile.id).is_none()
76+
self.states.profiles.instances.find_instance(profile.profile.id).is_none()
7777
}
7878
_ => false,
7979
}
@@ -117,13 +117,13 @@ impl TabViewer for MyContext {
117117
}
118118
TabKind::Mods { profile } => ModManager {
119119
task_manager: &mut self.manager,
120-
profiles_config: &mut self.states.profiles.profiles,
120+
profiles_config: &mut self.states.profiles.instances,
121121
mod_manager_state: &mut self.states.mod_manager,
122122
profile: profile.clone(),
123123
}
124124
.ui(ui),
125125
TabKind::ProfileInfo { profile } => ProfileInfo {
126-
profiles: &self.states.profiles.profiles,
126+
profiles: &self.states.profiles.instances,
127127
task_manager: &mut self.manager,
128128
profile: profile.clone(),
129129
tabs_state: &mut self.states.tabs,

crates/client/src/download.rs

+8-17
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use nomi_core::{
1010
AssetsDownloader, DownloadQueue,
1111
},
1212
game_paths::GamePaths,
13-
instance::{launch::LaunchSettings, Instance},
13+
instance::{launch::LaunchSettings, Profile},
1414
loaders::{
1515
fabric::Fabric,
1616
forge::{Forge, ForgeVersion},
@@ -48,46 +48,37 @@ async fn try_download_version(profile: Arc<RwLock<ModdedProfile>>, progress_shar
4848
let game_paths = GamePaths {
4949
game: mc_dir.clone(),
5050
assets: mc_dir.join("assets"),
51-
version: mc_dir.join("versions").join(version),
51+
profile: mc_dir.join("versions").join(version),
5252
libraries: mc_dir.join("libraries"),
5353
};
5454

55-
let builder = Instance::builder()
55+
let builder = Profile::builder()
5656
.name(version_profile.name.clone())
5757
.version(version_profile.version().to_string())
5858
.game_paths(game_paths.clone());
5959

6060
let instance = match loader {
61-
Loader::Vanilla => builder.instance(Box::new(Vanilla::new(version_profile.version(), game_paths.clone()).await?)),
62-
Loader::Fabric { version } => builder.instance(Box::new(
61+
Loader::Vanilla => builder.downloader(Box::new(Vanilla::new(version_profile.version(), game_paths.clone()).await?)),
62+
Loader::Fabric { version } => builder.downloader(Box::new(
6363
Fabric::new(version_profile.version(), version.as_ref(), game_paths.clone()).await?,
6464
)),
65-
Loader::Forge => builder.instance(Box::new(
65+
Loader::Forge => builder.downloader(Box::new(
6666
Forge::new(version_profile.version(), ForgeVersion::Recommended, game_paths.clone()).await?,
6767
)),
6868
}
6969
.build();
7070

7171
let settings = LaunchSettings {
72-
assets: instance.game_paths.assets.clone(),
73-
game_dir: instance.game_paths.game.clone(),
74-
java_bin: JavaRunner::default(),
75-
libraries_dir: instance.game_paths.libraries.clone(),
76-
manifest_file: instance.game_paths.version.join(format!("{}.json", &version)),
77-
natives_dir: instance.game_paths.version.join("natives"),
78-
version_jar_file: instance.game_paths.version.join(format!("{}.jar", &version)),
72+
java_runner: None,
7973
version: version.to_string(),
8074
version_type: version_type.clone(),
8175
};
8276

8377
let launch_instance = instance.launch_instance(settings, Some(vec!["-Xms2G".to_string(), "-Xmx4G".to_string()]));
8478

85-
let instance = instance.instance();
86-
79+
let instance = instance.downloader();
8780
let io = instance.io();
88-
8981
let downloader: Box<dyn Downloader<Data = DownloadResult>> = instance.into_downloader();
90-
9182
io.await?;
9283

9384
let downloader = DownloadQueue::new().with_downloader_dyn(downloader);

crates/client/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,19 @@ impl eframe::App for MyTabs {
140140
.add_collection::<collections::AssetsCollection>(())
141141
.add_collection::<collections::FabricDataCollection>(&mut self.context.states.add_profile_menu_state.fabric_versions)
142142
.add_collection::<collections::GameDeletionCollection>(())
143-
.add_collection::<collections::GameDownloadingCollection>(&self.context.states.profiles.profiles)
143+
.add_collection::<collections::GameDownloadingCollection>(&self.context.states.profiles.instances)
144144
.add_collection::<collections::JavaCollection>(())
145145
.add_collection::<collections::ProjectCollection>(&mut self.context.states.mod_manager.current_project)
146146
.add_collection::<collections::ProjectVersionsCollection>(&mut self.context.states.mod_manager.current_versions)
147147
.add_collection::<collections::DependenciesCollection>((
148148
&mut self.context.states.mod_manager.current_dependencies,
149149
self.context.states.mod_manager.current_project.as_ref().map(|p| &p.id),
150150
))
151-
.add_collection::<collections::ModsDownloadingCollection>(&self.context.states.profiles.profiles)
151+
.add_collection::<collections::ModsDownloadingCollection>(&self.context.states.profiles.instances)
152152
.add_collection::<collections::GameRunnerCollection>(())
153153
.add_collection::<collections::DownloadAddedModsCollection>((
154154
&mut self.context.states.profile_info.currently_downloading_mods,
155-
&self.context.states.profiles.profiles,
155+
&self.context.states.profiles.instances,
156156
));
157157

158158
ctx.set_pixels_per_point(self.context.states.client_settings.pixels_per_point);

crates/client/src/states.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use egui_task_manager::{Caller, Task, TaskManager};
44
use nomi_core::{
55
downloads::{java::JavaDownloader, progress::MappedSender, traits::Downloader},
66
fs::read_toml_config_sync,
7-
DOT_NOMI_JAVA_DIR, DOT_NOMI_JAVA_EXECUTABLE, DOT_NOMI_PROFILES_CONFIG, DOT_NOMI_SETTINGS_CONFIG,
7+
DOT_NOMI_JAVA_DIR, DOT_NOMI_JAVA_EXECUTABLE, DOT_NOMI_SETTINGS_CONFIG,
88
};
99
use tracing::info;
1010

@@ -15,7 +15,7 @@ use crate::{
1515
add_tab_menu::TabsState,
1616
profiles::ProfilesState,
1717
settings::{ClientSettingsState, SettingsState},
18-
AddProfileMenuState, LogsState, ModManagerState, ProfileInfoState, ProfilesConfig,
18+
AddProfileMenuState, InstancesConfig, LogsState, ModManagerState, ProfileInfoState,
1919
},
2020
};
2121

@@ -44,7 +44,7 @@ impl Default for States {
4444
java: JavaState::new(),
4545
profiles: ProfilesState {
4646
currently_downloading_profiles: HashSet::new(),
47-
profiles: read_toml_config_sync::<ProfilesConfig>(DOT_NOMI_PROFILES_CONFIG).unwrap_or_default(),
47+
instances: read_toml_config_sync::<InstancesConfig>(DOT_NOMI_PROFILES_CONFIG).unwrap_or_default(),
4848
},
4949
client_settings: settings.client_settings.clone(),
5050
settings,

crates/client/src/views/add_profile_menu.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ impl View for AddProfileMenu<'_> {
202202
)
203203
.clicked()
204204
{
205-
self.profiles_state.profiles.add_profile(ModdedProfile::new(VersionProfile {
206-
id: self.profiles_state.profiles.create_id(),
205+
self.profiles_state.instances.add_instance(ModdedProfile::new(VersionProfile {
206+
id: self.profiles_state.instances.next_id(),
207207
name: self.menu_state.profile_name_buf.trim_end().to_owned(),
208208
state: ProfileState::NotDownloaded {
209209
// PANICS: It will never panic because it's
@@ -213,7 +213,7 @@ impl View for AddProfileMenu<'_> {
213213
version_type: self.menu_state.selected_version_type.clone(),
214214
},
215215
}));
216-
self.profiles_state.profiles.update_config().report_error();
216+
self.profiles_state.instances.update_config_sync().report_error();
217217
}
218218
}
219219
}

crates/client/src/views/mods_manager.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ use crate::{
2828
DOT_NOMI_MODS_STASH_DIR,
2929
};
3030

31-
use super::{ModdedProfile, ProfilesConfig, View};
31+
use super::{InstancesConfig, ModdedProfile, View};
3232

3333
pub use crate::mods::*;
3434

3535
pub struct ModManager<'a> {
3636
pub task_manager: &'a mut TaskManager,
37-
pub profiles_config: &'a mut ProfilesConfig,
37+
pub profiles_config: &'a mut InstancesConfig,
3838
pub profile: Arc<RwLock<ModdedProfile>>,
3939
pub mod_manager_state: &'a mut ModManagerState,
4040
}
@@ -586,7 +586,7 @@ impl View for ModManager<'_> {
586586

587587
let project_type = project.project_type;
588588

589-
let _ = self.profiles_config.update_config().report_error();
589+
let _ = self.profiles_config.update_config_sync().report_error();
590590
let is_data_pack = self.mod_manager_state.is_datapack;
591591
let profile_id = {
592592
let lock = profile.read();

crates/client/src/views/profile_info.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use nomi_modding::modrinth::project::ProjectId;
77
use parking_lot::RwLock;
88

99
use crate::{
10-
collections::DownloadAddedModsCollection, errors_pool::ErrorPoolExt, open_directory::open_directory_native, ui_ext::UiExt, views::ProfilesConfig,
11-
TabKind, DOT_NOMI_MODS_STASH_DIR,
10+
collections::DownloadAddedModsCollection, errors_pool::ErrorPoolExt, open_directory::open_directory_native, ui_ext::UiExt,
11+
views::InstancesConfig, TabKind, DOT_NOMI_MODS_STASH_DIR,
1212
};
1313

1414
use super::{download_added_mod, Mod, ModdedProfile, TabsState, View};
1515

1616
pub struct ProfileInfo<'a> {
17-
pub profiles: &'a ProfilesConfig,
17+
pub profiles: &'a InstancesConfig,
1818
pub task_manager: &'a mut TaskManager,
1919
pub profile: Arc<RwLock<ModdedProfile>>,
2020
pub tabs_state: &'a mut TabsState,
@@ -273,7 +273,7 @@ impl View for ProfileInfo<'_> {
273273
}
274274

275275
{
276-
self.profiles.update_config().report_error();
276+
self.profiles.update_config_sync().report_error();
277277
}
278278

279279
self.profile_info_state.mods_to_import.clear();
@@ -377,7 +377,7 @@ impl View for ProfileInfo<'_> {
377377
}
378378
}
379379

380-
self.profiles.update_config().report_error();
380+
self.profiles.update_config_sync().report_error();
381381
}
382382

383383
if ui.button("Reset").clicked() {
@@ -476,7 +476,7 @@ impl View for ProfileInfo<'_> {
476476

477477
vec.retain(|m| !mods_to_remove.contains(&m.project_id));
478478
if !mods_to_remove.is_empty() {
479-
self.profiles.update_config().report_error();
479+
self.profiles.update_config_sync().report_error();
480480
}
481481

482482
let _ = std::mem::replace(&mut self.profile.write().mods.mods, vec);

0 commit comments

Comments
 (0)