Skip to content

Commit

Permalink
Merge pull request colobot#1651 from colobot/1649-the-message-instruc…
Browse files Browse the repository at this point in the history
…tion-and-character-escaping

Fixed accidental removal of tooltip when displaying text with message()
  • Loading branch information
tomaszkax86 authored May 12, 2024
2 parents 5cc97d0 + 906ac1e commit c56d240
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions colobot-base/src/ui/controls/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,18 @@ CLabel* CWindow::CreateLabel(const glm::vec2& pos, const glm::vec2& dim, int ico

auto p = name.find("\\");
if (p == std::string::npos)
label->SetName(name);
label->SetName(name, false);
else
label->SetName(name.substr(0, p));
label->SetName(name.substr(0, p), false);

return label;
}

CLabel* CWindow::CreateLabelRaw(const glm::vec2& pos, const glm::vec2& dim, int icon, EventType eventMsg, std::string name)
{
CLabel* label = CreateControl<CLabel>(pos, dim, icon, eventMsg);

label->SetName(name, false);

return label;
}
Expand Down
1 change: 1 addition & 0 deletions colobot-base/src/ui/controls/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class CWindow : public CControl
CGroup* CreateGroup(const glm::vec2& pos, const glm::vec2& dim, int icon, EventType eventMsg);
CImage* CreateImage(const glm::vec2& pos, const glm::vec2& dim, int icon, EventType eventMsg);
CLabel* CreateLabel(const glm::vec2& pos, const glm::vec2& dim, int icon, EventType eventMsg, std::string name);
CLabel* CreateLabelRaw(const glm::vec2& pos, const glm::vec2& dim, int icon, EventType eventMsg, std::string name);
CEdit* CreateEdit(const glm::vec2& pos, const glm::vec2& dim, int icon, EventType eventMsg);
CEditValue* CreateEditValue(const glm::vec2& pos, const glm::vec2& dim, int icon, EventType eventMsg);
CScroll* CreateScroll(const glm::vec2& pos, const glm::vec2& dim, int icon, EventType eventMsg);
Expand Down
4 changes: 2 additions & 2 deletions colobot-base/src/ui/displaytext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void CDisplayText::DisplayText(const char *text, glm::vec3 goal, float height,

ppos = pos;
ppos.y -= hLine/2.0f;
label = pw->CreateLabel(ppos, dim, -1, EventType(EVENT_DT_LABEL0+nLine), text);
label = pw->CreateLabelRaw(ppos, dim, -1, EventType(EVENT_DT_LABEL0+nLine), text);
if ( label != nullptr )
{
label->SetFontSize(FONTSIZE);
Expand Down Expand Up @@ -390,7 +390,7 @@ bool CDisplayText::ClearLastText()

pb1->SetState(STATE_ENABLE, pb2->TestState(STATE_ENABLE));
pg1->SetIcon(pg2->GetIcon());
pl1->SetName(pl2->GetName());
pl1->SetName(pl2->GetName(), false);

m_textLines[i] = m_textLines[i+1];
}
Expand Down

0 comments on commit c56d240

Please sign in to comment.