Skip to content

Commit ec93f11

Browse files
authored
Merge pull request #528 from StopMotionEGames/feature/tabs-cross-platform
Updated file extension checking
2 parents 4f6f1ec + 28d1f84 commit ec93f11

File tree

11 files changed

+80
-46
lines changed

11 files changed

+80
-46
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,19 @@
66
/shaders/__ba_sh_downscale/
77
/scripts/blur_scripts/
88
/scripts/__blur_area_functions/
9+
/__MACOSX/shaders/sh_blur_realtime/
10+
/__MACOSX/shaders/sh_blur_static/
11+
/__MACOSX/shaders/__ba_sh_blur_baked/
12+
/__MACOSX/shaders/__ba_sh_blur_gaussian/
13+
/__MACOSX/shaders/__ba_sh_blur_noise/
14+
/__MACOSX/shaders/__ba_sh_downscale/
15+
/__MACOSX/scripts/blur_scripts/
16+
/__MACOSX/scripts/__blur_area_functions/
17+
/__MACOSX/._shaders
18+
/__MACOSX/shaders/._shader_liquid_glass
19+
__MACOSX/shaders/.___ba_sh_blur_gaussian
20+
__MACOSX/shaders/.___ba_sh_downscale
21+
__MACOSX/shaders/._sh_blur_static
22+
__MACOSX/shaders/._sh_blur_realtime
23+
__MACOSX/shaders/.___ba_sh_blur_noise
924
**/.DS_Store

scripts/control_create/control_create.gml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function control_create() {
1515
// Window
1616
#macro NOT_RUN_FROM_IDE !string_count("GMS2TEMP", get_execution_command()) // THIS CONSTANT IS A REVERSE BOOLEAN (0 is from IDE)
1717
//show_message(get_execution_command() + "IDE: " + string(NOT_RUN_FROM_IDE))
18-
p_num = parameter_count()
19-
isplayer = (check_args("-player"))
20-
filenamearg = check_args()
18+
p_num = parameter_count();
19+
isplayer = (check_args("-player"));
20+
filenamearg = check_args();
2121
for (var i = 0; i < p_num; i += 1) {
2222
if (parameter_string(i) = "-player" || parameter_string(i) == "--protocol-launcher") isplayer = 1
2323
}
@@ -28,8 +28,10 @@ function control_create() {
2828
if (!isplayer) server_socket = network_create_server(network_socket_tcp, 30010, 1)
2929
client_socket = -1
3030
if (server_socket < 0 && !isplayer) {port_taken = 1; client_socket = network_create_socket(network_socket_tcp)}
31-
if (parameter_count() > 0) {
32-
if (filenamearg != "" && (filename_ext(filenamearg) = ".mid" || filename_ext(filenamearg) = ".midi" || filename_ext(filenamearg) = ".schematic" || filename_ext(filenamearg) = ".nbs" || filename_ext(filenamearg) = ".zip")) {
31+
if (p_num > 0) {
32+
if (filenamearg != "" && (string_lower(filename_ext(filenamearg)) == ".mid" || string_lower(filename_ext(filenamearg)) == ".midi" ||
33+
string_lower(filename_ext(filenamearg)) == ".schematic" || string_lower(filename_ext(filenamearg)) == ".nbs" ||
34+
string_lower(filename_ext(filenamearg)) == ".zip")) {
3335
if (port_taken) {
3436
network_connect(client_socket, "127.0.0.1", 30010)
3537
var temp_buffer = buffer_create(0, buffer_grow, 1)
@@ -176,7 +178,6 @@ function control_create() {
176178
fullscreen = 0
177179
autosave = 0
178180
autosavemins = 10
179-
tonextsave = 0
180181
backupmins = 1
181182
tonextbackup = 0
182183
language = 1 * (os_get_language() = "zh" && os_get_region() = "CN")
@@ -573,6 +574,7 @@ function control_create() {
573574
// Settings
574575
if (!check_args("--prefreset")) load_settings()
575576
if (os_type = os_macosx) macos_enable_system_settings_menu()
577+
tonextsave = autosave ? autosavemins : 0; // Defining autosavemins here to avoid the autosave when the first song is loaded after open the game.
576578
menu_macos_init()
577579
switch(language) {
578580
default:
@@ -693,12 +695,15 @@ function control_create() {
693695
// }
694696

695697
if (os_type = os_macosx && macos_url_pending_count() > 0) {
696-
var temp_url = macos_url_take_pending()
698+
var temp_url = macos_url_take_pending();
697699
if (string_count("nbs://", temp_url) = 0) {
698-
var file = string_replace_all(temp_url, "file://", "")
699-
if (file != "" && (filename_ext(file) = ".mid" || filename_ext(file) = ".midi" || filename_ext(file) = ".schematic" || filename_ext(file) = ".nbs" || filename_ext(file) = ".zip")) {
700-
songs[song].filename = file
701-
load_song(file, 0, 1, 1)
700+
var file = string_replace_all(temp_url, "file://", "");
701+
if (file != "" &&
702+
(string_lower(filename_ext(file)) == ".mid" || string_lower(filename_ext(file)) == ".midi" || string_lower(filename_ext(file)) == ".schematic" ||
703+
string_lower(filename_ext(file)) == ".nbs" || string_lower(filename_ext(file)) == ".zip")) {
704+
songs[song].filename = file;
705+
songs[song].file_ext = file_ext;
706+
load_song(file, 0, 1, 1);
702707
}
703708
} else {
704709
isplayer = 1
@@ -781,9 +786,12 @@ function control_create() {
781786
download_song_start(download_url)
782787
}
783788
// Open song
784-
if (os_type != os_macosx && parameter_count() > 0) {
785-
songs[song].filename = filenamearg
786-
if (songs[song].filename != "" && (filename_ext(songs[song].filename) = ".mid" || filename_ext(songs[song].filename) = ".midi" || filename_ext(songs[song].filename) = ".schematic" || filename_ext(songs[song].filename) = ".nbs" || filename_ext(songs[song].filename) = ".zip")) {
789+
if (os_type != os_macosx && p_num > 0) {
790+
songs[song].filename = filenamearg;
791+
if (songs[song].filename != "" &&
792+
(string_lower(filename_ext(songs[song].filename)) == ".mid" || string_lower(filename_ext(songs[song].filename)) == ".midi" ||
793+
string_lower(filename_ext(songs[song].filename)) == ".schematic" || string_lower(filename_ext(songs[song].filename)) == ".nbs" ||
794+
string_lower(filename_ext(songs[song].filename)) == ".zip")) {
787795
if (!port_taken) {
788796
load_song(songs[song].filename, 0, 1, 1)
789797
}

scripts/control_draw/control_draw.gml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,7 @@ function control_draw() {
22502250
}
22512251
if (!hovernote) {
22522252
// Auto-save remaining time
2253-
if (autosave && filename_ext(current_song.filename) = ".nbs") {
2253+
if (autosave && string_lower(filename_ext(current_song.filename)) = ".nbs") {
22542254
draw_theme_color()
22552255
xx += 4
22562256
if (language != 1) draw_text_dynamic(xx, rh - 18, "Next auto-save: " + string(ceil(tonextsave)) + " minute" + condstr(ceil(tonextsave)<>1, "s"))
@@ -2707,7 +2707,7 @@ function control_draw() {
27072707
if (showmsg) draw_msg()
27082708
if (rainbowtoggle) draw_accent_rainbow()
27092709
if (dndfile != "") {
2710-
if (filename_ext(dndfile) = ".nbp") pattern_import(dndfile, 1)
2710+
if (string_lower(filename_ext(dndfile)) = ".nbp") pattern_import(dndfile, 1)
27112711
else if (lastfile != dndfile) {
27122712
load_song(dndfile)
27132713
if (os_type = os_macosx) macos_bookmark_store(dndfile, dndfile, 0)
@@ -2761,8 +2761,9 @@ function control_draw() {
27612761
if (macos_url_pending_count() > 0) {
27622762
var temp_url = macos_url_take_pending()
27632763
if (string_count("nbs://", temp_url) = 0) {
2764-
var file = string_replace_all(temp_url, "file://", "")
2765-
if (file != "" && (filename_ext(file) = ".mid" || filename_ext(file) = ".midi" || filename_ext(file) = ".schematic" || filename_ext(file) = ".nbs" || filename_ext(file) = ".zip")) {
2764+
var file = string_replace_all(temp_url, "file://", "");
2765+
var file_ext = string_lower(filename_ext(file));
2766+
if (file != "" && (file_ext == ".mid" || file_ext == ".midi" || file_ext == ".schematic" || file_ext == ".nbs" || file_ext == ".zip")) {
27662767
load_song(file, 0, isplayer, 0)
27672768
}
27682769
} else {

scripts/control_social/control_social.gml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ function control_social(){
3939
w_isdragging = 0
4040
}
4141
} else if (async_load[? "id"] == "FILE_OPEN"){
42-
var file = async_load[? "path"]
43-
if (file != "" && (filename_ext(file) = ".mid" || filename_ext(file) = ".midi" || filename_ext(file) = ".schematic" || filename_ext(file) = ".nbs" || filename_ext(file) = ".zip")) {
42+
var file = async_load[? "path"];
43+
if (file != "" && (string_lower(filename_ext(file)) == ".mid" || string_lower(filename_ext(file)) == ".midi" ||
44+
string_lower(filename_ext(file)) == ".schematic" || string_lower(filename_ext(file)) == ".nbs" || string_lower(filename_ext(file)) == ".zip")) {
4445
load_song(file)
4546
}
4647
}

scripts/control_step/control_step.gml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,12 @@ function control_step() {
157157

158158
if (!isplayer) {
159159
// Autosave
160-
if (autosave && filename_ext(current_song.filename) = ".nbs") {
160+
if (autosave && string_lower(filename_ext(current_song.filename)) == ".nbs") {
161161
tonextsave -= 1 / room_speed / 60 * (1 / currspeed)
162162
if (tonextsave <= 0 && playing == 0) {
163163
tonextsave = autosavemins
164-
save_song(current_song.filename, true)
164+
log("Auto saving song", current_song.filename)
165+
save_song(current_song.filename, false, true)
165166
}
166167
}
167168

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
function enforce_extension(path, ext){
2-
if (filename_ext(path) != ext) path += ext
2+
if (string_lower(filename_ext(path)) != ext) path += ext
33
return path
44
}

scripts/load_reference_audio/load_reference_audio.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ function load_reference_audio(){
1111
songs[song].reference_volume = 100
1212
songs[song].reference_audio_file = string(get_open_filename_ext("Supported sounds (*.ogg;*.wav)|*.ogg;*.wav", "", songfolder, condstr(language != 1, "Load reference audio", "打开参考音频")))
1313
songs[song].reference_audio = -1
14-
if (filename_ext(songs[song].reference_audio_file) == ".ogg") {
14+
if (string_lower(filename_ext(songs[song].reference_audio_file)) == ".ogg") {
1515
songs[song].reference_audio = audio_create_stream(songs[song].reference_audio_file)
16-
} else if (filename_ext(songs[song].reference_audio_file) == ".wav") {
16+
} else if (string_lower(filename_ext(songs[song].reference_audio_file)) == ".wav") {
1717
songs[song].reference_audio = wav_load_buffer(songs[song].reference_audio_file)
1818
}
1919
if (songs[song].reference_audio < 0) {

scripts/load_song/load_song.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function load_song() {
2929
//backup_clear()
3030
}
3131
reset_add()
32-
file_ext = filename_ext(fn)
32+
file_ext = string_lower(filename_ext(fn));
3333
if (file_ext = ".mid" || file_ext = ".midi") {
3434
open_midi(fn)
3535
return 1

scripts/pattern_import/pattern_import.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ function pattern_import() {
1919
}
2020
if (fn = "" || !file_exists_lib(fn)) return 0
2121

22-
file_ext = filename_ext(fn)
22+
file_ext = string_lower(filename_ext(fn));
2323
if (file_ext != ".nbp") {message(condstr(language != 1, "Error: This file is not a pattern.", "错误:该文件不是分段文件。"), condstr(language != 1, "Error", "错误")) return 0}
24-
if (file_ext = ".nbp") {
24+
if (file_ext == ".nbp") {
2525
buffer = buffer_import(fn)
2626

2727
song_pat_version = buffer_read_byte()

scripts/refresh_resourcepacks/refresh_resourcepacks.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ function refresh_resourcepacks(){
88
pack_to_push = file_find_next()
99
continue
1010
}
11-
if (filename_ext(pack_to_push) = ".zip") pack_ext = 1
12-
else if (filename_ext(pack_to_push) = "") pack_ext = 2
11+
if (string_lower(filename_ext(pack_to_push)) == ".zip") pack_ext = 1
12+
else if (filename_ext(pack_to_push) == "") pack_ext = 2
1313
else if (directory_exists(resource_directory + pack_to_push)) pack_ext = 2
1414
if (pack_ext != 0) array_push(resourcepacks, new_resourcepack(pack_ext, pack_to_push))
1515
log("Pushing resource pack " + pack_to_push)

0 commit comments

Comments
 (0)