mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 21:01:37 +00:00
Implement ImGui font atlas caching.
This commit is contained in:
parent
0a588949a7
commit
0248ef664e
13 changed files with 343 additions and 17 deletions
|
|
@ -323,3 +323,5 @@ BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/co
|
|||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/common/select_fill.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/common/select_fill.dds" ARRAY_NAME "g_select_fill" COMPRESSION_TYPE "zstd")
|
||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/game_icon.bmp" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/game_icon.bmp" ARRAY_NAME "g_game_icon")
|
||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/game_icon_night.bmp" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/game_icon_night.bmp" ARRAY_NAME "g_game_icon_night")
|
||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/font/im_font_atlas.bin" DEST_FILE "${RESOURCES_OUTPUT_PATH}/font/im_font_atlas.bin" ARRAY_NAME "g_im_font_atlas" COMPRESSION_TYPE "zstd")
|
||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/font/im_font_atlas.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/font/im_font_atlas.dds" ARRAY_NAME "g_im_font_atlas_texture" COMPRESSION_TYPE "zstd")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
#include "imgui_snapshot.h"
|
||||
|
||||
#include <locale/locale.h>
|
||||
#include <res/font/im_font_atlas.bin.h>
|
||||
#include <user/config.h>
|
||||
#include <decompressor.h>
|
||||
#include <kernel/xdbf.h>
|
||||
|
||||
void ImDrawDataSnapshot::Clear()
|
||||
{
|
||||
for (int n = 0; n < Cache.GetMapSize(); n++)
|
||||
|
|
@ -52,3 +58,211 @@ void ImDrawDataSnapshot::SnapUsingSwap(ImDrawData* src, double current_time)
|
|||
Cache.Remove(GetDrawListID(entry->SrcCopy), entry);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T1, typename T2>
|
||||
void ImFontAtlasSnapshot::SnapPointer(size_t offset, const T1& value, const T2& ptr, size_t count)
|
||||
{
|
||||
if (ptr != nullptr && count != 0)
|
||||
{
|
||||
if (!objects.contains(ptr))
|
||||
{
|
||||
constexpr size_t ALIGN = alignof(std::remove_pointer_t<T2>);
|
||||
constexpr size_t SIZE = sizeof(std::remove_pointer_t<T2>);
|
||||
|
||||
size_t ptrOffset = (data.size() + ALIGN - 1) & ~(ALIGN - 1);
|
||||
data.resize(ptrOffset + SIZE * count);
|
||||
memcpy(&data[ptrOffset], ptr, SIZE * count);
|
||||
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
size_t curPtrOffset = ptrOffset + SIZE * i;
|
||||
objects[&ptr[i]] = curPtrOffset;
|
||||
Traverse(curPtrOffset, ptr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
size_t fieldOffset = offset + (reinterpret_cast<ptrdiff_t>(&ptr) - reinterpret_cast<ptrdiff_t>(&value));
|
||||
*reinterpret_cast<size_t*>(&data[fieldOffset]) = objects[ptr];
|
||||
offsets.push_back(fieldOffset);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void ImFontAtlasSnapshot::Traverse(size_t offset, const T& value)
|
||||
{
|
||||
if constexpr (std::is_pointer_v<T>)
|
||||
{
|
||||
SnapPointer(offset, value, value, 1);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, ImFontAtlas>)
|
||||
{
|
||||
SnapPointer(offset, value, value.ConfigData.Data, value.ConfigData.Size);
|
||||
SnapPointer(offset, value, value.CustomRects.Data, value.CustomRects.Size);
|
||||
SnapPointer(offset, value, value.Fonts.Data, value.Fonts.Size);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, ImFont>)
|
||||
{
|
||||
SnapPointer(offset, value, value.IndexAdvanceX.Data, value.IndexAdvanceX.Size);
|
||||
SnapPointer(offset, value, value.IndexLookup.Data, value.IndexLookup.Size);
|
||||
SnapPointer(offset, value, value.Glyphs.Data, value.Glyphs.Size);
|
||||
SnapPointer(offset, value, value.FallbackGlyph, 1);
|
||||
SnapPointer(offset, value, value.ContainerAtlas, 1);
|
||||
SnapPointer(offset, value, value.ConfigData, value.ConfigDataCount);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, ImFontAtlasCustomRect>)
|
||||
{
|
||||
SnapPointer(offset, value, value.Font, 1);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, ImFontConfig>)
|
||||
{
|
||||
SnapPointer(offset, value, value.GlyphRanges, value.GlyphRanges != nullptr ? wcslen(reinterpret_cast<const wchar_t*>(value.GlyphRanges)) + 1 : 0);
|
||||
SnapPointer(offset, value, value.DstFont, 1);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
size_t ImFontAtlasSnapshot::Snap(const T& value)
|
||||
{
|
||||
size_t offset = (data.size() + alignof(T) - 1) & ~(alignof(T) - 1);
|
||||
data.resize(offset + sizeof(T));
|
||||
memcpy(&data[offset], &value, sizeof(T));
|
||||
objects[&value] = offset;
|
||||
Traverse(offset, value);
|
||||
return offset;
|
||||
}
|
||||
|
||||
struct ImFontAtlasSnapshotHeader
|
||||
{
|
||||
uint32_t imguiVersion;
|
||||
uint32_t dataOffset;
|
||||
uint32_t offsetCount;
|
||||
uint32_t offsetsOffset;
|
||||
};
|
||||
|
||||
void ImFontAtlasSnapshot::Snap()
|
||||
{
|
||||
data.resize(sizeof(ImFontAtlasSnapshotHeader));
|
||||
size_t dataOffset = Snap(*ImGui::GetIO().Fonts);
|
||||
|
||||
size_t offsetsOffset = data.size();
|
||||
std::sort(offsets.begin(), offsets.end());
|
||||
|
||||
data.insert(data.end(),
|
||||
reinterpret_cast<uint8_t*>(offsets.data()),
|
||||
reinterpret_cast<uint8_t*>(offsets.data() + offsets.size()));
|
||||
|
||||
auto header = reinterpret_cast<ImFontAtlasSnapshotHeader*>(data.data());
|
||||
header->imguiVersion = IMGUI_VERSION_NUM;
|
||||
header->dataOffset = dataOffset;
|
||||
header->offsetCount = offsets.size();
|
||||
header->offsetsOffset = offsetsOffset;
|
||||
}
|
||||
|
||||
static std::unique_ptr<uint8_t[]> g_imFontAtlas;
|
||||
|
||||
ImFontAtlas* ImFontAtlasSnapshot::Load()
|
||||
{
|
||||
g_imFontAtlas = decompressZstd(g_im_font_atlas, g_im_font_atlas_uncompressed_size);
|
||||
|
||||
auto header = reinterpret_cast<ImFontAtlasSnapshotHeader*>(g_imFontAtlas.get());
|
||||
assert(header->imguiVersion == IMGUI_VERSION_NUM && "ImGui version mismatch, the font atlas needs to be regenerated!");
|
||||
|
||||
auto offsetTable = reinterpret_cast<uint32_t*>(g_imFontAtlas.get() + header->offsetsOffset);
|
||||
for (size_t i = 0; i < header->offsetCount; i++)
|
||||
{
|
||||
*reinterpret_cast<size_t*>(g_imFontAtlas.get() + (*offsetTable)) += reinterpret_cast<size_t>(g_imFontAtlas.get());
|
||||
++offsetTable;
|
||||
}
|
||||
|
||||
return reinterpret_cast<ImFontAtlas*>(g_imFontAtlas.get() + header->dataOffset);
|
||||
}
|
||||
|
||||
|
||||
static void GetGlyphs(std::set<ImWchar>& glyphs, const std::string_view& value)
|
||||
{
|
||||
const char* cur = value.data();
|
||||
while (cur < value.data() + value.size())
|
||||
{
|
||||
unsigned int c;
|
||||
cur += ImTextCharFromUtf8(&c, cur, value.data() + value.size());
|
||||
glyphs.emplace(c);
|
||||
}
|
||||
}
|
||||
|
||||
static std::vector<ImWchar> g_glyphRanges;
|
||||
|
||||
void ImFontAtlasSnapshot::GenerateGlyphRanges()
|
||||
{
|
||||
std::vector<std::string_view> localeStrings;
|
||||
|
||||
for (auto& config : Config::Definitions)
|
||||
config->GetLocaleStrings(localeStrings);
|
||||
|
||||
std::set<ImWchar> glyphs;
|
||||
|
||||
for (size_t i = 0x20; i <= 0xFF; i++)
|
||||
glyphs.emplace(i);
|
||||
|
||||
for (auto& localeString : localeStrings)
|
||||
GetGlyphs(glyphs, localeString);
|
||||
|
||||
for (auto& [name, locale] : g_locale)
|
||||
{
|
||||
for (auto& [language, value] : locale)
|
||||
GetGlyphs(glyphs, value);
|
||||
}
|
||||
|
||||
for (auto& [language, locale] : g_bool_locale)
|
||||
{
|
||||
for (auto& [value, nameAndDesc] : locale)
|
||||
{
|
||||
GetGlyphs(glyphs, std::get<0>(nameAndDesc));
|
||||
GetGlyphs(glyphs, std::get<1>(nameAndDesc));
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = XDBF_LANGUAGE_ENGLISH; i <= XDBF_LANGUAGE_ITALIAN; i++)
|
||||
{
|
||||
auto achievements = g_xdbfWrapper.GetAchievements(static_cast<EXDBFLanguage>(i));
|
||||
for (auto& achievement : achievements)
|
||||
{
|
||||
GetGlyphs(glyphs, achievement.Name);
|
||||
GetGlyphs(glyphs, achievement.UnlockedDesc);
|
||||
GetGlyphs(glyphs, achievement.LockedDesc);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto glyph : glyphs)
|
||||
{
|
||||
if (g_glyphRanges.empty() || (g_glyphRanges.back() + 1) != glyph)
|
||||
{
|
||||
g_glyphRanges.push_back(glyph);
|
||||
g_glyphRanges.push_back(glyph);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_glyphRanges.back() = glyph;
|
||||
}
|
||||
}
|
||||
|
||||
g_glyphRanges.push_back(0);
|
||||
}
|
||||
|
||||
ImFont* ImFontAtlasSnapshot::GetFont(const char* name, float size)
|
||||
{
|
||||
auto fontAtlas = ImGui::GetIO().Fonts;
|
||||
for (auto& configData : fontAtlas->ConfigData)
|
||||
{
|
||||
if (strstr(configData.Name, name) != nullptr && abs(configData.SizePixels - size) < 0.001f)
|
||||
{
|
||||
assert(configData.DstFont != nullptr);
|
||||
return configData.DstFont;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_IM_FONT_ATLAS_SNAPSHOT
|
||||
assert(false && "Unable to locate equivalent font in the atlas file.");
|
||||
#endif
|
||||
|
||||
return fontAtlas->AddFontFromFileTTF(name, size, nullptr, g_glyphRanges.data());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,3 +30,34 @@ struct ImDrawDataSnapshot
|
|||
ImGuiID GetDrawListID(ImDrawList* src_list) { return ImHashData(&src_list, sizeof(src_list)); } // Hash pointer
|
||||
ImDrawDataSnapshotEntry* GetOrAddEntry(ImDrawList* src_list) { return Cache.GetOrAddByKey(GetDrawListID(src_list)); }
|
||||
};
|
||||
|
||||
// Undefine this to generate a font atlas file in working directory.
|
||||
// You also need to do this if you are testing localization, as only
|
||||
// characters in the locale get added to the atlas.
|
||||
// Don't forget to compress the generated atlas texture to BC4 with no mips!
|
||||
#define ENABLE_IM_FONT_ATLAS_SNAPSHOT
|
||||
|
||||
struct ImFontAtlasSnapshot
|
||||
{
|
||||
std::vector<uint8_t> data;
|
||||
ankerl::unordered_dense::map<const void*, size_t> objects;
|
||||
std::vector<uint32_t> offsets;
|
||||
|
||||
template<typename T1, typename T2>
|
||||
void SnapPointer(size_t offset, const T1& value, const T2& ptr, size_t count);
|
||||
|
||||
template<typename T>
|
||||
void Traverse(size_t offset, const T& value);
|
||||
|
||||
template<typename T>
|
||||
size_t Snap(const T& value);
|
||||
|
||||
void Snap();
|
||||
|
||||
static ImFontAtlas* Load();
|
||||
|
||||
static void GenerateGlyphRanges();
|
||||
|
||||
// When ENABLE_IM_FONT_ATLAS_SNAPSHOT is undefined, this creates the font runtime instead.
|
||||
static ImFont* GetFont(const char* name, float size);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@
|
|||
#include <ui/window.h>
|
||||
#include <user/config.h>
|
||||
|
||||
#include <res/font/im_font_atlas.dds.h>
|
||||
#include <decompressor.h>
|
||||
|
||||
#include <SWA.h>
|
||||
|
||||
#include "../../thirdparty/ShaderRecomp/ShaderRecomp/shader_common.h"
|
||||
|
|
@ -1064,6 +1067,15 @@ static void CreateImGuiBackend()
|
|||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
|
||||
|
||||
#ifdef ENABLE_IM_FONT_ATLAS_SNAPSHOT
|
||||
delete io.Fonts;
|
||||
io.Fonts = ImFontAtlasSnapshot::Load();
|
||||
#else
|
||||
io.Fonts->TexDesiredWidth = 4096;
|
||||
io.Fonts->AddFontDefault();
|
||||
ImFontAtlasSnapshot::GenerateGlyphRanges();
|
||||
#endif
|
||||
|
||||
AchievementMenu::Init();
|
||||
AchievementOverlay::Init();
|
||||
MessageWindow::Init();
|
||||
|
|
@ -1071,6 +1083,12 @@ static void CreateImGuiBackend()
|
|||
|
||||
ImGui_ImplSDL2_InitForOther(Window::s_pWindow);
|
||||
|
||||
RenderComponentMapping componentMapping(RenderSwizzle::ONE, RenderSwizzle::ONE, RenderSwizzle::ONE, RenderSwizzle::R);
|
||||
|
||||
#ifdef ENABLE_IM_FONT_ATLAS_SNAPSHOT
|
||||
g_imFontTexture = LoadTexture(decompressZstd(g_im_font_atlas_texture, g_im_font_atlas_texture_uncompressed_size).get(),
|
||||
g_im_font_atlas_texture_uncompressed_size, componentMapping);
|
||||
#else
|
||||
g_imFontTexture = std::make_unique<GuestTexture>(ResourceType::Texture);
|
||||
|
||||
uint8_t* pixels;
|
||||
|
|
@ -1125,11 +1143,12 @@ static void CreateImGuiBackend()
|
|||
textureViewDesc.format = textureDesc.format;
|
||||
textureViewDesc.dimension = RenderTextureViewDimension::TEXTURE_2D;
|
||||
textureViewDesc.mipLevels = 1;
|
||||
textureViewDesc.componentMapping = RenderComponentMapping(RenderSwizzle::ONE, RenderSwizzle::ONE, RenderSwizzle::ONE, RenderSwizzle::R);
|
||||
textureViewDesc.componentMapping = componentMapping;
|
||||
g_imFontTexture->textureView = g_imFontTexture->texture->createTextureView(textureViewDesc);
|
||||
|
||||
g_imFontTexture->descriptorIndex = g_textureDescriptorAllocator.allocate();
|
||||
g_textureDescriptorSet->setTexture(g_imFontTexture->descriptorIndex, g_imFontTexture->texture, RenderTextureLayout::SHADER_READ, g_imFontTexture->textureView.get());
|
||||
#endif
|
||||
|
||||
io.Fonts->SetTexID(g_imFontTexture.get());
|
||||
|
||||
|
|
@ -1174,6 +1193,32 @@ static void CreateImGuiBackend()
|
|||
pipelineDesc.inputSlots = &inputSlot;
|
||||
pipelineDesc.inputSlotsCount = 1;
|
||||
g_imPipeline = g_device->createGraphicsPipeline(pipelineDesc);
|
||||
|
||||
#ifndef ENABLE_IM_FONT_ATLAS_SNAPSHOT
|
||||
ImFontAtlasSnapshot snapshot;
|
||||
snapshot.Snap();
|
||||
|
||||
FILE* file = fopen("im_font_atlas.bin", "wb");
|
||||
if (file)
|
||||
{
|
||||
fwrite(snapshot.data.data(), 1, snapshot.data.size(), file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
ddspp::Header header;
|
||||
ddspp::HeaderDXT10 headerDX10;
|
||||
ddspp::encode_header(ddspp::R8_UNORM, width, height, 1, ddspp::Texture2D, 1, 1, header, headerDX10);
|
||||
|
||||
file = fopen("im_font_atlas.dds", "wb");
|
||||
if (file)
|
||||
{
|
||||
fwrite(&ddspp::DDS_MAGIC, 4, 1, file);
|
||||
fwrite(&header, sizeof(header), 1, file);
|
||||
fwrite(&headerDX10, sizeof(headerDX10), 1, file);
|
||||
fwrite(pixels, 1, width * height, file);
|
||||
fclose(file);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void CreateHostDevice()
|
||||
|
|
@ -4123,7 +4168,7 @@ static RenderFormat ConvertDXGIFormat(ddspp::DXGIFormat format)
|
|||
}
|
||||
}
|
||||
|
||||
static bool LoadTexture(GuestTexture& texture, uint8_t* data, size_t dataSize)
|
||||
static bool LoadTexture(GuestTexture& texture, uint8_t* data, size_t dataSize, RenderComponentMapping componentMapping)
|
||||
{
|
||||
ddspp::Descriptor ddsDesc;
|
||||
if (ddspp::decode_header(data, ddsDesc) != ddspp::Error)
|
||||
|
|
@ -4146,6 +4191,7 @@ static bool LoadTexture(GuestTexture& texture, uint8_t* data, size_t dataSize)
|
|||
viewDesc.format = desc.format;
|
||||
viewDesc.dimension = ConvertTextureViewDimension(ddsDesc.type);
|
||||
viewDesc.mipLevels = ddsDesc.numMips;
|
||||
viewDesc.componentMapping = componentMapping;
|
||||
texture.textureView = texture.texture->createTextureView(viewDesc);
|
||||
texture.descriptorIndex = g_textureDescriptorAllocator.allocate();
|
||||
g_textureDescriptorSet->setTexture(texture.descriptorIndex, texture.texture, RenderTextureLayout::SHADER_READ, texture.textureView.get());
|
||||
|
|
@ -4287,11 +4333,11 @@ static bool LoadTexture(GuestTexture& texture, uint8_t* data, size_t dataSize)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<GuestTexture> LoadTexture(uint8_t* data, size_t dataSize)
|
||||
std::unique_ptr<GuestTexture> LoadTexture(uint8_t* data, size_t dataSize, RenderComponentMapping componentMapping)
|
||||
{
|
||||
GuestTexture texture(ResourceType::Texture);
|
||||
|
||||
if (LoadTexture(texture, data, dataSize))
|
||||
if (LoadTexture(texture, data, dataSize, componentMapping))
|
||||
return std::make_unique<GuestTexture>(std::move(texture));
|
||||
|
||||
return nullptr;
|
||||
|
|
@ -4303,7 +4349,7 @@ static void MakePictureData(GuestPictureData* pictureData, uint8_t* data, uint32
|
|||
{
|
||||
GuestTexture texture(ResourceType::Texture);
|
||||
|
||||
if (LoadTexture(texture, data, dataSize))
|
||||
if (LoadTexture(texture, data, dataSize, {}))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
texture.texture->setName(reinterpret_cast<char*>(g_memory.Translate(pictureData->name + 2)));
|
||||
|
|
|
|||
|
|
@ -379,6 +379,6 @@ enum GuestTextureAddress
|
|||
D3DTADDRESS_BORDER = 6
|
||||
};
|
||||
|
||||
extern std::unique_ptr<GuestTexture> LoadTexture(uint8_t* data, size_t dataSize);
|
||||
extern std::unique_ptr<GuestTexture> LoadTexture(uint8_t* data, size_t dataSize, RenderComponentMapping componentMapping = RenderComponentMapping());
|
||||
|
||||
extern void VideoConfigValueChangedCallback(class IConfigDef* config);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include <wrl/client.h>
|
||||
#include <smolv.h>
|
||||
#include <print>
|
||||
#include <set>
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <res/images/achievements_menu/trophy.dds.h>
|
||||
#include <res/images/common/general_window.dds.h>
|
||||
#include <res/images/common/select_fill.dds.h>
|
||||
#include <gpu/imgui_snapshot.h>
|
||||
|
||||
constexpr double HEADER_CONTAINER_INTRO_MOTION_START = 0;
|
||||
constexpr double HEADER_CONTAINER_INTRO_MOTION_END = 15;
|
||||
|
|
@ -621,9 +622,9 @@ void AchievementMenu::Init()
|
|||
|
||||
constexpr float FONT_SCALE = 2.0f;
|
||||
|
||||
g_fntSeurat = io.Fonts->AddFontFromFileTTF("FOT-SeuratPro-M.otf", 24.0f * FONT_SCALE);
|
||||
g_fntNewRodinDB = io.Fonts->AddFontFromFileTTF("FOT-NewRodinPro-DB.otf", 20.0f * FONT_SCALE);
|
||||
g_fntNewRodinUB = io.Fonts->AddFontFromFileTTF("FOT-NewRodinPro-UB.otf", 20.0f * FONT_SCALE);
|
||||
g_fntSeurat = ImFontAtlasSnapshot::GetFont("FOT-SeuratPro-M.otf", 24.0f * FONT_SCALE);
|
||||
g_fntNewRodinDB = ImFontAtlasSnapshot::GetFont("FOT-NewRodinPro-DB.otf", 20.0f * FONT_SCALE);
|
||||
g_fntNewRodinUB = ImFontAtlasSnapshot::GetFont("FOT-NewRodinPro-UB.otf", 20.0f * FONT_SCALE);
|
||||
|
||||
g_upTrophyIcon = LoadTexture(decompressZstd(g_trophy, g_trophy_uncompressed_size).get(), g_trophy_uncompressed_size);
|
||||
g_upSelectionCursor = LoadTexture(decompressZstd(g_select_fill, g_select_fill_uncompressed_size).get(), g_select_fill_uncompressed_size);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <exports.h>
|
||||
#include <decompressor.h>
|
||||
#include <res/images/common/general_window.dds.h>
|
||||
#include <gpu/imgui_snapshot.h>
|
||||
|
||||
constexpr double OVERLAY_CONTAINER_COMMON_MOTION_START = 0;
|
||||
constexpr double OVERLAY_CONTAINER_COMMON_MOTION_END = 11;
|
||||
|
|
@ -77,7 +78,7 @@ void AchievementOverlay::Init()
|
|||
|
||||
constexpr float FONT_SCALE = 2.0f;
|
||||
|
||||
g_fntSeurat = io.Fonts->AddFontFromFileTTF("FOT-SeuratPro-M.otf", 24.0f * FONT_SCALE);
|
||||
g_fntSeurat = ImFontAtlasSnapshot::GetFont("FOT-SeuratPro-M.otf", 24.0f * FONT_SCALE);
|
||||
|
||||
g_upWindow = LoadTexture(decompressZstd(g_general_window, g_general_window_uncompressed_size).get(), g_general_window_uncompressed_size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <exports.h>
|
||||
#include <decompressor.h>
|
||||
#include <res/images/common/select_fade.dds.h>
|
||||
#include <gpu/imgui_snapshot.h>
|
||||
|
||||
constexpr double OVERLAY_CONTAINER_COMMON_MOTION_START = 0;
|
||||
constexpr double OVERLAY_CONTAINER_COMMON_MOTION_END = 11;
|
||||
|
|
@ -175,7 +176,7 @@ void MessageWindow::Init()
|
|||
|
||||
constexpr float FONT_SCALE = 2.0f;
|
||||
|
||||
g_fntSeurat = io.Fonts->AddFontFromFileTTF("FOT-SeuratPro-M.otf", 28.0f * FONT_SCALE);
|
||||
g_fntSeurat = ImFontAtlasSnapshot::GetFont("FOT-SeuratPro-M.otf", 24.0f * FONT_SCALE);
|
||||
|
||||
g_upSelectionCursor = LoadTexture(decompressZstd(g_select_fade, g_select_fade_uncompressed_size).get(), g_select_fade_uncompressed_size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <api/SWA/System/InputState.h>
|
||||
#include <gpu/imgui_common.h>
|
||||
#include <gpu/video.h>
|
||||
#include <gpu/imgui_snapshot.h>
|
||||
#include <kernel/heap.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <locale/locale.h>
|
||||
|
|
@ -975,9 +976,9 @@ void OptionsMenu::Init()
|
|||
|
||||
constexpr float FONT_SCALE = 2.0f;
|
||||
|
||||
g_seuratFont = io.Fonts->AddFontFromFileTTF("FOT-SeuratPro-M.otf", 26.0f * FONT_SCALE);
|
||||
g_dfsogeistdFont = io.Fonts->AddFontFromFileTTF("DFSoGeiStd-W7.otf", 48.0f * FONT_SCALE);
|
||||
g_newRodinFont = io.Fonts->AddFontFromFileTTF("FOT-NewRodinPro-DB.otf", 20.0f * FONT_SCALE);
|
||||
g_seuratFont = ImFontAtlasSnapshot::GetFont("FOT-SeuratPro-M.otf", 24.0f * FONT_SCALE);
|
||||
g_dfsogeistdFont = ImFontAtlasSnapshot::GetFont("DFSoGeiStd-W7.otf", 48.0f * FONT_SCALE);
|
||||
g_newRodinFont = ImFontAtlasSnapshot::GetFont("FOT-NewRodinPro-DB.otf", 20.0f * FONT_SCALE);
|
||||
}
|
||||
|
||||
void OptionsMenu::Draw()
|
||||
|
|
|
|||
|
|
@ -163,3 +163,28 @@ std::string ConfigDef<T>::GetValueDescription() const
|
|||
|
||||
return std::get<1>(strings.at(Value));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void ConfigDef<T>::GetLocaleStrings(std::vector<std::string_view>& localeStrings) const
|
||||
{
|
||||
if (Locale != nullptr)
|
||||
{
|
||||
for (auto& [language, nameAndDesc] : *Locale)
|
||||
{
|
||||
localeStrings.push_back(std::get<0>(nameAndDesc));
|
||||
localeStrings.push_back(std::get<1>(nameAndDesc));
|
||||
}
|
||||
}
|
||||
|
||||
if (EnumLocale != nullptr)
|
||||
{
|
||||
for (auto& [language, locale] : *EnumLocale)
|
||||
{
|
||||
for (auto& [value, nameAndDesc] : locale)
|
||||
{
|
||||
localeStrings.push_back(std::get<0>(nameAndDesc));
|
||||
localeStrings.push_back(std::get<1>(nameAndDesc));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ public:
|
|||
virtual std::string GetValueDescription() const = 0;
|
||||
virtual std::string GetDefinition(bool withSection = false) const = 0;
|
||||
virtual std::string ToString(bool strWithQuotes = true) const = 0;
|
||||
virtual void GetLocaleStrings(std::vector<std::string_view>& localeStrings) const = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -232,12 +233,12 @@ class ConfigDef : public IConfigDef
|
|||
public:
|
||||
std::string Section{};
|
||||
std::string Name{};
|
||||
CONFIG_LOCALE* Locale;
|
||||
CONFIG_LOCALE* Locale{};
|
||||
T DefaultValue{};
|
||||
T Value{ DefaultValue };
|
||||
std::unordered_map<std::string, T>* EnumTemplate;
|
||||
std::map<T, std::string> EnumTemplateReverse{};
|
||||
CONFIG_ENUM_LOCALE(T)* EnumLocale;
|
||||
CONFIG_ENUM_LOCALE(T)* EnumLocale{};
|
||||
std::function<void(ConfigDef<T>*)> Callback;
|
||||
|
||||
// CONFIG_DEFINE
|
||||
|
|
@ -350,6 +351,8 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
void GetLocaleStrings(std::vector<std::string_view>& localeStrings) const override;
|
||||
|
||||
ConfigDef& operator=(const ConfigDef& other)
|
||||
{
|
||||
if (this != &other)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 5b5ad2794a2c78d50dc6a85e71954fb6b9e80ae2
|
||||
Subproject commit 96cbb00e929c3731e01685a7352f59a417d606a4
|
||||
Loading…
Add table
Reference in a new issue