Author: cazfi Date: Sun Feb 1 06:50:22 2015 New Revision: 27917 URL: http://svn.gna.org/viewcvs/freeciv?rev=27917&view=rev Log: Made it possible to Withdraw Vision from someone you're at war with in sdl-clients
See bug #23210 Modified: trunk/client/gui-sdl/diplodlg.c trunk/client/gui-sdl2/diplodlg.c Modified: trunk/client/gui-sdl/diplodlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl/diplodlg.c?rev=27917&r1=27916&r2=27917&view=diff ============================================================================== --- trunk/client/gui-sdl/diplodlg.c (original) +++ trunk/client/gui-sdl/diplodlg.c Sun Feb 1 06:50:22 2015 @@ -1489,8 +1489,9 @@ SDL_String16 *pStr; SDL_Surface *pText; SDL_Rect dst; - bool shared = FALSE; + bool shared; SDL_Rect area; + int buttons = 0; if (pSDip_Dlg) { return; @@ -1532,18 +1533,17 @@ FREESTRING16(pStr); area.w = MAX(area.w , pText->w); area.h += pText->h + adj_size(15); - - if(type != DS_WAR && can_client_issue_orders()) { - - if(type == DS_ARMISTICE) { - fc_snprintf(cBuf, sizeof(cBuf), _("Declare WAR")); + + if (type != DS_WAR && can_client_issue_orders()) { + if (type == DS_ARMISTICE) { + fc_snprintf(cBuf, sizeof(cBuf), _("Declare WAR")); } else { - fc_snprintf(cBuf, sizeof(cBuf), _("Cancel Treaty")); + fc_snprintf(cBuf, sizeof(cBuf), _("Cancel Treaty")); } - + /* cancel treaty */ pBuf = create_themeicon_button_from_chars(pTheme->UNITS2_Icon, - pWindow->dst, cBuf, adj_font(12), 0); + pWindow->dst, cBuf, adj_font(12), 0); pBuf->action = cancel_pact_dlg_callback; set_wstate(pBuf, FC_WS_NORMAL); @@ -1555,27 +1555,29 @@ pBuf->next->size.w = pBuf->size.w; button_w = MAX(button_w , pBuf->size.w); button_h = MAX(button_h , pBuf->size.h); - - shared = gives_shared_vision(client.conn.playing, pPlayer); - - if(shared) { - /* shared vision */ - pBuf = create_themeicon_button_from_chars(pTheme->UNITS2_Icon, pWindow->dst, - _("Withdraw vision"), adj_font(12), 0); - - pBuf->action = withdraw_vision_dlg_callback; - set_wstate(pBuf, FC_WS_NORMAL); - pBuf->data.player = pPlayer; - pBuf->key = SDLK_w; - pBuf->string16->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT); - add_to_gui_list(ID_BUTTON, pBuf); - pBuf->size.w = MAX(pBuf->next->size.w, pBuf->size.w); - pBuf->next->size.w = pBuf->size.w; - button_w = MAX(button_w , pBuf->size.w); - button_h = MAX(button_h , pBuf->size.h); - } - } - + buttons++; + } + + shared = gives_shared_vision(client.conn.playing, pPlayer); + + if (shared) { + /* shared vision */ + pBuf = create_themeicon_button_from_chars(pTheme->UNITS2_Icon, pWindow->dst, + _("Withdraw vision"), adj_font(12), 0); + + pBuf->action = withdraw_vision_dlg_callback; + set_wstate(pBuf, FC_WS_NORMAL); + pBuf->data.player = pPlayer; + pBuf->key = SDLK_w; + pBuf->string16->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT); + add_to_gui_list(ID_BUTTON, pBuf); + pBuf->size.w = MAX(pBuf->next->size.w, pBuf->size.w); + pBuf->next->size.w = pBuf->size.w; + button_w = MAX(button_w , pBuf->size.w); + button_h = MAX(button_h , pBuf->size.h); + buttons++; + } + /* meet */ pBuf = create_themeicon_button_from_chars(pTheme->PLAYERS_Icon, pWindow->dst, _("Call Diplomatic Meeting"), adj_font(12), 0); @@ -1590,6 +1592,7 @@ pBuf->next->size.w = pBuf->size.w; button_w = MAX(button_w , pBuf->size.w); button_h = MAX(button_h , pBuf->size.h); + buttons++; pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon, pWindow->dst, _("Send him back"), adj_font(12), 0); @@ -1600,20 +1603,13 @@ pBuf->key = SDLK_ESCAPE; button_w = MAX(button_w , pBuf->size.w); button_h = MAX(button_h , pBuf->size.h); - + buttons++; + button_h += adj_size(4); area.w = MAX(area.w, button_w + adj_size(20)); - - if(type != DS_WAR) { - if(shared) { - area.h += 4 * (button_h + adj_size(10)); - } else { - area.h += 3 * (button_h + adj_size(10)); - } - } else { - area.h += 2 * (button_h + adj_size(10)); - } - + + area.h += buttons * (button_h + adj_size(10)); + add_to_gui_list(ID_BUTTON, pBuf); @@ -1646,23 +1642,23 @@ pBuf = pWindow; - if(type != DS_WAR) { - /* cancel treaty */ + /* war: meet, peace: cancel treaty */ + pBuf = pBuf->prev; + pBuf->size.w = button_w; + pBuf->size.h = button_h; + pBuf->size.x = area.x + (area.w - (pBuf->size.w)) / 2; + pBuf->size.y = dst.y; + + if (shared) { + /* vision */ pBuf = pBuf->prev; pBuf->size.w = button_w; pBuf->size.h = button_h; - pBuf->size.x = area.x + (area.w - (pBuf->size.w)) / 2; - pBuf->size.y = dst.y; - - if(shared) { - /* vision */ - pBuf = pBuf->prev; - pBuf->size.w = button_w; - pBuf->size.h = button_h; - pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10); - pBuf->size.x = pBuf->next->size.x; - } - + pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10); + pBuf->size.x = pBuf->next->size.x; + } + + if (type != DS_WAR) { /* meet */ pBuf = pBuf->prev; pBuf->size.w = button_w; @@ -1670,15 +1666,6 @@ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10); pBuf->size.x = pBuf->next->size.x; - } else { - - /* meet */ - pBuf = pBuf->prev; - pBuf->size.w = button_w; - pBuf->size.h = button_h; - pBuf->size.x = area.x + (area.w - (pBuf->size.w)) / 2; - pBuf->size.y = dst.y; - } /* cancel */ Modified: trunk/client/gui-sdl2/diplodlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/diplodlg.c?rev=27917&r1=27916&r2=27917&view=diff ============================================================================== --- trunk/client/gui-sdl2/diplodlg.c (original) +++ trunk/client/gui-sdl2/diplodlg.c Sun Feb 1 06:50:22 2015 @@ -1500,8 +1500,9 @@ SDL_String16 *pStr; SDL_Surface *pText; SDL_Rect dst; - bool shared = FALSE; + bool shared; SDL_Rect area; + int buttons = 0; if (pSDip_Dlg) { return; @@ -1566,25 +1567,27 @@ pBuf->next->size.w = pBuf->size.w; button_w = MAX(button_w , pBuf->size.w); button_h = MAX(button_h , pBuf->size.h); - - shared = gives_shared_vision(client.conn.playing, pPlayer); - - if (shared) { - /* shared vision */ - pBuf = create_themeicon_button_from_chars(pTheme->UNITS2_Icon, pWindow->dst, - _("Withdraw vision"), adj_font(12), 0); - - pBuf->action = withdraw_vision_dlg_callback; - set_wstate(pBuf, FC_WS_NORMAL); - pBuf->data.player = pPlayer; - pBuf->key = SDLK_w; - pBuf->string16->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT); - add_to_gui_list(ID_BUTTON, pBuf); - pBuf->size.w = MAX(pBuf->next->size.w, pBuf->size.w); - pBuf->next->size.w = pBuf->size.w; - button_w = MAX(button_w , pBuf->size.w); - button_h = MAX(button_h , pBuf->size.h); - } + buttons++; + } + + shared = gives_shared_vision(client.conn.playing, pPlayer); + + if (shared) { + /* shared vision */ + pBuf = create_themeicon_button_from_chars(pTheme->UNITS2_Icon, pWindow->dst, + _("Withdraw vision"), adj_font(12), 0); + + pBuf->action = withdraw_vision_dlg_callback; + set_wstate(pBuf, FC_WS_NORMAL); + pBuf->data.player = pPlayer; + pBuf->key = SDLK_w; + pBuf->string16->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT); + add_to_gui_list(ID_BUTTON, pBuf); + pBuf->size.w = MAX(pBuf->next->size.w, pBuf->size.w); + pBuf->next->size.w = pBuf->size.w; + button_w = MAX(button_w , pBuf->size.w); + button_h = MAX(button_h , pBuf->size.h); + buttons++; } /* meet */ @@ -1601,6 +1604,7 @@ pBuf->next->size.w = pBuf->size.w; button_w = MAX(button_w , pBuf->size.w); button_h = MAX(button_h , pBuf->size.h); + buttons++; pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon, pWindow->dst, _("Send him back"), @@ -1612,19 +1616,12 @@ pBuf->key = SDLK_ESCAPE; button_w = MAX(button_w , pBuf->size.w); button_h = MAX(button_h , pBuf->size.h); + buttons++; button_h += adj_size(4); area.w = MAX(area.w, button_w + adj_size(20)); - if (type != DS_WAR) { - if (shared) { - area.h += 4 * (button_h + adj_size(10)); - } else { - area.h += 3 * (button_h + adj_size(10)); - } - } else { - area.h += 2 * (button_h + adj_size(10)); - } + area.h += buttons * (button_h + adj_size(10)); add_to_gui_list(ID_BUTTON, pBuf); @@ -1657,38 +1654,29 @@ pBuf = pWindow; - if (type != DS_WAR) { - /* cancel treaty */ + /* war: meet, peace: cancel treaty */ + pBuf = pBuf->prev; + pBuf->size.w = button_w; + pBuf->size.h = button_h; + pBuf->size.x = area.x + (area.w - (pBuf->size.w)) / 2; + pBuf->size.y = dst.y; + + if (shared) { + /* vision */ pBuf = pBuf->prev; pBuf->size.w = button_w; pBuf->size.h = button_h; - pBuf->size.x = area.x + (area.w - (pBuf->size.w)) / 2; - pBuf->size.y = dst.y; - - if (shared) { - /* vision */ - pBuf = pBuf->prev; - pBuf->size.w = button_w; - pBuf->size.h = button_h; - pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10); - pBuf->size.x = pBuf->next->size.x; - } - + pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10); + pBuf->size.x = pBuf->next->size.x; + } + + if (type != DS_WAR) { /* meet */ pBuf = pBuf->prev; pBuf->size.w = button_w; pBuf->size.h = button_h; pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10); pBuf->size.x = pBuf->next->size.x; - - } else { - - /* meet */ - pBuf = pBuf->prev; - pBuf->size.w = button_w; - pBuf->size.h = button_h; - pBuf->size.x = area.x + (area.w - (pBuf->size.w)) / 2; - pBuf->size.y = dst.y; } /* cancel */ _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits