Refactor...
This commit is contained in:
83
src/dialog.h
83
src/dialog.h
@@ -1,56 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "render.h"
|
||||
#include "window.h"
|
||||
#include <string>
|
||||
|
||||
#define DIALOG_FILE_EXPLORER_COMMAND_SIZE 512
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DIALOG_FILE_EXPLORER_COMMAND "open"
|
||||
#else
|
||||
#define DIALOG_FILE_EXPLORER_COMMAND "xdg-open \"%s\" &"
|
||||
#endif
|
||||
namespace anm2ed::dialog
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
NONE,
|
||||
ANM2_NEW,
|
||||
ANM2_OPEN,
|
||||
ANM2_SAVE,
|
||||
SPRITESHEET_OPEN,
|
||||
SPRITESHEET_REPLACE
|
||||
};
|
||||
|
||||
const SDL_DialogFileFilter DIALOG_FILE_FILTER_ANM2[] = {{"Anm2 file", "anm2;xml"}};
|
||||
class Dialog
|
||||
{
|
||||
public:
|
||||
SDL_Window* window{};
|
||||
std::string path{};
|
||||
Type type{NONE};
|
||||
int selectedFilter{-1};
|
||||
int replaceID{-1};
|
||||
|
||||
const SDL_DialogFileFilter DIALOG_FILE_FILTER_PNG[] = {{"PNG image", "png"}};
|
||||
|
||||
const SDL_DialogFileFilter DIALOG_RENDER_FILE_FILTERS[] = {{"PNG image", "png"}, {"GIF image", "gif"}, {"WebM video", "webm"}, {"MP4 video", "mp4"}};
|
||||
|
||||
const SDL_DialogFileFilter DIALOG_FILE_FILTER_FFMPEG[] = {
|
||||
#ifdef _WIN32
|
||||
{"Executable", "exe"}
|
||||
#else
|
||||
{"Executable", ""}
|
||||
#endif
|
||||
};
|
||||
|
||||
enum DialogType {
|
||||
DIALOG_NONE,
|
||||
DIALOG_ANM2_OPEN,
|
||||
DIALOG_ANM2_SAVE,
|
||||
DIALOG_SPRITESHEET_ADD,
|
||||
DIALOG_SPRITESHEET_REPLACE,
|
||||
DIALOG_RENDER_PATH_SET,
|
||||
DIALOG_FFMPEG_PATH_SET
|
||||
};
|
||||
|
||||
struct Dialog {
|
||||
SDL_Window* window = nullptr;
|
||||
std::string path{};
|
||||
int selectedFilter = ID_NONE;
|
||||
int replaceID = ID_NONE;
|
||||
DialogType type = DIALOG_NONE;
|
||||
bool isSelected{};
|
||||
};
|
||||
|
||||
void dialog_init(Dialog* self, SDL_Window* window);
|
||||
void dialog_anm2_open(Dialog* self);
|
||||
void dialog_spritesheet_add(Dialog* self);
|
||||
void dialog_spritesheet_replace(Dialog* self, int id);
|
||||
void dialog_anm2_save(Dialog* self);
|
||||
void dialog_render_path_set(Dialog* self, RenderType type);
|
||||
void dialog_render_directory_set(Dialog* self);
|
||||
void dialog_ffmpeg_path_set(Dialog* self);
|
||||
void dialog_reset(Dialog* self);
|
||||
void dialog_explorer_open(const std::string& path);
|
||||
Dialog();
|
||||
Dialog(SDL_Window* window);
|
||||
void anm2_new();
|
||||
void anm2_open();
|
||||
void anm2_save();
|
||||
void spritesheet_open();
|
||||
void spritesheet_replace();
|
||||
void file_explorer_open(const std::string& path);
|
||||
void reset();
|
||||
bool is_selected_file(Type type);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user