diff options
Diffstat (limited to 'platform')
| -rw-r--r-- | platform/android/android_native_app_glue.h | 2 | ||||
| -rw-r--r-- | platform/windows/SCsub | 6 | ||||
| -rw-r--r-- | platform/windows/godot_win.cpp | 107 | ||||
| -rw-r--r-- | platform/windows/os_windows.cpp | 11 |
4 files changed, 38 insertions, 88 deletions
diff --git a/platform/android/android_native_app_glue.h b/platform/android/android_native_app_glue.h index a902a3b4d..f5ba27ae6 100644 --- a/platform/android/android_native_app_glue.h +++ b/platform/android/android_native_app_glue.h @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - * Copyright (C) 2010 The Android Open Source Project +/* Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/windows/SCsub b/platform/windows/SCsub index a77428e95..1ad32e798 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -12,3 +12,9 @@ common_win=[ ] env.Program('#bin/godot',['godot_win.cpp']+common_win,PROGSUFFIX=env["PROGSUFFIX"]) + +# Microsoft Visual Studio Project Generation +if (env['vsproj'])=="yes": + env.vs_srcs = env.vs_srcs + ["platform/windows/godot_win.cpp"] + for x in common_win: + env.vs_srcs = env.vs_srcs + ["platform/windows/" + x] diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp index 0e74f6351..81c90d9dd 100644 --- a/platform/windows/godot_win.cpp +++ b/platform/windows/godot_win.cpp @@ -115,29 +115,24 @@ PCHAR* return argv; } -char* mb_to_utf8(const char* mbs) { - - int wlen = MultiByteToWideChar(CP_ACP,0,mbs,-1,NULL,0); // returns 0 if failed - wchar_t *wbuf = new wchar_t[wlen + 1]; - MultiByteToWideChar(CP_ACP,0,mbs,-1,wbuf,wlen); - wbuf[wlen]=0; - - int ulen = WideCharToMultiByte(CP_UTF8,0,wbuf,-1,NULL,0,NULL,NULL); +char* wc_to_utf8(const wchar_t* wc) { + int ulen = WideCharToMultiByte(CP_UTF8,0,wc,-1,NULL,0,NULL,NULL); char * ubuf = new char[ulen + 1]; - WideCharToMultiByte(CP_UTF8,0,wbuf,-1,ubuf,ulen,NULL,NULL); + WideCharToMultiByte(CP_UTF8,0,wc,-1,ubuf,ulen,NULL,NULL); ubuf[ulen] = 0; return ubuf; } -int main(int argc, char** argv) { +int widechar_main(int argc, wchar_t** argv) { OS_Windows os(NULL); setlocale(LC_CTYPE, ""); char ** argv_utf8 = new char*[argc]; + for(int i=0; i<argc; ++i) { - argv_utf8[i] = mb_to_utf8(argv[i]); + argv_utf8[i] = wc_to_utf8(argv[i]); } Main::setup(argv_utf8[0], argc - 1, &argv_utf8[1]); @@ -154,82 +149,30 @@ int main(int argc, char** argv) { return os.get_exit_code(); }; -HINSTANCE godot_hinstance = NULL; - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - - int argc; - char** argv; - - char* arg; - int index; - int result; - - // count the arguments - - argc = 1; - arg = lpCmdLine; - - while (arg[0] != 0) { - - while (arg[0] != 0 && arg[0] == ' ') { - arg++; - } - - if (arg[0] != 0) { - - argc++; - - while (arg[0] != 0 && arg[0] != ' ') { - arg++; - } - - } - - } - - // tokenize the arguments - - argv = (char**)malloc(argc * sizeof(char*)); - - arg = lpCmdLine; - index = 1; - - while (arg[0] != 0) { - - while (arg[0] != 0 && arg[0] == ' ') { - arg++; - } - - if (arg[0] != 0) { - - argv[index] = arg; - index++; - - while (arg[0] != 0 && arg[0] != ' ') { - arg++; - } - - if (arg[0] != 0) { - arg[0] = 0; - arg++; - } - - } +int main(int _argc, char** _argv) { + // _argc and _argv are ignored + // we are going to use the WideChar version of them instead - } + LPWSTR *wc_argv; + int argc; + int result; - // put the program name into argv[0] + wc_argv = CommandLineToArgvW(GetCommandLineW(), &argc); - char filename[_MAX_PATH]; + if( NULL == wc_argv ) { + wprintf(L"CommandLineToArgvW failed\n"); + return 0; + } - GetModuleFileName(NULL, filename, _MAX_PATH); - argv[0] = filename; + result = widechar_main(argc, wc_argv); - // call the user specified main function + LocalFree(wc_argv); + return result; +} - result = main(argc, argv); +HINSTANCE godot_hinstance = NULL; - free(argv); - return result; +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { + godot_hinstance = hInstance; + return main(0,NULL); } diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 93275b3d5..135071977 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2117,12 +2117,13 @@ bool OS_Windows::has_environment(const String& p_var) const { String OS_Windows::get_environment(const String& p_var) const { - char* val = getenv(p_var.utf8().get_data()); - if (val) - return val; - + wchar_t wval[0x7Fff]; // MSDN says 32767 char is the maximum + int wlen = GetEnvironmentVariableW(p_var.c_str(),wval,0x7Fff); + if ( wlen > 0 ) { + return wval; + } return ""; -}; +} String OS_Windows::get_stdin_string(bool p_block) { |
