mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 21:05:56 -05:00
feat: Added option to specify max file size to load into memory
This commit is contained in:
@@ -99,7 +99,7 @@ namespace hex {
|
||||
bool m_requiresRestart = false;
|
||||
std::function<bool()> m_enabledCallback;
|
||||
std::function<void(Widget&)> m_changedCallback;
|
||||
std::optional<std::string> m_tooltip;
|
||||
std::optional<UnlocalizedString> m_tooltip;
|
||||
};
|
||||
|
||||
[[nodiscard]]
|
||||
@@ -113,7 +113,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
const std::optional<std::string>& getTooltip() const {
|
||||
const std::optional<UnlocalizedString>& getTooltip() const {
|
||||
return m_interface.m_tooltip;
|
||||
}
|
||||
|
||||
@@ -176,6 +176,21 @@ namespace hex {
|
||||
float m_min, m_max;
|
||||
};
|
||||
|
||||
class SliderDataSize : public Widget {
|
||||
public:
|
||||
SliderDataSize(u64 defaultValue, u64 min, u64 max) : m_value(defaultValue), m_min(min), m_max(max) { }
|
||||
bool draw(const std::string &name) override;
|
||||
|
||||
void load(const nlohmann::json &data) override;
|
||||
nlohmann::json store() override;
|
||||
|
||||
[[nodiscard]] i32 getValue() const { return m_value; }
|
||||
|
||||
protected:
|
||||
u64 m_value;
|
||||
u64 m_min, m_max;
|
||||
};
|
||||
|
||||
class ColorPicker : public Widget {
|
||||
public:
|
||||
explicit ColorPicker(ImColor defaultColor);
|
||||
|
||||
@@ -312,6 +312,23 @@ namespace hex {
|
||||
}
|
||||
|
||||
|
||||
bool SliderDataSize::draw(const std::string &name) {
|
||||
return ImGuiExt::SliderBytes(name.c_str(), &m_value, m_min, m_max);
|
||||
}
|
||||
|
||||
void SliderDataSize::load(const nlohmann::json &data) {
|
||||
if (data.is_number_integer()) {
|
||||
m_value = data.get<u64>();
|
||||
} else {
|
||||
log::warn("Invalid data type loaded from settings for slider!");
|
||||
}
|
||||
}
|
||||
|
||||
nlohmann::json SliderDataSize::store() {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
ColorPicker::ColorPicker(ImColor defaultColor) {
|
||||
m_value = {
|
||||
defaultColor.Value.x,
|
||||
|
||||
@@ -573,12 +573,16 @@ namespace ImGuiExt {
|
||||
bool result = false;
|
||||
if (IsItemHovered() && (currTime - lastMoveTime) >= 0.5 && hoveredID == lastHoveredID) {
|
||||
if (!std::string_view(text).empty()) {
|
||||
BeginTooltip();
|
||||
if (isSeparator)
|
||||
SeparatorText(text);
|
||||
else
|
||||
TextUnformatted(text);
|
||||
EndTooltip();
|
||||
const auto width = 300 * hex::ImHexApi::System::getGlobalScale();
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(width, 0), ImVec2(width, FLT_MAX));
|
||||
if (BeginTooltip()) {
|
||||
if (isSeparator)
|
||||
SeparatorText(text);
|
||||
else
|
||||
TextFormattedWrapped("{}", text);
|
||||
|
||||
EndTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
result = true;
|
||||
|
||||
Reference in New Issue
Block a user