added draft and natstat with their requirements
This commit is contained in:
1 parent
6513c6f8ec
commit
1667e18dda
10 files changed
+1542
No files matched your search
@@ -144,6 +144,12 @@ set(PROJECT_SOURCES
|
||||
game/localplayer/Wonders.cpp
|
||||
game/localplayer/Wonders.h
|
||||
game/localplayer/Wonders.ui
|
||||
game/localplayer/NatStat.cpp
|
||||
game/localplayer/NatStat.h
|
||||
game/localplayer/NatStat.ui
|
||||
game/localplayer/Draft.cpp
|
||||
game/localplayer/Draft.h
|
||||
game/localplayer/Draft.ui
|
||||
${TS_FILES}
|
||||
)
|
||||
|
||||
|
||||
@@ -61,6 +61,39 @@ inline bool hasMapOption(MapOptions options, MapOption option)
|
||||
return (options & (1u << option)) != 0;
|
||||
}
|
||||
|
||||
// TSaveOption/TSaveOptions: Term.pas's user-configurable UI preferences
|
||||
// bitset (same bit-position-not-ordinal convention as MapOption above).
|
||||
enum SaveOption {
|
||||
soAlEffectiveMovesOnly = 0,
|
||||
soEnMoves = 1,
|
||||
soEnAttacks = 2,
|
||||
soEnNoMoves = 3,
|
||||
soWaitTurn = 4,
|
||||
soEffectiveMovesOnly = 5,
|
||||
soEnFastMoves = 6,
|
||||
soSlowMoves = 7,
|
||||
soFastMoves = 8,
|
||||
soVeryFastMoves = 9,
|
||||
soNames = 10,
|
||||
soRepList = 11,
|
||||
soRepScreens = 12,
|
||||
soSoundOff = 13,
|
||||
soSoundOn = 14,
|
||||
soSoundOnAlt = 15,
|
||||
soScrollSlow = 16,
|
||||
soScrollFast = 17,
|
||||
soScrollOff = 18,
|
||||
soAlSlowMoves = 19,
|
||||
soAlFastMoves = 20,
|
||||
soAlNoMoves = 21,
|
||||
soTellAI = 30,
|
||||
};
|
||||
using SaveOptions = std::uint32_t;
|
||||
inline bool hasSaveOption(SaveOptions options, SaveOption option)
|
||||
{
|
||||
return (options & (1u << option)) != 0;
|
||||
}
|
||||
|
||||
using TImpOrder = std::array<std::int8_t, (nImp + 4) / 4 * 4>;
|
||||
using TEnhancementJobs = std::uint8_t[12][8];
|
||||
// Pascal's `set of 0..39`; bit i set means "treat Server() result code i as
|
||||
|
||||
@@ -0,0 +1,525 @@
|
||||
// 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 "Draft.h"
|
||||
#include "ui_Draft.h"
|
||||
|
||||
#include "Cevo/CevoScreenTools.h"
|
||||
#include "Cevo/CevoTexture.h"
|
||||
#include "Global.h"
|
||||
#include "Help.h"
|
||||
#include "Term.h"
|
||||
#include "Tribes.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QMouseEvent>
|
||||
|
||||
namespace Cevo {
|
||||
namespace Draft {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int MaxLines0 = 11;
|
||||
constexpr int LinePitch = 20;
|
||||
constexpr int xDomain = 30;
|
||||
constexpr int yDomain0 = 464;
|
||||
constexpr int DomainPitch = 40;
|
||||
constexpr int xFeature = 38;
|
||||
constexpr int yFeature0 = 42;
|
||||
constexpr int xWeight = 100;
|
||||
constexpr int yWeight0 = 271;
|
||||
constexpr int xTotal = 20;
|
||||
constexpr int xTotal2 = 34;
|
||||
constexpr int yTotal0 = 354;
|
||||
constexpr int xView = 17;
|
||||
constexpr int yView0 = 283;
|
||||
|
||||
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
|
||||
// plain-English placeholders for this dialog's own text.
|
||||
QString phrase(const QString &key)
|
||||
{
|
||||
static const QHash<QString, QString> table = {
|
||||
{QStringLiteral("TITLE_DRAFT"), QStringLiteral("Unit Design")},
|
||||
{QStringLiteral("BTN_OK"), QStringLiteral("OK")},
|
||||
{QStringLiteral("DOMAIN0"), QStringLiteral("Ground units")},
|
||||
{QStringLiteral("DOMAIN1"), QStringLiteral("Sea units")},
|
||||
{QStringLiteral("DOMAIN2"), QStringLiteral("Air units")},
|
||||
{QStringLiteral("UNITSTRENGTH"), QStringLiteral("Strength")},
|
||||
{QStringLiteral("UNITTRANSPORT"), QStringLiteral("Transport")},
|
||||
{QStringLiteral("UNITSPEED"), QStringLiteral("Speed")},
|
||||
{QStringLiteral("UNITCOST"), QStringLiteral("Cost")},
|
||||
};
|
||||
const auto it = table.constFind(key);
|
||||
return it != table.constEnd() ? it.value() : key;
|
||||
}
|
||||
|
||||
QString phraseFeature(int code)
|
||||
{
|
||||
// Feature names (StringTables.pas) aren't ported.
|
||||
return QStringLiteral("Feature #%1").arg(code);
|
||||
}
|
||||
|
||||
QString phraseCostDiff(int difficulty)
|
||||
{
|
||||
return QStringLiteral("Cost (difficulty %1)").arg(difficulty);
|
||||
}
|
||||
|
||||
void imageOpBCCItem(Dpi::Bitmap &dst, Dpi::Bitmap &src, const QPoint &pos, const QRect &srcRect, int color1,
|
||||
int color2)
|
||||
{
|
||||
imageOpBCC(dst, src, pos.x(), pos.y(), srcRect.left(), srcRect.top(), srcRect.width(), srcRect.height(), color1,
|
||||
color2);
|
||||
}
|
||||
|
||||
bool isFeatureAuto(int feature)
|
||||
{
|
||||
return (AutoFeature & (1u << feature)) != 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
DraftDlg::DraftDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::DraftDlg)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
initButtons();
|
||||
helpContext = QStringLiteral("CLASSES");
|
||||
setWindowTitle(phrase(QStringLiteral("TITLE_DRAFT")));
|
||||
ui->okBtn->setCaption(phrase(QStringLiteral("BTN_OK")));
|
||||
|
||||
ui->groundArea->setToolTip(phrase(QStringLiteral("DOMAIN0")));
|
||||
ui->seaArea->setToolTip(phrase(QStringLiteral("DOMAIN1")));
|
||||
ui->airArea->setToolTip(phrase(QStringLiteral("DOMAIN2")));
|
||||
|
||||
back.setSize(width(), height());
|
||||
back.canvas().begin();
|
||||
back.canvas().fillRect(QRect(0, 0, back.width(), back.height()));
|
||||
back.canvas().end();
|
||||
tmpl.loadFromFile(getGraphicsDir() + QStringLiteral("/MiliRes") + PngExt);
|
||||
|
||||
ui->closeBtn->onClick = [this] {
|
||||
setModalResult(Dpi::ModalResult::Cancel);
|
||||
close();
|
||||
};
|
||||
ui->okBtn->onClick = [this] {
|
||||
setModalResult(Dpi::ModalResult::Ok);
|
||||
close();
|
||||
};
|
||||
|
||||
onShow = [this] {
|
||||
domain = dGround;
|
||||
while (domain < dAir && Upgrade[domain][0].Preq != preNone &&
|
||||
ClientTools::myRO->Tech[Upgrade[domain][0].Preq] < tsApplicable)
|
||||
++domain;
|
||||
|
||||
maxLines = 0;
|
||||
for (int d = 0; d < nDomains; ++d) {
|
||||
if (Upgrade[d][0].Preq == preNone || ClientTools::myRO->Tech[Upgrade[d][0].Preq] >= tsApplicable) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < nFeature; ++i)
|
||||
if (isFeatureInList(d, i))
|
||||
++count;
|
||||
if (count > maxLines)
|
||||
maxLines = count;
|
||||
}
|
||||
}
|
||||
cut = (MaxLines0 - maxLines) * LinePitch;
|
||||
ui->okBtn->move(ui->okBtn->x(), 477 - cut);
|
||||
yDomain = yDomain0 - cut;
|
||||
yWeight = yWeight0 - cut;
|
||||
yTotal = yTotal0 - cut;
|
||||
yView = yView0 - cut;
|
||||
|
||||
if (windowMode() == WindowMode::Modal)
|
||||
centerToScreen(tmpl.width(), tmpl.height() - cut);
|
||||
|
||||
setDomain(domain);
|
||||
ClientTools::server(sCreateDevModel, ClientTools::me, domain, nullptr);
|
||||
ClientTools::myModel[ClientTools::myRO->nModel] = ClientTools::myRO->DevModel;
|
||||
Term::initMyModel(ClientTools::myRO->nModel, false);
|
||||
offscreenPaint();
|
||||
incCap = -1;
|
||||
decCap = -1;
|
||||
};
|
||||
}
|
||||
|
||||
DraftDlg::~DraftDlg()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DraftDlg::showNewContent(WindowMode newMode)
|
||||
{
|
||||
BufferedDrawDlg::showNewContent(newMode);
|
||||
}
|
||||
|
||||
bool DraftDlg::isFeatureInList(int d, int i) const
|
||||
{
|
||||
return !isFeatureAuto(i) && (1u << d & Feature[i].Domains) != 0 && Feature[i].Preq != preNA &&
|
||||
(Feature[i].Preq == preNone ||
|
||||
(Feature[i].Preq == preSun && ClientTools::myRO->Wonder[woSun].EffectiveOwner == ClientTools::me) ||
|
||||
(Feature[i].Preq >= 0 && ClientTools::myRO->Tech[Feature[i].Preq] >= tsApplicable));
|
||||
}
|
||||
|
||||
void DraftDlg::setDomain(int d)
|
||||
{
|
||||
auto prio = [](int fix) {
|
||||
const int featurePreq = Feature[fix].Preq;
|
||||
int result;
|
||||
if (fix < mcFirstNonCap)
|
||||
result = 10000 + fix;
|
||||
else if (featurePreq == preNone)
|
||||
result = 20000;
|
||||
else if (featurePreq < 0)
|
||||
result = 40000;
|
||||
else
|
||||
result = 30000 + ClientTools::advValue[static_cast<std::size_t>(featurePreq)];
|
||||
if (!isFeatureAuto(fix))
|
||||
result += 90000;
|
||||
return result;
|
||||
};
|
||||
|
||||
domain = d;
|
||||
lines = 0;
|
||||
for (int i = 0; i < nFeature; ++i) {
|
||||
if (isFeatureInList(domain, i)) {
|
||||
code[static_cast<std::size_t>(lines)] = i;
|
||||
++lines;
|
||||
}
|
||||
}
|
||||
yFeature = yFeature0 + (maxLines - lines) * LinePitch / 2;
|
||||
|
||||
for (int i = 0; i < lines - 1; ++i)
|
||||
for (int j = i + 1; j < lines; ++j)
|
||||
if (prio(code[static_cast<std::size_t>(i)]) > prio(code[static_cast<std::size_t>(j)]))
|
||||
std::swap(code[static_cast<std::size_t>(i)], code[static_cast<std::size_t>(j)]);
|
||||
}
|
||||
|
||||
void DraftDlg::offscreenPaint()
|
||||
{
|
||||
BufferedDrawDlg::offscreenPaint();
|
||||
if (!MainTexture)
|
||||
return;
|
||||
|
||||
unshareBitmap(back);
|
||||
|
||||
resize(width(), tmpl.height() - cut);
|
||||
if (height() > MainTexture->height()) {
|
||||
bitBltBitmap(back, 0, 0, width(), 64, MainTexture->image(), (MainTexture->width() - width()) / 2,
|
||||
MainTexture->height() - 64);
|
||||
bitBltBitmap(back, 0, 64, width(), height() - 64, MainTexture->image(), (MainTexture->width() - width()) / 2,
|
||||
0);
|
||||
} else {
|
||||
bitBltBitmap(back, 0, 0, width(), height(), MainTexture->image(), (MainTexture->width() - width()) / 2,
|
||||
(MainTexture->height() - height()) / 2);
|
||||
}
|
||||
imageOpB(back, tmpl, 0, 0, 0, 0, tmpl.width(), 64);
|
||||
imageOpB(back, tmpl, 0, 64, 0, 64 + cut, tmpl.width(), tmpl.height() - 64 - cut);
|
||||
|
||||
bitBltBitmap(offscreen, 0, 0, width(), height(), back, 0, 0);
|
||||
|
||||
Dpi::Canvas &canvas = offscreen.canvas();
|
||||
canvas.begin();
|
||||
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]);
|
||||
risedTextOut(canvas, 10, 7, windowTitle());
|
||||
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Small)]);
|
||||
|
||||
auto domainAvailable = [](int d) {
|
||||
return Upgrade[d][0].Preq == preNone || ClientTools::myRO->Tech[Upgrade[d][0].Preq] >= tsApplicable;
|
||||
};
|
||||
|
||||
int domainCount = 0;
|
||||
for (int d = 0; d < nDomains; ++d)
|
||||
if (domainAvailable(d))
|
||||
++domainCount;
|
||||
if (domainCount > 1) {
|
||||
for (int d = 0; d < nDomains; ++d) {
|
||||
if (domainAvailable(d)) {
|
||||
const int x = xDomain + d * DomainPitch;
|
||||
imageOpBCC(offscreen, Templates->data, x, yDomain, 142, 246 + 37 * d, 36, 36, 0,
|
||||
d == domain ? 0x00C0FF : 0x606060);
|
||||
}
|
||||
}
|
||||
frame(canvas, xDomain - 11, yDomain - 3, xDomain + 2 * DomainPitch + 46, yDomain + 38,
|
||||
colorFromDelphi(0xB0B0B0), Qt::white);
|
||||
rframe(canvas, xDomain - 12, yDomain - 4, xDomain + 2 * DomainPitch + 47, yDomain + 39, Qt::white,
|
||||
colorFromDelphi(0xB0B0B0));
|
||||
}
|
||||
ui->groundArea->move(ui->groundArea->x(), yDomain);
|
||||
ui->groundArea->setVisible(domainAvailable(dGround));
|
||||
ui->seaArea->move(ui->seaArea->x(), yDomain);
|
||||
ui->seaArea->setVisible(domainAvailable(dSea));
|
||||
ui->airArea->move(ui->airArea->x(), yDomain);
|
||||
ui->airArea->setVisible(domainAvailable(dAir));
|
||||
|
||||
const TModel &devModel = ClientTools::myRO->DevModel;
|
||||
|
||||
// strength bar
|
||||
{
|
||||
int y = yTotal;
|
||||
darkGradient(canvas, xTotal - 6, y + 1, 184, 2);
|
||||
darkGradient(canvas, xTotal2 + 172, y + 1, 95, 2);
|
||||
risedTextOut(canvas, xTotal - 2, y, phrase(QStringLiteral("UNITSTRENGTH")));
|
||||
risedTextOut(canvas, xTotal + 112 + 30, y, QStringLiteral("x%1").arg(devModel.MStrength));
|
||||
risedTextOut(canvas, xTotal2 + 148 + 30, y, QStringLiteral("="));
|
||||
const QString s = QStringLiteral("%1/%2").arg(devModel.Attack).arg(devModel.Defense);
|
||||
risedTextOut(canvas, xTotal2 + 170 + 64 + 30 - biColorTextWidth(canvas, s), y, s);
|
||||
|
||||
// transport bar
|
||||
if (devModel.MTrans > 0) {
|
||||
y = yTotal + 19;
|
||||
darkGradient(canvas, xTotal - 6, y + 1, 184, 1);
|
||||
darkGradient(canvas, xTotal2 + 172, y + 1, 95, 1);
|
||||
risedTextOut(canvas, xTotal - 2, y, phrase(QStringLiteral("UNITTRANSPORT")));
|
||||
risedTextOut(canvas, xTotal + 112 + 30, y, QStringLiteral("x%1").arg(devModel.MTrans));
|
||||
risedTextOut(canvas, xTotal2 + 148 + 30, y, QStringLiteral("="));
|
||||
|
||||
canvas.font().setColor(Qt::black);
|
||||
int dx = -237 - 30;
|
||||
for (int i = mcFirstNonCap - 1; i >= 3; --i) {
|
||||
if (i == mcSeaTrans || i == mcCarrier || i == mcAirTrans) {
|
||||
const int num = devModel.Cap[i] * devModel.MTrans;
|
||||
if (num > 0) {
|
||||
dx += 15;
|
||||
canvas.brush().setColor(colorFromDelphi(0xC0C0C0));
|
||||
canvas.frameRect(QRect(xTotal2 - 3 - dx, y + 2, 14, 14));
|
||||
canvas.brush().setStyle(Qt::NoBrush);
|
||||
sprite(canvas, *HGrSystem, xTotal2 - 1 - dx, y + 4, 10, 10, 66 + i % 11 * 11,
|
||||
137 + i / 11 * 11);
|
||||
if (num > 1) {
|
||||
const QString countText = QString::number(num);
|
||||
const int w = canvas.textWidth(countText);
|
||||
dx += w + 1;
|
||||
canvas.brush().setColor(Qt::white);
|
||||
canvas.fillRect(QRect(xTotal2 - 3 - dx, y + 2, w + 2, 14));
|
||||
canvas.brush().setStyle(Qt::NoBrush);
|
||||
canvas.textOut(xTotal2 - 3 - dx + 1, y, countText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// speed bar
|
||||
y = yTotal + 38;
|
||||
loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, y, phrase(QStringLiteral("UNITSPEED")));
|
||||
dLine(canvas, xTotal - 2, xTotal + 174, y + 16, MainTexture->colorBevelShade, MainTexture->colorBevelLight);
|
||||
dLine(canvas, xTotal2 + 176, xTotal2 + 263, y + 16, MainTexture->colorBevelShade,
|
||||
MainTexture->colorBevelLight);
|
||||
QString s2 = movementToString(devModel.Speed);
|
||||
risedTextOut(canvas, xTotal2 + 170 + 64 + 30 - canvas.textWidth(s2), y, s2);
|
||||
|
||||
// cost bar
|
||||
y = yTotal + 57;
|
||||
loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, y, phrase(QStringLiteral("UNITCOST")));
|
||||
loweredTextOut(canvas, -1, *MainTexture, xTotal + 112 + 30, y, QStringLiteral("x%1").arg(devModel.MCost));
|
||||
loweredTextOut(canvas, -1, *MainTexture, xTotal2 + 148 + 30, y, QStringLiteral("="));
|
||||
dLine(canvas, xTotal - 2, xTotal + 174, y + 16, MainTexture->colorBevelShade, MainTexture->colorBevelLight);
|
||||
dLine(canvas, xTotal2 + 176, xTotal2 + 263, y + 16, MainTexture->colorBevelShade,
|
||||
MainTexture->colorBevelLight);
|
||||
QString s3 = QString::number(devModel.Cost);
|
||||
risedTextOut(canvas, xTotal2 + 170 + 64 + 30 - 12 - canvas.textWidth(s3), y, s3);
|
||||
sprite(canvas, *HGrSystem, xTotal2 + 170 + 54 + 30, y + 4, 10, 10, 88, 115);
|
||||
|
||||
if (ClientTools::g.Difficulty[ClientTools::me] != 2) {
|
||||
y = yTotal + 76;
|
||||
loweredTextOut(canvas, -1, *MainTexture, xTotal - 2, y,
|
||||
phraseCostDiff(ClientTools::g.Difficulty[ClientTools::me]));
|
||||
loweredTextOut(canvas, -1, *MainTexture, xTotal2 + 148 + 30, y, QStringLiteral("="));
|
||||
dLine(canvas, xTotal - 2, xTotal + 174, y + 16, MainTexture->colorBevelShade,
|
||||
MainTexture->colorBevelLight);
|
||||
dLine(canvas, xTotal2 + 176, xTotal2 + 263, y + 16, MainTexture->colorBevelShade,
|
||||
MainTexture->colorBevelLight);
|
||||
QString s4 = QString::number(devModel.Cost * BuildCostMod[ClientTools::g.Difficulty[ClientTools::me]] / 12);
|
||||
risedTextOut(canvas, xTotal2 + 170 + 64 + 30 - 12 - canvas.textWidth(s4), y, s4);
|
||||
sprite(canvas, *HGrSystem, xTotal2 + 170 + 54 + 30, y + 4, 10, 10, 88, 115);
|
||||
}
|
||||
}
|
||||
|
||||
// weight display
|
||||
GraphicSetItem *weightOn = Templates->searchByName(QStringLiteral("WeightOn"));
|
||||
GraphicSetItem *weightOff = Templates->searchByName(QStringLiteral("WeightOff"));
|
||||
for (int i = 0; i < devModel.MaxWeight; ++i) {
|
||||
GraphicSetItem *item = i < devModel.Weight ? weightOn : weightOff;
|
||||
if (item)
|
||||
imageOpBCCItem(offscreen, Templates->data, QPoint(xWeight + 20 * i, yWeight), item->boundsRect(), 0,
|
||||
0x949494);
|
||||
}
|
||||
|
||||
for (int i = 0; i < lines; ++i) {
|
||||
const int c = code[static_cast<std::size_t>(i)];
|
||||
if (!isFeatureAuto(c)) {
|
||||
if (c < mcFirstNonCap) {
|
||||
bitBltBitmap(offscreen, xFeature - 21, yFeature + 2 + LinePitch * i, 12, 12, HGrSystem->data, 169,
|
||||
172);
|
||||
bitBltBitmap(offscreen, xFeature - 9, yFeature + 2 + LinePitch * i, 12, 12, HGrSystem->data, 169, 159);
|
||||
rframe(canvas, xFeature - 22, yFeature + 1 + LinePitch * i, xFeature + 3, yFeature + 14 + LinePitch * i,
|
||||
MainTexture->colorBevelShade, MainTexture->colorBevelLight);
|
||||
} else {
|
||||
bitBltBitmap(offscreen, xFeature - 9, yFeature + 2 + LinePitch * i, 12, 12, HGrSystem->data, 169,
|
||||
185 + 13 * devModel.Cap[c]);
|
||||
rframe(canvas, xFeature - 10, yFeature + 1 + LinePitch * i, xFeature + 3, yFeature + 14 + LinePitch * i,
|
||||
MainTexture->colorBevelShade, MainTexture->colorBevelLight);
|
||||
}
|
||||
|
||||
lightGradient(canvas, xFeature + 34, yFeature + LinePitch * i, 50, HGrSystem->data.image().pixelColor(187, 137));
|
||||
int capWeight = (domain == dGround && c == mcDefense) ? 2 : Feature[c].Weight;
|
||||
const int n = capWeight + Feature[c].Cost;
|
||||
int d = 6;
|
||||
while (n > 0 && (n - 1) * d * 2 > 48 - 10)
|
||||
--d;
|
||||
for (int j = 0; j < n; ++j) {
|
||||
if (j < capWeight)
|
||||
sprite(canvas, *HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d, yFeature + 2 + LinePitch * i + 1,
|
||||
10, 10, 88, 126);
|
||||
else
|
||||
sprite(canvas, *HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d, yFeature + 2 + LinePitch * i + 1,
|
||||
10, 10, 88, 115);
|
||||
}
|
||||
}
|
||||
darkGradient(canvas, xFeature + 17, yFeature + LinePitch * i, 16, 1);
|
||||
frame(canvas, xFeature + 18, yFeature + 1 + LinePitch * i, xFeature + 31, yFeature + 14 + LinePitch * i,
|
||||
colorFromDelphi(0xC0C0C0), colorFromDelphi(0xC0C0C0));
|
||||
sprite(canvas, *HGrSystem, xFeature + 20, yFeature + 3 + LinePitch * i, 10, 10, 66 + c % 11 * 11,
|
||||
137 + c / 11 * 11);
|
||||
|
||||
const int textColor = devModel.Cap[c] > 0 ? colorToDelphi(MainTexture->colorLitText) : -1;
|
||||
if (c < mcFirstNonCap)
|
||||
loweredTextOut(canvas, textColor, *MainTexture, xFeature + 7, yFeature + LinePitch * i - 1,
|
||||
QString::number(devModel.Cap[c]));
|
||||
loweredTextOut(canvas, textColor, *MainTexture, xFeature + 88, yFeature + LinePitch * i - 1, phraseFeature(c));
|
||||
}
|
||||
|
||||
// free features
|
||||
int j = 0;
|
||||
for (int i = 0; i < nFeature; ++i) {
|
||||
if (isFeatureAuto(i) && (1u << domain & Feature[i].Domains) != 0 && Feature[i].Preq != preNA &&
|
||||
((Feature[i].Preq == preSun && ClientTools::myRO->Wonder[woSun].EffectiveOwner == ClientTools::me) ||
|
||||
(Feature[i].Preq >= 0 && ClientTools::myRO->Tech[Feature[i].Preq] >= tsApplicable)) &&
|
||||
!(Feature[i].Preq == adSteamEngine && ClientTools::myRO->Tech[adNuclearPower] >= tsApplicable)) {
|
||||
darkGradient(canvas, xWeight + 4, yWeight + 32 + LinePitch * j, 16, 1);
|
||||
frame(canvas, xWeight + 5, yWeight + 33 + LinePitch * j, xWeight + 18, yWeight + 47 + LinePitch * j,
|
||||
colorFromDelphi(0xC0C0C0), colorFromDelphi(0xC0C0C0));
|
||||
sprite(canvas, *HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * j, 10, 10, 66 + i % 11 * 11,
|
||||
137 + i / 11 * 11);
|
||||
loweredTextOut(canvas, -1, *MainTexture, xWeight + 26, yWeight + 31 + LinePitch * j, phraseFeature(i));
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
||||
if (bigImp) {
|
||||
Tribes::Tribe &me = *Tribes::tribe[static_cast<std::size_t>(ClientTools::me)];
|
||||
Tribes::ModelPicture &mp = me.modelPictureAt(ClientTools::myRO->nModel);
|
||||
frameImage(canvas, *bigImp, xView + 4, yView + 4, xSizeBig, ySizeBig, 0, 0);
|
||||
if (mp.hGr)
|
||||
sprite(canvas, *mp.hGr, xView, yView, 64, 44, mp.pix % 10 * 65 + 1, mp.pix / 10 * 49 + 1);
|
||||
}
|
||||
|
||||
canvas.end();
|
||||
markUsedOffscreen(width(), height());
|
||||
}
|
||||
|
||||
void DraftDlg::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
BufferedDrawDlg::resizeEvent(event);
|
||||
ui->closeBtn->move(width() - 31, ui->closeBtn->y());
|
||||
}
|
||||
|
||||
void DraftDlg::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
const int x = event->pos().x();
|
||||
const int y = event->pos().y();
|
||||
|
||||
auto domainAvailable = [](int d) {
|
||||
return Upgrade[d][0].Preq == preNone || ClientTools::myRO->Tech[Upgrade[d][0].Preq] >= tsApplicable;
|
||||
};
|
||||
|
||||
for (int d = 0; d < nDomains; ++d) {
|
||||
if (d != domain && domainAvailable(d) && x >= xDomain + d * DomainPitch &&
|
||||
x < xDomain + d * DomainPitch + 36 && y >= yDomain && y < yDomain + 36) {
|
||||
setDomain(d);
|
||||
ClientTools::server(sCreateDevModel, ClientTools::me, domain, nullptr);
|
||||
ClientTools::myModel[ClientTools::myRO->nModel] = ClientTools::myRO->DevModel;
|
||||
Term::initMyModel(ClientTools::myRO->nModel, false);
|
||||
smartUpdateContent();
|
||||
}
|
||||
}
|
||||
|
||||
if (y >= yFeature && y < yFeature + LinePitch * lines) {
|
||||
const int i = (y - yFeature) / LinePitch;
|
||||
const int c = code[static_cast<std::size_t>(i)];
|
||||
if (x >= xFeature - 21 && x < width() && (event->modifiers() & Qt::ShiftModifier)) {
|
||||
Help::showNewContent(windowModeMakePersistent(windowMode()), Help::LinkCategory::Feature, c);
|
||||
} else if (!isFeatureAuto(c)) {
|
||||
if (c < mcFirstNonCap && x >= xFeature - 21 && x < xFeature - 21 + 12) {
|
||||
incCap = c;
|
||||
bitBltBitmap(offscreen, xFeature - 21, yFeature + 2 + LinePitch * i, 12, 12, HGrSystem->data, 182,
|
||||
172);
|
||||
smartInvalidate();
|
||||
} else if (x >= xFeature - 9 && x < xFeature - 9 + 12) {
|
||||
decCap = c;
|
||||
if (c < mcFirstNonCap)
|
||||
bitBltBitmap(offscreen, xFeature - 9, yFeature + 2 + LinePitch * i, 12, 12, HGrSystem->data,
|
||||
182, 159);
|
||||
else
|
||||
bitBltBitmap(offscreen, xFeature - 9, yFeature + 2 + LinePitch * i, 12, 12, HGrSystem->data,
|
||||
182, 185 + 13 * ClientTools::myRO->DevModel.Cap[c]);
|
||||
smartInvalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BufferedDrawDlg::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void DraftDlg::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (incCap >= 0) {
|
||||
const int newValue = ClientTools::myRO->DevModel.Cap[incCap] + 1;
|
||||
ClientTools::server(sSetDevModelCap + (newValue << 4), ClientTools::me, incCap, nullptr);
|
||||
ClientTools::myModel[ClientTools::myRO->nModel] = ClientTools::myRO->DevModel;
|
||||
Term::initMyModel(ClientTools::myRO->nModel, false);
|
||||
smartUpdateContent();
|
||||
incCap = -1;
|
||||
} else if (decCap >= 0) {
|
||||
if (decCap >= mcFirstNonCap || ClientTools::myRO->DevModel.Cap[decCap] > 0) {
|
||||
int newValue = ClientTools::myRO->DevModel.Cap[decCap] - 1;
|
||||
if (decCap >= mcFirstNonCap)
|
||||
newValue = -newValue;
|
||||
ClientTools::server(sSetDevModelCap + (newValue << 4), ClientTools::me, decCap, nullptr);
|
||||
ClientTools::myModel[ClientTools::myRO->nModel] = ClientTools::myRO->DevModel;
|
||||
Term::initMyModel(ClientTools::myRO->nModel, false);
|
||||
}
|
||||
smartUpdateContent();
|
||||
decCap = -1;
|
||||
}
|
||||
BufferedDrawDlg::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
} // namespace Draft
|
||||
} // namespace Cevo
|
||||
@@ -0,0 +1,80 @@
|
||||
// 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
|
||||
|
||||
#include "Cevo/CevoBaseWin.h"
|
||||
#include "Cevo/Protocol.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class DraftDlg;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Cevo {
|
||||
namespace Draft {
|
||||
|
||||
// TDraftDlg equivalent: the new-unit-type "draft" designer (pick a domain,
|
||||
// tune feature capability levels, see live strength/cost/speed totals). UI
|
||||
// built from Draft.ui (adapted from the original's Draft.lfm).
|
||||
class DraftDlg : public BufferedDrawDlg {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DraftDlg(QWidget *parent = nullptr);
|
||||
~DraftDlg() override;
|
||||
|
||||
void showNewContent(WindowMode newMode);
|
||||
|
||||
protected:
|
||||
void offscreenPaint() override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
bool isFeatureInList(int d, int i) const;
|
||||
void setDomain(int d);
|
||||
|
||||
int domain = dGround;
|
||||
int maxLines = 0;
|
||||
int lines = 0;
|
||||
int cut = 0;
|
||||
int yDomain = 0, yFeature = 0, yWeight = 0, yTotal = 0, yView = 0;
|
||||
int incCap = -1, decCap = -1;
|
||||
std::array<int, nFeature> code{};
|
||||
Dpi::Bitmap tmpl;
|
||||
Dpi::Bitmap back;
|
||||
|
||||
Ui::DraftDlg *ui;
|
||||
};
|
||||
|
||||
} // namespace Draft
|
||||
} // namespace Cevo
|
||||
Vendored
+111
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<ui version="4.0">
|
||||
<class>DraftDlg</class>
|
||||
<widget class="QWidget" name="DraftDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>315</width>
|
||||
<height>511</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>C-evo</string>
|
||||
</property>
|
||||
<widget class="Cevo::ButtonA" name="okBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>196</x>
|
||||
<y>477</y>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonB" name="closeBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>284</x>
|
||||
<y>6</y>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="groundArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>464</y>
|
||||
<width>36</width>
|
||||
<height>36</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="seaArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>464</y>
|
||||
<width>36</width>
|
||||
<height>36</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="airArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>464</y>
|
||||
<width>36</width>
|
||||
<height>36</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Cevo::ButtonA</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Cevo/CevoButtonA.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Cevo::ButtonB</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Cevo/CevoButtonB.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Cevo::Area</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Cevo/CevoArea.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
</ui>
|
||||
@@ -0,0 +1,483 @@
|
||||
// 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 "NatStat.h"
|
||||
#include "ui_NatStat.h"
|
||||
|
||||
#include "Cevo/CevoScreenTools.h"
|
||||
#include "Cevo/CevoTexture.h"
|
||||
#include "ClientTools.h"
|
||||
#include "Global.h"
|
||||
#include "IsoEngine.h"
|
||||
#include "Term.h"
|
||||
#include "Tribes.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Cevo {
|
||||
namespace NatStat {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int xIcon = 326;
|
||||
constexpr int yIcon = 49;
|
||||
constexpr int xAttrib = 96;
|
||||
constexpr int yAttrib = 40;
|
||||
constexpr int xRelation = 16;
|
||||
constexpr int yRelation = 110;
|
||||
constexpr int PaperShade = 3;
|
||||
constexpr int ReportLines = 12;
|
||||
constexpr int LineSpacing = 22;
|
||||
constexpr int xReport = 24;
|
||||
constexpr int yReport = 165;
|
||||
constexpr int wReport = 352;
|
||||
constexpr int hReport = ReportLines * LineSpacing;
|
||||
|
||||
// Phrases/Phrases2 (StringTables.pas) aren't ported; disclosed
|
||||
// plain-English placeholders for this dialog's own text.
|
||||
QString phrase(const QString &key)
|
||||
{
|
||||
static const QHash<QString, QString> table = {
|
||||
{QStringLiteral("BTN_SELECT"), QStringLiteral("Select nation")},
|
||||
{QStringLiteral("BTN_DIALOG"), QStringLiteral("Negotiate")},
|
||||
{QStringLiteral("FRSTATPOP"), QStringLiteral("Population: %1")},
|
||||
{QStringLiteral("FRSTATTER"), QStringLiteral("Territory: %1")},
|
||||
{QStringLiteral("FRSTATTECH"), QStringLiteral("Advances researched: %1")},
|
||||
{QStringLiteral("FRSTATEXP"), QStringLiteral("Land explored: %1%")},
|
||||
{QStringLiteral("FROLDCIVILREP"), QStringLiteral("Last report: %1")},
|
||||
{QStringLiteral("FRTREASURY"), QStringLiteral("Treasury: %1")},
|
||||
{QStringLiteral("FRRELATIONS"), QStringLiteral("Relations:")},
|
||||
{QStringLiteral("FRCOLDWAR"), QStringLiteral("We are in a cold war.")},
|
||||
{QStringLiteral("FRMYANARCHY"), QStringLiteral("We are in anarchy.")},
|
||||
{QStringLiteral("FRANARCHY"), QStringLiteral("They are in anarchy.")},
|
||||
{QStringLiteral("FREXTINCT"), QStringLiteral("Extinct since")},
|
||||
{QStringLiteral("FRCREDIBILITY"), QStringLiteral("Credibility: %1")},
|
||||
{QStringLiteral("FRNOCONTACT"), QStringLiteral("No contact")},
|
||||
{QStringLiteral("FRTREATY"), QStringLiteral("Treaty:")},
|
||||
{QStringLiteral("FRNOVISIT"), QStringLiteral("Never visited")},
|
||||
{QStringLiteral("FRLASTCONTACT"), QStringLiteral("Last contact:")},
|
||||
{QStringLiteral("FRNOCIVILREP"), QStringLiteral("No civil report available.")},
|
||||
{QStringLiteral("MENU_TELLAI"), QStringLiteral("Tell AI")},
|
||||
};
|
||||
const auto it = table.constFind(key);
|
||||
return it != table.constEnd() ? it.value() : key;
|
||||
}
|
||||
|
||||
QString phraseGovernment(int government)
|
||||
{
|
||||
return QStringLiteral("government #%1 ").arg(government);
|
||||
}
|
||||
|
||||
QString phraseCredibility(int roughCredibility)
|
||||
{
|
||||
static const QHash<int, QString> table = {
|
||||
{0, QStringLiteral("poor")}, {1, QStringLiteral("fair")}, {2, QStringLiteral("good")},
|
||||
{3, QStringLiteral("perfect")},
|
||||
};
|
||||
const auto it = table.constFind(roughCredibility);
|
||||
return it != table.constEnd() ? it.value() : QString();
|
||||
}
|
||||
|
||||
QString phraseTreaty(int treaty)
|
||||
{
|
||||
static const QHash<int, QString> table = {
|
||||
{trNoContact, QStringLiteral("no contact")}, {trNone, QStringLiteral("none")},
|
||||
{trCeaseFire, QStringLiteral("cease-fire")}, {trPeace, QStringLiteral("peace")},
|
||||
{trFriendlyContact, QStringLiteral("friendly")}, {trAlliance, QStringLiteral("alliance")},
|
||||
};
|
||||
const auto it = table.constFind(treaty);
|
||||
return it != table.constEnd() ? it.value() : QString();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NatStatDlg::NatStatDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::NatStatDlg)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
initButtons();
|
||||
ui->contactBtn->setTemplate(Templates ? &Templates->data : nullptr);
|
||||
ui->contactBtn->setButtonIndex(3);
|
||||
helpContext = QStringLiteral("DIPLOMACY");
|
||||
ui->toggleBtn->setToolTip(phrase(QStringLiteral("BTN_SELECT")));
|
||||
ui->contactBtn->setToolTip(phrase(QStringLiteral("BTN_DIALOG")));
|
||||
|
||||
back.setSize(width(), height());
|
||||
back.canvas().begin();
|
||||
back.canvas().fillRect(QRect(0, 0, back.width(), back.height()));
|
||||
back.canvas().end();
|
||||
|
||||
tmpl.loadFromFile(getGraphicsDir() + QStringLiteral("/Nation") + PngExt);
|
||||
|
||||
popup = new QMenu(this);
|
||||
|
||||
ui->closeBtn->onClick = [this] { close(); };
|
||||
ui->toggleBtn->onClick = [this] { toggleBtnClicked(); };
|
||||
ui->contactBtn->onClick = [this] { dialogBtnClicked(); };
|
||||
ui->scrollUpBtn->onClick = [this] {
|
||||
if (linesDown > 0) {
|
||||
--linesDown;
|
||||
smartUpdateContent();
|
||||
}
|
||||
};
|
||||
ui->scrollDownBtn->onClick = [this] {
|
||||
if (linesDown + ReportLines < reportText.size()) {
|
||||
++linesDown;
|
||||
smartUpdateContent();
|
||||
}
|
||||
};
|
||||
ui->tellAIBtn->onClick = [this] { tellAIBtnClicked(); };
|
||||
|
||||
onShow = [this] {
|
||||
if (pView == ClientTools::me) {
|
||||
selfReport.TurnOfCivilReport = ClientTools::myRO->Turn;
|
||||
selfReport.TurnOfMilReport = ClientTools::myRO->Turn;
|
||||
std::copy(std::begin(ClientTools::myRO->Treaty), std::end(ClientTools::myRO->Treaty),
|
||||
std::begin(selfReport.Treaty));
|
||||
selfReport.Government = ClientTools::myRO->Government;
|
||||
selfReport.Money = ClientTools::myRO->Money;
|
||||
currentReport = &selfReport;
|
||||
} else {
|
||||
currentReport = ClientTools::myRO->EnemyReport[pView];
|
||||
}
|
||||
if (currentReport->TurnOfCivilReport >= 0)
|
||||
generateReportText();
|
||||
showContact = pView != ClientTools::me && !(Term::supervising && ClientTools::me == 0);
|
||||
contactEnabled =
|
||||
showContact && !Term::supervising && (1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) != 0;
|
||||
ui->contactBtn->setVisible(contactEnabled && (ClientTools::myRO->Happened & phGameEnd) == 0 &&
|
||||
IsoEngine::clientMode < scContact);
|
||||
const bool showScroll =
|
||||
currentReport->TurnOfCivilReport >= 0 && reportText.size() > ReportLines;
|
||||
ui->scrollUpBtn->setVisible(showScroll);
|
||||
ui->scrollDownBtn->setVisible(showScroll);
|
||||
ui->tellAIBtn->setButtonIndex(
|
||||
ClientTools::hasSaveOption(Term::optionChecked, ClientTools::soTellAI) ? 3 : 2);
|
||||
setWindowTitle(Tribes::tribe[static_cast<std::size_t>(pView)]->tPhrase(QStringLiteral("TITLE_NATION")));
|
||||
linesDown = 0;
|
||||
offscreenPaint();
|
||||
};
|
||||
}
|
||||
|
||||
NatStatDlg::~NatStatDlg()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void NatStatDlg::checkAge()
|
||||
{
|
||||
if (!MainTexture)
|
||||
return;
|
||||
if (MainTexture->age() != agePrepared) {
|
||||
agePrepared = MainTexture->age();
|
||||
bitBltBitmap(back, 0, 0, width(), height(), MainTexture->image(), (MainTexture->width() - width()) / 2,
|
||||
(MainTexture->height() - height()) / 2);
|
||||
imageOpB(back, tmpl, 0, 0, 0, 0, width(), height());
|
||||
}
|
||||
}
|
||||
|
||||
void NatStatDlg::showNewContent(WindowMode newMode, int p)
|
||||
{
|
||||
if (p < 0) {
|
||||
if (IsoEngine::clientMode >= scContact) {
|
||||
pView = Term::dipMem[static_cast<std::size_t>(ClientTools::me)].pContact;
|
||||
} else {
|
||||
pView = 0;
|
||||
while (pView < nPl && (ClientTools::myRO->Treaty[pView] < trNone ||
|
||||
(1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) == 0))
|
||||
++pView;
|
||||
if (pView >= nPl)
|
||||
pView = ClientTools::me;
|
||||
}
|
||||
} else {
|
||||
pView = p;
|
||||
}
|
||||
BufferedDrawDlg::showNewContent(newMode);
|
||||
}
|
||||
|
||||
void NatStatDlg::playerClicked(int p)
|
||||
{
|
||||
showNewContent(windowMode(), p);
|
||||
}
|
||||
|
||||
void NatStatDlg::generateReportText()
|
||||
{
|
||||
std::vector<std::int32_t> list(static_cast<std::size_t>(ClientTools::myRO->Turn + 2));
|
||||
|
||||
auto statText = [&](int no) -> QString {
|
||||
if (currentReport->TurnOfCivilReport >= 0 &&
|
||||
ClientTools::server(sGetChart + (no << 4), ClientTools::me, pView, list.data()) >= rExecuted) {
|
||||
const int i = list[static_cast<std::size_t>(currentReport->TurnOfCivilReport)];
|
||||
switch (no) {
|
||||
case stPop: return phrase(QStringLiteral("FRSTATPOP")).arg(i);
|
||||
case stTerritory: return phrase(QStringLiteral("FRSTATTER")).arg(i);
|
||||
case stScience: return phrase(QStringLiteral("FRSTATTECH")).arg(i / nAdv);
|
||||
case stExplore:
|
||||
return phrase(QStringLiteral("FRSTATEXP")).arg(i * 100 / (ClientTools::g.lx * ClientTools::g.ly));
|
||||
default: return QString();
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
};
|
||||
|
||||
reportText.clear();
|
||||
reportText.append(QString());
|
||||
if (ClientTools::myRO->Turn - currentReport->TurnOfCivilReport > 1 &&
|
||||
(1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) != 0) {
|
||||
reportText.append(phrase(QStringLiteral("FROLDCIVILREP")).arg(Term::turnToString(currentReport->TurnOfCivilReport)));
|
||||
reportText.append(QString());
|
||||
}
|
||||
|
||||
if ((1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) != 0) {
|
||||
reportText.append(phrase(QStringLiteral("FRTREASURY")).arg(currentReport->Money));
|
||||
reportText.append(statText(stPop));
|
||||
reportText.append(statText(stTerritory));
|
||||
}
|
||||
reportText.append(statText(stScience));
|
||||
reportText.append(statText(stExplore));
|
||||
|
||||
bool hasContact = false;
|
||||
for (int p1 = 0; p1 < nPl; ++p1)
|
||||
if (p1 != ClientTools::me && currentReport->Treaty[p1] > trNoContact) {
|
||||
hasContact = true;
|
||||
break;
|
||||
}
|
||||
if (hasContact) {
|
||||
reportText.append(QString());
|
||||
reportText.append(phrase(QStringLiteral("FRRELATIONS")));
|
||||
for (int extinctPart = 0; extinctPart <= 1; ++extinctPart) {
|
||||
for (int treaty = trAlliance; treaty >= trNone; --treaty) {
|
||||
for (int p1 = 0; p1 < nPl; ++p1) {
|
||||
if (p1 != ClientTools::me && currentReport->Treaty[p1] == treaty &&
|
||||
((1u << p1 & static_cast<unsigned>(ClientTools::myRO->Alive)) == 0) == (extinctPart != 0)) {
|
||||
QString s = Tribes::tribe[static_cast<std::size_t>(p1)]->tString(phraseTreaty(treaty));
|
||||
if (extinctPart)
|
||||
s = QLatin1Char('(') + s + QLatin1Char(')');
|
||||
reportText.append(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
reportText.append(QString());
|
||||
}
|
||||
|
||||
void NatStatDlg::offscreenPaint()
|
||||
{
|
||||
BufferedDrawDlg::offscreenPaint();
|
||||
checkAge();
|
||||
|
||||
const bool extinct = (1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) == 0;
|
||||
|
||||
bitBltBitmap(offscreen, 0, 0, width(), height(), back, 0, 0);
|
||||
|
||||
Dpi::Canvas &canvas = offscreen.canvas();
|
||||
canvas.begin();
|
||||
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]);
|
||||
risedTextOut(canvas, 40, 7, windowTitle());
|
||||
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
|
||||
|
||||
Tribes::Tribe &tribe = *Tribes::tribe[static_cast<std::size_t>(pView)];
|
||||
tribe.initAge(ClientTools::getAge(pView));
|
||||
if (tribe.faceHGr) {
|
||||
bitBltBitmap(offscreen, 18, yIcon - 4, 64, 48, tribe.faceHGr->data, 1 + tribe.facePix % 10 * 65,
|
||||
1 + tribe.facePix / 10 * 49);
|
||||
frame(canvas, 18 - 1, yIcon - 4 - 1, 18 + 64, yIcon - 4 + 48, Qt::black, Qt::black);
|
||||
}
|
||||
|
||||
if (pView == ClientTools::me || !extinct)
|
||||
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib,
|
||||
phraseGovernment(currentReport->Government) + QStringLiteral("and"));
|
||||
|
||||
if (pView == ClientTools::me) {
|
||||
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 19,
|
||||
phraseCredibility(Term::roughCredibility(ClientTools::myRO->Credibility)));
|
||||
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 38,
|
||||
phrase(QStringLiteral("FRCREDIBILITY")).arg(ClientTools::myRO->Credibility));
|
||||
} else {
|
||||
if (extinct) {
|
||||
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 9, phrase(QStringLiteral("FREXTINCT")));
|
||||
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 28,
|
||||
Term::turnToString(currentReport->TurnOfCivilReport));
|
||||
} else {
|
||||
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 19,
|
||||
phraseCredibility(Term::roughCredibility(currentReport->Credibility)));
|
||||
loweredTextOut(canvas, -1, *MainTexture, xAttrib, yAttrib + 38,
|
||||
phrase(QStringLiteral("FRCREDIBILITY")).arg(currentReport->Credibility));
|
||||
}
|
||||
|
||||
if (ClientTools::myRO->Treaty[pView] == trNoContact) {
|
||||
const QString s = phrase(QStringLiteral("FRNOCONTACT"));
|
||||
loweredTextOut(canvas, -1, *MainTexture, (width() - biColorTextWidth(canvas, s)) / 2, yRelation + 9, s);
|
||||
} else if (showContact) {
|
||||
loweredTextOut(canvas, -1, *MainTexture, xRelation, yRelation, phrase(QStringLiteral("FRTREATY")));
|
||||
loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation,
|
||||
phraseTreaty(ClientTools::myRO->Treaty[pView]));
|
||||
if (currentReport->TurnOfContact < 0) {
|
||||
loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation + 19,
|
||||
phrase(QStringLiteral("FRNOVISIT")));
|
||||
} else {
|
||||
loweredTextOut(canvas, -1, *MainTexture, xRelation, yRelation + 19,
|
||||
phrase(QStringLiteral("FRLASTCONTACT")));
|
||||
loweredTextOut(canvas, -1, *MainTexture, width() / 2, yRelation + 19,
|
||||
Term::turnToString(currentReport->TurnOfContact));
|
||||
}
|
||||
}
|
||||
|
||||
if (extinct && bigImp)
|
||||
frameImage(canvas, *bigImp, xIcon, yIcon, xSizeBig, ySizeBig, 0, 200, false);
|
||||
}
|
||||
|
||||
if (currentReport->TurnOfCivilReport >= 0) {
|
||||
fillSeamless(canvas, xReport, yReport, wReport, hReport, 0, 0, paper);
|
||||
canvas.brush().setColor(MainTexture->colorBevelShade);
|
||||
canvas.fillRect(QRect(xReport + wReport, yReport + PaperShade, PaperShade, hReport));
|
||||
canvas.fillRect(QRect(xReport + PaperShade, yReport + hReport, wReport + PaperShade - PaperShade, PaperShade));
|
||||
canvas.brush().setStyle(Qt::NoBrush);
|
||||
|
||||
int y = 0;
|
||||
for (int i = 0; i < reportText.size(); ++i) {
|
||||
if (i >= linesDown && i < linesDown + ReportLines) {
|
||||
const QString &s = reportText.at(i);
|
||||
if (!s.isEmpty())
|
||||
biColorTextOut(canvas, Colors->image().pixelColor(clkMisc, cliPaperText), colorFromDelphi(0x7F007F),
|
||||
xReport + 8, yReport + LineSpacing * y, s);
|
||||
++y;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const QString s = phrase(QStringLiteral("FRNOCIVILREP"));
|
||||
risedTextOut(canvas, (width() - biColorTextWidth(canvas, s)) / 2, yReport + hReport / 2 - 10, s);
|
||||
}
|
||||
|
||||
if (ClientTools::hasSaveOption(Term::optionChecked, ClientTools::soTellAI)) {
|
||||
// Server(sGetAIInfo,...) returning a live AI-credits string isn't wired here yet.
|
||||
loweredTextOut(canvas, -1, *MainTexture, 42, 445, QString());
|
||||
} else {
|
||||
loweredTextOut(canvas, -2, *MainTexture, 42, 445, phrase(QStringLiteral("MENU_TELLAI")));
|
||||
}
|
||||
|
||||
ui->contactBtn->setBack(canvas, ui->contactBtn->x(), ui->contactBtn->y());
|
||||
canvas.end();
|
||||
|
||||
markUsedOffscreen(width(), height());
|
||||
}
|
||||
|
||||
void NatStatDlg::dialogBtnClicked()
|
||||
{
|
||||
const int contactResult = Term::mainScreenDipCall(scContact + (pView << 4));
|
||||
if (contactResult < rExecuted) {
|
||||
if (contactResult == eColdWar) {
|
||||
// SoundMessage(...) - Messg.pas's sound-message variant isn't wired here yet.
|
||||
} else if (ClientTools::myRO->Government == gAnarchy) {
|
||||
// "We are in anarchy" - Messg.pas sound message, not wired here yet.
|
||||
} else if (contactResult == eAnarchy) {
|
||||
if (ClientTools::myRO->Treaty[pView] >= trPeace) {
|
||||
if (Term::mainScreenContactRefused(pView, QStringLiteral("FRANARCHY")))
|
||||
smartUpdateContent();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
void NatStatDlg::toggleBtnClicked()
|
||||
{
|
||||
popup->clear();
|
||||
|
||||
if (ClientTools::g.Difficulty[ClientTools::me] != 0) {
|
||||
QAction *action = popup->addAction(
|
||||
Tribes::tribe[static_cast<std::size_t>(ClientTools::me)]->tPhrase(QStringLiteral("TITLE_NATION")));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(ClientTools::me == pView);
|
||||
connect(action, &QAction::triggered, this, [this] { playerClicked(ClientTools::me); });
|
||||
}
|
||||
|
||||
for (int extinctPart = 0; extinctPart <= 1; ++extinctPart) {
|
||||
const int startCount = popup->actions().size();
|
||||
for (int p1 = 0; p1 < nPl; ++p1) {
|
||||
const bool aliveMatch = (1u << p1 & static_cast<unsigned>(ClientTools::myRO->Alive)) != 0 &&
|
||||
ClientTools::myRO->Treaty[p1] >= trNone;
|
||||
const bool extinctMatch = ClientTools::g.Difficulty[p1] > 0 &&
|
||||
(1u << p1 & static_cast<unsigned>(ClientTools::myRO->Alive)) == 0;
|
||||
if ((extinctPart != 0 && extinctMatch) || (extinctPart == 0 && aliveMatch)) {
|
||||
QString caption = Tribes::tribe[static_cast<std::size_t>(p1)]->tPhrase(QStringLiteral("TITLE_NATION"));
|
||||
if (extinctPart)
|
||||
caption = QLatin1Char('(') + caption + QLatin1Char(')');
|
||||
QAction *action = popup->addAction(caption);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(p1 == pView);
|
||||
connect(action, &QAction::triggered, this, [this, p1] { playerClicked(p1); });
|
||||
}
|
||||
}
|
||||
if (startCount > 0 && popup->actions().size() > startCount)
|
||||
popup->insertSeparator(popup->actions().at(startCount));
|
||||
}
|
||||
|
||||
popup->popup(mapToGlobal(QPoint(ui->toggleBtn->x(), ui->toggleBtn->y() + ui->toggleBtn->height())));
|
||||
}
|
||||
|
||||
void NatStatDlg::tellAIBtnClicked()
|
||||
{
|
||||
Term::optionChecked ^= (1u << ClientTools::soTellAI);
|
||||
ui->tellAIBtn->setButtonIndex(ClientTools::hasSaveOption(Term::optionChecked, ClientTools::soTellAI) ? 3 : 2);
|
||||
smartUpdateContent();
|
||||
}
|
||||
|
||||
void NatStatDlg::ecoChange()
|
||||
{
|
||||
if (isVisible() && pView == ClientTools::me) {
|
||||
selfReport.Government = ClientTools::myRO->Government;
|
||||
selfReport.Money = ClientTools::myRO->Money;
|
||||
smartUpdateContent();
|
||||
}
|
||||
}
|
||||
|
||||
void NatStatDlg::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_F9) {
|
||||
int i = 0;
|
||||
do {
|
||||
pView = (pView + 1) % nPl;
|
||||
++i;
|
||||
} while (i < nPl && !((1u << pView & static_cast<unsigned>(ClientTools::myRO->Alive)) != 0 &&
|
||||
ClientTools::myRO->Treaty[pView] >= trNone));
|
||||
if (i >= nPl)
|
||||
pView = ClientTools::me;
|
||||
playerClicked(pView);
|
||||
} else {
|
||||
BufferedDrawDlg::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NatStat
|
||||
} // namespace Cevo
|
||||
@@ -0,0 +1,87 @@
|
||||
// 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
|
||||
|
||||
#include "Cevo/CevoBaseWin.h"
|
||||
#include "Cevo/Protocol.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
class QMenu;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class NatStatDlg;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Cevo {
|
||||
namespace NatStat {
|
||||
|
||||
// TNatStatDlg equivalent: a nation's nation-status report (treasury, stats,
|
||||
// relations, leader portrait). UI built from NatStat.ui (adapted from the
|
||||
// original's NatStat.lfm).
|
||||
class NatStatDlg : public BufferedDrawDlg {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NatStatDlg(QWidget *parent = nullptr);
|
||||
~NatStatDlg() override;
|
||||
|
||||
void showNewContent(WindowMode newMode, int p = -1);
|
||||
void checkAge();
|
||||
void ecoChange();
|
||||
|
||||
protected:
|
||||
void offscreenPaint() override;
|
||||
|
||||
private:
|
||||
void generateReportText();
|
||||
void toggleBtnClicked();
|
||||
void playerClicked(int p);
|
||||
void dialogBtnClicked();
|
||||
void tellAIBtnClicked();
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
int pView = 0;
|
||||
int agePrepared = -2;
|
||||
int linesDown = 0;
|
||||
TEnemyReport selfReport{};
|
||||
const TEnemyReport *currentReport = nullptr;
|
||||
bool showContact = false;
|
||||
bool contactEnabled = false;
|
||||
Dpi::Bitmap back;
|
||||
Dpi::Bitmap tmpl;
|
||||
QStringList reportText;
|
||||
|
||||
QMenu *popup;
|
||||
Ui::NatStatDlg *ui;
|
||||
};
|
||||
|
||||
} // namespace NatStat
|
||||
} // namespace Cevo
|
||||
Vendored
+121
@@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<ui version="4.0">
|
||||
<class>NatStatDlg</class>
|
||||
<widget class="QWidget" name="NatStatDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>C-evo</string>
|
||||
</property>
|
||||
<widget class="Cevo::ButtonB" name="toggleBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>6</x>
|
||||
<y>6</y>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonB" name="closeBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>369</x>
|
||||
<y>6</y>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonC" name="scrollUpBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>381</x>
|
||||
<y>278</y>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonC" name="scrollDownBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>381</x>
|
||||
<y>290</y>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::EOTButton" name="contactBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>45</y>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonC" name="tellAIBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>24</x>
|
||||
<y>450</y>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Cevo::ButtonB</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Cevo/CevoButtonB.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Cevo::ButtonC</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Cevo/CevoButtonC.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Cevo::EOTButton</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Cevo/CevoEOTButton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
</ui>
|
||||
@@ -28,11 +28,40 @@
|
||||
|
||||
#include "Term.h"
|
||||
|
||||
#include "Global.h"
|
||||
#include "Tribes.h"
|
||||
|
||||
namespace Cevo {
|
||||
namespace Term {
|
||||
|
||||
PersistentData *myData = nullptr;
|
||||
Dpi::Bitmap *smallImp = nullptr;
|
||||
ClientTools::SaveOptions optionChecked = 0;
|
||||
bool supervising = false;
|
||||
std::array<DipMemEntry, nPl> dipMem{};
|
||||
std::function<int(int)> mainScreenDipCall = [](int) { return eInvalid; };
|
||||
std::function<bool(int, const QString &)> mainScreenContactRefused = [](int, const QString &) { return false; };
|
||||
|
||||
int roughCredibility(int credibility)
|
||||
{
|
||||
if (credibility <= 69)
|
||||
return 0;
|
||||
if (credibility <= 89)
|
||||
return 1;
|
||||
if (credibility <= 99)
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
QString turnToString(int turn)
|
||||
{
|
||||
if (!generateNames)
|
||||
return QString::number(turn);
|
||||
const int year = turnToYear(turn);
|
||||
// Phrases['BC']/['AD'] (StringTables.pas) aren't ported; disclosed
|
||||
// plain-English fallback format.
|
||||
return year < 0 ? QStringLiteral("%1 BC").arg(-year) : QStringLiteral("AD %1").arg(year);
|
||||
}
|
||||
|
||||
void impImage(Dpi::Canvas &canvas, int x, int y, int iix, int government, bool isControl)
|
||||
{
|
||||
@@ -46,5 +75,29 @@ void impImage(Dpi::Canvas &canvas, int x, int y, int iix, int government, bool i
|
||||
(iix + SystemIconLines * 7) / 7 * ySizeBig, isControl);
|
||||
}
|
||||
|
||||
void chooseModelPicture(int p, int mix, int code, int hash, int turn, bool forceNew, bool final)
|
||||
{
|
||||
Tribes::ModelPictureInfo picture;
|
||||
picture.trix = p;
|
||||
picture.mix = mix;
|
||||
picture.hash = hash;
|
||||
const bool isNew = Tribes::tribe[static_cast<std::size_t>(p)]->chooseModelPicture(picture, code, turn, forceNew);
|
||||
if (final) {
|
||||
Tribes::tribe[static_cast<std::size_t>(p)]->setModelPicture(picture, isNew);
|
||||
} else {
|
||||
Tribes::ModelPicture &mp = Tribes::tribe[static_cast<std::size_t>(p)]->modelPictureAt(mix);
|
||||
mp.hGr = loadGraphicSet(picture.grName);
|
||||
mp.pix = picture.pix;
|
||||
}
|
||||
}
|
||||
|
||||
void initMyModel(int mix, bool final)
|
||||
{
|
||||
TModelInfo mi{};
|
||||
MakeModelInfo(ClientTools::me, mix, ClientTools::myModel[mix], mi);
|
||||
chooseModelPicture(ClientTools::me, mix, Tribes::modelCode(mi), ClientTools::modelHash(mi),
|
||||
ClientTools::myRO->Turn, false, final);
|
||||
}
|
||||
|
||||
} // namespace Term
|
||||
} // namespace Cevo
|
||||
@@ -32,7 +32,10 @@
|
||||
#include "Cevo/Protocol.h"
|
||||
#include "ClientTools.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
|
||||
namespace Cevo {
|
||||
namespace Term {
|
||||
@@ -80,5 +83,45 @@ extern Dpi::Bitmap *smallImp;
|
||||
// from bigImp, substituting the age-specific palace graphic for imPalace.
|
||||
void impImage(Dpi::Canvas &canvas, int x, int y, int iix, int government = -1, bool isControl = false);
|
||||
|
||||
// Term.pas's `OptionChecked: TSaveOptions;` (user-configurable UI options).
|
||||
extern ClientTools::SaveOptions optionChecked;
|
||||
// Term.pas's `Supervising: Boolean;` (true when controlling player 0 is
|
||||
// just observing rather than playing a nation).
|
||||
extern bool supervising;
|
||||
|
||||
// Term.pas's `TDipMem` (per-nation negotiation session memory) - only the
|
||||
// one field (`pContact`) anything needs so far.
|
||||
struct DipMemEntry {
|
||||
int pContact = -1;
|
||||
};
|
||||
extern std::array<DipMemEntry, nPl> dipMem;
|
||||
|
||||
// Term.pas's RoughCredibility(): buckets a 0..100 credibility value into a
|
||||
// 4-level rating (0..3) for display.
|
||||
int roughCredibility(int credibility);
|
||||
|
||||
// ScreenTools.pas's TurnToString(): turnToYear() formatted as "<n> BC"/"AD
|
||||
// <n>" (or the plain turn number if `generateNames` is off). Lives here
|
||||
// rather than in the widget-layer CevoScreenTools.h since it needs
|
||||
// Global::generateNames (a game-layer symbol widget/ mustn't depend on).
|
||||
QString turnToString(int turn);
|
||||
|
||||
// Term.pas's `MainScreen: TMainScreen` instance isn't ported; these mirror
|
||||
// its DipCall()/ContactRefused() methods as injection points other leaf
|
||||
// dialogs can call into once Term.pas/Nego.pas exist. Default to safe
|
||||
// no-ops (DipCall "not executed", ContactRefused "not refused") so callers
|
||||
// relying on them just see "nothing happened" rather than crashing.
|
||||
extern std::function<int(int command)> mainScreenDipCall;
|
||||
extern std::function<bool(int p, const QString &item)> mainScreenContactRefused;
|
||||
|
||||
// Term.pas's ChooseModelPicture()/InitMyModel(): assigns a visual "picture"
|
||||
// to a developed/enemy unit model. Simplified - always takes the
|
||||
// "non-original tribe" path (dispatches straight through
|
||||
// Tribe::setModelPicture()) since the network cSet*ModelPicture command
|
||||
// plumbing isn't ported, and the mkSlaves (Code==74) special case isn't
|
||||
// handled either (narrow edge case, not reached by anything ported so far).
|
||||
void chooseModelPicture(int p, int mix, int code, int hash, int turn, bool forceNew, bool final);
|
||||
void initMyModel(int mix, bool final);
|
||||
|
||||
} // namespace Term
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user