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()
|
2023-12-23 21:09:41 +01:00
|
|
|
: hex::Popup<PopupTelemetryRequest>("hex.ui.common.question", false) {
|
2023-06-20 11:55:56 +02:00
|
|
|
// Check if there is a telemetry uuid
|
2023-12-19 13:10:25 +01:00
|
|
|
m_uuid = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", "").get<std::string>();
|
|
|
|
if(m_uuid.empty()) {
|
2023-06-20 11:55:56 +02:00
|
|
|
// Generate a new uuid
|
2023-12-19 13:10:25 +01:00
|
|
|
m_uuid = wolv::hash::generateUUID();
|
2023-06-20 11:55:56 +02:00
|
|
|
// Save
|
2023-12-19 13:10:25 +01:00
|
|
|
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", m_uuid);
|
2023-06-20 11:55:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2023-12-19 13:10:25 +01:00
|
|
|
ImGui::TextWrapped("%s", m_uuid.c_str());
|
2023-06-20 11:55:56 +02:00
|
|
|
|
|
|
|
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));
|
2023-12-23 21:09:41 +01:00
|
|
|
if (ImGui::Button("hex.ui.common.allow"_lang, buttonSize)) {
|
2023-06-20 11:55:56 +02:00
|
|
|
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));
|
2023-12-23 21:09:41 +01:00
|
|
|
if (ImGui::Button("hex.ui.common.deny"_lang, buttonSize)) {
|
2023-06-20 11:55:56 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|