ui: Fix hash function name localization
This commit is contained in:
parent
653a688fe6
commit
5551e82fea
@ -426,7 +426,7 @@ namespace hex {
|
|||||||
|
|
||||||
class Hash {
|
class Hash {
|
||||||
public:
|
public:
|
||||||
Hash(std::string name) : m_name(std::move(name)) {}
|
Hash(std::string unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {}
|
||||||
|
|
||||||
class Function {
|
class Function {
|
||||||
public:
|
public:
|
||||||
@ -463,8 +463,8 @@ namespace hex {
|
|||||||
virtual void draw() { }
|
virtual void draw() { }
|
||||||
[[nodiscard]] virtual Function create(std::string name) = 0;
|
[[nodiscard]] virtual Function create(std::string name) = 0;
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getName() const {
|
[[nodiscard]] const std::string &getUnlocalizedName() const {
|
||||||
return this->m_name;
|
return this->m_unlocalizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -473,7 +473,7 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_name;
|
std::string m_unlocalizedName;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace impl {
|
namespace impl {
|
||||||
|
@ -8,7 +8,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class HashMD5 : public ContentRegistry::Hashes::Hash {
|
class HashMD5 : public ContentRegistry::Hashes::Hash {
|
||||||
public:
|
public:
|
||||||
HashMD5() : Hash("hex.builtin.hash.md5"_lang) {}
|
HashMD5() : Hash("hex.builtin.hash.md5") {}
|
||||||
|
|
||||||
Function create(std::string name) override {
|
Function create(std::string name) override {
|
||||||
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
||||||
@ -21,7 +21,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class HashSHA1 : public ContentRegistry::Hashes::Hash {
|
class HashSHA1 : public ContentRegistry::Hashes::Hash {
|
||||||
public:
|
public:
|
||||||
HashSHA1() : Hash("hex.builtin.hash.sha1"_lang) {}
|
HashSHA1() : Hash("hex.builtin.hash.sha1") {}
|
||||||
|
|
||||||
Function create(std::string name) override {
|
Function create(std::string name) override {
|
||||||
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
||||||
@ -34,7 +34,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class HashSHA224 : public ContentRegistry::Hashes::Hash {
|
class HashSHA224 : public ContentRegistry::Hashes::Hash {
|
||||||
public:
|
public:
|
||||||
HashSHA224() : Hash("hex.builtin.hash.sha224"_lang) {}
|
HashSHA224() : Hash("hex.builtin.hash.sha224") {}
|
||||||
|
|
||||||
Function create(std::string name) override {
|
Function create(std::string name) override {
|
||||||
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
||||||
@ -47,7 +47,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class HashSHA256 : public ContentRegistry::Hashes::Hash {
|
class HashSHA256 : public ContentRegistry::Hashes::Hash {
|
||||||
public:
|
public:
|
||||||
HashSHA256() : Hash("hex.builtin.hash.sha256"_lang) {}
|
HashSHA256() : Hash("hex.builtin.hash.sha256") {}
|
||||||
|
|
||||||
Function create(std::string name) override {
|
Function create(std::string name) override {
|
||||||
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
||||||
@ -60,7 +60,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class HashSHA384 : public ContentRegistry::Hashes::Hash {
|
class HashSHA384 : public ContentRegistry::Hashes::Hash {
|
||||||
public:
|
public:
|
||||||
HashSHA384() : Hash("hex.builtin.hash.sha384"_lang) {}
|
HashSHA384() : Hash("hex.builtin.hash.sha384") {}
|
||||||
|
|
||||||
Function create(std::string name) override {
|
Function create(std::string name) override {
|
||||||
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
return Hash::create(name, [](const Region& region, prv::Provider *provider) -> std::vector<u8> {
|
||||||
@ -131,9 +131,9 @@ namespace hex::plugin::builtin {
|
|||||||
ContentRegistry::Hashes::add<HashSHA384>();
|
ContentRegistry::Hashes::add<HashSHA384>();
|
||||||
ContentRegistry::Hashes::add<HashSHA512>();
|
ContentRegistry::Hashes::add<HashSHA512>();
|
||||||
|
|
||||||
ContentRegistry::Hashes::add<HashCRC<u16>>("hex.builtin.hash.crc8"_lang, crypt::crc8, 0x07, 0x0000, 0x0000);
|
ContentRegistry::Hashes::add<HashCRC<u16>>("hex.builtin.hash.crc8", crypt::crc8, 0x07, 0x0000, 0x0000);
|
||||||
ContentRegistry::Hashes::add<HashCRC<u16>>("hex.builtin.hash.crc16"_lang, crypt::crc16, 0x8005, 0x0000, 0x0000);
|
ContentRegistry::Hashes::add<HashCRC<u16>>("hex.builtin.hash.crc16", crypt::crc16, 0x8005, 0x0000, 0x0000);
|
||||||
ContentRegistry::Hashes::add<HashCRC<u32>>("hex.builtin.hash.crc32"_lang, crypt::crc32, 0x04C1'1DB7, 0xFFFF'FFFF, 0xFFFF'FFFF);
|
ContentRegistry::Hashes::add<HashCRC<u32>>("hex.builtin.hash.crc32", crypt::crc32, 0x04C1'1DB7, 0xFFFF'FFFF, 0xFFFF'FFFF);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,10 +70,10 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Begin(View::toWindowName("hex.builtin.view.hashes.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
|
if (ImGui::Begin(View::toWindowName("hex.builtin.view.hashes.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
|
||||||
if (ImGui::BeginCombo("hex.builtin.view.hashes.function"_lang, this->m_selectedHash != nullptr ? this->m_selectedHash->getName().c_str() : "")) {
|
if (ImGui::BeginCombo("hex.builtin.view.hashes.function"_lang, this->m_selectedHash != nullptr ? LangEntry(this->m_selectedHash->getUnlocalizedName()) : "")) {
|
||||||
|
|
||||||
for (const auto hash : hashes) {
|
for (const auto hash : hashes) {
|
||||||
if (ImGui::Selectable(hash->getName().c_str(), this->m_selectedHash == hash)) {
|
if (ImGui::Selectable(LangEntry(hash->getUnlocalizedName()), this->m_selectedHash == hash)) {
|
||||||
this->m_selectedHash = hash;
|
this->m_selectedHash = hash;
|
||||||
this->m_newHashName.clear();
|
this->m_newHashName.clear();
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->m_newHashName.empty() && this->m_selectedHash != nullptr)
|
if (this->m_newHashName.empty() && this->m_selectedHash != nullptr)
|
||||||
this->m_newHashName = hex::format("{} {}", this->m_selectedHash->getName(), static_cast<const char *>("hex.builtin.view.hashes.hash"_lang));
|
this->m_newHashName = hex::format("{} {}", LangEntry(this->m_selectedHash->getUnlocalizedName()), static_cast<const char *>("hex.builtin.view.hashes.hash"_lang));
|
||||||
|
|
||||||
if (ImGui::BeginChild("##settings", ImVec2(ImGui::GetContentRegionAvailWidth(), 200_scaled), true)) {
|
if (ImGui::BeginChild("##settings", ImVec2(ImGui::GetContentRegionAvailWidth(), 200_scaled), true)) {
|
||||||
if (this->m_selectedHash != nullptr) {
|
if (this->m_selectedHash != nullptr) {
|
||||||
@ -150,7 +150,7 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextFormatted("{}", function.getType()->getName());
|
ImGui::TextFormatted("{}", LangEntry(function.getType()->getUnlocalizedName()));
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
std::string result;
|
std::string result;
|
||||||
|
Loading…
Reference in New Issue
Block a user