refactor pt 1; getting each thing right and then will push to main

This commit is contained in:
2025-09-19 17:57:48 -04:00
parent 9a6810d1bb
commit dbb6d13f34
37 changed files with 7313 additions and 8950 deletions
+45 -66
View File
@@ -1,91 +1,70 @@
#include "dialog.h"
#ifdef _WIN32
#include <windows.h>
#include <windows.h>
#endif
static void _dialog_callback(void* userdata, const char* const* filelist, s32 filter)
{
Dialog* self;
static void _dialog_callback(void* userdata, const char* const* filelist, int filter) {
Dialog* self;
self = (Dialog*)userdata;
self = (Dialog*)userdata;
if (filelist && filelist[0] && strlen(filelist[0]) > 0)
{
self->path = filelist[0];
self->isSelected = true;
self->selectedFilter = filter;
}
else
{
self->isSelected = false;
self->selectedFilter = INDEX_NONE;
}
if (filelist && filelist[0] && strlen(filelist[0]) > 0) {
self->path = filelist[0];
self->isSelected = true;
self->selectedFilter = filter;
} else {
self->isSelected = false;
self->selectedFilter = INDEX_NONE;
}
}
void dialog_init(Dialog* self, SDL_Window* window)
{
self->window = window;
void dialog_init(Dialog* self, SDL_Window* window) { self->window = window; }
void dialog_anm2_open(Dialog* self) {
SDL_ShowOpenFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_ANM2, std::size(DIALOG_FILE_FILTER_ANM2), nullptr, false);
self->type = DIALOG_ANM2_OPEN;
}
void dialog_anm2_open(Dialog* self)
{
SDL_ShowOpenFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_ANM2, std::size(DIALOG_FILE_FILTER_ANM2), nullptr, false);
self->type = DIALOG_ANM2_OPEN;
void dialog_anm2_save(Dialog* self) {
SDL_ShowSaveFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_ANM2, std::size(DIALOG_FILE_FILTER_ANM2), nullptr);
self->type = DIALOG_ANM2_SAVE;
}
void dialog_anm2_save(Dialog* self)
{
SDL_ShowSaveFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_ANM2, std::size(DIALOG_FILE_FILTER_ANM2), nullptr);
self->type = DIALOG_ANM2_SAVE;
void dialog_spritesheet_add(Dialog* self) {
SDL_ShowOpenFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_PNG, std::size(DIALOG_FILE_FILTER_PNG), nullptr, false);
self->type = DIALOG_SPRITESHEET_ADD;
}
void dialog_spritesheet_add(Dialog* self)
{
SDL_ShowOpenFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_PNG, std::size(DIALOG_FILE_FILTER_PNG), nullptr, false);
self->type = DIALOG_SPRITESHEET_ADD;
void dialog_spritesheet_replace(Dialog* self, int id) {
SDL_ShowOpenFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_PNG, std::size(DIALOG_FILE_FILTER_PNG), nullptr, false);
self->replaceID = id;
self->type = DIALOG_SPRITESHEET_REPLACE;
}
void dialog_spritesheet_replace(Dialog* self, s32 id)
{
SDL_ShowOpenFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_PNG, std::size(DIALOG_FILE_FILTER_PNG), nullptr, false);
self->replaceID = id;
self->type = DIALOG_SPRITESHEET_REPLACE;
void dialog_render_path_set(Dialog* self, RenderType type) {
SDL_DialogFileFilter filter = DIALOG_RENDER_FILE_FILTERS[type];
if (type == RENDER_PNG)
SDL_ShowOpenFolderDialog(_dialog_callback, self, self->window, nullptr, false);
else
SDL_ShowSaveFileDialog(_dialog_callback, self, self->window, &filter, 1, nullptr);
self->type = DIALOG_RENDER_PATH_SET;
}
void dialog_render_path_set(Dialog* self, RenderType type)
{
SDL_DialogFileFilter filter = DIALOG_RENDER_FILE_FILTERS[type];
if (type == RENDER_PNG)
SDL_ShowOpenFolderDialog(_dialog_callback, self, self->window, nullptr, false);
else
SDL_ShowSaveFileDialog(_dialog_callback, self, self->window, &filter, 1, nullptr);
self->type = DIALOG_RENDER_PATH_SET;
void dialog_ffmpeg_path_set(Dialog* self) {
SDL_ShowOpenFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_FFMPEG, std::size(DIALOG_FILE_FILTER_FFMPEG), nullptr, false);
self->type = DIALOG_FFMPEG_PATH_SET;
}
void dialog_ffmpeg_path_set(Dialog* self)
{
SDL_ShowOpenFileDialog(_dialog_callback, self, self->window, DIALOG_FILE_FILTER_FFMPEG, std::size(DIALOG_FILE_FILTER_FFMPEG), nullptr, false);
self->type = DIALOG_FFMPEG_PATH_SET;
}
void dialog_explorer_open(const std::string& path)
{
void dialog_explorer_open(const std::string& path) {
#ifdef _WIN32
ShellExecuteA(NULL, DIALOG_FILE_EXPLORER_COMMAND, path.c_str(), NULL, NULL, SW_SHOWNORMAL);
#else
char command[DIALOG_FILE_EXPLORER_COMMAND_SIZE];
snprintf(command, sizeof(command), DIALOG_FILE_EXPLORER_COMMAND, path.c_str());
system(command);
ShellExecuteA(NULL, DIALOG_FILE_EXPLORER_COMMAND, path.c_str(), NULL, NULL, SW_SHOWNORMAL);
#else
char command[DIALOG_FILE_EXPLORER_COMMAND_SIZE];
snprintf(command, sizeof(command), DIALOG_FILE_EXPLORER_COMMAND, path.c_str());
system(command);
#endif
}
void
dialog_reset(Dialog* self)
{
self->replaceID = ID_NONE;
self->type = DIALOG_NONE;
self->path.clear();
self->isSelected = false;
}
void dialog_reset(Dialog* self) { *self = {self->window}; }