main window and many fixes
This commit is contained in:
1 parent
80c329a697
commit
69700f8b65
18 files changed
+3280
-95
No files matched your search
@@ -27,10 +27,12 @@
|
||||
// knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
#include "Term.MainScreen.h"
|
||||
#include "Term.MainScreen.Menus.h"
|
||||
|
||||
#include "Cevo/Database.h"
|
||||
#include "ClientTools.h"
|
||||
#include "Global.h"
|
||||
#include "Sound.h"
|
||||
#include "Tribes.h"
|
||||
|
||||
#include <QApplication>
|
||||
@@ -54,7 +56,8 @@ MainScreen::MainScreen(QWidget *parent) : DrawDlg(parent)
|
||||
resize(800, 480);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
onCloseQuery = [this] {
|
||||
// TODO: when not closable, idle and playing, the original resigns (mResign.Click).
|
||||
if (!m_closable && m_idle && ClientTools::me == 0 && clientMode < scContact)
|
||||
menuCommand(MenuCommand::Resign);
|
||||
return m_closable;
|
||||
};
|
||||
|
||||
@@ -66,7 +69,9 @@ MainScreen::MainScreen(QWidget *parent) : DrawDlg(parent)
|
||||
m_topBar.canvas().font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
|
||||
m_offscreen.canvas().font().assign(UniFont[static_cast<std::size_t>(FontType::Small)]);
|
||||
createControls();
|
||||
|
||||
loadSettings();
|
||||
createMenus();
|
||||
wireControls();
|
||||
mainScreenZoomToCity = [this](int loc, bool nextUnitOnClose, int showEvent) {
|
||||
return zoomToCity(loc, nextUnitOnClose, showEvent);
|
||||
};
|
||||
@@ -381,14 +386,21 @@ int MainScreen::dipCall(int command)
|
||||
mem.sentCommand = command;
|
||||
mem.formerTreaty = ClientTools::myRO->Treaty[mem.pContact];
|
||||
if (command == scDipCancelTreaty) {
|
||||
// TODO: Sound.pas not ported.
|
||||
Sound::play(QStringLiteral("CANCELTREATY"));
|
||||
} else if (command == scDipAccept) {
|
||||
for (int i = 0; i < receivedOffer.nDeliver; ++i)
|
||||
mem.receivedPrices.set(static_cast<std::size_t>(receivedOffer.Price[i] >> 24));
|
||||
for (int i = 0; i < receivedOffer.nCost; ++i)
|
||||
mem.deliveredPrices.set(
|
||||
static_cast<std::size_t>(receivedOffer.Price[receivedOffer.nDeliver + i] >> 24));
|
||||
// TODO: Sound.pas not ported (NEWTREATY/ACCEPTOFFER distinction).
|
||||
bool isTreatyDeal = false;
|
||||
for (int i = 0; i < receivedOffer.nDeliver + receivedOffer.nCost; ++i) {
|
||||
if ((receivedOffer.Price[i] & opMask) == opTreaty) {
|
||||
isTreatyDeal = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Sound::play(isTreatyDeal ? QStringLiteral("NEWTREATY") : QStringLiteral("ACCEPTOFFER"));
|
||||
}
|
||||
cityDlg().closeAction = CityScreen::CityCloseAction::None;
|
||||
closeDialogsForNextPlayer(*this);
|
||||
@@ -440,25 +452,27 @@ void MainScreen::setAIName(int p, const QString &name)
|
||||
bool MainScreen::contactRefused(int p, const QString &item)
|
||||
{
|
||||
Q_ASSERT(ClientTools::myRO->Treaty[p] >= trPeace);
|
||||
const QString s = Tribes::tribe[static_cast<std::size_t>(p)]->tPhrase(item);
|
||||
QString s = Tribes::tribe[static_cast<std::size_t>(p)]->tPhrase(item);
|
||||
if (ClientTools::myRO->Turn < ClientTools::myRO->LastCancelTreaty[p] + CancelTreatyTurns) {
|
||||
// TODO: Phrases/SimpleMessage dialog not shown - needs Messg.pas's
|
||||
// simpleMessage() wired through an injection point if ever needed
|
||||
// from here; the important part (refusing the cancel) still works.
|
||||
simpleMessage(s);
|
||||
return false;
|
||||
}
|
||||
const Dpi::ModalResult result =
|
||||
MessgEx::simpleQuery(MessageKind::YesNo, s, QStringLiteral("NEGO_REJECTED"));
|
||||
if (result == Dpi::ModalResult::Ok) {
|
||||
// TODO: Sound.pas not ported.
|
||||
int dummy = 0;
|
||||
ClientTools::server(sCancelTreaty, ClientTools::me, 0, &dummy);
|
||||
if (ClientTools::myRO->Treaty[p] == trNone)
|
||||
ClientTools::cityOptimizer_BeginOfTurn();
|
||||
// TODO: needs the real main map (not ported yet) to repaint.
|
||||
return true;
|
||||
switch (ClientTools::myRO->Treaty[p]) {
|
||||
case trPeace: s += QLatin1Char(' ') + phrases[QStringLiteral("FRCANCELQUERY_PEACE")]; break;
|
||||
case trFriendlyContact: s += QLatin1Char(' ') + phrases[QStringLiteral("FRCANCELQUERY_FRIENDLY")]; break;
|
||||
case trAlliance: s += QLatin1Char(' ') + phrases[QStringLiteral("FRCANCELQUERY_ALLIANCE")]; break;
|
||||
default: break;
|
||||
}
|
||||
return false;
|
||||
if (MessgEx::simpleQuery(MessageKind::YesNo, s, QStringLiteral("NEGO_REJECTED")) != Dpi::ModalResult::Ok)
|
||||
return false;
|
||||
Sound::play(QStringLiteral("CANCELTREATY"));
|
||||
ClientTools::server(sCancelTreaty, ClientTools::me, 0, nullptr);
|
||||
if (ClientTools::myRO->Treaty[p] == trNone)
|
||||
ClientTools::cityOptimizer_BeginOfTurn();
|
||||
// peace treaty was cancelled -- use formerly forbidden tiles
|
||||
m_mapValid = false;
|
||||
paintAllMaps();
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainScreen::getTribeList()
|
||||
|
||||
Reference in new issue
Block a user