Pixel-Composer/scripts/sample_projects/sample_projects.gml

40 lines
1.1 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
#region samples
globalvar SAMPLE_PROJECTS;
SAMPLE_PROJECTS = ds_list_create();
#endregion
2023-12-05 13:49:18 +01:00
function LOAD_FOLDER(list, folder) { #region
var path = $"{DIRECTORY}Welcome files/{folder}";
2022-01-29 14:25:18 +01:00
var file = file_find_first(path + "/*", fa_directory);
2023-02-15 10:43:24 +01:00
2023-03-08 12:14:01 +01:00
while(file != "") {
2023-02-15 10:43:24 +01:00
if(filename_ext(file) == ".pxc") {
2023-03-08 12:14:01 +01:00
var full_path = path + "/" + file;
var f = new FileObject(filename_name_only(file), full_path);
2022-01-13 05:24:03 +01:00
var icon_path = string_replace(full_path, filename_ext(full_path), ".png");
2023-12-08 03:50:09 +01:00
if(file_exists_empty(icon_path)) {
2022-01-13 05:24:03 +01:00
f.spr = sprite_add(icon_path, 0, false, false, 0, 0);
sprite_set_offset(f.spr, sprite_get_width(f.spr) / 2, sprite_get_height(f.spr) / 2);
}
2022-01-29 14:25:18 +01:00
f.tag = folder;
ds_list_add(list, f);
2022-01-13 05:24:03 +01:00
}
file = file_find_next();
}
file_find_close();
2023-12-05 13:49:18 +01:00
} #endregion
2022-01-29 14:25:18 +01:00
2023-12-05 13:49:18 +01:00
function LOAD_SAMPLE() { #region
2022-01-29 14:25:18 +01:00
ds_list_clear(SAMPLE_PROJECTS);
2023-12-05 13:49:18 +01:00
var zzip = "Welcome files.zip";
var targ = $"{DIRECTORY}Welcome files";
2022-01-29 14:25:18 +01:00
2023-12-05 13:49:18 +01:00
directory_verify(targ);
zip_unzip(zzip, targ);
2023-03-08 12:14:01 +01:00
2022-01-29 14:25:18 +01:00
LOAD_FOLDER(SAMPLE_PROJECTS, "Getting started");
LOAD_FOLDER(SAMPLE_PROJECTS, "Sample Projects");
2023-12-05 13:49:18 +01:00
} #endregion