1
0
mirror of synced 2025-01-11 05:42:15 +01:00

impr: Make maximum in-memory file size setting easier to use. Bump value to 512MiB

This commit is contained in:
WerWolv 2025-01-04 13:56:20 +01:00
parent 8da69c11d9
commit f94819351a
5 changed files with 16 additions and 6 deletions

View File

@ -176,7 +176,7 @@ namespace hex {
class SliderDataSize : public Widget { class SliderDataSize : public Widget {
public: public:
SliderDataSize(u64 defaultValue, u64 min, u64 max) : m_value(defaultValue), m_min(min), m_max(max) { } SliderDataSize(u64 defaultValue, u64 min, u64 max, u64 stepSize) : m_value(defaultValue), m_min(min), m_max(max), m_stepSize(stepSize) { }
bool draw(const std::string &name) override; bool draw(const std::string &name) override;
void load(const nlohmann::json &data) override; void load(const nlohmann::json &data) override;
@ -187,6 +187,7 @@ namespace hex {
protected: protected:
u64 m_value; u64 m_value;
u64 m_min, m_max; u64 m_min, m_max;
u64 m_stepSize;
}; };
class ColorPicker : public Widget { class ColorPicker : public Widget {

View File

@ -150,7 +150,7 @@ namespace ImGuiExt {
bool InputHexadecimal(const char* label, u32 *value, ImGuiInputTextFlags flags = ImGuiInputTextFlags_None); bool InputHexadecimal(const char* label, u32 *value, ImGuiInputTextFlags flags = ImGuiInputTextFlags_None);
bool InputHexadecimal(const char* label, u64 *value, ImGuiInputTextFlags flags = ImGuiInputTextFlags_None); bool InputHexadecimal(const char* label, u64 *value, ImGuiInputTextFlags flags = ImGuiInputTextFlags_None);
bool SliderBytes(const char *label, u64 *value, u64 min, u64 max, ImGuiSliderFlags flags = ImGuiSliderFlags_None); bool SliderBytes(const char *label, u64 *value, u64 min, u64 max, u64 stepSize = 1, ImGuiSliderFlags flags = ImGuiSliderFlags_None);
inline bool HasSecondPassed() { inline bool HasSecondPassed() {
return static_cast<ImU32>(ImGui::GetTime() * 100) % 100 <= static_cast<ImU32>(ImGui::GetIO().DeltaTime * 100); return static_cast<ImU32>(ImGui::GetTime() * 100) % 100 <= static_cast<ImU32>(ImGui::GetIO().DeltaTime * 100);

View File

@ -333,7 +333,7 @@ namespace hex {
bool SliderDataSize::draw(const std::string &name) { bool SliderDataSize::draw(const std::string &name) {
return ImGuiExt::SliderBytes(name.c_str(), &m_value, m_min, m_max); return ImGuiExt::SliderBytes(name.c_str(), &m_value, m_min, m_max, m_stepSize);
} }
void SliderDataSize::load(const nlohmann::json &data) { void SliderDataSize::load(const nlohmann::json &data) {

View File

@ -913,8 +913,9 @@ namespace ImGuiExt {
return InputIntegerPrefix(label, "0x", value, ImGuiDataType_U64, "%llX", flags | ImGuiInputTextFlags_CharsHexadecimal); return InputIntegerPrefix(label, "0x", value, ImGuiDataType_U64, "%llX", flags | ImGuiInputTextFlags_CharsHexadecimal);
} }
bool SliderBytes(const char *label, u64 *value, u64 min, u64 max, ImGuiSliderFlags flags) { bool SliderBytes(const char *label, u64 *value, u64 min, u64 max, u64 stepSize, ImGuiSliderFlags flags) {
std::string format; std::string format;
if (*value < 1024) { if (*value < 1024) {
format = hex::format("{} Bytes", *value); format = hex::format("{} Bytes", *value);
} else if (*value < 1024 * 1024) { } else if (*value < 1024 * 1024) {
@ -925,7 +926,15 @@ namespace ImGuiExt {
format = hex::format("{:.2f} GB", *value / (1024.0 * 1024.0 * 1024.0)); format = hex::format("{:.2f} GB", *value / (1024.0 * 1024.0 * 1024.0));
} }
return ImGui::SliderScalar(label, ImGuiDataType_U64, value, &min, &max, format.c_str(), flags | ImGuiSliderFlags_Logarithmic); *value /= stepSize;
min /= stepSize;
max /= stepSize;
auto result = ImGui::SliderScalar(label, ImGuiDataType_U64, value, &min, &max, format.c_str(), flags | ImGuiSliderFlags_Logarithmic);
*value *= stepSize;
return result;
} }
void SmallProgressBar(float fraction, float yOffset) { void SmallProgressBar(float fraction, float yOffset) {

View File

@ -749,7 +749,7 @@ namespace hex::plugin::builtin {
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.show_tips", false); ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.show_tips", false);
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.save_recent_providers", true); ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.save_recent_providers", true);
ContentRegistry::Settings::add<AutoBackupWidget>("hex.builtin.setting.general", "", "hex.builtin.setting.general.auto_backup_time"); ContentRegistry::Settings::add<AutoBackupWidget>("hex.builtin.setting.general", "", "hex.builtin.setting.general.auto_backup_time");
ContentRegistry::Settings::add<Widgets::SliderDataSize>("hex.builtin.setting.general", "", "hex.builtin.setting.general.max_mem_file_size", 128_MiB, 0_bytes, 32_GiB) ContentRegistry::Settings::add<Widgets::SliderDataSize>("hex.builtin.setting.general", "", "hex.builtin.setting.general.max_mem_file_size", 512_MiB, 0_bytes, 32_GiB, 1_MiB)
.setTooltip("hex.builtin.setting.general.max_mem_file_size.desc"); .setTooltip("hex.builtin.setting.general.max_mem_file_size.desc");
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.auto_load_patterns", true); ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.auto_load_patterns", true);
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.sync_pattern_source", false); ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.sync_pattern_source", false);