Skip to content

Commit

Permalink
feat: Content browser improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrno committed Nov 23, 2024
1 parent 4f95055 commit 7ce6a2e
Show file tree
Hide file tree
Showing 52 changed files with 536 additions and 262 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ target_include_directories(vortex_shared PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/main/src
)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ui/crash_handler ui_crash_handler_build)
target_link_libraries(vortex_shared PUBLIC crash_handler)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ui/editor ui_editor_build)
target_link_libraries(vortex_shared PUBLIC editor)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ui/crash_handler ui_crash_handler_build)
target_link_libraries(vortex_shared PUBLIC crash_handler)

target_link_libraries(vortex_shared PUBLIC cherry)

Expand Down
16 changes: 9 additions & 7 deletions ui/editor/app/core/modules_utility/modules_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,18 @@ namespace VortexEditor
truncatedText = name + "\n";
}


const char *originalDesc = module->m_description.c_str();
std::string truncatedDesc = module->m_description;
std::string truncatedDesc = module->m_description;
if (truncatedDesc.length() > 100) {
truncatedDesc = truncatedDesc.substr(0, 97) + "...";
}
const char *originalDesc = truncatedDesc.c_str();

if (ImGui::CalcTextSize(originalDesc).x > maxTextWidth)
{
truncatedDesc = module->m_description.substr(0, 20);
truncatedDesc = module->m_description.substr(0, 90);
if (ImGui::CalcTextSize(truncatedDesc.c_str()).x > maxTextWidth)
{
truncatedDesc = module->m_description.substr(0, 10) + "\n" + module->m_description.substr(10, 10);
truncatedDesc = module->m_description.substr(0, 55) + "\n" + module->m_description.substr(55, 55);
}
}
else
Expand Down Expand Up @@ -182,9 +184,9 @@ namespace VortexEditor
ImGui::SetCursorScreenPos(descriptionPos);

ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.5f, 0.5f, 0.5f, 1.0f));
ImGui::PushItemWidth(maxTextWidth);
ImGui::PushItemWidth(fixedSize.x);

DrawDescription(drawList, descriptionPos, truncatedDesc.c_str(), ModulesSearch, highlightColor, textColor, highlightTextColor);
DrawDescription(drawList, descriptionPos, truncatedDesc.c_str(), ModulesSearch, highlightColor, Cherry::HexToImU32("#8A8A8AFF"), highlightTextColor, oldfontsize);
ImGui::PopItemWidth();
ImGui::PopStyleColor();

Expand Down
24 changes: 13 additions & 11 deletions ui/editor/app/core/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@ static void MyButton(const std::string &name, int w, int h)
if (cursorPos.x + totalSize.x < windowVisibleX2)
ImGui::SameLine();
}
static void DrawDescription(ImDrawList *drawList, ImVec2 textPos, const char *text, const char *search, ImU32 highlightColor, ImU32 textColor, ImU32 highlightTextColor)
static void DrawDescription(ImDrawList *drawList, ImVec2 textPos, const char *text, const char *search, ImU32 highlightColor, ImU32 textColor, ImU32 highlightTextColor, float oldfontsize)
{

ImGui::GetFont()->Scale = 0.7f;
ImGui::PushFont(ImGui::GetFont());

if (!text || !search || !*search)
{
drawList->AddText(textPos, textColor, text);
Expand Down Expand Up @@ -281,9 +285,10 @@ static void DrawDescription(ImDrawList *drawList, ImVec2 textPos, const char *te
{
drawList->AddText(textPos, textColor, start);
}
ImGui::GetFont()->Scale = oldfontsize;
ImGui::PopFont();
}


static void DrawHighlightedText(ImDrawList *drawList, ImVec2 textPos, const char *text, const char *search, ImU32 highlightColor, ImU32 textColor, ImU32 highlightTextColor)
{
if (!text || !search || !*search)
Expand Down Expand Up @@ -538,18 +543,15 @@ static void MyButton(const std::shared_ptr<EnvProject> envproject, int xsize = 1

drawList->AddRectFilled(smallRectPos, ImVec2(smallRectPos.x + smallRectSize.x, smallRectPos.y + smallRectSize.y), IM_COL32(0, 0, 0, 255));
ImVec2 versionTextPos = ImVec2(smallRectPos.x + (smallRectSize.x - ImGui::CalcTextSize(versionText).x) / 2, smallRectPos.y + (smallRectSize.y - ImGui::CalcTextSize("version").y) / 2);

if(CheckIfVortexVersionExist(envproject->compatibleWith))
{
drawList->AddText(versionTextPos, IM_COL32(255, 255, 255, 255), versionText);

if (CheckIfVortexVersionExist(envproject->compatibleWith))
{
drawList->AddText(versionTextPos, IM_COL32(255, 255, 255, 255), versionText);
}
else{
drawList->AddText(versionTextPos, IM_COL32(255, 20, 20, 255), versionText);

else
{
drawList->AddText(versionTextPos, IM_COL32(255, 20, 20, 255), versionText);
}



ImVec2 textPos = ImVec2(cursorPos.x + (squareSize.x - textSize.x) / 2, cursorPos.y + squareSize.y + 5);

Expand Down
Loading

0 comments on commit 7ce6a2e

Please sign in to comment.