mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
Various fixes and improvements
This commit is contained in:
@@ -122,21 +122,21 @@ namespace hex {
|
||||
}
|
||||
|
||||
std::string toEngineeringString(double value) {
|
||||
constexpr std::array prefixes = { "a", "f", "p", "n", "u", "m", "", "k", "M", "G", "T", "P", "E" };
|
||||
constexpr std::array Suffixes = { "a", "f", "p", "n", "u", "m", "", "k", "M", "G", "T", "P", "E" };
|
||||
|
||||
int8_t prefixIndex = 6;
|
||||
int8_t suffixIndex = 6;
|
||||
|
||||
while (prefixIndex != 0 && prefixIndex != 12 && (value >= 1000 || value < 1) && value != 0) {
|
||||
while (suffixIndex != 0 && suffixIndex != 12 && (value >= 1000 || value < 1) && value != 0) {
|
||||
if (value >= 1000) {
|
||||
value /= 1000;
|
||||
prefixIndex++;
|
||||
suffixIndex++;
|
||||
} else if (value < 1) {
|
||||
value *= 1000;
|
||||
prefixIndex--;
|
||||
suffixIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
return std::to_string(value).substr(0, 5) + prefixes[prefixIndex];
|
||||
return std::to_string(value).substr(0, 5) + Suffixes[suffixIndex];
|
||||
}
|
||||
|
||||
std::vector<u8> readFile(std::string_view path) {
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace hex {
|
||||
}
|
||||
|
||||
void View::drawCommonInterfaces() {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 10));
|
||||
if (ImGui::BeginPopupModal("Error", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::Text("%s", SharedData::errorPopupMessage.c_str());
|
||||
ImGui::NewLine();
|
||||
@@ -50,7 +49,6 @@ namespace hex {
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
if (SharedData::fileBrowser.showFileDialog(SharedData::fileBrowserTitle, SharedData::fileBrowserDialogMode, ImVec2(0, 0), SharedData::fileBrowserValidExtensions)) {
|
||||
SharedData::fileBrowserCallback(SharedData::fileBrowser.selected_path);
|
||||
@@ -61,7 +59,7 @@ namespace hex {
|
||||
void View::showErrorPopup(std::string_view errorMessage) {
|
||||
SharedData::errorPopupMessage = errorMessage;
|
||||
|
||||
ImGui::OpenPopup("Error");
|
||||
View::doLater([] { ImGui::OpenPopup("Error"); });
|
||||
}
|
||||
|
||||
bool View::hasViewMenuItemEntry() {
|
||||
|
||||
Reference in New Issue
Block a user