ALL: Sync with ScummVM - rev. cd37d510f9

This commit is contained in:
Bastien Bouclet 2019-01-26 20:47:55 +01:00
parent 0dc8726136
commit 66654cb376
194 changed files with 19108 additions and 9954 deletions

View file

@ -27,7 +27,6 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one...
#include <shellapi.h>
#if defined(__GNUC__) && defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
// required for SHGFP_TYPE_CURRENT in shlobj.h
@ -43,10 +42,12 @@
#include "backends/audiocd/win32/win32-audiocd.h"
#include "backends/platform/sdl/win32/win32.h"
#include "backends/platform/sdl/win32/win32-window.h"
#include "backends/platform/sdl/win32/win32_wrapper.h"
#include "backends/saves/windows/windows-saves.h"
#include "backends/fs/windows/windows-fs-factory.h"
#include "backends/taskbar/win32/win32-taskbar.h"
#include "backends/updates/win32/win32-updates.h"
#include "backends/dialogs/win32/win32-dialogs.h"
#include "common/memstream.h"
@ -61,7 +62,12 @@ void OSystem_Win32::init() {
#if defined(USE_TASKBAR)
// Initialize taskbar manager
_taskbarManager = new Win32TaskbarManager(_window);
_taskbarManager = new Win32TaskbarManager((SdlWindow_Win32*)_window);
#endif
#if defined(USE_SYSDIALOGS)
// Initialize dialog manager
_dialogManager = new Win32DialogManager((SdlWindow_Win32*)_window);
#endif
// Invoke parent implementation of this method
@ -102,6 +108,11 @@ bool OSystem_Win32::hasFeature(Feature f) {
if (f == kFeatureDisplayLogFile || f == kFeatureOpenUrl)
return true;
#ifdef USE_SYSDIALOGS
if (f == kFeatureSystemBrowserDialog)
return true;
#endif
return OSystem_SDL::hasFeature(f);
}
@ -166,10 +177,8 @@ Common::String OSystem_Win32::getSystemLanguage() const {
char langName[9];
char ctryName[9];
const LCID languageIdentifier = GetUserDefaultUILanguage();
if (GetLocaleInfo(languageIdentifier, LOCALE_SISO639LANGNAME, langName, sizeof(langName)) != 0 &&
GetLocaleInfo(languageIdentifier, LOCALE_SISO3166CTRYNAME, ctryName, sizeof(ctryName)) != 0) {
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, langName, sizeof(langName)) != 0 &&
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, ctryName, sizeof(ctryName)) != 0) {
Common::String localeName = langName;
localeName += "_";
localeName += ctryName;
@ -189,10 +198,10 @@ Common::String OSystem_Win32::getScreenshotsPath() {
return screenshotsPath;
}
// Use the My Pictures folder.
char picturesPath[MAXPATHLEN];
// Use the My Pictures folder.
if (SHGetFolderPath(NULL, CSIDL_MYPICTURES, NULL, SHGFP_TYPE_CURRENT, picturesPath) != S_OK) {
if (SHGetFolderPathFunc(NULL, CSIDL_MYPICTURES, NULL, SHGFP_TYPE_CURRENT, picturesPath) != S_OK) {
warning("Unable to access My Pictures directory");
return Common::String();
}
@ -212,30 +221,8 @@ Common::String OSystem_Win32::getScreenshotsPath() {
Common::String OSystem_Win32::getDefaultConfigFileName() {
char configFile[MAXPATHLEN];
OSVERSIONINFO win32OsVersion;
ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO));
win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&win32OsVersion);
// Check for non-9X version of Windows.
if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
// Use the Application Data directory of the user profile.
if (win32OsVersion.dwMajorVersion >= 5) {
if (!GetEnvironmentVariable("APPDATA", configFile, sizeof(configFile)))
error("Unable to access application data directory");
} else {
if (!GetEnvironmentVariable("USERPROFILE", configFile, sizeof(configFile)))
error("Unable to access user profile directory");
strcat(configFile, "\\Application Data");
// If the directory already exists (as it should in most cases),
// we don't want to fail, but we need to stop on other errors (such as ERROR_PATH_NOT_FOUND)
if (!CreateDirectory(configFile, NULL)) {
if (GetLastError() != ERROR_ALREADY_EXISTS)
error("Cannot create Application data folder");
}
}
// Use the Application Data directory of the user profile.
if (SHGetFolderPathFunc(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, configFile) == S_OK) {
strcat(configFile, "\\ResidualVM");
if (!CreateDirectory(configFile, NULL)) {
if (GetLastError() != ERROR_ALREADY_EXISTS)
@ -262,6 +249,7 @@ Common::String OSystem_Win32::getDefaultConfigFileName() {
fclose(tmp);
}
} else {
warning("Unable to access application data directory");
// Check windows directory
uint ret = GetWindowsDirectory(configFile, MAXPATHLEN);
if (ret == 0 || ret > MAXPATHLEN)
@ -280,24 +268,8 @@ Common::WriteStream *OSystem_Win32::createLogFile() {
char logFile[MAXPATHLEN];
OSVERSIONINFO win32OsVersion;
ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO));
win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&win32OsVersion);
// Check for non-9X version of Windows.
if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
// Use the Application Data directory of the user profile.
if (win32OsVersion.dwMajorVersion >= 5) {
if (!GetEnvironmentVariable("APPDATA", logFile, sizeof(logFile)))
error("Unable to access application data directory");
} else {
if (!GetEnvironmentVariable("USERPROFILE", logFile, sizeof(logFile)))
error("Unable to access user profile directory");
strcat(logFile, "\\Application Data");
CreateDirectory(logFile, NULL);
}
// Use the Application Data directory of the user profile.
if (SHGetFolderPathFunc(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, logFile) == S_OK) {
strcat(logFile, "\\ResidualVM");
CreateDirectory(logFile, NULL);
strcat(logFile, "\\Logs");
@ -311,6 +283,7 @@ Common::WriteStream *OSystem_Win32::createLogFile() {
return stream;
} else {
warning("Unable to access application data directory");
return 0;
}
}