gui: make resources type safe

- add string, int, color and resource loading helpers
- use typed resource classes, and some cleanup in loading code
- remove abstract GetResource() to enforce type safe access
- add height and width query methods to resources and use them
- minor cleanup
- simplify LoadPlacement

Change-Id: I9b81785109a80b3806ad6b50cba4d893b87b0db1
diff --git a/gui/resources.hpp b/gui/resources.hpp
index cc5e7b6..69d2427 100644
--- a/gui/resources.hpp
+++ b/gui/resources.hpp
@@ -17,8 +17,8 @@
 	virtual ~Resource() {}
 
 public:
-	virtual void* GetResource(void) = 0;
-	std::string GetName(void) { return mName; }
+	std::string GetName() { return mName; }
+	virtual bool loadedOK() = 0;
 
 private:
 	std::string mName;
@@ -44,7 +44,10 @@
 	virtual ~FontResource();
 
 public:
-	virtual void* GetResource(void) { return mFont; }
+	void* GetResource() { return this ? mFont : NULL; }
+	int GetHeight() { return gr_getMaxFontHeight(this ? mFont : NULL); }
+
+	virtual bool loadedOK() { return mFont != NULL; }
 
 protected:
 	void* mFont;
@@ -58,7 +61,11 @@
 	virtual ~ImageResource();
 
 public:
-	virtual void* GetResource(void) { return mSurface; }
+	gr_surface GetResource() { return this ? mSurface : NULL; }
+	int GetWidth() { return gr_get_width(this ? mSurface : NULL); }
+	int GetHeight() { return gr_get_height(this ? mSurface : NULL); }
+
+	virtual bool loadedOK() { return mSurface != NULL; }
 
 protected:
 	gr_surface mSurface;
@@ -71,9 +78,12 @@
 	virtual ~AnimationResource();
 
 public:
-	virtual void* GetResource(void) { return mSurfaces.empty() ? NULL : mSurfaces.at(0); }
-	virtual void* GetResource(int entry) { return mSurfaces.empty() ? NULL : mSurfaces.at(entry); }
-	virtual int GetResourceCount(void) { return mSurfaces.size(); }
+	gr_surface GetResource() { return (!this || mSurfaces.empty()) ? NULL : mSurfaces.at(0); }
+	gr_surface GetResource(int entry) { return (!this || mSurfaces.empty()) ? NULL : mSurfaces.at(entry); }
+	int GetWidth() { return gr_get_width(this ? GetResource() : NULL); }
+	int GetHeight() { return gr_get_height(this ? GetResource() : NULL); }
+	int GetResourceCount() { return mSurfaces.size(); }
+	virtual bool loadedOK() { return !mSurfaces.empty(); }
 
 protected:
 	std::vector<gr_surface> mSurfaces;