diff --git a/Libraries/Tablegen/Source/Tablegen.cpp b/Libraries/Tablegen/Source/Tablegen.cpp index e136dd8..a7a0f6b 100644 --- a/Libraries/Tablegen/Source/Tablegen.cpp +++ b/Libraries/Tablegen/Source/Tablegen.cpp @@ -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