← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/inputwarequeue_display into lp:widelands

 

Benedikt Straub has proposed merging lp:~widelands-dev/widelands/inputwarequeue_display into lp:widelands.

Commit message:
Missing wares (and workers) are indicated differently in InputQueueDisplays if the ware is on the way to the building than if it's really missing

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1781732 in widelands: "Show missing wares differently if ware is on the way"
  https://bugs.launchpad.net/widelands/+bug/1781732

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/inputwarequeue_display/+merge/350385
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/inputwarequeue_display into lp:widelands.
=== modified file 'src/economy/input_queue.cc'
--- src/economy/input_queue.cc	2018-04-07 16:59:00 +0000
+++ src/economy/input_queue.cc	2018-07-21 16:50:25 +0000
@@ -120,6 +120,20 @@
 	update();
 }
 
+uint32_t InputQueue::get_coming() const {
+	if (request_ == nullptr || !request_->is_open()) {
+		return 0;
+	}
+	return request_->get_num_transfers();
+}
+
+uint32_t InputQueue::get_missing() const {
+	if (request_ == nullptr || !request_->is_open()) {
+		return 0;
+	}
+	return request_->get_open_count();
+}
+
 constexpr uint16_t kCurrentPacketVersion = 3;
 
 void InputQueue::read(FileRead& fr, Game& game, MapObjectLoader& mol) {

=== modified file 'src/economy/input_queue.h'
--- src/economy/input_queue.h	2018-04-07 16:59:00 +0000
+++ src/economy/input_queue.h	2018-07-21 16:50:25 +0000
@@ -102,6 +102,22 @@
 	virtual Quantity get_filled() const = 0;
 
 	/**
+	 * The amount of missing wares or workers which are currently being transported to this building.
+	 * This might temporarily be larger than get_max_fill() but will
+	 * be smaller than get_max_size().
+	 * @return The amount at this moment.
+	 */
+	uint32_t get_coming() const;
+
+	/**
+	 * The amount of missing wares or workers which are not currently being transported to this building.
+	 * This might temporarily be larger than get_max_fill() but will
+	 * be smaller than get_max_size().
+	 * @return The amount at this moment.
+	 */
+	uint32_t get_missing() const;
+
+	/**
 	 * Clear the queue appropriately.
 	 * Implementing classes should call update() at the end to remove the request.
 	 */

=== modified file 'src/wui/inputqueuedisplay.cc'
--- src/wui/inputqueuedisplay.cc	2018-04-27 06:11:05 +0000
+++ src/wui/inputqueuedisplay.cc	2018-07-21 16:50:25 +0000
@@ -129,7 +129,8 @@
 	cache_max_fill_ = queue_->get_max_fill();
 
 	uint32_t nr_inputs_to_draw = std::min(queue_->get_filled(), cache_size_);
-	uint32_t nr_empty_to_draw = cache_size_ - nr_inputs_to_draw;
+	uint32_t nr_missing_to_draw = std::min(queue_->get_missing(), cache_size_ - nr_inputs_to_draw);
+	uint32_t nr_coming_to_draw = cache_size_ - nr_inputs_to_draw - nr_missing_to_draw;
 
 	Vector2i point = Vector2i::zero();
 	point.x = Border + (show_only_ ? 0 : CellWidth + CellSpacing);
@@ -139,10 +140,15 @@
 		dst.blitrect(Vector2i(point.x, point.y), icon_, Recti(0, 0, icon_->width(), icon_->height()),
 		             BlendMode::UseAlpha);
 	}
-	for (; nr_empty_to_draw; --nr_empty_to_draw, point.x += CellWidth + CellSpacing) {
-		dst.blitrect_scale_monochrome(Rectf(point.x, point.y, icon_->width(), icon_->height()), icon_,
-		                              Recti(0, 0, icon_->width(), icon_->height()),
-		                              RGBAColor(166, 166, 166, 127));
+	for (; nr_coming_to_draw; --nr_coming_to_draw, point.x += CellWidth + CellSpacing) {
+		dst.blitrect_scale_monochrome(Rectf(point.x, point.y, icon_->width(), icon_->height()), icon_,
+		                              Recti(0, 0, icon_->width(), icon_->height()),
+		                              RGBAColor(127, 127, 127, 191));
+	}
+	for (; nr_missing_to_draw; --nr_missing_to_draw, point.x += CellWidth + CellSpacing) {
+		dst.blitrect_scale_monochrome(Rectf(point.x, point.y, icon_->width(), icon_->height()), icon_,
+		                              Recti(0, 0, icon_->width(), icon_->height()),
+		                              RGBAColor(191, 191, 191, 63));
 	}
 
 	if (!show_only_) {


Follow ups