From c46633a78b5ca57fd6479a541daf9fbc48e3a0d2 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 22 Jun 2023 19:51:16 +0300 Subject: [PATCH 25/25] sdl2: Add "Shared Tiles" clauses support See osdn #45062 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/diplodlg.c | 40 +++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/client/gui-sdl2/diplodlg.c b/client/gui-sdl2/diplodlg.c index 03fd68f392..28f7773c92 100644 --- a/client/gui-sdl2/diplodlg.c +++ b/client/gui-sdl2/diplodlg.c @@ -307,7 +307,7 @@ static int vision_callback(struct widget *pwidget) } /**********************************************************************//** - User interacted with embassy -widget. + User interacted with Embassy -widget. **************************************************************************/ static int embassy_callback(struct widget *pwidget) { @@ -327,6 +327,27 @@ static int embassy_callback(struct widget *pwidget) return -1; } +/**********************************************************************//** + User interacted with Shared Tiles -widget. +**************************************************************************/ +static int shared_tiles_callback(struct widget *pwidget) +{ + if (PRESSED_EVENT(main_data.event)) { + struct diplomacy_dialog *pdialog; + + if (!(pdialog = get_diplomacy_dialog(player_by_number(pwidget->data.cont->id1)))) { + pdialog = get_diplomacy_dialog(player_by_number(pwidget->data.cont->id0)); + } + + dsend_packet_diplomacy_create_clause_req(&client.conn, + player_number(pdialog->treaty->plr1), + pwidget->data.cont->id0, + CLAUSE_SHARED_TILES, 0); + } + + return -1; +} + /**********************************************************************//** User interacted with map -widget. **************************************************************************/ @@ -652,7 +673,23 @@ static struct advanced_dialog *popup_diplomatic_objects(struct player *pplayer0, count++; } + if (clause_enabled(CLAUSE_SHARED_TILES)) { + buf = create_iconlabel_from_chars_fonto(NULL, pwindow->dst, + _("Share tiles"), FONTO_ATTENTION, + (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE)); + buf->string_utf8->fgcol + = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT); + width = MAX(width, buf->size.w); + height = MAX(height, buf->size.h); + buf->action = shared_tiles_callback; + buf->data.cont = cont; + set_wstate(buf, FC_WS_NORMAL); + add_to_gui_list(ID_LABEL, buf); + count++; + } + /* ---------------------------- */ + if (clause_enabled(CLAUSE_GOLD) && pplayer0->economic.gold > 0) { cont->value = pplayer0->economic.gold; @@ -678,6 +715,7 @@ static struct advanced_dialog *popup_diplomatic_objects(struct player *pplayer0, add_to_gui_list(ID_LABEL, buf); count++; } + /* ---------------------------- */ /* Trading: advances */ -- 2.39.2