added citytypes and terms stub
This commit is contained in:
1 parent
371b18bd34
commit
e71c06ee31
6 files changed
+645
No files matched your search
@@ -119,6 +119,9 @@ set(PROJECT_SOURCES
|
|||||||
game/localplayer/KeyBindings.h
|
game/localplayer/KeyBindings.h
|
||||||
game/localplayer/ClientTools.cpp
|
game/localplayer/ClientTools.cpp
|
||||||
game/localplayer/ClientTools.h
|
game/localplayer/ClientTools.h
|
||||||
|
game/localplayer/CityType.cpp
|
||||||
|
game/localplayer/CityType.h
|
||||||
|
game/localplayer/CityType.ui
|
||||||
game/localplayer/Diagram.cpp
|
game/localplayer/Diagram.cpp
|
||||||
game/localplayer/Diagram.h
|
game/localplayer/Diagram.h
|
||||||
game/localplayer/Diagram.ui
|
game/localplayer/Diagram.ui
|
||||||
@@ -126,6 +129,8 @@ set(PROJECT_SOURCES
|
|||||||
game/localplayer/Diplomacy.h
|
game/localplayer/Diplomacy.h
|
||||||
game/localplayer/IsoEngine.cpp
|
game/localplayer/IsoEngine.cpp
|
||||||
game/localplayer/IsoEngine.h
|
game/localplayer/IsoEngine.h
|
||||||
|
game/localplayer/Term.cpp
|
||||||
|
game/localplayer/Term.h
|
||||||
game/localplayer/Tribes.cpp
|
game/localplayer/Tribes.cpp
|
||||||
game/localplayer/Tribes.h
|
game/localplayer/Tribes.h
|
||||||
${TS_FILES}
|
${TS_FILES}
|
||||||
|
|||||||
@@ -0,0 +1,356 @@
|
|||||||
|
// 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 "CityType.h"
|
||||||
|
#include "ui_CityType.h"
|
||||||
|
|
||||||
|
#include "Cevo/CevoScreenTools.h"
|
||||||
|
#include "Cevo/CevoTexture.h"
|
||||||
|
#include "ClientTools.h"
|
||||||
|
#include "Term.h"
|
||||||
|
|
||||||
|
#include <QHash>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
namespace CityType {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Phrases (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_CITYTYPES"), QStringLiteral("City Types")},
|
||||||
|
{QStringLiteral("BTN_DELETE"), QStringLiteral("Delete")},
|
||||||
|
{QStringLiteral("BUILDORDER"), QStringLiteral("Build order")},
|
||||||
|
{QStringLiteral("BUILDREST"), QStringLiteral("Remaining improvements")},
|
||||||
|
};
|
||||||
|
const auto it = table.constFind(key);
|
||||||
|
return it != table.constEnd() ? it.value() : key;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString phraseCityType(int ctype)
|
||||||
|
{
|
||||||
|
static const QHash<int, QString> table = {
|
||||||
|
{0, QStringLiteral("Type A")}, {1, QStringLiteral("Type B")},
|
||||||
|
{2, QStringLiteral("Type C")}, {3, QStringLiteral("Type D")},
|
||||||
|
};
|
||||||
|
const auto it = table.constFind(ctype);
|
||||||
|
return it != table.constEnd() ? it.value() : QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString phraseImprovement(int iix)
|
||||||
|
{
|
||||||
|
// Imp[]'s display names (StringTables.pas) aren't ported.
|
||||||
|
return QStringLiteral("Improvement #%1").arg(iix);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr int xList = 7;
|
||||||
|
constexpr int yList = 0;
|
||||||
|
constexpr int nListRow = 4;
|
||||||
|
constexpr int nListCol = 10;
|
||||||
|
constexpr int xPool = 7;
|
||||||
|
constexpr int yPool = 220;
|
||||||
|
constexpr int nPoolRow = 4;
|
||||||
|
constexpr int nPoolCol = 10;
|
||||||
|
constexpr int xSwitch = 7;
|
||||||
|
constexpr int ySwitch = 150;
|
||||||
|
constexpr int xView = 226;
|
||||||
|
constexpr int yView = 130;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
CityTypeDlg::CityTypeDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::CityTypeDlg)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->closeBtn->setButtonIndex(0);
|
||||||
|
ui->deleteBtn->setButtonIndex(21);
|
||||||
|
|
||||||
|
captionRight = ui->closeBtn->x();
|
||||||
|
initButtons();
|
||||||
|
helpContext = QStringLiteral("MACRO");
|
||||||
|
setWindowTitle(phrase(QStringLiteral("TITLE_CITYTYPES")));
|
||||||
|
ui->deleteBtn->setToolTip(phrase(QStringLiteral("BTN_DELETE")));
|
||||||
|
|
||||||
|
ui->closeBtn->onClick = [this] { close(); };
|
||||||
|
ui->deleteBtn->onClick = [this] {
|
||||||
|
Term::myData->impOrder[static_cast<std::size_t>(ctype)].fill(-1);
|
||||||
|
listed.fill(false);
|
||||||
|
changed = true;
|
||||||
|
smartUpdateContent();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
CityTypeDlg::~CityTypeDlg()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::showNewContent(WindowMode newMode)
|
||||||
|
{
|
||||||
|
BufferedDrawDlg::showNewContent(newMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::loadType(int newType)
|
||||||
|
{
|
||||||
|
ctype = newType;
|
||||||
|
listed.fill(false);
|
||||||
|
int i = 0;
|
||||||
|
while (Term::myData->impOrder[static_cast<std::size_t>(ctype)][static_cast<std::size_t>(i)] >= 0) {
|
||||||
|
listed[static_cast<std::size_t>(Term::myData->impOrder[static_cast<std::size_t>(ctype)][static_cast<std::size_t>(i)])] = true;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
changed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::saveType()
|
||||||
|
{
|
||||||
|
if (!changed)
|
||||||
|
return;
|
||||||
|
for (int cix = 0; cix < ClientTools::myRO->nCity; ++cix)
|
||||||
|
if (ClientTools::myCity[cix].Loc >= 0 && (ClientTools::myCity[cix].Status & 7) == ctype + 1)
|
||||||
|
ClientTools::autoBuild(cix, Term::myData->impOrder[static_cast<std::size_t>(ctype)]);
|
||||||
|
changed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
FramedDlg::showEvent(event);
|
||||||
|
loadType(0);
|
||||||
|
dragiix = -1;
|
||||||
|
offscreenPaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
saveType();
|
||||||
|
FramedDlg::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
FramedDlg::resizeEvent(event);
|
||||||
|
ui->closeBtn->move(width() - 38, ui->closeBtn->y());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::vpaint(Dpi::Canvas &canvas)
|
||||||
|
{
|
||||||
|
FramedDlg::vpaint(canvas);
|
||||||
|
if (!MainTexture)
|
||||||
|
return;
|
||||||
|
btnFrame(canvas, ui->deleteBtn->geometry(), *MainTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::offscreenPaint()
|
||||||
|
{
|
||||||
|
FramedDlg::offscreenPaint();
|
||||||
|
if (!MainTexture || !Term::myData)
|
||||||
|
return;
|
||||||
|
Dpi::Canvas &canvas = offscreen.canvas();
|
||||||
|
canvas.begin();
|
||||||
|
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Small)]);
|
||||||
|
fillOffscreen(xList - 7, yList, 42 * nListCol + 14, 32 * nListRow);
|
||||||
|
fillOffscreen(xPool - 7, yPool, 42 * nPoolCol + 14, 32 * nPoolRow);
|
||||||
|
fillOffscreen(0, yList + 32 * nListRow, 42 * nPoolCol + 14, yPool - yList - 32 * nListRow);
|
||||||
|
|
||||||
|
frame(canvas, 0, yList + 32 * nListRow, innerWidth - 255, yPool - 23, MainTexture->colorBevelLight,
|
||||||
|
MainTexture->colorBevelShade);
|
||||||
|
frame(canvas, innerWidth - 254, yList + 32 * nListRow, innerWidth - 89, yPool - 23, MainTexture->colorBevelLight,
|
||||||
|
MainTexture->colorBevelShade);
|
||||||
|
frame(canvas, innerWidth - 88, yList + 32 * nListRow, innerWidth - 1, yPool - 23, MainTexture->colorBevelLight,
|
||||||
|
MainTexture->colorBevelShade);
|
||||||
|
frame(canvas, 0, yPool - 22, innerWidth - 1, yPool - 1, MainTexture->colorBevelLight,
|
||||||
|
MainTexture->colorBevelShade);
|
||||||
|
|
||||||
|
for (int i = 0; i < Term::nCityType; ++i) {
|
||||||
|
rframe(canvas, xSwitch + i * 42, ySwitch, xSwitch + 39 + i * 42, ySwitch + 23, MainTexture->colorBevelShade,
|
||||||
|
MainTexture->colorBevelLight);
|
||||||
|
if (i == ctype)
|
||||||
|
frame(canvas, xSwitch + 1 + i * 42, ySwitch + 1, xSwitch + 38 + i * 42, ySwitch + 22,
|
||||||
|
MainTexture->colorBevelShade, MainTexture->colorBevelLight);
|
||||||
|
else
|
||||||
|
frame(canvas, xSwitch + 1 + i * 42, ySwitch + 1, xSwitch + 38 + i * 42, ySwitch + 22,
|
||||||
|
MainTexture->colorBevelLight, MainTexture->colorBevelShade);
|
||||||
|
if (Term::smallImp)
|
||||||
|
bitBltBitmap(offscreen, xSwitch + 2 + i * 42, ySwitch + 2, Term::xSizeSmall, Term::ySizeSmall,
|
||||||
|
*Term::smallImp, (i + 3) * Term::xSizeSmall, 0);
|
||||||
|
}
|
||||||
|
risedTextOut(canvas, 8, yList + 32 * nListRow + 2, phrase(QStringLiteral("BUILDORDER")));
|
||||||
|
risedTextOut(canvas, 8, ySwitch + 26, phraseCityType(ctype));
|
||||||
|
const QString buildRest = phrase(QStringLiteral("BUILDREST"));
|
||||||
|
risedTextOut(canvas, (innerWidth - biColorTextWidth(canvas, buildRest)) / 2, yList + 72 + 32 * nListRow,
|
||||||
|
buildRest);
|
||||||
|
|
||||||
|
for (int i = 1; i < nListRow; ++i)
|
||||||
|
dLine(canvas, xList - 5, xList + 4 + 42 * nListCol, yList - 1 + 32 * i, MainTexture->colorBevelLight,
|
||||||
|
MainTexture->colorBevelShade);
|
||||||
|
for (int i = 0; i < nListCol * nListRow; ++i) {
|
||||||
|
const QString s = QString::number(i + 1);
|
||||||
|
canvas.font().setColor(MainTexture->colorTextLight);
|
||||||
|
canvas.textOut(xList + 20 + i % nListCol * 42 - canvas.textWidth(s) / 2,
|
||||||
|
yList + 15 + i / nListCol * 32 - canvas.textHeight(s) / 2, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &order = Term::myData->impOrder[static_cast<std::size_t>(ctype)];
|
||||||
|
int i = 0;
|
||||||
|
while (order[static_cast<std::size_t>(i)] >= 0) {
|
||||||
|
rframe(canvas, xList + 20 - Term::xSizeSmall / 2 + i % nListCol * 42,
|
||||||
|
yList + 15 - Term::ySizeSmall / 2 + i / nListCol * 32,
|
||||||
|
xList + 21 + Term::xSizeSmall / 2 + i % nListCol * 42,
|
||||||
|
yList + 16 + Term::ySizeSmall / 2 + i / nListCol * 32, MainTexture->colorBevelLight,
|
||||||
|
MainTexture->colorBevelShade);
|
||||||
|
if (Term::smallImp)
|
||||||
|
bitBltBitmap(offscreen, xList + 21 - Term::xSizeSmall / 2 + i % nListCol * 42,
|
||||||
|
yList + 16 - Term::ySizeSmall / 2 + i / nListCol * 32, Term::xSizeSmall, Term::ySizeSmall,
|
||||||
|
*Term::smallImp, order[static_cast<std::size_t>(i)] % 7 * Term::xSizeSmall,
|
||||||
|
(order[static_cast<std::size_t>(i)] + Term::SystemIconLines * 7) / 7 * Term::ySizeSmall);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
nPool = 0;
|
||||||
|
for (int iix = nWonder; iix < nImp; ++iix) {
|
||||||
|
if (!listed[static_cast<std::size_t>(iix)] && Imp[iix].Kind == ikCommon && iix != imTrGoods &&
|
||||||
|
Imp[iix].Preq != preNA &&
|
||||||
|
(Imp[iix].Preq == preNone || ClientTools::myRO->Tech[Imp[iix].Preq] >= tsApplicable)) {
|
||||||
|
poolIix[static_cast<std::size_t>(nPool)] = iix;
|
||||||
|
rframe(canvas, xPool + 20 - Term::xSizeSmall / 2 + nPool % nPoolCol * 42,
|
||||||
|
yPool + 15 - Term::ySizeSmall / 2 + nPool / nPoolCol * 32,
|
||||||
|
xPool + 21 + Term::xSizeSmall / 2 + nPool % nPoolCol * 42,
|
||||||
|
yPool + 16 + Term::ySizeSmall / 2 + nPool / nPoolCol * 32, MainTexture->colorBevelLight,
|
||||||
|
MainTexture->colorBevelShade);
|
||||||
|
if (Term::smallImp)
|
||||||
|
bitBltBitmap(offscreen, xPool + 21 - Term::xSizeSmall / 2 + nPool % nPoolCol * 42,
|
||||||
|
yPool + 16 - Term::ySizeSmall / 2 + nPool / nPoolCol * 32, Term::xSizeSmall,
|
||||||
|
Term::ySizeSmall, *Term::smallImp, iix % 7 * Term::xSizeSmall,
|
||||||
|
(iix + Term::SystemIconLines * 7) / 7 * Term::ySizeSmall);
|
||||||
|
++nPool;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->deleteBtn->setVisible(order[0] >= 0);
|
||||||
|
|
||||||
|
if (dragiix >= 0) {
|
||||||
|
Term::impImage(canvas, xView + 9, yView + 5, dragiix);
|
||||||
|
const QString s = phraseImprovement(dragiix);
|
||||||
|
risedTextOut(canvas, xView + 36 - biColorTextWidth(canvas, s) / 2, ySwitch + 26, s);
|
||||||
|
}
|
||||||
|
canvas.end();
|
||||||
|
markUsedOffscreen(innerWidth, innerHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
FramedDlg::mousePressEvent(event);
|
||||||
|
if (!Term::myData)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const int x = event->pos().x() - SideFrame;
|
||||||
|
const int y = event->pos().y() - WideFrame;
|
||||||
|
auto &order = Term::myData->impOrder[static_cast<std::size_t>(ctype)];
|
||||||
|
|
||||||
|
int i = (x - xList) / 42 + (y - yList) / 32 * nListCol;
|
||||||
|
if (i >= 0 && i < nImp && order[static_cast<std::size_t>(i)] >= 0 && x > xList + 2 + i % nListCol * 42 &&
|
||||||
|
y > yList + 5 + i / nListCol * 32 && x < xList + 3 + 36 + i % nListCol * 42 &&
|
||||||
|
y < yList + 6 + 20 + i / nListCol * 32) {
|
||||||
|
if (event->modifiers() & Qt::ShiftModifier) {
|
||||||
|
// TODO: HelpDlg isn't ported yet - shift-click-for-help is a
|
||||||
|
// no-op for now (Term.pas's MainScreen.HelpDlg.ShowNewContent).
|
||||||
|
} else {
|
||||||
|
dragiix = order[static_cast<std::size_t>(i)];
|
||||||
|
smartUpdateContent();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = (x - xPool) / 42 + (y - yPool) / 32 * nPoolCol;
|
||||||
|
if (i >= 0 && i < nPool && x > xPool + 2 + i % nPoolCol * 42 && y > yPool + 5 + i / nPoolCol * 32 &&
|
||||||
|
x < xPool + 3 + 36 + i % nPoolCol * 42 && y < yPool + 6 + 20 + i / nPoolCol * 32) {
|
||||||
|
if (event->modifiers() & Qt::ShiftModifier) {
|
||||||
|
// TODO: same HelpDlg deferral as above.
|
||||||
|
} else {
|
||||||
|
dragiix = poolIix[static_cast<std::size_t>(i)];
|
||||||
|
smartUpdateContent();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = (x - xSwitch) / 42;
|
||||||
|
if (i >= 0 && i < Term::nCityType && x > xSwitch + 2 + i * 42 && x < xSwitch + 3 + 36 + i * 42 &&
|
||||||
|
y >= ySwitch + 2 && y < ySwitch + 22) {
|
||||||
|
saveType();
|
||||||
|
loadType(i);
|
||||||
|
smartUpdateContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CityTypeDlg::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
FramedDlg::mouseReleaseEvent(event);
|
||||||
|
if (!Term::myData)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const int x = event->pos().x() - SideFrame;
|
||||||
|
const int y = event->pos().y() - WideFrame;
|
||||||
|
auto &order = Term::myData->impOrder[static_cast<std::size_t>(ctype)];
|
||||||
|
|
||||||
|
auto unList = [&](int iix) {
|
||||||
|
int i = 0;
|
||||||
|
while (order[static_cast<std::size_t>(i)] >= 0 && order[static_cast<std::size_t>(i)] != iix)
|
||||||
|
++i;
|
||||||
|
Q_ASSERT(order[static_cast<std::size_t>(i)] == iix);
|
||||||
|
for (; i < nImp - 1; ++i)
|
||||||
|
order[static_cast<std::size_t>(i)] = order[static_cast<std::size_t>(i + 1)];
|
||||||
|
listed[static_cast<std::size_t>(iix)] = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (dragiix >= 0) {
|
||||||
|
if (x >= xList && x < xList + nListCol * 42 && y >= yList && y < yList + nListRow * 32) {
|
||||||
|
if (listed[static_cast<std::size_t>(dragiix)])
|
||||||
|
unList(dragiix);
|
||||||
|
int i = (x - xList) / 42 + (y - yList) / 32 * nListCol;
|
||||||
|
while (i > 0 && order[static_cast<std::size_t>(i - 1)] < 0)
|
||||||
|
--i;
|
||||||
|
for (int j = nImp - 2; j >= i; --j)
|
||||||
|
order[static_cast<std::size_t>(j + 1)] = order[static_cast<std::size_t>(j)];
|
||||||
|
order[static_cast<std::size_t>(i)] = dragiix;
|
||||||
|
listed[static_cast<std::size_t>(dragiix)] = true;
|
||||||
|
changed = true;
|
||||||
|
} else if (listed[static_cast<std::size_t>(dragiix)] && x >= xPool && x < xPool + nPoolCol * 42 &&
|
||||||
|
y >= yPool && y < yPool + nPoolRow * 32) {
|
||||||
|
unList(dragiix);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
dragiix = -1;
|
||||||
|
smartUpdateContent();
|
||||||
|
}
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CityType
|
||||||
|
} // namespace Cevo
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
// 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 CityTypeDlg;
|
||||||
|
}
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
namespace CityType {
|
||||||
|
|
||||||
|
// TCityTypeDlg equivalent: drag-and-drop city build-order editor. UI built
|
||||||
|
// from CityType.ui (adapted from the original's CityType.lfm).
|
||||||
|
class CityTypeDlg : public FramedDlg {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CityTypeDlg(QWidget *parent = nullptr);
|
||||||
|
~CityTypeDlg() override;
|
||||||
|
|
||||||
|
void showNewContent(WindowMode newMode);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void offscreenPaint() override;
|
||||||
|
void vpaint(Dpi::Canvas &canvas) override;
|
||||||
|
void showEvent(QShowEvent *event) override;
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void loadType(int newType);
|
||||||
|
void saveType();
|
||||||
|
|
||||||
|
int nPool = 0;
|
||||||
|
int dragiix = -1;
|
||||||
|
int ctype = 0;
|
||||||
|
std::array<int, nImp> poolIix{};
|
||||||
|
std::array<bool, nImp + 1> listed{}; // set of 0..nImp
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
Ui::CityTypeDlg *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CityType
|
||||||
|
} // namespace Cevo
|
||||||
Vendored
+71
@@ -0,0 +1,71 @@
|
|||||||
|
<?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>CityTypeDlg</class>
|
||||||
|
<widget class="QWidget" name="CityTypeDlg">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>452</width>
|
||||||
|
<height>395</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>C-evo</string>
|
||||||
|
</property>
|
||||||
|
<widget class="Cevo::ButtonB" name="closeBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>414</x>
|
||||||
|
<y>6</y>
|
||||||
|
<width>25</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonB" name="deleteBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>410</x>
|
||||||
|
<y>172</y>
|
||||||
|
<width>25</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>Cevo::ButtonB</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>Cevo/CevoButtonB.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
</ui>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// 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.h"
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
namespace Term {
|
||||||
|
|
||||||
|
PersistentData *myData = nullptr;
|
||||||
|
Dpi::Bitmap *smallImp = nullptr;
|
||||||
|
|
||||||
|
void impImage(Dpi::Canvas &canvas, int x, int y, int iix, int government, bool isControl)
|
||||||
|
{
|
||||||
|
if (government < 0)
|
||||||
|
government = ClientTools::myRO->Government;
|
||||||
|
if (iix == imPalace && government != gAnarchy)
|
||||||
|
iix = government - 8;
|
||||||
|
if (!bigImp)
|
||||||
|
return;
|
||||||
|
frameImage(canvas, *bigImp, x, y, xSizeBig, ySizeBig, (iix + SystemIconLines * 7) % 7 * xSizeBig,
|
||||||
|
(iix + SystemIconLines * 7) / 7 * ySizeBig, isControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Term
|
||||||
|
} // namespace Cevo
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
// 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/CevoScreenTools.h"
|
||||||
|
#include "Cevo/Protocol.h"
|
||||||
|
#include "ClientTools.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
namespace Term {
|
||||||
|
|
||||||
|
// PORT STATUS: Term.pas itself (~7500 lines, the main game screen) is NOT
|
||||||
|
// ported - it needs ~14 other LocalPlayer dialogs that don't exist yet
|
||||||
|
// (see /memories/repo/cevo-evo-game.md for the port order). This file only
|
||||||
|
// pre-seeds the handful of Term.pas globals/constants/helpers that the
|
||||||
|
// LEAF dialogs (CityType, ...) need from it; real Term.pas content gets
|
||||||
|
// added into this same namespace/file set once its turn comes.
|
||||||
|
|
||||||
|
constexpr int nCityType = 4;
|
||||||
|
// icons.bmp properties: lines of system icons before improvements start.
|
||||||
|
constexpr int xSizeSmall = 36;
|
||||||
|
constexpr int ySizeSmall = 20;
|
||||||
|
constexpr int SystemIconLines = 2;
|
||||||
|
|
||||||
|
// Term.pas's `TPersistentData` (per-player persisted client-side settings,
|
||||||
|
// e.g. city build-order preferences) - only the fields some leaf dialog
|
||||||
|
// needs are ported so far; add more as needed.
|
||||||
|
struct PersistentData {
|
||||||
|
int farTech = 0;
|
||||||
|
int toldAge = 0;
|
||||||
|
int toldModels = 0;
|
||||||
|
int toldAlive = 0;
|
||||||
|
int toldContact = 0;
|
||||||
|
int toldOwnCredibility = 0;
|
||||||
|
int coldWarStart = 0;
|
||||||
|
int peaceEvaHappened = 0;
|
||||||
|
ClientTools::TEnhancementJobs enhancementJobs{};
|
||||||
|
std::array<ClientTools::TImpOrder, nCityType> impOrder{};
|
||||||
|
std::array<TWonderInfo, nWonder> toldWonders{};
|
||||||
|
std::array<std::int8_t, nAdv> toldTech{};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Term.pas's `MyData: ^TPersistentData;` - null until a real game/turn is
|
||||||
|
// active (set by Term.pas's InitTurn(), not yet ported).
|
||||||
|
extern PersistentData *myData;
|
||||||
|
|
||||||
|
// Term.pas's `SmallImp: TBitmap;` (icons.bmp sprite sheet, small size) -
|
||||||
|
// populated by Term.pas's asset loading, not yet ported.
|
||||||
|
extern Dpi::Bitmap *smallImp;
|
||||||
|
|
||||||
|
// Equivalent of Term.pas's ImpImage(): draws an improvement/wonder icon
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
} // namespace Term
|
||||||
|
} // namespace Cevo
|
||||||
Reference in new issue
Block a user