Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion linux/src/file_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <gtk/gtk.h>
#include <cstring>

std::vector<std::string> openFileDialog(const std::string &title, const std::string &defaultDir, const std::vector<std::string> &filterExtensions) {
std::vector<std::string> open_file_dialog(const std::string &title, const std::string &defaultDir, const std::vector<std::string> &filterExtensions) {
std::vector<std::string> result;

// Initialize GTK if not already initialized
Expand Down
2 changes: 1 addition & 1 deletion linux/src/file_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#include <vector>
#include <string>

std::vector<std::string> openFileDialog(const std::string &title, const std::string &defaultDir, const std::vector<std::string> &filterExtensions);
std::vector<std::string> open_file_dialog(const std::string &title, const std::string &defaultDir, const std::vector<std::string> &filterExtensions);

#endif
2 changes: 1 addition & 1 deletion macos/src/file_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#include <string>
#include <vector>

std::vector<std::string>openFileDialog(char const * const aTitle, char const * const aDefaultPathAndFile, const std::vector<std::string> & filters);
std::vector<std::string>open_file_dialog(char const * const aTitle, char const * const aDefaultPathAndFile, const std::vector<std::string> & filters);

#endif
2 changes: 1 addition & 1 deletion macos/src/file_dialog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string>
#include <vector>

std::vector<std::string>openFileDialog(
std::vector<std::string>open_file_dialog(
char const * const aTitle ,
char const * const aDefaultPathAndFile ,
const std::vector<std::string> & filters) {
Expand Down
2 changes: 1 addition & 1 deletion shared/audio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int audio_init(void) {
printf("Audio driver: %s\n", drivers[i]);
char msg[256];
snprintf(msg, sizeof(msg), "Audio driver: %s", drivers[i]);
toast_show(TOAST_SUCCESS, msg);
toast_show(TOAST_INFO, msg);
driver_found = 1;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion shared/chip8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int chip8_load_rom(const char *rom_filepath) {
} else {
/* load ROM from GUI */
char new_rom_name[PATH_MAX];
openFileDialog(new_rom_name) ?
open_file_dialog(new_rom_name) ?
printf("User aborted the open file dialog.\n") :
chip8_load_rom(new_rom_name);

Expand Down
2 changes: 1 addition & 1 deletion shared/gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static void gui_toasts(void) {
} else if (type == TOAST_ERROR) {
bg_color = ImVec4(0.5f, 0.1f, 0.1f, 0.85f * alpha);
} else {
bg_color = ImVec4(0.5f, 0.4f, 0.1f, 0.85f * alpha);
bg_color = ImVec4(0.2f, 0.2f, 0.2f, 0.85f * alpha);
}

ImGui::PushStyleColor(ImGuiCol_WindowBg, bg_color);
Expand Down
6 changes: 3 additions & 3 deletions shared/open_file_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
#endif

/* Returns 0 on success, 1 on error (or user hit cancel) */
int openFileDialog(char *rom_name) {
int open_file_dialog(char *rom_name) {

#if defined(__APPLE__) || defined(__linux__)
// Common flow for Apple and Linux: both return a vector<string>
std::vector<std::string> fileTypes = {"ch8", "CH8", "chip-8", "CHIP-8", "Chip-8"};
const char* defaultDir = ""; // unify behavior: let OS choose last-used/home
std::vector<std::string> files = openFileDialog("Chip8", defaultDir, fileTypes);
std::vector<std::string> files = open_file_dialog("Chip8", defaultDir, fileTypes);
if (files.empty()) return 1;
snprintf(rom_name, 256, "%s", files[0].c_str());
return 0;

#elif defined(_WIN32)
// Windows API variant writes directly into buffer and returns int
return openFileDialog(rom_name, "Chip8\0*.ch8\0All\0*.*\0");
return open_file_dialog(rom_name, "Chip8\0*.ch8\0All\0*.*\0");

#else
return 1;
Expand Down
2 changes: 1 addition & 1 deletion shared/open_file_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
#include <limits.h> /* PATH_MAX */
#endif

int openFileDialog(char *rom_name);
int open_file_dialog(char *rom_name);

#endif
6 changes: 3 additions & 3 deletions shared/profiles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ static int resolve_profiles_path(void) {
fclose(file);
char msg[256];
snprintf(msg, sizeof(msg), "ROM profiles: %s", loaded_profiles_path);
toast_show(TOAST_SUCCESS, msg);
toast_show(TOAST_INFO, msg);
return 1;
}
/* Doesn't exist yet — create it */
if (create_profiles_file(loaded_profiles_path)) {
char msg[256];
snprintf(msg, sizeof(msg), "ROM profiles created: %s", loaded_profiles_path);
toast_show(TOAST_INFO, msg);
toast_show(TOAST_SUCCESS, msg);
} else {
char msg[256];
snprintf(msg, sizeof(msg), "Failed to create: %s", loaded_profiles_path);
Expand Down Expand Up @@ -153,7 +153,7 @@ static int resolve_profiles_path(void) {
set_path(loaded_profiles_path, sizeof(loaded_profiles_path), search_paths[i]);
char msg[256];
snprintf(msg, sizeof(msg), "ROM profiles: %s", search_paths[i]);
toast_show(TOAST_SUCCESS, msg);
toast_show(TOAST_INFO, msg);
return 1;
}
}
Expand Down
6 changes: 3 additions & 3 deletions windows/src/file_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>

int openFileDialog(char *rom_name, char *filters) {
int open_file_dialog(char *rom_name, char *filters) {
/* open file dialogue */
char cwd[MAX_PATH];
GetCurrentDirectory(MAX_PATH, cwd);
Expand Down Expand Up @@ -34,7 +34,7 @@ int openFileDialog(char *rom_name, char *filters) {
/* user hit cancel */
return 1;
}

strcpy(rom_name, szFile);
return 0;
}
}
2 changes: 1 addition & 1 deletion windows/src/file_dialog.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef WIN32_FILE_DIALOG_H
#define WIN32_FILE_DIALOG_H

int openFileDialog(char *rom_name, char *filters);
int open_file_dialog(char *rom_name, char *filters);

#endif
Loading