diff options
author | Juan Linietsky <red@kyoko> | 2015-05-11 15:49:41 -0300 |
---|---|---|
committer | Juan Linietsky <red@kyoko> | 2015-05-11 15:49:41 -0300 |
commit | 4b8745ad63409cf14b02735981ee35d2f794421c (patch) | |
tree | 607dcfbb77430e8ed7eef25de6b7bec9c4032aec /platform/windows | |
parent | dda60296d81edaabfdb56f47a2c949b5dad283fb (diff) | |
parent | b777bf5ff5c3891daa0f93987ca12d0d7d053c2b (diff) |
Merge branch 'master' of https://github.com/okamstudio/godot
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/SCsub | 6 | ||||
-rw-r--r-- | platform/windows/detect.py | 2 | ||||
-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/windows/SCsub b/platform/windows/SCsub index a77428e954..1ad32e7989 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/detect.py b/platform/windows/detect.py index 9cdf04797c..298fa3bc78 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -204,7 +204,7 @@ def configure(env): elif (env["target"]=="debug"):
- env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/O1'])
+ env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/Od'])
env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
env.Append(LINKFLAGS=['/DEBUG'])
diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp index 0e74f63510..81c90d9dd0 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 93275b3d54..1350719778 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) { |