Files
David Benepe e30f1c535a DKR Assets Tool v0.5.2 (Basic glTF support) (#610)
* Removed old unused files

* Added gltf support

* Reverted dkr_assets_tool_settings.json to previous

* Added animated model example

* document audio_vehicle.c (#588)

* wip

* wip

* wip

* wip

* document audio_vehicle.c

* update score once again

* unify function prefix

* small tweaks

* match func_80060910 and func_80060AC8 (#589)

* match func_80060AC8

* reworked func_80060C58

* match func_80060910

* non equivalent func_8006017C

* format

* match calc_env_mapping_for_object

* Homogenate batch flags and render flags and begin the painful task of documenting waves. (#590)

* part one of wave pain

* 2

* littel bit more

* m

* h

* l

* aagghh

* yeah

* :)

* bruh

* b

* m

* faith

* z

* b

* rename batch flags

* Update waves.c

* fix conflicts

* match func_8000B38C (#592)

* match func_8000B38C

* format code

* update score

* match calc_dynamic_lighting_for_object_1 (#594)

* match calc_dynamic_lighting_for_object_1

* format and score

* update score

* update score again

* Document some Boost data (#593)

* Run formatter

* Document some boost info

* decompile and document math_util.c (#595)

* Match func_8002F440 (#596)

* Add a WIP attempt of func_8004447C, and add some scratch links

* match func_8002F440 and run formatter

* Cleanup some comments

* Update score, fix warnings, and run formatter again

* Remove some bad comments

* match: func_8007FFEC (#599)

* feat: allow score script to generate treemap file for decomp progress (#598)

* Various touchups here and there, some renames in camera.c (#597)

* the beginning of the void

* update asset tool

* void :)

* there

* cam

* model

* more

* fix warns

* ok

* whoops missed a rename

* Add a few NON_EQUIVALENT functions from scratches to keep them up to date (#602)

* WIP func_800101AC

* WIP func_800452A0

* cleanup

* Formatter and func_8004CC20 near match

* func_8004CC20 better score and documentation

* func_80049794 WIP and compilable

* Major cleanup of func_80049794

* Formatter

* Update scratch

* Add func_80019808 from scratch

* Cleanup func_80019808

* func_80019808 score improvment

* Improve func_80049794 score (Thanks Dominik!)

* func_8001C6C4 WIP

* func_8001E93C WIP

* small documenting

* Eliminate a lot of Obj64 casts.

* fix: do not pass default to treemap arg (#604)

* Quick fix for score script (#606)

* WIP func_80060EA8

* Quick fix for score script

* name and document lights, CC modes and textures (#607)

* improve match for func_800BDC80 & match func_80060EA8, func_8002F2AC (#609)

* improve match for func_800BDC80 & match func_80060EA8

* match: func_8002F2AC

* match: func_800452A0 & func_80042D20 (#611)

* partial match: func_800452A0, improve from non equiv to non matching

* match: func_800452A0 & func_80042D20

* document: remaining funcs, add decomp.me links (#612)

* match func_8004447C (#615)

* Document camera and sprites (#614)

* Cleanup, and use constants where possible (#617)

* Update func_80060EA8 WIP

* formatter

* More func_80060EA8

* More func_80060EA8

* WIP func_80060EA8

* Minor cleanups and documenting

* minot cleanup

* Define some constant flags properly

* Misc documenting and cleanup

* formatter

* Fix the scratch link for vsprintf (It was DP's)

* Add the WIP version of vsprintf that's 95.82% matching.

* Fix score script (#619)

* Added gltf support

* Allow either commas or vertical pipes for splitting render flags

---------

Co-authored-by: Unnunu <serge_zorkin@mail.ru>
Co-authored-by: Fazana <52551480+FazanaJ@users.noreply.github.com>
Co-authored-by: Ryan Myers <ryan.p.myers@gmail.com>
Co-authored-by: Dominik Peters <github@d-peters.com>
2025-06-12 10:29:08 -04:00

176 lines
5.3 KiB
C++

#include "buildInfo.h"
#include "misc/globalSettings.h"
#include "helpers/c/cContext.h"
#include "helpers/jsonHelper.h"
using namespace DkrAssetsTool;
BuildInfo::BuildInfo() {
DebugHelper::error("Must not initalize empty build info.");
}
/*
BuildInfo::BuildInfo(JsonFile *src, const fs::path &dst, const fs::path &dir)
: srcFile(src), dstPath(dst), localDirectory(dir) {
_buildType = BUILD_TO_FILE;
}*/
/*
BuildInfo::BuildInfo(JsonFile *src, const fs::path &dir)
: srcFile(src), dstPath(""), localDirectory(dir) {
_buildType = BUILD_TO_BINARY;
}
*/
BuildInfo::BuildInfo(std::string buildId, std::string buildSectionId, const JsonFile &src, size_t fileIndex, const fs::path &dir, const BuildInfoContext &infoContext)
: _dstPath(""), _localDirectory(dir), _jsonFile(src), _infoContext(infoContext), _buildId(buildId), _buildSectionId(buildSectionId), _fileIndex(fileIndex) {
_buildType = BUILD_TO_BINARY;
const JsonFile &jsonFile = get_src_json_file();
_type = jsonFile.get_string("/type", "NoType");
}
BuildInfo::BuildInfo(std::string buildId, std::string buildSectionId, std::string deferredFromBuildId, std::string deferredFromSectionId, const std::vector<uint8_t> &outData,
size_t fileIndex, const fs::path &dir, const BuildInfoContext &infoContext) : out(outData), _dstPath(""), _localDirectory(dir), _jsonFile(std::nullopt), _infoContext(infoContext),
_buildId(buildId), _buildSectionId(buildSectionId), _deferredFromBuildId(deferredFromBuildId), _deferredFromSectionId(deferredFromSectionId), _type("Binary"), _fileIndex(fileIndex) {
_buildType = BUILD_TO_BINARY;
}
BuildInfo::~BuildInfo() {
}
BuildInfoType BuildInfo::get_build_type() const {
return _buildType;
}
bool BuildInfo::build_to_file() const {
return _buildType == BUILD_TO_FILE;
}
bool BuildInfo::build_to_binary() const {
return _buildType == BUILD_TO_BINARY;
}
void BuildInfo::write_out_to_dstPath() {
FileHelper::write_binary_file(out, _dstPath, true);
}
void BuildInfo::copy_to_dstPath(fs::path srcPath) {
FileHelper::copy(srcPath, _dstPath);
}
void BuildInfo::write_empty_file_to_dstPath() {
FileHelper::write_empty_file(_dstPath, true);
}
fs::path BuildInfo::get_dstPath() const {
return _dstPath;
}
fs::path BuildInfo::get_dst_folder() const {
return _dstPath.parent_path();
}
fs::path BuildInfo::get_dst_filename() const {
return _dstPath.filename();
}
fs::path BuildInfo::get_path_to_directory() const {
return GlobalSettings::get_decomp_path_to_output_assets() / _localDirectory;
}
CContext &BuildInfo::get_c_context() const {
const BuildInfoContext &infoContext = _infoContext.value();
return infoContext.get_c_context();
}
BuildTextureCache &BuildInfo::get_texture_cache() const {
const BuildInfoContext &infoContext = _infoContext.value();
return infoContext.get_texture_cache();
}
BuildInfoCollection &BuildInfo::get_collection() const {
const BuildInfoContext &infoContext = _infoContext.value();
return infoContext.get_collection();
}
const JsonFile &BuildInfo::get_src_json_file() const {
DebugHelper::assert_(_jsonFile.has_value(),
"(BuildInfo::get_src_json_file) _jsonFile is null! build id was \"", _buildId, "\"");
return _jsonFile.value();
}
const BuildInfoContext &BuildInfo::get_info_context() const {
DebugHelper::assert_(_infoContext.has_value(),
"(BuildInfo::get_info_context) _infoContext is null! build id was \"", _buildId, "\"");
return _infoContext.value();
}
std::string BuildInfo::get_type() const {
return _type;
}
std::string BuildInfo::get_build_id() const {
return _buildId;
}
std::string BuildInfo::get_section_build_id() const {
return _buildSectionId;
}
std::string BuildInfo::get_deferred_from_build_id() const {
return _deferredFromBuildId;
}
std::string BuildInfo::get_deferred_from_section_build_id() const {
return _deferredFromSectionId;
}
size_t BuildInfo::get_file_index() const {
return _fileIndex;
}
bool BuildInfo::is_deferred() const {
return !_deferredFromSectionId.empty();
}
bool BuildInfo::is_complete() const {
return _complete;
}
void BuildInfo::done() {
_complete = true;
//pad_output_data();
}
void BuildInfo::pad_output_data() {
while((out.size() % 8) != 0) {
out.push_back(0);
}
}
void BuildInfo::load_structs_into_c_context(std::vector<fs::path> structFilesToLoad) {
fs::path includeFolder = GlobalSettings::get_decomp_path("include_subpath", "include/");
DebugHelper::assert_(!includeFolder.empty(),
"(BuildInfo::load_structs_into_c_context) Could not find the include folder!");
CContext &cContext = get_c_context();
for(fs::path &structPath : structFilesToLoad) {
CStructHelper::load_structs_from_file(cContext, includeFolder / structPath);
}
}
void BuildInfo::load_enums_into_c_context(std::vector<fs::path> enumFilesToLoad) {
fs::path includeFolder = GlobalSettings::get_decomp_path("include_subpath", "include/");
DebugHelper::assert_(!includeFolder.empty(),
"(BuildInfo::load_enums_into_c_context) Could not find the include folder!");
CContext &cContext = get_c_context();
for(fs::path &enumPath : enumFilesToLoad) {
CEnumsHelper::load_enums_from_file(cContext, includeFolder / enumPath);
}
}