[Tablegen] Add link elements to optimize image loading
This commit is contained in:
parent
838d3dcdfe
commit
7c3604fcf3
1 changed files with 18 additions and 6 deletions
|
@ -64,11 +64,9 @@ namespace Tablegen
|
|||
|
||||
constexpr std::string ImageStyle(std::string_view indent,
|
||||
std::size_t index,
|
||||
std::string_view imageName,
|
||||
std::string_view imageFormat,
|
||||
std::string_view imagePath,
|
||||
std::string_view extraSpecifier = "")
|
||||
{
|
||||
std::string imagePath = std::vformat(imageFormat, std::make_format_args(imageName));
|
||||
return std::format(imageStyleFormat, indent, index, extraSpecifier, imagePath);
|
||||
}
|
||||
|
||||
|
@ -180,6 +178,21 @@ namespace Tablegen
|
|||
imageWrap.append_attribute("class") = "kanji-image-wrap";
|
||||
imageWrap.append_attribute("id") = std::format("kanji-{}", i);
|
||||
|
||||
std::string imagePath = std::vformat(
|
||||
settings.ImageFormat, std::make_format_args(character.ImagePath)
|
||||
);
|
||||
std::string animationPath = std::vformat(
|
||||
settings.AnimationFormat, std::make_format_args(character.AnimationPath)
|
||||
);
|
||||
|
||||
pugi::xml_node prefetchImage = container.append_child("link");
|
||||
prefetchImage.append_attribute("rel") = "prefetch";
|
||||
prefetchImage.append_attribute("href") = imagePath;
|
||||
|
||||
pugi::xml_node prefetchAnimation = container.append_child("link");
|
||||
prefetchAnimation.append_attribute("rel") = "prefetch";
|
||||
prefetchAnimation.append_attribute("href") = animationPath;
|
||||
|
||||
pugi::xml_node image = imageWrap.append_child("input");
|
||||
image.append_attribute("type") = "checkbox";
|
||||
image.append_attribute("class") = "kanji-image";
|
||||
|
@ -188,9 +201,8 @@ namespace Tablegen
|
|||
////////////////////////////////////////////////////////////////////
|
||||
// CSS
|
||||
////////////////////////////////////////////////////////////////////
|
||||
staticImg.append(ImageStyle(indent, i, character.ImagePath, settings.ImageFormat));
|
||||
animatedImg.append(ImageStyle(indent, i, character.AnimationPath,
|
||||
settings.AnimationFormat, ":checked"));
|
||||
staticImg.append(ImageStyle(indent, i, imagePath));
|
||||
animatedImg.append(ImageStyle(indent, i, animationPath, ":checked"));
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// JavaScript
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue