Skip to content

Commit 9a34a61

Browse files
committed
use "download" terminology on wasm
- add feedback for options - (wasm) hide options that do nothing - update gradle wrapper
1 parent e6141cd commit 9a34a61

11 files changed

Lines changed: 222 additions & 183 deletions

File tree

Cargo.lock

Lines changed: 102 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradle/wrapper/gradle-wrapper.jar

2.73 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
/* Allow canvas to fill entire web page: */
5454
html,
5555
body {
56-
overflow: hidden;
5756
margin: 0 !important;
5857
padding: 0 !important;
5958
height: 100%;
@@ -123,10 +122,15 @@
123122

124123
<!-- the loading spinner will be removed in gui.rs -->
125124
<!-- make sure the ids of these elements are kept, they are referenced in rust (both gui.rs and cli.rs)! -->
126-
<div class="centered" id="loading_text">
127-
<noscript>You need javascript to use this website</noscript>
128-
<p style="font-size: 16px" id="loading_status">Loading…</p>
129-
<div class="lds-dual-ring"></div>
125+
<div class="centered">
126+
<div id="loading_text">
127+
<noscript
128+
>You need javascript to use this page. Alternatively, you may use the
129+
downloadable version of this installer.</noscript
130+
>
131+
<p style="font-size: 16px" id="loading_status">Loading…</p>
132+
<div class="lds-dual-ring"></div>
133+
</div>
130134
</div>
131135
</body>
132136
</html>

locales/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"gui.button.yes": "Ja",
4242
"gui.button.no": "Nein",
4343
"gui.button.cancel": "Abbrechen",
44+
"gui.button.install_web": "Herunterladen",
45+
"gui.message.excluding_flap": "Flap wird nicht mitgeliefert.",
46+
"gui.message.not_creating_profile": "Es wird kein Launcher-Profil erstellt.",
4447
"client.error.directory_does_not_exist": "Der Ordner %{dir} existiert nicht. Stelle sicher, dass du den richtigen Ordner ausgewählt und dass du das Spiel mindestens einmal vorher gestartet hast.",
4548
"client.info.installation_start": "Installiere client für %{version} mit %{loader} Loader %{loader_version} nach %{destination}",
4649
"client.info.installation_start_web": "Installiere client für %{version} mit %{loader} Loader %{loader_version}",

locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"gui.button.yes": "Yes",
4242
"gui.button.no": "No",
4343
"gui.button.cancel": "Cancel",
44+
"gui.button.install_web": "Download",
45+
"gui.message.excluding_flap": "Not installing Flap.",
46+
"gui.message.not_creating_profile": "Not creating profile entry.",
4447
"client.error.directory_does_not_exist": "The directory %{dir} does not exist. Make sure you selected the correct folder and that you have started the game at least once before.",
4548
"client.info.installation_start": "Installing client for %{version} using %{loader} Loader %{loader_version} to %{destination}",
4649
"client.info.installation_start_web": "Installing client for %{version} using %{loader} Loader %{loader_version}",

src/actions/client.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,8 @@ pub async fn install(
149149
});
150150
}
151151

152-
if create_profile {
153-
if cfg!(not(target_arch = "wasm32")) {
154-
update_profiles(location, profile_name, version, loader_type, calamus_gen)?;
155-
}
152+
if create_profile && cfg!(not(target_arch = "wasm32")) {
153+
update_profiles(location, profile_name, version, loader_type, calamus_gen)?;
156154
}
157155

158156
let _ = sender.send((1.0, t!("client.info.done").into()));

src/actions/server.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ async fn install_path(
100100
)
101101
};
102102
let _ = sender.send((0.1, message.into()));
103-
#[cfg(not(target_arch = "wasm32"))]
104103
let location = location.canonicalize()?;
105104

106105
#[cfg(not(target_arch = "wasm32"))]

src/ui/cli.rs

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ pub async fn run() {
101101

102102
#[cfg(target_arch = "wasm32")]
103103
{
104+
let window = web_sys::window().expect("Window not available");
105+
let document = window.document().expect("Document not available");
104106
let location = web_sys::window().expect("Window not available").location();
105107
let query = location.search().unwrap_or(String::new());
106108
let query_presplit = format!("--{}", query[1..].replace("&", " --").replace("=", " "));
@@ -110,6 +112,11 @@ pub async fn run() {
110112
.bin_name("ornithe-installer-rs")
111113
.color(clap::ColorChoice::Never)
112114
.try_get_matches_from(query_cleaned);
115+
let loading_text = document.get_element_by_id("loading_text").unwrap();
116+
let _ = loading_text.insert_adjacent_html(
117+
"afterend",
118+
"<i style=\"font-size: 16px;\" id=\"status_notes\"></i>",
119+
);
113120

114121
match res {
115122
Ok(res) => match parse(res).await {
@@ -119,10 +126,7 @@ pub async fn run() {
119126
Ornithe has been successfully installed.
120127
Most mods require that you also download the Ornithe Standard Libraries mod and place it in your mods folder.
121128
You can find it at {}.", crate::OSL_MODRINTH_URL);
122-
let window = web_sys::window().expect("Window not available");
123-
let document = window.document().expect("Document not available");
124-
if let Some(element) = document.get_element_by_id("loading_text") {
125-
element.set_inner_html(&format!(
129+
loading_text.set_inner_html(&format!(
126130
"<h3>Installation complete!</h3>
127131
<p>
128132
Ornithe has been successfully installed.
@@ -132,13 +136,13 @@ pub async fn run() {
132136
You can find it at <a href=\"{}\">{}</a>
133137
</p>",
134138
crate::OSL_MODRINTH_URL,
135-
crate::OSL_MODRINTH_URL
136-
));
137-
}
139+
crate::OSL_MODRINTH_URL));
138140
}
139141
}
140142
Err(e) => {
141143
log::warn!("Error while running Ornithe Installer CLI: {}", &e.0);
144+
loading_text
145+
.set_inner_html(&format!("<h3>Encountered error:</h3><p>{}</p>", &e.0));
142146
}
143147
},
144148
Err(error) => {
@@ -188,6 +192,9 @@ async fn parse(matches: ArgMatches) -> Result<InstallationResult, InstallerError
188192
}
189193
if let Some(matches) = matches.subcommand_matches("loader-versions") {
190194
let generation = matches.get_one::<u32>("gen").map(|u| *u);
195+
if let Some(g) = generation {
196+
print_note_intermediary_generation(g);
197+
}
191198
let versions = crate::net::meta::fetch_loader_versions(&generation).await?;
192199
let loader_type = get_loader_type(matches)?;
193200
let betas = matches.get_flag("show-betas");
@@ -307,7 +314,9 @@ async fn parse(matches: ArgMatches) -> Result<InstallationResult, InstallerError
307314
while !fut.is_finished() || !recv.is_empty() {
308315
match recv.try_recv() {
309316
Ok((prog, msg)) => {
310-
pb.println(msg);
317+
if !msg.is_empty() {
318+
pb.println(msg);
319+
}
311320
pb.set_position((prog * 100.0) as u64);
312321
}
313322
Err(_) => {}
@@ -318,6 +327,35 @@ async fn parse(matches: ArgMatches) -> Result<InstallationResult, InstallerError
318327
}
319328
}
320329

330+
fn print_note_intermediary_generation(generation: u32) {
331+
#[cfg(target_arch = "wasm32")]
332+
{
333+
log::info!("Using Intermediary Generation: {generation}");
334+
let window = web_sys::window().expect("Window not available");
335+
let document = window.document().expect("Document not available");
336+
let status_notes = document.get_element_by_id("status_notes").unwrap();
337+
let _ = status_notes.insert_adjacent_html(
338+
"beforeend",
339+
&format!("Using Intermediary Generation: {generation}<br>"),
340+
);
341+
}
342+
#[cfg(not(target_arch = "wasm32"))]
343+
println!("Using Intermediary Generation: {generation}");
344+
}
345+
346+
fn print_note_excluding_flap(_sender: &UnboundedSender<(f32, String)>) {
347+
#[cfg(target_arch = "wasm32")]
348+
{
349+
log::info!("Not installing Flap.");
350+
let window = web_sys::window().expect("Window not available");
351+
let document = window.document().expect("Document not available");
352+
let status_notes = document.get_element_by_id("status_notes").unwrap();
353+
let _ = status_notes.insert_adjacent_html("beforeend", "Not installing Flap.<br>");
354+
}
355+
#[cfg(not(target_arch = "wasm32"))]
356+
let _ = _sender.send((0.0, "Not installing Flap.".to_owned()));
357+
}
358+
321359
async fn do_install(
322360
send: UnboundedSender<(f32, String)>,
323361
matches: ArgMatches,
@@ -332,6 +370,14 @@ async fn do_install(
332370
let loader_version = get_loader_version(matches, loader_versions)?;
333371
let location = matches.get_one::<PathBuf>("dir").unwrap().clone();
334372
let create_profile = matches.get_flag("generate-profile");
373+
#[cfg(not(target_arch = "wasm32"))]
374+
if !create_profile {
375+
let _ = send.send((0.0, "Not generating profile entry.".to_owned()));
376+
}
377+
let exclude_flap = matches.get_flag("exclude-flap");
378+
if exclude_flap {
379+
print_note_excluding_flap(&send);
380+
}
335381
crate::actions::client::install(
336382
send,
337383
minecraft_version,
@@ -341,7 +387,7 @@ async fn do_install(
341387
info.calamus_generation,
342388
location,
343389
create_profile,
344-
!matches.get_flag("exclude-flap"),
390+
!exclude_flap,
345391
)
346392
.await?;
347393
return Ok(InstallationResult::Installed);
@@ -357,7 +403,10 @@ async fn do_install(
357403
let loader_versions = all_loader_versions.get(&loader_type).unwrap();
358404
let loader_version = get_loader_version(matches, loader_versions)?;
359405
let location = matches.get_one::<PathBuf>("dir").unwrap().clone();
360-
let include_flap = !matches.get_flag("exclude-flap");
406+
let exclude_flap = matches.get_flag("exclude-flap");
407+
if exclude_flap {
408+
print_note_excluding_flap(&send);
409+
}
361410
if let Some(matches) = matches.subcommand_matches("run") {
362411
let java = matches.get_one::<PathBuf>("java");
363412
let run_args = matches.get_one::<String>("args");
@@ -369,7 +418,7 @@ async fn do_install(
369418
loader_version,
370419
info.calamus_generation,
371420
location,
372-
include_flap,
421+
!exclude_flap,
373422
java,
374423
run_args.map(|s| s.split(" ")),
375424
)
@@ -388,7 +437,7 @@ async fn do_install(
388437
info.calamus_generation,
389438
location,
390439
matches.get_flag("download-minecraft"),
391-
include_flap,
440+
!exclude_flap,
392441
)
393442
.await?;
394443
return Ok(InstallationResult::Installed);
@@ -408,6 +457,10 @@ async fn do_install(
408457
.unwrap()
409458
.clone();
410459
let generate_zip = matches.get_one::<bool>("generate-zip").unwrap().clone();
460+
let exclude_flap = matches.get_flag("exclude-flap");
461+
if exclude_flap {
462+
print_note_excluding_flap(&send);
463+
}
411464
crate::actions::prism_pack::install(
412465
send,
413466
minecraft_version,
@@ -418,7 +471,7 @@ async fn do_install(
418471
copy_profile_path,
419472
generate_zip,
420473
info.calamus_generation,
421-
!matches.get_flag("exclude-flap"),
474+
!exclude_flap,
422475
)
423476
.await?;
424477
return Ok(InstallationResult::Installed);
@@ -431,6 +484,9 @@ async fn get_minecraft_information(
431484
matches: &ArgMatches,
432485
) -> Result<MinecraftInformation, InstallerError> {
433486
let generation = matches.get_one::<u32>("gen").map(|u| *u);
487+
if let Some(g) = generation {
488+
print_note_intermediary_generation(g);
489+
}
434490
let minecraft_versions = crate::net::manifest::fetch_versions(&generation).await?;
435491
let intermediary_versions = crate::net::meta::fetch_intermediary_versions(&generation).await?;
436492

0 commit comments

Comments
 (0)