(svn r12402) -Fix: some toolbars didn't seem to show anymore.
authorrubidium
Mon, 24 Mar 2008 05:59:42 +0000
changeset 9222 7e175d5a9b4e
parent 9221 1168ec4e2ea4
child 9223 3512b3d48703
(svn r12402) -Fix: some toolbars didn't seem to show anymore.
src/main_gui.cpp
src/toolbar_gui.cpp
--- a/src/main_gui.cpp	Mon Mar 24 00:52:28 2008 +0000
+++ b/src/main_gui.cpp	Mon Mar 24 05:59:42 2008 +0000
@@ -523,14 +523,12 @@
 	if (_networking && WP(w, menu_d).main_button == 9) num++;
 
 	if (WP(w, menu_d).item_count != num) {
-		Point pos;
 		WP(w, menu_d).item_count = num;
 		SetWindowDirty(w);
 		num = num * 10 + 2;
 		w->height = num;
 		w->widget[0].bottom = w->widget[0].top + num - 1;
-		pos = GetToolbarDropdownPos(0, w->width, w->height);
-		w->top = pos.y;
+		w->top = GetToolbarDropdownPos(0, w->width, w->height).y;
 		SetWindowDirty(w);
 	}
 }
@@ -686,10 +684,6 @@
  * @return Return a pointer to the newly created dropdown window */
  Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask)
 {
-	int width;
-	int height;
-	Point pos;
-
 	assert(disabled_mask == 0 || item_count <= 8);
 	w->LowerWidget(parent_button);
 	w->InvalidateWidget(parent_button);
@@ -697,10 +691,10 @@
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
 
 	// Extend the dropdown toolbar to the longest string in the list
-	width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
-	height = item_count * 10 + 2;
+	int width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
+	int height = item_count * 10 + 2;
 
-	pos = GetToolbarDropdownPos(parent_button, width, height);
+	Point pos = GetToolbarDropdownPos(parent_button, width, height);
 
 	w = AllocateWindow(pos.x, pos.y, width, height, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
 	w->widget[0].bottom = item_count * 10 + 1;
@@ -722,13 +716,11 @@
 
 Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray)
 {
-	Point pos;;
-
 	w->LowerWidget(main_button);
 	w->InvalidateWidget(main_button);
 
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
-	pos = GetToolbarDropdownPos(main_button, 241, 82);
+	Point pos = GetToolbarDropdownPos(main_button, 241, 82);
 	w = AllocateWindow(pos.x, pos.y, 241, 82, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
 	w->flags4 &= ~WF_WHITE_BORDER_MASK;
 	WP(w, menu_d).item_count = 0;
--- a/src/toolbar_gui.cpp	Mon Mar 24 00:52:28 2008 +0000
+++ b/src/toolbar_gui.cpp	Mon Mar 24 05:59:42 2008 +0000
@@ -45,12 +45,11 @@
  * the default position is aligned with the left side of the clicked button */
 Point GetToolbarDropdownPos(uint16 parent_button, int width, int height)
 {
-	Window *w = FindWindowById(WC_MAIN_TOOLBAR,0);
+	const Window *w = FindWindowById(WC_MAIN_TOOLBAR,0);
 	Point pos;
-	pos.x =  w->widget[GB(parent_button, 0, 8)].left;
-	pos.y = -height;
+	pos.x = w->widget[GB(parent_button, 0, 8)].left;
 	pos.x = w->left + Clamp(pos.x, 0, w->width - width);
-	pos.y = w->top + pos.y;
+	pos.y = w->height;
 
 	return pos;
 }