switch ttf file for preparing chinese UI

pull/2/head
ink-soul 2023-06-12 09:18:05 +08:00
parent befeda7cff
commit 0ba1c93ff4
3 changed files with 37 additions and 8 deletions

View File

@ -67,7 +67,7 @@ public:
io.Fonts->AddFontFromMemoryTTF(fontAsset, size, 14.0f * scale);
delete[] fontAsset;
#else
std::string ttfFilePath = getAssetPath() + "/Roboto-Medium.ttf";
std::string ttfFilePath = getAssetPath() + "/STXINWEI.TTF";
io.Fonts->AddFontFromFileTTF(ttfFilePath.data(), 16.0f);
#endif
io.Fonts->GetTexDataAsRGBA32(&fontData, &texWidth, &texHeight);
@ -248,7 +248,24 @@ public:
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
vkDestroyDescriptorPool(device, descriptorPool, nullptr);
}
std::string string_to_utf8(const std::string& str)
{
int nwLen = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
wchar_t* pwBuf = new wchar_t[nwLen + 1];
memset(pwBuf, 0, nwLen * 2 + 2);
MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen);
int nLen = WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
char* pBuf = new char[nLen + 1];
memset(pBuf, 0, nLen + 1);
WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
std::string ret = pBuf;
delete[]pwBuf;
delete[]pBuf;
return ret;
}
void draw(VkCommandBuffer cmdBuffer) {
vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
vkCmdBindDescriptorSets(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);

View File

@ -1680,8 +1680,8 @@ PlumageRender::PlumageRender()
gui->text("%.1d fps (%.2f ms)", lastFPS, (1000.0f / lastFPS));
if (gui->header("Scene")) {
if (gui->button("Open gltf file")) {
if (gui->header("model")) {
if (gui->button(gui->string_to_utf8("open gltf model").c_str())) {
std::string filename = "";
char buffer[MAX_PATH];
OPENFILENAME ofn;
@ -1726,11 +1726,11 @@ PlumageRender::PlumageRender()
}
}
if (gui->header("Debug view")) {
if (gui->header("Debug ")) {
const std::vector<std::string> debugNamesInputs = {
"none", "Base color", "Normal", "Occlusion", "Emissive", "Metallic", "Roughness"
};
if (gui->combo("Inputs", &debugViewInputs, debugNamesInputs)) {
if (gui->combo("input", &debugViewInputs, debugNamesInputs)) {
shaderData.debugViewInputs = static_cast<float>(debugViewInputs);
updateShaderParams = true;
}
@ -1744,13 +1744,13 @@ PlumageRender::PlumageRender()
}
if (models.scene.animations.size() > 0) {
if (gui->header("Animations")) {
gui->checkbox("Animate", &animate);
if (gui->header("animation")) {
gui->checkbox("pause", &animate);
std::vector<std::string> animationNames;
for (auto animation : models.scene.animations) {
animationNames.push_back(animation.name);
}
gui->combo("Animation", &animationIndex, animationNames);
gui->combo("animation", &animationIndex, animationNames);
}
}

View File

@ -60,7 +60,19 @@ public:
float debugViewInputs = 0;
float debugViewEquation = 0;
} shaderData;
struct ChinesesUI
{
const char * model = "u8模型";
const char* openNewModel = "打开gltf模型";
const char* environmentMap = "环境贴图";
const char* environment = "环境光照";
const char* debugInput = "输入";
const char* debugPBREquation = "PBR计算参数";
const char* animation = "动画";
const char* pauseAnimation = "暂停动画";
const char* animationSeq = "动画序列";
}chineseUI;
struct UniformBufferSet {
Buffer scene;
Buffer skybox;