Fix double free; add credits to About

This commit is contained in:
Luke Street 2021-05-27 08:25:55 -04:00
parent 31e7721fbf
commit 996eadfb4f
3 changed files with 24 additions and 5 deletions

View File

@ -178,7 +178,9 @@ void ImGuiConsole::BeginEntityRow(const ImGuiEntityEntry& entry) {
auto text = fmt::format(FMT_STRING("{:x}"), entry.uid.Value());
ImGui::Selectable(text.c_str(), &entry.ent->m_debugSelected,
ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap);
entry.ent->m_debugHovered = ImGui::IsItemHovered();
if (ImGui::IsItemHovered()) {
entry.ent->m_debugHovered = true;
}
if (ImGui::BeginPopupContextItem(text.c_str())) {
ImGui::PopStyleColor();
@ -313,7 +315,7 @@ void ImGuiConsole::ShowInspectWindow(bool* isOpen) {
bool ImGuiConsole::ShowEntityInfoWindow(TUniqueId uid) {
bool open = true;
ImGuiEntityEntry& entry = ImGuiConsole::entities[uid.Value()];
auto name = fmt::format(FMT_STRING("{}##{:x}"), !entry.name.empty() ? entry.name : "Entity", uid.Value());
auto name = fmt::format(FMT_STRING("{}##{:x}"), !entry.name.empty() ? entry.name : entry.type, uid.Value());
if (ImGui::Begin(name.c_str(), &open, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::PushID(uid.Value());
entry.ent->ImGuiInspect();
@ -338,6 +340,11 @@ void ImGuiConsole::ShowAboutWindow() {
ImGuiTextCenter(METAFORCE_WC_DESCRIBE);
const ImVec2& padding = ImGui::GetStyle().WindowPadding;
ImGui::Dummy(padding);
ImGuiTextCenter("2015-2021");
ImGuiTextCenter("Phillip Stephens (Antidote)");
ImGuiTextCenter("Jack Andersen (jackoalan)");
ImGuiTextCenter("Luke Street (encounter)");
ImGuiTextCenter("Metaforce contributors");
ImGui::Dummy(padding);
ImGui::Separator();
if (ImGui::BeginTable("Version Info", 2, ImGuiTableFlags_BordersInnerV)) {
@ -362,6 +369,13 @@ void ImGuiConsole::ShowAboutWindow() {
if (ImGui::TableNextColumn()) {
ImGui::TextUnformatted(METAFORCE_WC_DATE);
}
ImGui::TableNextRow();
if (ImGui::TableNextColumn()) {
ImGui::TextUnformatted("Build name");
}
if (ImGui::TableNextColumn()) {
ImGui::TextUnformatted(METAFORCE_DLPACKAGE);
}
ImGui::EndTable();
}
}
@ -623,6 +637,9 @@ void ImGuiConsole::PostUpdate() {
inspectingEntities.erase(item.uid);
item.uid = kInvalidUniqueId;
item.ent = nullptr; // for safety
} else {
// Clear debug hovered
ent->m_debugHovered = false;
}
}
} else {

View File

@ -227,7 +227,7 @@ void CEntity::ImGuiInspect() {
ImGui::EndTable();
}
}
if (m_incomingConnections && ImGui::CollapsingHeader("Incoming Connections")) {
if (m_incomingConnections != nullptr && ImGui::CollapsingHeader("Incoming Connections")) {
if (ImGui::BeginTable("Incoming Connections", 6,
ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV)) {
ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed, 0, 'id');
@ -235,10 +235,11 @@ void CEntity::ImGuiInspect() {
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch, 0, 'name');
ImGui::TableSetupColumn("State", ImGuiTableColumnFlags_WidthFixed, 0, 'stat');
ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_WidthFixed, 0, 'msg');
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed |
ImGuiTableColumnFlags_NoResize);
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableHeadersRow();
for (const auto& item : (*m_incomingConnections)) {
for (const auto& item : *m_incomingConnections) {
const auto uid = g_StateManager->GetIdForScript(item.x8_objId);
if (uid == kInvalidUniqueId) {
continue;

View File

@ -108,6 +108,7 @@ void ImGuiEngine::Initialize(boo::IGraphicsDataFactory* factory, boo::IWindow* w
snprintf(fontConfig.Name, sizeof(fontConfig.Name), "Noto Mono Regular, %dpx",
static_cast<int>(fontConfig.SizePixels));
fontNormal = io.Fonts->AddFont(&fontConfig);
fontConfig.FontDataOwnedByAtlas = false; // first one took ownership
fontConfig.SizePixels = std::floor(24.f * scale);
snprintf(fontConfig.Name, sizeof(fontConfig.Name), "Noto Mono Regular, %dpx",
static_cast<int>(fontConfig.SizePixels));