Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diplomacy Visibility #1613

Merged
merged 4 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions client/diplodlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "fc_client.h"
#include "icons.h"
#include "page_game.h"
#include "plrdlg.h"
#include "sprite.h"
#include "top_bar.h"

Expand Down Expand Up @@ -831,6 +832,7 @@ void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted,
QWidget *w;

if (!queen()->isRepoDlgOpen(QStringLiteral("DDI"))) {
update_top_bar_diplomacy_status(false);
return;
}
i = queen()->gimmeIndexOf(QStringLiteral("DDI"));
Expand All @@ -841,6 +843,7 @@ void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted,
dw->treaty.accept0 = I_accepted;
dw->treaty.accept1 = other_accepted;
dw->update_wdg();
update_top_bar_diplomacy_status(dd->count() > 0);
}

/**
Expand Down Expand Up @@ -887,6 +890,7 @@ void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
if (player_by_number(initiated_from) == client.conn.playing) {
queen()->game_tab_widget->setCurrentIndex(i);
}
update_top_bar_diplomacy_status(dd->count() > 0);
}

/**
Expand All @@ -901,6 +905,7 @@ void handle_diplomacy_create_clause(int counterpart, int giver,
QWidget *w;

if (!queen()->isRepoDlgOpen(QStringLiteral("DDI"))) {
update_top_bar_diplomacy_status(false);
return;
}
i = queen()->gimmeIndexOf(QStringLiteral("DDI"));
Expand All @@ -923,13 +928,15 @@ void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
QWidget *w;

if (!queen()->isRepoDlgOpen(QStringLiteral("DDI"))) {
update_top_bar_diplomacy_status(false);
return;
}
i = queen()->gimmeIndexOf(QStringLiteral("DDI"));
fc_assert(i != -1);
w = queen()->game_tab_widget->widget(i);
dd = qobject_cast<diplo_dlg *>(w);
dd->close_widget(counterpart);
update_top_bar_diplomacy_status(dd->count() > 0);
}

/**
Expand All @@ -944,6 +951,7 @@ void handle_diplomacy_remove_clause(int counterpart, int giver,
QWidget *w;

if (!queen()->isRepoDlgOpen(QStringLiteral("DDI"))) {
update_top_bar_diplomacy_status(false);
return;
}
i = queen()->gimmeIndexOf(QStringLiteral("DDI"));
Expand All @@ -968,12 +976,14 @@ void close_all_diplomacy_dialogs()

qApp->alert(king()->central_wdg);
if (!queen()->isRepoDlgOpen(QStringLiteral("DDI"))) {
update_top_bar_diplomacy_status(false);
return;
}
i = queen()->gimmeIndexOf(QStringLiteral("DDI"));
fc_assert(i != -1);
w = queen()->game_tab_widget->widget(i);
dd = qobject_cast<diplo_dlg *>(w);
update_top_bar_diplomacy_status(false);
dd->close();
delete dd;
}
2 changes: 1 addition & 1 deletion client/page_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void pageGame::reloadSidebarIcons()
sw_map->setIcon(fcIcons::instance()->getIcon(QStringLiteral("view")));
sw_cunit->setIcon(fcIcons::instance()->getIcon(QStringLiteral("units")));
sw_cities->setIcon(fcIcons::instance()->getIcon(QStringLiteral("cities")));
sw_diplo->setIcon(fcIcons::instance()->getIcon(QStringLiteral("nations")));
sw_diplo->setIcon(fcIcons::instance()->getIcon(QStringLiteral("flag")));
sw_science->setIcon(
fcIcons::instance()->getIcon(QStringLiteral("research")));
sw_economy->setIcon(
Expand Down
34 changes: 28 additions & 6 deletions client/plrdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "fonts.h"
#include "page_game.h"
#include "sprite.h"
#include "top_bar.h"

/**
Help function to draw checkbox inside delegate
Expand Down Expand Up @@ -725,9 +726,11 @@ plr_report::plr_report() : QWidget()
ui.plr_wdg->sortByColumn(king()->qt_settings.player_repo_sort_col,
king()->qt_settings.player_report_sort);
}
if (queen()->gimmeIndexOf(QStringLiteral("DDI")) > 0) {
ui.diplo_but->setEnabled(true);
}
const bool has_meeting =
(queen()->gimmeIndexOf(QStringLiteral("DDI")) > 0);
ui.diplo_but->setEnabled(has_meeting);
update_top_bar_diplomacy_status(has_meeting);
queen()->updateSidebarTooltips();
ui.plr_wdg->set_pr_rep(this);
}

Expand Down Expand Up @@ -912,9 +915,10 @@ void plr_report::update_report(bool update_selection)
if (can_meet_with_player(other_player)) {
ui.meet_but->setEnabled(true);
}
if (queen()->gimmeIndexOf(QStringLiteral("DDI")) > 0) {
ui.diplo_but->setEnabled(true);
}
const bool has_meeting =
(queen()->gimmeIndexOf(QStringLiteral("DDI")) > 0);
ui.diplo_but->setEnabled(has_meeting);
update_top_bar_diplomacy_status(has_meeting);
ui.plr_wdg->restore_selection();
}

Expand Down Expand Up @@ -944,6 +948,7 @@ void popup_players_dialog()
queen()->game_tab_widget->setCurrentWidget(pr);
pr->update_report();
}
queen()->updateSidebarTooltips();
}

/**
Expand Down Expand Up @@ -982,6 +987,7 @@ void popdown_players_report()
pr = reinterpret_cast<plr_report *>(w);
pr->deleteLater();
}
queen()->updateSidebarTooltips();
}
/**
Update the intelligence dialog for the given player. This is called by
Expand All @@ -992,3 +998,19 @@ void update_intel_dialog(struct player *p) { real_players_dialog_update(p); }
Close an intelligence dialog for the given player.
*/
void close_intel_dialog(struct player *p) { real_players_dialog_update(p); }

/**
* Function to update the top bar button. Blink when there are open
* Diplomacy meetings, don't when there are none.
*/
void update_top_bar_diplomacy_status(bool blinker)
{
queen()->sw_diplo->keep_blinking = blinker;
if (blinker) {
queen()->sw_diplo->sblink();
} else {
queen()->sw_diplo->update();
}
queen()->updateSidebarTooltips();
queen()->reloadSidebarIcons();
}
1 change: 1 addition & 0 deletions client/plrdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,4 @@ private slots:
};

void popdown_players_report();
void update_top_bar_diplomacy_status(bool blinker);