mirror of https://github.com/OpenRCT2/OpenRCT2.git
clean up config
This commit is contained in:
parent
0e7283679b
commit
231777d131
|
@ -1,28 +1,18 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 2013
|
# Visual Studio 2013
|
||||||
VisualStudioVersion = 12.0.21005.1
|
VisualStudioVersion = 12.0.30110.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2", "openrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2", "openrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
Release|Mixed Platforms = Release|Mixed Platforms
|
|
||||||
Release|Win32 = Release|Win32
|
Release|Win32 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32
|
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32
|
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Any CPU.ActiveCfg = Release|Win32
|
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Mixed Platforms.Build.0 = Release|Win32
|
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32
|
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32
|
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
|
27
src/config.c
27
src/config.c
|
@ -147,6 +147,7 @@ void config_save()
|
||||||
|
|
||||||
configuration_t gConfig;
|
configuration_t gConfig;
|
||||||
|
|
||||||
|
static char *config_show_directory_browser();
|
||||||
static void config_parse_settings(FILE *fp);
|
static void config_parse_settings(FILE *fp);
|
||||||
static int config_get_line(FILE *fp, char *setting, char *value);
|
static int config_get_line(FILE *fp, char *setting, char *value);
|
||||||
static int config_parse_setting(FILE *fp, char *setting);
|
static int config_parse_setting(FILE *fp, char *setting);
|
||||||
|
@ -170,7 +171,7 @@ void config_init()
|
||||||
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 acces to you documents folder?)");
|
config_error("Could not create config file (do you have write access to your documents folder?)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcat(path, "\\config.ini");
|
strcat(path, "\\config.ini");
|
||||||
|
@ -230,7 +231,7 @@ static void config_create_default(char *path)
|
||||||
|
|
||||||
if (!config_find_rct2_path(gConfig.game_path)) {
|
if (!config_find_rct2_path(gConfig.game_path)) {
|
||||||
MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directoy where you installed RCT2!", "OpenRCT2", MB_OK);
|
MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directoy where you installed RCT2!", "OpenRCT2", MB_OK);
|
||||||
char *res = directory_browser();
|
char *res = config_show_directory_browser();
|
||||||
strcpy(gConfig.game_path, res);
|
strcpy(gConfig.game_path, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,8 +243,10 @@ static void config_create_default(char *path)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//A directory browser allowing for semi-automatic config.ini for non standard installs
|
/**
|
||||||
char* directory_browser()
|
* A directory browser allowing for semi-automatic config.ini for non standard installs.
|
||||||
|
*/
|
||||||
|
static char *config_show_directory_browser()
|
||||||
{
|
{
|
||||||
BROWSEINFO bi;
|
BROWSEINFO bi;
|
||||||
char pszBuffer[MAX_PATH];
|
char pszBuffer[MAX_PATH];
|
||||||
|
@ -251,16 +254,14 @@ char* directory_browser()
|
||||||
LPMALLOC lpMalloc;
|
LPMALLOC lpMalloc;
|
||||||
|
|
||||||
// Initialize COM
|
// Initialize COM
|
||||||
if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK)
|
if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) {
|
||||||
{
|
|
||||||
MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK);
|
MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK);
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a pointer to the shell memory allocator
|
// Get a pointer to the shell memory allocator
|
||||||
if (SHGetMalloc(&lpMalloc) != S_OK)
|
if (SHGetMalloc(&lpMalloc) != S_OK) {
|
||||||
{
|
|
||||||
MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK);
|
MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK);
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -276,16 +277,12 @@ char* directory_browser()
|
||||||
|
|
||||||
char *outPath = "C:\\";
|
char *outPath = "C:\\";
|
||||||
|
|
||||||
if (pidl = SHBrowseForFolder(&bi))
|
if (pidl = SHBrowseForFolder(&bi)) {
|
||||||
{
|
|
||||||
// Copy the path directory to the buffer
|
// Copy the path directory to the buffer
|
||||||
if (SHGetPathFromIDList(pidl, pszBuffer))
|
if (SHGetPathFromIDList(pidl, pszBuffer)) {
|
||||||
{
|
// Store pszBuffer (and the path) in the outPath
|
||||||
// store pszBuffer (and the path) in the outPath
|
|
||||||
outPath = strcat("", pszBuffer);
|
outPath = strcat("", pszBuffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
return outPath;
|
return outPath;
|
||||||
|
|
|
@ -81,7 +81,6 @@ extern uint16 gShortcutKeys[SHORTCUT_COUNT];
|
||||||
void config_reset_shortcut_keys();
|
void config_reset_shortcut_keys();
|
||||||
void config_load();
|
void config_load();
|
||||||
void config_save();
|
void config_save();
|
||||||
char* directory_browser();
|
|
||||||
|
|
||||||
|
|
||||||
// New config format
|
// New config format
|
||||||
|
|
|
@ -151,7 +151,7 @@ void rct2_init_directories()
|
||||||
// check install directory
|
// check install directory
|
||||||
DWORD dwAttrib = GetFileAttributes(gConfig.game_path);
|
DWORD dwAttrib = GetFileAttributes(gConfig.game_path);
|
||||||
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) {
|
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||||
MessageBox(NULL, "Invalid RCT2 installation path. Please delete config.ini and run OpenRTC2 again.", "OpenRCT2", MB_OK);
|
MessageBox(NULL, "Invalid RCT2 installation path. Please correct in config.ini.", "OpenRCT2", MB_OK);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue