mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-24 02:14:22 +00:00
ImGuiStorage: Added bool helper functions for completeness.
This commit is contained in:
parent
ce4d731486
commit
69cc00f91f
2 changed files with 19 additions and 1 deletions
15
imgui.cpp
15
imgui.cpp
|
|
@ -1313,6 +1313,11 @@ int ImGuiStorage::GetInt(ImU32 key, int default_val) const
|
|||
return it->val_i;
|
||||
}
|
||||
|
||||
bool ImGuiStorage::GetBool(ImU32 key, bool default_val) const
|
||||
{
|
||||
return GetInt(key, default_val ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
float ImGuiStorage::GetFloat(ImU32 key, float default_val) const
|
||||
{
|
||||
ImVector<Pair>::iterator it = LowerBound(const_cast<ImVector<ImGuiStorage::Pair>&>(Data), key);
|
||||
|
|
@ -1338,6 +1343,11 @@ int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val)
|
|||
return &it->val_i;
|
||||
}
|
||||
|
||||
bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val)
|
||||
{
|
||||
return (bool*)GetIntRef(key, default_val ? 1 : 0);
|
||||
}
|
||||
|
||||
float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val)
|
||||
{
|
||||
ImVector<Pair>::iterator it = LowerBound(Data, key);
|
||||
|
|
@ -1366,6 +1376,11 @@ void ImGuiStorage::SetInt(ImU32 key, int val)
|
|||
it->val_i = val;
|
||||
}
|
||||
|
||||
void ImGuiStorage::SetBool(ImU32 key, bool val)
|
||||
{
|
||||
SetInt(key, val ? 1 : 0);
|
||||
}
|
||||
|
||||
void ImGuiStorage::SetFloat(ImU32 key, float val)
|
||||
{
|
||||
ImVector<Pair>::iterator it = LowerBound(Data, key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue