Pixel-Composer/scripts/sample_projects/sample_projects.gml

34 lines
1,007 B
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
#region samples
globalvar SAMPLE_PROJECTS;
SAMPLE_PROJECTS = ds_list_create();
#endregion
2022-01-29 14:25:18 +01:00
function LOAD_FOLDER(list, folder) {
2022-09-21 06:09:40 +02:00
var path = directory_get_current_working() + folder;
2022-01-29 14:25:18 +01:00
var file = file_find_first(path + "/*", fa_directory);
2022-01-13 05:24:03 +01:00
while(file != "") {
if(filename_ext(file) == ".json" || filename_ext(file) == ".pxc") {
2022-01-29 14:25:18 +01:00
var full_path = path + "\\" + file;
2022-01-25 10:58:11 +01:00
var f = new FileObject(string_replace(filename_name(file), filename_ext(file), ""), full_path);
2022-01-13 05:24:03 +01:00
var icon_path = string_replace(full_path, filename_ext(full_path), ".png");
if(file_exists(icon_path)) {
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();
2022-01-29 14:25:18 +01:00
}
function LOAD_SAMPLE() {
ds_list_clear(SAMPLE_PROJECTS);
LOAD_FOLDER(SAMPLE_PROJECTS, "Getting started");
LOAD_FOLDER(SAMPLE_PROJECTS, "Sample Projects");
2022-01-13 05:24:03 +01:00
}