From 7413c3d9940aa9d7c51de93d2a07c2e5167962c9 Mon Sep 17 00:00:00 2001
From: David Salvisberg <dave@portablegaming.de>
Date: Sat, 27 Dec 2014 14:40:08 +0100
Subject: [PATCH 1/4] Make button config menu save changes to disk whenever the
 changes are accepted.

---
 src/settingsmenu.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/settingsmenu.cpp b/src/settingsmenu.cpp
index ad3b9fd..a734ffa 100644
--- a/src/settingsmenu.cpp
+++ b/src/settingsmenu.cpp
@@ -678,6 +678,9 @@ struct SettingsMenuPrivate
 
 		rtData.bindingUpdateMsg.post(binds);
 
+		/* Store the key bindings to disk as well to prevent config loss */
+		storeBindings(binds, rtData.config);
+
 		destroyReq = true;
 	}
 
-- 
2.43.0


From 6829ddc09f88bf34bc893f3af769ed08d748e154 Mon Sep 17 00:00:00 2001
From: David Salvisberg <dave@portablegaming.de>
Date: Sun, 28 Dec 2014 06:06:28 +0100
Subject: [PATCH 2/4] Removed store keybindings from main, since it now already
 gets stored onAccept.

---
 src/main.cpp | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp
index 6185e58..bdcd7ad 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -321,11 +321,6 @@ int main(int argc, char *argv[])
 	/* Clean up any remainin events */
 	eventThread.cleanup();
 
-	/* Store key bindings */
-	BDescVec keyBinds;
-	rtData.bindingUpdateMsg.get(keyBinds);
-	storeBindings(keyBinds, rtData.config);
-
 	Debug() << "Shutting down.";
 
 	SDL_DestroyWindow(win);
-- 
2.43.0


From b1e1d288795ed0d654cf71f656dfa8ed00fcf665 Mon Sep 17 00:00:00 2001
From: David Salvisberg <dave@portablegaming.de>
Date: Wed, 31 Dec 2014 13:49:18 +0100
Subject: [PATCH 3/4] Added rudimentary support for font outlines.

---
 src/bitmap.cpp | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/bitmap.cpp b/src/bitmap.cpp
index fa499ad..37b3984 100644
--- a/src/bitmap.cpp
+++ b/src/bitmap.cpp
@@ -51,6 +51,8 @@
                             "Operation not supported for mega surfaces"); \
 	}
 
+#define OUTLINE_SIZE 1
+
 /* Normalize (= ensure width and
  * height are positive) */
 static IntRect normalizedRect(const IntRect &rect)
@@ -942,6 +944,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
 
 	TTF_Font *font = p->font->getSdlFont();
 	const Color &fontColor = p->font->getColor();
+	const Color &outColor = p->font->getOutColor();
 
 	SDL_Color c = fontColor.toSDLColor();
 	c.a = 255;
@@ -957,11 +960,33 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
 
 	p->ensureFormat(txtSurf, SDL_PIXELFORMAT_ABGR8888);
 
-	// While real outlining is not yet here, use shadow
-	// as a replacement to at least make text legible
-	if (p->font->getShadow() || p->font->getOutline())
+	if (p->font->getShadow())
 		applyShadow(txtSurf, *p->format, c);
 
+	/* outline using TTF_Outline and blending it together with SDL_BlitSurface
+	 * FIXME: outline is forced to have the same opacity as the font color */
+	if (p->font->getOutline()) {
+		SDL_Color co = outColor.toSDLColor();
+		co.a = 255;
+		SDL_Surface *outline;
+		/* set the next font render to render the outline */
+		TTF_SetFontOutline(font, OUTLINE_SIZE);
+		if (shState->rtData().config.solidFonts)
+			outline = TTF_RenderUTF8_Solid(font, str, co);
+		else
+			outline = TTF_RenderUTF8_Blended(font, str, co);
+
+		p->ensureFormat(outline, SDL_PIXELFORMAT_ABGR8888);
+		SDL_Rect outRect = {OUTLINE_SIZE, OUTLINE_SIZE, txtSurf->w, txtSurf->h}; 
+
+		SDL_SetSurfaceBlendMode(txtSurf, SDL_BLENDMODE_BLEND);
+		SDL_BlitSurface(txtSurf, NULL, outline, &outRect);
+		SDL_FreeSurface(txtSurf);
+		txtSurf = outline;
+		/* reset outline to 0 */
+		TTF_SetFontOutline(font, 0);
+	}
+
 	int alignX = rect.x;
 
 	switch (align)
-- 
2.43.0


From 8240f3333f6b0198cd1f9dd171f128d204c3eec7 Mon Sep 17 00:00:00 2001
From: David Salvisberg <dave@portablegaming.de>
Date: Wed, 31 Dec 2014 16:02:10 +0100
Subject: [PATCH 4/4] Fixed hue shader turning pure white pixel to pure black
 on some GPUs.

---
 shader/hue.frag | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/shader/hue.frag b/shader/hue.frag
index 416ee9b..405c91b 100644
--- a/shader/hue.frag
+++ b/shader/hue.frag
@@ -29,7 +29,11 @@ void main ()
 	/* Make the user's adjustments */
 	hue += hueAdjust;
 
-	// Convert back to YIQ
+	/* Remember old I and color */
+	float IOriginal = I;
+	vec4 coOriginal = color;
+
+	/* Convert back to YIQ */
 	Q = chroma * sin (hue);
 	I = chroma * cos (hue);
 
@@ -40,5 +44,5 @@ void main ()
 	color.b  = dot  (yIQ, kYIQToB);
 
 	/* Save the result */
-	gl_FragColor = color;
+	gl_FragColor = (IOriginal == 0.0) ? coOriginal : color;
 }
-- 
2.43.0