Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef TTIO_PLI_INCLUDED
Toshihiro Shimizu 890ddd
#define TTIO_PLI_INCLUDED
Toshihiro Shimizu 890ddd
Shinya Kitaoka 79e39b
#include <memory></memory>
Shinya Kitaoka 79e39b
Toshihiro Shimizu 890ddd
#include "tlevel_io.h"
Toshihiro Shimizu 890ddd
Campbell Barton 8c6c57
class GroupTag;
Toshihiro Shimizu 890ddd
class ParsedPli;
Toshihiro Shimizu 890ddd
class ImageTag;
Toshihiro Shimizu 890ddd
class TImageWriterPli;
Toshihiro Shimizu 890ddd
class TImageReaderPli;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===========================================================================
Toshihiro Shimizu 890ddd
/*
Shinya Kitaoka d1f6c4
class TWriterInfoPli final : public TWriterInfo {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
 ~TWriterInfoPli() {}
Shinya Kitaoka 120a6e
  static TWriterInfo *create(const std::string &ext) { return new
Shinya Kitaoka 120a6e
TWriterInfoPli(); }
Toshihiro Shimizu 890ddd
  TWriterInfo *clone() const {
Toshihiro Shimizu 890ddd
  return new TWriterInfoPli(*this); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
  TWriterInfoPli() {}
Toshihiro Shimizu 890ddd
  TWriterInfoPli(const TWriterInfoPli&) {}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
//===========================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  TLevelWriterPli:
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka d1f6c4
class TLevelWriterPli final : public TLevelWriter {
Shinya Kitaoka 120a6e
  //! object to manage a pli
Shinya Kitaoka 120a6e
  std::unique_ptr<parsedpli> m_pli;</parsedpli>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! number of frame in pli
Shinya Kitaoka 120a6e
  UINT m_frameNumber;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //  vettore da utilizzare per il calcolo della palette
Shinya Kitaoka 120a6e
  std::vector<tpixel> m_colorArray;</tpixel>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TLevelWriterPli(const TFilePath &path, TPropertyGroup *winfo);
Shinya Kitaoka 120a6e
  ~TLevelWriterPli();
Shinya Kitaoka 473e70
  TImageWriterP getFrameWriter(TFrameId fid) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  friend class TImageWriterPli;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  static TLevelWriter *create(const TFilePath &f, TPropertyGroup *winfo) {
Shinya Kitaoka 120a6e
    return new TLevelWriterPli(f, winfo);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // not implemented
Shinya Kitaoka 120a6e
  TLevelWriterPli(const TLevelWriterPli &);
Shinya Kitaoka 120a6e
  TLevelWriterPli &operator=(const TLevelWriterPli &);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===========================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef std::pair<imagetag *,="" bool=""> pliFrameInfo;</imagetag>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  TLevelReaderPli:
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka d1f6c4
class TLevelReaderPli final : public TLevelReader {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TLevelReaderPli(const TFilePath &path);
Shinya Kitaoka 120a6e
  ~TLevelReaderPli();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Return info about current pli
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 473e70
  TLevelP loadInfo() override;
Shinya Kitaoka 473e70
  void doReadPalette(bool doReadIt) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Return an image with Reader information
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 473e70
  TImageReaderP getFrameReader(TFrameId fid) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  QString getCreator() override;
Shinya Kitaoka 120a6e
  friend class TImageReaderPli;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  bool m_init;
luz paz 67b4e9
  //! struct which contains reference to frame
Shinya Kitaoka 120a6e
  std::map<tframeid, pliframeinfo=""> m_mapOfImage;</tframeid,>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! Reference to pli palette
Shinya Kitaoka 120a6e
  TPixel *m_palette;
Shinya Kitaoka 120a6e
  bool m_readPalette;
Shinya Kitaoka 120a6e
  //!
Shinya Kitaoka 120a6e
  TUINT32 m_paletteCount;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! flag to check if file exists
Shinya Kitaoka 120a6e
  bool m_doesExist;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! object to manage a pli
Shinya Kitaoka 120a6e
  ParsedPli *m_pli;
Shinya Kitaoka 120a6e
  TLevelP m_level;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  static TLevelReader *create(const TFilePath &f) {
Shinya Kitaoka 120a6e
    return new TLevelReaderPli(f);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // not implemented
Shinya Kitaoka 120a6e
  TLevelReaderPli(const TLevelReaderPli &);
Shinya Kitaoka 120a6e
  TLevelReaderPli &operator=(const TLevelReaderPli &);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===========================================================================
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
Classe locale per la lettura di un frame del livello.
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka d1f6c4
class TImageReaderPli final : public TImageReader {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TFrameId m_frameId;  //
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // not implemented
Shinya Kitaoka 120a6e
  TImageReaderPli(const TImageReaderPli &);
Shinya Kitaoka 120a6e
  TImageReaderPli &operator=(const TImageReaderPli &src);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TImageReaderPli(const TFilePath &f, const TFrameId &frameId,
Shinya Kitaoka 120a6e
                  TLevelReaderPli *);
Shinya Kitaoka 120a6e
  ~TImageReaderPli() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  TImageP load() override;
Shinya Kitaoka 120a6e
  TImageP doLoad();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TDimension getSize() const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRect getBBox() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  //! Size of image
Shinya Kitaoka 120a6e
  int m_lx, m_ly;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! Reference to level reader
Shinya Kitaoka 120a6e
  TLevelReaderPli *m_lrp;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Campbell Barton 8c6c57
// Functions
Campbell Barton 8c6c57
shun-iwasawa 27b0cf
TPalette *readPalette(GroupTag *paletteTag, int majorVersion, int minorVersion);
Campbell Barton 8c6c57
Shinya Kitaoka 120a6e
#endif  // TTIO_PLI_INCLUDED