mirror of https://github.com/OpenRCT2/OpenRCT2.git
Save screenshots in home folder, Add functions for path separator and detection of homefolder to osinterface
This commit is contained in:
parent
5b568f376c
commit
bbae0af0ef
11
src/config.c
11
src/config.c
|
@ -216,20 +216,23 @@ void config_save()
|
||||||
*/
|
*/
|
||||||
void config_init()
|
void config_init()
|
||||||
{
|
{
|
||||||
TCHAR path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
|
|
||||||
memcpy(&gGeneral_config, &gGeneral_config_default, sizeof(general_configuration_t));
|
memcpy(&gGeneral_config, &gGeneral_config_default, sizeof(general_configuration_t));
|
||||||
|
|
||||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { // find home folder
|
strncpy(path, osinterface_get_orct2_homefolder(), MAX_PATH);
|
||||||
strcat(path, "\\OpenRCT2");
|
|
||||||
|
if (strcmp(path, "") != 0){
|
||||||
DWORD dwAttrib = GetFileAttributes(path);
|
DWORD dwAttrib = GetFileAttributes(path);
|
||||||
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { // folder does not exist
|
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { // folder does not exist
|
||||||
if (!CreateDirectory(path, NULL)) {
|
if (!CreateDirectory(path, NULL)) {
|
||||||
config_error("Could not create config file (do you have write access to your documents folder?)");
|
config_error("Could not create config file (do you have write access to your documents folder?)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcat(path, "\\config.ini");
|
|
||||||
|
sprintf(path, "%s%c%s", path, osinterface_get_path_separator(), "config.ini");
|
||||||
|
|
||||||
fp = fopen(path, "r");
|
fp = fopen(path, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
config_create_default(path);
|
config_create_default(path);
|
||||||
|
|
|
@ -428,3 +428,19 @@ char* osinterface_open_directory_browser(char *title) {
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
return outPath;
|
return outPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* osinterface_get_orct2_homefolder()
|
||||||
|
{
|
||||||
|
char path[260]="";
|
||||||
|
|
||||||
|
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { // find home folder
|
||||||
|
strcat(path, "\\OpenRCT2");
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
char osinterface_get_path_separator()
|
||||||
|
{
|
||||||
|
return '\\';
|
||||||
|
}
|
|
@ -50,4 +50,7 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c
|
||||||
void osinterface_show_messagebox(char* message);
|
void osinterface_show_messagebox(char* message);
|
||||||
char* osinterface_open_directory_browser(char *title);
|
char* osinterface_open_directory_browser(char *title);
|
||||||
|
|
||||||
|
char* osinterface_get_orct2_homefolder();
|
||||||
|
char osinterface_get_path_separator();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <lodepng.h>
|
#include <lodepng.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include "osinterface.h"
|
||||||
#include "addresses.h"
|
#include "addresses.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
@ -64,7 +65,7 @@ static int screenshot_get_next_path(char *path, char *extension)
|
||||||
RCT2_GLOBAL(0x013CE952, uint16) = i;
|
RCT2_GLOBAL(0x013CE952, uint16) = i;
|
||||||
|
|
||||||
// Glue together path and filename
|
// Glue together path and filename
|
||||||
sprintf(path, "%sSCR%d%s", RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char), i, extension);
|
sprintf(path, "%s%cSCR%d%s", osinterface_get_orct2_homefolder(), osinterface_get_path_separator(), i, extension);
|
||||||
|
|
||||||
if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND)
|
if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND)
|
||||||
return i;
|
return i;
|
||||||
|
|
Loading…
Reference in New Issue