Add setting to show full group hierarchy in group names
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "tracerestrict.h"
|
||||
#include "game/game_text.hpp"
|
||||
#include "network/network_content_gui.h"
|
||||
#include "core/y_combinator.hpp"
|
||||
#include <stack>
|
||||
|
||||
#include "table/strings.h"
|
||||
@@ -1705,19 +1706,30 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||
}
|
||||
|
||||
case SCC_GROUP_NAME: { // {GROUP}
|
||||
const Group *g = Group::GetIfValid(args->GetInt32());
|
||||
if (g == nullptr) break;
|
||||
uint32 id = (uint32)args->GetInt64();
|
||||
bool recurse = _settings_client.gui.show_group_hierarchy_name && (id & GROUP_NAME_HIERARCHY);
|
||||
id &= ~GROUP_NAME_HIERARCHY;
|
||||
const Group *group = Group::GetIfValid(id);
|
||||
if (group == nullptr) break;
|
||||
|
||||
if (!g->name.empty()) {
|
||||
int64 args_array[] = {(int64)(size_t)g->name.c_str()};
|
||||
StringParameters tmp_params(args_array);
|
||||
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
|
||||
} else {
|
||||
int64 args_array[] = {g->index};
|
||||
StringParameters tmp_params(args_array);
|
||||
auto handle_group = y_combinator([&](auto handle_group, const Group *g) -> void {
|
||||
if (recurse && g->parent != INVALID_GROUP) {
|
||||
handle_group(Group::Get(g->parent));
|
||||
StringParameters tmp_params(nullptr, 0, nullptr);
|
||||
buff = GetStringWithArgs(buff, STR_HIERARCHY_SEPARATOR, &tmp_params, last);
|
||||
}
|
||||
if (!g->name.empty()) {
|
||||
int64 args_array[] = {(int64)(size_t)g->name.c_str()};
|
||||
StringParameters tmp_params(args_array);
|
||||
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
|
||||
} else {
|
||||
int64 args_array[] = {g->index};
|
||||
StringParameters tmp_params(args_array);
|
||||
|
||||
buff = GetStringWithArgs(buff, STR_FORMAT_GROUP_NAME, &tmp_params, last);
|
||||
}
|
||||
buff = GetStringWithArgs(buff, STR_FORMAT_GROUP_NAME, &tmp_params, last);
|
||||
}
|
||||
});
|
||||
handle_group(group);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user