2023-12-16 17:10:45 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "WUPSConfigItem.h"
|
|
|
|
#include <wups/config.h>
|
2021-09-24 19:57:15 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct ConfigItemBoolean {
|
|
|
|
WUPSConfigItemHandle handle;
|
2023-12-16 17:10:45 +01:00
|
|
|
const char *identifier;
|
2021-09-24 19:57:15 +02:00
|
|
|
bool defaultValue;
|
2023-12-16 17:10:45 +01:00
|
|
|
bool valueAtCreation;
|
2021-09-24 19:57:15 +02:00
|
|
|
bool value;
|
|
|
|
char trueValue[32];
|
|
|
|
char falseValue[32];
|
2023-12-16 17:10:45 +01:00
|
|
|
void *valueChangedCallback;
|
2021-09-24 19:57:15 +02:00
|
|
|
} ConfigItemBoolean;
|
|
|
|
|
|
|
|
typedef void (*BooleanValueChangedCallback)(ConfigItemBoolean *, bool);
|
|
|
|
|
2023-12-16 17:10:45 +01:00
|
|
|
WUPSConfigAPIStatus
|
|
|
|
WUPSConfigItemBoolean_CreateEx(const char *identifier,
|
|
|
|
const char *displayName,
|
|
|
|
bool defaultValue,
|
|
|
|
bool currentValue,
|
|
|
|
BooleanValueChangedCallback callback,
|
|
|
|
const char *trueValue,
|
|
|
|
const char *falseValue,
|
|
|
|
WUPSConfigItemHandle *outHandle);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Adds a boolean configuration item to the specified category.
|
|
|
|
*
|
|
|
|
* This function adds a boolean configuration item to the given category. The item is displayed with a specified display name.
|
|
|
|
* The default value and current value of the item are set to the provided values. A callback function is called whenever
|
|
|
|
* the value of the item changes.
|
|
|
|
*
|
|
|
|
* @param cat The handle of the category to add the item to.
|
|
|
|
* @param identifier Optional identifier for the item. Can be NULL.
|
|
|
|
* @param displayName The display name of the item.
|
|
|
|
* @param defaultValue The default value of the item.
|
|
|
|
* @param currentValue The current value of the item.
|
|
|
|
* @param callback A callback function that will be called when the config menu closes and the value of the item has been changed.
|
|
|
|
* @return True if the item was added successfully, false otherwise.
|
|
|
|
*/
|
|
|
|
WUPSConfigAPIStatus
|
|
|
|
WUPSConfigItemBoolean_AddToCategory(WUPSConfigCategoryHandle cat,
|
|
|
|
const char *identifier,
|
|
|
|
const char *displayName,
|
|
|
|
bool defaultValue,
|
|
|
|
bool currentValue,
|
|
|
|
BooleanValueChangedCallback callback);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Adds a boolean configuration item to the specified category.
|
|
|
|
*
|
|
|
|
* This function adds a boolean configuration item to the given category. The item is displayed with a specified display name.
|
|
|
|
* The default value and current value of the item are set to the provided values. A callback function is called whenever
|
|
|
|
* the value of the item changes.
|
|
|
|
*
|
|
|
|
* @param cat The handle of the category to add the item to.
|
|
|
|
* @param identifier Optional identifier for the item. Can be NULL.
|
|
|
|
* @param displayName The display name of the item.
|
|
|
|
* @param defaultValue The default value of the item.
|
|
|
|
* @param currentValue The current value of the item.
|
|
|
|
* @param callback A callback function that will be called when the config menu closes and the value of the item has been changed.
|
|
|
|
* @param trueValue The string representation of the true value.
|
|
|
|
* @param falseValue The string representation of the false value.
|
|
|
|
* @return True if the item was successfully added to the category, false otherwise.
|
|
|
|
*/
|
|
|
|
WUPSConfigAPIStatus
|
|
|
|
WUPSConfigItemBoolean_AddToCategoryEx(WUPSConfigCategoryHandle cat,
|
|
|
|
const char *identifier,
|
|
|
|
const char *displayName,
|
|
|
|
bool defaultValue,
|
|
|
|
bool currentValue,
|
|
|
|
BooleanValueChangedCallback callback,
|
|
|
|
const char *trueValue,
|
|
|
|
const char *falseValue);
|
2021-09-24 19:57:15 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2023-12-16 17:10:45 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
|
|
#include "WUPSConfigItem.h"
|
|
|
|
#include <optional>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <string>
|
|
|
|
#include <wups/config_api.h>
|
|
|
|
|
|
|
|
class WUPSConfigItemBoolean : public WUPSConfigItem {
|
|
|
|
public:
|
|
|
|
static std::optional<WUPSConfigItemBoolean> CreateEx(std::optional<std::string> identifier,
|
|
|
|
std::string_view displayName,
|
|
|
|
bool defaultValue,
|
|
|
|
bool currentValue,
|
|
|
|
BooleanValueChangedCallback callback,
|
|
|
|
std::string_view trueValue,
|
|
|
|
std::string_view falseValue,
|
|
|
|
WUPSConfigAPIStatus &err) noexcept;
|
|
|
|
|
|
|
|
static WUPSConfigItemBoolean CreateEx(std::optional<std::string> identifier,
|
|
|
|
std::string_view displayName,
|
|
|
|
bool defaultValue,
|
|
|
|
bool currentValue,
|
|
|
|
BooleanValueChangedCallback callback,
|
|
|
|
std::string_view trueValue,
|
|
|
|
std::string_view falseValue);
|
|
|
|
|
|
|
|
static std::optional<WUPSConfigItemBoolean> Create(std::optional<std::string> identifier,
|
|
|
|
std::string_view displayName,
|
|
|
|
bool defaultValue,
|
|
|
|
bool currentValue,
|
|
|
|
BooleanValueChangedCallback callback,
|
|
|
|
WUPSConfigAPIStatus &err) noexcept;
|
|
|
|
|
|
|
|
static WUPSConfigItemBoolean Create(std::optional<std::string> identifier,
|
|
|
|
std::string_view displayName,
|
|
|
|
bool defaultValue,
|
|
|
|
bool currentValue,
|
|
|
|
BooleanValueChangedCallback callback);
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit WUPSConfigItemBoolean(WUPSConfigItemHandle itemHandle) : WUPSConfigItem(itemHandle) {
|
|
|
|
}
|
|
|
|
};
|
2021-09-24 19:57:15 +02:00
|
|
|
#endif
|