added select and its deps
This commit is contained in:
1 parent
a60c60186b
commit
d65065644e
9 files changed
+2057
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user