added select and its deps
This commit is contained in:
1 parent
a60c60186b
commit
d65065644e
9 files changed
+2057
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,184 @@
|
||||
// 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/CevoPVScrollBar.h"
|
||||
#include "Cevo/Protocol.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <array>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class ListDlg;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Cevo {
|
||||
namespace Select {
|
||||
|
||||
// TListKind equivalent: which of the 21 flavors of list this dialog
|
||||
// currently renders.
|
||||
enum class ListKind {
|
||||
Project,
|
||||
Advance,
|
||||
FarAdvance,
|
||||
Cities,
|
||||
CityEvents,
|
||||
Models,
|
||||
EnemyModels,
|
||||
AllEnemyModels,
|
||||
Tribe,
|
||||
Science,
|
||||
ShipPart,
|
||||
EnemyShipPart,
|
||||
ChooseTech,
|
||||
ChooseEnemyTech,
|
||||
ChooseModel,
|
||||
ChooseEnemyModel,
|
||||
ChooseCity,
|
||||
ChooseEnemyCity,
|
||||
StealTech,
|
||||
Government,
|
||||
Mission,
|
||||
};
|
||||
|
||||
// TLayerIndex equivalent: kProject splits its lines across up to 3 pages.
|
||||
enum class LayerIndex { Improvements, Wonders, Classes };
|
||||
|
||||
// Select.pas's own const block (also referenced from CityScreen.pas via
|
||||
// `uses Select` as `cpType` - that file ported earlier than this one, so
|
||||
// it got its own `Term::cpType` copy of the same value; both must stay in
|
||||
// sync if this value is ever revisited).
|
||||
constexpr int cpType = 0x10000;
|
||||
constexpr int mixAll = 0x10000;
|
||||
constexpr int adAll = 0x10000;
|
||||
|
||||
// TLine equivalent - a plain value type (no owning-pointer indirection
|
||||
// needed, unlike the original's TObjectList<TLine>; that was only there
|
||||
// because Delphi's TObjectList couldn't hold plain records).
|
||||
struct Line {
|
||||
int code = 0;
|
||||
int model = 0;
|
||||
int modelSortValue = 0;
|
||||
};
|
||||
|
||||
// TLayer equivalent.
|
||||
class Layer {
|
||||
public:
|
||||
explicit Layer(LayerIndex index = LayerIndex::Improvements) : m_index(index) {}
|
||||
|
||||
LayerIndex index() const { return m_index; }
|
||||
std::vector<Line> &lines() { return m_lines; }
|
||||
const std::vector<Line> &lines() const { return m_lines; }
|
||||
|
||||
void addLine(int code, int model = 0, int modelSortValue = 0);
|
||||
void sortModels();
|
||||
void sortCities();
|
||||
void sortTechs();
|
||||
|
||||
int firstShrinkedLine = std::numeric_limits<int>::max();
|
||||
|
||||
private:
|
||||
LayerIndex m_index;
|
||||
std::vector<Line> m_lines;
|
||||
};
|
||||
|
||||
// TListDlg/TModalSelectDlg equivalent: a generic, paged, scrollable list
|
||||
// dialog used for project/tech/city/model/tribe/government/mission
|
||||
// selection and for the city/enemy-model/tech report browsers.
|
||||
class ListDlg : public FramedDlg {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ListDlg(QWidget *parent = nullptr);
|
||||
~ListDlg() override;
|
||||
|
||||
void offscreenPaint() override;
|
||||
void showNewContent(WindowMode newMode, ListKind listKind);
|
||||
void showNewContentCityProject(WindowMode newMode, int cix);
|
||||
void showNewContentMilReport(WindowMode newMode, int player);
|
||||
void ecoChange();
|
||||
void techChange();
|
||||
void addCity();
|
||||
void removeUnit();
|
||||
bool renameCity(int cix);
|
||||
bool renameModel(int mix);
|
||||
// -2: empty, -1: ambiguous, other: the only choice.
|
||||
int onlyChoice(ListKind testKind);
|
||||
|
||||
int result = -1;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
void initLines();
|
||||
void paintLine(Dpi::Canvas &canvas, int l, bool nonText, bool lit, bool toWidget);
|
||||
int getSelectionIndex() const;
|
||||
void setSelectionIndex(int index);
|
||||
void modeBtnClicked(LayerIndex index);
|
||||
void toggleBtnClicked();
|
||||
void playerClicked(int player);
|
||||
|
||||
ListKind kind = ListKind::Mission;
|
||||
int lineDistance = 0;
|
||||
int maxLines = 0;
|
||||
int cixProject = 0;
|
||||
int playerView = 0;
|
||||
int selected = -2;
|
||||
int dispLines = 0;
|
||||
Layer *layer = nullptr;
|
||||
int nColumn = 0;
|
||||
int techNameSpace = 0;
|
||||
int scienceNation = -1;
|
||||
std::array<Layer, 3> layers{Layer(LayerIndex::Improvements), Layer(LayerIndex::Wonders),
|
||||
Layer(LayerIndex::Classes)};
|
||||
std::array<int, nPl> column{};
|
||||
bool closable = false;
|
||||
bool multiPage = false;
|
||||
PVScrollBar *scrollBar = nullptr;
|
||||
QMenu *popup = nullptr;
|
||||
|
||||
Ui::ListDlg *ui;
|
||||
};
|
||||
|
||||
// TModalSelectDlg = TListDlg - same class, used modally for city-project
|
||||
// selection (matches Term::modalSelectDlgShowCityProject's shape already).
|
||||
using ModalSelectDlg = ListDlg;
|
||||
|
||||
} // namespace Select
|
||||
} // namespace Cevo
|
||||
Vendored
+101
@@ -0,0 +1,101 @@
|
||||
<?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>ListDlg</class>
|
||||
<widget class="QWidget" name="ListDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>381</width>
|
||||
<height>262</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>C-evo</string>
|
||||
</property>
|
||||
<widget class="Cevo::ButtonB" name="closeBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>343</x>
|
||||
<y>6</y>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonB" name="layerClassesButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>344</x>
|
||||
<y>224</y>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonB" name="layerWondersButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>312</x>
|
||||
<y>224</y>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonB" name="layerImprovementsButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>224</y>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonB" name="toggleBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>13</x>
|
||||
<y>6</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>
|
||||
@@ -105,6 +105,13 @@ void initMyModel(int mix, bool final)
|
||||
|
||||
int gameMode = 0;
|
||||
int age = 0;
|
||||
std::uint32_t cityRepMask = ~static_cast<std::uint32_t>(chPopIncrease) & ~static_cast<std::uint32_t>(chCaptured) &
|
||||
~static_cast<std::uint32_t>(chNoGrowthWarning);
|
||||
std::array<int, nAdv> advIcon = [] {
|
||||
std::array<int, nAdv> result;
|
||||
result.fill(-1);
|
||||
return result;
|
||||
}();
|
||||
std::array<int, nPl * nMmax> lostArmy{};
|
||||
int nLostArmy = 0;
|
||||
std::function<void()> initAllEnemyModels = [] {};
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <QString>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
|
||||
namespace Cevo {
|
||||
@@ -50,6 +51,11 @@ namespace Term {
|
||||
// added into this same namespace/file set once its turn comes.
|
||||
|
||||
constexpr int nCityType = 4;
|
||||
// Term.pas's own pseudo-advance ids (adjacent to Protocol.pas's adMilitary
|
||||
// = 0x800) used by the tech-selection dialog (Select.pas).
|
||||
constexpr int adNone = 0x801;
|
||||
constexpr int adFar = 0x802;
|
||||
constexpr int adNexus = 0x803;
|
||||
// icons.bmp properties: lines of system icons before improvements start.
|
||||
constexpr int xSizeSmall = 36;
|
||||
constexpr int ySizeSmall = 20;
|
||||
@@ -148,6 +154,19 @@ extern int gameMode;
|
||||
// `clkAge0 + Age`). Stays 0 until Term.pas is ported and updates it.
|
||||
extern int age;
|
||||
|
||||
// Term.pas's `CityRepMask: Cardinal;` (user-configurable "which city
|
||||
// events to report" bitmask, persisted via QSettings in the original -
|
||||
// not wired to settings here yet, just the documented default value).
|
||||
extern std::uint32_t cityRepMask;
|
||||
|
||||
// Term.pas's `AdvIcon: array[0..nAdv-1] of Integer;` (per-advance icon
|
||||
// index into SmallImp/HGrSystem, computed by a Term.pas init routine not
|
||||
// yet ported) - stays -1 ("no icon assigned yet") for every entry until
|
||||
// Term.pas is ported; harmless if read before that (just selects an
|
||||
// arbitrary/wrong icon, not a crash - same "pre-seed stays default" policy
|
||||
// as lostArmy[]/nLostArmy).
|
||||
extern std::array<int, nAdv> advIcon;
|
||||
|
||||
// Term.pas's layout constant (MidPanelHeight - TopBarHeight) div 2; the
|
||||
// two panel-size constants it derives from belong to Term's not-yet-ported
|
||||
// main window layout, so only the resulting fixed value is pre-seeded here.
|
||||
|
||||
@@ -388,6 +388,8 @@ QString Tribe::tPhrase(const QString &item) const
|
||||
{QStringLiteral("FRSTART_NOTREATY"), QStringLiteral("Greetings.")},
|
||||
{QStringLiteral("FRSTART_PEACE"), QStringLiteral("Greetings, friend.")},
|
||||
{QStringLiteral("WONDEROWNER"), QStringLiteral("built by the #A")},
|
||||
{QStringLiteral("GENMODEL"), QStringLiteral("Model #%1")},
|
||||
{QStringLiteral("OWNED"), QStringLiteral("%1 (owned)")},
|
||||
};
|
||||
const auto it = table.constFind(item);
|
||||
return tString(it != table.constEnd() ? it.value() : item);
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace Cevo {
|
||||
namespace UnitStat {
|
||||
|
||||
std::function<void(WindowMode, int)> showNewContentOwnModel = [](WindowMode, int) {};
|
||||
std::function<void(WindowMode, int)> showNewContentEnemyModel = [](WindowMode, int) {};
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -177,6 +178,9 @@ UnitStatDlg::UnitStatDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::
|
||||
ui->helpBtn->onClick = [this] { Help::showNewContent(WindowMode::Persistent, Help::LinkCategory::Model, 0); };
|
||||
|
||||
UnitStat::showNewContentOwnModel = [this](WindowMode newMode, int mix) { this->showNewContentOwnModel(newMode, mix); };
|
||||
UnitStat::showNewContentEnemyModel = [this](WindowMode newMode, int emix) {
|
||||
this->showNewContentEnemyModel(newMode, emix);
|
||||
};
|
||||
|
||||
onShow = [this] {
|
||||
if (kind == UnitStatDialogKind::EnemyUnit || kind == UnitStatDialogKind::EnemyCityDefense ||
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace UnitStat {
|
||||
// wired up to a real UnitStatDlg instance's showNewContentOwnModel() once
|
||||
// one exists (Term.pas isn't ported yet).
|
||||
extern std::function<void(WindowMode, int)> showNewContentOwnModel;
|
||||
// Mirrors `MainScreen.UnitStatDlg.ShowNewContent_EnemyModel(NewMode, Emix)`.
|
||||
extern std::function<void(WindowMode, int)> showNewContentEnemyModel;
|
||||
|
||||
enum class UnitStatDialogKind { OwnModel, OwnUnit, EnemyModel, EnemyUnit, EnemyCityDefense, EnemyCity };
|
||||
|
||||
|
||||
Reference in new issue
Block a user