Fix #135134: Do Not Show Full Path to Built-In Assets
We are showing full paths to the library file on some tooltips, like for brush assets. This PR checks to see if the asset is in the BLENDER_SYSTEM_DATAFILES/assets folder. If so it just shows it as "Built-in Asset:" and with the last portion of the path. Pull Request: https://projects.blender.org/blender/blender/pulls/135593
This commit is contained in:
committed by
Harley Acheson
parent
fd9ac90395
commit
5ea6ffef68
@@ -25,6 +25,8 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "AS_essentials_library.hh"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_userdef_types.h"
|
||||
@@ -1004,12 +1006,14 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
|
||||
if (but->rnapoin.owner_id) {
|
||||
const ID *id = but->rnapoin.owner_id;
|
||||
if (ID_IS_LINKED(id)) {
|
||||
std::string assets_path = blender::asset_system::essentials_directory_path();
|
||||
const bool is_builtin = BLI_path_contains(assets_path.c_str(), id->lib->filepath);
|
||||
const std::string title = is_builtin ? TIP_("Built-in Asset") : TIP_("Library");
|
||||
const std::string lib_path = id->lib->filepath;
|
||||
const std::string path = is_builtin ? lib_path.substr(assets_path.size()) :
|
||||
id->lib->filepath;
|
||||
UI_tooltip_text_field_add(
|
||||
*data,
|
||||
fmt::format(fmt::runtime(TIP_("Library: {}")), id->lib->filepath),
|
||||
{},
|
||||
UI_TIP_STYLE_NORMAL,
|
||||
UI_TIP_LC_NORMAL);
|
||||
*data, fmt::format("{}: {}", title, path), {}, UI_TIP_STYLE_NORMAL, UI_TIP_LC_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user