forked from townforge/townforge
game: add tooltip with full player names and titles in chat console
This commit is contained in:
parent
d4f024247f
commit
316400bc6a
@ -10350,16 +10350,16 @@ void CryptoCityUrho3D::HandleNewChatLine(StringHash eventType, VariantMap& event
|
||||
|
||||
const String stimestamp = tools::get_human_readable_timestamp(timestamp).c_str();
|
||||
const String prefix = "(" + stimestamp + ")";
|
||||
std::pair<String, uint32_t> source;
|
||||
std::tuple<String, uint32_t, std::string> source;
|
||||
String final_line;
|
||||
if (me)
|
||||
{
|
||||
source = std::make_pair("", 0);
|
||||
source = std::make_tuple("", 0, "");
|
||||
final_line = String(gameState.get_player_name(account_id).c_str()) + " " + line;
|
||||
}
|
||||
else
|
||||
{
|
||||
source = std::make_pair(gameState.get_player_name(account_id).c_str(), account_id);
|
||||
source = std::make_tuple(gameState.get_player_name(account_id).c_str(), account_id, gameState.get_player_name(account_id, true));
|
||||
final_line = line;
|
||||
}
|
||||
console->AddLine(prefix, source, final_line, me ? "ChatEmoteStyle" : "ChatDefaultStyle", color, alt_color);
|
||||
|
@ -264,10 +264,11 @@ TBWidget *UIConsole::RowDataSource::CreateItemWidget(int index, TBSelectItemView
|
||||
TBEditField *source_content = new_console_edit_field();
|
||||
source_content->SetGravity(WIDGET_GRAVITY_ALL);
|
||||
source_content->SetID(TBIDC("content"));
|
||||
source_content->SetText(make_widget_text(prefix, suffix, item->row.source.first));
|
||||
source_content->SetText(make_widget_text(prefix, suffix, std::get<0>(item->row.source)));
|
||||
source_field->SetTooltipText(std::get<2>(item->row.source));
|
||||
source_field->GetContentRoot()->AddChild(source_content);
|
||||
source_field->data.SetInt(item->row.source.second);
|
||||
if (!item->row.source.first.Empty())
|
||||
source_field->data.SetInt(std::get<1>(item->row.source));
|
||||
if (!std::get<0>(item->row.source).Empty())
|
||||
{
|
||||
TBEditField *text = new_console_edit_field();
|
||||
text->SetText(make_widget_text(prefix, suffix, ": "));
|
||||
@ -951,6 +952,8 @@ void UIConsole::Update()
|
||||
snap_ = false;
|
||||
}
|
||||
|
||||
UITBWindow::Update();
|
||||
|
||||
if (pendingRows_.Empty())
|
||||
return;
|
||||
|
||||
@ -972,8 +975,6 @@ void UIConsole::Update()
|
||||
rowContainer_->ValidateList();
|
||||
|
||||
UpdateElements(); // May need to readjust the height due to scrollbar visibility changes
|
||||
|
||||
UITBWindow::Update();
|
||||
}
|
||||
|
||||
bool UIConsole::HasUnreadPrefix(const char *prefix) const
|
||||
@ -993,7 +994,7 @@ bool UIConsole::HasUnreadPrefix(const char *prefix) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void UIConsole::AddLine(const String &prefix, const std::pair<String, uint32_t> &source, const String &line, const String &style, unsigned color, unsigned alt_color)
|
||||
void UIConsole::AddLine(const String &prefix, const std::tuple<String, uint32_t, std::string> &source, const String &line, const String &style, unsigned color, unsigned alt_color)
|
||||
{
|
||||
if (prefix.Empty())
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ class UIConsole: public UITBWindow
|
||||
struct row_data_t
|
||||
{
|
||||
Urho3D::String prefix;
|
||||
std::pair<Urho3D::String, uint32_t> source;
|
||||
std::tuple<Urho3D::String, uint32_t, std::string> source;
|
||||
Urho3D::String line;
|
||||
Urho3D::String style;
|
||||
unsigned color;
|
||||
@ -213,7 +213,7 @@ public:
|
||||
|
||||
void AddInterpreter(const Urho3D::String &name);
|
||||
void RemoveInterpreter(const Urho3D::String &name);
|
||||
void AddLine(const Urho3D::String &prefix, const std::pair<Urho3D::String, uint32_t> &source, const Urho3D::String &line, const Urho3D::String &style = "", unsigned color = 0, unsigned alt_color = 0);
|
||||
void AddLine(const Urho3D::String &prefix, const std::tuple<Urho3D::String, uint32_t, std::string> &source, const Urho3D::String &line, const Urho3D::String &style = "", unsigned color = 0, unsigned alt_color = 0);
|
||||
void SetPrefixStyle(const Urho3D::String &s);
|
||||
void AddImages(const std::vector<std::pair<std::string, std::vector<std::pair<std::shared_ptr<tb::TBBitmap>, unsigned int>>>> &new_images, bool clear = false);
|
||||
void AddColors(const std::vector<std::tuple<std::string, Urho3D::Color, bool>> &new_colors, bool clear = false);
|
||||
|
Loading…
Reference in New Issue
Block a user