19#include <QApplication>
66 QPushButton *add_clause1;
67 QPushButton *add_clause2;
74 struct color *textcolors[2] = {
93 text_tooltip = QString(diplstate_type_translated_name(state->
type));
95 text_tooltip = text_tooltip +
" (";
96 text_tooltip = text_tooltip + QString(
PL_(
"%1 turn left",
100 text_tooltip = text_tooltip +
")";
103 text =
"<b><h3><center>"
106 +
"</center></h3></b>";
108 text =
"<style>h3{background-color: "
111 +
"}</style>" + text;
112 label3->setText(text);
113 label3->setMinimumWidth(300);
115 text =
"<b><h3><center>"
118 +
"</center></h3></b></body>";
120 text =
"<style>h3{background-color: "
123 +
"}</style>" + text;
124 label4->setMinimumWidth(300);
125 label4->setText(text);
126 layout->addWidget(label3, 0, 5);
127 layout->addWidget(label4, 5, 5);
128 plr1_label =
new QLabel;
135 plr1_label->setPixmap(*pix);
137 plr1_label->setText(
"FLAG MISSING");
140 plr_buf,
sizeof(plr_buf));
141 text =
"<b><center>" + text.toHtmlEscaped() +
"</center></b>";
142 label->setText(text);
144 layout->addWidget(plr1_label, 1, 0);
145 layout->addWidget(label, 1, 5);
151 plr2_label =
new QLabel;
152 if (sprite2 != NULL) {
154 plr2_label->setPixmap(*pix);
156 plr2_label->setText(
"FLAG MISSING");
159 plr_buf,
sizeof(plr_buf));
160 text2 =
"<b><center>" + text2.toHtmlEscaped() +
"</center></b>";
161 label2->setText(text2);
163 layout->addWidget(plr2_label, 6, 0);
164 layout->addWidget(label2, 6, 5);
170 QSpinBox *gold_edit1;
171 QSpinBox *gold_edit2;
173 goldlab1 =
new QLabel(
_(
"Gold:"));
174 goldlab1->setAlignment(Qt::AlignRight);
175 goldlab2 =
new QLabel(
_(
"Gold:"));
176 goldlab2->setAlignment(Qt::AlignRight);
177 gold_edit1 =
new QSpinBox;
178 gold_edit2 =
new QSpinBox;
179 gold_edit1->setMinimum(0);
180 gold_edit2->setMinimum(0);
181 gold_edit1->setFocusPolicy(Qt::ClickFocus);
182 gold_edit2->setFocusPolicy(Qt::ClickFocus);
185 connect(gold_edit1, SIGNAL(valueChanged(
int)), SLOT(
gold_changed1(
int)));
186 connect(gold_edit2, SIGNAL(valueChanged(
int)), SLOT(
gold_changed2(
int)));
187 layout->addWidget(goldlab1, 7, 4);
188 layout->addWidget(goldlab2, 3, 4);
189 layout->addWidget(gold_edit1, 7, 5);
190 layout->addWidget(gold_edit2, 3, 5);
196 add_clause1 =
new QPushButton(style()->standardIcon(QStyle::SP_ArrowRight),
198 add_clause2 =
new QPushButton(style()->standardIcon(QStyle::SP_ArrowRight),
200 add_clause1->setFocusPolicy(Qt::ClickFocus);
201 add_clause2->setFocusPolicy(Qt::ClickFocus);
204 layout->addWidget(add_clause1, 7, clause_column);
205 layout->addWidget(add_clause2, 3, clause_column);
209 text_edit->setProperty(
"showGrid",
"false");
210 text_edit->setProperty(
"selectionBehavior",
"SelectRows");
211 text_edit->setEditTriggers(QAbstractItemView::NoEditTriggers);
212 text_edit->verticalHeader()->setVisible(
false);
213 text_edit->horizontalHeader()->setVisible(
false);
214 text_edit->setSelectionMode(QAbstractItemView::SingleSelection);
217 header->setStretchLastSection(
true);
218 connect(
text_edit, &QTableWidget::itemDoubleClicked,
224 new QPushButton(style()->standardIcon(QStyle::SP_DialogYesButton),
227 new QPushButton(style()->standardIcon(QStyle::SP_DialogNoButton),
228 _(
"Cancel meeting"));
235 label4->setToolTip(text_tooltip);
236 plr2_label->setToolTip(text_tooltip);
239 label3->setToolTip(text_tooltip);
240 plr1_label->setToolTip(text_tooltip);
317 struct player *pgiver, *pother;
318 enum diplstate_type ds;
319 QAction *all_advancs;
320 QAction *some_action;
321 QMap <QString, int>city_list;
322 QMap <QString, int>::const_iterator city_iter;
323 QMap <QString, Tech_type_id> adv_list;
324 QMap <QString, Tech_type_id>::const_iterator adv_iter;
325 QMenu *map_menu =
nullptr;
326 QMenu *adv_menu, *city_menu, *pacts_menu;
327 QMenu *menu =
new QMenu(
this);
343 map_menu = menu->addMenu(
_(
"Maps"));
344 world_map =
new QAction(
_(
"World-map"),
this);
346 map_menu->addAction(world_map);
352 if (map_menu ==
nullptr) {
353 map_menu = menu->addMenu(
_(
"Maps"));
356 sea_map =
new QAction(
_(
"Sea-map"),
this);
358 map_menu->addAction(sea_map);
365 adv_menu = menu->addMenu(
_(
"Advances"));
374 == TECH_PREREQS_KNOWN)) {
380 all_advancs =
new QAction(
_(
"All advances"),
this);
382 adv_menu->addAction(all_advancs);
383 adv_menu->addSeparator();
386 adv_iter = adv_list.constBegin();
387 if (adv_list.count() > 0) {
388 while (adv_iter != adv_list.constEnd()) {
389 id = adv_iter.value();
390 some_action = adv_menu->addAction(adv_iter.key());
391 connect(some_action, &QAction::triggered,
this,
398 adv_menu->setDisabled(
true);
405 city_menu = menu->addMenu(
_(
"Cities"));
409 city_list.insert(pcity->name, pcity->id);
412 city_iter = city_list.constBegin();
413 if (city_list.count() > 0) {
414 while (city_iter != city_list.constEnd()) {
415 id = city_iter.value();
416 some_action = city_menu->addAction(city_iter.key());
417 connect(some_action, &QAction::triggered,
this,
424 city_menu->setDisabled(
true);
429 some_action =
new QAction(
_(
"Give shared vision"),
this);
430 connect(some_action, &QAction::triggered,
this,
432 menu->addAction(some_action);
434 some_action->setDisabled(
true);
439 some_action =
new QAction(
_(
"Give embassy"),
this);
441 menu->addAction(some_action);
443 some_action->setDisabled(
true);
449 pacts_menu = menu->addMenu(
_(
"Pacts"));
453 some_action =
new QAction(
Q_(
"?diplomatic_state:Cease-fire"),
this);
455 pacts_menu->addAction(some_action);
456 if (ds == DS_CEASEFIRE || ds == DS_TEAM) {
457 some_action->setDisabled(
true);
462 some_action =
new QAction(
Q_(
"?diplomatic_state:Peace"),
this);
464 pacts_menu->addAction(some_action);
465 if (ds == DS_PEACE || ds == DS_TEAM) {
466 some_action->setDisabled(
true);
471 some_action =
new QAction(
Q_(
"?diplomatic_state:Alliance"),
this);
473 pacts_menu->addAction(some_action);
474 if (ds == DS_ALLIANCE || ds == DS_TEAM) {
475 some_action->setDisabled(
true);
481 menu->setAttribute(Qt::WA_DeleteOnClose);
482 menu->popup(QCursor::pos());
560 int giver, dest, other;
576 CLAUSE_CITY, city_num);
584 int giver, dest, other;
600 CLAUSE_ADVANCE, tech);
608 int giver, dest, other;
609 const struct research *dresearch, *gresearch;
642 == TECH_PREREQS_KNOWN)) {
690 QTableWidgetItem *qitem;
700 qitem =
new QTableWidgetItem();
702 qitem->setTextAlignment(Qt::AlignLeft);
710 qitem =
new QTableWidgetItem();
711 qitem->setText(
_(
"--- This treaty is blank. "
712 "Please add some clauses. ---"));
713 qitem->setTextAlignment(Qt::AlignLeft);
740 gui()->sw_diplo->resize_pixmap(
gui()->sw_diplo->width(),
741 gui()->sw_diplo->height());
742 gui()->sw_diplo->set_custom_labels(QString());
743 gui()->sw_diplo->update_final_pixmap();
772 setFocusPolicy(Qt::ClickFocus);
797 setTabIcon(i, QIcon(*pix));
826 setAttribute(Qt::WA_DeleteOnClose);
827 gui()->gimme_place(
this,
"DDI");
829 gui()->game_tab_widget->setCurrentIndex(
index);
842 while (i.hasNext()) {
849 gui()->remove_repo_dlg(
"DDI");
850 gui()->game_tab_widget->setCurrentIndex(0);
884 while (i.hasNext()) {
911 if (!
gui()->is_repo_dlg_open(
"DDI")) {
914 i =
gui()->gimme_index_of(
"DDI");
916 w =
gui()->game_tab_widget->widget(i);
917 dd = qobject_cast<diplo_dlg *>(w);
935 QPixmap *pix, *def_pix, *pix2, *pix3, *def_pix_del;
945 gui()->switch_page(PAGE_GAME);
948 pix2 =
new QPixmap();
949 def_pix_del =
new QPixmap();
953 *pix2 = pix->scaledToWidth(
gui()->sw_diplo->width() - 2,
954 Qt::SmoothTransformation);
955 if (pix2->height() >
gui()->sw_diplo->height()) {
956 *pix2 = pix->scaledToHeight(
gui()->sw_diplo->height(),
957 Qt::SmoothTransformation);
959 pix3 =
new QPixmap(
gui()->sw_diplo->width(),
gui()->sw_diplo->height());
960 pix3->fill(Qt::transparent);
962 *def_pix_del = def_pix->scaled(
gui()->sw_diplo->width(),
963 gui()->sw_diplo->height(),
964 Qt::IgnoreAspectRatio,
965 Qt::SmoothTransformation);
967 p.drawPixmap(1, 1, *pix2);
968 p.drawPixmap(0, 0, *def_pix_del);
970 gui()->sw_diplo->set_pixmap(pix3);
971 gui()->sw_diplo->resize_pixmap(
gui()->sw_diplo->width(),
972 gui()->sw_diplo->height());
975 gui()->sw_diplo->update_final_pixmap();
980 was_open =
gui()->is_repo_dlg_open(
"DDI");
984 if (!dd->
init(
false)) {
991 i =
gui()->gimme_index_of(
"DDI");
993 w =
gui()->game_tab_widget->widget(i);
994 dd = qobject_cast<diplo_dlg *>(w);
1003 gui()->game_tab_widget->setCurrentIndex(i);
1009 gui()->game_tab_widget->setCurrentIndex(i);
1017 enum clause_type
type,
int value)
1024 if (!
gui()->is_repo_dlg_open(
"DDI")) {
1027 i =
gui()->gimme_index_of(
"DDI");
1029 w =
gui()->game_tab_widget->widget(i);
1030 dd = qobject_cast<diplo_dlg *>(w);
1047 if (!
gui()->is_repo_dlg_open(
"DDI")) {
1050 i =
gui()->gimme_index_of(
"DDI");
1052 w =
gui()->game_tab_widget->widget(i);
1053 dd = qobject_cast<diplo_dlg *>(w);
1062 enum clause_type
type,
int value)
1070 if (!
gui()->is_repo_dlg_open(
"DDI")) {
1073 i =
gui()->gimme_index_of(
"DDI");
1075 w =
gui()->game_tab_widget->widget(i);
1076 dd = qobject_cast<diplo_dlg *>(w);
1095 if (!
gui()->is_repo_dlg_open(
"DDI")) {
1098 i =
gui()->gimme_index_of(
"DDI");
1100 w =
gui()->game_tab_widget->widget(i);
1101 dd = qobject_cast<diplo_dlg *>(w);
bool is_capital(const struct city *pcity)
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
QMap< int, diplo_wdg * > treaty_list
void make_active(int party)
diplo_dlg(int counterpart, int initiated_from)
void close_widget(int counterpart)
void add_widget(int counterpart, int initiated_from)
diplo_wdg * find_widget(int counterpart)
void show_menu(int player)
void gold_changed1(int val)
void gold_changed2(int val)
void closeEvent(QCloseEvent *event)
QPushButton * cancel_treaty
void give_shared_vision()
void give_city(int city_num)
void dbl_click(QTableWidgetItem *item)
diplo_wdg(int id, int id2)
QPushButton * accept_treaty
void give_advance(int tech)
QPixmap * get_pixmap(const QString &id)
static fc_icons * instance()
bool client_is_observer(void)
int client_player_number(void)
enum client_states client_state(void)
bool can_client_issue_orders(void)
const char * title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
struct color * color_best_contrast(struct color *subject, struct color **candidates, int ncandidates)
struct color * get_player_color(const struct tileset *t, const struct player *pplayer)
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
struct player * player_by_number(const int player_id)
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
int client_player_number(void)
void handle_diplomacy_create_clause(int counterpart, int giver, enum clause_type type, int value)
void close_all_diplomacy_dialogs(void)
void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
int int initiated_from int int giver
int int initiated_from handle_diplomacy_remove_clause
handle_diplomacy_cancel_meeting
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
bool clause_enabled(enum clause_type type)
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
#define clause_list_iterate_end
#define clause_list_iterate(clauselist, pclause)
#define PL_(String1, String2, n)
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
static enum client_pages current_page
#define CAPTURE_DEFAULT_THIS
QApplication * current_app()
#define fc_assert_ret(condition)
#define fc_assert(condition)
struct nation_type * nation_of_player(const struct player *pplayer)
const char * nation_plural_for_player(const struct player *pplayer)
int dsend_packet_diplomacy_create_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_cancel_meeting_req(struct connection *pc, int counterpart)
int dsend_packet_diplomacy_remove_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_accept_treaty_req(struct connection *pc, int counterpart)
struct player * player_by_number(const int player_id)
int player_number(const struct player *pplayer)
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
bool gives_shared_vision(const struct player *me, const struct player *them)
struct research * research_get(const struct player *pplayer)
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
struct clause_list * clauses
struct packet_game_info info
bool tech_trade_allow_holes
struct city_list * cities
const char * advance_name_translation(const struct advance *padvance)
Tech_type_id advance_number(const struct advance *padvance)
#define advance_iterate(_start, _p)
#define advance_iterate_end
struct sprite * get_treaty_thumb_sprite(const struct tileset *t, bool on_off)
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)