2024-02-03 13:11:50 +01:00
|
|
|
function __initSteamUGC() { #region
|
2023-02-15 10:43:24 +01:00
|
|
|
globalvar STEAM_SUBS, STEAM_COLLECTION, STEAM_PROJECTS;
|
2023-02-17 11:31:33 +01:00
|
|
|
STEAM_SUBS = ds_list_create();
|
2023-02-15 10:43:24 +01:00
|
|
|
STEAM_COLLECTION = ds_list_create();
|
|
|
|
STEAM_PROJECTS = ds_list_create();
|
|
|
|
|
2023-02-16 02:51:51 +01:00
|
|
|
if(DEMO) return;
|
2023-02-15 10:43:24 +01:00
|
|
|
if(!STEAM_ENABLED) return;
|
|
|
|
|
2023-11-27 11:40:28 +01:00
|
|
|
directory_verify(DIRECTORY + "steamUGC");
|
2024-02-03 13:11:50 +01:00
|
|
|
try { steamUCGload(); } catch(e) { log_message("SESSION", $"> init SteamUGC | error {e}"); }
|
|
|
|
} #endregion
|
2023-02-17 11:31:33 +01:00
|
|
|
|
2024-02-03 13:11:50 +01:00
|
|
|
function steamUCGload() { #region
|
2023-02-17 11:31:33 +01:00
|
|
|
ds_list_clear(STEAM_SUBS);
|
|
|
|
ds_list_clear(STEAM_COLLECTION);
|
|
|
|
ds_list_clear(STEAM_PROJECTS);
|
|
|
|
|
2023-02-15 10:43:24 +01:00
|
|
|
steam_ugc_get_subscribed_items(STEAM_SUBS);
|
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(STEAM_SUBS); i++ ) {
|
|
|
|
var item_map = ds_map_create();
|
|
|
|
|
|
|
|
if (steam_ugc_get_item_install_info(STEAM_SUBS[| i], item_map)) {
|
|
|
|
var info_map = ds_map_create();
|
|
|
|
var _update = false;
|
|
|
|
|
|
|
|
if (steam_ugc_get_item_update_info(STEAM_SUBS[| i], info_map))
|
|
|
|
_update = info_map[? "needs_update"];
|
|
|
|
|
|
|
|
ds_map_destroy(info_map);
|
|
|
|
|
2023-11-27 11:40:28 +01:00
|
|
|
if(_update) steam_ugc_subscribe_item(STEAM_SUBS[| i]);
|
|
|
|
else __loadSteamUGC(STEAM_SUBS[| i], item_map);
|
|
|
|
} else
|
2023-02-15 10:43:24 +01:00
|
|
|
steam_ugc_subscribe_item(STEAM_SUBS[| i]);
|
|
|
|
|
|
|
|
ds_map_destroy(item_map);
|
|
|
|
}
|
2024-02-03 13:11:50 +01:00
|
|
|
} #endregion
|
2023-02-15 10:43:24 +01:00
|
|
|
|
2024-02-03 13:11:50 +01:00
|
|
|
function __loadSteamUGC(file_id, item_map) { #region
|
2023-02-15 10:43:24 +01:00
|
|
|
var _path = item_map[? "folder"];
|
|
|
|
|
2024-02-03 13:11:50 +01:00
|
|
|
var f = file_find_first(_path + "/*.pxcc", 0); file_find_close();
|
2023-02-15 10:43:24 +01:00
|
|
|
if(f != "") {
|
|
|
|
__loadSteamUGCCollection(file_id, f, _path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-02-03 13:11:50 +01:00
|
|
|
var p = file_find_first(_path + "/*.pxc", 0); file_find_close();
|
2023-02-15 10:43:24 +01:00
|
|
|
if(p != "") {
|
|
|
|
__loadSteamUGCProject(file_id, p, _path);
|
|
|
|
return;
|
|
|
|
}
|
2024-02-03 13:11:50 +01:00
|
|
|
} #endregion
|
2023-02-15 10:43:24 +01:00
|
|
|
|
2024-02-03 13:11:50 +01:00
|
|
|
function __loadSteamUGCCollection(file_id, f, path) { #region
|
|
|
|
if(filename_ext(f) != ".pxcc") return;
|
|
|
|
|
|
|
|
var fullPath = $"{path}/{f}";
|
|
|
|
var name = filename_name_only(f);
|
|
|
|
var file = new FileObject(name, fullPath);
|
|
|
|
var icon_path = string_replace(fullPath, ".pxcc", ".png");
|
2024-01-16 09:56:20 +01:00
|
|
|
|
2023-12-08 03:50:09 +01:00
|
|
|
if(file_exists_empty(icon_path)) {
|
2023-02-15 10:43:24 +01:00
|
|
|
var _temp = sprite_add(icon_path, 0, false, false, 0, 0);
|
2024-02-03 13:11:50 +01:00
|
|
|
var ww = sprite_get_width(_temp);
|
|
|
|
var hh = sprite_get_height(_temp);
|
|
|
|
var amo = safe_mod(ww, hh) == 0? ww / hh : 1;
|
2023-02-15 10:43:24 +01:00
|
|
|
sprite_delete(_temp);
|
2024-02-03 13:11:50 +01:00
|
|
|
|
2023-11-27 11:40:28 +01:00
|
|
|
file.spr_path = [ icon_path, amo, false ];
|
2023-02-15 10:43:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ds_list_add(STEAM_COLLECTION, file);
|
|
|
|
|
2024-01-10 06:36:33 +01:00
|
|
|
var meta = file.getMetadata(true);
|
2023-11-27 14:50:20 +01:00
|
|
|
meta.steam = FILE_STEAM_TYPE.steamOpen;
|
2023-02-15 10:43:24 +01:00
|
|
|
meta.file_id = file_id;
|
2024-02-03 13:11:50 +01:00
|
|
|
} #endregion
|
2023-02-15 10:43:24 +01:00
|
|
|
|
2024-02-03 13:11:50 +01:00
|
|
|
function __loadSteamUGCProject(file_id, f, path) { #region
|
|
|
|
if(filename_ext(f) != ".pxc") return;
|
|
|
|
|
|
|
|
var fullPath = $"{path}/{f}";
|
|
|
|
var name = filename_name_only(f);
|
|
|
|
var file = new FileObject(name, fullPath);
|
2023-03-08 12:14:01 +01:00
|
|
|
var icon_path = path + "/thumbnail.png";
|
2024-02-03 13:11:50 +01:00
|
|
|
|
|
|
|
if(file_exists_empty(icon_path)) {
|
|
|
|
var _temp = sprite_add(icon_path, 0, false, false, 0, 0);
|
|
|
|
var ww = sprite_get_width(_temp);
|
|
|
|
var hh = sprite_get_height(_temp);
|
|
|
|
var amo = safe_mod(ww, hh) == 0? ww / hh : 1;
|
|
|
|
sprite_delete(_temp);
|
|
|
|
|
|
|
|
file.spr_path = [ icon_path, amo, false ];
|
|
|
|
}
|
2023-02-15 10:43:24 +01:00
|
|
|
|
|
|
|
ds_list_add(STEAM_PROJECTS, file);
|
|
|
|
|
2024-02-03 13:11:50 +01:00
|
|
|
var meta = file.getMetadata(true);
|
2023-11-27 14:50:20 +01:00
|
|
|
meta.steam = FILE_STEAM_TYPE.steamOpen;
|
2023-02-15 10:43:24 +01:00
|
|
|
meta.file_id = file_id;
|
2024-02-03 13:11:50 +01:00
|
|
|
} #endregion
|