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 {
|
2023-02-14 07:37:13 +01:00
|
|
|
log = 1 << 0,
|
|
|
|
warning = 1 << 1,
|
|
|
|
error = 1 << 2,
|
2022-11-03 11:44:49 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
function notification(type, str, icon = noone, color = c_ui_blue_dkgrey, life = -1) constructor {
|
2023-12-10 02:48:10 +01:00
|
|
|
self.type = type;
|
|
|
|
self.txt = str;
|
|
|
|
self.icon = icon;
|
2022-11-03 11:44:49 +01:00
|
|
|
self.color = color;
|
|
|
|
|
|
|
|
self.life_max = life;
|
2023-12-10 02:48:10 +01:00
|
|
|
self.life = life;
|
2022-11-03 11:44:49 +01:00
|
|
|
|
|
|
|
self.onClick = noone;
|
2023-01-17 08:11:55 +01:00
|
|
|
self.tooltip = "";
|
|
|
|
self.icon_end = noone;
|
2022-11-14 03:16:15 +01:00
|
|
|
|
2023-02-21 07:38:25 +01:00
|
|
|
self.amount = 1;
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
self.time = string_lead_zero(current_hour, 2) + ":" + string_lead_zero(current_minute, 2) + "." + string_lead_zero(current_second, 2);
|
2022-12-22 03:09:55 +01:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
static setOnClick = function(onClick, tooltip = "", icon_end = noone) {
|
2022-12-22 03:09:55 +01:00
|
|
|
self.onClick = method(self, onClick);
|
2023-01-17 08:11:55 +01:00
|
|
|
self.tooltip = tooltip;
|
|
|
|
self.icon_end = icon_end;
|
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
return self;
|
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
}
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
function noti_status(str, icon = noone, flash = false, ref = noone) {
|
2023-10-18 14:58:55 +02:00
|
|
|
if(TEST_ERROR) return {};
|
2023-10-02 08:57:44 +02:00
|
|
|
|
2023-06-20 19:43:19 +02:00
|
|
|
str = string(str);
|
2023-03-22 08:47:19 +01:00
|
|
|
show_debug_message("STATUS: " + str);
|
2023-10-27 13:55:31 +02:00
|
|
|
if(PANEL_MAIN == 0) return;
|
2023-03-22 08:47:19 +01:00
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
if(flash && PANEL_MENU) {
|
|
|
|
PANEL_MENU.noti_flash = 1;
|
|
|
|
PANEL_MENU.noti_flash_color = flash;
|
|
|
|
}
|
|
|
|
|
2023-02-21 07:38:25 +01:00
|
|
|
if(!ds_list_empty(STATUSES) && STATUSES[| ds_list_size(STATUSES) - 1].txt == str) {
|
|
|
|
STATUSES[| ds_list_size(STATUSES) - 1].amount++;
|
2023-02-28 09:43:01 +01:00
|
|
|
return STATUSES[| ds_list_size(STATUSES) - 1];
|
2023-02-21 07:38:25 +01:00
|
|
|
}
|
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
var noti = new notification(NOTI_TYPE.log, str, icon);
|
|
|
|
ds_list_add(STATUSES, noti);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(ref) {
|
|
|
|
var onClick = function() { PANEL_GRAPH.focusNode(self.ref); };
|
|
|
|
noti.ref = ref;
|
|
|
|
noti.onClick = method(noti, onClick);
|
|
|
|
}
|
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
return noti;
|
2022-11-03 11:44:49 +01:00
|
|
|
}
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
function noti_warning(str, icon = noone, ref = noone) {
|
2023-10-18 14:58:55 +02:00
|
|
|
if(TEST_ERROR) return {};
|
2023-10-27 13:55:31 +02:00
|
|
|
if(PANEL_MAIN == 0) return;
|
2023-03-22 08:47:19 +01:00
|
|
|
|
2023-02-21 07:38:25 +01:00
|
|
|
if(PANEL_MENU) {
|
|
|
|
PANEL_MENU.noti_flash = 1;
|
|
|
|
PANEL_MENU.noti_flash_color = COLORS._main_accent;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!ds_list_empty(STATUSES) && STATUSES[| ds_list_size(STATUSES) - 1].txt == str) {
|
2023-12-10 02:48:10 +01:00
|
|
|
var noti = STATUSES[| ds_list_size(STATUSES) - 1];
|
|
|
|
|
|
|
|
noti.amount++;
|
|
|
|
noti.life = noti.life_max;
|
|
|
|
return noti;
|
2023-02-21 07:38:25 +01:00
|
|
|
}
|
|
|
|
|
2023-12-10 02:48:10 +01:00
|
|
|
show_debug_message("WARNING: " + str);
|
2023-10-31 05:30:42 +01:00
|
|
|
var noti = new notification(NOTI_TYPE.warning, str, icon, c_ui_orange, PREFERENCES.notification_time);
|
2022-11-03 11:44:49 +01:00
|
|
|
ds_list_add(STATUSES, noti);
|
|
|
|
ds_list_add(WARNING, noti);
|
2023-02-14 07:37:13 +01:00
|
|
|
|
2023-08-02 19:11:57 +02:00
|
|
|
if(!instance_exists(o_dialog_warning))
|
2023-02-15 10:43:24 +01:00
|
|
|
dialogCall(o_dialog_warning, mouse_mx + ui(16), mouse_my + ui(16)).warning_text = str;
|
2022-11-03 11:44:49 +01:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(ref) {
|
|
|
|
var onClick = function() { PANEL_GRAPH.focusNode(self.ref); };
|
|
|
|
noti.ref = ref;
|
|
|
|
noti.onClick = method(noti, onClick);
|
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
return noti;
|
|
|
|
}
|
|
|
|
|
2023-02-14 07:37:13 +01:00
|
|
|
function noti_error(str, icon = noone, ref = noone) {
|
2023-10-18 14:58:55 +02:00
|
|
|
if(TEST_ERROR) return {};
|
2023-03-22 08:47:19 +01:00
|
|
|
show_debug_message("ERROR: " + str);
|
2023-10-27 13:55:31 +02:00
|
|
|
if(PANEL_MAIN == 0) print(str);
|
2023-03-22 08:47:19 +01:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
var noti = new notification(NOTI_TYPE.error, str, icon, c_ui_red);
|
|
|
|
ds_list_add(STATUSES, noti);
|
|
|
|
ds_list_add(ERRORS, noti);
|
|
|
|
|
2023-02-14 07:37:13 +01:00
|
|
|
if(ref) {
|
|
|
|
var onClick = function() { PANEL_GRAPH.focusNode(self.ref); };
|
|
|
|
noti.ref = ref;
|
|
|
|
noti.onClick = method(noti, onClick);
|
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
return noti;
|
|
|
|
}
|
|
|
|
|
|
|
|
function noti_remove(noti) {
|
|
|
|
ds_list_remove(STATUSES, noti);
|
|
|
|
ds_list_remove(ERRORS, noti);
|
|
|
|
}
|
|
|
|
#endregion
|