Batch update libstorm-nvgt modules

This commit is contained in:
Storm Dragon
2026-02-22 19:18:47 -05:00
parent 44f13b1aeb
commit aa1ab8f533
16 changed files with 1197 additions and 1046 deletions

View File

@@ -1,6 +1,6 @@
#include "audio_paths.nvgt"
funcdef void notification_speak_callback(const string &in message, bool interrupt);
funcdef void notification_speak_callback(const string& in message, bool interrupt);
string[] notificationsHistory;
string[] notificationsQueue;
@@ -13,163 +13,176 @@ timer notificationsDelayTimer;
sound notificationsSound;
bool notificationsWaitingForSound = false;
string notificationsSoundPath = "sounds/notify";
notification_speak_callback@ notificationsSpeakCallback = null;
notification_speak_callback @notificationsSpeakCallback = null;
void notifications_set_speak_callback(notification_speak_callback@ callback) {
@notificationsSpeakCallback = @callback;
void notifications_set_speak_callback(notification_speak_callback @callback) {
@notificationsSpeakCallback = @callback;
}
void notifications_set_sound_path(const string soundPath) {
notificationsSoundPath = soundPath;
notificationsSoundPath = soundPath;
}
void notifications_set_delay_ms(int delayMs) {
if (delayMs < 0) {
delayMs = 0;
}
notificationsDelayMs = delayMs;
if (delayMs < 0) {
delayMs = 0;
}
notificationsDelayMs = delayMs;
}
void notifications_set_max_history(int maxCount) {
if (maxCount < 1) {
maxCount = 1;
}
notificationsMaxHistory = maxCount;
if (maxCount < 1) {
maxCount = 1;
}
notificationsMaxHistory = maxCount;
while (notificationsHistory.length() > uint(notificationsMaxHistory)) {
notificationsHistory.remove_at(0);
}
while (notificationsHistory.length() > uint(notificationsMaxHistory)) {
notificationsHistory.remove_at(0);
}
if (notificationsHistory.length() == 0) {
notificationsCurrentIndex = -1;
} else if (notificationsCurrentIndex >= int(notificationsHistory.length())) {
notificationsCurrentIndex = notificationsHistory.length() - 1;
}
if (notificationsHistory.length() == 0) {
notificationsCurrentIndex = -1;
} else if (notificationsCurrentIndex >= int(notificationsHistory.length())) {
notificationsCurrentIndex = notificationsHistory.length() - 1;
}
}
void notifications_clear() {
notificationsHistory.resize(0);
notificationsQueue.resize(0);
notificationsCurrentIndex = -1;
notificationsActive = false;
notificationsWaitingForSound = false;
notificationsSound.close();
notificationsHistory.resize(0);
notificationsQueue.resize(0);
notificationsCurrentIndex = -1;
notificationsActive = false;
notificationsWaitingForSound = false;
notificationsSound.close();
}
void notifications_speak(const string &in message, bool interrupt) {
if (@notificationsSpeakCallback !is null) {
notificationsSpeakCallback(message, interrupt);
return;
}
screen_reader_speak(message, interrupt);
void notifications_speak(const string& in message, bool interrupt) {
if (@notificationsSpeakCallback !is null) {
notificationsSpeakCallback(message, interrupt);
return;
}
screen_reader_speak(message, interrupt);
}
void notifications_enqueue(const string &in message) {
notificationsQueue.insert_last(message);
notificationsHistory.insert_last(message);
void notifications_enqueue(const string& in message) {
notificationsQueue.insert_last(message);
notificationsHistory.insert_last(message);
while (notificationsHistory.length() > uint(notificationsMaxHistory)) {
notificationsHistory.remove_at(0);
}
while (notificationsHistory.length() > uint(notificationsMaxHistory)) {
notificationsHistory.remove_at(0);
}
notificationsCurrentIndex = notificationsHistory.length() - 1;
notificationsCurrentIndex = notificationsHistory.length() - 1;
}
bool notifications_try_play_sound() {
string resolvedPath = resolve_audio_path(notificationsSoundPath);
if (resolvedPath == "") {
return false;
}
notificationsSound.close();
notificationsSound.close();
if (!notificationsSound.load(resolvedPath)) {
return false;
}
// Avoid file_exists()-only checks so packaged Android assets can still load.
if (notificationsSound.load(notificationsSoundPath)) {
notificationsSound.play();
return true;
}
notificationsSound.play();
return true;
string oggPath = notificationsSoundPath + ".ogg";
if (notificationsSound.load(oggPath)) {
notificationsSound.play();
return true;
}
string wavPath = notificationsSoundPath + ".wav";
if (!notificationsSound.load(wavPath)) {
return false;
}
notificationsSound.play();
return true;
}
void notifications_update() {
if (notificationsQueue.length() == 0) {
if (notificationsActive && notificationsDelayTimer.elapsed >= notificationsDelayMs) {
notificationsActive = false;
}
return;
}
if (notificationsQueue.length() == 0) {
if (notificationsActive && notificationsDelayTimer.elapsed >= notificationsDelayMs) {
notificationsActive = false;
}
return;
}
if (notificationsActive && notificationsDelayTimer.elapsed < notificationsDelayMs) {
return;
}
if (notificationsActive && notificationsDelayTimer.elapsed < notificationsDelayMs) {
return;
}
if (notificationsWaitingForSound) {
if (notificationsSound.playing) {
return;
}
if (notificationsWaitingForSound) {
if (notificationsSound.playing) {
return;
}
notifications_speak(notificationsQueue[0], true);
notificationsQueue.remove_at(0);
notificationsWaitingForSound = false;
notificationsActive = true;
notificationsDelayTimer.restart();
return;
}
notifications_speak(notificationsQueue[0], true);
notificationsQueue.remove_at(0);
notificationsWaitingForSound = false;
notificationsActive = true;
notificationsDelayTimer.restart();
return;
}
if (notifications_try_play_sound()) {
notificationsWaitingForSound = true;
return;
}
if (notifications_try_play_sound()) {
notificationsWaitingForSound = true;
return;
}
notifications_speak(notificationsQueue[0], true);
notificationsQueue.remove_at(0);
notificationsActive = true;
notificationsDelayTimer.restart();
notifications_speak(notificationsQueue[0], true);
notificationsQueue.remove_at(0);
notificationsActive = true;
notificationsDelayTimer.restart();
}
void notifications_check_keys() {
if (key_pressed(KEY_LEFTBRACKET)) {
if (notificationsHistory.length() == 0) {
notifications_speak("No notifications.", true);
return;
}
if (key_pressed(KEY_LEFTBRACKET)) {
if (notificationsHistory.length() == 0) {
notifications_speak("No notifications.", true);
return;
}
notificationsCurrentIndex--;
if (notificationsCurrentIndex < 0) {
notificationsCurrentIndex = 0;
notifications_speak("Oldest notification. " + notificationsHistory[notificationsCurrentIndex], true);
return;
}
notificationsCurrentIndex--;
if (notificationsCurrentIndex < 0) {
notificationsCurrentIndex = 0;
notifications_speak("Oldest notification. " + notificationsHistory[notificationsCurrentIndex], true);
return;
}
int position = notificationsCurrentIndex + 1;
notifications_speak(notificationsHistory[notificationsCurrentIndex] + " " + position + " of " + notificationsHistory.length(), true);
return;
}
int position = notificationsCurrentIndex + 1;
notifications_speak(notificationsHistory[notificationsCurrentIndex] + " " + position + " of " +
notificationsHistory.length(),
true);
return;
}
if (key_pressed(KEY_RIGHTBRACKET)) {
if (notificationsHistory.length() == 0) {
notifications_speak("No notifications.", true);
return;
}
if (key_pressed(KEY_RIGHTBRACKET)) {
if (notificationsHistory.length() == 0) {
notifications_speak("No notifications.", true);
return;
}
notificationsCurrentIndex++;
if (notificationsCurrentIndex >= int(notificationsHistory.length())) {
notificationsCurrentIndex = notificationsHistory.length() - 1;
notifications_speak("Newest notification. " + notificationsHistory[notificationsCurrentIndex], true);
return;
}
notificationsCurrentIndex++;
if (notificationsCurrentIndex >= int(notificationsHistory.length())) {
notificationsCurrentIndex = notificationsHistory.length() - 1;
notifications_speak("Newest notification. " + notificationsHistory[notificationsCurrentIndex], true);
return;
}
int position = notificationsCurrentIndex + 1;
notifications_speak(notificationsHistory[notificationsCurrentIndex] + " " + position + " of " + notificationsHistory.length(), true);
return;
}
int position = notificationsCurrentIndex + 1;
notifications_speak(notificationsHistory[notificationsCurrentIndex] + " " + position + " of " +
notificationsHistory.length(),
true);
return;
}
if (key_pressed(KEY_BACKSLASH)) {
if (notificationsHistory.length() == 0) {
notifications_speak("No notifications.", true);
return;
}
if (key_pressed(KEY_BACKSLASH)) {
if (notificationsHistory.length() == 0) {
notifications_speak("No notifications.", true);
return;
}
notificationsCurrentIndex = notificationsHistory.length() - 1;
notifications_speak(notificationsHistory[notificationsCurrentIndex], true);
}
notificationsCurrentIndex = notificationsHistory.length() - 1;
notifications_speak(notificationsHistory[notificationsCurrentIndex], true);
}
}