← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~gamag/widelands/SimpleEvictWorkerButton into lp:widelands

 

Gabriel Margiani has proposed merging lp:~gamag/widelands/SimpleEvictWorkerButton into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~gamag/widelands/SimpleEvictWorkerButton/+merge/146268

Again a new evict worker button.
But this one only sends selected workers away from productionsites and seems to work.
-- 
https://code.launchpad.net/~gamag/widelands/SimpleEvictWorkerButton/+merge/146268
Your team Widelands Developers is requested to review the proposed merge of lp:~gamag/widelands/SimpleEvictWorkerButton into lp:widelands.
=== modified file 'src/logic/productionsite.cc'
--- src/logic/productionsite.cc	2012-12-15 12:04:36 +0000
+++ src/logic/productionsite.cc	2013-02-02 15:26:25 +0000
@@ -590,6 +590,9 @@
 {
 	Building::act(game, data);
 
+	if (!can_start_working())
+		return;
+
 	if
 		(m_program_timer
 		 and

=== modified file 'src/wui/productionsitewindow.cc'
--- src/wui/productionsitewindow.cc	2012-12-13 10:41:22 +0000
+++ src/wui/productionsitewindow.cc	2013-02-02 15:26:25 +0000
@@ -70,7 +70,11 @@
 	if (!productionsite().descr().nr_working_positions()) {
 		m_worker_table = 0;
 	} else {
-		m_worker_table = new UI::Table<uintptr_t>(get_tabs(), 0, 0, 0, 100);
+		UI::Box * worker_box = new UI::Box
+			(get_tabs(),
+			 0, 0, UI::Box::Vertical);
+		m_worker_table = new UI::Table<uintptr_t>(worker_box, 0, 0, 0, 100);
+		m_worker_caps = new UI::Box(worker_box, 0, 0, UI::Box::Horizontal);
 
 		m_worker_table->add_column(150, _("Worker"));
 		m_worker_table->add_column(40, _("Exp"));
@@ -81,9 +85,20 @@
 			 i < productionsite().descr().nr_working_positions(); ++i)
 			m_worker_table->add(i);
 
+		m_worker_caps->add_inf_space();
+		UI::Button * evict_button = new UI::Button
+						(m_worker_caps, "evict", 0, 0, 34, 34,
+						 g_gr->imgcache().load(PicMod_UI, "pics/but4.png"),
+						 g_gr->imgcache().load(PicMod_Game, "pics/menu_drop_soldier.png"),
+						 _("Terminate the empoyment of the selected worker"));
+		evict_button->sigclicked.connect(boost::bind(&ProductionSite_Window::evict_worker, boost::ref(*this)));
+		m_worker_caps->add(evict_button, UI::Box::AlignCenter);
+
+		worker_box->add(m_worker_table, UI::Box::AlignLeft, true);
+		worker_box->add(m_worker_caps, UI::Box::AlignLeft, true);
 		get_tabs()->add
 			("workers", g_gr->imgcache().load(PicMod_UI, pic_tab_workers),
-			 m_worker_table,
+			 worker_box,
 			 productionsite().descr().nr_working_positions() > 1 ?
 			 _("Workers") : _("Worker"));
 	}
@@ -160,3 +175,14 @@
 {
 	new ProductionSite_Window(parent, *this, registry);
 }
+
+void ProductionSite_Window::evict_worker() {
+	if (m_worker_table->has_selection()) {
+		Widelands::Worker * worker =
+			productionsite().working_positions()[m_worker_table->get_selected()].worker;
+		if (worker) {
+			worker->reset_tasks(igbase().game());
+			worker->start_task_gowarehouse(igbase().game());
+		}
+	}
+}

=== modified file 'src/wui/productionsitewindow.h'
--- src/wui/productionsitewindow.h	2012-02-15 21:25:34 +0000
+++ src/wui/productionsitewindow.h	2013-02-02 15:26:25 +0000
@@ -36,9 +36,11 @@
 
 protected:
 	virtual void think();
+	void evict_worker();
 
 private:
 	UI::Table<uintptr_t> * m_worker_table;
+	UI::Box * m_worker_caps;
 };
 
 #endif // _PRODUCTIONSITEWINDOW_H_