← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~nomeata/widelands/bugfix668857 into lp:widelands

 

Joachim Breitner has proposed merging lp:~nomeata/widelands/bugfix668857 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  #668857 in spectator mode buttons in headquarters are missing
  https://bugs.launchpad.net/bugs/668857


This fixes the bug, although I doubt that it was caused by my changes.
Also another minor clean-up patch included in this branch.
-- 
https://code.launchpad.net/~nomeata/widelands/bugfix668857/+merge/39705
Your team Widelands Developers is requested to review the proposed merge of lp:~nomeata/widelands/bugfix668857 into lp:widelands.
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc	2010-10-17 19:42:01 +0000
+++ src/wui/buildingwindow.cc	2010-10-31 11:22:46 +0000
@@ -55,6 +55,7 @@
 	m_capscache_player_number = 0;
 	m_capsbuttons = 0;
 	m_capscache = 0;
+	m_caps_setup = false;
 	m_toggle_workarea = 0;
 
 	UI::Box* vbox = new UI::Box(this, 0, 0, UI::Box::Vertical);
@@ -117,13 +118,16 @@
 		die();
 
 	if
-		(m_capscache_player_number != igbase().player_number()
+		(! m_caps_setup
+		 or
+		 m_capscache_player_number != igbase().player_number()
 		 or
 		 building().get_playercaps() != m_capscache) {
 		m_capsbuttons->free_children();
 		create_capsbuttons(m_capsbuttons);
 		move_out_of_the_way();
 		warp_mouse_to_fastclick_panel();
+		m_caps_setup = true;
 	}
 
 

=== modified file 'src/wui/buildingwindow.h'
--- src/wui/buildingwindow.h	2010-10-17 19:42:01 +0000
+++ src/wui/buildingwindow.h	2010-10-31 11:22:46 +0000
@@ -82,6 +82,7 @@
 	//  capabilities that were last used in setting up the caps panel
 	uint32_t m_capscache;
 	Widelands::Player_Number m_capscache_player_number;
+	bool m_caps_setup;
 
 	Overlay_Manager::Job_Id m_workarea_job_id;
 	PictureID workarea_cumulative_picid[NUMBER_OF_WORKAREA_PICS];

=== modified file 'src/wui/warehousewindow.cc'
--- src/wui/warehousewindow.cc	2010-10-30 14:43:32 +0000
+++ src/wui/warehousewindow.cc	2010-10-31 11:22:46 +0000
@@ -38,7 +38,7 @@
  * Extends the wares display to show and modify stock policy of items.
  */
 struct WarehouseWaresDisplay : WaresDisplay {
-	WarehouseWaresDisplay(UI::Panel * parent, uint32_t width, Interactive_GameBase &, Warehouse &, wdType type);
+	WarehouseWaresDisplay(UI::Panel * parent, uint32_t width, Interactive_GameBase &, Warehouse &, wdType type, bool selectable);
 
 protected:
 	virtual void draw_ware(RenderTarget& dst, Widelands::Ware_Index ware);
@@ -49,9 +49,9 @@
 };
 
 WarehouseWaresDisplay::WarehouseWaresDisplay
-	(UI::Panel* parent, uint32_t width, Interactive_GameBase & igbase, Warehouse& wh, wdType type)
+	(UI::Panel* parent, uint32_t width, Interactive_GameBase & igbase, Warehouse& wh, wdType type, bool selectable)
 :
-WaresDisplay(parent, 0, 0, wh.owner().tribe(), type, true),
+WaresDisplay(parent, 0, 0, wh.owner().tribe(), type, selectable),
 m_igbase(igbase),
 m_warehouse(wh)
 {
@@ -86,26 +86,27 @@
 
 	void set_policy(Warehouse::StockPolicy);
 private:
-	WarehouseWaresDisplay m_display;
 	Interactive_GameBase & m_gb;
 	Warehouse & m_wh;
+	bool m_can_act;
 	WaresDisplay::wdType m_type;
-
+	WarehouseWaresDisplay m_display;
 };
 
 WarehouseWaresPanel::WarehouseWaresPanel(UI::Panel * parent, uint32_t width, Interactive_GameBase & gb, Warehouse & wh, WaresDisplay::wdType type) :
 	UI::Box(parent, 0, 0, UI::Box::Vertical),
-	m_display(this, width, gb, wh, type),
 	m_gb(gb),
 	m_wh(wh),
-	m_type(type)
+	m_can_act(m_gb.can_act(m_wh.owner().player_number())),
+	m_type(type),
+	m_display(this, width, m_gb, m_wh, m_type, m_can_act)
 {
 	add(&m_display, UI::Box::AlignLeft, true);
 
-	UI::Box *buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);
-	add(buttons, UI::Box::AlignLeft);
-		
-	if (m_gb.can_act(m_wh.owner().player_number())) {
+	if (m_can_act) {
+		UI::Box *buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);
+		add(buttons, UI::Box::AlignLeft);
+			
 #define ADD_POLICY_BUTTON(policy, policyname, tooltip)                    \
         	buttons->add(new UI::Callback_Button(                     \
 			buttons, #policy,                                 \
@@ -159,11 +160,6 @@
 	Warehouse & warehouse() {
 		return ref_cast<Warehouse, Widelands::Building>(building());
 	}
-
-private:
-	void make_wares_tab
-		(WaresDisplay::wdType type,
-		 PictureID tabicon, const std::string & tooltip);
 };
 
 /**
@@ -175,21 +171,26 @@
 	 UI::Window *         & registry)
 	: Building_Window(parent, wh, registry)
 {
-	make_wares_tab
-		(WaresDisplay::WARE, g_gr->get_picture(PicMod_UI, pic_tab_wares),
+	get_tabs()->add(
+		"wares",
+		g_gr->get_picture(PicMod_UI, pic_tab_wares),
+		new WarehouseWaresPanel(get_tabs(),
+			Width,
+			igbase(),
+			warehouse(),
+			WaresDisplay::WARE),
 		 _("Wares"));
-	make_wares_tab
-		(WaresDisplay::WORKER, g_gr->get_picture(PicMod_UI, pic_tab_workers),
+	get_tabs()->add(
+		"workers",
+		g_gr->get_picture(PicMod_UI, pic_tab_workers),
+		new WarehouseWaresPanel(get_tabs(),
+			Width,
+			igbase(),
+			warehouse(),
+			WaresDisplay::WORKER),
 		 _("Workers"));
 }
 
-void Warehouse_Window::make_wares_tab
-	(WaresDisplay::wdType type, PictureID tabicon, const std::string & tooltip)
-{
-	WarehouseWaresPanel * panel = new WarehouseWaresPanel(get_tabs(), Width, igbase(), warehouse(), type);
-	get_tabs()->add("wares", tabicon, panel, tooltip);
-}
-
 /**
  * Create the status window describing the warehouse.
  */


Follow ups