Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Brush sets: status messages in the interface language (es, zh-TW, zh-CN); command results stay English

islandmedc82df793c923
diff --git a/src/app/App.h b/src/app/App.h
index c64fc1e1..f4284349 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -2143,6 +2143,9 @@ private:
bool applyBrushSet(const std::string& name, std::string& message);
bool saveShelfAsBrushSet(const std::string& name, std::string& message);
bool deleteBrushSet(const std::string& name, std::string& message);
+ template <class... A> void say(std::string& message, const char* english, A... args);
+ void sayCounts(std::string& message, const char* english, const std::string& name, int brushes, int keys);
+ void runBrushSetCommand(const std::string& command, const std::string& name); // then the status in the interface language
void openBrushSetSave();
void drawBrushSetSave(); // the Save Shelf as Brush Set window
struct BrushSetsUi {
@@ -2151,6 +2154,7 @@ private:
bool saveOpen = false, saveFocus = false, deleteOpen = false;
char name[65] = "";
std::string error; // why the last Save didn't work
+ std::string shown; // the last brush set step's result in the interface language (the status bar)
std::string deleting; // the set Delete asks about
std::string pending; // a set's action ran: switched to at the start of the next frame
} brushSets_;
diff --git a/src/app/I18nSimplifiedChinese.cpp b/src/app/I18nSimplifiedChinese.cpp
index 6b5172f1..56aec624 100644
--- a/src/app/I18nSimplifiedChinese.cpp
+++ b/src/app/I18nSimplifiedChinese.cpp
@@ -3330,6 +3330,15 @@ constexpr Entry kSimplifiedChinese[] = {
{"Replaces the set %s.", "将替换笔刷组 %s。"},
{"Delete the brush set %s?", "删除笔刷组 %s?"},
{"Switch the bottom shelf to this set's brushes and give them the set's keys.", "将底部工具栏换成这个组的笔刷,并应用这个组的快捷键。"},
+ {"%d key", "%d 个快捷键"},
+ {"%d keys", "%d 个快捷键"},
+ {"Brush set: %s (%s, %s)", "笔刷组:%s(%s,%s)"},
+ {"Brush set saved: %s (%s, %s)", "已保存笔刷组:%s(%s,%s)"},
+ {"Brush set updated: %s (%s, %s)", "已更新笔刷组:%s(%s,%s)"},
+ {"Brush set deleted: %s (the shelf stays as it is)", "已删除笔刷组:%s(工具栏保持不变)"},
+ {"No brush set called %s", "没有名为 %s 的笔刷组"},
+ {"No brush sets yet: Save Shelf as Brush Set makes one", "还没有笔刷组:“将工具栏保存为笔刷组”可创建一个"},
+ {"A brush set's name must be 1 to 64 characters", "笔刷组名称须为 1 到 64 个字符"},
};
} // namespace
diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cpp
index ecdaea02..999396ed 100644
--- a/src/app/I18nSpanish.cpp
+++ b/src/app/I18nSpanish.cpp
@@ -3798,6 +3798,15 @@ constexpr Entry kSpanish[] = {
{"Replaces the set %s.", "Reemplaza el conjunto %s."},
{"Delete the brush set %s?", "¿Eliminar el conjunto de pinceles %s?"},
{"Switch the bottom shelf to this set's brushes and give them the set's keys.", "Cambia el estante inferior a los pinceles de este conjunto y les da sus teclas."},
+ {"%d key", "%d tecla"},
+ {"%d keys", "%d teclas"},
+ {"Brush set: %s (%s, %s)", "Conjunto de pinceles: %s (%s, %s)"},
+ {"Brush set saved: %s (%s, %s)", "Conjunto de pinceles guardado: %s (%s, %s)"},
+ {"Brush set updated: %s (%s, %s)", "Conjunto de pinceles actualizado: %s (%s, %s)"},
+ {"Brush set deleted: %s (the shelf stays as it is)", "Conjunto de pinceles eliminado: %s (el estante queda como está)"},
+ {"No brush set called %s", "No hay ningún conjunto de pinceles llamado %s"},
+ {"No brush sets yet: Save Shelf as Brush Set makes one", "Aún no hay conjuntos de pinceles: Guardar estante como conjunto de pinceles crea uno"},
+ {"A brush set's name must be 1 to 64 characters", "El nombre de un conjunto de pinceles debe tener de 1 a 64 caracteres"},
};
} // namespace
diff --git a/src/app/I18nTraditionalChinese.cpp b/src/app/I18nTraditionalChinese.cpp
index 1474c1c2..57920fa9 100644
--- a/src/app/I18nTraditionalChinese.cpp
+++ b/src/app/I18nTraditionalChinese.cpp
@@ -3328,6 +3328,15 @@ constexpr Entry kTraditionalChinese[] = {
{"Replaces the set %s.", "將取代筆刷組 %s。"},
{"Delete the brush set %s?", "刪除筆刷組 %s?"},
{"Switch the bottom shelf to this set's brushes and give them the set's keys.", "將底部工具列換成這個組的筆刷,並套用這個組的快速鍵。"},
+ {"%d key", "%d 個快速鍵"},
+ {"%d keys", "%d 個快速鍵"},
+ {"Brush set: %s (%s, %s)", "筆刷組:%s(%s,%s)"},
+ {"Brush set saved: %s (%s, %s)", "已儲存筆刷組:%s(%s,%s)"},
+ {"Brush set updated: %s (%s, %s)", "已更新筆刷組:%s(%s,%s)"},
+ {"Brush set deleted: %s (the shelf stays as it is)", "已刪除筆刷組:%s(工具列保持不變)"},
+ {"No brush set called %s", "沒有名為 %s 的筆刷組"},
+ {"No brush sets yet: Save Shelf as Brush Set makes one", "還沒有筆刷組:「將工具列儲存為筆刷組」可建立一個"},
+ {"A brush set's name must be 1 to 64 characters", "筆刷組名稱須為 1 到 64 個字元"},
};
} // namespace
diff --git a/src/app/PanelBrushSets.cpp b/src/app/PanelBrushSets.cpp
index 0ec7f489..d974f003 100644
--- a/src/app/PanelBrushSets.cpp
+++ b/src/app/PanelBrushSets.cpp
@@ -65,6 +65,19 @@ int findSet(const std::vector<BrushSet>& list, const std::string& name) {
return -1;
}
+// printf into a std::string (the messages below come in English and in the interface language).
+template <class... A> std::string format(const char* f, A... args) {
+ if constexpr (sizeof...(A) == 0) return f;
+ char buf[512];
+ std::snprintf(buf, sizeof buf, f, args...);
+ return buf;
+}
+
+std::string countText(int n, const char* one, const char* many, bool translated) {
+ const char* f = n == 1 ? one : many;
+ return format(translated ? tr(f) : f, n);
+}
+
std::string trimmed(const std::string& s) {
const size_t a = s.find_first_not_of(" \t"), b = s.find_last_not_of(" \t");
return a == std::string::npos ? std::string() : s.substr(a, b - a + 1);
@@ -159,7 +172,7 @@ void App::syncShelfBrushActions() {
if (!brushSets_.pending.empty()) {
std::string msg;
applyBrushSet(std::exchange(brushSets_.pending, std::string()), msg);
- status_ = msg;
+ status_ = brushSets_.shown;
}
if (layout_.bottomShelf == brushSets_.shelfSeen) return;
brushSets_.shelfSeen = layout_.bottomShelf;
@@ -205,11 +218,31 @@ void App::syncShelfBrushActions() {
}
}
+// The result in English (the command's message: scripts, the console, the AI link) and in the interface language
+// (brushSets_.shown, for the status bar when the step came from the interface).
+template <class... A> void App::say(std::string& message, const char* english, A... args) {
+ message = format(english, args...);
+ brushSets_.shown = format(tr(english), args...);
+}
+
+void App::sayCounts(std::string& message, const char* english, const std::string& name, int brushes, int keys) {
+ message = format(english, name.c_str(), countText(brushes, "%d brush", "%d brushes", false).c_str(),
+ countText(keys, "%d key", "%d keys", false).c_str());
+ brushSets_.shown = format(tr(english), name.c_str(), countText(brushes, "%d brush", "%d brushes", true).c_str(),
+ countText(keys, "%d key", "%d keys", true).c_str());
+}
+
+void App::runBrushSetCommand(const std::string& command, const std::string& name) {
+ brushSets_.shown.clear();
+ runCommand(command, {{"name", name}});
+ if (!brushSets_.shown.empty()) status_ = brushSets_.shown; // in the interface language
+}
+
bool App::applyBrushSet(const std::string& name, std::string& message) {
const int i = findSet(brushSets_.list, name);
if (i < 0) {
- message = brushSets_.list.empty() ? "No brush sets yet: Save Shelf as Brush Set makes one"
- : "No brush set called " + name;
+ if (brushSets_.list.empty()) say(message, "No brush sets yet: Save Shelf as Brush Set makes one");
+ else say(message, "No brush set called %s", name.c_str());
return false;
}
const BrushSet set = brushSets_.list[size_t(i)];
@@ -226,15 +259,14 @@ bool App::applyBrushSet(const std::string& name, std::string& message) {
++keys;
}
uiPrefs_.brushSet = set.name;
- message = "Brush set: " + set.name + " (" + std::to_string(countBrushes(set.shelf)) + " brushes, " +
- std::to_string(keys) + (keys == 1 ? " key)" : " keys)");
+ sayCounts(message, "Brush set: %s (%s, %s)", set.name, countBrushes(set.shelf), keys);
return true;
}
bool App::saveShelfAsBrushSet(const std::string& rawName, std::string& message) {
const std::string name = trimmed(rawName);
if (name.empty() || name.size() > kMaxBrushSetName) {
- message = "A brush set's name must be 1 to 64 characters";
+ say(message, "A brush set's name must be 1 to 64 characters");
return false;
}
BrushSet set;
@@ -247,32 +279,32 @@ bool App::saveShelfAsBrushSet(const std::string& rawName, std::string& message)
const bool replaced = std::any_of(brushSets_.list.begin(), brushSets_.list.end(), [&](const BrushSet& b) { return b.name == name; });
std::string err;
if (!saveBrushSet(brushSetsDir(), set, err)) {
- message = err;
+ message = brushSets_.shown = err;
return false;
}
refreshBrushSets();
uiPrefs_.brushSet = name;
const int keys = int(std::count_if(set.keys.begin(), set.keys.end(), [](const auto& k) { return !k.second.empty(); }));
- message = std::string(replaced ? "Brush set updated: " : "Brush set saved: ") + name + " (" +
- std::to_string(countBrushes(set.shelf)) + " brushes, " + std::to_string(keys) + (keys == 1 ? " key)" : " keys)");
+ sayCounts(message, replaced ? "Brush set updated: %s (%s, %s)" : "Brush set saved: %s (%s, %s)", name, countBrushes(set.shelf),
+ keys);
return true;
}
bool App::deleteBrushSet(const std::string& name, std::string& message) {
const int i = findSet(brushSets_.list, name);
if (i < 0) {
- message = "No brush set called " + name;
+ say(message, "No brush set called %s", name.c_str());
return false;
}
const std::string gone = brushSets_.list[size_t(i)].name;
std::string err;
if (!deleteBrushSetFile(brushSets_.list[size_t(i)], err)) {
- message = err;
+ message = brushSets_.shown = err;
return false;
}
if (uiPrefs_.brushSet == gone) uiPrefs_.brushSet.clear();
refreshBrushSets();
- message = "Brush set deleted: " + gone + " (the shelf stays as it is)";
+ say(message, "Brush set deleted: %s (the shelf stays as it is)", gone.c_str());
return true;
}
@@ -291,7 +323,7 @@ void App::drawBrushSetMenu() {
char count[64];
std::snprintf(count, sizeof count, n == 1 ? tr("%d brush") : tr("%d brushes"), n);
const std::string label = set.name + "##brushset" + std::to_string(i);
- if (ImGui::MenuItem(label.c_str(), count, int(i) == current)) runCommand("brush_set", {{"name", set.name}});
+ if (ImGui::MenuItem(label.c_str(), count, int(i) == current)) runBrushSetCommand("brush_set", set.name);
ui::HelpText(set.name.c_str(), actions_.shortcutText("brushset.use." + slug(set.name)).c_str(),
"Switch the bottom shelf to this set's brushes and give them the set's keys.", "Brush > Brush set");
}
@@ -379,7 +411,7 @@ void App::drawBrushSetSave() {
if (ImGui::Button(tr("Cancel##brushsetsave_cancel"), button) || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
ImGui::CloseCurrentPopup();
} else if (ok && !name.empty()) {
- runCommand("brush_set_save", {{"name", name}});
+ runBrushSetCommand("brush_set_save", name);
if (lastCommandOk_) ImGui::CloseCurrentPopup();
else error = status_;
}
@@ -392,7 +424,7 @@ void App::drawBrushSetSave() {
ImGui::TextDisabled("%s", tr("Only the set goes: the brushes and the shelf stay as they are."));
bool close = false;
if (ImGui::Button(tr("Delete##brushsetdelete_ok"), button)) {
- runCommand("brush_set_delete", {{"name", brushSets_.deleting}});
+ runBrushSetCommand("brush_set_delete", brushSets_.deleting);
close = true;
}
ImGui::SameLine();