|
1 | 1 | // load_settings() |
2 | | -var a, settings_ver_loaded; |
| 2 | +var a; |
3 | 3 | log("Load settings") |
4 | | -if (!file_exists_lib(data_directory + "settings.onbs")) return 0 |
5 | | -buffer = buffer_import(data_directory + "settings.onbs") |
6 | | - |
7 | | -byte1 = buffer_read_byte() |
8 | | -byte2 = buffer_read_byte() |
9 | | - |
10 | | -if(byte1 = 69 && byte2 = 69) { |
11 | | - settings_ver_loaded = buffer_read_byte() |
12 | | - if settings_ver_loaded > settings_version { |
13 | | - message("The settings file being read was made in a later version of Note Block Studio!\nFailed to load program.","Error") |
14 | | - return -1 |
15 | | - } |
16 | | -} else { |
17 | | - settings_ver_loaded = 0 |
18 | | - buffer_skip(-2) |
19 | | -} |
| 4 | +if (!file_exists(data_directory + "settings.ini")) return 0 |
| 5 | +ini_open(data_directory + "settings.ini") |
20 | 6 |
|
21 | 7 | // Recent songs |
22 | 8 | for (a = 0; a < 11; a += 1) { |
23 | | - recent_song[a] = buffer_read_string() |
24 | | - recent_song_time[a] = buffer_read_double() |
| 9 | + recent_song[a] = ini_read_string("recent", "recent_song_" + string(a) + "_path", recent_song[a]) |
| 10 | + recent_song_time[a] = ini_read_string("recent", "recent_song_" + string(a) + "_time", recent_song_time[a]) |
25 | 11 | } |
26 | 12 | // Preferences |
27 | | -check_update = buffer_read_byte() |
28 | | -show_welcome = buffer_read_byte() |
29 | | -theme = buffer_read_byte() |
30 | | -songfolder = buffer_read_string() |
31 | | -show_numbers = buffer_read_byte() |
32 | | -show_octaves = buffer_read_byte() |
33 | | -draw_type = buffer_read_byte() |
34 | | -show_keynames = buffer_read_byte() |
35 | | -show_keyboard = buffer_read_byte() |
36 | | -show_notechart = buffer_read_byte() |
37 | | -keysmax = buffer_read_byte() |
38 | | -mousewheel = buffer_read_byte() |
39 | | -changepitch = buffer_read_byte() |
40 | | -select_lastpressed = buffer_read_byte() |
41 | | -marker_follow = buffer_read_byte() |
42 | | -marker_pagebypage = buffer_read_byte() |
43 | | -marker_start = buffer_read_byte() |
44 | | -marker_end = buffer_read_byte() |
45 | | -buffer_read_byte() // record |
46 | | -buffer_read_byte() // record round |
47 | | -realvolume = buffer_read_byte() |
| 13 | +vers = ini_read_string("preferences", "last_version", version) |
| 14 | +check_update = ini_read_real( "preferences", "check_update", check_update) |
| 15 | +show_welcome = ini_read_real( "preferences", "show_welcome", show_welcome) |
| 16 | +theme = ini_read_real( "preferences", "theme", theme) |
| 17 | +refreshrate = ini_read_real( "preferences", "refresh_rate", refreshrate) |
| 18 | +songfolder = ini_read_string("preferences", "song_folder", songfolder) |
| 19 | +patternfolder = ini_read_string("preferences", "pattern_folder", patternfolder) |
| 20 | +show_numbers = ini_read_real( "preferences", "show_numbers", show_numbers) |
| 21 | +show_octaves = ini_read_real( "preferences", "show_octaves", show_octaves) |
| 22 | +fade = ini_read_real( "preferences", "use_fading", fade) |
| 23 | +draw_type = ini_read_real( "preferences", "draw_type", draw_type) |
| 24 | +show_piano = ini_read_real( "preferences", "show_piano", show_piano) |
| 25 | +keysmax = ini_read_real( "preferences", "keys_to_show", keysmax) |
| 26 | +show_keynames = ini_read_real( "preferences", "show_keynames", show_keynames) |
| 27 | +show_keyboard = ini_read_real( "preferences", "show_keyboard", show_keyboard) |
| 28 | +show_notechart = ini_read_real( "preferences", "show_numbers", show_numbers) |
| 29 | +mousewheel = ini_read_real( "preferences", "mousewheel", mousewheel) |
| 30 | +changepitch = ini_read_real( "preferences", "change_pitch", changepitch) |
| 31 | +select_lastpressed = ini_read_real( "preferences", "select_lastpressed", select_lastpressed) |
| 32 | +marker_follow = ini_read_real( "preferences", "marker_follow", marker_follow) |
| 33 | +marker_pagebypage = ini_read_real( "preferences", "marker_pagebypage", marker_pagebypage) |
| 34 | +marker_start = ini_read_real( "preferences", "marker_start", marker_start) |
| 35 | +marker_end = ini_read_real( "preferences", "marker_end", marker_end) |
| 36 | +realvolume = ini_read_real( "preferences", "show_layer_volumes", realvolume) |
| 37 | +realstereo = ini_read_real( "preferences", "use_stereo", realstereo) |
| 38 | +looptobarend = ini_read_real( "preferences", "loop_to_bar_end", looptobarend) |
48 | 39 |
|
49 | 40 | // Midi import settings |
50 | | -w_midi_remember = buffer_read_byte() |
51 | | -w_midi_removesilent = buffer_read_byte() |
52 | | -w_midi_name = buffer_read_byte() |
53 | | -w_midi_name_patch = buffer_read_byte() |
54 | | -w_midi_maxheight = buffer_read_byte() |
55 | | -w_midi_tempo = buffer_read_byte() |
56 | | -w_midi_octave = buffer_read_byte() |
| 41 | +w_midi_remember = ini_read_real( "midi_import", "remember", w_midi_remember) |
| 42 | +w_midi_removesilent = ini_read_real( "midi_import", "remove_silent", w_midi_removesilent) |
| 43 | +w_midi_name = ini_read_real( "midi_import", "name", w_midi_name) |
| 44 | +w_midi_name_patch = ini_read_real( "midi_import", "name_patch", w_midi_name_patch) |
| 45 | +w_midi_maxheight = ini_read_real( "midi_import", "maxheight", w_midi_maxheight) |
| 46 | +w_midi_vel = ini_read_real( "midi_import", "enable_velocity", w_midi_vel) |
| 47 | +w_midi_tempo = ini_read_real( "midi_import", "tempo", w_midi_tempo) |
| 48 | +w_midi_octave = ini_read_real( "midi_import", "octave", w_midi_octave) |
57 | 49 | // instruments |
58 | 50 | for (a = 0; a < 128; a += 1) { |
59 | | - midi_ins[a, 1] = buffer_read_byte() // Instrument |
60 | | - if (midi_ins[a, 1] = 255) // -1 |
61 | | - midi_ins[a, 1] = -1 |
62 | | - midi_ins[a, 2] = buffer_read_byte() // Octave |
63 | | - if (midi_ins[a, 2] = 255) // -1 |
64 | | - midi_ins[a, 2] = -1 |
| 51 | + midi_ins[a, 1] = ini_read_real( "midi_import", "ins_" + string(a), midi_ins[a, 1]) // Instrument |
| 52 | + if (midi_ins[a, 1] = 255) // -1 |
| 53 | + midi_ins[a, 1] = -1 |
| 54 | + midi_ins[a, 2] = ini_read_real( "midi_import", "ins_" + string(a) + "_oct", midi_ins[a, 2]) // Octave |
| 55 | + if (midi_ins[a, 2] = 255) // -1 |
| 56 | + midi_ins[a, 2] = -1 |
65 | 57 | } |
66 | 58 | // drums |
67 | 59 | for (a = 24; a < 88; a += 1) { |
68 | | - midi_drum[a, 1] = buffer_read_byte() // Instrument |
69 | | - if (midi_drum[a, 1] = 255) // -1 |
70 | | - midi_drum[a, 1] = -1 |
71 | | - midi_drum[a, 2] = buffer_read_byte() // Key |
72 | | - if (midi_drum[a, 2] = 255) // -1 |
73 | | - midi_drum[a, 2] = -1 |
74 | | -} |
75 | | -// Midi export settings |
76 | | -buffer_read_byte() // w_midiexp_remember |
77 | | -buffer_read_byte() // w_midiexp_layers |
78 | | -buffer_read_byte() // w_midiexp_open |
79 | | -for (a = 0; a < 14; a += 1) { |
80 | | - buffer_read_byte() // w_midiexp_patch[a] |
81 | | - buffer_read_byte() // w_midiexp_kind[a] |
82 | | - buffer_read_byte() // w_midiexp_oct[a] |
| 60 | + midi_drum[a, 1] = ini_read_real( "midi_import", "drum_" + string(a), midi_drum[a, 1]) // Instrument |
| 61 | + if (midi_drum[a, 1] = 255) // -1 |
| 62 | + midi_drum[a, 1] = -1 |
| 63 | + midi_drum[a, 2] = ini_read_real( "midi_import", "drum_" + string(a) + "_key", midi_drum[a, 2]) // Key |
| 64 | + if (midi_drum[a, 2] = 255) // -1 |
| 65 | + midi_drum[a, 2] = -1 |
83 | 66 | } |
84 | | -buffer_read_byte() // w_midiexp_ignored |
| 67 | + |
85 | 68 | // Schematic export settings |
86 | | -sch_exp_walkway_block = buffer_read_byte() |
87 | | -sch_exp_walkway_data = buffer_read_byte() |
88 | | -sch_exp_circuit_block = buffer_read_byte() |
89 | | -sch_exp_circuit_data = buffer_read_byte() |
90 | | -sch_exp_ground_block = buffer_read_byte() |
91 | | -sch_exp_ground_data = buffer_read_byte() |
92 | | -sch_exp_layout = buffer_read_byte() |
93 | | -sch_exp_notesperrow = buffer_read_byte() |
94 | | -sch_exp_includelocked = buffer_read_byte() |
95 | | -sch_exp_compress = buffer_read_byte() |
96 | | -sch_exp_loop = buffer_read_byte() |
97 | | -sch_exp_glass = buffer_read_byte() |
98 | | -sch_exp_minecart = buffer_read_byte() |
99 | | -sch_exp_chest = buffer_read_byte() |
100 | | -if settings_ver_loaded >= 1 { |
101 | | - for (a = 0; a < 34; a += 1) { |
102 | | - sch_exp_ins_block[a] = buffer_read_byte() |
103 | | - sch_exp_ins_data[a] = buffer_read_byte() |
104 | | - } |
105 | | -} else { |
106 | | - for (a = 0; a < 20; a += 1) { |
107 | | - sch_exp_ins_block[a] = buffer_read_byte() |
108 | | - sch_exp_ins_data[a] = buffer_read_byte() |
109 | | - } |
| 69 | +sch_exp_minecraft_old = ini_read_real("schematic_export", "use_old_format", sch_exp_minecraft_old) |
| 70 | +sch_exp_walkway_block = ini_read_real("schematic_export", "walkway_block", sch_exp_walkway_block) |
| 71 | +sch_exp_walkway_data = ini_read_real("schematic_export", "walkway_data", sch_exp_walkway_data) |
| 72 | +sch_exp_circuit_block = ini_read_real("schematic_export", "circuit_block", sch_exp_circuit_block) |
| 73 | +sch_exp_circuit_data = ini_read_real("schematic_export", "circuit_data", sch_exp_circuit_data) |
| 74 | +sch_exp_ground_block = ini_read_real("schematic_export", "ground_block", sch_exp_ground_block) |
| 75 | +sch_exp_ground_data = ini_read_real("schematic_export", "ground_data", sch_exp_ground_data) |
| 76 | +sch_exp_layout = ini_read_real("schematic_export", "layout", sch_exp_layout) |
| 77 | +sch_exp_notesperrow = ini_read_real("schematic_export", "notes_per_row", sch_exp_notesperrow) |
| 78 | +sch_exp_includelocked = ini_read_real("schematic_export", "include_locked", sch_exp_includelocked) |
| 79 | +sch_exp_compress = ini_read_real("schematic_export", "compress", sch_exp_compress) |
| 80 | +sch_exp_loop = ini_read_real("schematic_export", "loop", sch_exp_loop) |
| 81 | +sch_exp_glass = ini_read_real("schematic_export", "glass", sch_exp_glass) |
| 82 | +sch_exp_minecart = ini_read_real("schematic_export", "minecart", sch_exp_minecart) |
| 83 | +sch_exp_chest = ini_read_real("schematic_export", "chest", sch_exp_chest) |
| 84 | +for (a = 0; a < 34; a += 1) { |
| 85 | + sch_exp_ins_block[a] = ini_read_real("schematic_export", "ins_block_" + string(a), sch_exp_ins_block[a]) |
| 86 | + sch_exp_ins_data[a] = ini_read_real("schematic_export", "ins_data_" + string(a), sch_exp_ins_data[a]) |
110 | 87 | } |
111 | 88 |
|
| 89 | +// Branch export settings |
| 90 | +sch_exp_stereo = ini_read_real("branch_export", "stereo", sch_exp_stereo) |
| 91 | +sch_exp_velocity = ini_read_real("branch_export", "velocity", sch_exp_velocity) |
| 92 | +sch_exp_circuitry = ini_read_real("branch_export", "circuitry", sch_exp_circuitry) |
| 93 | +sch_exp_vertical = ini_read_real("branch_export", "vertical", sch_exp_vertical) |
| 94 | +sch_exp_polyphony = ini_read_real("branch_export", "polyphony", sch_exp_polyphony) |
| 95 | +sch_exp_layer1 = ini_read_real("branch_export", "layer1", sch_exp_layer1) |
| 96 | +sch_exp_layer2 = ini_read_real("branch_export", "layer2", sch_exp_layer2) |
| 97 | +sch_exp_layer3 = ini_read_real("branch_export", "layer3", sch_exp_layer3) |
| 98 | +sch_exp_range_start = ini_read_real("branch_export", "range_start", sch_exp_range_start) |
| 99 | +sch_exp_range_end = ini_read_real("branch_export", "range_end", sch_exp_range_end) |
| 100 | + |
112 | 101 | // Keyboard keys |
113 | | -for (a = 0; a < 88; a += 1) piano_key[a] = buffer_read_short() |
| 102 | +for (a = 0; a < 88; a += 1) piano_key[a] = ini_read_real("piano_keys", "piano_key_" + string(a), piano_key[a]) |
114 | 103 | // Warnings |
115 | | -warning_octaves = buffer_read_byte() |
116 | | -warning_instrument = buffer_read_byte() |
117 | | -warning_schematic = buffer_read_byte() |
118 | | -vers = buffer_read_string_int() |
119 | | -sch_exp_minecraft_old = buffer_read_byte() |
120 | | -soundsystem = max(0, buffer_read_byte()) |
121 | | -refreshrate = buffer_read_byte() |
122 | | -fade = buffer_read_byte() |
123 | | -realstereo = buffer_read_byte() |
124 | | -show_piano = buffer_read_byte() |
125 | | -rhval = buffer_read_byte() |
126 | | -if settings_ver_loaded >= 1 { |
127 | | - w_midi_vel = buffer_read_byte() |
128 | | - patternfolder = buffer_read_string() |
129 | | - looptobarend = buffer_read_byte() |
130 | | - sch_exp_stereo = buffer_read_byte() |
131 | | - sch_exp_velocity = buffer_read_byte() |
132 | | - sch_exp_circuitry = buffer_read_byte() |
133 | | - sch_exp_vertical = buffer_read_byte() |
134 | | - sch_exp_polyphony = buffer_read_byte() |
135 | | - sch_exp_layer1 = buffer_read_byte() |
136 | | - sch_exp_layer2 = buffer_read_byte() |
137 | | - sch_exp_layer3 = buffer_read_byte() |
138 | | - sch_exp_range_start = buffer_read_short() |
139 | | - sch_exp_range_end = buffer_read_short() |
140 | | -} |
141 | | -buffer_delete(buffer) |
| 104 | +warning_octaves = ini_read_real("warnings", "octaves", warning_octaves) |
| 105 | +warning_instrument = ini_read_real("warnings", "instrument", warning_instrument) |
| 106 | +warning_schematic = ini_read_real("warnings", "schematics", warning_schematic) |
| 107 | + |
| 108 | +ini_close() |
142 | 109 | return 1 |
0 commit comments