[Tablegen] Specify characters separately from the settings
This commit is contained in:
parent
9da2940746
commit
a0b221f103
4 changed files with 19 additions and 15 deletions
|
@ -4,7 +4,6 @@
|
||||||
#include <Common/RGB.hpp>
|
#include <Common/RGB.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace Tablegen
|
namespace Tablegen
|
||||||
{
|
{
|
||||||
|
@ -49,7 +48,6 @@ namespace Tablegen
|
||||||
std::size_t CharactersPerRow;
|
std::size_t CharactersPerRow;
|
||||||
std::string ImageFormat;
|
std::string ImageFormat;
|
||||||
std::string AnimationFormat;
|
std::string AnimationFormat;
|
||||||
std::vector<CharacterInfo> Characters;
|
|
||||||
|
|
||||||
static Settings Default();
|
static Settings Default();
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,17 +8,21 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Tablegen
|
namespace Tablegen
|
||||||
{
|
{
|
||||||
std::string GeneratePage(const Settings& settings = Settings::Default());
|
std::string GeneratePage(std::vector<CharacterInfo> characters,
|
||||||
|
const Settings& settings = Settings::Default());
|
||||||
|
|
||||||
void GeneratePage(const std::string& path, const Settings& settings = Settings::Default());
|
void GeneratePage(const std::string& path, std::vector<CharacterInfo> characters,
|
||||||
|
const Settings& settings = Settings::Default());
|
||||||
|
|
||||||
# ifdef TABLEGEN_EXPOSE_XML
|
# ifdef TABLEGEN_EXPOSE_XML
|
||||||
void GenerateAsChild(pugi::xml_node& node, const Settings& settings = Settings::Default());
|
void GenerateAsChild(pugi::xml_node& node, std::vector<CharacterInfo> characters,
|
||||||
|
const Settings& settings = Settings::Default());
|
||||||
|
|
||||||
pugi::xml_document GenerateDocument(const Settings& settings = Settings::Default());
|
pugi::xml_document GenerateDocument(std::vector<CharacterInfo> characters, const Settings& settings = Settings::Default());
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ namespace Tablegen
|
||||||
.CharactersPerRow = 3,
|
.CharactersPerRow = 3,
|
||||||
.ImageFormat = "https://3011.io/Assets/Images/Kanji/Static/{}.png",
|
.ImageFormat = "https://3011.io/Assets/Images/Kanji/Static/{}.png",
|
||||||
.AnimationFormat = "https://3011.io/Assets/Temp/{}.svg",
|
.AnimationFormat = "https://3011.io/Assets/Temp/{}.svg",
|
||||||
.Characters = {},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,9 @@ namespace Tablegen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GeneratePage(const Settings& settings)
|
std::string GeneratePage(std::vector<CharacterInfo> characters, const Settings& settings)
|
||||||
{
|
{
|
||||||
pugi::xml_document doc = GenerateDocument(settings);
|
pugi::xml_document doc = GenerateDocument(characters, settings);
|
||||||
|
|
||||||
std::uint32_t formatOptions;
|
std::uint32_t formatOptions;
|
||||||
formatOptions = pugi::format_indent | pugi::format_no_escapes | pugi::format_no_declaration;
|
formatOptions = pugi::format_indent | pugi::format_no_escapes | pugi::format_no_declaration;
|
||||||
|
@ -106,16 +106,18 @@ namespace Tablegen
|
||||||
return str.str();
|
return str.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneratePage(const std::string& path, const Settings& settings)
|
void GeneratePage(const std::string& path, std::vector<CharacterInfo> characters,
|
||||||
|
const Settings& settings)
|
||||||
{
|
{
|
||||||
pugi::xml_document doc = GenerateDocument(settings);
|
pugi::xml_document doc = GenerateDocument(characters, settings);
|
||||||
|
|
||||||
std::uint32_t formatOptions;
|
std::uint32_t formatOptions;
|
||||||
formatOptions = pugi::format_indent | pugi::format_no_escapes | pugi::format_no_declaration;
|
formatOptions = pugi::format_indent | pugi::format_no_escapes | pugi::format_no_declaration;
|
||||||
doc.save_file("test.html", " ", formatOptions);
|
doc.save_file("test.html", " ", formatOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateAsChild(pugi::xml_node& node, const Settings& settings)
|
void GenerateAsChild(pugi::xml_node& node, std::vector<CharacterInfo> characters,
|
||||||
|
const Settings& settings)
|
||||||
{
|
{
|
||||||
pugi::xml_node tableRoot = node;
|
pugi::xml_node tableRoot = node;
|
||||||
|
|
||||||
|
@ -151,7 +153,7 @@ namespace Tablegen
|
||||||
std::string tagIndent((indentLevel > 0 ? indentLevel - 1 : 0) * 4, ' ');
|
std::string tagIndent((indentLevel > 0 ? indentLevel - 1 : 0) * 4, ' ');
|
||||||
|
|
||||||
pugi::xml_node tableBody = table.append_child("tbody");
|
pugi::xml_node tableBody = table.append_child("tbody");
|
||||||
for (pugi::xml_node row; const auto& [i, character] : vw::enumerate(settings.Characters)) {
|
for (pugi::xml_node row; const auto& [i, character] : vw::enumerate(characters)) {
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// HTML
|
// HTML
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -201,10 +203,11 @@ namespace Tablegen
|
||||||
script.append_child(pugi::node_pcdata).set_value(Script(indent, tagIndent, buttons));
|
script.append_child(pugi::node_pcdata).set_value(Script(indent, tagIndent, buttons));
|
||||||
}
|
}
|
||||||
|
|
||||||
pugi::xml_document GenerateDocument(const Settings& settings)
|
pugi::xml_document GenerateDocument(std::vector<CharacterInfo> characters,
|
||||||
|
const Settings& settings)
|
||||||
{
|
{
|
||||||
pugi::xml_document doc;
|
pugi::xml_document doc;
|
||||||
GenerateAsChild(doc);
|
GenerateAsChild(doc, characters, settings);
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue