summaryrefslogtreecommitdiff
path: root/lyt/picture.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2010-10-14 20:17:20 +0200
committerTreeki <treeki@gmail.com>2010-10-14 20:17:20 +0200
commitebcc95da4c26369511caa90d89c5ed06e1e4853a (patch)
tree6ed445f0204a6e6615088d135c4b29c4309077a4 /lyt/picture.cpp
parentfdf8cfec2b795393d7ee901abaf747575067068b (diff)
downloadLayoutStudio-ebcc95da4c26369511caa90d89c5ed06e1e4853a.tar.gz
LayoutStudio-ebcc95da4c26369511caa90d89c5ed06e1e4853a.zip
brlyt packing added, plus some changes in the existing API (mostly for const correctness). brlyt writing may still need some testing (especially for the material structs)
Diffstat (limited to '')
-rw-r--r--lyt/picture.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/lyt/picture.cpp b/lyt/picture.cpp
index f00027b..8cd5f1f 100644
--- a/lyt/picture.cpp
+++ b/lyt/picture.cpp
@@ -24,7 +24,12 @@ LYTPicture::LYTPicture(LYTLayout &layout) : LYTPane(layout) {
}
-void LYTPicture::dumpToDebug(bool showHeading) {
+Magic LYTPicture::magic() const {
+ return Magic('pic1');
+}
+
+
+void LYTPicture::dumpToDebug(bool showHeading) const {
if (showHeading)
qDebug() << "LYTPicture" << name << "@" << (void*)this;
@@ -43,19 +48,19 @@ void LYTPicture::dumpToDebug(bool showHeading) {
-void LYTPicture::writeToDataStream(QDataStream &out) {
+void LYTPicture::writeToDataStream(QDataStream &out) const {
LYTPane::writeToDataStream(out);
for (int i = 0; i < 4; i++)
WriteRGBA8Color(vtxColours[i], out);
// calculate the material number
- int materialNum = m_layout.materials.keys().indexOf(materialName);
+ int materialNum = m_layout.materials.getIndexOfName(materialName);
out << (quint16)materialNum;
// write texcoords
out << (quint8)texCoords.count();
- out.skipRawData(1); // padding
+ WritePadding(1, out);
foreach (LYTTexCoords texCoord, texCoords) {
for (int i = 0; i < 4; i++)
@@ -74,7 +79,7 @@ void LYTPicture::readFromDataStream(QDataStream &in) {
quint16 materialNum;
in >> (quint16&)materialNum;
- materialName = m_layout.materials.keys().at(materialNum);
+ materialName = m_layout.materials.getNameOfIndex(materialNum);
// read texcoords
quint8 texCoordNum;
@@ -83,8 +88,8 @@ void LYTPicture::readFromDataStream(QDataStream &in) {
texCoords.resize(texCoordNum);
- foreach (LYTTexCoords texCoord, texCoords) {
- for (int i = 0; i < 4; i++)
- ReadPointF(in, texCoord.coord[i]);
+ for (int i = 0; i < texCoordNum; i++) {
+ for (int j = 0; j < 4; j++)
+ ReadPointF(in, texCoords[i].coord[j]);
}
}