2021-12-04 12:33:18 -05:00
|
|
|
#pragma once
|
|
|
|
|
2023-03-21 19:41:14 -04:00
|
|
|
#include <map>
|
2022-03-02 20:01:37 -05:00
|
|
|
#include <set>
|
2021-12-04 12:33:18 -05:00
|
|
|
#include <string>
|
2022-06-22 23:37:46 -04:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-12-04 12:33:18 -05:00
|
|
|
#include "common/common_types.h"
|
2023-07-14 18:17:54 -04:00
|
|
|
#include "common/custom_data/Tfrag3Data.h"
|
2022-07-05 20:38:13 -04:00
|
|
|
#include "common/util/FileUtil.h"
|
2021-12-04 12:33:18 -05:00
|
|
|
|
|
|
|
namespace decompiler {
|
|
|
|
struct TextureDB {
|
2023-08-16 19:40:28 -04:00
|
|
|
TextureDB();
|
2021-12-04 12:33:18 -05:00
|
|
|
struct TextureData {
|
|
|
|
u16 w, h;
|
|
|
|
std::string name;
|
|
|
|
u32 page;
|
2023-03-21 19:41:14 -04:00
|
|
|
u32 dest = -1;
|
2021-12-04 12:33:18 -05:00
|
|
|
std::vector<u32> rgba_bytes;
|
2023-03-17 20:35:26 -04:00
|
|
|
u32 num_mips = -1;
|
2021-12-04 12:33:18 -05:00
|
|
|
};
|
|
|
|
|
2023-03-21 19:41:14 -04:00
|
|
|
std::map<u32, TextureData> textures;
|
2021-12-04 12:33:18 -05:00
|
|
|
std::unordered_map<u32, std::string> tpage_names;
|
2022-03-02 20:01:37 -05:00
|
|
|
std::unordered_map<std::string, std::set<u32>> texture_ids_per_level;
|
2021-12-04 12:33:18 -05:00
|
|
|
|
2023-07-14 18:17:54 -04:00
|
|
|
// special textures for animation.
|
|
|
|
std::map<u32, tfrag3::IndexTexture> index_textures_by_combo_id;
|
|
|
|
|
|
|
|
std::unordered_map<std::string, u32> animated_tex_output_to_anim_slot;
|
|
|
|
|
2023-08-16 19:40:28 -04:00
|
|
|
static constexpr int kPlaceholderWhiteTexturePage = INT16_MAX;
|
|
|
|
static constexpr int kPlaceholderWhiteTextureId = 0;
|
|
|
|
|
2021-12-04 12:33:18 -05:00
|
|
|
void add_texture(u32 tpage,
|
|
|
|
u32 texid,
|
|
|
|
const std::vector<u32>& data,
|
|
|
|
u16 w,
|
|
|
|
u16 h,
|
|
|
|
const std::string& tex_name,
|
2022-03-02 20:01:37 -05:00
|
|
|
const std::string& tpage_name,
|
2023-03-17 20:35:26 -04:00
|
|
|
const std::vector<std::string>& level_names,
|
2023-03-21 19:41:14 -04:00
|
|
|
u32 num_mips,
|
|
|
|
u32 dest);
|
2022-03-02 20:01:37 -05:00
|
|
|
|
2023-07-14 18:17:54 -04:00
|
|
|
void add_index_texture(u32 tpage,
|
|
|
|
u32 texid,
|
|
|
|
const std::vector<u8>& index_data,
|
|
|
|
const std::array<math::Vector4<u8>, 256>& clut,
|
|
|
|
u16 w,
|
|
|
|
u16 h,
|
|
|
|
const std::string& tex_name,
|
|
|
|
const std::string& tpage_name,
|
|
|
|
const std::vector<std::string>& level_names);
|
|
|
|
|
2023-10-12 19:02:36 -04:00
|
|
|
void merge_textures(const fs::path& base_path);
|
2022-07-05 20:38:13 -04:00
|
|
|
void replace_textures(const fs::path& path);
|
2023-03-21 19:41:14 -04:00
|
|
|
|
|
|
|
std::string generate_texture_dest_adjustment_table() const;
|
2021-12-04 12:33:18 -05:00
|
|
|
};
|
2024-03-23 09:25:11 -04:00
|
|
|
|
|
|
|
// used by decompiler for texture macros
|
|
|
|
struct TexInfo {
|
|
|
|
std::string name;
|
|
|
|
std::string tpage_name;
|
|
|
|
u32 idx;
|
|
|
|
};
|
2021-12-04 12:33:18 -05:00
|
|
|
} // namespace decompiler
|