summaryrefslogtreecommitdiff
path: root/lyt/layout.h
blob: 092be44e9a54d189127f7e0d814d30b5ef04db11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*******************************************************************************
  This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio)
  Copyright (c) 2010 Treeki (treeki@gmail.com)

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, version 2.0.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License 2.0 for more details.

  You should have received a copy of the GNU General Public License 2.0
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/

#ifndef LYTLAYOUT_H
#define LYTLAYOUT_H

#include "packagebase.h"
#include "materials/material.h"
#include "materials/materialcontainer.h"
#include "group.h"
#include "pane.h"
#include "textbox.h"
#include "picture.h"
#include "window.h"
#include "bounding.h"
#include "binaryfile.h"
#include "binaryfilesection.h"

#include <QtCore/QStringList>
#include <QtCore/QMap>
#include <QtCore/QDataStream>

class LYTTexMap; // forward declaration so it can be a friend class

class LYTLayout {
public:
	LYTLayout(LYTPackageBase &package);
	LYTLayout(LYTPackageBase &package, QString name);
	~LYTLayout();

	void clear();
	LYTPackageBase &package() const;

	QByteArray pack();

	quint8 flags;

	float width;
	float height;

	LYTMaterialContainer materials;

	LYTPane *rootPane;
	QList<LYTGroup *> groups;



protected:
	LYTPackageBase &m_package;

	// these are private because they are not intended for public use
	// they're only here so that LYTPane's subclasses and a few others can read
	// this info when reading/writing -- hence why they are friend classes
	QStringList m_fontRefs;
	QStringList m_textureRefs;

	bool loadLayoutFromPackage(QString name);

	void readLyt1(LYTBinaryFileSection &section);
	void readTxl1(LYTBinaryFileSection &section);
	void readFnl1(LYTBinaryFileSection &section);
	void readMat1(LYTBinaryFileSection &section);

	LYTPane *createPaneObj(LYTBinaryFileSection &section);

	QStringList generateTextureRefs() const;
	QStringList generateFontRefs() const;

	void writeMat1(LYTBinaryFileSection &section) const;
	void writePane(LYTBinaryFile &file, LYTPane *pane) const;
	void writeGroups(LYTBinaryFile &file) const;

	friend class LYTPane;
	friend class LYTTextBox;
	friend class LYTPicture;
	friend class LYTWindow;
	friend class LYTBounding;
	friend class LYTTexMap;

};

#endif // LYTLAYOUT_H