Skip to content

Commit

Permalink
fix ImGui::SetTooltip formatting
Browse files Browse the repository at this point in the history
SetTooltip calls sprintf, a tooltip with "%whatever" crashes the game
  • Loading branch information
0xSombra authored and WSSDude committed Aug 7, 2021
1 parent 9cd2c2d commit 167290a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/overlay/widgets/TweakDBEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ std::pair<bool, std::string*> InputTextCStr(const char* acpLabel, const char* ac
}
}

void SetTooltipUnformatted(const char* acpText)
{
ImGui::BeginTooltip();
ImGui::TextUnformatted(acpText);
ImGui::EndTooltip();
}

bool NextItemVisible(const ImVec2& aSize = ImVec2(1, 1), bool aClaimSpaceIfInvisible = true)
{
ImVec2 rectMin = ImGui::GetCursorScreenPos();
Expand Down Expand Up @@ -704,11 +711,11 @@ bool TweakDBEditor::DrawRecordDropdown(const char* acpLabel, RED4ext::TweakDBID&
{
RED4ext::CName typeName;
record->GetType()->GetName(typeName);
ImGui::SetTooltip(typeName.ToString());
ImGui::SetTooltipUnformatted(typeName.ToString());
}
else
{
ImGui::SetTooltip("ERROR_RECORD_NOT_FOUND");
ImGui::SetTooltipUnformatted("ERROR_RECORD_NOT_FOUND");
}
}
if (comboOpened)
Expand Down Expand Up @@ -751,7 +758,7 @@ bool TweakDBEditor::DrawRecordDropdown(const char* acpLabel, RED4ext::TweakDBID&
}

if (ImGui::IsItemHovered())
ImGui::SetTooltip(recordGroup.m_name.c_str());
ImGui::SetTooltipUnformatted(recordGroup.m_name.c_str());

if (isSelected)
ImGui::SetItemDefaultFocus();
Expand Down Expand Up @@ -1073,11 +1080,11 @@ bool TweakDBEditor::DrawFlatTweakDBID(RED4ext::TweakDBID aDBID, RED4ext::CStackT
{
RED4ext::CName typeName;
record->GetType()->GetName(typeName);
ImGui::SetTooltip(typeName.ToString());
ImGui::SetTooltipUnformatted(typeName.ToString());
}
else
{
ImGui::SetTooltip("ERROR_RECORD_NOT_FOUND");
ImGui::SetTooltipUnformatted("ERROR_RECORD_NOT_FOUND");
}
}

Expand Down Expand Up @@ -1537,7 +1544,7 @@ bool TweakDBEditor::DrawFlatCName(RED4ext::TweakDBID aDBID, RED4ext::CStackType&
{
RED4ext::CString localizedText;
ExecuteGlobalFunction("GetLocalizedTextByKey", &localizedText, atoll(pStr + 7));
ImGui::SetTooltip(localizedText.c_str());
ImGui::SetTooltipUnformatted(localizedText.c_str());
}

uint64_t hash = pCName->hash;
Expand Down Expand Up @@ -1601,7 +1608,7 @@ bool TweakDBEditor::DrawFlatString(RED4ext::TweakDBID aDBID, RED4ext::CStackType
{
RED4ext::CString localizedText;
RED4ext::ExecuteGlobalFunction("GetLocalizedTextByKey", &localizedText, atoll(pCString->c_str() + 7));
ImGui::SetTooltip(localizedText.c_str());
ImGui::SetTooltipUnformatted(localizedText.c_str());
}

if (valueChanged)
Expand Down

0 comments on commit 167290a

Please sign in to comment.