Bug #2507 » 0003-Qt-Keep-diplomacy-gold-limit-in-step-with-players-go-main.patch
| client/gui-qt/diplodlg.cpp | ||
|---|---|---|
|
if (clause_enabled(CLAUSE_GOLD)) {
|
||
|
QLabel *goldlab1;
|
||
|
QLabel *goldlab2;
|
||
|
QSpinBox *gold_edit1;
|
||
|
QSpinBox *gold_edit2;
|
||
|
goldlab1 = new QLabel(_("Gold:"));
|
||
|
goldlab1->setAlignment(Qt::AlignRight);
|
||
| ... | ... | |
|
layout->addWidget(gold_edit2, 3, 5);
|
||
|
clause_column = 6;
|
||
|
} else {
|
||
|
gold_edit1 = nullptr;
|
||
|
gold_edit2 = nullptr;
|
||
|
clause_column = 5;
|
||
|
}
|
||
| ... | ... | |
|
event->accept();
|
||
|
}
|
||
|
/************************************************************************//**
|
||
|
Keep the maximum of the gold spinners in step with the players' gold
|
||
|
****************************************************************************/
|
||
|
void diplo_wdg::update_gold(struct player *pplayer)
|
||
|
{
|
||
|
QSpinBox *spin;
|
||
|
if (pplayer == plr1) {
|
||
|
spin = gold_edit2;
|
||
|
} else if (pplayer == plr2) {
|
||
|
spin = gold_edit1;
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
if (spin != nullptr) {
|
||
|
// Clamping the value to a lower maximum must not offer that amount
|
||
|
spin->blockSignals(true);
|
||
|
spin->setMaximum(pplayer->economic.gold);
|
||
|
spin->blockSignals(false);
|
||
|
}
|
||
|
}
|
||
|
/************************************************************************//**
|
||
|
Gold changed on first spinner
|
||
|
****************************************************************************/
|
||
| ... | ... | |
|
}
|
||
|
}
|
||
|
/************************************************************************//**
|
||
|
Updates gold spinners of all diplomacy widgets in current dialog
|
||
|
****************************************************************************/
|
||
|
void diplo_dlg::update_gold(struct player *pplayer)
|
||
|
{
|
||
|
QMapIterator <struct player *, diplo_wdg *>i(treaty_list);
|
||
|
while (i.hasNext()) {
|
||
|
i.next();
|
||
|
i.value()->update_gold(pplayer);
|
||
|
}
|
||
|
}
|
||
|
/************************************************************************//**
|
||
|
Existing dialog requested again.
|
||
|
****************************************************************************/
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
void update_diplomacy_gold(struct player *pplayer)
|
||
|
{
|
||
|
/* PORTME */
|
||
|
int i;
|
||
|
diplo_dlg *dd;
|
||
|
QWidget *w;
|
||
|
if (!gui()->is_repo_dlg_open("DDI")) {
|
||
|
return;
|
||
|
}
|
||
|
i = gui()->gimme_index_of("DDI");
|
||
|
fc_assert(i != -1);
|
||
|
w = gui()->game_tab_widget->widget(i);
|
||
|
dd = qobject_cast<diplo_dlg *>(w);
|
||
|
dd->update_gold(pplayer);
|
||
|
}
|
||
| client/gui-qt/diplodlg.h | ||
|---|---|---|
|
struct player *they, struct player *initiator);
|
||
|
~diplo_wdg();
|
||
|
void update_wdg();
|
||
|
void update_gold(struct player *pplayer);
|
||
|
void set_index(int ind);
|
||
|
int get_index();
|
||
|
struct treaty *treaty;
|
||
| ... | ... | |
|
private:
|
||
|
struct player *plr1;
|
||
|
struct player *plr2;
|
||
|
QSpinBox *gold_edit1;
|
||
|
QSpinBox *gold_edit2;
|
||
|
int active_menu;
|
||
|
struct player *curr_player;
|
||
|
bool p1_accept;
|
||
| ... | ... | |
|
~diplo_dlg();
|
||
|
void reactivate();
|
||
|
void update_dlg();
|
||
|
void update_gold(struct player *pplayer);
|
||
|
bool init(bool raise);
|
||
|
diplo_wdg *find_widget(struct player *they);
|
||
|
void close_widget(struct player *they);
|
||
- « Previous
- 1
- 2
- Next »