mirror of
https://github.com/wiiu-env/ScreenshotWUPS.git
synced 2025-02-16 19:49:11 +01:00
Use the configId in config-callbacks to share the same callback for multiple config items
This commit is contained in:
parent
9bd2fb739e
commit
51b0a754b7
@ -1,6 +1,6 @@
|
|||||||
FROM wiiuenv/devkitppc:20220917
|
FROM wiiuenv/devkitppc:20220917
|
||||||
|
|
||||||
COPY --from=wiiuenv/wiiupluginsystem:20220904 /artifacts $DEVKITPRO
|
COPY --from=wiiuenv/wiiupluginsystem:20220924 /artifacts $DEVKITPRO
|
||||||
COPY --from=wiiuenv/libmappedmemory:20220904 /artifacts $DEVKITPRO
|
COPY --from=wiiuenv/libmappedmemory:20220904 /artifacts $DEVKITPRO
|
||||||
|
|
||||||
WORKDIR project
|
WORKDIR project
|
47
src/main.cpp
47
src/main.cpp
@ -94,30 +94,33 @@ INITIALIZE_PLUGIN() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void formatChanged(ConfigItemMultipleValues *item, uint32_t newValue) {
|
void multipleValueItemCallback(ConfigItemMultipleValues *item, uint32_t newValue) {
|
||||||
DEBUG_FUNCTION_LINE("New value in %s changed: %d", item->configID, newValue);
|
if (item && item->configId) {
|
||||||
|
DEBUG_FUNCTION_LINE("New value in %s changed: %d", item->configId, newValue);
|
||||||
|
if (std::string_view(item->configId) == FORMAT_CONFIG_STRING) {
|
||||||
gOutputFormat = (ImageOutputFormatEnum) newValue;
|
gOutputFormat = (ImageOutputFormatEnum) newValue;
|
||||||
|
|
||||||
if (gOutputFormat >= 3) {
|
if (gOutputFormat >= 3) {
|
||||||
gOutputFormat = IMAGE_OUTPUT_FORMAT_JPEG;
|
gOutputFormat = IMAGE_OUTPUT_FORMAT_JPEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPS_StoreInt(nullptr, item->configID, (int32_t) newValue);
|
WUPS_StoreInt(nullptr, item->configId, (int32_t) newValue);
|
||||||
}
|
} else if (std::string_view(item->configId) == SCREEN_CONFIG_STRING) {
|
||||||
|
|
||||||
void imageSourceChanged(ConfigItemMultipleValues *item, uint32_t newValue) {
|
|
||||||
DEBUG_FUNCTION_LINE("New value in %s changed: %d", item->configID, newValue);
|
|
||||||
gImageSource = (ImageSourceEnum) newValue;
|
gImageSource = (ImageSourceEnum) newValue;
|
||||||
|
|
||||||
if (gImageSource >= 3) {
|
if (gImageSource >= 3) {
|
||||||
gImageSource = IMAGE_SOURCE_TV_AND_DRC;
|
gImageSource = IMAGE_SOURCE_TV_AND_DRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPS_StoreInt(nullptr, item->configID, (int32_t) newValue);
|
WUPS_StoreInt(nullptr, item->configId, (int32_t) newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qualityChanged(ConfigItemIntegerRange *item, int32_t newValue) {
|
void integerRangeItemCallback(ConfigItemIntegerRange *item, int32_t newValue) {
|
||||||
DEBUG_FUNCTION_LINE("New quality: %d", newValue);
|
if (item && item->configId) {
|
||||||
|
DEBUG_FUNCTION_LINE("New value in %s changed: %d", item->configId, newValue);
|
||||||
|
if (std::string_view(item->configId) == QUALITY_CONFIG_STRING) {
|
||||||
gQuality = (ImageOutputFormatEnum) newValue;
|
gQuality = (ImageOutputFormatEnum) newValue;
|
||||||
|
|
||||||
if (gQuality < 10) {
|
if (gQuality < 10) {
|
||||||
@ -126,14 +129,20 @@ void qualityChanged(ConfigItemIntegerRange *item, int32_t newValue) {
|
|||||||
gQuality = 100;
|
gQuality = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPS_StoreInt(nullptr, QUALITY_CONFIG_STRING, (int32_t) gQuality);
|
WUPS_StoreInt(nullptr, item->configId, (int32_t) gQuality);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enabledChanged(ConfigItemBoolean *item, bool newValue) {
|
void boolItemCallback(ConfigItemBoolean *item, bool newValue) {
|
||||||
DEBUG_FUNCTION_LINE("gEnabled new value: %d", newValue);
|
if (item && item->configId) {
|
||||||
|
DEBUG_FUNCTION_LINE("New value in %s changed: %d", item->configId, newValue);
|
||||||
|
if (std::string_view(item->configId) == ENABLED_CONFIG_STRING) {
|
||||||
gEnabled = (ImageOutputFormatEnum) newValue;
|
gEnabled = (ImageOutputFormatEnum) newValue;
|
||||||
|
|
||||||
WUPS_StoreBool(nullptr, ENABLED_CONFIG_STRING, gEnabled);
|
WUPS_StoreBool(nullptr, item->configId, gEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPS_GET_CONFIG() {
|
WUPS_GET_CONFIG() {
|
||||||
@ -149,9 +158,7 @@ WUPS_GET_CONFIG() {
|
|||||||
WUPSConfigCategoryHandle setting;
|
WUPSConfigCategoryHandle setting;
|
||||||
WUPSConfig_AddCategoryByNameHandled(config, "Settings", &setting);
|
WUPSConfig_AddCategoryByNameHandled(config, "Settings", &setting);
|
||||||
|
|
||||||
|
WUPSConfigItemBoolean_AddToCategoryHandled(config, setting, ENABLED_CONFIG_STRING, "Enabled", gEnabled, &boolItemCallback);
|
||||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, setting, ENABLED_CONFIG_STRING, "Enabled", gEnabled, &enabledChanged);
|
|
||||||
|
|
||||||
|
|
||||||
ConfigItemMultipleValuesPair source[3];
|
ConfigItemMultipleValuesPair source[3];
|
||||||
source[0].value = IMAGE_SOURCE_TV_AND_DRC;
|
source[0].value = IMAGE_SOURCE_TV_AND_DRC;
|
||||||
@ -174,7 +181,7 @@ WUPS_GET_CONFIG() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WUPSConfigItemMultipleValues_AddToCategoryHandled(config, setting, SCREEN_CONFIG_STRING, "Screen", defaultIndex, source,
|
WUPSConfigItemMultipleValues_AddToCategoryHandled(config, setting, SCREEN_CONFIG_STRING, "Screen", defaultIndex, source,
|
||||||
sizeof(source) / sizeof(source[0]), &imageSourceChanged);
|
sizeof(source) / sizeof(source[0]), &multipleValueItemCallback);
|
||||||
|
|
||||||
ConfigItemMultipleValuesPair fileFormat[3];
|
ConfigItemMultipleValuesPair fileFormat[3];
|
||||||
fileFormat[0].value = IMAGE_OUTPUT_FORMAT_JPEG;
|
fileFormat[0].value = IMAGE_OUTPUT_FORMAT_JPEG;
|
||||||
@ -197,10 +204,10 @@ WUPS_GET_CONFIG() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WUPSConfigItemMultipleValues_AddToCategoryHandled(config, setting, FORMAT_CONFIG_STRING, "Output format", defaultIndex, fileFormat,
|
WUPSConfigItemMultipleValues_AddToCategoryHandled(config, setting, FORMAT_CONFIG_STRING, "Output format", defaultIndex, fileFormat,
|
||||||
sizeof(fileFormat) / sizeof(fileFormat[0]), &formatChanged);
|
sizeof(fileFormat) / sizeof(fileFormat[0]), &multipleValueItemCallback);
|
||||||
|
|
||||||
|
|
||||||
WUPSConfigItemIntegerRange_AddToCategoryHandled(config, setting, QUALITY_CONFIG_STRING, "JPEG quality", gQuality, 10, 100, &qualityChanged);
|
WUPSConfigItemIntegerRange_AddToCategoryHandled(config, setting, QUALITY_CONFIG_STRING, "JPEG quality", gQuality, 10, 100, &integerRangeItemCallback);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user