mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Utils: Move GetListPropertyItems to utils
This commit is contained in:
parent
851a6f8c5a
commit
4d65c2adee
@ -616,32 +616,6 @@ RequestResult RequestHandler::SetInputAudioMonitorType(const Request& request)
|
|||||||
return RequestResult::Success();
|
return RequestResult::Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<json> GetListPropertyItems(obs_property_t *property)
|
|
||||||
{
|
|
||||||
std::vector<json> ret;
|
|
||||||
|
|
||||||
enum obs_combo_format itemFormat = obs_property_list_format(property);
|
|
||||||
size_t itemCount = obs_property_list_item_count(property);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < itemCount; i++) {
|
|
||||||
json itemData;
|
|
||||||
itemData["itemName"] = obs_property_list_item_name(property, i);
|
|
||||||
itemData["itemEnabled"] = !obs_property_list_item_disabled(property, i);
|
|
||||||
if (itemFormat == OBS_COMBO_FORMAT_INT) {
|
|
||||||
itemData["itemValue"] = obs_property_list_item_int(property, i);
|
|
||||||
} else if (itemFormat == OBS_COMBO_FORMAT_FLOAT) {
|
|
||||||
itemData["itemValue"] = obs_property_list_item_float(property, i);
|
|
||||||
} else if (itemFormat == OBS_COMBO_FORMAT_STRING) {
|
|
||||||
itemData["itemValue"] = obs_property_list_item_string(property, i);
|
|
||||||
} else {
|
|
||||||
itemData["itemValue"] = nullptr;
|
|
||||||
}
|
|
||||||
ret.push_back(itemData);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items of a list property from an input's properties.
|
* Gets the items of a list property from an input's properties.
|
||||||
*
|
*
|
||||||
@ -677,7 +651,7 @@ RequestResult RequestHandler::GetInputPropertiesListPropertyItems(const Request&
|
|||||||
return RequestResult::Error(RequestStatus::InvalidResourceType, "The property found is not a list.");
|
return RequestResult::Error(RequestStatus::InvalidResourceType, "The property found is not a list.");
|
||||||
|
|
||||||
json responseData;
|
json responseData;
|
||||||
responseData["propertyItems"] = GetListPropertyItems(property);
|
responseData["propertyItems"] = Utils::Obs::ArrayHelper::GetListPropertyItems(property);
|
||||||
|
|
||||||
return RequestResult::Success(responseData);
|
return RequestResult::Success(responseData);
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,7 @@ namespace Utils {
|
|||||||
std::vector<json> GetSceneItemList(obs_scene_t *scene, bool basic = false);
|
std::vector<json> GetSceneItemList(obs_scene_t *scene, bool basic = false);
|
||||||
std::vector<json> GetInputList(std::string inputKind = "");
|
std::vector<json> GetInputList(std::string inputKind = "");
|
||||||
std::vector<std::string> GetInputKindList(bool unversioned = false, bool includeDisabled = false);
|
std::vector<std::string> GetInputKindList(bool unversioned = false, bool includeDisabled = false);
|
||||||
|
std::vector<json> GetListPropertyItems(obs_property_t *property);
|
||||||
std::vector<std::string> GetTransitionKindList();
|
std::vector<std::string> GetTransitionKindList();
|
||||||
std::vector<json> GetSceneTransitionList();
|
std::vector<json> GetSceneTransitionList();
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,32 @@ std::vector<std::string> Utils::Obs::ArrayHelper::GetInputKindList(bool unversio
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<json> Utils::Obs::ArrayHelper::GetListPropertyItems(obs_property_t *property)
|
||||||
|
{
|
||||||
|
std::vector<json> ret;
|
||||||
|
|
||||||
|
enum obs_combo_format itemFormat = obs_property_list_format(property);
|
||||||
|
size_t itemCount = obs_property_list_item_count(property);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < itemCount; i++) {
|
||||||
|
json itemData;
|
||||||
|
itemData["itemName"] = obs_property_list_item_name(property, i);
|
||||||
|
itemData["itemEnabled"] = !obs_property_list_item_disabled(property, i);
|
||||||
|
if (itemFormat == OBS_COMBO_FORMAT_INT) {
|
||||||
|
itemData["itemValue"] = obs_property_list_item_int(property, i);
|
||||||
|
} else if (itemFormat == OBS_COMBO_FORMAT_FLOAT) {
|
||||||
|
itemData["itemValue"] = obs_property_list_item_float(property, i);
|
||||||
|
} else if (itemFormat == OBS_COMBO_FORMAT_STRING) {
|
||||||
|
itemData["itemValue"] = obs_property_list_item_string(property, i);
|
||||||
|
} else {
|
||||||
|
itemData["itemValue"] = nullptr;
|
||||||
|
}
|
||||||
|
ret.push_back(itemData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> Utils::Obs::ArrayHelper::GetTransitionKindList()
|
std::vector<std::string> Utils::Obs::ArrayHelper::GetTransitionKindList()
|
||||||
{
|
{
|
||||||
std::vector<std::string> ret;
|
std::vector<std::string> ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user