/* * This file is part of OpenTTD. * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . */ /** @file newgrf_dump.h Functions/types related to NewGRF sprite group dumping. */ #ifndef NEWGRF_DUMP_H #define NEWGRF_DUMP_H #include "3rdparty/robin_hood/robin_hood.h" #include enum DumpSpriteGroupPrintOp { DSGPO_PRINT, DSGPO_START, DSGPO_END, DSGPO_NFO_LINE, }; using DumpSpriteGroupPrinter = std::function; struct SpriteGroupDumper { bool use_shadows = false; bool more_details = false; private: char buffer[1024]; DumpSpriteGroupPrinter print_fn; const SpriteGroup *top_default_group = nullptr; const SpriteGroup *top_graphics_group = nullptr; robin_hood::unordered_flat_set seen_dsgs; enum SpriteGroupDumperFlags { SGDF_DEFAULT = 1 << 0, SGDF_RANGE = 1 << 1, }; char *DumpSpriteGroupAdjust(char *p, const char *last, const struct DeterministicSpriteGroupAdjust &adjust, const char *padding, uint32_t &highlight_tag, uint &conditional_indent); void DumpSpriteGroup(const struct SpriteGroup *sg, const char *prefix, uint flags); public: SpriteGroupDumper(DumpSpriteGroupPrinter print) : print_fn(print) {} void DumpSpriteGroup(const SpriteGroup *sg, uint flags) { this->DumpSpriteGroup(sg, "", flags); } void Print(const char *msg) { this->print_fn(nullptr, DSGPO_PRINT, 0, msg); } }; #endif /* NEWGRF_DEBUG_H */