multiple sparce implementations for main window
This commit is contained in:
1 parent
8e7d483471
commit
e59988ab1d
9 files changed
+1091
-25
No files matched your search
@@ -137,6 +137,8 @@ set(PROJECT_SOURCES
|
|||||||
game/localplayer/TechTree.ui
|
game/localplayer/TechTree.ui
|
||||||
game/localplayer/Term.cpp
|
game/localplayer/Term.cpp
|
||||||
game/localplayer/Term.h
|
game/localplayer/Term.h
|
||||||
|
game/localplayer/Term.MainScreen.cpp
|
||||||
|
game/localplayer/Term.MainScreen.h
|
||||||
game/localplayer/Tribes.cpp
|
game/localplayer/Tribes.cpp
|
||||||
game/localplayer/Tribes.h
|
game/localplayer/Tribes.h
|
||||||
game/localplayer/Help.cpp
|
game/localplayer/Help.cpp
|
||||||
|
|||||||
@@ -85,13 +85,13 @@ EnhanceDlg::EnhanceDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::EnhanceD
|
|||||||
|
|
||||||
popup = new QMenu(this);
|
popup = new QMenu(this);
|
||||||
for (int terrType = fGrass; terrType <= fMountains; ++terrType) {
|
for (int terrType = fGrass; terrType <= fMountains; ++terrType) {
|
||||||
if (terrType == fJungle)
|
if (terrType == Term::fJungle)
|
||||||
continue;
|
continue;
|
||||||
QString caption;
|
QString caption;
|
||||||
if (terrType == fGrass)
|
if (terrType == fGrass)
|
||||||
caption = phrase(QStringLiteral("TWOTERRAINS")).arg(terrainName(fGrass)).arg(terrainName(fGrass + 12));
|
caption = phrase(QStringLiteral("TWOTERRAINS")).arg(terrainName(fGrass)).arg(terrainName(fGrass + 12));
|
||||||
else if (terrType == fForest)
|
else if (terrType == fForest)
|
||||||
caption = phrase(QStringLiteral("TWOTERRAINS")).arg(terrainName(fForest)).arg(terrainName(fJungle));
|
caption = phrase(QStringLiteral("TWOTERRAINS")).arg(terrainName(fForest)).arg(terrainName(Term::fJungle));
|
||||||
else
|
else
|
||||||
caption = terrainName(terrType);
|
caption = terrainName(terrType);
|
||||||
QAction *action = popup->addAction(caption);
|
QAction *action = popup->addAction(caption);
|
||||||
@@ -146,7 +146,7 @@ void EnhanceDlg::showNewContent(WindowMode newMode, int terrType)
|
|||||||
void EnhanceDlg::offscreenPaint()
|
void EnhanceDlg::offscreenPaint()
|
||||||
{
|
{
|
||||||
FramedDlg::offscreenPaint();
|
FramedDlg::offscreenPaint();
|
||||||
if (!Term::myData || !HGrSystem || !HGrTerrain)
|
if (!Term::myData || !HGrSystem || !noMap->hGrTerrain)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Dpi::Canvas &canvas = offscreen.canvas();
|
Dpi::Canvas &canvas = offscreen.canvas();
|
||||||
@@ -209,31 +209,31 @@ void EnhanceDlg::offscreenPaint()
|
|||||||
const int xxt = noMap->xxt;
|
const int xxt = noMap->xxt;
|
||||||
const int yyt = noMap->yyt;
|
const int yyt = noMap->yyt;
|
||||||
if (terrType < fForest) {
|
if (terrType < fForest) {
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + terrType * (xxt * 2 + 1), 1 + yyt);
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + terrType * (xxt * 2 + 1), 1 + yyt);
|
||||||
} else {
|
} else {
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 2 * (xxt * 2 + 1),
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 2 * (xxt * 2 + 1),
|
||||||
1 + yyt + 2 * (yyt * 3 + 1));
|
1 + yyt + 2 * (yyt * 3 + 1));
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 7 * (xxt * 2 + 1),
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 7 * (xxt * 2 + 1),
|
||||||
1 + yyt + 2 * (2 + terrType - fForest) * (yyt * 3 + 1));
|
1 + yyt + 2 * (2 + terrType - fForest) * (yyt * 3 + 1));
|
||||||
}
|
}
|
||||||
if ((tileImp & fTerImp) == tiFarm)
|
if ((tileImp & fTerImp) == tiFarm)
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + (xxt * 2 + 1),
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + (xxt * 2 + 1),
|
||||||
1 + yyt + 12 * (yyt * 3 + 1));
|
1 + yyt + 12 * (yyt * 3 + 1));
|
||||||
else if ((tileImp & fTerImp) == tiIrrigation)
|
else if ((tileImp & fTerImp) == tiIrrigation)
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1, 1 + yyt + 12 * (yyt * 3 + 1));
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1, 1 + yyt + 12 * (yyt * 3 + 1));
|
||||||
if (tileImp & fRR) {
|
if (tileImp & fRR) {
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 6 * (xxt * 2 + 1),
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 6 * (xxt * 2 + 1),
|
||||||
1 + yyt + 10 * (yyt * 3 + 1));
|
1 + yyt + 10 * (yyt * 3 + 1));
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 2 * (xxt * 2 + 1),
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 2 * (xxt * 2 + 1),
|
||||||
1 + yyt + 10 * (yyt * 3 + 1));
|
1 + yyt + 10 * (yyt * 3 + 1));
|
||||||
} else if (tileImp & fRoad) {
|
} else if (tileImp & fRoad) {
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 6 * (xxt * 2 + 1),
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 6 * (xxt * 2 + 1),
|
||||||
1 + yyt + 9 * (yyt * 3 + 1));
|
1 + yyt + 9 * (yyt * 3 + 1));
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 2 * (xxt * 2 + 1),
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 2 * (xxt * 2 + 1),
|
||||||
1 + yyt + 9 * (yyt * 3 + 1));
|
1 + yyt + 9 * (yyt * 3 + 1));
|
||||||
}
|
}
|
||||||
if ((tileImp & fTerImp) == tiMine)
|
if ((tileImp & fTerImp) == tiMine)
|
||||||
sprite(canvas, *HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 2 * (xxt * 2 + 1),
|
sprite(canvas, *noMap->hGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1 + 2 * (xxt * 2 + 1),
|
||||||
1 + yyt + 12 * (yyt * 3 + 1));
|
1 + yyt + 12 * (yyt * 3 + 1));
|
||||||
x += xxt * 2 + 6;
|
x += xxt * 2 + 6;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,16 @@ MessgExDlg::~MessgExDlg()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MessgExDlg::inputText() const
|
||||||
|
{
|
||||||
|
return ui->eInput->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessgExDlg::setInputText(const QString &text)
|
||||||
|
{
|
||||||
|
ui->eInput->setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
void MessgExDlg::closeEvent(QCloseEvent *event)
|
void MessgExDlg::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
iconKind = MessageIconKind::None;
|
iconKind = MessageIconKind::None;
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ public:
|
|||||||
|
|
||||||
Dpi::ModalResult showModal();
|
Dpi::ModalResult showModal();
|
||||||
void cancelMovie();
|
void cancelMovie();
|
||||||
|
// EInput.Text (the model-rename field shown for MessageKind::Model).
|
||||||
|
QString inputText() const;
|
||||||
|
void setInputText(const QString &text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
|||||||
@@ -0,0 +1,553 @@
|
|||||||
|
// This file is part of c-evo-evo.
|
||||||
|
//
|
||||||
|
// This software is governed by the CeCILL license under French law and
|
||||||
|
// abiding by the rules of distribution of free software. You can use,
|
||||||
|
// modify and/or redistribute the software under the terms of the CeCILL
|
||||||
|
// license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
// "http://www.cecill.info".
|
||||||
|
//
|
||||||
|
// As a counterpart to the access to the source code and rights to copy,
|
||||||
|
// modify and redistribute granted by the license, users are provided only
|
||||||
|
// with a limited warranty and the software's author, the holder of the
|
||||||
|
// economic rights, and the successive licensors have only limited
|
||||||
|
// liability.
|
||||||
|
//
|
||||||
|
// In this respect, the user's attention is drawn to the risks associated
|
||||||
|
// with loading, using, modifying and/or developing or reproducing the
|
||||||
|
// software by the user in light of its specific status of free software,
|
||||||
|
// that may mean that it is complicated to manipulate, and that also
|
||||||
|
// therefore means that it is reserved for developers and experienced
|
||||||
|
// professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
// encouraged to load and test the software's suitability as regards their
|
||||||
|
// requirements in conditions enabling the security of their systems and/or
|
||||||
|
// data to be ensured and, more generally, to use and operate it in the
|
||||||
|
// same conditions as regards security.
|
||||||
|
//
|
||||||
|
// The fact that you are presently reading this means that you have had
|
||||||
|
// knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
#include "Term.MainScreen.h"
|
||||||
|
|
||||||
|
#include "Cevo/Database.h"
|
||||||
|
#include "ClientTools.h"
|
||||||
|
#include "Global.h"
|
||||||
|
#include "Tribes.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
namespace Term {
|
||||||
|
|
||||||
|
MainScreen::MainScreen(QWidget *parent) : DrawDlg(parent)
|
||||||
|
{
|
||||||
|
IsoEngine::init([](int emix) { return initEnemyModel(emix); });
|
||||||
|
|
||||||
|
mainScreenZoomToCity = [this](int loc, bool nextUnitOnClose, int showEvent) {
|
||||||
|
Q_UNUSED(nextUnitOnClose);
|
||||||
|
Q_UNUSED(showEvent);
|
||||||
|
// TODO: needs the real main map (not ported yet) to actually
|
||||||
|
// scroll/focus the view - just opens the city dialog for now.
|
||||||
|
cityDlg().showNewContent(WindowMode::Persistent, loc, 0);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
mainScreenCityClosed = [](int, bool, bool) {};
|
||||||
|
mainScreenUpdateViews = [this](bool updateCityScreen) { updateViews(updateCityScreen); };
|
||||||
|
mainScreenRepaintAll = [this] { repaintAll(); };
|
||||||
|
mainScreenDipCall = [this](int command) { return dipCall(command); };
|
||||||
|
mainScreenContactRefused = [this](int p, const QString &item) { return contactRefused(p, item); };
|
||||||
|
modalSelectDlgShowCityProject = [this](int cix) {
|
||||||
|
modalSelectDlg().showNewContentCityProject(WindowMode::Modal, cix);
|
||||||
|
return modalSelectDlg().result;
|
||||||
|
};
|
||||||
|
listDlgRenameCity = [this](int cix) { return listDlg().renameCity(cix); };
|
||||||
|
mainScreenMessgExDlg = [this] { return &messgExDlg(); };
|
||||||
|
mainScreenModalSelectDlg = [this] { return &modalSelectDlg(); };
|
||||||
|
mainScreenNatStatDlg = [this] { return &natStatDlg(); };
|
||||||
|
mainScreenOfferCall = [this](const TOffer &offer) {
|
||||||
|
TOffer mutableOffer = offer;
|
||||||
|
return offerCall(mutableOffer);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
MainScreen::~MainScreen() = default;
|
||||||
|
|
||||||
|
Wonders::WondersDlg &MainScreen::wondersDlg()
|
||||||
|
{
|
||||||
|
if (!m_wondersDlg)
|
||||||
|
m_wondersDlg = std::make_unique<Wonders::WondersDlg>();
|
||||||
|
return *m_wondersDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
TechTree::TechTreeDlg &MainScreen::techTreeDlg()
|
||||||
|
{
|
||||||
|
if (!m_techTreeDlg)
|
||||||
|
m_techTreeDlg = std::make_unique<TechTree::TechTreeDlg>();
|
||||||
|
return *m_techTreeDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Enhance::EnhanceDlg &MainScreen::enhanceDlg()
|
||||||
|
{
|
||||||
|
if (!m_enhanceDlg)
|
||||||
|
m_enhanceDlg = std::make_unique<Enhance::EnhanceDlg>();
|
||||||
|
return *m_enhanceDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Nego::NegoDlg &MainScreen::negoDlg()
|
||||||
|
{
|
||||||
|
if (!m_negoDlg)
|
||||||
|
m_negoDlg = std::make_unique<Nego::NegoDlg>();
|
||||||
|
return *m_negoDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
CityType::CityTypeDlg &MainScreen::cityTypeDlg()
|
||||||
|
{
|
||||||
|
if (!m_cityTypeDlg)
|
||||||
|
m_cityTypeDlg = std::make_unique<CityType::CityTypeDlg>();
|
||||||
|
return *m_cityTypeDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Diagram::DiaDlg &MainScreen::diaDlg()
|
||||||
|
{
|
||||||
|
if (!m_diaDlg) {
|
||||||
|
m_diaDlg = std::make_unique<Diagram::DiaDlg>();
|
||||||
|
arrangeDialog(m_diaDlg.get());
|
||||||
|
}
|
||||||
|
return *m_diaDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
CityScreen::CityDlg &MainScreen::cityDlg()
|
||||||
|
{
|
||||||
|
if (!m_cityDlg) {
|
||||||
|
m_cityDlg = std::make_unique<CityScreen::CityDlg>();
|
||||||
|
m_cityDlg->checkAge();
|
||||||
|
}
|
||||||
|
return *m_cityDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rates::RatesDlg &MainScreen::ratesDlg()
|
||||||
|
{
|
||||||
|
if (!m_ratesDlg)
|
||||||
|
m_ratesDlg = std::make_unique<Rates::RatesDlg>();
|
||||||
|
return *m_ratesDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Battle::BattleDlg &MainScreen::battleDlg()
|
||||||
|
{
|
||||||
|
if (!m_battleDlg)
|
||||||
|
m_battleDlg = std::make_unique<Battle::BattleDlg>();
|
||||||
|
return *m_battleDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
NatStat::NatStatDlg &MainScreen::natStatDlg()
|
||||||
|
{
|
||||||
|
if (!m_natStatDlg) {
|
||||||
|
m_natStatDlg = std::make_unique<NatStat::NatStatDlg>();
|
||||||
|
arrangeDialog(m_natStatDlg.get());
|
||||||
|
m_natStatDlg->checkAge();
|
||||||
|
}
|
||||||
|
return *m_natStatDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnitStat::UnitStatDlg &MainScreen::unitStatDlg()
|
||||||
|
{
|
||||||
|
if (!m_unitStatDlg) {
|
||||||
|
m_unitStatDlg = std::make_unique<UnitStat::UnitStatDlg>();
|
||||||
|
arrangeDialog(m_unitStatDlg.get());
|
||||||
|
m_unitStatDlg->checkAge();
|
||||||
|
}
|
||||||
|
return *m_unitStatDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Draft::DraftDlg &MainScreen::draftDlg()
|
||||||
|
{
|
||||||
|
if (!m_draftDlg)
|
||||||
|
m_draftDlg = std::make_unique<Draft::DraftDlg>();
|
||||||
|
return *m_draftDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Select::ModalSelectDlg &MainScreen::modalSelectDlg()
|
||||||
|
{
|
||||||
|
if (!m_modalSelectDlg)
|
||||||
|
m_modalSelectDlg = std::make_unique<Select::ModalSelectDlg>();
|
||||||
|
return *m_modalSelectDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Select::ListDlg &MainScreen::listDlg()
|
||||||
|
{
|
||||||
|
if (!m_listDlg) {
|
||||||
|
m_listDlg = std::make_unique<Select::ListDlg>();
|
||||||
|
arrangeDialog(m_listDlg.get());
|
||||||
|
}
|
||||||
|
return *m_listDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessgEx::MessgExDlg &MainScreen::messgExDlg()
|
||||||
|
{
|
||||||
|
if (!m_messgExDlg)
|
||||||
|
m_messgExDlg = std::make_unique<MessgEx::MessgExDlg>();
|
||||||
|
return *m_messgExDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Help::HelpDlg &MainScreen::helpDlg()
|
||||||
|
{
|
||||||
|
if (!m_helpDlg) {
|
||||||
|
m_helpDlg = std::make_unique<Help::HelpDlg>();
|
||||||
|
arrangeDialog(m_helpDlg.get());
|
||||||
|
// TODO: Help::HelpDlg has no difficulty field in this port yet
|
||||||
|
// (StringTables-dependent content was simplified away, see
|
||||||
|
// Help.pas's own repo-memory entry).
|
||||||
|
}
|
||||||
|
return *m_helpDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cevo::LogDlg &MainScreen::logDlg()
|
||||||
|
{
|
||||||
|
if (!m_logDlg)
|
||||||
|
m_logDlg = std::make_unique<Cevo::LogDlg>();
|
||||||
|
return *m_logDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainScreen::arrangeDialog(BufferedDrawDlg *form)
|
||||||
|
{
|
||||||
|
if (!form)
|
||||||
|
return;
|
||||||
|
const Dpi::Monitor monitor = Dpi::Screen::primaryMonitor();
|
||||||
|
if (form == m_listDlg.get()) {
|
||||||
|
m_listDlg->userLeft = monitor.left() + 8;
|
||||||
|
m_listDlg->userTop = monitor.top() + TopBarHeight + 8;
|
||||||
|
}
|
||||||
|
if (form == m_helpDlg.get()) {
|
||||||
|
m_helpDlg->userLeft = monitor.left() + monitor.width() - m_helpDlg->width() - 8;
|
||||||
|
m_helpDlg->userTop = monitor.top() + TopBarHeight + 8;
|
||||||
|
}
|
||||||
|
if (form == m_unitStatDlg.get()) {
|
||||||
|
m_unitStatDlg->userLeft = monitor.left() + 397;
|
||||||
|
m_unitStatDlg->userTop = monitor.top() + TopBarHeight + 64;
|
||||||
|
}
|
||||||
|
if (form == m_diaDlg.get()) {
|
||||||
|
m_diaDlg->userLeft = monitor.left() + (monitor.width() - m_diaDlg->width()) / 2;
|
||||||
|
m_diaDlg->userTop = monitor.top() + (monitor.height() - m_diaDlg->height()) / 2;
|
||||||
|
}
|
||||||
|
if (form == m_natStatDlg.get()) {
|
||||||
|
m_natStatDlg->userLeft = monitor.left() + monitor.width() - m_natStatDlg->width() - 8;
|
||||||
|
m_natStatDlg->userTop = monitor.top() + monitor.height() - PanelHeight - m_natStatDlg->height() - 8;
|
||||||
|
if (m_natStatDlg->userTop < 8)
|
||||||
|
m_natStatDlg->userTop = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainScreen::arrangeDialogs()
|
||||||
|
{
|
||||||
|
arrangeDialog(m_listDlg.get());
|
||||||
|
arrangeDialog(m_helpDlg.get());
|
||||||
|
arrangeDialog(m_unitStatDlg.get());
|
||||||
|
arrangeDialog(m_diaDlg.get());
|
||||||
|
arrangeDialog(m_natStatDlg.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// Original: `if G.RO[DipMem[Me].pContact] <> nil then ApplyToVisibleForms
|
||||||
|
// (faClose) else begin if CityDlg.Visible ... end;` - the ApplyToVisibleForms
|
||||||
|
// branch is multiplayer/hotseat-only (closes every dialog so the next
|
||||||
|
// player's turn starts clean) and isn't reachable without the full
|
||||||
|
// GRO[]/hotseat machinery; simplified to always take the single-player
|
||||||
|
// "close CityDlg/UnitStatDlg if open" path, disclosed.
|
||||||
|
void closeDialogsForNextPlayer(MainScreen &mainScreen)
|
||||||
|
{
|
||||||
|
if (mainScreen.cityDlg().isVisible())
|
||||||
|
mainScreen.cityDlg().close();
|
||||||
|
if (mainScreen.unitStatDlg().isVisible())
|
||||||
|
mainScreen.unitStatDlg().close();
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
bool chooseResearch()
|
||||||
|
{
|
||||||
|
MainScreen &screen = *mainScreen;
|
||||||
|
Select::ModalSelectDlg &select = screen.modalSelectDlg();
|
||||||
|
const int me = ClientTools::me;
|
||||||
|
const TPlayerContext &ro = *ClientTools::myRO;
|
||||||
|
if (myData->farTech != adNone && ro.Tech[myData->farTech] >= tsApplicable)
|
||||||
|
myData->farTech = adNone;
|
||||||
|
|
||||||
|
int chosenResearch;
|
||||||
|
do {
|
||||||
|
// research complete -- select new
|
||||||
|
do {
|
||||||
|
select.showNewContent(WindowMode::Modal, Select::ListKind::Advance);
|
||||||
|
if (select.result < 0)
|
||||||
|
return false;
|
||||||
|
chosenResearch = select.result;
|
||||||
|
if (chosenResearch == adMilitary) {
|
||||||
|
screen.draftDlg().showNewContent(WindowMode::Modal);
|
||||||
|
if (screen.draftDlg().modalResult() != Dpi::ModalResult::Ok)
|
||||||
|
Tribes::tribe[static_cast<std::size_t>(me)]->modelPictureAt(ro.nModel).hGr = nullptr;
|
||||||
|
}
|
||||||
|
} while (chosenResearch == adMilitary && screen.draftDlg().modalResult() != Dpi::ModalResult::Ok);
|
||||||
|
|
||||||
|
if (chosenResearch == adMilitary) {
|
||||||
|
initMyModel(ro.nModel, true);
|
||||||
|
} else if (chosenResearch == adFar) {
|
||||||
|
select.showNewContent(WindowMode::Modal, Select::ListKind::FarAdvance);
|
||||||
|
if (select.result >= 0) {
|
||||||
|
if (select.result == adNone ||
|
||||||
|
ClientTools::server(sSetResearch - sExecute, me, select.result, nullptr) < rExecuted) {
|
||||||
|
myData->farTech = select.result;
|
||||||
|
} else {
|
||||||
|
chosenResearch = select.result;
|
||||||
|
// can be researched immediately
|
||||||
|
myData->farTech = adNone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (chosenResearch == adFar);
|
||||||
|
|
||||||
|
if (chosenResearch == adNexus)
|
||||||
|
myData->farTech = adNexus;
|
||||||
|
else
|
||||||
|
ClientTools::server(sSetResearch, me, chosenResearch, nullptr);
|
||||||
|
screen.listDlg().techChange();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void applyToVisibleForms(FormAction formAction)
|
||||||
|
{
|
||||||
|
const QList<QWidget *> widgets = QApplication::topLevelWidgets();
|
||||||
|
for (QWidget *widget : widgets) {
|
||||||
|
auto *form = qobject_cast<BufferedDrawDlg *>(widget);
|
||||||
|
if (!form || !form->isVisible())
|
||||||
|
continue;
|
||||||
|
switch (formAction) {
|
||||||
|
case FormAction::Close:
|
||||||
|
form->close();
|
||||||
|
break;
|
||||||
|
case FormAction::Enable:
|
||||||
|
form->setEnabled(true);
|
||||||
|
break;
|
||||||
|
case FormAction::Disable:
|
||||||
|
form->setEnabled(false);
|
||||||
|
break;
|
||||||
|
case FormAction::Update:
|
||||||
|
// The original re-runs OnShow (private showEvent here); a repaint is what's reachable.
|
||||||
|
form->update();
|
||||||
|
form->repaint();
|
||||||
|
break;
|
||||||
|
case FormAction::SmartUpdateContent:
|
||||||
|
form->smartUpdateContent(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int MainScreen::dipCall(int command)
|
||||||
|
{
|
||||||
|
const int result = ClientTools::server(command, ClientTools::me, 0, nullptr);
|
||||||
|
if (result >= rExecuted) {
|
||||||
|
DipMemEntry &mem = dipMem[static_cast<std::size_t>(ClientTools::me)];
|
||||||
|
if ((command & 0xFF0F) == scContact) {
|
||||||
|
mem.pContact = (command >> 4) & 0xF;
|
||||||
|
negoDlg().initiate();
|
||||||
|
mem.deliveredPrices.reset();
|
||||||
|
mem.receivedPrices.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
mem.sentCommand = command;
|
||||||
|
mem.formerTreaty = ClientTools::myRO->Treaty[mem.pContact];
|
||||||
|
if (command == scDipCancelTreaty) {
|
||||||
|
// TODO: Sound.pas not ported.
|
||||||
|
} 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).
|
||||||
|
}
|
||||||
|
cityDlg().closeAction = CityScreen::CityCloseAction::None;
|
||||||
|
closeDialogsForNextPlayer(*this);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MainScreen::offerCall(TOffer &offer)
|
||||||
|
{
|
||||||
|
const int result = ClientTools::server(scDipOffer, ClientTools::me, 0, &offer);
|
||||||
|
if (result >= rExecuted) {
|
||||||
|
DipMemEntry &mem = dipMem[static_cast<std::size_t>(ClientTools::me)];
|
||||||
|
mem.sentCommand = scDipOffer;
|
||||||
|
mem.formerTreaty = ClientTools::myRO->Treaty[mem.pContact];
|
||||||
|
mem.sentOffer = offer;
|
||||||
|
cityDlg().closeAction = CityScreen::CityCloseAction::None;
|
||||||
|
closeDialogsForNextPlayer(*this);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainScreen::updateViews(bool updateCityScreen)
|
||||||
|
{
|
||||||
|
ClientTools::sumCities(taxSum, scienceSum);
|
||||||
|
// TODO: needs PanelPaint/the real main map (not ported yet).
|
||||||
|
listDlg().ecoChange();
|
||||||
|
natStatDlg().ecoChange();
|
||||||
|
if (updateCityScreen)
|
||||||
|
cityDlg().smartUpdateContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainScreen::setAIName(int, const QString &)
|
||||||
|
{
|
||||||
|
// TODO: AILogo[]/GetAppSharePath() (per-player AI logo bitmap) - not
|
||||||
|
// ported, no consumer reads it yet either (main window/panel not
|
||||||
|
// ported); no-op for now.
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
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.
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainScreen::getTribeList()
|
||||||
|
{
|
||||||
|
unusedTribeFiles.clear();
|
||||||
|
const QDir dir(localizedFilePath(QStringLiteral("Tribes")));
|
||||||
|
const QString ext = QLatin1String(CevoTribeExt);
|
||||||
|
const QStringList files = dir.entryList({QLatin1Char('*') + ext}, QDir::Files, QDir::Name);
|
||||||
|
for (const QString &file : files) {
|
||||||
|
const QString baseName = file.left(file.length() - ext.length());
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
if (Tribes::getTribeInfo(baseName, name, color))
|
||||||
|
unusedTribeFiles.push_back({baseName, color});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int MainScreen::chooseUnusedTribe()
|
||||||
|
{
|
||||||
|
Q_ASSERT(!unusedTribeFiles.empty());
|
||||||
|
int result = -1;
|
||||||
|
int bestColorDistance = -1;
|
||||||
|
int countBest = 0;
|
||||||
|
for (int j = 0; j < static_cast<int>(unusedTribeFiles.size()); ++j) {
|
||||||
|
const QColor candidate = unusedTribeFiles[static_cast<std::size_t>(j)].color;
|
||||||
|
int colorDistance = 250; // consider differences more than this infinite
|
||||||
|
for (const auto &tribe : Tribes::tribe) {
|
||||||
|
if (!tribe)
|
||||||
|
continue;
|
||||||
|
const int testColorDistance = std::abs(candidate.blue() - tribe->color.blue()) +
|
||||||
|
std::abs(candidate.green() - tribe->color.green()) * 3 +
|
||||||
|
std::abs(candidate.red() - tribe->color.red()) * 2;
|
||||||
|
colorDistance = std::min(colorDistance, testColorDistance);
|
||||||
|
}
|
||||||
|
if (colorDistance > bestColorDistance) {
|
||||||
|
countBest = 0;
|
||||||
|
bestColorDistance = colorDistance;
|
||||||
|
}
|
||||||
|
if (colorDistance == bestColorDistance) {
|
||||||
|
++countBest;
|
||||||
|
if (Database::delphiRandom(countBest) == 0)
|
||||||
|
result = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainScreen::showEnemyShipChange(const TShowShipChange &change)
|
||||||
|
{
|
||||||
|
MessgEx::MessgExDlg &dlg = messgExDlg();
|
||||||
|
const auto &owner1 = *Tribes::tribe[static_cast<std::size_t>(change.Ship1Owner)];
|
||||||
|
const auto &owner2 = *Tribes::tribe[static_cast<std::size_t>(change.Ship2Owner)];
|
||||||
|
switch (change.Reason) {
|
||||||
|
case scrProduction:
|
||||||
|
dlg.openSound = QStringLiteral("SHIP_BUILT");
|
||||||
|
dlg.messageText = owner1.tPhrase(QStringLiteral("SHIPBUILT"));
|
||||||
|
dlg.iconKind = MessgEx::MessageIconKind::Ship;
|
||||||
|
dlg.iconIndex = change.Ship1Owner;
|
||||||
|
break;
|
||||||
|
case scrDestruction:
|
||||||
|
dlg.openSound = QStringLiteral("SHIP_DESTROYED");
|
||||||
|
dlg.messageText = owner1.tPhrase(QStringLiteral("SHIPDESTROYED"));
|
||||||
|
dlg.iconKind = MessgEx::MessageIconKind::Imp;
|
||||||
|
break;
|
||||||
|
case scrTrade: {
|
||||||
|
dlg.openSound = QStringLiteral("SHIP_TRADED");
|
||||||
|
bool ship1Plus = false;
|
||||||
|
bool ship2Plus = false;
|
||||||
|
for (int i = 0; i < nShipPart; ++i) {
|
||||||
|
ship1Plus = ship1Plus || change.Ship1Change[i] > 0;
|
||||||
|
ship2Plus = ship2Plus || change.Ship2Change[i] > 0;
|
||||||
|
}
|
||||||
|
if (ship1Plus && ship2Plus) {
|
||||||
|
dlg.messageText = owner1.tPhrase(QStringLiteral("SHIPBITRADE1")) + QLatin1Char(' ') +
|
||||||
|
owner2.tPhrase(QStringLiteral("SHIPBITRADE2"));
|
||||||
|
} else if (ship1Plus) {
|
||||||
|
dlg.messageText = owner1.tPhrase(QStringLiteral("SHIPUNITRADE1")) + QLatin1Char(' ') +
|
||||||
|
owner2.tPhrase(QStringLiteral("SHIPUNITRADE2"));
|
||||||
|
} else {
|
||||||
|
dlg.messageText = owner2.tPhrase(QStringLiteral("SHIPUNITRADE1")) + QLatin1Char(' ') +
|
||||||
|
owner1.tPhrase(QStringLiteral("SHIPUNITRADE2"));
|
||||||
|
}
|
||||||
|
dlg.iconKind = MessgEx::MessageIconKind::Imp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case scrCapture:
|
||||||
|
dlg.openSound = QStringLiteral("SHIP_CAPTURED");
|
||||||
|
dlg.messageText = owner2.tPhrase(QStringLiteral("SHIPCAPTURE1")) + QLatin1Char(' ') +
|
||||||
|
owner1.tPhrase(QStringLiteral("SHIPCAPTURE2"));
|
||||||
|
dlg.iconKind = MessgEx::MessageIconKind::Ship;
|
||||||
|
dlg.iconIndex = change.Ship2Owner;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dlg.iconKind == MessgEx::MessageIconKind::Imp) {
|
||||||
|
int mostCost = 0;
|
||||||
|
for (int i = 0; i < nShipPart; ++i) {
|
||||||
|
const int testCost = std::abs(change.Ship1Change[i]) * Imp[imShipComp + i].Cost;
|
||||||
|
if (testCost > mostCost) {
|
||||||
|
mostCost = testCost;
|
||||||
|
dlg.iconIndex = imShipComp + i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dlg.kind = MessageKind::Ok;
|
||||||
|
dlg.showModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainScreen::rememberPeaceViolation()
|
||||||
|
{
|
||||||
|
myData->peaceEvaHappened = 0;
|
||||||
|
for (int uix = 0; uix < ClientTools::myRO->nUn; ++uix) {
|
||||||
|
const TUn &un = ClientTools::myUn[uix];
|
||||||
|
if (un.Loc >= 0) {
|
||||||
|
const int p1 = (*ClientTools::myRO->Territory)[un.Loc];
|
||||||
|
if (p1 != ClientTools::me && p1 >= 0 &&
|
||||||
|
ClientTools::myRO->Turn == ClientTools::myRO->EvaStart[p1] + (PeaceEvaTurns - 1))
|
||||||
|
myData->peaceEvaHappened |= (1 << p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Term
|
||||||
|
} // namespace Cevo
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
// This file is part of c-evo-evo.
|
||||||
|
//
|
||||||
|
// This software is governed by the CeCILL license under French law and
|
||||||
|
// abiding by the rules of distribution of free software. You can use,
|
||||||
|
// modify and/or redistribute the software under the terms of the CeCILL
|
||||||
|
// license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
// "http://www.cecill.info".
|
||||||
|
//
|
||||||
|
// As a counterpart to the access to the source code and rights to copy,
|
||||||
|
// modify and redistribute granted by the license, users are provided only
|
||||||
|
// with a limited warranty and the software's author, the holder of the
|
||||||
|
// economic rights, and the successive licensors have only limited
|
||||||
|
// liability.
|
||||||
|
//
|
||||||
|
// In this respect, the user's attention is drawn to the risks associated
|
||||||
|
// with loading, using, modifying and/or developing or reproducing the
|
||||||
|
// software by the user in light of its specific status of free software,
|
||||||
|
// that may mean that it is complicated to manipulate, and that also
|
||||||
|
// therefore means that it is reserved for developers and experienced
|
||||||
|
// professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
// encouraged to load and test the software's suitability as regards their
|
||||||
|
// requirements in conditions enabling the security of their systems and/or
|
||||||
|
// data to be ensured and, more generally, to use and operate it in the
|
||||||
|
// same conditions as regards security.
|
||||||
|
//
|
||||||
|
// The fact that you are presently reading this means that you have had
|
||||||
|
// knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// TMainScreen equivalent - PARTIAL PORT (session 1 of what will be a many-
|
||||||
|
// session effort, see /memories/repo/cevo-evo-game.md for the full 183-
|
||||||
|
// method inventory + proposed 10-file split). This slice only covers: the
|
||||||
|
// 17 lazy dialog accessors, arrangeDialog()/arrangeDialogs(), and the
|
||||||
|
// handful of small cross-dialog methods (dipCall/offerCall/
|
||||||
|
// contactRefused/updateViews/setAIName/rememberPeaceViolation) that every
|
||||||
|
// other LocalPlayer dialog already has a `Term::mainScreenXxx`
|
||||||
|
// std::function injection point standing in for - this class's
|
||||||
|
// constructor wires all of those through to real methods below. The full
|
||||||
|
// map/panel/menu system (MainOffscreenPaint/PanelPaint/Client() etc.) is
|
||||||
|
// NOT part of this slice and remains future work - this header is kept
|
||||||
|
// SEPARATE from the widely-included Term.h specifically so consumers that
|
||||||
|
// only need the `Term::mainScreen` pointer don't have to transitively
|
||||||
|
// include all 17 dialog headers below.
|
||||||
|
|
||||||
|
#include "Battle.h"
|
||||||
|
#include "CityScreen.h"
|
||||||
|
#include "CityType.h"
|
||||||
|
#include "Diagram.h"
|
||||||
|
#include "Draft.h"
|
||||||
|
#include "Enhance.h"
|
||||||
|
#include "Help.h"
|
||||||
|
#include "Log.h"
|
||||||
|
#include "MessgEx.h"
|
||||||
|
#include "NatStat.h"
|
||||||
|
#include "Nego.h"
|
||||||
|
#include "Rates.h"
|
||||||
|
#include "Select.h"
|
||||||
|
#include "TechTree.h"
|
||||||
|
#include "Term.h"
|
||||||
|
#include "UnitStat.h"
|
||||||
|
#include "Wonders.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
namespace Term {
|
||||||
|
|
||||||
|
class MainScreen : public DrawDlg {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit MainScreen(QWidget *parent = nullptr);
|
||||||
|
~MainScreen() override;
|
||||||
|
|
||||||
|
Wonders::WondersDlg &wondersDlg();
|
||||||
|
TechTree::TechTreeDlg &techTreeDlg();
|
||||||
|
Enhance::EnhanceDlg &enhanceDlg();
|
||||||
|
Nego::NegoDlg &negoDlg();
|
||||||
|
CityType::CityTypeDlg &cityTypeDlg();
|
||||||
|
Diagram::DiaDlg &diaDlg();
|
||||||
|
CityScreen::CityDlg &cityDlg();
|
||||||
|
Rates::RatesDlg &ratesDlg();
|
||||||
|
Battle::BattleDlg &battleDlg();
|
||||||
|
NatStat::NatStatDlg &natStatDlg();
|
||||||
|
UnitStat::UnitStatDlg &unitStatDlg();
|
||||||
|
Draft::DraftDlg &draftDlg();
|
||||||
|
Select::ModalSelectDlg &modalSelectDlg();
|
||||||
|
Select::ListDlg &listDlg();
|
||||||
|
MessgEx::MessgExDlg &messgExDlg();
|
||||||
|
Help::HelpDlg &helpDlg();
|
||||||
|
Cevo::LogDlg &logDlg();
|
||||||
|
|
||||||
|
// Positions a just-created persistent dialog relative to the (not yet
|
||||||
|
// ported) main screen's primary monitor - self-contained, doesn't
|
||||||
|
// need the real map/panel to exist.
|
||||||
|
void arrangeDialog(BufferedDrawDlg *form);
|
||||||
|
void arrangeDialogs();
|
||||||
|
|
||||||
|
int dipCall(int command);
|
||||||
|
int offerCall(TOffer &offer);
|
||||||
|
// TODO: needs PanelPaint/the real main map (not ported yet) - only
|
||||||
|
// the already-portable side (ListDlg::ecoChange()/NatStatDlg::
|
||||||
|
// ecoChange()/CityDlg::smartUpdateContent()) runs for now.
|
||||||
|
void updateViews(bool updateCityScreen = false);
|
||||||
|
bool contactRefused(int p, const QString &item);
|
||||||
|
// TODO: needs the real main map/panel (not ported yet) - no-op until
|
||||||
|
// then (matches the original's RepaintAll()'s sole purpose).
|
||||||
|
void repaintAll() {}
|
||||||
|
void setAIName(int p, const QString &name);
|
||||||
|
void rememberPeaceViolation();
|
||||||
|
// Term.pas's GetTribeList(): fills unusedTribeFiles from the Tribes directory.
|
||||||
|
void getTribeList();
|
||||||
|
// Picks (at random among the best) the unused tribe whose colour differs most from the tribes in play.
|
||||||
|
int chooseUnusedTribe();
|
||||||
|
void showEnemyShipChange(const TShowShipChange &showShipChange);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<Wonders::WondersDlg> m_wondersDlg;
|
||||||
|
std::unique_ptr<TechTree::TechTreeDlg> m_techTreeDlg;
|
||||||
|
std::unique_ptr<Enhance::EnhanceDlg> m_enhanceDlg;
|
||||||
|
std::unique_ptr<Nego::NegoDlg> m_negoDlg;
|
||||||
|
std::unique_ptr<CityType::CityTypeDlg> m_cityTypeDlg;
|
||||||
|
std::unique_ptr<Diagram::DiaDlg> m_diaDlg;
|
||||||
|
std::unique_ptr<CityScreen::CityDlg> m_cityDlg;
|
||||||
|
std::unique_ptr<Rates::RatesDlg> m_ratesDlg;
|
||||||
|
std::unique_ptr<Battle::BattleDlg> m_battleDlg;
|
||||||
|
std::unique_ptr<NatStat::NatStatDlg> m_natStatDlg;
|
||||||
|
std::unique_ptr<UnitStat::UnitStatDlg> m_unitStatDlg;
|
||||||
|
std::unique_ptr<Draft::DraftDlg> m_draftDlg;
|
||||||
|
std::unique_ptr<Select::ModalSelectDlg> m_modalSelectDlg;
|
||||||
|
std::unique_ptr<Select::ListDlg> m_listDlg;
|
||||||
|
std::unique_ptr<MessgEx::MessgExDlg> m_messgExDlg;
|
||||||
|
std::unique_ptr<Help::HelpDlg> m_helpDlg;
|
||||||
|
std::unique_ptr<Cevo::LogDlg> m_logDlg;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class FormAction { Close, Enable, Disable, Update, SmartUpdateContent };
|
||||||
|
|
||||||
|
// Term.pas's ApplyToVisibleForms(): applies the action to every visible
|
||||||
|
// BufferedDrawDlg window.
|
||||||
|
void applyToVisibleForms(FormAction formAction);
|
||||||
|
|
||||||
|
// Term.pas's ChooseResearch(): lets the player pick the next research
|
||||||
|
// (including the draft of a new military unit class / far advance). Returns
|
||||||
|
// false if the player cancelled.
|
||||||
|
bool chooseResearch();
|
||||||
|
|
||||||
|
} // namespace Term
|
||||||
|
} // namespace Cevo
|
||||||
+259
-6
@@ -28,11 +28,17 @@
|
|||||||
|
|
||||||
#include "Term.h"
|
#include "Term.h"
|
||||||
|
|
||||||
|
#include "Cevo/CmdList.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Help.h"
|
#include "Help.h"
|
||||||
#include "IsoEngine.h"
|
#include "IsoEngine.h"
|
||||||
#include "Tribes.h"
|
#include "Tribes.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace Cevo {
|
namespace Cevo {
|
||||||
namespace Term {
|
namespace Term {
|
||||||
|
|
||||||
@@ -81,15 +87,39 @@ void impImage(Dpi::Canvas &canvas, int x, int y, int iix, int government, bool i
|
|||||||
|
|
||||||
void chooseModelPicture(int p, int mix, int code, int hash, int turn, bool forceNew, bool final)
|
void chooseModelPicture(int p, int mix, int code, int hash, int turn, bool forceNew, bool final)
|
||||||
{
|
{
|
||||||
|
const auto player = static_cast<std::size_t>(p);
|
||||||
Tribes::ModelPictureInfo picture;
|
Tribes::ModelPictureInfo picture;
|
||||||
picture.trix = p;
|
picture.trix = p;
|
||||||
picture.mix = mix;
|
picture.mix = mix;
|
||||||
picture.hash = hash;
|
bool isNew;
|
||||||
const bool isNew = Tribes::tribe[static_cast<std::size_t>(p)]->chooseModelPicture(picture, code, turn, forceNew);
|
if (code == 74) { // use correct pictures for slaves
|
||||||
if (final) {
|
if (Tribes::tribe[player]->mixSlaves < 0) {
|
||||||
Tribes::tribe[static_cast<std::size_t>(p)]->setModelPicture(picture, isNew);
|
if (!tribeOriginal[player]) {
|
||||||
|
Tribes::tribe[player]->mixSlaves = mix;
|
||||||
} else {
|
} else {
|
||||||
Tribes::ModelPicture &mp = Tribes::tribe[static_cast<std::size_t>(p)]->modelPictureAt(mix);
|
int data = mix + (p << 16);
|
||||||
|
ClientTools::server(cSetSlaveIndex, 0, 0, &data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
picture.pix = toldSlavery == 1 ? pixSlaves : pixNoSlaves;
|
||||||
|
picture.hash = 0;
|
||||||
|
picture.grName = QStringLiteral("StdUnits");
|
||||||
|
isNew = true;
|
||||||
|
} else {
|
||||||
|
picture.hash = hash;
|
||||||
|
isNew = Tribes::tribe[player]->chooseModelPicture(picture, code, turn, forceNew);
|
||||||
|
}
|
||||||
|
if (final) {
|
||||||
|
if (!tribeOriginal[player]) {
|
||||||
|
Tribes::tribe[player]->setModelPicture(picture, isNew);
|
||||||
|
} else {
|
||||||
|
QByteArray data = packModelPictureInfo(picture);
|
||||||
|
ClientTools::server(commandWithData(isNew ? cSetNewModelPicture : cSetModelPicture,
|
||||||
|
picture.commandDataSize()),
|
||||||
|
0, 0, data.data());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Tribes::ModelPicture &mp = Tribes::tribe[player]->modelPictureAt(mix);
|
||||||
mp.hGr = loadGraphicSet(picture.grName);
|
mp.hGr = loadGraphicSet(picture.grName);
|
||||||
mp.pix = picture.pix;
|
mp.pix = picture.pix;
|
||||||
}
|
}
|
||||||
@@ -97,6 +127,9 @@ void chooseModelPicture(int p, int mix, int code, int hash, int turn, bool force
|
|||||||
|
|
||||||
void initMyModel(int mix, bool final)
|
void initMyModel(int mix, bool final)
|
||||||
{
|
{
|
||||||
|
// special models (Kind >= $08) still get a picture: cSetModelPicture comes after tellNewModels()
|
||||||
|
if (gameMode == cMovie && ClientTools::myModel[mix].Kind < 0x08)
|
||||||
|
return;
|
||||||
TModelInfo mi{};
|
TModelInfo mi{};
|
||||||
MakeModelInfo(ClientTools::me, mix, ClientTools::myModel[mix], mi);
|
MakeModelInfo(ClientTools::me, mix, ClientTools::myModel[mix], mi);
|
||||||
chooseModelPicture(ClientTools::me, mix, Tribes::modelCode(mi), ClientTools::modelHash(mi),
|
chooseModelPicture(ClientTools::me, mix, Tribes::modelCode(mi), ClientTools::modelHash(mi),
|
||||||
@@ -114,7 +147,222 @@ std::array<int, nAdv> advIcon = [] {
|
|||||||
}();
|
}();
|
||||||
std::array<int, nPl * nMmax> lostArmy{};
|
std::array<int, nPl * nMmax> lostArmy{};
|
||||||
int nLostArmy = 0;
|
int nLostArmy = 0;
|
||||||
std::function<void()> initAllEnemyModels = [] {};
|
|
||||||
|
bool initEnemyModel(int emix)
|
||||||
|
{
|
||||||
|
if (gameMode == cMovie)
|
||||||
|
return false;
|
||||||
|
const TModelInfo &enemyModel = (*ClientTools::myRO->EnemyModel)[emix];
|
||||||
|
chooseModelPicture(enemyModel.Owner, enemyModel.mix, Tribes::modelCode(enemyModel),
|
||||||
|
ClientTools::modelHash(enemyModel), ClientTools::myRO->Turn, false, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initAllEnemyModels()
|
||||||
|
{
|
||||||
|
for (int emix = 0; emix < ClientTools::myRO->nEnemyModel; ++emix) {
|
||||||
|
const TModelInfo &enemyModel = (*ClientTools::myRO->EnemyModel)[emix];
|
||||||
|
if (!Tribes::tribe[static_cast<std::size_t>(enemyModel.Owner)]->modelPictureAt(enemyModel.mix).hGr)
|
||||||
|
initEnemyModel(emix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void appendInt32(QByteArray &data, int value)
|
||||||
|
{
|
||||||
|
const auto v = static_cast<std::int32_t>(value);
|
||||||
|
data.append(reinterpret_cast<const char *>(&v), sizeof v);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pascal ShortString: length byte followed by the bytes.
|
||||||
|
void appendShortString(QByteArray &data, const QString &text)
|
||||||
|
{
|
||||||
|
QByteArray bytes = text.toUtf8();
|
||||||
|
bytes.truncate(255);
|
||||||
|
data.append(static_cast<char>(bytes.size()));
|
||||||
|
data.append(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint8_t shortStringRecordSize(const QString &text)
|
||||||
|
{
|
||||||
|
return static_cast<std::uint8_t>(sizeof(std::int32_t) + 1 + std::min<qsizetype>(255, text.toUtf8().size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
QByteArray TribeInfo::pack() const
|
||||||
|
{
|
||||||
|
QByteArray data;
|
||||||
|
appendInt32(data, trix);
|
||||||
|
appendShortString(data, fileName);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint8_t TribeInfo::commandDataSize() const { return shortStringRecordSize(fileName); }
|
||||||
|
|
||||||
|
QByteArray CityNameInfo::pack() const
|
||||||
|
{
|
||||||
|
QByteArray data;
|
||||||
|
appendInt32(data, id);
|
||||||
|
appendShortString(data, newName);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint8_t CityNameInfo::commandDataSize() const { return shortStringRecordSize(newName); }
|
||||||
|
|
||||||
|
QByteArray ModelNameInfo::pack() const
|
||||||
|
{
|
||||||
|
QByteArray data;
|
||||||
|
appendInt32(data, mix);
|
||||||
|
appendShortString(data, newName);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint8_t ModelNameInfo::commandDataSize() const { return shortStringRecordSize(newName); }
|
||||||
|
|
||||||
|
QByteArray packModelPictureInfo(const Tribes::ModelPictureInfo &info)
|
||||||
|
{
|
||||||
|
QByteArray data;
|
||||||
|
appendInt32(data, info.trix);
|
||||||
|
appendInt32(data, info.mix);
|
||||||
|
appendInt32(data, info.pix);
|
||||||
|
appendInt32(data, info.hash);
|
||||||
|
appendShortString(data, info.grName);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tribes::ModelPictureInfo unpackModelPictureInfo(const void *data)
|
||||||
|
{
|
||||||
|
const auto *bytes = static_cast<const unsigned char *>(data);
|
||||||
|
std::int32_t fields[4];
|
||||||
|
std::memcpy(fields, bytes, sizeof fields);
|
||||||
|
Tribes::ModelPictureInfo info;
|
||||||
|
info.trix = fields[0];
|
||||||
|
info.mix = fields[1];
|
||||||
|
info.pix = fields[2];
|
||||||
|
info.hash = fields[3];
|
||||||
|
const unsigned char length = bytes[sizeof fields];
|
||||||
|
info.grName = QString::fromUtf8(reinterpret_cast<const char *>(bytes + sizeof fields + 1), length);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<bool, nPl> tribeOriginal{};
|
||||||
|
int toldSlavery = 0;
|
||||||
|
|
||||||
|
QString attackSound(int code)
|
||||||
|
{
|
||||||
|
return QStringLiteral("ATTACK_%1%2%3").arg(code / 100 % 10).arg(code / 10 % 10).arg(code % 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
int alignUp(int value, int alignment) { return value | (alignment - 1); }
|
||||||
|
|
||||||
|
void initSmallImp()
|
||||||
|
{
|
||||||
|
static Dpi::Bitmap storage;
|
||||||
|
smallImp = &storage;
|
||||||
|
if (!bigImp)
|
||||||
|
return;
|
||||||
|
smallImp->setSize(bigImp->width() * xSizeSmall / xSizeBig, bigImp->height() * ySizeSmall / ySizeBig);
|
||||||
|
smallImp->canvas().stretchDraw(QRect(0, 0, smallImp->width(), smallImp->height()), bigImp->image());
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkToldNoReturn(int uix)
|
||||||
|
{
|
||||||
|
// check whether aircraft survived low-fuel warning
|
||||||
|
Q_ASSERT(!supervising);
|
||||||
|
TUn &un = ClientTools::myUn[uix];
|
||||||
|
if ((un.Status & usToldNoReturn) &&
|
||||||
|
((ClientTools::myMap[un.Loc] & fCity) || (ClientTools::myMap[un.Loc] & fTerImp) == tiBase || un.Master >= 0))
|
||||||
|
un.Status &= ~usToldNoReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool createTribe(int p, QString fileName, bool original)
|
||||||
|
{
|
||||||
|
fileName = localizedFilePath(QStringLiteral("Tribes/") + fileName + QLatin1String(CevoTribeExt));
|
||||||
|
if (!QFile::exists(fileName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const auto player = static_cast<std::size_t>(p);
|
||||||
|
tribeOriginal[player] = original;
|
||||||
|
Tribes::tribe[player] = std::make_unique<Tribes::Tribe>(fileName);
|
||||||
|
if (gameMode == cNewGame || !original) {
|
||||||
|
chooseModelPicture(p, 0, 010, 1, 0, true, true);
|
||||||
|
chooseModelPicture(p, 1, 040, 1, 0, true, true);
|
||||||
|
chooseModelPicture(p, 2, 041, 1, 0, true, true);
|
||||||
|
chooseModelPicture(p, -1, 017, 1, 0, true, true);
|
||||||
|
}
|
||||||
|
dipMem[player].pContact = -1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tellNewContacts()
|
||||||
|
{
|
||||||
|
if (supervising)
|
||||||
|
return;
|
||||||
|
for (int p1 = 0; p1 < nPl; ++p1) {
|
||||||
|
if (p1 != ClientTools::me && !(myData->toldContact & (1 << p1)) &&
|
||||||
|
(ClientTools::myRO->Alive & (1 << p1)) && ClientTools::myRO->Treaty[p1] > trNoContact) {
|
||||||
|
MessgEx::tribeMessage(p1, Tribes::tribe[static_cast<std::size_t>(p1)]->tPhrase(QStringLiteral("FRNEWNATION")),
|
||||||
|
QString());
|
||||||
|
myData->toldContact |= 1 << p1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tellNewModels()
|
||||||
|
{
|
||||||
|
if (supervising)
|
||||||
|
return;
|
||||||
|
Tribes::Tribe &myTribe = *Tribes::tribe[static_cast<std::size_t>(ClientTools::me)];
|
||||||
|
while (myData->toldModels < ClientTools::myRO->nModel) { // new unit class available
|
||||||
|
const int told = myData->toldModels;
|
||||||
|
if (myTribe.modelPictureAt(told).hGr && ClientTools::myModel[told].Kind != mkSelfDeveloped) {
|
||||||
|
// save picture of DevModel
|
||||||
|
myTribe.modelPictureAt(told + 1) = myTribe.modelPictureAt(told);
|
||||||
|
myTribe.modelNameAt(told + 1) = myTribe.modelNameAt(told);
|
||||||
|
myTribe.modelPictureAt(told).hGr = nullptr;
|
||||||
|
}
|
||||||
|
if (!myTribe.modelPictureAt(told).hGr)
|
||||||
|
initMyModel(told, true);
|
||||||
|
// only run if no researched model
|
||||||
|
MessgEx::MessgExDlg *dlg = mainScreenMessgExDlg();
|
||||||
|
if (dlg) {
|
||||||
|
if (ClientTools::myModel[told].Kind == mkSelfDeveloped)
|
||||||
|
dlg->openSound = QStringLiteral("NEWMODEL_%1").arg(age);
|
||||||
|
// TODO: Phrases['MODELAVAILABLE'] (StringTables.pas not ported) - plain English fallback.
|
||||||
|
dlg->messageText = QStringLiteral("New units are ready for production.");
|
||||||
|
if (gameMode == cMovie) {
|
||||||
|
dlg->kind = MessageKind::OkHelp; // doesn't matter
|
||||||
|
dlg->messageText += QLatin1Char('\\') + myTribe.modelNameAt(told);
|
||||||
|
} else {
|
||||||
|
dlg->kind = MessageKind::Model;
|
||||||
|
dlg->setInputText(myTribe.modelNameAt(told));
|
||||||
|
}
|
||||||
|
dlg->iconKind = MessgEx::MessageIconKind::Model;
|
||||||
|
dlg->iconIndex = told;
|
||||||
|
dlg->showModal();
|
||||||
|
const QString newName = dlg->inputText();
|
||||||
|
if (!newName.isEmpty() && newName != myTribe.modelNameAt(told)) { // user renamed model
|
||||||
|
ModelNameInfo info;
|
||||||
|
info.mix = told;
|
||||||
|
info.newName = newName;
|
||||||
|
while (info.commandDataSize() > CommandDataMaxSize && !info.newName.isEmpty())
|
||||||
|
info.newName.chop(1);
|
||||||
|
QByteArray data = info.pack();
|
||||||
|
ClientTools::server(commandWithData(cSetModelName, info.commandDataSize()), ClientTools::me, 0,
|
||||||
|
data.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ClientTools::myModel[told].Kind == mkSettler) { // engineers make settlers obsolete
|
||||||
|
for (int mix = 0; mix < told; ++mix) {
|
||||||
|
if (ClientTools::myModel[mix].Kind == mkSettler)
|
||||||
|
ClientTools::myModel[mix].Status |= msObsolete;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++myData->toldModels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::array<int, nCityEventPriority> CityEventPriority = {
|
const std::array<int, nCityEventPriority> CityEventPriority = {
|
||||||
chDisorder, chImprovementLost, chUnitLost, chAllImpsMade,
|
chDisorder, chImprovementLost, chUnitLost, chAllImpsMade,
|
||||||
@@ -180,5 +428,10 @@ std::function<NatStat::NatStatDlg *()> mainScreenNatStatDlg = [] { return static
|
|||||||
std::function<int(const TOffer &)> mainScreenOfferCall = [](const TOffer &) { return eInvalid; };
|
std::function<int(const TOffer &)> mainScreenOfferCall = [](const TOffer &) { return eInvalid; };
|
||||||
TOffer receivedOffer{};
|
TOffer receivedOffer{};
|
||||||
|
|
||||||
|
int taxSum = 0;
|
||||||
|
int scienceSum = 0;
|
||||||
|
std::vector<UnusedTribe> unusedTribeFiles;
|
||||||
|
MainScreen *mainScreen = nullptr;
|
||||||
|
|
||||||
} // namespace Term
|
} // namespace Term
|
||||||
} // namespace Cevo
|
} // namespace Cevo
|
||||||
+93
-6
@@ -35,9 +35,13 @@
|
|||||||
#include "MessgEx.h"
|
#include "MessgEx.h"
|
||||||
#include "NatStat.h"
|
#include "NatStat.h"
|
||||||
#include "Select.h"
|
#include "Select.h"
|
||||||
|
#include "Tribes.h"
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -68,6 +72,22 @@ constexpr int SystemIconLines = 2;
|
|||||||
constexpr int msObsolete = 0x1;
|
constexpr int msObsolete = 0x1;
|
||||||
constexpr int msAllowConscripts = 0x2;
|
constexpr int msAllowConscripts = 0x2;
|
||||||
|
|
||||||
|
// Client exclusive commands (relayed by the server to the other clients).
|
||||||
|
constexpr int cSetTribe = 0x9000;
|
||||||
|
constexpr int cSetNewModelPicture = 0x9100;
|
||||||
|
constexpr int cSetModelName = 0x9110;
|
||||||
|
constexpr int cSetModelPicture = 0x9120;
|
||||||
|
constexpr int cSetSlaveIndex = 0x9131;
|
||||||
|
constexpr int cSetCityName = 0x9200;
|
||||||
|
|
||||||
|
// TUn.Status bit flags not already in IsoEngine.h.
|
||||||
|
constexpr int usWaiting = 0x02;
|
||||||
|
constexpr int usToldNoReturn = 0x100;
|
||||||
|
|
||||||
|
// Index of the slaves/no-slaves pictures in StdUnits.
|
||||||
|
constexpr int pixSlaves = 0;
|
||||||
|
constexpr int pixNoSlaves = 1;
|
||||||
|
|
||||||
// Term.pas's `MainScreen.mNames.Checked` (menu checkbox: show real model
|
// Term.pas's `MainScreen.mNames.Checked` (menu checkbox: show real model
|
||||||
// names vs. generic "Model #n" names) - defaults to the more useful true.
|
// names vs. generic "Model #n" names) - defaults to the more useful true.
|
||||||
extern bool mainScreenNamesChecked;
|
extern bool mainScreenNamesChecked;
|
||||||
@@ -180,10 +200,13 @@ extern std::uint32_t cityRepMask;
|
|||||||
// as lostArmy[]/nLostArmy).
|
// as lostArmy[]/nLostArmy).
|
||||||
extern std::array<int, nAdv> advIcon;
|
extern std::array<int, nAdv> advIcon;
|
||||||
|
|
||||||
// Term.pas's layout constant (MidPanelHeight - TopBarHeight) div 2; the
|
// Term.pas's layout constants (main window layout, now that TMainScreen
|
||||||
// two panel-size constants it derives from belong to Term's not-yet-ported
|
// itself is being ported for real).
|
||||||
// main window layout, so only the resulting fixed value is pre-seeded here.
|
constexpr int TopBarHeight = 41;
|
||||||
constexpr int MapCenterUp = 39;
|
constexpr int PanelHeight = 168;
|
||||||
|
constexpr int MidPanelHeight = 120;
|
||||||
|
// (MidPanelHeight - TopBarHeight) div 2 = (120 - 41) div 2 = 39.
|
||||||
|
constexpr int MapCenterUp = (MidPanelHeight - TopBarHeight) / 2;
|
||||||
|
|
||||||
// Term.pas's `LostArmy`/`nLostArmy` (model-indexed lost-unit counts shown
|
// Term.pas's `LostArmy`/`nLostArmy` (model-indexed lost-unit counts shown
|
||||||
// by MessgEx.pas's "army destroyed" report) - stay all-zero until Term.pas
|
// by MessgEx.pas's "army destroyed" report) - stay all-zero until Term.pas
|
||||||
@@ -193,8 +216,9 @@ extern int nLostArmy;
|
|||||||
|
|
||||||
// Term.pas's InitAllEnemyModels()/InitEnemyModel(): resolves a picture for
|
// Term.pas's InitAllEnemyModels()/InitEnemyModel(): resolves a picture for
|
||||||
// every known enemy unit model so MessgEx.pas's "enemy army" report can
|
// every known enemy unit model so MessgEx.pas's "enemy army" report can
|
||||||
// draw them. Injection point (default no-op) until Term.pas is ported.
|
// draw them.
|
||||||
extern std::function<void()> initAllEnemyModels;
|
bool initEnemyModel(int emix);
|
||||||
|
void initAllEnemyModels();
|
||||||
|
|
||||||
// Term.pas's own "city status flags"/additional "city happened flags"
|
// Term.pas's own "city status flags"/additional "city happened flags"
|
||||||
// constants (distinct from Protocol.pas's chXxx flags in ai/Protocol.h).
|
// constants (distinct from Protocol.pas's chXxx flags in ai/Protocol.h).
|
||||||
@@ -249,5 +273,68 @@ extern std::function<NatStat::NatStatDlg *()> mainScreenNatStatDlg;
|
|||||||
// eInvalid by default.
|
// eInvalid by default.
|
||||||
extern std::function<int(const TOffer &offer)> mainScreenOfferCall;
|
extern std::function<int(const TOffer &offer)> mainScreenOfferCall;
|
||||||
|
|
||||||
|
// Term.pas's TTribeInfo/TCityNameInfo/TModelNameInfo: payloads of the
|
||||||
|
// client exclusive commands. pack() yields the wire layout (int32 + Pascal
|
||||||
|
// ShortString: length byte then bytes), commandDataSize() is the size to
|
||||||
|
// pass to commandWithData().
|
||||||
|
struct TribeInfo {
|
||||||
|
int trix = 0;
|
||||||
|
QString fileName;
|
||||||
|
QByteArray pack() const;
|
||||||
|
std::uint8_t commandDataSize() const;
|
||||||
|
};
|
||||||
|
struct CityNameInfo {
|
||||||
|
int id = 0;
|
||||||
|
QString newName;
|
||||||
|
QByteArray pack() const;
|
||||||
|
std::uint8_t commandDataSize() const;
|
||||||
|
};
|
||||||
|
struct ModelNameInfo {
|
||||||
|
int mix = 0;
|
||||||
|
QString newName;
|
||||||
|
QByteArray pack() const;
|
||||||
|
std::uint8_t commandDataSize() const;
|
||||||
|
};
|
||||||
|
// Wire layout of Tribes::ModelPictureInfo (4 int32 + ShortString).
|
||||||
|
QByteArray packModelPictureInfo(const Tribes::ModelPictureInfo &info);
|
||||||
|
Tribes::ModelPictureInfo unpackModelPictureInfo(const void *data);
|
||||||
|
|
||||||
|
// Term.pas's `TribeOriginal`: whether tribe p comes from the original
|
||||||
|
// (non-network-relayed) game rather than being created for a movie/viewer.
|
||||||
|
extern std::array<bool, nPl> tribeOriginal;
|
||||||
|
// Term.pas's `ToldSlavery` (1 once slavery has been announced).
|
||||||
|
extern int toldSlavery;
|
||||||
|
|
||||||
|
QString attackSound(int code);
|
||||||
|
int alignUp(int value, int alignment);
|
||||||
|
// Term.pas's InitSmallImp(): builds smallImp by scaling down bigImp.
|
||||||
|
void initSmallImp();
|
||||||
|
// Clears the "low fuel warning" flag of an aircraft that made it back.
|
||||||
|
void checkToldNoReturn(int uix);
|
||||||
|
// Loads the tribe file and registers the tribe's standard model pictures.
|
||||||
|
bool createTribe(int p, QString fileName, bool original);
|
||||||
|
void tellNewContacts();
|
||||||
|
void tellNewModels();
|
||||||
|
|
||||||
|
// Term.pas's `UnusedTribeFiles` (name + colour of every tribe file not yet in play).
|
||||||
|
struct UnusedTribe {
|
||||||
|
QString fileName;
|
||||||
|
QColor color;
|
||||||
|
};
|
||||||
|
extern std::vector<UnusedTribe> unusedTribeFiles;
|
||||||
|
|
||||||
|
// Term.pas's `TaxSum`/`ScienceSum: Integer;` (aggregate tax/science totals
|
||||||
|
// across all owned cities, refreshed by MainScreen::updateViews()).
|
||||||
|
extern int taxSum;
|
||||||
|
extern int scienceSum;
|
||||||
|
|
||||||
|
// Term.pas's `TMainScreen` - the main game window; see
|
||||||
|
// Term.MainScreen.h/.cpp for the real class (kept out of this
|
||||||
|
// widely-included pre-seed header to avoid pulling in every dialog
|
||||||
|
// header transitively - consumers that only need the global instance
|
||||||
|
// pointer can use this forward declaration).
|
||||||
|
class MainScreen;
|
||||||
|
extern MainScreen *mainScreen;
|
||||||
|
|
||||||
} // namespace Term
|
} // namespace Term
|
||||||
} // namespace Cevo
|
} // namespace Cevo
|
||||||
@@ -380,6 +380,15 @@ QString Tribe::tPhrase(const QString &item) const
|
|||||||
{QStringLiteral("FRNOTACCEPTPRESENT"), QStringLiteral("We decline your gift.")},
|
{QStringLiteral("FRNOTACCEPTPRESENT"), QStringLiteral("We decline your gift.")},
|
||||||
{QStringLiteral("FRBYE"), QStringLiteral("Farewell.")},
|
{QStringLiteral("FRBYE"), QStringLiteral("Farewell.")},
|
||||||
{QStringLiteral("FRNOTACCEPTOFFER"), QStringLiteral("We do not accept this offer.")},
|
{QStringLiteral("FRNOTACCEPTOFFER"), QStringLiteral("We do not accept this offer.")},
|
||||||
|
{QStringLiteral("FRNEWNATION"), QStringLiteral("We have contact to #n now.")},
|
||||||
|
{QStringLiteral("SHIPBUILT"), QStringLiteral("#N have completed a part of their transstellar colony ship.")},
|
||||||
|
{QStringLiteral("SHIPBITRADE1"), QStringLiteral("#S and")},
|
||||||
|
{QStringLiteral("SHIPBITRADE2"), QStringLiteral("#s are exchanging colony ship parts.")},
|
||||||
|
{QStringLiteral("SHIPUNITRADE1"), QStringLiteral("#N receive")},
|
||||||
|
{QStringLiteral("SHIPUNITRADE2"), QStringLiteral("colony ship parts from #s.")},
|
||||||
|
{QStringLiteral("SHIPCAPTURE1"), QStringLiteral("#N take control of the")},
|
||||||
|
{QStringLiteral("SHIPCAPTURE2"), QStringLiteral("#a colony ship!")},
|
||||||
|
{QStringLiteral("SHIPDESTROYED"), QStringLiteral("#N lost control of their colony ship.")},
|
||||||
{QStringLiteral("FRPEACE"), QStringLiteral("we propose a peace treaty")},
|
{QStringLiteral("FRPEACE"), QStringLiteral("we propose a peace treaty")},
|
||||||
{QStringLiteral("FRFRIENDLY"), QStringLiteral("we propose friendly relations")},
|
{QStringLiteral("FRFRIENDLY"), QStringLiteral("we propose friendly relations")},
|
||||||
{QStringLiteral("FRALLIANCE"), QStringLiteral("we propose an alliance")},
|
{QStringLiteral("FRALLIANCE"), QStringLiteral("we propose an alliance")},
|
||||||
|
|||||||
Reference in new issue
Block a user