Ticket #7792: console.diff
File console.diff, 6.1 KB (added by , 14 years ago) |
---|
-
README
924 924 -z, --list-games Display list of supported games and exit 925 925 -t, --list-targets Display list of configured targets and exit 926 926 --list-saves=TARGET Display a list of savegames for the game (TARGET) specified 927 --no-console Disable the console window (Windows only) 927 928 928 929 -c, --config=CONFIG Use alternate configuration file 929 930 -p, --path=PATH Path to where the game is installed … … 1955 1956 1956 1957 confirm_exit bool Ask for confirmation by the user before quitting 1957 1958 (SDL backend only). 1959 no_console bool Disable the console window (Windows only). 1958 1960 cdrom number Number of CD-ROM unit to use for audio. If 1959 1961 negative, don't even try to access the CD-ROM. 1960 1962 joystick_num number Number of joystick device to use for input -
backends/platform/sdl/sdl.cpp
116 116 } 117 117 #endif 118 118 119 #if defined(WIN32) 120 struct SdlConsoleHidingWin32 { 121 DWORD myPid; 122 DWORD myTid; 123 HWND consoleHandle; 124 }; 119 #if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) 120 static Common::String getLogPath() { 121 char appDataPath[MAXPATHLEN]; 122 OSVERSIONINFO win32OsVersion; 123 ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO)); 124 win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 125 GetVersionEx(&win32OsVersion); 126 // Check for non-9X version of Windows. 127 if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) { 128 // Use the Application Data directory of the user profile. 129 if (win32OsVersion.dwMajorVersion >= 5) { 130 if (!GetEnvironmentVariable("APPDATA", appDataPath, sizeof(appDataPath))) 131 error("Unable to access application data directory"); 132 } else { 133 if (!GetEnvironmentVariable("USERPROFILE", appDataPath, sizeof(appDataPath))) 134 error("Unable to access user profile directory"); 125 135 126 // console hiding for win32 127 static BOOL CALLBACK initBackendFindConsoleWin32Proc(HWND hWnd, LPARAM lParam) { 128 DWORD pid, tid; 129 SdlConsoleHidingWin32 *variables = (SdlConsoleHidingWin32 *)lParam; 130 tid = GetWindowThreadProcessId(hWnd, &pid); 131 if ((tid == variables->myTid) && (pid == variables->myPid)) { 132 variables->consoleHandle = hWnd; 133 return FALSE; 136 strcat(appDataPath, "\\Application Data"); 137 CreateDirectory(appDataPath, NULL); 134 138 } 135 return TRUE; 139 140 strcat(appDataPath, "\\ScummVM"); 141 CreateDirectory(appDataPath, NULL); 142 } else { 143 // Use current working directory 144 GetCurrentDirectory(MAXPATHLEN, appDataPath); 136 145 } 146 147 return appDataPath; 148 } 137 149 #endif 138 150 139 151 void OSystem_SDL::initBackend() { … … 155 167 if (joystick_num > -1) 156 168 sdlFlags |= SDL_INIT_JOYSTICK; 157 169 158 #if 0 159 // NEW CODE TO HIDE CONSOLE FOR WIN32 160 #if defined(WIN32) 161 // console hiding for win32 162 SdlConsoleHidingWin32 consoleHidingWin32; 163 consoleHidingWin32.consoleHandle = 0; 164 consoleHidingWin32.myPid = GetCurrentProcessId(); 165 consoleHidingWin32.myTid = GetCurrentThreadId(); 166 EnumWindows (initBackendFindConsoleWin32Proc, (LPARAM)&consoleHidingWin32); 170 #if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) 171 if (ConfMan.getBool("no_console")) { 172 FreeConsole(); 173 /* Redirect standard input and standard output */ 174 char STDOUT_FILE[MAX_PATH], STDERR_FILE[MAX_PATH]; 167 175 168 if (!ConfMan.getBool("show_console")) { 169 if (consoleHidingWin32.consoleHandle) { 170 // We won't find a window with our TID/PID in case we were started from command-line 171 ShowWindow(consoleHidingWin32.consoleHandle, SW_HIDE); 176 strcpy(STDOUT_FILE, getLogPath().c_str()); 177 strcpy(STDERR_FILE, getLogPath().c_str()); 178 strcat(STDOUT_FILE, "\\scummvm.stdout.txt"); 179 strcat(STDERR_FILE, "\\scummvm.stderr.txt"); 180 181 freopen(STDOUT_FILE, "w", stdout); 182 freopen(STDERR_FILE, "w", stderr); 183 setbuf(stdout, NULL); /* No buffering */ 184 setbuf(stderr, NULL); /* No buffering */ 185 } else { 186 if (AllocConsole()) { 187 freopen("CONIN$","r",stdin); 188 freopen("CONOUT$","w",stdout); 189 freopen("CONOUT$","w",stderr); 172 190 } 191 SetConsoleTitle("ScummVM Status Window"); 173 192 } 174 193 #endif 175 #endif176 194 177 195 if (SDL_Init(sdlFlags) == -1) { 178 196 error("Could not initialize SDL: %s", SDL_GetError()); -
base/commandLine.cpp
60 60 " -z, --list-games Display list of supported games and exit\n" 61 61 " -t, --list-targets Display list of configured targets and exit\n" 62 62 " --list-saves=TARGET Display a list of savegames for the game (TARGET) specified\n" 63 #if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) 64 " --no-console Disable the console window\n" 65 #endif 63 66 "\n" 64 67 " -c, --config=CONFIG Use alternate configuration file\n" 65 68 " -p, --path=PATH Path to where the game is installed\n" … … 220 223 ConfMan.registerDefault("record_temp_file_name", "record.tmp"); 221 224 ConfMan.registerDefault("record_time_file_name", "record.time"); 222 225 223 #if 0 224 // NEW CODE TO HIDE CONSOLE FOR WIN32 225 #ifdef WIN32 226 // console hiding for win32 227 ConfMan.registerDefault("show_console", false); 226 #if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) 227 // Console window is enabled by default on Windows 228 ConfMan.registerDefault("no_console", false); 228 229 #endif 229 #endif230 230 } 231 231 232 232 // … … 554 554 END_OPTION 555 555 #endif 556 556 557 #if 0 558 // NEW CODE TO HIDE CONSOLE FOR WIN32 559 #ifdef WIN32 560 // console hiding for win32 561 DO_LONG_OPTION_BOOL("show-console") 557 #if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) 558 // Optional disabling of console window on Windows 559 DO_LONG_OPTION_BOOL("no-console") 562 560 END_OPTION 563 561 #endif 564 #endif565 562 566 563 unknownOption: 567 564 // If we get till here, the option is unhandled and hence unknown.