switch ttf file for preparing chinese UI
parent
befeda7cff
commit
0ba1c93ff4
19
base/ui.hpp
19
base/ui.hpp
|
@ -67,7 +67,7 @@ public:
|
||||||
io.Fonts->AddFontFromMemoryTTF(fontAsset, size, 14.0f * scale);
|
io.Fonts->AddFontFromMemoryTTF(fontAsset, size, 14.0f * scale);
|
||||||
delete[] fontAsset;
|
delete[] fontAsset;
|
||||||
#else
|
#else
|
||||||
std::string ttfFilePath = getAssetPath() + "/Roboto-Medium.ttf";
|
std::string ttfFilePath = getAssetPath() + "/STXINWEI.TTF";
|
||||||
io.Fonts->AddFontFromFileTTF(ttfFilePath.data(), 16.0f);
|
io.Fonts->AddFontFromFileTTF(ttfFilePath.data(), 16.0f);
|
||||||
#endif
|
#endif
|
||||||
io.Fonts->GetTexDataAsRGBA32(&fontData, &texWidth, &texHeight);
|
io.Fonts->GetTexDataAsRGBA32(&fontData, &texWidth, &texHeight);
|
||||||
|
@ -248,7 +248,24 @@ public:
|
||||||
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
|
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
|
||||||
vkDestroyDescriptorPool(device, descriptorPool, 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) {
|
void draw(VkCommandBuffer cmdBuffer) {
|
||||||
vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||||
vkCmdBindDescriptorSets(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
|
vkCmdBindDescriptorSets(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
|
||||||
|
|
|
@ -1680,8 +1680,8 @@ PlumageRender::PlumageRender()
|
||||||
|
|
||||||
gui->text("%.1d fps (%.2f ms)", lastFPS, (1000.0f / lastFPS));
|
gui->text("%.1d fps (%.2f ms)", lastFPS, (1000.0f / lastFPS));
|
||||||
|
|
||||||
if (gui->header("Scene")) {
|
if (gui->header("model")) {
|
||||||
if (gui->button("Open gltf file")) {
|
if (gui->button(gui->string_to_utf8("open gltf model").c_str())) {
|
||||||
std::string filename = "";
|
std::string filename = "";
|
||||||
char buffer[MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
|
@ -1726,11 +1726,11 @@ PlumageRender::PlumageRender()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gui->header("Debug view")) {
|
if (gui->header("Debug ")) {
|
||||||
const std::vector<std::string> debugNamesInputs = {
|
const std::vector<std::string> debugNamesInputs = {
|
||||||
"none", "Base color", "Normal", "Occlusion", "Emissive", "Metallic", "Roughness"
|
"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);
|
shaderData.debugViewInputs = static_cast<float>(debugViewInputs);
|
||||||
updateShaderParams = true;
|
updateShaderParams = true;
|
||||||
}
|
}
|
||||||
|
@ -1744,13 +1744,13 @@ PlumageRender::PlumageRender()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (models.scene.animations.size() > 0) {
|
if (models.scene.animations.size() > 0) {
|
||||||
if (gui->header("Animations")) {
|
if (gui->header("animation")) {
|
||||||
gui->checkbox("Animate", &animate);
|
gui->checkbox("pause", &animate);
|
||||||
std::vector<std::string> animationNames;
|
std::vector<std::string> animationNames;
|
||||||
for (auto animation : models.scene.animations) {
|
for (auto animation : models.scene.animations) {
|
||||||
animationNames.push_back(animation.name);
|
animationNames.push_back(animation.name);
|
||||||
}
|
}
|
||||||
gui->combo("Animation", &animationIndex, animationNames);
|
gui->combo("animation", &animationIndex, animationNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,19 @@ public:
|
||||||
float debugViewInputs = 0;
|
float debugViewInputs = 0;
|
||||||
float debugViewEquation = 0;
|
float debugViewEquation = 0;
|
||||||
} shaderData;
|
} 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 {
|
struct UniformBufferSet {
|
||||||
Buffer scene;
|
Buffer scene;
|
||||||
Buffer skybox;
|
Buffer skybox;
|
||||||
|
|
Loading…
Reference in New Issue