From 36bffb1754deb18b223a3206daa2478568675909 Mon Sep 17 00:00:00 2001
From: Sam Moore <matches@ucc.asn.au>
Date: Sat, 28 Apr 2012 17:15:40 +0800
Subject: [PATCH] Updated graphics to for displaying on the clubroom projector

sulix: Oh dear god, my eyes, my eyes

Preliminary Round 1 starts at 6:00pm tonight... for anyone who actually reads this.

[SZM]
---
 judge/manager/game.cpp     | 16 ++++++++++++++--
 judge/manager/graphics.h   |  2 ++
 judge/manager/stratego.cpp | 13 +++++++------
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/judge/manager/game.cpp b/judge/manager/game.cpp
index c1238f0..f50ce27 100644
--- a/judge/manager/game.cpp
+++ b/judge/manager/game.cpp
@@ -1,5 +1,7 @@
 #include "game.h"
 #include <stdarg.h>
+#include <string>
+
 using namespace std;
 
 
@@ -22,7 +24,13 @@ Game::Game(const char * redPath, const char * bluePath, const bool enableGraphic
 
 	#ifdef BUILD_GRAPHICS
 	if (graphicsEnabled && (!Graphics::Initialised()))
-			Graphics::Initialise("Stratego", theBoard.Width()*32, theBoard.Height()*32);
+	{
+			string s = "Stratego: ";
+			s += string(redPath);
+			s += " ";
+			s += string(bluePath);
+			Graphics::Initialise(s.c_str(), theBoard.Width()*GRID_SIZE, theBoard.Height()*GRID_SIZE);
+	}
 	#endif //BUILD_GRAPHICS
 
 
@@ -60,7 +68,11 @@ Game::Game(const char * fromFile, const bool enableGraphics, double newStallTime
 
 	#ifdef BUILD_GRAPHICS
 	if (graphicsEnabled && (!Graphics::Initialised()))
-			Graphics::Initialise("Stratego", theBoard.Width()*32, theBoard.Height()*32);
+	{
+			string s = "Stratego: (file) ";
+			s += string(fromFile);
+			Graphics::Initialise(s.c_str(), theBoard.Width()*GRID_SIZE, theBoard.Height()*GRID_SIZE);
+	}
 	#endif //BUILD_GRAPHICS
 
 	input = fopen(fromFile, "r");
diff --git a/judge/manager/graphics.h b/judge/manager/graphics.h
index 89a44df..41dd7de 100644
--- a/judge/manager/graphics.h
+++ b/judge/manager/graphics.h
@@ -8,6 +8,8 @@
 #include <SDL/SDL.h>
 #include <SDL/SDL_opengl.h>
 
+#define GRID_SIZE 64.0
+
 typedef SDL_Surface Screen;
 typedef SDL_Rect Rectangle;
 typedef short unsigned int SUint;
diff --git a/judge/manager/stratego.cpp b/judge/manager/stratego.cpp
index c9716cf..0e299cb 100644
--- a/judge/manager/stratego.cpp
+++ b/judge/manager/stratego.cpp
@@ -234,7 +234,7 @@ void Board::Draw(const Piece::Colour & reveal, bool showRevealed)
 	}
 
 	Graphics::ClearScreen();
-	
+	float scale = (float)(Piece::textures[(int)(Piece::NOTHING)].width()) / (float)(GRID_SIZE);
 	for (int y=0; y < height; ++y)
 	{
 		for (int x=0; x < width; ++x)
@@ -249,7 +249,8 @@ void Board::Draw(const Piece::Colour & reveal, bool showRevealed)
 					|| (piece->beenRevealed && showRevealed))
 			{
 				//Display the piece
-				Piece::textures[(int)(piece->type)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+				
+				Piece::textures[(int)(piece->type)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
 				
 			}
 			else
@@ -257,16 +258,16 @@ void Board::Draw(const Piece::Colour & reveal, bool showRevealed)
 				switch (piece->colour)
 				{
 					case Piece::RED:
-						Piece::textures[(int)(Piece::NOTHING)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+						Piece::textures[(int)(Piece::NOTHING)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
 						break;
 					case Piece::BLUE:
-						Piece::textures[(int)(Piece::NOTHING)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+						Piece::textures[(int)(Piece::NOTHING)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
 						break;
 					case Piece::NONE:
-						Piece::textures[(int)(Piece::BOULDER)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+						Piece::textures[(int)(Piece::BOULDER)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
 						break;
 					case Piece::BOTH:
-						Piece::textures[(int)(Piece::BOULDER)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+						Piece::textures[(int)(Piece::BOULDER)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
 						break;
 				}
 			}
-- 
GitLab