forked from cizia64/selector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelector.hpp
More file actions
55 lines (45 loc) · 1.4 KB
/
Selector.hpp
File metadata and controls
55 lines (45 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include "SDL2/SDL_image.h"
#include "SDL2/SDL_ttf.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <algorithm>
#include <filesystem>
#include <iostream>
#include <string>
#include <vector>
using std::string;
using vec_string = std::vector<string>;
#define FILECHOOSER_TITLE "Choose a file"
const int filesPerPage = 10; // Assuming 10 files fit on one page, adjust if needed
class Selector
{
private:
SDL_Window* window;
SDL_Renderer* renderer;
SDL_GameController* controller;
string title;
SDL_Texture* backgroundTexture;
Mix_Chunk* clickSound;
string font_path;
TTF_Font* font;
int chosenFileI{};
vec_string fileList;
vec_string filters; // New member to store filters
bool isCustom;
void renderCounter(SDL_Renderer* renderer, int currentOption,
int totalOptions); // Declaration of renderCounter
Mix_Chunk* loadClickSound(const vec_string& paths); // Sound loading method
void getFileList(string directory, bool recursive);
void drawFileList();
void drawTitle(const string& title);
void drawSelector();
void drawBackground();
public:
Selector(string title, string backgroundImage = "");
~Selector();
void setFolder(string directory, bool recursive = false, vec_string filters = {});
void setCustom(vec_string customChoices);
int run();
string get();
};