mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
ImGui: Add TTF font support
We use the Roboto font that we're already shipping for now, although, we could also support other fonts or have a setting.
This commit is contained in:
parent
21ffc37ebd
commit
c529743e4a
@ -27,7 +27,7 @@ using namespace std::placeholders;
|
|||||||
#include "Common/Render/Text/draw_text.h"
|
#include "Common/Render/Text/draw_text.h"
|
||||||
#include "Common/File/FileUtil.h"
|
#include "Common/File/FileUtil.h"
|
||||||
#include "Common/Battery/Battery.h"
|
#include "Common/Battery/Battery.h"
|
||||||
|
#include "Common/File/VFS/VFS.h"
|
||||||
#include "Common/UI/Root.h"
|
#include "Common/UI/Root.h"
|
||||||
#include "Common/UI/UI.h"
|
#include "Common/UI/UI.h"
|
||||||
#include "Common/UI/Context.h"
|
#include "Common/UI/Context.h"
|
||||||
@ -1646,7 +1646,13 @@ void EmuScreen::renderImDebugger() {
|
|||||||
if (!imguiInited_) {
|
if (!imguiInited_) {
|
||||||
imguiInited_ = true;
|
imguiInited_ = true;
|
||||||
imDebugger_ = std::make_unique<ImDebugger>();
|
imDebugger_ = std::make_unique<ImDebugger>();
|
||||||
ImGui_ImplThin3d_Init(draw);
|
|
||||||
|
// Read the TTF font
|
||||||
|
size_t size = 0;
|
||||||
|
uint8_t *fontData = g_VFS.ReadFile("Roboto-Condensed.ttf", &size);
|
||||||
|
// This call works even if fontData is nullptr, in which case the font just won't get loaded.
|
||||||
|
// This takes ownership of the font array.
|
||||||
|
ImGui_ImplThin3d_Init(draw, fontData, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PSP_IsInited()) {
|
if (PSP_IsInited()) {
|
||||||
|
@ -371,7 +371,6 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug) {
|
|||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginMenu("Window")) {
|
if (ImGui::BeginMenu("Window")) {
|
||||||
ImGui::Checkbox("Dear ImGUI Demo", &cfg_.demoOpen);
|
|
||||||
ImGui::Checkbox("CPU debugger", &cfg_.disasmOpen);
|
ImGui::Checkbox("CPU debugger", &cfg_.disasmOpen);
|
||||||
ImGui::Checkbox("Registers", &cfg_.regsOpen);
|
ImGui::Checkbox("Registers", &cfg_.regsOpen);
|
||||||
ImGui::Checkbox("Callstacks", &cfg_.callstackOpen);
|
ImGui::Checkbox("Callstacks", &cfg_.callstackOpen);
|
||||||
@ -382,6 +381,8 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug) {
|
|||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginMenu("Misc")) {
|
if (ImGui::BeginMenu("Misc")) {
|
||||||
|
ImGui::Checkbox("Dear ImGui Demo", &cfg_.demoOpen);
|
||||||
|
ImGui::Checkbox("ImGui Style editor", &cfg_.styleEditorOpen);
|
||||||
if (ImGui::MenuItem("Close Debugger")) {
|
if (ImGui::MenuItem("Close Debugger")) {
|
||||||
g_Config.bShowImDebugger = false;
|
g_Config.bShowImDebugger = false;
|
||||||
}
|
}
|
||||||
@ -394,6 +395,10 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug) {
|
|||||||
ImGui::ShowDemoWindow(&cfg_.demoOpen);
|
ImGui::ShowDemoWindow(&cfg_.demoOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg_.styleEditorOpen) {
|
||||||
|
ImGui::ShowStyleEditor();
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg_.disasmOpen) {
|
if (cfg_.disasmOpen) {
|
||||||
disasm_.Draw(mipsDebug, &cfg_.disasmOpen, coreState);
|
disasm_.Draw(mipsDebug, &cfg_.disasmOpen, coreState);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ struct ImConfig {
|
|||||||
bool hleModulesOpen = false;
|
bool hleModulesOpen = false;
|
||||||
bool atracOpen = true;
|
bool atracOpen = true;
|
||||||
bool structViewerOpen = false;
|
bool structViewerOpen = false;
|
||||||
|
bool styleEditorOpen = false;
|
||||||
|
|
||||||
// HLE explorer settings
|
// HLE explorer settings
|
||||||
// bool filterByUsed = true;
|
// bool filterByUsed = true;
|
||||||
|
@ -217,8 +217,16 @@ void ImGui_ImplThin3d_DestroyDeviceObjects() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw) {
|
bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw, const uint8_t *ttf_font, size_t size) {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if (ttf_font) {
|
||||||
|
io.Fonts->AddFontFromMemoryTTF((void *)ttf_font, size, 18.0f * g_display.dpi_scale_x, nullptr, io.Fonts->GetGlyphRangesDefault());
|
||||||
|
} else {
|
||||||
|
// necessary?
|
||||||
|
io.Fonts->AddFontDefault();
|
||||||
|
}
|
||||||
|
ImGui::GetStyle().ScaleAllSizes(g_display.dpi_scale_x);
|
||||||
|
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
#include "Common/GPU/thin3d.h"
|
#include "Common/GPU/thin3d.h"
|
||||||
#include "Common/Math/lin/matrix4x4.h"
|
#include "Common/Math/lin/matrix4x4.h"
|
||||||
|
|
||||||
// Called by user code
|
// Called by user code. Takes ownership of the font buffer and later deletes it.
|
||||||
IMGUI_IMPL_API bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw);
|
IMGUI_IMPL_API bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw, const uint8_t *ttf_font, size_t size);
|
||||||
IMGUI_IMPL_API void ImGui_ImplThin3d_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplThin3d_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplThin3d_NewFrame(Draw::DrawContext *draw, Lin::Matrix4x4 drawMatrix);
|
IMGUI_IMPL_API void ImGui_ImplThin3d_NewFrame(Draw::DrawContext *draw, Lin::Matrix4x4 drawMatrix);
|
||||||
IMGUI_IMPL_API void ImGui_ImplThin3d_RenderDrawData(ImDrawData* draw_data, Draw::DrawContext *draw);
|
IMGUI_IMPL_API void ImGui_ImplThin3d_RenderDrawData(ImDrawData* draw_data, Draw::DrawContext *draw);
|
||||||
|
2
ext/lua
2
ext/lua
@ -1 +1 @@
|
|||||||
Subproject commit f3271af11ab8591164b871e36520a7210964f3f6
|
Subproject commit 7648485f14e8e5ee45e8e39b1eb4d3206dbd405a
|
Loading…
Reference in New Issue
Block a user