JpgSubfile.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // Created by Иван_Архипов on 24.11.2017.
  3. //
  4. #include "JpgSubfile.h"
  5. #include "../BinaryData.h"
  6. #include "../DatFile.h"
  7. #include "../Common/DatException.h"
  8. namespace LOTRO_DAT {
  9. JpgSubfile::JpgSubfile() {}
  10. JpgSubfile::JpgSubfile(DatFile *dat, long long fragments_count, long long unknown1,
  11. long long file_id, long long file_offset, long long file_size,
  12. long long timestamp,
  13. long long version, long long block_size)
  14. : Subfile(dat, fragments_count, unknown1, file_id, file_offset, file_size, timestamp, version, block_size) {
  15. }
  16. FILE_TYPE JpgSubfile::FileType() const {
  17. return FONT;
  18. }
  19. std::string JpgSubfile::Extension() const {
  20. return ".fontbin";
  21. }
  22. bool JpgSubfile::PrepareForExport(const BinaryData &file_data, long long &export_size, std::vector<BinaryData> &binary_data,
  23. std::vector<std::u16string> &text_data, std::vector<YAML::Node> &options) {
  24. export_size = 1;
  25. binary_data.emplace_back(file_data.CutData(24));
  26. text_data.emplace_back(u"");
  27. options.emplace_back(YAML::Node());
  28. options[0]["file_id"] = file_id();
  29. options[0]["extension"] = Extension();
  30. }
  31. BinaryData JpgSubfile::MakeForImport(const BinaryData &old_data, const BinaryData &binary_data, const std::u16string &text_data,
  32. const YAML::Node &options) {
  33. if (!options["extension"] || options["extension"].as<std::string>() != Extension() ||
  34. !options["file_id"] || options["file_id"].as<long long>() != file_id()) {
  35. throw DatException("Bad DdsSubfile::MakeForImport() - invalid options data!", IMPORT_EXCEPTION);
  36. }
  37. return old_data.CutData(0, 40) + binary_data;
  38. }
  39. };