From d4c0cde7488eace1e177aea488e433b6836f829a Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 10 Feb 2019 16:55:54 +0000 Subject: [PATCH] Added Windows-specific icon files --- Makefile | 13 ++++++++++++- res/ICON/0.ico | Bin 0 -> 766 bytes res/ICON/ICON.rc | 2 ++ res/ICON/ICON_MINI.ico | Bin 0 -> 318 bytes src/Main.cpp | 14 +++++++++++--- src/Resource.cpp | 6 +++++- 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 res/ICON/0.ico create mode 100644 res/ICON/ICON.rc create mode 100644 res/ICON/ICON_MINI.ico diff --git a/Makefile b/Makefile index 7a6caea2..99bc70bc 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,6 @@ RESOURCES = \ BITMAP/CREDIT18.bmp \ CURSOR/CURSOR_IKA.bmp \ CURSOR/CURSOR_NORMAL.bmp \ - ICON/4.bmp \ ORG/ACCESS \ ORG/ANZEN \ ORG/BALCONY \ @@ -182,8 +181,16 @@ else RESOURCES += BITMAP/PIXEL.bmp endif +ifneq ($(WINDOWS), 1) + RESOURCES += ICON/4.bmp +endif + OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES))) +ifeq ($(WINDOWS), 1) +OBJECTS += obj/$(FILENAME)/win_icon.o +endif + all: build/$(FILENAME) build/$(FILENAME): $(OBJECTS) @@ -211,5 +218,9 @@ obj/bin2h: res/bin2h.c @echo Compiling $^ @gcc -O3 -s -static $^ -o $@ +obj/$(FILENAME)/win_icon.o: res/ICON/ICON.rc res/ICON/0.ico res/ICON/ICON_MINI.ico + @mkdir -p $(@D) + @windres $< $@ + clean: @rm -rf build obj diff --git a/res/ICON/0.ico b/res/ICON/0.ico new file mode 100644 index 0000000000000000000000000000000000000000..33fc2aa3c0323cfa9877ff309e47b8640446278d GIT binary patch literal 766 zcmcgqF>b>!45XU^DzcJmLhP-N5X)!N}xWrimU53(mT(crs$X#f%;d ziyJ=xM!=rFV=K8NIe91@|zdUj7{GRqJQx% zPxN8AXem12Wh}W~GeRFHv(uiu5PEJryRJvGV>^@QIXmSGaN@i3Bc}j~C+7^0 zQvwdoOz#|-2|FSnfgOC-UwAEjC=xr4lxVGyDPVD7=8DPVErO~715vduL0W2OtM3pm vUt;|DzK;?ZeIRtPLG`(st)GoAdX>p+I_s?f^GxSbJt!XB4};BxANnJ{3z1#C literal 0 HcmV?d00001 diff --git a/src/Main.cpp b/src/Main.cpp index 38c9fc79..0d91786c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -102,7 +102,13 @@ int main(int argc, char *argv[]) //Get path of the data folder strcpy(gDataPath, gModulePath); memcpy(&gDataPath[strlen(gDataPath)], "/data", 6); //Pixel didn't use a strcat - + +#ifdef WINDOWS + // Set the window icons. See icon.rc. + SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON, "101"); + SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL, "102"); +#endif + //Initialize SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER) >= 0) { @@ -226,7 +232,7 @@ int main(int argc, char *argv[]) { printf("Failed to load cursor"); } - + //Get window dimensions and colour depth int colourDepth = 16; @@ -285,6 +291,7 @@ int main(int argc, char *argv[]) if (CheckFileExists("fps")) bFps = true; +#ifndef WINDOWS //Load icon SDL_RWops *fp = FindResource("ICON4"); @@ -303,7 +310,8 @@ int main(int argc, char *argv[]) { printf("Failed to load icon"); } - +#endif + //Set rects RECT loading_rect = {0, 0, 64, 8}; RECT clip_rect = {0, 0, gWindowWidth, gWindowHeight}; diff --git a/src/Resource.cpp b/src/Resource.cpp index 52e704c5..4db11132 100644 --- a/src/Resource.cpp +++ b/src/Resource.cpp @@ -69,7 +69,9 @@ #else #include "Resource/BITMAP/PIXEL.bmp.h" #endif +#ifndef WINDOWS #include "Resource/ICON/4.bmp.h" +#endif #include "Resource/CURSOR/CURSOR_IKA.bmp.h" #include "Resource/CURSOR/CURSOR_NORMAL.bmp.h" @@ -391,13 +393,15 @@ const unsigned char* GetResource(const char *name, size_t *size) #endif } +#ifndef WINDOWS //ICON if (!strcmp(name, "ICON4")) { *size = sizeof(r4); return r4; } - +#endif + //CURSOR if (!strcmp(name, "CURSOR_NORMAL")) {