-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
75 lines (60 loc) · 2.59 KB
/
main.cpp
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*RenDev#2616 File Selector Tool
Copyright (C) 2021 RenDev
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
Permission is also granted to not credit the author in any way as long as you do not take credit
for this piece of software.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Contact me at [email protected] if you need to contact me about this licence*/
#include "FileSelect.h"
#include <string>
#include <iostream>
static const char* NAME_OF_CREATOR = "Software made by RenDev#2616, [email protected]";
static const char* DATE_OF_BUILD = "BUILD DATE: "DATE;
static const char* VERSION_NUMBER = "VERSION NUMBER: "VER;
static const char* PROGRAM_NAME = PROG_NAME;
#include <dirent.h>
static char DLL_PATH[PATH_MAX];
static char* dllEntry(char* title){
FileSelect* win = new FileSelect((std::string)title, {SCREEN_W, SCREEN_H}, true);
std::string path_chosen;
win->Start(&path_chosen);
if(path_chosen.size() >= PATH_MAX) return NULL;
strcpy(DLL_PATH, path_chosen.c_str());
return DLL_PATH;
}
int main(int argc, char* argv[]){
FileSelect * win;
v2d<unsigned int> size;
switch(argc){
case 1:
win = new FileSelect("Select a file", {SCREEN_W, SCREEN_H}, true);
break;
case 2:
win = new FileSelect(std::string(argv[1]), {SCREEN_W, SCREEN_H}, true);
break;
case 4:
size = {std::stoi(argv[2]), std::stoi(argv[3])};
if(size.y < 400)
size.y = 400;
if(size.x < 400)
size.x = 400;
win = new FileSelect(std::string(argv[1]), size, true);
break;
default:
std::cerr << "ERR: Not enough arguments";
exit(-1);
break;
};
std::string path_chosen;
win->Start(&path_chosen);
puts(path_chosen.c_str());
return 0;
}