Skip to content

Commit 279132a

Browse files
committed
Minor optimizations to updater
- Add quotation marks to the shell command to allow spaces in the filename - Draw a placeholder in the download progress bar while the file size isn't retrieved (-.-- instead of 0.00) - Restore original draw_loading() code (for sure this time) - Change "Setup" to "Installer" in the filename - Delete old installers on startup - Shift some stuff in the startup code - Restore version number to current version
1 parent df25c8f commit 279132a

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

scripts/control_create/control_create.gml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ save_version = nbs_version
333333
load_settings()
334334
change_theme()
335335
if (show_welcome) window = w_greeting
336+
337+
// Updates
336338
if (check_update)
337339
update_http = http_get("https://api.github.com/repos/HielkeMinecraft/OpenNoteBlockStudio/releases/latest")
338340
else
@@ -344,7 +346,11 @@ if (file_exists_lib(settings_file) && vers != version) {
344346
window = w_update
345347
update = 3
346348
}
347-
log("Startup OK")
349+
350+
// Delete old installer
351+
if (file_exists_lib(update_file)) {
352+
files_delete_lib(update_file)
353+
}
348354

349355
// Auto-recovery
350356
if (file_exists_lib(backup_file)) {
@@ -357,4 +363,6 @@ if (file_exists_lib(backup_file)) {
357363
if (parameter_count() > 0) {
358364
filename = parameter_string(1)
359365
if (filename != "") load_song(filename)
360-
}
366+
}
367+
368+
log("Startup OK")

scripts/draw_downloadprogress/draw_downloadprogress.gml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// draw_downloadprogress(caption, desc, downloaded_size, total_size)
2-
var caption, desc, done, total, done_mb, total_mb, percent, x1, y1;
2+
var caption, desc, done, total, done_mb, total_mb, done_text, total_text, text, percent, x1, y1;
33
caption = argument0
44
desc = argument1
55
done = argument2
@@ -21,5 +21,13 @@ draw_rectangle(x1 + 30, y1 + 60, x1 + 30 + percent * 240, y1 + 80, 0)
2121
draw_theme_color()
2222
draw_rectangle(x1 + 30, y1 + 60, x1 + 270, y1 + 80, 1)
2323
if (percent > 0.5) draw_set_color(c_white)
24-
draw_text(floor(window_width / 2), y1 + 65, string_format(done_mb, 0, 2) + "/" + string_format(total_mb, 0, 2) + " MB (" + string(round(percent * 100)) + "%)")
24+
if (total <= 0) {
25+
done_text = "-.--"
26+
total_text = "-.--"
27+
} else {
28+
done_text = string_format(done_mb, 0, 2)
29+
total_text = string_format(total_mb, 0, 2)
30+
}
31+
text = done_text + "/" + total_text + " MB (" + string(round(percent * 100)) + "%)"
32+
draw_text(floor(window_width / 2), y1 + 65, text)
2533
draw_set_halign(fa_left)
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
// draw_loading(caption, desc, percent)
2-
var caption, desc, done, total, done_mb, total_mb, percent, x1, y1;
1+
/*draw_loading(caption, desc, percent)
2+
var caption, desc, perc, x1, y1;
33
caption = argument0
44
desc = argument1
5-
done = argument2
6-
total = argument3
7-
percent = done/total
8-
done_mb = done/power(1024, 2)
9-
total_mb = total/power(1024, 2)
5+
perc = argument2
106
x1 = floor(window_width / 2 - 150)
117
y1 = floor(window_height / 2 - 50)
128
draw_theme_color()
@@ -17,9 +13,10 @@ draw_set_font(fnt_main)
1713
draw_set_halign(fa_center)
1814
draw_text(floor(window_width / 2), y1 + 40, desc)
1915
draw_set_color(10512464)
20-
draw_rectangle(x1 + 30, y1 + 60, x1 + 30 + percent * 240, y1 + 80, 0)
16+
draw_rectangle(x1 + 30, y1 + 60, x1 + 30 + perc * 240, y1 + 80, 0)
2117
draw_theme_color()
2218
draw_rectangle(x1 + 30, y1 + 60, x1 + 270, y1 + 80, 1)
23-
if (percent > 0.5) draw_set_color(c_white)
24-
draw_text(floor(window_width / 2), y1 + 65, string_format(done_mb, 0, 2) + "/" + string_format(total_mb, 0, 2) + " MB (" + string(round(percent * 100)) + "%)")
19+
if (perc > 0.5) draw_set_color(c_white)
20+
draw_text(floor(window_width / 2), y1 + 65, string(floor(perc * 100)) + "% done")
2521
draw_set_halign(fa_left)
22+
screen_refresh()

scripts/get_update/get_update.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if (async_load[? "id"] == update_download) {
1515
if (file_get_size(update_file) == total_size) {
1616
show_message("Download complete! Click OK to begin installing the update.")
1717
// At this point, the game is paused until the user dismisses the message
18-
ExecuteShell(update_file, false, true)
18+
ExecuteShell("\"" + update_file + "\"", false, true)
1919
game_end()
2020
} else {
2121
if (question("Failed to download update. Do you want to open the Note Block Studio website and update manually?", "Failed")) {

scripts/macros/macros.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#macro gm_runtime_version "2.2.3.344"
22
#macro version_date "2019.12.31"
3-
#macro version "3.6.0"
3+
#macro version "3.7.0"
44
#macro nbs_version 4
55
#macro pat_version 1
66

@@ -14,7 +14,7 @@
1414
#macro pattern_directory data_directory + "Patterns\\"
1515
#macro log_file file_directory + "log.txt"
1616
#macro temp_file file_directory + "tmp.file"
17-
#macro update_file file_directory + "Minecraft Note Block Studio Setup.exe"
17+
#macro update_file file_directory + "Minecraft Note Block Studio Installer.exe"
1818
#macro settings_file file_directory + "settings.ini"
1919
#macro backup_file file_directory + "backup.nbs"
2020

0 commit comments

Comments
 (0)