added tribes and keybinding
This commit is contained in:
1 parent
d1074096aa
commit
199cf2479c
7 files changed
+1383
No files matched your search
@@ -0,0 +1,138 @@
|
||||
// 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/Protocol.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace Cevo {
|
||||
|
||||
class GraphicSet;
|
||||
|
||||
namespace Tribes {
|
||||
|
||||
// TCityPicture equivalent.
|
||||
struct CityPicture {
|
||||
int xShield = 0;
|
||||
int yShield = 0;
|
||||
};
|
||||
|
||||
// TModelPicture equivalent.
|
||||
struct ModelPicture {
|
||||
GraphicSet *hGr = nullptr;
|
||||
int pix = 0;
|
||||
int xShield = 0;
|
||||
int yShield = 0;
|
||||
};
|
||||
|
||||
// TModelPictureInfo equivalent.
|
||||
struct ModelPictureInfo {
|
||||
int trix = 0;
|
||||
int mix = 0;
|
||||
int pix = 0;
|
||||
int hash = 0;
|
||||
QString grName;
|
||||
|
||||
// Size this record would take in the (not yet ported) network command
|
||||
// stream: 4 ints + a 1-byte length prefix + the (UTF-8) name bytes.
|
||||
std::uint8_t commandDataSize() const;
|
||||
};
|
||||
|
||||
// TTribe equivalent. Holds a tribe's graphic assets (nation symbol/ruler
|
||||
// face/city sprites), the parsed `.tribe.txt` name-template script, and the
|
||||
// per-model picture assignments made for this game.
|
||||
class Tribe {
|
||||
public:
|
||||
explicit Tribe(const QString &fileName);
|
||||
~Tribe();
|
||||
Tribe(const Tribe &) = delete;
|
||||
Tribe &operator=(const Tribe &) = delete;
|
||||
|
||||
GraphicSet *symHGr = nullptr;
|
||||
int symPix = 0;
|
||||
GraphicSet *faceHGr = nullptr;
|
||||
int facePix = 0;
|
||||
GraphicSet *cHGr = nullptr;
|
||||
int cPix = 0;
|
||||
int cAge = -1;
|
||||
int mixSlaves = -1;
|
||||
QColor color;
|
||||
int numberName = -1;
|
||||
std::array<CityPicture, 4> cityPicture;
|
||||
|
||||
// ModelPicture/ModelName are indexed -1..256 in the original (-1 is the
|
||||
// "building site" picture); use these accessors rather than the raw
|
||||
// (0-based, +1-shifted) backing arrays.
|
||||
ModelPicture &modelPictureAt(int mix) { return m_modelPicture[static_cast<std::size_t>(mix + 1)]; }
|
||||
const ModelPicture &modelPictureAt(int mix) const { return m_modelPicture[static_cast<std::size_t>(mix + 1)]; }
|
||||
QString &modelNameAt(int mix) { return m_modelName[static_cast<std::size_t>(mix + 1)]; }
|
||||
const QString &modelNameAt(int mix) const { return m_modelName[static_cast<std::size_t>(mix + 1)]; }
|
||||
|
||||
QString getCityName(int i) const;
|
||||
void setCityName(int i, const QString &newName);
|
||||
QString tString(QString templateText) const;
|
||||
// Phrases/Phrases2 (StringTables.pas) aren't ported; falls back to a
|
||||
// plain-English template for the one phrase this file needs (city-name
|
||||
// generation past the end of a tribe's scripted name list).
|
||||
QString tPhrase(const QString &item) const;
|
||||
void setModelPicture(const ModelPictureInfo &info, bool isNew);
|
||||
bool chooseModelPicture(ModelPictureInfo &picture, int code, int turn, bool forceNew);
|
||||
void initAge(int age);
|
||||
|
||||
private:
|
||||
int m_cityLine0 = 0;
|
||||
int m_nCityLines = 0;
|
||||
std::array<QString, 26> m_name; // Name['a'..'z']
|
||||
QStringList m_script;
|
||||
std::array<ModelPicture, 258> m_modelPicture;
|
||||
std::array<QString, 258> m_modelName;
|
||||
};
|
||||
|
||||
constexpr int MaxPlayers = nPl;
|
||||
|
||||
extern std::array<std::unique_ptr<Tribe>, MaxPlayers> tribe;
|
||||
extern GraphicSet *hGrStdUnits;
|
||||
|
||||
void init();
|
||||
void done();
|
||||
QString cityName(int founder);
|
||||
int modelCode(const TModelInfo &modelInfo);
|
||||
void findStdModelPicture(int code, int &pix, QString &name);
|
||||
bool getTribeInfo(const QString &fileName, QString &name, QColor &color);
|
||||
void findPosition(GraphicSet *hGr, int x, int y, int xmax, int ymax, QColor mark, int &xp, int &yp);
|
||||
|
||||
} // namespace Tribes
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user