1 /*
2  * Copyright (c) 2006 - 2008
3  * Wandering Monster Studios Limited
4  *
5  * Any use of this program is governed by the terms of Wandering Monster
6  * Studios Limited's Licence Agreement included with this program, a copy
7  * of which can be obtained by contacting Wandering Monster Studios
8  * Limited at info@wanderingmonster.co.nz.
9  *
10  */
11 
12 #include "HighScoresShipFormatter.h"
13 #include <Rocket/Core/TypeConverter.h>
14 
HighScoresShipFormatter()15 HighScoresShipFormatter::HighScoresShipFormatter() : Rocket::Controls::DataFormatter("ship")
16 {
17 }
18 
~HighScoresShipFormatter()19 HighScoresShipFormatter::~HighScoresShipFormatter()
20 {
21 }
22 
FormatData(Rocket::Core::String & formatted_data,const Rocket::Core::StringList & raw_data)23 void HighScoresShipFormatter::FormatData(Rocket::Core::String& formatted_data, const Rocket::Core::StringList& raw_data)
24 {
25 	// Data format:
26 	// raw_data[0] is the colour, in "%d, %d, %d, %d" format.
27 
28 	Rocket::Core::Colourb ship_colour;
29 	Rocket::Core::TypeConverter< Rocket::Core::String, Rocket::Core::Colourb >::Convert(raw_data[0], ship_colour);
30 
31 	Rocket::Core::String colour_string(32, "%d,%d,%d", ship_colour.red, ship_colour.green, ship_colour.blue);
32 
33 	formatted_data = "<defender style=\"color: rgb(" + colour_string + ");\" />";
34 }
35