← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~mxsscott/widelands/1096786 into lp:widelands

 

Mark Scott has proposed merging lp:~mxsscott/widelands/1096786 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1096786 in widelands: "Indicate direction of steepness in road building mode"
  https://bugs.launchpad.net/widelands/+bug/1096786

For more details, see:
https://code.launchpad.net/~mxsscott/widelands/1096786/+merge/142182

Indicate direction of steepness of proposed road building - uphill or downhill.

See commit message for a detailed change description.

Adds two new images to the pics/ folder, which are direct horizontal flips of the existing road steepness indicators.
-- 
https://code.launchpad.net/~mxsscott/widelands/1096786/+merge/142182
Your team Widelands Developers is requested to review the proposed merge of lp:~mxsscott/widelands/1096786 into lp:widelands.
=== added file 'pics/roadb_reddown.png'
Binary files pics/roadb_reddown.png	1970-01-01 00:00:00 +0000 and pics/roadb_reddown.png	2013-01-07 19:43:25 +0000 differ
=== added file 'pics/roadb_yellowdown.png'
Binary files pics/roadb_yellowdown.png	1970-01-01 00:00:00 +0000 and pics/roadb_yellowdown.png	2013-01-07 19:43:25 +0000 differ
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc	2012-12-16 14:29:46 +0000
+++ src/wui/interactive_base.cc	2013-01-07 19:43:25 +0000
@@ -810,26 +810,28 @@
 		if (m_buildroad->get_index(neighb) >= 0)
 			continue; // the road can't cross itself
 
-		int32_t const slope =
-			abs(endpos.field->get_height() - neighb.field->get_height());
-		int32_t icon;
-
-		if (slope < 2)
-			icon = 1;
+		int32_t slope;
+
+		if
+			(Widelands::WALK_E == dir
+			 || Widelands::WALK_NE == dir
+			 || Widelands::WALK_SE == dir)
+			slope = neighb.field->get_height() - endpos.field->get_height();
+		else
+			slope = endpos.field->get_height() - neighb.field->get_height();
+
+		const char * name = 0;
+
+		if (slope <= -4)
+			name = "pics/roadb_reddown.png";
+		else if (slope <= -2)
+			name = "pics/roadb_yellowdown.png";
+		else if (slope < 2)
+			name = "pics/roadb_green.png";
 		else if (slope < 4)
-			icon = 2;
+			name = "pics/roadb_yellow.png";
 		else
-			icon = 3;
-
-		char const * name;
-		switch (icon) {
-		case 1: name = "pics/roadb_green.png";  break;
-		case 2: name = "pics/roadb_yellow.png"; break;
-		case 3: name = "pics/roadb_red.png";    break;
-		default:
-			assert(false);
-			break;
-		}
+			name = "pics/roadb_red.png";
 
 		egbase().map().overlay_manager().register_overlay
 			(neighb,