Skip to content

Commit

Permalink
Merge branch 'nbs-version-3' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
HielkeMaps committed Aug 8, 2019
2 parents 5beba9f + e6c04da commit 03571c5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions scripts/draw_window_update/draw_window_update.gml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ else draw_text(x1 + 8, y1 + 8, "Changelist")
draw_set_font(fnt_main)
if (window = w_update) draw_text(x1 + 32, y1 + 32, "Thank you for upgrading to version " + version + "!")
fullstr = ""
fullstr += "Changes in v3.5.2 (2019.08.06):\n* NBS format updated to version 3. Now stores song length again\n\n"
fullstr += "Changes in v3.5.1 (2019.07.14):\n* Fixed MIDI Import crash\n\n"
fullstr += "Changes in v3.5.0 (2019.07.11):\n* Added Stereo.\n* Stereo added to Datapack Export.\n* Improved MIDI import, again.\n* Added settings to enhance performance.\n New sprites for note blocks in the dark theme.\n\n"
fullstr += "Changes in v3.4.0 (2019.05.11):\n* Added dark theme.\n* Datapack export: added option to let nearby players hear your music too.\n* Improved MIDI import.\n* NBS format now stores its version for future proofing. This means that\n songs made here can't be opened in older versions of Note Block Studio.\n\n"
Expand Down
15 changes: 10 additions & 5 deletions scripts/load_song/load_song.gml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ if (file_ext = ".nbs") {
byte2 = buffer_read_byte()

if(byte1 = 0 && byte2 = 0){
song_nbt_version = buffer_read_byte()
if song_nbt_version < nbt_version message("Warning: You are opening an older NBS file. Saving this file will make it incompatible with older Note Block Studio versions.","Warning")
if song_nbt_version > nbt_version message("Warning: You are opening an NBS file created in a later version of Note Block Studio. It may crash when opening.","Warning")
song_nbs_version = buffer_read_byte()
if song_nbs_version < nbs_version message("Warning: You are opening an older NBS file. Saving this file will make it incompatible with older Note Block Studio versions.","Warning")
if song_nbs_version > nbs_version message("Warning: You are opening an NBS file created in a later version of Note Block Studio. It may crash when opening.","Warning")
song_first_custom_index = buffer_read_byte()
custom_index_diff = first_custom_index - song_first_custom_index

//From nbt version 3, we save the song length again
if(song_nbs_version > 3){
buffer_read_short()
}
}else{
message("Warning: You are opening an older NBS file. Saving this file will make it incompatible with older Note Block Studio versions.","Warning")
song_nbt_version = 0
song_nbs_version = 0
custom_index_diff = 0
song_first_custom_index = 0
}
Expand Down Expand Up @@ -109,7 +114,7 @@ if (file_ext = ".nbs") {
if (layervol[b] = -1) layervol[b] = 100
layervol[b] = median(0, layervol[b], 100)
if (layervol[b] < 100) realvolume = 1
if song_nbt_version>=2 {
if song_nbs_version>=2 {
layerstereo[b] = buffer_read_byte()
}
else {
Expand Down
6 changes: 3 additions & 3 deletions scripts/macros/macros.gml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#macro gm_runtime_version "2.1.5.246"
#macro version_date "2019.05.11"
#macro version "3.5.1"
#macro nbt_version 2
#macro version_date "2019.08.06"
#macro version "3.5.2"
#macro nbs_version 3

#macro link_download "https://github.com/HielkeMinecraft/OpenNoteBlockStudio/releases/latest"
#macro link_topic "https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-tools/2945101-open-minecraft-note-block-studio"
Expand Down
8 changes: 7 additions & 1 deletion scripts/save_song/save_song.gml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ if (fn = "" || filename_ext(filename) != ".nbs") {
if (selected > 0) selection_place(0)
buffer = buffer_create(8, buffer_grow, 1)

//First 2 bytes 0 to indicate new nbs format
buffer_write_short(0)
buffer_write_byte(nbt_version)

buffer_write_byte(nbs_version)
buffer_write_byte(first_custom_index)

//song length (ticks)
buffer_write_short(enda)

//layer count
buffer_write_short(endb2)

buffer_write_string_int(song_name)
Expand Down

0 comments on commit 03571c5

Please sign in to comment.