1002 lines
44 KiB
C++
1002 lines
44 KiB
C++
// TMainScreen.InitTurn, NextUnit, EndTurn, ZoomToCity and CityClosed (Term.pas).
|
|
//
|
|
// PORT STATUS / deviations:
|
|
// - sound (Play, SoundPreload) is not ported;
|
|
// - the menu check marks the original reads (mRepScreens, mWaitTurn, ...) are
|
|
// read from optionChecked, which the menus will keep in sync;
|
|
// - InitTurn's continuation of multi-turn goto/terrain enhancement needs
|
|
// MoveUnit (not ported) and is marked TODO.
|
|
|
|
#include "Term.MainScreen.h"
|
|
|
|
#include "Cevo/CevoScreenTools.h"
|
|
#include "Cevo/CevoTexture.h"
|
|
#include "Global.h"
|
|
#include "Messg.h"
|
|
#include "Sound.h"
|
|
|
|
#include <QApplication>
|
|
#include <QTimer>
|
|
|
|
namespace Cevo {
|
|
namespace Term {
|
|
|
|
namespace {
|
|
|
|
struct AdvBookIconEntry {
|
|
int adv;
|
|
int icon;
|
|
};
|
|
|
|
constexpr std::array<AdvBookIconEntry, 16> AdvBookIcon = { {
|
|
{ adPolytheism, woZeus },
|
|
{ adBronzeWorking, woColossus },
|
|
{ adMapMaking, woLighthouse },
|
|
{ adPoetry, imTheater },
|
|
{ adMonotheism, woMich },
|
|
{ adPhilosophy, woLeo },
|
|
{ adTheoryOfGravity, woNewton },
|
|
{ adSteel, woEiffel },
|
|
{ adDemocracy, woLiberty },
|
|
{ adAutomobile, imHighways },
|
|
{ adSanitation, imSewer },
|
|
{ adElectronics, woHoover },
|
|
{ adNuclearFission, woManhattan },
|
|
{ adRecycling, imRecycling },
|
|
{ adComputers, imResLab },
|
|
{ adSpaceFlight, woMir },
|
|
} };
|
|
|
|
// Fills a (Pascal or Qt style) phrase template with arguments.
|
|
QString formatPhraseText(const QString &text, const QStringList &args)
|
|
{
|
|
QString result = phraseToQtFormat(text);
|
|
for (const QString &arg : args)
|
|
result = result.arg(arg);
|
|
return result;
|
|
}
|
|
|
|
bool isResourceUnused(int cix, int needFood, int needProd)
|
|
{
|
|
TCityAreaInfo cityAreaInfo;
|
|
ClientTools::server(sGetCityAreaInfo, ClientTools::me, cix, &cityAreaInfo);
|
|
for (int dy = -3; dy <= 3; ++dy) {
|
|
for (int dx = -3; dx <= 3; ++dx) {
|
|
if (((dx + dy) & 1) == 0 && dx * dx * dy * dy < 81) {
|
|
const int fix = ((dy + 3) << 2) + ((dx + 3) >> 1);
|
|
if ((ClientTools::myCity[cix].Tiles & (1u << fix)) == 0 // not used yet
|
|
&& cityAreaInfo.Available[fix] == faAvailable) { // usable
|
|
TTileInfo tileInfo;
|
|
tileInfo.ExplCity = cix;
|
|
ClientTools::server(sGetHypoCityTileInfo, ClientTools::me,
|
|
ClientTools::dLoc(ClientTools::myCity[cix].Loc, dx, dy), &tileInfo);
|
|
if (tileInfo.Food >= needFood && tileInfo.Prod >= needProd)
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void MainScreen::initTurn(int newPlayer)
|
|
{
|
|
TNewGameData &g = ClientTools::g;
|
|
const auto clearBitmap = [](Dpi::Bitmap &bitmap) {
|
|
Dpi::Canvas &canvas = bitmap.canvas();
|
|
canvas.brush().setColor(Qt::black);
|
|
canvas.fillRect(QRect(0, 0, bitmap.width(), bitmap.height()));
|
|
canvas.brush().setStyle(Qt::NoBrush);
|
|
canvas.end();
|
|
};
|
|
const std::array<ButtonC *, 5> mapButtons = { m_mapBtn0, m_mapBtn1, m_mapBtn4, m_mapBtn5, m_mapBtn6 };
|
|
|
|
if (ClientTools::isMultiPlayerGame() && newPlayer != ClientTools::me) {
|
|
m_unitInfoBtn->setVisible(false);
|
|
m_unitBtn->setVisible(false);
|
|
m_terrainBtn->setVisible(false);
|
|
m_eot->setVisible(false);
|
|
}
|
|
if (ClientTools::isMultiPlayerGame() && newPlayer != ClientTools::me
|
|
&& (g.RO[0]->Happened & phShipComplete) == 0) { // inter player screen
|
|
for (ButtonC *button : mapButtons)
|
|
button->setVisible(false);
|
|
ClientTools::me = -1;
|
|
MainTexture->setAge(-1);
|
|
clearBitmap(m_panel);
|
|
clearBitmap(m_topBar);
|
|
update();
|
|
|
|
const QString s = turnToString(g.RO[0]->Turn);
|
|
if (supervising)
|
|
simpleMessage(formatPhrase(QStringLiteral("SUPERTURN"), { s }));
|
|
else
|
|
simpleMessage(Tribes::tribe[static_cast<std::size_t>(newPlayer)]->tPhrase(QStringLiteral("TURN")).arg(s));
|
|
}
|
|
for (ButtonC *button : mapButtons)
|
|
button->setVisible(true);
|
|
|
|
ClientTools::itsMeAgain(newPlayer);
|
|
const int me = ClientTools::me;
|
|
const TPlayerContext &ro = *ClientTools::myRO;
|
|
myData = static_cast<PersistentData *>(g.RO[newPlayer]->Data);
|
|
if (me == 0 && (ro.Turn == 0 || clientMode == cResume))
|
|
update(); // colorize empty space
|
|
|
|
if (!supervising) {
|
|
age = ClientTools::getAge(me);
|
|
if (MainTexture->age() != age) {
|
|
MainTexture->setAge(age);
|
|
m_eot->update(); // has visible background parts in its bounds
|
|
}
|
|
if (clientMode == cMovieTurn)
|
|
m_eot->setButtonIndex(eotCancel);
|
|
else if (clientMode < scContact)
|
|
m_eot->setButtonIndex(eotGray);
|
|
else
|
|
m_eot->setButtonIndex(eotBackToNego);
|
|
} else {
|
|
age = 0;
|
|
MainTexture->setAge(-1);
|
|
m_eot->setButtonIndex(clientMode == cMovieTurn ? eotCancel : eotBlinkOn);
|
|
}
|
|
initCityMark(*MainTexture);
|
|
if (m_cityDlg)
|
|
m_cityDlg->checkAge();
|
|
if (m_natStatDlg)
|
|
m_natStatDlg->checkAge();
|
|
if (m_unitStatDlg)
|
|
m_unitStatDlg->checkAge();
|
|
if (m_helpDlg)
|
|
m_helpDlg->difficulty = g.Difficulty[me];
|
|
|
|
IsoEngine::unFocus = -1;
|
|
m_markCityLoc = -1;
|
|
IsoEngine::blinkOn = false;
|
|
m_blinkTime = -1;
|
|
m_tracking = false;
|
|
m_turnComplete = false;
|
|
|
|
if (toldSlavery < 0 || ((toldSlavery == 1) != (ro.Wonder[woPyramids].EffectiveOwner >= 0))) {
|
|
toldSlavery = ro.Wonder[woPyramids].EffectiveOwner >= 0 ? 1 : 0;
|
|
for (int p1 = 0; p1 < nPl; ++p1) {
|
|
Tribes::Tribe *tribe = Tribes::tribe[static_cast<std::size_t>(p1)].get();
|
|
if (tribe && tribe->mixSlaves >= 0) { // replace unit picture
|
|
Tribes::ModelPictureInfo picture;
|
|
picture.mix = tribe->mixSlaves;
|
|
picture.pix = toldSlavery == 1 ? pixSlaves : pixNoSlaves;
|
|
picture.hash = 0;
|
|
picture.grName = QStringLiteral("StdUnits");
|
|
tribe->setModelPicture(picture, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!supervising && clientMode == cTurn) {
|
|
for (int cix = 0; cix < ro.nCity; ++cix) {
|
|
TCity &city = ClientTools::myCity[cix];
|
|
if (city.Loc >= 0 && (ro.Turn == 0 || (city.Flags & chFounded) != 0))
|
|
city.Status = (city.Status & ~csResourceWeightsMask) | (3 << 4);
|
|
// new city, set to maximum growth
|
|
}
|
|
}
|
|
if (clientMode == cTurn || clientMode == cContinue)
|
|
ClientTools::cityOptimizer_BeginOfTurn(); // maybe peace was made or has ended
|
|
ClientTools::sumCities(taxSum, scienceSum);
|
|
|
|
if (clientMode == cMovieTurn) {
|
|
m_unitInfoBtn->setVisible(false);
|
|
m_unitBtn->setVisible(false);
|
|
m_terrainBtn->setVisible(false);
|
|
m_eot->setToolTip(phrases[QStringLiteral("BTN_STOP")]);
|
|
m_eot->setVisible(true);
|
|
} else if (clientMode < scContact) {
|
|
m_unitInfoBtn->setVisible(IsoEngine::unFocus >= 0);
|
|
m_unitBtn->setVisible(IsoEngine::unFocus >= 0);
|
|
checkTerrainBtnVisible();
|
|
m_turnComplete = supervising;
|
|
m_eot->setToolTip(phrases[QStringLiteral("BTN_ENDTURN")]);
|
|
m_eot->setVisible(ClientTools::server(sTurn - sExecute, me, 0, nullptr) >= rExecuted);
|
|
} else {
|
|
m_unitInfoBtn->setVisible(false);
|
|
m_unitBtn->setVisible(false);
|
|
m_terrainBtn->setVisible(false);
|
|
m_eot->setToolTip(phrases[QStringLiteral("BTN_NEGO")]);
|
|
m_eot->setVisible(true);
|
|
}
|
|
setTroopLoc(-1);
|
|
m_mapValid = false;
|
|
int newAgeCenterTo = 0;
|
|
if (((ro.Turn == 0 && !supervising) || ClientTools::isMultiPlayerGame() || clientMode == cResume)
|
|
&& ro.nCity > 0) {
|
|
int loc1 = ClientTools::myCity[0].Loc;
|
|
if (clientMode == cTurn && ro.Turn == 0) {
|
|
// move city out of center to not be covered by welcome screen
|
|
const int dx = std::min(5, m_mapWidth / (m_mainMap->xxt * 5));
|
|
const int dy = std::min(5, m_mapHeight / (m_mainMap->yyt * 5));
|
|
if (loc1 >= g.lx * g.ly / 2) {
|
|
newAgeCenterTo = -1;
|
|
loc1 = ClientTools::dLoc(loc1, -dx, -dy);
|
|
} else {
|
|
newAgeCenterTo = 1;
|
|
loc1 = ClientTools::dLoc(loc1, -dx, dy);
|
|
}
|
|
}
|
|
centre(loc1);
|
|
}
|
|
|
|
applyToVisibleForms(FormAction::Enable);
|
|
|
|
bool showCityList = false;
|
|
bool updatePanel = false;
|
|
int newGovAvailable = -1;
|
|
// The rest of the turn start is skipped by the early exits below (game end / extinct).
|
|
const auto finishEarly = [this] { m_turnComplete = true; };
|
|
|
|
if (clientMode != cResume) {
|
|
paintAll();
|
|
if ((ro.Happened & phChangeGov) != 0 && ro.NatBuilt[imPalace] > 0)
|
|
impImage(m_panel.canvas(), width() - XPalace, YPalace, imPalace, gAnarchy);
|
|
// first turn after anarchy -- don't show despotism palace!
|
|
updateNow();
|
|
applyToVisibleForms(FormAction::Update);
|
|
|
|
MessgEx::MessgExDlg &dlg = messgExDlg();
|
|
if ((ro.Happened & phGameEnd) != 0) { // game ended
|
|
int winners = 0;
|
|
if ((ro.Happened & phExtinct) != 0) {
|
|
dlg.openSound = QStringLiteral("MSG_GAMEOVER");
|
|
dlg.messageText = Tribes::tribe[static_cast<std::size_t>(me)]->tPhrase(QStringLiteral("GAMEOVER"));
|
|
dlg.iconKind = MessgEx::MessageIconKind::BigIcon;
|
|
dlg.iconIndex = 8;
|
|
} else if ((ro.Happened & phShipComplete) != 0) {
|
|
for (int p1 = 0; p1 < nPl; ++p1) {
|
|
if (((1 << p1) & ro.Alive) != 0) {
|
|
winners |= 1 << p1;
|
|
for (int i = 0; i < nShipPart; ++i) {
|
|
if (ro.Ship[p1].Parts[i] < ShipNeed[i])
|
|
winners &= ~(1 << p1);
|
|
}
|
|
}
|
|
}
|
|
Q_ASSERT(winners != 0);
|
|
if ((winners & (1 << me)) != 0) {
|
|
QString s;
|
|
for (int p1 = 0; p1 < nPl; ++p1) {
|
|
if (p1 != me && ((1 << p1) & winners) != 0) {
|
|
const QString shortName =
|
|
Tribes::tribe[static_cast<std::size_t>(p1)]->tPhrase(QStringLiteral("SHORTNAME"));
|
|
s = s.isEmpty() ? shortName
|
|
: formatPhrase(QStringLiteral("SHAREDWIN_CONCAT"), { s, shortName });
|
|
}
|
|
}
|
|
dlg.openSound = QStringLiteral("MSG_YOUWIN");
|
|
dlg.messageText = Tribes::tribe[static_cast<std::size_t>(me)]->tPhrase(QStringLiteral("MYSPACESHIP"));
|
|
if (!s.isEmpty())
|
|
dlg.messageText += QLatin1Char('\\') + formatPhrase(QStringLiteral("SHAREDWIN"), { s });
|
|
dlg.iconKind = MessgEx::MessageIconKind::BigIcon;
|
|
dlg.iconIndex = 9;
|
|
} else {
|
|
Q_ASSERT(me == 0);
|
|
dlg.openSound = QStringLiteral("MSG_GAMEOVER");
|
|
dlg.messageText.clear();
|
|
for (int p1 = 0; p1 < nPl; ++p1) {
|
|
if ((winners & (1 << p1)) != 0)
|
|
dlg.messageText +=
|
|
Tribes::tribe[static_cast<std::size_t>(p1)]->tPhrase(QStringLiteral("SPACESHIP1"));
|
|
}
|
|
dlg.messageText += QLatin1Char('\\') + phrases[QStringLiteral("SPACESHIP2")];
|
|
dlg.iconKind = MessgEx::MessageIconKind::EnemyShipComplete;
|
|
}
|
|
} else { // time up
|
|
Q_ASSERT(me == 0);
|
|
dlg.openSound = QStringLiteral("MSG_GAMEOVER");
|
|
dlg.messageText = !supervising ? Tribes::tribe[static_cast<std::size_t>(me)]->tPhrase(
|
|
QStringLiteral("TIMEUP"))
|
|
: phrases[QStringLiteral("TIMEUPSUPER")];
|
|
dlg.iconKind = MessgEx::MessageIconKind::Imp;
|
|
dlg.iconIndex = 22;
|
|
}
|
|
dlg.kind = MessageKind::Ok;
|
|
dlg.showModal();
|
|
if ((ro.Happened & phExtinct) == 0 && (ro.Happened & phShipComplete) == 0)
|
|
diaDlg().showNewContentCharts(WindowMode::Modal);
|
|
finishEarly();
|
|
return;
|
|
}
|
|
if (!supervising && ((1 << me) & ro.Alive) == 0) {
|
|
finishEarly();
|
|
return;
|
|
}
|
|
|
|
if (clientMode == cContinue && (dipMem[static_cast<std::size_t>(me)].sentCommand & 0xFF0F) == scContact) {
|
|
// contact was refused
|
|
if (ro.Treaty[dipMem[static_cast<std::size_t>(me)].pContact] >= trPeace)
|
|
contactRefused(dipMem[static_cast<std::size_t>(me)].pContact, QStringLiteral("FRREJECTED"));
|
|
else
|
|
MessgEx::soundMessageEx(Tribes::tribe[static_cast<std::size_t>(dipMem[static_cast<std::size_t>(me)].pContact)]->tPhrase(
|
|
QStringLiteral("FRREJECTED")),
|
|
QStringLiteral("NEGO_REJECTED"));
|
|
}
|
|
|
|
if (!supervising && age > myData->toldAge && (age > 0 || clientMode != cMovieTurn)) {
|
|
Tribes::Tribe &tribe = *Tribes::tribe[static_cast<std::size_t>(me)];
|
|
if (age == 0) {
|
|
if (phrases2FallenBackToEnglish)
|
|
dlg.messageText = tribe.tPhrase(QStringLiteral("AGE0"))
|
|
.arg(turnToString(ro.Turn))
|
|
.arg(Tribes::cityName(ClientTools::myCity[0].ID));
|
|
else
|
|
dlg.messageText = tribe.tString(phraseToQtFormat(phrases2[QStringLiteral("AGE0")]))
|
|
.arg(turnToString(ro.Turn));
|
|
} else {
|
|
dlg.messageText =
|
|
tribe.tPhrase(QStringLiteral("AGE%1").arg(age)).arg(turnToString(ro.Turn));
|
|
}
|
|
dlg.iconKind = MessgEx::MessageIconKind::Age;
|
|
dlg.iconIndex = age;
|
|
dlg.kind = MessageKind::Ok;
|
|
dlg.centerTo = newAgeCenterTo;
|
|
dlg.openSound = QStringLiteral("AGE_%1").arg(age);
|
|
QApplication::processEvents();
|
|
dlg.showModal();
|
|
myData->toldAge = age;
|
|
if (age > 0)
|
|
myData->toldTech[AgePreq[age]] = static_cast<std::int8_t>(ro.Tech[AgePreq[age]]);
|
|
}
|
|
|
|
if (myData->toldAlive != ro.Alive) {
|
|
for (int p1 = 0; p1 < nPl; ++p1) {
|
|
if (((myData->toldAlive - ro.Alive) & (1 << p1)) != 0) {
|
|
dlg.openSound = QStringLiteral("MSG_EXTINCT");
|
|
dlg.messageText = Tribes::tribe[static_cast<std::size_t>(p1)]
|
|
->tPhrase(QStringLiteral("EXTINCT"))
|
|
.arg(turnToString(ro.Turn));
|
|
if (ro.Alive == (1 << me))
|
|
dlg.messageText += phrases[QStringLiteral("EXTINCTALL")];
|
|
dlg.kind = MessageKind::Ok;
|
|
dlg.iconKind = MessgEx::MessageIconKind::Imp;
|
|
dlg.iconIndex = 21;
|
|
dlg.showModal();
|
|
}
|
|
}
|
|
if (clientMode != cMovieTurn && !supervising)
|
|
diaDlg().showNewContentCharts(WindowMode::Modal);
|
|
}
|
|
|
|
// tell changes of own credibility
|
|
if (!supervising) {
|
|
if (roughCredibility(ro.Credibility) != roughCredibility(myData->toldOwnCredibility)) {
|
|
const QString s = roughCredibility(ro.Credibility) > roughCredibility(myData->toldOwnCredibility)
|
|
? phrases[QStringLiteral("CREDUP")]
|
|
: phrases[QStringLiteral("CREDDOWN")];
|
|
MessgEx::tribeMessage(me,
|
|
formatPhraseText(s, { phrases.lookup(QStringLiteral("CREDIBILITY"),
|
|
roughCredibility(ro.Credibility)) }),
|
|
QString());
|
|
}
|
|
myData->toldOwnCredibility = ro.Credibility;
|
|
}
|
|
|
|
for (int i = 0; i < nWonder; ++i) {
|
|
bool ownWonder = false;
|
|
for (int cix = 0; cix < ro.nCity; ++cix) {
|
|
if (ClientTools::myCity[cix].Loc >= 0 && ClientTools::myCity[cix].ID == ro.Wonder[i].CityID) {
|
|
ownWonder = true;
|
|
break;
|
|
}
|
|
}
|
|
const QString wonderName = phrases.lookup(QStringLiteral("IMPROVEMENTS"), i);
|
|
const auto wonderDialog = [&](const QString &sound, const QString &text) {
|
|
dlg.openSound = sound;
|
|
dlg.messageText = text;
|
|
dlg.kind = MessageKind::OkHelp;
|
|
dlg.helpKind = Help::LinkCategory::Imp;
|
|
dlg.helpNo = i;
|
|
dlg.iconKind = MessgEx::MessageIconKind::Imp;
|
|
dlg.iconIndex = i;
|
|
dlg.showModal();
|
|
};
|
|
if (ro.Wonder[i].CityID != myData->toldWonders[static_cast<std::size_t>(i)].CityID) {
|
|
if (ro.Wonder[i].CityID == WonderDestroyed) { // tell about destroyed wonders
|
|
wonderDialog(QStringLiteral("WONDER_DESTROYED"),
|
|
formatPhraseText(phrases[QStringLiteral("WONDERDEST")], { wonderName }));
|
|
} else {
|
|
if (i == woManhattan) {
|
|
if (ro.Wonder[i].EffectiveOwner > me)
|
|
myData->coldWarStart = ro.Turn - 1;
|
|
else
|
|
myData->coldWarStart = ro.Turn;
|
|
}
|
|
if (!ownWonder) { // tell about newly built wonders
|
|
QString sound;
|
|
QString s;
|
|
if (i == woManhattan) {
|
|
sound = QStringLiteral("MSG_COLDWAR");
|
|
s = Tribes::tribe[static_cast<std::size_t>(ro.Wonder[i].EffectiveOwner)]->tPhrase(
|
|
QStringLiteral("COLDWAR"));
|
|
} else if (ro.Wonder[i].EffectiveOwner >= 0) {
|
|
sound = QStringLiteral("WONDER_BUILT");
|
|
s = Tribes::tribe[static_cast<std::size_t>(ro.Wonder[i].EffectiveOwner)]->tPhrase(
|
|
QStringLiteral("WONDERBUILT"));
|
|
} else {
|
|
sound = QStringLiteral("MSG_DEFAULT");
|
|
s = phraseToQtFormat(phrases[QStringLiteral("WONDERBUILTEXP")]);
|
|
// already expired when built
|
|
}
|
|
wonderDialog(sound, formatPhraseText(s, { wonderName, Tribes::cityName(ro.Wonder[i].CityID) }));
|
|
}
|
|
}
|
|
} else if (ro.Wonder[i].EffectiveOwner != myData->toldWonders[static_cast<std::size_t>(i)].EffectiveOwner
|
|
&& ro.Wonder[i].CityID > WonderDestroyed) {
|
|
if (ro.Wonder[i].EffectiveOwner < 0) {
|
|
if (i != woMir) // tell about expired wonders
|
|
wonderDialog(QStringLiteral("WONDER_EXPIRED"),
|
|
formatPhraseText(phrases[QStringLiteral("WONDEREXP")],
|
|
{ wonderName, Tribes::cityName(ro.Wonder[i].CityID) }));
|
|
} else if (myData->toldWonders[static_cast<std::size_t>(i)].EffectiveOwner >= 0 && !ownWonder) {
|
|
// tell about capture of wonders
|
|
wonderDialog(QStringLiteral("WONDER_CAPTURED"),
|
|
formatPhraseText(Tribes::tribe[static_cast<std::size_t>(ro.Wonder[i].EffectiveOwner)]
|
|
->tPhrase(QStringLiteral("WONDERCAPT")),
|
|
{ wonderName, Tribes::cityName(ro.Wonder[i].CityID) }));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ro.Turn == myData->coldWarStart + ColdWarTurns) {
|
|
MessgEx::soundMessageEx(phrases[QStringLiteral("COLDWAREND")], QStringLiteral("MSG_DEFAULT"));
|
|
myData->coldWarStart = -ColdWarTurns - 1;
|
|
}
|
|
|
|
tellNewModels();
|
|
} // clientMode != cResume
|
|
myData->toldAlive = ro.Alive;
|
|
std::memcpy(myData->toldWonders.data(), ro.Wonder, sizeof(myData->toldWonders));
|
|
|
|
if (clientMode != cResume) { // tell about new techs
|
|
MessgEx::MessgExDlg &dlg = messgExDlg();
|
|
for (int ad = 0; ad < nAdv; ++ad) {
|
|
if (((ro.TestFlags & tfAllTechs) == 0
|
|
&& ((ro.Tech[ad] >= tsApplicable) != (myData->toldTech[static_cast<std::size_t>(ad)] >= tsApplicable)))
|
|
|| (IsFutureTech(ad) && ro.Tech[ad] != myData->toldTech[static_cast<std::size_t>(ad)])) {
|
|
if (gameMode != cMovie)
|
|
dlg.openSound = QStringLiteral("NEWADVANCE_%1").arg(age);
|
|
QString item2 = phrases.lookup(QStringLiteral("ADVANCES"), ad);
|
|
if (IsFutureTech(ad))
|
|
item2 += QStringLiteral(" %1").arg(ro.Tech[ad]);
|
|
dlg.messageText = formatPhrase(QStringLiteral("RESEARCH_GENERAL"), { item2 });
|
|
dlg.kind = MessageKind::OkHelp;
|
|
dlg.helpKind = Help::LinkCategory::Adv;
|
|
dlg.helpNo = ad;
|
|
dlg.iconKind = MessgEx::MessageIconKind::Book;
|
|
dlg.iconIndex = -1;
|
|
for (const AdvBookIconEntry &entry : AdvBookIcon) {
|
|
if (entry.adv == ad)
|
|
dlg.iconIndex = entry.icon;
|
|
}
|
|
dlg.showModal();
|
|
myData->toldTech[static_cast<std::size_t>(ad)] = static_cast<std::int8_t>(ro.Tech[ad]);
|
|
for (int i = gMonarchy; i < nGov; ++i) {
|
|
if (GovPreq[i] == ad)
|
|
newGovAvailable = i;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (clientMode == cTurn) {
|
|
if ((ro.Happened & phTech) != 0 && myData->farTech != adNexus)
|
|
chooseResearch();
|
|
|
|
if ((ro.Happened & phChangeGov) != 0) {
|
|
modalSelectDlg().showNewContent(WindowMode::Modal, Select::ListKind::Government);
|
|
ClientTools::server(sSetGovernment, me, modalSelectDlg().result, nullptr);
|
|
ClientTools::cityOptimizer_BeginOfTurn();
|
|
updatePanel = true;
|
|
}
|
|
}
|
|
|
|
if (!supervising && (clientMode == cTurn || clientMode == cMovieTurn)) {
|
|
for (int cix = 0; cix < ro.nCity; ++cix)
|
|
ClientTools::myCity[cix].Status &= ~csToldBombard;
|
|
}
|
|
|
|
if ((clientMode == cTurn || clientMode == cMovieTurn) && ro.Government != gAnarchy) {
|
|
// tell what happened in cities
|
|
MessgEx::MessgExDlg &dlg = messgExDlg();
|
|
for (int wondersOnly = 1; wondersOnly >= 0; --wondersOnly) {
|
|
for (int cix = 0; cix < ro.nCity; ++cix) {
|
|
TCity &city = ClientTools::myCity[cix];
|
|
if (!(ro.Turn > 0 && city.Loc >= 0 && (city.Flags & chCaptured) == 0
|
|
&& ((wondersOnly != 0)
|
|
== ((city.Flags & chProduction) != 0 && (city.Project0 & cpImp) != 0
|
|
&& (city.Project0 & cpIndex) < nWonder))))
|
|
continue;
|
|
if (wondersOnly != 0) { // tell about newly built wonder
|
|
dlg.openSound = QStringLiteral("WONDER_BUILT");
|
|
dlg.messageText = formatPhraseText(
|
|
Tribes::tribe[static_cast<std::size_t>(me)]->tPhrase(QStringLiteral("WONDERBUILTOWN")),
|
|
{ phrases.lookup(QStringLiteral("IMPROVEMENTS"), city.Project0 & cpIndex),
|
|
Tribes::cityName(city.ID) });
|
|
dlg.kind = MessageKind::OkHelp;
|
|
dlg.helpKind = Help::LinkCategory::Imp;
|
|
dlg.helpNo = city.Project0 & cpIndex;
|
|
dlg.iconKind = MessgEx::MessageIconKind::Imp;
|
|
dlg.iconIndex = city.Project0 & cpIndex;
|
|
dlg.showModal();
|
|
}
|
|
if (!supervising && clientMode == cTurn) {
|
|
bool allowCityScreen = true;
|
|
if ((city.Status & 7) != 0 && (city.Project & (cpImp + cpIndex)) == cpImp + imTrGoods) {
|
|
if (myData->impOrder[static_cast<std::size_t>((city.Status & 7) - 1)][0] >= 0) {
|
|
if (ClientTools::autoBuild(cix, myData->impOrder[static_cast<std::size_t>((city.Status & 7) - 1)]))
|
|
allowCityScreen = false;
|
|
else if ((city.Flags & chProduction) != 0)
|
|
city.Flags = (city.Flags & ~chProduction) | chAllImpsMade;
|
|
} else {
|
|
city.Flags |= chTypeDel;
|
|
}
|
|
}
|
|
if ((city.Size >= NeedAqueductSize && ro.Tech[Imp[imAqueduct].Preq] < tsApplicable)
|
|
|| (city.Size >= NeedSewerSize && ro.Tech[Imp[imSewer].Preq] < tsApplicable))
|
|
city.Flags &= ~chNoGrowthWarning; // don't remind of unknown building
|
|
if ((city.Flags & chNoSettlerProd) == 0)
|
|
city.Status &= ~csToldDelay;
|
|
else if ((city.Status & csToldDelay) == 0)
|
|
city.Status |= csToldDelay;
|
|
else
|
|
city.Flags &= ~chNoSettlerProd;
|
|
if (ClientTools::hasSaveOption(optionChecked, ClientTools::soRepScreens)) {
|
|
if ((city.Flags & cityRepMask) != 0 && allowCityScreen) { // show what happened in cities
|
|
setTroopLoc(city.Loc);
|
|
m_markCityLoc = city.Loc;
|
|
panelPaint();
|
|
cityDlg().closeAction = CityScreen::CityCloseAction::None;
|
|
cityDlg().showNewContent(WindowMode::Modal, city.Loc, city.Flags & cityRepMask);
|
|
updatePanel = true;
|
|
}
|
|
} else if ((city.Flags & cityRepMask) != 0) {
|
|
showCityList = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (clientMode == cTurn && newGovAvailable >= 0) {
|
|
MessgEx::MessgExDlg &dlg = messgExDlg();
|
|
dlg.messageText = formatPhrase(QStringLiteral("AUTOREVOLUTION"),
|
|
{ phrases.lookup(QStringLiteral("GOVERNMENT"), newGovAvailable) });
|
|
dlg.kind = MessageKind::YesNo;
|
|
dlg.iconKind = MessgEx::MessageIconKind::PureIcon;
|
|
dlg.iconIndex = 6 + newGovAvailable;
|
|
if (dlg.showModal() == Dpi::ModalResult::Ok)
|
|
ClientTools::server(sRevolution, me, 0, nullptr);
|
|
}
|
|
|
|
if (clientMode == cTurn || clientMode == cMovieTurn) {
|
|
if ((ro.Happened & phGliderLost) != 0)
|
|
MessgEx::contextMessage(phrases[QStringLiteral("GLIDERLOST")], QStringLiteral("MSG_DEFAULT"),
|
|
Help::LinkCategory::Model, 200);
|
|
if ((ro.Happened & phPlaneLost) != 0)
|
|
MessgEx::contextMessage(phrases[QStringLiteral("PLANELOST")], QStringLiteral("MSG_DEFAULT"),
|
|
Help::LinkCategory::Feature, mcFuel);
|
|
if ((ro.Happened & phPeaceEvacuation) != 0) {
|
|
for (int p1 = 0; p1 < nPl; ++p1) {
|
|
if (((1 << p1) & myData->peaceEvaHappened) != 0)
|
|
MessgEx::soundMessageEx(
|
|
Tribes::tribe[static_cast<std::size_t>(p1)]->tPhrase(QStringLiteral("WITHDRAW")),
|
|
QStringLiteral("MSG_DEFAULT"));
|
|
}
|
|
}
|
|
if ((ro.Happened & phPeaceViolation) != 0) {
|
|
for (int p1 = 0; p1 < nPl; ++p1) {
|
|
if (((1 << p1) & ro.Alive) != 0 && ro.EvaStart[p1] == ro.Turn)
|
|
MessgEx::soundMessageEx(Tribes::tribe[static_cast<std::size_t>(p1)]
|
|
->tPhrase(QStringLiteral("VIOLATION"))
|
|
.arg(turnToString(ro.Turn + PeaceEvaTurns - 1)),
|
|
QStringLiteral("MSG_WITHDRAW"));
|
|
}
|
|
}
|
|
tellNewContacts();
|
|
}
|
|
|
|
if (clientMode == cMovieTurn) {
|
|
updateNow();
|
|
} else if (clientMode == cTurn) {
|
|
if (updatePanel)
|
|
updateViews();
|
|
QApplication::processEvents();
|
|
|
|
if (!supervising) {
|
|
for (int uix = 0; uix < ro.nUn; ++uix) {
|
|
TUn &un = ClientTools::myUn[uix];
|
|
if (un.Loc < 0)
|
|
continue;
|
|
if ((un.Flags & unWithdrawn) != 0)
|
|
un.Status = 0;
|
|
if (un.Health == 100)
|
|
un.Status &= ~IsoEngine::usRecover;
|
|
if (un.Master >= 0 || ClientTools::unitExhausted(uix))
|
|
un.Status &= ~usWaiting;
|
|
else
|
|
un.Status |= usWaiting;
|
|
checkToldNoReturn(uix);
|
|
if ((un.Status & IsoEngine::usGoto) != 0) { // continue multi-turn goto
|
|
setUnFocus(uix);
|
|
setTroopLoc(un.Loc);
|
|
focusOnLoc(m_troopLoc, flRepaintPanel | flImmUpdate);
|
|
TMoveAdviceData moveAdviceData;
|
|
int moveResult;
|
|
if ((un.Status >> 16) == 0x7FFF)
|
|
moveResult = ClientTools::getMoveAdvice(IsoEngine::unFocus, maNextCity, moveAdviceData);
|
|
else
|
|
moveResult = ClientTools::getMoveAdvice(IsoEngine::unFocus, un.Status >> 16, moveAdviceData);
|
|
bool stop;
|
|
if (moveResult >= rExecuted) { // !!! Shinkansen
|
|
moveResult = eOK;
|
|
bool ok = true;
|
|
for (int i = 0; i < moveAdviceData.nStep; ++i) {
|
|
const int loc1 = ClientTools::dLoc(un.Loc, moveAdviceData.dx[i], moveAdviceData.dy[i]);
|
|
if ((ClientTools::myMap[loc1] & (fCity | fOwned)) == static_cast<std::uint32_t>(fCity)
|
|
// don't capture cities during auto move
|
|
|| (ClientTools::myMap[loc1] & (fUnit | fOwned)) == static_cast<std::uint32_t>(fUnit)) {
|
|
// don't attack during auto move
|
|
ok = false;
|
|
break;
|
|
}
|
|
const int moveOptions = loc1 == moveAdviceData.ToLoc
|
|
|| (moveAdviceData.ToLoc == maNextCity
|
|
&& (ClientTools::myMap[loc1] & fCity) != 0)
|
|
? muAutoNoWait
|
|
: 0;
|
|
moveResult = moveUnit(moveAdviceData.dx[i], moveAdviceData.dy[i], moveOptions);
|
|
if (moveResult < rExecuted || moveResult == eEnemySpotted) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
}
|
|
stop = !ok || un.Loc == moveAdviceData.ToLoc
|
|
|| (moveAdviceData.ToLoc == maNextCity && (ClientTools::myMap[un.Loc] & fCity) != 0);
|
|
} else {
|
|
moveResult = eOK;
|
|
stop = true;
|
|
}
|
|
if (moveResult != eDied) {
|
|
if (stop)
|
|
un.Status &= 0xFFFF - IsoEngine::usGoto;
|
|
else
|
|
un.Status &= ~usWaiting;
|
|
}
|
|
}
|
|
if ((un.Status & (IsoEngine::usEnhance | IsoEngine::usGoto)) == IsoEngine::usEnhance) {
|
|
// continue terrain enhancement
|
|
const int moveResult = ClientTools::processEnhancement(uix, myData->enhancementJobs);
|
|
if (moveResult != eDied) {
|
|
if (moveResult == eJobDone)
|
|
un.Status &= ~IsoEngine::usEnhance;
|
|
else
|
|
un.Status &= ~usWaiting;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
m_haveStrategyAdvice = false;
|
|
m_goOnPhase = true;
|
|
if (supervising || gameMode == cMovie) {
|
|
setTroopLoc(-1);
|
|
paintAll();
|
|
} else {
|
|
if (clientMode >= scContact)
|
|
setUnFocus(-1);
|
|
else
|
|
nextUnit(-1, false);
|
|
if (IsoEngine::unFocus < 0) {
|
|
unStartLoc = -1;
|
|
if (ClientTools::isMultiPlayerGame() || clientMode == cResume) {
|
|
if (ro.nCity > 0)
|
|
focusOnLoc(ClientTools::myCity[0].Loc);
|
|
else
|
|
focusOnLoc(g.lx * g.ly / 2);
|
|
}
|
|
setTroopLoc(-1);
|
|
panelPaint();
|
|
}
|
|
if (showCityList)
|
|
listDlg().showNewContent(WindowMode::Persistent, Select::ListKind::CityEvents);
|
|
}
|
|
}
|
|
|
|
void MainScreen::nextUnit(int nearLoc, bool autoTurn)
|
|
{
|
|
if (clientMode >= scContact)
|
|
return;
|
|
const TPlayerContext &ro = *ClientTools::myRO;
|
|
TUn *myUn = ClientTools::myUn;
|
|
IsoEngine::destinationMarkOn = false;
|
|
paintDestination();
|
|
int newFocus = -1;
|
|
for (int gotoOnly = m_goOnPhase ? 1 : 0; gotoOnly >= 0; --gotoOnly) {
|
|
newFocus = -1;
|
|
double dist = 0;
|
|
for (int i = 1; i <= ro.nUn; ++i) {
|
|
const int uix = (IsoEngine::unFocus + i) % ro.nUn;
|
|
if (myUn[uix].Loc >= 0 && myUn[uix].Job == jNone
|
|
&& (myUn[uix].Status & (IsoEngine::usStay | IsoEngine::usRecover | usWaiting)) == usWaiting
|
|
&& (gotoOnly == 0 || (myUn[uix].Status & IsoEngine::usGoto) != 0)) {
|
|
if (nearLoc < 0) {
|
|
newFocus = uix;
|
|
break;
|
|
}
|
|
const double testDist = ClientTools::distance(nearLoc, myUn[uix].Loc);
|
|
if (newFocus < 0 || testDist < dist) {
|
|
newFocus = uix;
|
|
dist = testDist;
|
|
}
|
|
}
|
|
}
|
|
if (gotoOnly != 0) {
|
|
if (newFocus < 0)
|
|
m_goOnPhase = false;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
if (newFocus >= 0) {
|
|
setUnFocus(newFocus);
|
|
setTroopLoc(myUn[newFocus].Loc);
|
|
focusOnLoc(m_troopLoc, flRepaintPanel);
|
|
} else if (autoTurn && !ClientTools::hasSaveOption(optionChecked, ClientTools::soWaitTurn)) {
|
|
m_turnComplete = true;
|
|
setUnFocus(-1);
|
|
setTroopLoc(-1);
|
|
QTimer::singleShot(0, this, [this] { endTurn(); });
|
|
} else {
|
|
if (!m_turnComplete && m_eot->isVisible())
|
|
Sound::play(QStringLiteral("TURNEND"));
|
|
m_turnComplete = true;
|
|
setUnFocus(-1);
|
|
setTroopLoc(-1);
|
|
panelPaint();
|
|
}
|
|
}
|
|
|
|
bool MainScreen::endTurn(bool wasSkipped)
|
|
{
|
|
TNewGameData &g = ClientTools::g;
|
|
const int me = ClientTools::me;
|
|
if (clientMode >= scDipOffer)
|
|
return false;
|
|
|
|
if (supervising && me != 0) {
|
|
applyToVisibleForms(FormAction::Close);
|
|
ClientTools::itsMeAgain(0);
|
|
}
|
|
const TPlayerContext &ro = *ClientTools::myRO;
|
|
TUn *myUn = ClientTools::myUn;
|
|
|
|
ClientTools::cityOptimizer_EndOfTurn();
|
|
|
|
if (!wasSkipped) { // check warnings
|
|
// need to move planes home?
|
|
for (int uix = 0; uix < ro.nUn; ++uix) {
|
|
TUn &un = myUn[uix];
|
|
if (un.Loc >= 0 && ClientTools::myModel[un.mix].Domain == dAir && (un.Status & usToldNoReturn) == 0
|
|
&& un.Master < 0 && (ClientTools::myMap[un.Loc] & fCity) == 0
|
|
&& (ClientTools::myMap[un.Loc] & fTerImp) != static_cast<std::uint32_t>(tiBase)) {
|
|
TPlaneReturnData planeReturnData;
|
|
planeReturnData.Fuel = un.Fuel;
|
|
planeReturnData.Loc = un.Loc;
|
|
planeReturnData.Movement = 0; // end turn without further movement?
|
|
if (ClientTools::server(sGetPlaneReturn, me, uix, &planeReturnData) == eNoWay) {
|
|
int centerLoc = un.Loc + g.lx * 6;
|
|
// centering the unit itself would make it covered by the query dialog
|
|
while (centerLoc >= g.lx * g.ly)
|
|
centerLoc -= g.lx * 2;
|
|
centre(centerLoc);
|
|
setTroopLoc(-1);
|
|
paintAll();
|
|
|
|
const QString msgItem = ClientTools::myModel[un.mix].Kind == mkSpecial_Glider
|
|
? QStringLiteral("LOWFUEL_GLIDER")
|
|
: QStringLiteral("LOWFUEL");
|
|
if (MessgEx::simpleQuery(MessageKind::YesNo, phrases[msgItem], QStringLiteral("WARNING_LOWSUPPORT"))
|
|
!= Dpi::ModalResult::Ok) {
|
|
setUnFocus(uix);
|
|
setTroopLoc(un.Loc);
|
|
panelPaint();
|
|
return false;
|
|
}
|
|
myUn[uix].Status |= usToldNoReturn;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!supervising && (ro.TestFlags & tfImmImprove) == 0 && ro.Government != gAnarchy
|
|
&& ro.Money + taxSum < 0 && ro.TaxRate < 100) { // low funds!
|
|
MessgEx::MessgExDlg &dlg = messgExDlg();
|
|
dlg.openSound = QStringLiteral("WARNING_LOWFUNDS");
|
|
dlg.messageText = phrases[QStringLiteral("LOWFUNDS")];
|
|
dlg.kind = MessageKind::YesNo;
|
|
dlg.iconKind = MessgEx::MessageIconKind::Imp;
|
|
dlg.iconIndex = imTrGoods;
|
|
if (dlg.showModal() != Dpi::ModalResult::Ok)
|
|
return false;
|
|
}
|
|
|
|
if (ro.Government != gAnarchy) {
|
|
for (int cix = 0; cix < ro.nCity; ++cix) {
|
|
TCity &city = ClientTools::myCity[cix];
|
|
if (city.Loc < 0 || (city.Flags & chCaptured) != 0)
|
|
continue;
|
|
bool zoom = false;
|
|
TCityReport cityReport;
|
|
cityReport.HypoTiles = -1;
|
|
cityReport.HypoTax = -1;
|
|
cityReport.HypoLux = -1;
|
|
ClientTools::server(sGetCityReport, me, cix, &cityReport);
|
|
|
|
MessgEx::MessgExDlg &dlg = messgExDlg();
|
|
if (cityReport.Working - cityReport.Happy > (city.Size >> 1) && (city.Flags & chCaptured) <= 0x10000) {
|
|
dlg.openSound = QStringLiteral("WARNING_DISORDER");
|
|
const QString msgItem = (city.Status & csResourceWeightsMask) == 0
|
|
? QStringLiteral("DISORDER")
|
|
: QStringLiteral("DISORDER_UNREST");
|
|
dlg.messageText = formatPhrase(msgItem, { Tribes::cityName(city.ID) });
|
|
dlg.kind = MessageKind::YesNo;
|
|
zoom = dlg.showModal() != Dpi::ModalResult::Ok;
|
|
}
|
|
if (!zoom && city.Food + cityReport.FoodRep - cityReport.Eaten < 0) {
|
|
dlg.openSound = QStringLiteral("WARNING_FAMINE");
|
|
QString msgItem;
|
|
if ((city.Status & csResourceWeightsMask) == 0)
|
|
msgItem = QStringLiteral("FAMINE");
|
|
else if (cityReport.Deployed != 0 && isResourceUnused(cix, 1, 0))
|
|
msgItem = QStringLiteral("FAMINE_UNREST");
|
|
else
|
|
msgItem = QStringLiteral("FAMINE_TILES");
|
|
dlg.messageText = formatPhrase(msgItem, { Tribes::cityName(city.ID) });
|
|
dlg.kind = MessageKind::YesNo;
|
|
dlg.iconKind = MessgEx::MessageIconKind::Imp;
|
|
dlg.iconIndex = 22;
|
|
zoom = dlg.showModal() != Dpi::ModalResult::Ok;
|
|
}
|
|
if (!zoom && cityReport.ProdRep < cityReport.Support) {
|
|
dlg.openSound = QStringLiteral("WARNING_LOWSUPPORT");
|
|
QString msgItem;
|
|
if ((city.Status & csResourceWeightsMask) == 0)
|
|
msgItem = QStringLiteral("LOWSUPPORT");
|
|
else if (cityReport.Deployed != 0 && isResourceUnused(cix, 0, 1))
|
|
msgItem = QStringLiteral("LOWSUPPORT_UNREST");
|
|
else
|
|
msgItem = QStringLiteral("LOWSUPPORT_TILES");
|
|
dlg.messageText = formatPhrase(msgItem, { Tribes::cityName(city.ID) });
|
|
dlg.kind = MessageKind::YesNo;
|
|
dlg.iconKind = MessgEx::MessageIconKind::Imp;
|
|
dlg.iconIndex = 29;
|
|
zoom = dlg.showModal() != Dpi::ModalResult::Ok;
|
|
}
|
|
if (zoom) { // zoom to city
|
|
zoomToCity(city.Loc);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((ro.Happened & phTech) != 0 && ro.ResearchTech < 0 && myData->farTech != adNexus) {
|
|
if (!chooseResearch())
|
|
return false;
|
|
}
|
|
}
|
|
|
|
rememberPeaceViolation();
|
|
|
|
setUnFocus(-1);
|
|
for (int uix = 0; uix < ro.nUn; ++uix)
|
|
myUn[uix].Status &= usPersistent;
|
|
|
|
cityDlg().closeAction = CityScreen::CityCloseAction::None;
|
|
if (ClientTools::isMultiPlayerGame()) {
|
|
applyToVisibleForms(FormAction::Close); // close windows for next player
|
|
} else {
|
|
if (cityDlg().isVisible())
|
|
cityDlg().close();
|
|
if (unitStatDlg().isVisible())
|
|
unitStatDlg().close();
|
|
}
|
|
applyToVisibleForms(FormAction::Disable);
|
|
|
|
if (ClientTools::server(sTurn, m_pTurn, 0, nullptr) >= rExecuted) {
|
|
m_eot->setToolTip(phrases[m_jump[static_cast<std::size_t>(m_pTurn)] > 0 ? QStringLiteral("BTN_STOP")
|
|
: QStringLiteral("BTN_SKIP")]);
|
|
setTroopLoc(-1);
|
|
m_pTurn = -1;
|
|
m_pLogo = -1;
|
|
m_unitInfoBtn->setVisible(false);
|
|
m_unitBtn->setVisible(false);
|
|
m_terrainBtn->setVisible(false);
|
|
m_eot->setButtonIndex(eotCancel);
|
|
m_eot->setVisible(true);
|
|
m_mapValid = false;
|
|
panelPaint();
|
|
updateNow();
|
|
setClientMode(-1);
|
|
m_idle = false;
|
|
m_skipped = wasSkipped;
|
|
for (int p1 = 1; p1 < nPl; ++p1) {
|
|
if (g.RO[p1]) {
|
|
m_skipped = true; // don't show enemy moves in hotseat mode
|
|
break;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
panelPaint();
|
|
return false;
|
|
}
|
|
|
|
void MainScreen::endNego()
|
|
{
|
|
if (negoDlg().isVisible())
|
|
negoDlg().close();
|
|
m_haveStrategyAdvice = false;
|
|
m_eot->setButtonIndex(eotCancel);
|
|
m_eot->setVisible(true);
|
|
panelPaint();
|
|
updateNow();
|
|
setClientMode(-1);
|
|
m_idle = false;
|
|
}
|
|
|
|
bool MainScreen::zoomToCity(int loc, bool nextUnitOnClose, int showEvent)
|
|
{
|
|
const bool result = (ClientTools::myMap[loc] & (fOwned | fSpiedOut)) != 0;
|
|
if (result) {
|
|
CityScreen::CityDlg &dlg = cityDlg();
|
|
if (clientMode >= scContact) {
|
|
dlg.closeAction = CityScreen::CityCloseAction::None;
|
|
dlg.restoreUnFocus = -1;
|
|
} else if (nextUnitOnClose) {
|
|
dlg.closeAction = CityScreen::CityCloseAction::StepFocus;
|
|
dlg.restoreUnFocus = -1;
|
|
} else if (!dlg.isVisible()) {
|
|
dlg.closeAction = CityScreen::CityCloseAction::RestoreFocus;
|
|
dlg.restoreUnFocus = IsoEngine::unFocus;
|
|
}
|
|
setUnFocus(-1);
|
|
setTroopLoc(loc);
|
|
m_markCityLoc = loc;
|
|
panelPaint();
|
|
dlg.showNewContent(WindowMode::Persistent, loc, static_cast<std::uint32_t>(showEvent));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
void MainScreen::cityClosed(int activateUix, bool stepFocus, bool selectFocus)
|
|
{
|
|
if (supervising) {
|
|
setTroopLoc(-1);
|
|
panelPaint();
|
|
} else if (activateUix >= 0) {
|
|
setUnFocus(activateUix);
|
|
setTroopLoc(ClientTools::myUn[activateUix].Loc);
|
|
if (selectFocus)
|
|
focusOnLoc(m_troopLoc, flRepaintPanel);
|
|
else
|
|
panelPaint();
|
|
} else if (stepFocus) {
|
|
nextUnit(m_troopLoc, true);
|
|
} else {
|
|
setTroopLoc(-1);
|
|
panelPaint();
|
|
}
|
|
}
|
|
|
|
} // namespace Term
|
|
} // namespace Cevo
|