initial port for Cevo game in C++ (libs)
This commit is contained in:
commit
8436242032
375 files changed
+46282
No files matched your search
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dpi/DpiGraphics.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
|
||||
namespace Cevo {
|
||||
|
||||
class GraphicSet;
|
||||
|
||||
// TGraphicSetItem equivalent: one named sub-rectangle of a GraphicSet's
|
||||
// sprite sheet.
|
||||
class GraphicSetItem {
|
||||
public:
|
||||
QString name;
|
||||
int left = 0;
|
||||
int top = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
GraphicSet *graphicSet = nullptr;
|
||||
|
||||
QRect boundsRect() const { return QRect(left, top, width, height); }
|
||||
void setBoundsRect(const QRect &rect);
|
||||
};
|
||||
|
||||
// TGraphicSet equivalent: a sprite sheet (data) with its transparency mask
|
||||
// (mask), plus a set of named item rectangles. Persisted as XML, though not
|
||||
// in the same node layout as the original (custom WriteString/WriteInteger
|
||||
// helper), so files are not binary-compatible with the original .grs format.
|
||||
class GraphicSet {
|
||||
public:
|
||||
GraphicSet() = default;
|
||||
~GraphicSet();
|
||||
GraphicSet(const GraphicSet &) = delete;
|
||||
GraphicSet &operator=(const GraphicSet &) = delete;
|
||||
|
||||
QString name;
|
||||
Dpi::Bitmap data;
|
||||
Dpi::Bitmap mask;
|
||||
|
||||
// Looks up by index first, falling back to name; nullptr (with a
|
||||
// warning) if neither resolves to an item.
|
||||
GraphicSetItem *item(const QString &itemName) const;
|
||||
GraphicSetItem *searchByName(const QString &itemName) const;
|
||||
GraphicSetItem *addNew(const QString &itemName);
|
||||
const QList<GraphicSetItem *> &items() const { return m_items; }
|
||||
|
||||
void loadFromFile(const QString &fileName);
|
||||
void saveToFile(const QString &fileName) const;
|
||||
|
||||
private:
|
||||
QList<GraphicSetItem *> m_items;
|
||||
};
|
||||
|
||||
constexpr const char *GraphicSetFileRootNode = "GraphicSet";
|
||||
constexpr const char *GraphicSetFileExt = ".grs";
|
||||
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user