Skip to content

Commit e4f1a46

Browse files
committed
change notifications to toasts naming
1 parent 80b665e commit e4f1a46

File tree

12 files changed

+165
-165
lines changed

12 files changed

+165
-165
lines changed

linux/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ BOOTROM_SOURCE = ../roms/Kiwi8_logo_2.ch8
4747
# Source files
4848
CORE_SRCS = ../shared/audio.cc ../shared/chip8.cc ../shared/crc32.cc ../shared/display.cc ../shared/gui.cc \
4949
../shared/input.cc ../shared/main.cc \
50-
../shared/notifications.cc ../shared/open_file_dialog.cc ../shared/profiles.cc
50+
../shared/toast.cc ../shared/open_file_dialog.cc ../shared/profiles.cc
5151
IMGUI_SRCS = ../external/imgui/imgui.cpp ../external/imgui/imgui_draw.cpp ../external/imgui/imgui_impl_sdl.cpp
5252
LINUX_SRCS = src/file_dialog.cc
5353

macos/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ BOOTROM_SOURCE = ../roms/Kiwi8_logo_2.ch8
3232
# Source files
3333
CORE_SRCS = ../shared/audio.cc ../shared/chip8.cc ../shared/crc32.cc ../shared/display.cc ../shared/gui.cc \
3434
../shared/input.cc ../shared/main.cc \
35-
../shared/notifications.cc ../shared/open_file_dialog.cc ../shared/profiles.cc
35+
../shared/toast.cc ../shared/open_file_dialog.cc ../shared/profiles.cc
3636
IMGUI_SRCS = ../external/imgui/imgui.cpp ../external/imgui/imgui_draw.cpp ../external/imgui/imgui_impl_sdl.cpp
3737
MACOS_SRCS = src/file_dialog.mm
3838

shared/audio.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "audio.h"
2-
#include "notifications.h"
2+
#include "toast.h"
33
#include <stdio.h>
44
#include <string.h>
55
#include <math.h>
@@ -65,25 +65,25 @@ int audio_init(void) {
6565
printf("Audio driver: %s\n", drivers[i]);
6666
char msg[256];
6767
snprintf(msg, sizeof(msg), "Audio driver: %s", drivers[i]);
68-
notify_show(NOTIFY_SUCCESS, msg);
68+
toast_show(TOAST_SUCCESS, msg);
6969
driver_found = 1;
7070
break;
7171
}
7272
}
7373
if (!driver_found) {
7474
printf("Could not initialize any audio driver, continuing without sound.\n");
75-
notify_show(NOTIFY_ERROR, "Could not initialize audio driver");
76-
notify_show(NOTIFY_INFO, "Continuing without sound");
75+
toast_show(TOAST_ERROR, "Could not initialize audio driver");
76+
toast_show(TOAST_INFO, "Continuing without sound");
7777
}
7878
audio.device = SDL_OpenAudioDevice(NULL, 0, &audio.audiospec, NULL, SDL_AUDIO_ALLOW_ANY_CHANGE);
7979
if (!audio.device) {
8080
printf("No audio device available, using dummy driver. %s\n", SDL_GetError());
81-
notify_show(NOTIFY_INFO, "Using dummy audio driver");
81+
toast_show(TOAST_INFO, "Using dummy audio driver");
8282
SDL_setenv("SDL_AUDIODRIVER", "dummy", 1);
8383
audio.device = SDL_OpenAudioDevice(NULL, 0, &audio.audiospec, NULL, SDL_AUDIO_ALLOW_ANY_CHANGE);
8484
if (!audio.device) {
8585
printf("Failed to initialize audio (even with dummy driver): %s\n", SDL_GetError());
86-
notify_show(NOTIFY_ERROR, "Failed to initialize audio");
86+
toast_show(TOAST_ERROR, "Failed to initialize audio");
8787
return 1;
8888
}
8989
}

shared/chip8.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "profiles.h"
44
#include "quirks.h"
55
#include "crc32.h"
6-
#include "notifications.h"
6+
#include "toast.h"
77
#include "open_file_dialog.h"
88
#include <SDL2/SDL.h>
99
#include <stdio.h>
@@ -66,8 +66,8 @@ int chip8_init(
6666
memset(chip8.vram[i], 0, HEIGHT * sizeof(unsigned char));
6767
}
6868

69-
/* Initialize notification system first (before audio) */
70-
notify_init();
69+
/* Initialize toast system first (before audio) */
70+
toast_init();
7171

7272
audio_init();
7373

@@ -127,7 +127,7 @@ int chip8_load_rom(const char *rom_filepath) {
127127
FILE *file;
128128
file = fopen(rom_filepath, "rb");
129129
if(file == NULL){
130-
notify_show(NOTIFY_ERROR, "Unable to open ROM file");
130+
toast_show(TOAST_ERROR, "Unable to open ROM file");
131131
return 1;
132132
}
133133

@@ -136,7 +136,7 @@ int chip8_load_rom(const char *rom_filepath) {
136136
chip8.rom_size = ftell(file);
137137
rewind(file);
138138
if (chip8.rom_size > MEM_SIZE - ENTRY_POINT) {
139-
notify_show(NOTIFY_ERROR, "ROM is too large or not formatted properly");
139+
toast_show(TOAST_ERROR, "ROM is too large or not formatted properly");
140140
fclose(file);
141141
return 1;
142142
}
@@ -145,15 +145,15 @@ int chip8_load_rom(const char *rom_filepath) {
145145
free(chip8.rom);
146146
chip8.rom = (unsigned char *)malloc(chip8.rom_size);
147147
if(!chip8.rom) {
148-
notify_show(NOTIFY_ERROR, "Unable to allocate memory for ROM");
148+
toast_show(TOAST_ERROR, "Unable to allocate memory for ROM");
149149
fclose(file);
150150
return 1;
151151
}
152152
memset(chip8.rom, 0 , chip8.rom_size);
153153

154154
/* save the rom for later (soft-resets) */
155155
if (!fread(chip8.rom, sizeof(unsigned char), chip8.rom_size, file)) {
156-
notify_show(NOTIFY_ERROR, "Unable to read ROM file");
156+
toast_show(TOAST_ERROR, "Unable to read ROM file");
157157
fclose(file);
158158
return 1;
159159
}
@@ -171,7 +171,7 @@ int chip8_load_rom(const char *rom_filepath) {
171171
chip8.rom_loaded = 1;
172172
char notif_msg[256];
173173
snprintf(notif_msg, sizeof(notif_msg), "ROM loaded: %s", chip8.rom_filename);
174-
notify_show(NOTIFY_SUCCESS, notif_msg);
174+
toast_show(TOAST_SUCCESS, notif_msg);
175175

176176
/* Compute CRC32 and lookup profile */
177177
uint32_t crc = crc32_compute(chip8.rom, chip8.rom_size);
@@ -180,9 +180,9 @@ int chip8_load_rom(const char *rom_filepath) {
180180
if (profile) {
181181
/* Apply profile quirks */
182182
chip8.quirks = profile->quirks;
183-
notify_show(NOTIFY_SUCCESS, "Profile applied");
183+
toast_show(TOAST_SUCCESS, "Profile applied");
184184
} else {
185-
notify_show(NOTIFY_INFO, "No profile found");
185+
toast_show(TOAST_INFO, "No profile found");
186186
}
187187

188188
chip8_soft_reset();
@@ -265,15 +265,15 @@ void chip8_run(){
265265
if (event & LOAD_ROM) chip8_load_rom(NULL);
266266
if (event & SOFT_RESET) {
267267
chip8_soft_reset();
268-
notify_show(NOTIFY_INFO, "Reset");
268+
toast_show(TOAST_INFO, "Reset");
269269
}
270270
if (event & SAVE_PROFILE) {
271271
profiles_save_current();
272272
gui.save_profile_flag = 0;
273273
}
274274

275-
/* Update notification timers */
276-
notify_update((double)interval / 1000.0);
275+
/* Update toast timers */
276+
toast_update((double)interval / 1000.0);
277277

278278
if (!chip8.paused) {
279279
/* emulate a number of cycles */

shared/gui.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "display.h"
33
#include "gui.h"
44
#include "license.h" // Generated at build time from LICENSE
5-
#include "notifications.h"
5+
#include "toast.h"
66
#include "usage.h"
77
#include <stdio.h>
88

@@ -99,9 +99,9 @@ static void gui_help_windows(void) {
9999
}
100100
}
101101

102-
static void gui_notifications(void) {
102+
static void gui_toasts(void) {
103103
int count;
104-
const struct notification *notifications = notify_get_notifications(&count);
104+
const struct toast *notifications = toast_get_toasts(&count);
105105

106106
if (count == 0) {
107107
return;
@@ -115,14 +115,14 @@ static void gui_notifications(void) {
115115
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
116116

117117
for (int i = 0; i < 8; i++) {
118-
if (!notify_is_active(&notifications[i])) {
118+
if (!toast_is_active(&notifications[i])) {
119119
continue;
120120
}
121121

122122
const char *message;
123123
int type;
124124
double time_remaining;
125-
notify_get_info(&notifications[i], &message, &type, &time_remaining);
125+
toast_get_info(&notifications[i], &message, &type, &time_remaining);
126126

127127
/* Calculate alpha for fade out effect */
128128
float alpha = 1.0f;
@@ -132,9 +132,9 @@ static void gui_notifications(void) {
132132

133133
/* Set colors based on notification type */
134134
ImVec4 bg_color;
135-
if (type == NOTIFY_SUCCESS) {
135+
if (type == TOAST_SUCCESS) {
136136
bg_color = ImVec4(0.1f, 0.4f, 0.1f, 0.85f * alpha);
137-
} else if (type == NOTIFY_ERROR) {
137+
} else if (type == TOAST_ERROR) {
138138
bg_color = ImVec4(0.5f, 0.1f, 0.1f, 0.85f * alpha);
139139
} else {
140140
bg_color = ImVec4(0.25f, 0.25f, 0.25f, 0.85f * alpha);
@@ -211,7 +211,7 @@ static void gui_main_menu(void) {
211211
before = chip8.paused;
212212
ImGui::MenuItem("Pause", "P", &chip8.paused);
213213
if (before != chip8.paused) {
214-
notify_show(NOTIFY_INFO, chip8.paused ? "Paused" : "Unpaused");
214+
toast_show(TOAST_INFO, chip8.paused ? "Paused" : "Unpaused");
215215
}
216216

217217
/* CPU frequency */
@@ -241,13 +241,13 @@ static void gui_main_menu(void) {
241241
before = chip8.muted;
242242
ImGui::MenuItem("Mute Audio", "M", &chip8.muted);
243243
if (before != chip8.muted) {
244-
notify_show(NOTIFY_INFO, chip8.muted ? "Muted" : "Unmuted");
244+
toast_show(TOAST_INFO, chip8.muted ? "Muted" : "Unmuted");
245245
}
246246

247247
before = display.limit_fps_flag;
248248
ImGui::MenuItem("60 FPS Limit", NULL, &display.limit_fps_flag);
249249
if (before != display.limit_fps_flag) {
250-
notify_show(NOTIFY_INFO, display.limit_fps_flag ? "60 FPS limit enabled" : "60 FPS limit disabled");
250+
toast_show(TOAST_INFO, display.limit_fps_flag ? "60 FPS limit enabled" : "60 FPS limit disabled");
251251
}
252252

253253
/*
@@ -338,7 +338,7 @@ void gui_process_events(SDL_Event *event) {
338338
void gui_new_frame(void) {
339339
ImGui_ImplSdl_NewFrame(display.window);
340340
gui_main_menu();
341-
gui_notifications();
341+
gui_toasts();
342342
}
343343

344344
void gui_render(void) {

shared/input.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "chip8.h"
22
#include "input.h"
33
#include "display.h"
4-
#include "notifications.h"
4+
#include "toast.h"
55

66
/* Global input instance */
77
struct input input;
@@ -48,11 +48,11 @@ static int input_process_events(void) {
4848
if (input.state[SDL_SCANCODE_RETURN]) display_toggle_fullscreen();
4949
if (input.state[SDL_SCANCODE_P]) {
5050
chip8.paused = !chip8.paused;
51-
notify_show(NOTIFY_INFO, chip8.paused ? "Paused" : "Unpaused");
51+
toast_show(TOAST_INFO, chip8.paused ? "Paused" : "Unpaused");
5252
}
5353
if (input.state[SDL_SCANCODE_M]) {
5454
chip8.muted = !chip8.muted;
55-
notify_show(NOTIFY_INFO, chip8.muted ? "Muted" : "Unmuted");
55+
toast_show(TOAST_INFO, chip8.muted ? "Muted" : "Unmuted");
5656
}
5757
if (input.state[SDL_SCANCODE_LALT]) gui.show_menu_flag = !gui.show_menu_flag;
5858
if (input.state[SDL_SCANCODE_RALT]) gui.show_fps_flag = !gui.show_fps_flag;

shared/notifications.cc

Lines changed: 0 additions & 84 deletions
This file was deleted.

shared/notifications.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)