浏览代码

Update decorators in Invaders sample

Michael Ragazzon 6 年之前
父节点
当前提交
1416b0c3ab

+ 2 - 2
Samples/invaders/src/DecoratorInstancerDefender.cpp

@@ -32,7 +32,7 @@
 
 
 DecoratorInstancerDefender::DecoratorInstancerDefender()
 DecoratorInstancerDefender::DecoratorInstancerDefender()
 {
 {
-	RegisterProperty("image-src", "").AddParser("string");
+	id_image_src = RegisterProperty("image-src", "").AddParser("string").GetId();
 }
 }
 
 
 DecoratorInstancerDefender::~DecoratorInstancerDefender()
 DecoratorInstancerDefender::~DecoratorInstancerDefender()
@@ -44,7 +44,7 @@ Rocket::Core::Decorator* DecoratorInstancerDefender::InstanceDecorator(const Roc
 {
 {
 	ROCKET_UNUSED(name);
 	ROCKET_UNUSED(name);
 
 
-	const Rocket::Core::Property* image_source_property = properties.GetProperty("image-src");
+	const Rocket::Core::Property* image_source_property = properties.GetProperty(id_image_src);
 	Rocket::Core::String image_source = image_source_property->Get< Rocket::Core::String >();
 	Rocket::Core::String image_source = image_source_property->Get< Rocket::Core::String >();
 
 
 	DecoratorDefender* decorator = new DecoratorDefender();
 	DecoratorDefender* decorator = new DecoratorDefender();

+ 3 - 0
Samples/invaders/src/DecoratorInstancerDefender.h

@@ -51,6 +51,9 @@ public:
 
 
 	/// Releases the instancer.
 	/// Releases the instancer.
 	void Release();
 	void Release();
+
+private:
+	Rocket::Core::PropertyId id_image_src;
 };
 };
 
 
 #endif
 #endif

+ 14 - 14
Samples/invaders/src/DecoratorInstancerStarfield.cpp

@@ -31,13 +31,13 @@
 
 
 DecoratorInstancerStarfield::DecoratorInstancerStarfield()
 DecoratorInstancerStarfield::DecoratorInstancerStarfield()
 {
 {
-	RegisterProperty("num-layers", "3").AddParser("number");
-	RegisterProperty("top-colour", "#dddc").AddParser("color");
-	RegisterProperty("bottom-colour", "#333c").AddParser("color");
-	RegisterProperty("top-speed", "10.0").AddParser("number");
-	RegisterProperty("bottom-speed", "2.0").AddParser("number");
-	RegisterProperty("top-density", "15").AddParser("number");
-	RegisterProperty("bottom-density", "10").AddParser("number");
+	id_num_layers = RegisterProperty("num-layers", "3").AddParser("number").GetId();
+	id_top_colour = RegisterProperty("top-colour", "#dddc").AddParser("color").GetId();
+	id_bottom_colour = RegisterProperty("bottom-colour", "#333c").AddParser("color").GetId();
+	id_top_speed = RegisterProperty("top-speed", "10.0").AddParser("number").GetId();
+	id_bottom_speed = RegisterProperty("bottom-speed", "2.0").AddParser("number").GetId();
+	id_top_density = RegisterProperty("top-density", "15").AddParser("number").GetId();
+	id_bottom_density = RegisterProperty("bottom-density", "10").AddParser("number").GetId();
 }
 }
 
 
 DecoratorInstancerStarfield::~DecoratorInstancerStarfield()
 DecoratorInstancerStarfield::~DecoratorInstancerStarfield()
@@ -49,13 +49,13 @@ Rocket::Core::Decorator* DecoratorInstancerStarfield::InstanceDecorator(const Ro
 {
 {
 	ROCKET_UNUSED(name);
 	ROCKET_UNUSED(name);
 
 
-	int num_layers = Rocket::Core::Math::RealToInteger(properties.GetProperty("num-layers")->Get< float >());
-	Rocket::Core::Colourb top_colour = properties.GetProperty("top-colour")->Get< Rocket::Core::Colourb >();
-	Rocket::Core::Colourb bottom_colour = properties.GetProperty("bottom-colour")->Get< Rocket::Core::Colourb >();
-	float top_speed = properties.GetProperty("top-speed")->Get< float >();
-	float bottom_speed = properties.GetProperty("bottom-speed")->Get< float >();
-	int top_density = Rocket::Core::Math::RealToInteger(properties.GetProperty("top-density")->Get< float >());
-	int bottom_density = Rocket::Core::Math::RealToInteger(properties.GetProperty("bottom-density")->Get< float >());
+	int num_layers = Rocket::Core::Math::RealToInteger(properties.GetProperty(id_num_layers)->Get< float >());
+	Rocket::Core::Colourb top_colour = properties.GetProperty(id_top_colour)->Get< Rocket::Core::Colourb >();
+	Rocket::Core::Colourb bottom_colour = properties.GetProperty(id_bottom_colour)->Get< Rocket::Core::Colourb >();
+	float top_speed = properties.GetProperty(id_top_speed)->Get< float >();
+	float bottom_speed = properties.GetProperty(id_bottom_speed)->Get< float >();
+	int top_density = Rocket::Core::Math::RealToInteger(properties.GetProperty(id_top_density)->Get< float >());
+	int bottom_density = Rocket::Core::Math::RealToInteger(properties.GetProperty(id_bottom_density)->Get< float >());
 
 
 	DecoratorStarfield* decorator = new DecoratorStarfield();
 	DecoratorStarfield* decorator = new DecoratorStarfield();
 	if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density))
 	if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density))

+ 3 - 0
Samples/invaders/src/DecoratorInstancerStarfield.h

@@ -52,6 +52,9 @@ public:
 
 
 	/// Releases the instancer.
 	/// Releases the instancer.
 	void Release();
 	void Release();
+
+private:
+	Rocket::Core::PropertyId id_num_layers, id_top_colour, id_bottom_colour, id_top_speed, id_bottom_speed, id_top_density, id_bottom_density;
 };
 };
 
 
 #endif
 #endif