- [NEW] Function "configfolder()"

This commit is contained in:
2023-02-01 19:15:18 +01:00
parent f457075c49
commit 38e209fa76
5 changed files with 18 additions and 1 deletions

View File

@@ -170,6 +170,11 @@ void file_setconfigfolder(const char *foldername)
}
}
const char *file_getconfigfolder() {
std::string folder = config_folder + "/";
return folder.c_str();
}
void file_loadconfigvalues() {
config.clear();
std::string config_file = config_folder + "/config.txt";

View File

@@ -5,6 +5,7 @@
#define SOURCE_FOLDER 1
void file_setconfigfolder(const char *foldername);
const char *file_getconfigfolder();
void file_setresourcefilename(const char *str);
void file_setresourcefolder(const char *str);

View File

@@ -777,6 +777,11 @@ extern "C" {
return 0;
}
static int cpp_configfolder(lua_State *L) {
lua_pushstring(L, configfolder());
return 1;
}
static int cpp_exit(lua_State *L) {
exit();
return 0;
@@ -897,6 +902,7 @@ void push_lua_funcs() {
lua_pushcfunction(L,cpp_getconf); lua_setglobal(L, "getconf");
lua_pushcfunction(L,cpp_setconf); lua_setglobal(L, "setconf");
lua_pushcfunction(L,cpp_configfolder); lua_setglobal(L, "configfolder");
lua_pushcfunction(L,cpp_exit); lua_setglobal(L, "quit");

View File

@@ -1207,6 +1207,10 @@ void setconfig(const char* key, const char* value) {
file_setconfigvalue(key, value);
}
const char *configfolder() {
return file_getconfigfolder();
}
void exit() {
should_exit = true;
should_quit = true;

3
mini.h
View File

@@ -281,7 +281,8 @@ void setfullscreen(const bool value);
bool getcursor();
void setcursor(const bool value);
const char* getconfig(const char* key);
const char *getconfig(const char* key);
void setconfig(const char* key, const char* value);
const char *configfolder();
void exit();