Pixel-Composer/scripts/notification_system/notification_system.gml

55 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-11-03 11:44:49 +01:00
#region notification
globalvar STATUSES, WARNING, ERRORS;
STATUSES = ds_list_create();
WARNING = ds_list_create();
ERRORS = ds_list_create();
#endregion
#region classes
enum NOTI_TYPE {
log = 1 << 0,
warning = 1 << 1,
error = 1 << 2,
}
2022-11-14 03:16:15 +01:00
function notification(type, str, icon = s_noti_icon_log, color = c_ui_blue_dkgrey, life = -1) constructor {
2022-11-03 11:44:49 +01:00
self.type = type;
self.txt = str;
self.icon = icon;
self.color = color;
self.life_max = life;
self.life = life;
self.onClick = noone;
2022-11-14 03:16:15 +01:00
self.time = string_lead_zero(current_hour, 2) + ":" + string_lead_zero(current_minute, 2);
2022-11-03 11:44:49 +01:00
}
2022-11-14 03:16:15 +01:00
function noti_status(str, icon = s_noti_icon_log) {
2022-11-03 11:44:49 +01:00
ds_list_add(STATUSES, new notification(NOTI_TYPE.log, str, icon));
}
function noti_warning(str, icon = s_noti_icon_warning) {
var noti = new notification(NOTI_TYPE.warning, str, icon, c_ui_orange, 180);
ds_list_add(STATUSES, noti);
ds_list_add(WARNING, noti);
PANEL_MENU.noti_flash = 1;
return noti;
}
function noti_error(str, icon = s_noti_icon_error) {
var noti = new notification(NOTI_TYPE.error, str, icon, c_ui_red);
ds_list_add(STATUSES, noti);
ds_list_add(ERRORS, noti);
return noti;
}
function noti_remove(noti) {
ds_list_remove(STATUSES, noti);
ds_list_remove(ERRORS, noti);
}
#endregion