1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

embed OpenRCT2 icon for Windows (#3372)

Embeds the OpenRCT2 icon file using Win32 native resources and sets the window icon to it.
This commit is contained in:
Ted John
2016-04-21 19:17:26 +01:00
parent d7cd3d0662
commit b499a4589f
8 changed files with 138 additions and 1 deletions

View File

@@ -156,6 +156,7 @@ void platform_enumerate_files_end(int handle);
int platform_enumerate_directories_begin(const utf8 *directory);
bool platform_enumerate_directories_next(int handle, utf8 *path);
void platform_enumerate_directories_end(int handle);
void platform_init_window_icon();
// Returns the bitmask of the GetLogicalDrives function for windows, 0 for other systems
int platform_get_drives();

View File

@@ -892,4 +892,10 @@ utf8* platform_get_username() {
}
}
void platform_init_window_icon()
{
// TODO Create a surface with the window icon
// SDL_SetWindowIcon(gWindow, iconSurface)
}
#endif

View File

@@ -775,6 +775,7 @@ static void platform_create_window()
SDL_SetWindowGrab(gWindow, gConfigGeneral.trap_cursor ? SDL_TRUE : SDL_FALSE);
SDL_SetWindowMinimumSize(gWindow, 720, 480);
platform_init_window_icon();
// Set the update palette function pointer
RCT2_GLOBAL(0x009E2BE4, update_palette_func) = platform_update_palette;

View File

@@ -35,6 +35,9 @@
#include "../config.h"
#include "platform.h"
// Native resource IDs
#include "../../resources/resource.h"
// The name of the mutex used to prevent multiple instances of the game from running
#define SINGLE_INSTANCE_MUTEX_NAME "RollerCoaster Tycoon 2_GSKMUTEX"
@@ -43,6 +46,10 @@ utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 };
utf8 **windows_get_command_line_args(int *outNumArgs);
#define OPENRCT2_DLL_MODULE_NAME "openrct2.dll"
static HMODULE _dllModule = NULL;
/**
* Windows entry point to OpenRCT2 without a console window.
*/
@@ -69,6 +76,7 @@ utf8 **windows_get_command_line_args(int *outNumArgs);
*/
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
_dllModule = hModule;
return TRUE;
}
#endif // __MINGW32__
@@ -82,6 +90,10 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta
int argc, runGame;
char **argv;
if (_dllModule == NULL) {
_dllModule = GetModuleHandleA(OPENRCT2_DLL_MODULE_NAME);
}
RCT2_GLOBAL(RCT2_ADDRESS_HINSTANCE, HINSTANCE) = hInstance;
RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, LPSTR) = lpCmdLine;
@@ -798,6 +810,17 @@ HWND windows_get_window_handle()
return result;
}
void platform_init_window_icon()
{
if (_dllModule != NULL) {
HICON icon = LoadIcon(_dllModule, MAKEINTRESOURCE(IDI_ICON));
if (icon != NULL) {
HWND hwnd = windows_get_window_handle();
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon);
}
}
}
uint16 platform_get_locale_language()
{
CHAR langCode[4];