ff7tk  1.2.0.13
Work with Final Fantasy 7 game data
WindowBinFile.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009 - 2022 Arzel Jérôme <myst6re@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #pragma once
5 
6 #include <QtCore>
7 #include <TimFile>
8 #include <ff7tkformats_export.h>
9 
10 inline quint8 LEFT_PADD(quint8 w) {return (w >> 5);}
11 inline quint8 CHARACTER_WIDTH(quint8 w) {return(w & 0x1F);}
12 
13 class FF7TKFORMATS_EXPORT WindowBinFile
14 {
15 public:
16  enum FontColor {
17  DarkGrey=0,
18  DarkBlue=1,
19  Red=2,
20  Purple=3,
21  Green=4,
22  Cyan=5,
23  Yellow=6,
24  White=7
25  };
26 
27  WindowBinFile();
28  void clear();
29  bool open(const QString &path);
30  bool open(const QByteArray &data);
31  bool save(QByteArray &data) const;
32  bool isValid() const;
33  bool isModified() const;
34  bool isJp() const;
35  void setModified(bool modified);
36  int charCount() const;
37  int tableCount() const;
38  static int tableSize(quint8 table);
39  const QImage &image(FontColor color);
40  QImage letter(quint8 tableId, quint8 charId, FontColor color);
41  bool setLetter(quint8 tableId, quint8 charId, const QImage &image);
42  uint letterPixelIndex(quint8 tableId, quint8 charId, const QPoint &pos) const;
43  bool setLetterPixelIndex(quint8 tableId, quint8 charId, const QPoint &pos, uint pixelIndex);
44  quint8 charWidth(quint8 table, quint8 id) const;
45  quint8 charLeftPadding(quint8 table, quint8 id) const;
46  void setCharWidth(quint8 table, quint8 id, quint8 width);
47  void setCharLeftPadding(quint8 table, quint8 id, quint8 padding);
48 private:
49  static void saveSection(const QByteArray &section, QByteArray &data, quint16 type);
50  inline const TimFile &constFont(quint8 tableId) const {
51  if (isJp() && tableId >= 4) {
52  return _font2;
53  }
54  return _font;
55  }
56  inline TimFile &font(quint8 tableId) {
57  if (isJp() && tableId >= 4) {
58  return _font2;
59  }
60  return _font;
61  }
62  int palette(FontColor color, quint8 table) const;
63  QPoint letterPos(quint8 tableId, quint8 charId) const;
64  inline QSize letterSize() const {
65  return QSize(12, 12);
66  }
67  QRect letterRect(quint8 tableId, quint8 charId) const;
68  bool openFont(const QByteArray &data);
69  bool openFont2(const QByteArray &data);
70  bool openFontSize(const QByteArray &data);
71  static int absoluteId(quint8 table, quint8 id);
72  quint8 charInfo(quint8 table, quint8 id) const;
73  void setCharInfo(quint8 table, quint8 id, quint8 info);
74 
75  QList<quint8> _charWidth;
76  TimFile _icons;
77  TimFile _font;
78  TimFile _font2;
79  bool modified;
80 };
WindowBinFile::FontColor
FontColor
Definition: WindowBinFile.h:16
LEFT_PADD
quint8 LEFT_PADD(quint8 w)
Definition: WindowBinFile.h:10
CHARACTER_WIDTH
quint8 CHARACTER_WIDTH(quint8 w)
Definition: WindowBinFile.h:11
WindowBinFile
Definition: WindowBinFile.h:13
TimFile
Definition: TimFile.h:9