| 939 | } |
| 940 | |
| 941 | void setWindowIcon(int winResource, const std::string &unixPath) |
| 942 | { |
| 943 | #ifdef _WIN32 |
| 944 | HINSTANCE handle = GetModuleHandle(NULL); |
| 945 | HICON icon = LoadIcon(handle, MAKEINTRESOURCE(winResource)); |
| 946 | |
| 947 | SDL_SysWMinfo wminfo; |
| 948 | SDL_VERSION(&wminfo.version) |
| 949 | if (SDL_GetWMInfo(&wminfo)) |
| 950 | { |
| 951 | HWND hwnd = wminfo.window; |
| 952 | SetClassLongPtr(hwnd, GCLP_HICON, (LONG_PTR)icon); |
| 953 | } |
| 954 | #else |
| 955 | // SDL only takes UTF-8 filenames |
| 956 | // so here's an ugly hack to match this ugly reasoning |
| 957 | std::string utf8 = Language::wstrToUtf8(Language::fsToWstr(CrossPlatform::getDataFile(unixPath))); |
| 958 | SDL_Surface *icon = IMG_Load(utf8.c_str()); |
| 959 | if (icon != 0) |
| 960 | { |
| 961 | SDL_WM_SetIcon(icon, NULL); |
| 962 | SDL_FreeSurface(icon); |
| 963 | } |
| 964 | #endif |
| 965 | } |
| 966 | |
| 967 | } |
| 968 | } |