ref: d4c0cde7488eace1e177aea488e433b6836f829a
parent: 2ee2a1b34b975877b79d98e797f302964133c51e
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sun Feb 10 11:55:54 EST 2019
Added Windows-specific icon files
--- a/Makefile
+++ b/Makefile
@@ -131,7 +131,6 @@
BITMAP/CREDIT18.bmp \
CURSOR/CURSOR_IKA.bmp \
CURSOR/CURSOR_NORMAL.bmp \
- ICON/4.bmp \
ORG/ACCESS \
ORG/ANZEN \
ORG/BALCONY \
@@ -182,8 +181,16 @@
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)
@@ -210,6 +217,10 @@
@mkdir -p $(@D)
@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
binary files /dev/null b/res/ICON/0.ico differ
--- /dev/null
+++ b/res/ICON/ICON.rc
@@ -1,0 +1,2 @@
+101 ICON "0.ico"
+102 ICON "ICON_MINI.ico"
binary files /dev/null b/res/ICON/ICON_MINI.ico differ
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -102,7 +102,13 @@
//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 @@
{
printf("Failed to load cursor");
}
-
+
//Get window dimensions and colour depth
int colourDepth = 16;
@@ -285,6 +291,7 @@
if (CheckFileExists("fps"))
bFps = true;
+#ifndef WINDOWS
//Load icon
SDL_RWops *fp = FindResource("ICON4");
@@ -303,7 +310,8 @@
{
printf("Failed to load icon");
}
-
+#endif
+
//Set rects
RECT loading_rect = {0, 0, 64, 8};
RECT clip_rect = {0, 0, gWindowWidth, gWindowHeight};
--- 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,6 +393,7 @@
#endif
}
+#ifndef WINDOWS
//ICON
if (!strcmp(name, "ICON4"))
{
@@ -397,7 +400,8 @@
*size = sizeof(r4);
return r4;
}
-
+#endif
+
//CURSOR
if (!strcmp(name, "CURSOR_NORMAL"))
{