mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-04-25 07:57:04 -05:00
Fix BlackListEdit not closing on empty.
This commit is contained in:
parent
9b80fa5dc8
commit
fb88c7939a
52
include/json.hpp
Normal file
52
include/json.hpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#pragma once
|
||||
#include <json-c/json.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace json
|
||||
{
|
||||
// Use this instead of default json_object
|
||||
using Object = std::unique_ptr<json_object, decltype(&json_object_put)>;
|
||||
|
||||
// Use this instead of json_object_from_x. Pass the function and its arguments instead.
|
||||
template <typename... Args>
|
||||
static inline json::Object new_object(json_object *(*function)(Args...), Args... args)
|
||||
{
|
||||
return json::Object((*function)(args...), json_object_put);
|
||||
}
|
||||
|
||||
/// @brief Inline wrapper function for getting a json object by it's key.
|
||||
/// @param json json::Object to get the key from.
|
||||
/// @param key Key to get.
|
||||
/// @return json_object on success. NULL on failure.
|
||||
static inline json_object *get_object(json::Object &json, std::string_view key)
|
||||
{
|
||||
return json_object_object_get(json.get(), key.data());
|
||||
}
|
||||
|
||||
/// @brief Inline wrapper function to add an object to a json_object
|
||||
/// @param json Json object to add an object to.
|
||||
/// @param key Key of the object.
|
||||
/// @param object Object to add to json.
|
||||
/// @return True on success. False on failure.
|
||||
static inline bool add_object(json::Object &json, std::string_view key, json_object *object)
|
||||
{
|
||||
return json_object_object_add(json.get(), key.data(), object) == 0;
|
||||
}
|
||||
|
||||
/// @brief Returns the json string.
|
||||
static inline const char *get_string(json::Object &json) { return json_object_get_string(json.get()); }
|
||||
|
||||
/// @brief Returns the length of the string. I find json_object_get_string_len is unreliable?
|
||||
static inline int64_t length(json::Object &json)
|
||||
{
|
||||
const char *string = json_object_get_string(json.get());
|
||||
return std::char_traits<char>::length(string);
|
||||
}
|
||||
|
||||
/// @brief Returns the beginning for iterating.
|
||||
static inline json_object_iterator iter_begin(json::Object &json) { return json_object_iter_begin(json.get()); }
|
||||
|
||||
/// @brief Returns the end for iterating.
|
||||
static inline json_object_iterator iter_end(json::Object &json) { return json_object_iter_end(json.get()); }
|
||||
} // namespace json
|
||||
|
|
@ -25,8 +25,8 @@ void BlacklistEditState::update()
|
|||
sm_slidePanel->update(hasFocus);
|
||||
|
||||
if (aPressed) { BlacklistEditState::remove_from_blacklist(); }
|
||||
else if (bPressed || config::blacklist_is_empty()) { sm_slidePanel->close(); }
|
||||
else if (sm_slidePanel->is_closed()) { BlacklistEditState::deactivate_state(); }
|
||||
else if (bPressed || m_blacklist.empty()) { sm_slidePanel->close(); }
|
||||
}
|
||||
|
||||
void BlacklistEditState::render()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "CmdArgs.hpp"
|
||||
#include "cmdargs.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user