2023-11-10 20:47:08 +01:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-20 11:55:56 +02:00
|
|
|
#include <hex/ui/popup.hpp>
|
|
|
|
|
2023-11-21 14:38:01 +01:00
|
|
|
#include <hex/api/localization_manager.hpp>
|
2023-06-20 11:55:56 +02:00
|
|
|
|
|
|
|
#include <wolv/hash/uuid.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
class PopupTelemetryRequest : public Popup<PopupTelemetryRequest> {
|
|
|
|
public:
|
|
|
|
PopupTelemetryRequest()
|
|
|
|
: hex::Popup<PopupTelemetryRequest>("hex.builtin.common.question", false) {
|
|
|
|
// Check if there is a telemetry uuid
|
2023-10-21 23:07:33 +02:00
|
|
|
this->m_uuid = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", "").get<std::string>();
|
2023-06-20 11:55:56 +02:00
|
|
|
if(this->m_uuid.empty()) {
|
|
|
|
// Generate a new uuid
|
|
|
|
this->m_uuid = wolv::hash::generateUUID();
|
|
|
|
// Save
|
|
|
|
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", this->m_uuid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void drawContent() override {
|
|
|
|
static std::string message = "hex.builtin.welcome.server_contact_text"_lang;
|
2023-11-16 22:24:06 +01:00
|
|
|
ImGuiExt::TextFormattedWrapped("{}", message.c_str());
|
2023-06-20 11:55:56 +02:00
|
|
|
ImGui::NewLine();
|
|
|
|
|
|
|
|
if(ImGui::CollapsingHeader("hex.builtin.welcome.server_contact.data_collected_title"_lang)) {
|
|
|
|
if(ImGui::BeginTable("hex.builtin.welcome.server_contact.data_collected_table"_lang, 2,
|
2023-06-21 00:33:06 +02:00
|
|
|
ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY | ImGuiTableFlags_NoHostExtendY,
|
|
|
|
ImVec2(ImGui::GetContentRegionAvail().x, 100_scaled))) {
|
2023-06-20 11:55:56 +02:00
|
|
|
ImGui::TableSetupColumn("hex.builtin.welcome.server_contact.data_collected_table.key"_lang);
|
|
|
|
ImGui::TableSetupColumn("hex.builtin.welcome.server_contact.data_collected_table.value"_lang, ImGuiTableColumnFlags_WidthStretch);
|
2023-06-21 00:33:06 +02:00
|
|
|
ImGui::TableSetupScrollFreeze(0, 1);
|
|
|
|
|
2023-06-20 11:55:56 +02:00
|
|
|
ImGui::TableHeadersRow();
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextUnformatted("hex.builtin.welcome.server_contact.data_collected.uuid"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextWrapped("%s", this->m_uuid.c_str());
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextUnformatted("hex.builtin.welcome.server_contact.data_collected.version"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
2023-11-16 22:24:06 +01:00
|
|
|
ImGuiExt::TextFormattedWrapped("{}\n{}@{}\n{}",
|
2023-06-26 14:01:45 +02:00
|
|
|
ImHexApi::System::getImHexVersion(),
|
|
|
|
ImHexApi::System::getCommitHash(true),
|
|
|
|
ImHexApi::System::getCommitBranch(),
|
2023-06-21 00:33:06 +02:00
|
|
|
ImHexApi::System::isPortableVersion() ? "Portable" : "Installed"
|
|
|
|
);
|
2023-06-20 11:55:56 +02:00
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextUnformatted("hex.builtin.welcome.server_contact.data_collected.os"_lang);
|
|
|
|
ImGui::TableNextColumn();
|
2023-11-16 22:24:06 +01:00
|
|
|
ImGuiExt::TextFormattedWrapped("{}\n{}\n{}\n{}",
|
2023-06-21 00:21:16 +02:00
|
|
|
ImHexApi::System::getOSName(),
|
|
|
|
ImHexApi::System::getOSVersion(),
|
|
|
|
ImHexApi::System::getArchitecture(),
|
|
|
|
ImHexApi::System::getGPUVendor());
|
2023-06-20 11:55:56 +02:00
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::NewLine();
|
|
|
|
|
|
|
|
const auto width = ImGui::GetWindowWidth();
|
|
|
|
const auto buttonSize = ImVec2(width / 3 - ImGui::GetStyle().FramePadding.x * 3, 0);
|
|
|
|
const auto buttonPos = [&](u8 index) { return ImGui::GetStyle().FramePadding.x + (buttonSize.x + ImGui::GetStyle().FramePadding.x * 3) * index; };
|
|
|
|
|
|
|
|
ImGui::SetCursorPosX(buttonPos(0));
|
|
|
|
if (ImGui::Button("hex.builtin.common.allow"_lang, buttonSize)) {
|
|
|
|
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.server_contact", 1);
|
|
|
|
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.upload_crash_logs", 1);
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::SetCursorPosX(buttonPos(1));
|
|
|
|
if (ImGui::Button("hex.builtin.welcome.server_contact.crash_logs_only"_lang, buttonSize)) {
|
|
|
|
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.server_contact", 0);
|
|
|
|
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.upload_crash_logs", 1);
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::SetCursorPosX(buttonPos(2));
|
|
|
|
if (ImGui::Button("hex.builtin.common.deny"_lang, buttonSize)) {
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::SetWindowPos((ImHexApi::System::getMainWindowSize() - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] ImGuiWindowFlags getFlags() const override {
|
|
|
|
return ImGuiWindowFlags_AlwaysAutoResize;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] ImVec2 getMinSize() const override {
|
|
|
|
return scaled({ 500, 100 });
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] ImVec2 getMaxSize() const override {
|
2023-06-21 00:33:06 +02:00
|
|
|
return scaled({ 500, 450 });
|
2023-06-20 11:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_uuid;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|