mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-10-11 21:49:59 +00:00
Upstreaming imgui (#4960)
* added imgui upstream and updated ImGuiFileDialog with a needed update * cmake fix * update ImGuiChildFlags ,ImGuiWindowFlags in latest imgui * revert to recheck * big picture flags * fixed texture descriptor * migrated layer_extra to latest imgui * updated text_editor to latest imgui
This commit is contained in:
+4
-5
@@ -66,11 +66,6 @@
|
||||
path = externals/half
|
||||
url = https://github.com/ROCm/half.git
|
||||
shallow = true
|
||||
[submodule "externals/dear_imgui"]
|
||||
path = externals/dear_imgui
|
||||
url = https://github.com/shadps4-emu/ext-imgui.git
|
||||
shallow = true
|
||||
branch = docking
|
||||
[submodule "externals/pugixml"]
|
||||
path = externals/pugixml
|
||||
url = https://github.com/zeux/pugixml.git
|
||||
@@ -167,3 +162,7 @@
|
||||
[submodule "externals/abseil-cpp"]
|
||||
path = externals/abseil-cpp
|
||||
url = https://github.com/abseil/abseil-cpp.git
|
||||
[submodule "externals/imgui"]
|
||||
path = externals/imgui
|
||||
url = https://github.com/shadexternals/imgui.git
|
||||
branch = docking
|
||||
|
||||
Vendored
+7
-7
@@ -184,14 +184,14 @@ endif()
|
||||
|
||||
# Dear ImGui
|
||||
add_library(Dear_ImGui
|
||||
dear_imgui/imgui.cpp
|
||||
dear_imgui/imgui_demo.cpp
|
||||
dear_imgui/imgui_draw.cpp
|
||||
dear_imgui/imgui_internal.h
|
||||
dear_imgui/imgui_tables.cpp
|
||||
dear_imgui/imgui_widgets.cpp
|
||||
imgui/imgui.cpp
|
||||
imgui/imgui_demo.cpp
|
||||
imgui/imgui_draw.cpp
|
||||
imgui/imgui_internal.h
|
||||
imgui/imgui_tables.cpp
|
||||
imgui/imgui_widgets.cpp
|
||||
)
|
||||
target_include_directories(Dear_ImGui INTERFACE dear_imgui/)
|
||||
target_include_directories(Dear_ImGui INTERFACE imgui/)
|
||||
|
||||
# Tracy
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
|
||||
Vendored
+1
-1
Submodule externals/ImGuiFileDialog updated: 6e3ddeb485...57a1c6a6d4
Vendored
-1
Submodule externals/dear_imgui deleted from f4d9359095
+1
Submodule externals/imgui added at 7e1b65d26d
@@ -14,7 +14,6 @@
|
||||
namespace Core::Devtools {
|
||||
|
||||
void Layer::DrawNullGpuNotice() {
|
||||
|
||||
auto* window = ImGui::GetCurrentWindow();
|
||||
if (window->SkipItems) {
|
||||
return;
|
||||
@@ -24,25 +23,25 @@ void Layer::DrawNullGpuNotice() {
|
||||
constexpr std::string_view detailsNotice =
|
||||
"Disable the nullGpu config to show the game display";
|
||||
|
||||
auto displaySize = window->Size;
|
||||
|
||||
ImVec2 targetSize = displaySize * 0.7f;
|
||||
const ImVec2 displaySize = window->Size;
|
||||
const ImVec2 targetSize = displaySize * 0.7f;
|
||||
|
||||
float minFontSize = 1.0f;
|
||||
float maxFontSize = 200.0f;
|
||||
float optimalFontSize = minFontSize;
|
||||
|
||||
static auto lastSize = ImVec2(-1, -1);
|
||||
static ImVec2 lastSize(-1.0f, -1.0f);
|
||||
static float lastFontSize = -1.0f;
|
||||
|
||||
auto* font = ImGui::GetIO().Fonts->Fonts[IMGUI_FONT_TEXT_BIG];
|
||||
|
||||
if (lastSize != targetSize) {
|
||||
while (maxFontSize - minFontSize > 0.1f) {
|
||||
float testFontSize = (minFontSize + maxFontSize) / 2.0f;
|
||||
const float testFontSize = (minFontSize + maxFontSize) / 2.0f;
|
||||
|
||||
ImVec2 textSize = font->CalcTextSizeA(testFontSize, FLT_MAX, 0.0f, &mainNotice.front(),
|
||||
&mainNotice.back() + 1);
|
||||
const ImVec2 textSize =
|
||||
font->CalcTextSizeA(testFontSize, FLT_MAX, 0.0f, mainNotice.data(),
|
||||
mainNotice.data() + mainNotice.size());
|
||||
|
||||
if (textSize.x <= targetSize.x && textSize.y <= targetSize.y) {
|
||||
optimalFontSize = testFontSize;
|
||||
@@ -51,45 +50,59 @@ void Layer::DrawNullGpuNotice() {
|
||||
maxFontSize = testFontSize;
|
||||
}
|
||||
}
|
||||
|
||||
lastSize = targetSize;
|
||||
lastFontSize = optimalFontSize;
|
||||
} else {
|
||||
optimalFontSize = lastFontSize;
|
||||
}
|
||||
ImVec2 textSize = font->CalcTextSizeA(optimalFontSize, FLT_MAX, 0.0f, &mainNotice.front(),
|
||||
&mainNotice.back() + 1);
|
||||
|
||||
ImVec2 textSize = font->CalcTextSizeA(optimalFontSize, FLT_MAX, 0.0f, mainNotice.data(),
|
||||
mainNotice.data() + mainNotice.size());
|
||||
|
||||
ImVec2 textPos = (displaySize - textSize) * 0.5f + window->Pos;
|
||||
|
||||
const float scale = optimalFontSize / font->FontSize;
|
||||
// Glyph metrics are now stored in the size-specific baked font.
|
||||
ImFontBaked* baked = font->GetFontBaked(optimalFontSize);
|
||||
|
||||
double timeAnim = -std::numbers::pi * ImGui::GetTime();
|
||||
int i = 0;
|
||||
|
||||
for (auto ch : mainNotice) {
|
||||
double colorTime = sin(timeAnim + i * std::numbers::pi / 6.0) / 2.0 + 0.5;
|
||||
int color = (int)(200 * colorTime) + 55;
|
||||
const double colorTime = sin(timeAnim + i * std::numbers::pi / 6.0) / 2.0 + 0.5;
|
||||
|
||||
double posTime = sin(timeAnim + i * std::numbers::pi / 15.0) / 2.0 + 0.5;
|
||||
const int color = static_cast<int>(200 * colorTime) + 55;
|
||||
|
||||
const double posTime = sin(timeAnim + i * std::numbers::pi / 15.0) / 2.0 + 0.5;
|
||||
|
||||
ImVec2 pos = textPos;
|
||||
|
||||
auto pos = textPos;
|
||||
pos.y += 10.0 * (posTime < 0.5 ? std::pow(2.0, 20.0 * posTime - 10.0) / 2.0
|
||||
: (2.0 - std::pow(2.0, -20.0 * posTime + 10.0)) / 2.0);
|
||||
|
||||
window->DrawList->AddText(font, optimalFontSize, pos, IM_COL32(color, color, color, 255),
|
||||
&ch, &ch + 1);
|
||||
textPos.x += font->FindGlyph(ch)->AdvanceX * scale;
|
||||
i++;
|
||||
|
||||
// GetCharAdvance() is now on ImFontBaked and is already
|
||||
// scaled for optimalFontSize. No LegacySize scale needed.
|
||||
textPos.x += baked->GetCharAdvance(ch);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
font = ImGui::GetIO().Fonts->Fonts[IMGUI_FONT_TEXT];
|
||||
|
||||
textPos.y += textSize.y + 1.0;
|
||||
textPos.y += textSize.y + 1.0f;
|
||||
|
||||
optimalFontSize *= 0.2f;
|
||||
|
||||
textSize = font->CalcTextSizeA(optimalFontSize, FLT_MAX, 0.0f, detailsNotice.data(),
|
||||
detailsNotice.data() + detailsNotice.size());
|
||||
|
||||
optimalFontSize *= 0.2;
|
||||
textSize = font->CalcTextSizeA(optimalFontSize, FLT_MAX, 0.0f, &detailsNotice.front(),
|
||||
&detailsNotice.back() + 1);
|
||||
textPos.x = window->Pos.x + (window->Size.x - textSize.x) * 0.5f;
|
||||
|
||||
window->DrawList->AddText(font, optimalFontSize, textPos, IM_COL32(200, 200, 200, 255),
|
||||
&detailsNotice.front(), &detailsNotice.back() + 1);
|
||||
detailsNotice.data(), detailsNotice.data() + detailsNotice.size());
|
||||
}
|
||||
|
||||
} // namespace Core::Devtools
|
||||
|
||||
@@ -1047,16 +1047,24 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder) {
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
||||
ImGui::ColorConvertU32ToFloat4(mPalette[(int)PaletteIndex::Background]));
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
|
||||
if (!mIgnoreImGuiChild)
|
||||
ImGui::BeginChild(aTitle, aSize, aBorder,
|
||||
ImGuiWindowFlags_HorizontalScrollbar |
|
||||
ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoNav);
|
||||
|
||||
if (!mIgnoreImGuiChild) {
|
||||
ImGuiChildFlags child_flags = 0;
|
||||
|
||||
if (aBorder)
|
||||
child_flags |= ImGuiChildFlags_Borders;
|
||||
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar |
|
||||
ImGuiWindowFlags_AlwaysHorizontalScrollbar |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav;
|
||||
|
||||
ImGui::BeginChild(aTitle, aSize, child_flags, window_flags);
|
||||
}
|
||||
|
||||
if (mHandleKeyboardInputs) {
|
||||
HandleKeyboardInputs();
|
||||
ImGui::PushAllowKeyboardFocus(true);
|
||||
}
|
||||
|
||||
if (mHandleMouseInputs)
|
||||
@@ -1065,8 +1073,7 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder) {
|
||||
ColorizeInternal();
|
||||
Render();
|
||||
|
||||
if (mHandleKeyboardInputs)
|
||||
ImGui::PopAllowKeyboardFocus();
|
||||
// PopAllowKeyboardFocus() removed.
|
||||
|
||||
if (!mIgnoreImGuiChild)
|
||||
ImGui::EndChild();
|
||||
|
||||
@@ -310,6 +310,7 @@ void Launch(char* executableName, bool sameProcess) {
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(viewport->WorkPos);
|
||||
ImGui::SetNextWindowSize(viewport->WorkSize);
|
||||
|
||||
ImGuiWindowFlags window_flags =
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollWithMouse;
|
||||
|
||||
@@ -317,15 +318,18 @@ void Launch(char* executableName, bool sameProcess) {
|
||||
ImGui::DrawPrettyBackground();
|
||||
ImGui::SetWindowFontScale(uiScale);
|
||||
|
||||
ImGuiWindowFlags child_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NavFlattened;
|
||||
ImGuiChildFlags child_flags = ImGuiChildFlags_Borders | ImGuiChildFlags_NavFlattened;
|
||||
|
||||
ImGuiWindowFlags child_window_flags =
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse;
|
||||
|
||||
if (ImGui::IsWindowAppearing()) {
|
||||
ImGui::SetNextWindowFocus();
|
||||
}
|
||||
|
||||
ImGui::BeginChild("ContentRegion", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()), true,
|
||||
child_flags);
|
||||
ImGui::BeginChild("ContentRegion", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()),
|
||||
child_flags, child_window_flags);
|
||||
|
||||
Overlay::TextCentered("Select Game");
|
||||
ImGui::Dummy(ImVec2(0.0f, 10.f * uiScale));
|
||||
|
||||
|
||||
@@ -319,11 +319,13 @@ void SettingsWindow::DrawCategoryTabs() {
|
||||
|
||||
float vertSize = (settingsIconSize * uiScale + ImGui::CalcTextSize("Profiles").y) +
|
||||
ImGui::GetStyle().FramePadding.y * 4.f + 20.0 * uiScale;
|
||||
ImGuiWindowFlags child_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NavFlattened;
|
||||
ImGui::BeginChild("Categories", ImVec2(0, vertSize), true,
|
||||
child_flags | ImGuiWindowFlags_HorizontalScrollbar |
|
||||
ImGuiWindowFlags_NoScrollWithMouse);
|
||||
ImGuiChildFlags child_flags = ImGuiChildFlags_Borders | ImGuiChildFlags_NavFlattened;
|
||||
|
||||
ImGuiWindowFlags window_flags =
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
||||
|
||||
ImGui::BeginChild("Categories", ImVec2(0, vertSize), child_flags, window_flags);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(30.0f * uiScale, 0.0f));
|
||||
|
||||
@@ -386,8 +388,6 @@ void SettingsWindow::AddCategory(std::string name,
|
||||
void SettingsWindow::DrawMainContent(bool* open, const std::function<void()>& applySettings) {
|
||||
ImVec4 settingsColor = ImVec4(0.1f, 0.1f, 0.12f, 0.8f); // Darker gray
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, settingsColor);
|
||||
ImGuiWindowFlags child_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NavFlattened;
|
||||
|
||||
std::string centeredText;
|
||||
currentCategory == SettingsCategory::Folders
|
||||
@@ -478,16 +478,20 @@ void SettingsWindow::DrawMainContent(bool* open, const std::function<void()>& ap
|
||||
}
|
||||
|
||||
void SettingsWindow::DrawProfileSelector() {
|
||||
ImGuiWindowFlags child_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NavFlattened;
|
||||
ImGuiChildFlags child_flags = ImGuiChildFlags_Borders | ImGuiChildFlags_NavFlattened;
|
||||
|
||||
ImGuiWindowFlags window_flags =
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse;
|
||||
|
||||
ImVec4 settingsColor = ImVec4(0.1f, 0.1f, 0.12f, 0.8f); // Darker gray
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, settingsColor);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f);
|
||||
|
||||
ImGui::BeginChild("Profile Selection", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()), true,
|
||||
child_flags);
|
||||
ImGui::BeginChild("Profile Selection", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()),
|
||||
child_flags, window_flags);
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
if (ImGui::BeginTable("ProfilesTable", 2, ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders)) {
|
||||
@@ -582,10 +586,13 @@ void SettingsWindow::DrawProfileSelector() {
|
||||
}
|
||||
|
||||
void SettingsWindow::DrawGameFolderManager() {
|
||||
ImGuiWindowFlags child_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NavFlattened;
|
||||
ImGui::BeginChild("ContentRegion", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()), true,
|
||||
child_flags);
|
||||
ImGuiChildFlags child_flags = ImGuiChildFlags_Borders | ImGuiChildFlags_NavFlattened;
|
||||
|
||||
ImGuiWindowFlags window_flags =
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse;
|
||||
|
||||
ImGui::BeginChild("ContentRegion", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()), child_flags,
|
||||
window_flags);
|
||||
|
||||
if (ImGui::Button("Add Folder", ImVec2(400.f * uiScale, 0))) {
|
||||
ImGuiFileDialog::Instance()->OpenDialog("OpenFolder", "Add shadPS4 game folder", nullptr,
|
||||
@@ -665,11 +672,15 @@ void SettingsWindow::DrawGameFolderManager() {
|
||||
|
||||
void SettingsWindow::DrawSettingsTable(SettingsCategory category) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4.0f * uiScale, 10.0f * uiScale));
|
||||
ImGuiWindowFlags child_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NavFlattened;
|
||||
ImGuiChildFlags child_flags = ImGuiChildFlags_Borders | ImGuiChildFlags_NavFlattened;
|
||||
|
||||
ImGui::BeginChild("ContentRegion", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()), true,
|
||||
child_flags);
|
||||
ImGuiWindowFlags window_flags =
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4.0f * uiScale, 10.0f * uiScale));
|
||||
|
||||
ImGui::BeginChild("ContentRegion", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()), child_flags,
|
||||
window_flags);
|
||||
|
||||
if (category == SettingsCategory::General) {
|
||||
if (ImGui::BeginTable("SettingsTable", 2)) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
project(ImGui_Resources)
|
||||
|
||||
add_executable(Dear_ImGui_FontEmbed ${CMAKE_SOURCE_DIR}/externals/dear_imgui/misc/fonts/binary_to_compressed_c.cpp)
|
||||
add_executable(Dear_ImGui_FontEmbed ${CMAKE_SOURCE_DIR}/externals/imgui/misc/fonts/binary_to_compressed_c.cpp)
|
||||
|
||||
set(FONT_LIST
|
||||
NotoSansArabic-Regular.ttf
|
||||
|
||||
@@ -684,7 +684,7 @@ void RenderDrawData(ImDrawData& draw_data, vk::CommandBuffer command_buffer,
|
||||
command_buffer.setScissor(0, 1, &scissor);
|
||||
|
||||
// Bind DescriptorSet with font or user texture
|
||||
vk::DescriptorSet desc_set[1]{pcmd->TextureId->descriptor_set};
|
||||
vk::DescriptorSet desc_set[1]{pcmd->GetTexID()->descriptor_set};
|
||||
command_buffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics,
|
||||
bd->pipeline_layout, 0, {desc_set}, {});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user