libeuropa: Move YatfReader into europa::io::yatf
namespace
Finish Refactoring™️
This commit is contained in:
parent
84c537c873
commit
452a82b079
4 changed files with 19 additions and 16 deletions
|
@ -14,11 +14,11 @@
|
||||||
#include <europa/structs/Yatf.hpp>
|
#include <europa/structs/Yatf.hpp>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
namespace europa::io {
|
namespace europa::io::yatf {
|
||||||
|
|
||||||
/// Reader for PS2 Europa .tex files.
|
/// Reader for PS2 Europa .tex (YATF - Yet Another Texture Format) files.
|
||||||
struct YatfReader {
|
struct Reader {
|
||||||
explicit YatfReader(std::istream& is);
|
explicit Reader(std::istream& is);
|
||||||
|
|
||||||
void InitFromStream(std::istream& is);
|
void InitFromStream(std::istream& is);
|
||||||
|
|
|
@ -15,7 +15,7 @@ add_library(europa
|
||||||
io/pak/Writer.cpp
|
io/pak/Writer.cpp
|
||||||
|
|
||||||
# Yatf IO
|
# Yatf IO
|
||||||
io/YatfReader.cpp
|
io/yatf/Reader.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(europa PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
target_include_directories(europa PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||||
|
|
|
@ -10,19 +10,19 @@
|
||||||
// we should just use stbiw directly and provide our own
|
// we should just use stbiw directly and provide our own
|
||||||
// simpler/faster utilities for image buffers.
|
// simpler/faster utilities for image buffers.
|
||||||
|
|
||||||
#include <europa/io/YatfReader.hpp>
|
#include <europa/io/yatf/Reader.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "StreamUtils.h"
|
#include "../StreamUtils.h"
|
||||||
|
|
||||||
namespace europa::io {
|
namespace europa::io::yatf {
|
||||||
|
|
||||||
YatfReader::YatfReader(std::istream& is)
|
Reader::Reader(std::istream& is)
|
||||||
: stream(is) {
|
: stream(is) {
|
||||||
InitFromStream(stream);
|
InitFromStream(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YatfReader::InitFromStream(std::istream& is) {
|
void Reader::InitFromStream(std::istream& is) {
|
||||||
// Read the image header.
|
// Read the image header.
|
||||||
header = impl::ReadStreamType<structs::YatfHeader>(is);
|
header = impl::ReadStreamType<structs::YatfHeader>(is);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ namespace europa::io {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YatfReader::ReadImage() {
|
void Reader::ReadImage() {
|
||||||
if(header.flags & structs::YatfHeader::TextureFlag_NoPalette) {
|
if(header.flags & structs::YatfHeader::TextureFlag_NoPalette) {
|
||||||
image.Resize({ static_cast<std::uint16_t>(header.width), static_cast<std::uint16_t>(header.height) });
|
image.Resize({ static_cast<std::uint16_t>(header.width), static_cast<std::uint16_t>(header.height) });
|
||||||
stream.read(reinterpret_cast<char*>(image.GetBuffer()), (header.width * header.height) * sizeof(pixel::RgbaColor));
|
stream.read(reinterpret_cast<char*>(image.GetBuffer()), (header.width * header.height) * sizeof(pixel::RgbaColor));
|
||||||
|
@ -52,12 +52,12 @@ namespace europa::io {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pixel::RgbaImage& YatfReader::GetImage() {
|
pixel::RgbaImage& Reader::GetImage() {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
const structs::YatfHeader& YatfReader::GetHeader() const {
|
const structs::YatfHeader& Reader::GetHeader() const {
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace europa::io
|
} // namespace europa::io::yatf
|
|
@ -8,12 +8,15 @@
|
||||||
|
|
||||||
#include <pixel/ImageWriter.h>
|
#include <pixel/ImageWriter.h>
|
||||||
|
|
||||||
#include <europa/io/YatfReader.hpp>
|
#include <europa/io/yatf/Reader.hpp>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace eio = europa::io;
|
||||||
|
namespace yatf = eio::yatf;
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
if(argc != 2) {
|
if(argc != 2) {
|
||||||
std::cout << "Usage: " << argv[0] << " [path to Europa PAK file]";
|
std::cout << "Usage: " << argv[0] << " [path to Europa PAK file]";
|
||||||
|
@ -27,7 +30,7 @@ int main(int argc, char** argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
europa::io::YatfReader reader(ifs);
|
yatf::Reader reader(ifs);
|
||||||
|
|
||||||
if(reader.Invalid()) {
|
if(reader.Invalid()) {
|
||||||
std::cout << "Invalid YATF file \"" << argv[1] << "\"\n";
|
std::cout << "Invalid YATF file \"" << argv[1] << "\"\n";
|
||||||
|
|
Loading…
Reference in a new issue