<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39324 >

> [EMAIL PROTECTED] - Mi 04. Apr 2007, 21:34:31]:
> 
> -The dialogue for selling all of a certain improvement isn't destroyed
> when an option is selected
> - The dialogue for buying a unit isn't destroyed when buying isn't
> allowed (due to a city being in disorder) until the city dialogue 
> itself is closed
>

Here's a patch for these two problems.

Index: client/gui-sdl/citydlg.c
===================================================================
--- client/gui-sdl/citydlg.c	(Revision 12916)
+++ client/gui-sdl/citydlg.c	(Arbeitskopie)
@@ -1071,19 +1071,21 @@
 static int ok_buy_prod_city_dlg_callback(struct widget *pButton)
 {
   if (Main.event.button.button == SDL_BUTTON_LEFT) {
+    popdown_hurry_production_dialog();
+
     city_buy_production(pButton->data.city);
     
-    if (pCityDlg)
-    {
-      popdown_window_group_dialog(pHurry_Prod_Dlg->pBeginWidgetList,
-                                  pHurry_Prod_Dlg->pEndWidgetList);
-      FC_FREE(pHurry_Prod_Dlg);
+    if (pCityDlg) {
       /* enable city dlg */
       enable_city_dlg_widgets();
+      
+      /* disable buy button */
       set_wstate(pCityDlg->pBuy_Button, FC_WS_DISABLED);
-    } else {
-      popdown_hurry_production_dialog();
+      widget_redraw(pCityDlg->pBuy_Button);
+      widget_mark_dirty(pCityDlg->pBuy_Button);
+      flush_dirty();
     }
+    
   }    
   return -1;
 }
@@ -1109,7 +1111,7 @@
 {
   if (pHurry_Prod_Dlg) {
     popdown_window_group_dialog(pHurry_Prod_Dlg->pBeginWidgetList,
-			      pHurry_Prod_Dlg->pEndWidgetList);
+                                pHurry_Prod_Dlg->pEndWidgetList);
     FC_FREE(pHurry_Prod_Dlg);
     flush_dirty();
   }
@@ -1155,7 +1157,7 @@
   }
 
   value = city_buy_cost(pCity);
-  if(!pCity->did_buy) {
+  if (city_can_buy(pCity)) {
     if (game.player_ptr->economic.gold >= value) {
       my_snprintf(cBuf, sizeof(cBuf),
 		_("Buy %s for %d gold?\n"
@@ -1168,8 +1170,13 @@
 		name, value, game.player_ptr->economic.gold);
     }
   } else {
-    my_snprintf(cBuf, sizeof(cBuf),
-		_("Sorry, You have already bought here in this turn"));
+    if (pCity->did_buy) {
+      my_snprintf(cBuf, sizeof(cBuf),
+                  _("Sorry, You have already bought here in this turn."));
+    } else {
+      my_snprintf(cBuf, sizeof(cBuf),
+                  _("Sorry, You can't buy here in this turn."));
+    }
   }
 
   pStr = create_str16_from_char(_("Buy It?"), adj_font(12));
@@ -1207,7 +1214,7 @@
 
   add_to_gui_list(ID_BUTTON, pBuf);
 
-  if (!pCity->did_buy && game.player_ptr->economic.gold >= value) {
+  if (city_can_buy(pCity) && game.player_ptr->economic.gold >= value) {
     pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pWindow->dst,
 					      _("Yes"), adj_font(12), 0);
 
@@ -1278,7 +1285,7 @@
   pBuf = pWindow->prev;
   pBuf->size.y = dst.y;
   
-  if (!pCity->did_buy && game.player_ptr->economic.gold >= value) {
+  if (city_can_buy(pCity) && game.player_ptr->economic.gold >= value) {
     /* yes */
     pBuf = pBuf->prev;
     pBuf->size.x = area.x + (area.w - (2 * pBuf->size.w + adj_size(20))) / 2;
@@ -1512,7 +1519,7 @@
       }
     }
   
-    if (pCityDlg->pCity->did_buy && pCityDlg->pBuy_Button) {
+    if (!city_can_buy(pCityDlg->pCity) && pCityDlg->pBuy_Button) {
       set_wstate(pCityDlg->pBuy_Button, FC_WS_DISABLED);
     }
 
@@ -3237,7 +3244,7 @@
 
     } else {
 
-      if (!pCity->did_buy && pCityDlg->pBuy_Button
+      if (city_can_buy(pCity) && pCityDlg->pBuy_Button
 	 && (get_wstate(pCityDlg->pBuy_Button) == FC_WS_DISABLED)) {
 	set_wstate(pCityDlg->pBuy_Button, FC_WS_NORMAL);
 	widget_redraw(pCityDlg->pBuy_Button);
@@ -3815,7 +3822,7 @@
   pBuf->size.y = area.y + area.h - pBuf->size.h - adj_size(5);
   pCityDlg->pBuy_Button = pBuf;
   pBuf->key = SDLK_h;
-  if ((pOwner == game.player_ptr) && (!pCity->did_buy)) {
+  if (city_can_buy(pCity)) {
     set_wstate(pBuf, FC_WS_NORMAL);
   }
   add_to_gui_list(ID_CITY_DLG_PROD_BUY_BUTTON, pBuf);
Index: client/gui-sdl/repodlgs.c
===================================================================
--- client/gui-sdl/repodlgs.c	(Revision 12916)
+++ client/gui-sdl/repodlgs.c	(Arbeitskopie)
@@ -1414,7 +1414,7 @@
     total_count = pImpr->data.cont->id1;
     
     /* popdown sell dlg */
-    del_group_of_widgets_from_gui_list(pEconomy_Sell_Dlg->pBeginWidgetList,
+    popdown_window_group_dialog(pEconomy_Sell_Dlg->pBeginWidgetList,
                                 pEconomy_Sell_Dlg->pEndWidgetList);
     FC_FREE(pEconomy_Sell_Dlg);
     enable_economy_dlg();
@@ -1496,12 +1496,12 @@
     if(count > 0) {
       my_snprintf(cBuf, sizeof(cBuf),
       _("We have %d of %s\n(total value is : %d)\n"
-          "We can sell %d of them for %d gold"),
+          "We can sell %d of them for %d gold."),
               total_count, get_improvement_name(imp),
                               total_count * value, count, gold); 
     } else {
       my_snprintf(cBuf, sizeof(cBuf),
-          _("We can't sell any %s in this turn"), get_improvement_name(imp)); 
+          _("We can't sell any %s in this turn."), get_improvement_name(imp)); 
     }
     
     
@@ -1595,7 +1595,7 @@
       pBuf->next->size.x = pBuf->size.x + pBuf->size.w + adj_size(10);
     } else {
       /* x position of cancel button */
-      pBuf->size.x = area.x + area.w - adj_size(10);
+      pBuf->size.x = area.x + area.w - adj_size(10) - pBuf->size.w;
     }
     
     
Index: client/gui-sdl/cityrep.c
===================================================================
--- client/gui-sdl/cityrep.c	(Revision 12916)
+++ client/gui-sdl/cityrep.c	(Arbeitskopie)
@@ -555,7 +555,7 @@
     add_to_gui_list(MAX_ID - pCity->id, pBuf);
     pBuf->data.city = pCity;
     pBuf->action = popup_buy_production_from_city_report_callback;
-    if (!pCity->did_buy) {
+    if (city_can_buy(pCity)) {
       set_wstate(pBuf, FC_WS_NORMAL);    
     }
     
Index: client/gui-sdl/widget_scrollbar.c
===================================================================
--- client/gui-sdl/widget_scrollbar.c	(Revision 12916)
+++ client/gui-sdl/widget_scrollbar.c	(Arbeitskopie)
@@ -1356,43 +1356,32 @@
   struct widget *pBuf = pWidget;
   assert(pWidget != NULL);
   assert(pDlg != NULL);
-
+  
   /* if begin == end -> size = 1 */
   if (pDlg->pBeginActiveWidgetList == pDlg->pEndActiveWidgetList) {
     
     if(pDlg->pScroll) {
       pDlg->pScroll->count = 0;
-
-      if(!pDlg->pScroll->pUp_Left_Button && 
-	 !pDlg->pScroll->pScrollBar &&
-         !pDlg->pScroll->pDown_Right_Button) {
-        pDlg->pBeginWidgetList = NULL;
-        pDlg->pEndWidgetList = NULL;
-      }
-      
-      if(pDlg->pBeginActiveWidgetList == pDlg->pBeginWidgetList) {
-	pDlg->pBeginWidgetList = pDlg->pBeginWidgetList->next;
-      }
-      
-      if(pDlg->pEndActiveWidgetList == pDlg->pEndWidgetList) {
-	pDlg->pEndWidgetList = pDlg->pEndWidgetList->prev;
-      }
-      
-      pDlg->pBeginActiveWidgetList = NULL;
-      pDlg->pActiveWidgetList = NULL;
-      pDlg->pEndActiveWidgetList = NULL;
-      
-    } else {
-      pDlg->pBeginWidgetList = NULL;
-      pDlg->pEndWidgetList = NULL;
     }
     
+    if(pDlg->pBeginActiveWidgetList == pDlg->pBeginWidgetList) {
+      pDlg->pBeginWidgetList = pDlg->pBeginWidgetList->next;
+    }
+    
+    if(pDlg->pEndActiveWidgetList == pDlg->pEndWidgetList) {
+      pDlg->pEndWidgetList = pDlg->pEndWidgetList->prev;
+    }
+    
+    pDlg->pBeginActiveWidgetList = NULL;
+    pDlg->pActiveWidgetList = NULL;
+    pDlg->pEndActiveWidgetList = NULL;
+      
     widget_undraw(pWidget);
     widget_mark_dirty(pWidget);
     del_widget_from_gui_list(pWidget);
     return FALSE;
   }
-    
+  
   if (pDlg->pScroll && pDlg->pActiveWidgetList) {
     /* scrollbar exist and active, start mod. from last seen label */
     
_______________________________________________
Freeciv-dev mailing list
[EMAIL PROTECTED]
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to