From b57461dc6bd420aa0ddf6028b5df88296afefdfa Mon Sep 17 00:00:00 2001 From: iProdigy Date: Sun, 22 Dec 2024 19:48:19 -0600 Subject: [PATCH 1/2] feat: allow hiding just split dms from screenshots --- src/main/java/dinkplugin/DinkPluginConfig.java | 17 +++++++++++++---- src/main/java/dinkplugin/SettingsManager.java | 16 ++++++++++------ .../java/dinkplugin/domain/ChatPrivacyMode.java | 17 +++++++++++++++++ src/main/java/dinkplugin/util/Utils.java | 6 ++++-- 4 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 src/main/java/dinkplugin/domain/ChatPrivacyMode.java diff --git a/src/main/java/dinkplugin/DinkPluginConfig.java b/src/main/java/dinkplugin/DinkPluginConfig.java index dac944e2..59085530 100644 --- a/src/main/java/dinkplugin/DinkPluginConfig.java +++ b/src/main/java/dinkplugin/DinkPluginConfig.java @@ -2,6 +2,7 @@ import dinkplugin.domain.AchievementDiary; import dinkplugin.domain.ChatNotificationType; +import dinkplugin.domain.ChatPrivacyMode; import dinkplugin.domain.ClueTier; import dinkplugin.domain.CombatAchievementTier; import dinkplugin.domain.ConfigImportPolicy; @@ -330,17 +331,25 @@ default PlayerLookupService playerLookupService() { } @ConfigItem( - keyName = "screenshotHideChat", + keyName = "chatPrivacy", name = "Hide Chat in Images", description = "Whether to hide the chat box and private messages when capturing screenshots.
" + - "Note: visually you may notice the chat box momentarily flicker as it is hidden for the screenshot.", + "Note: visually you may notice the chat box momentarily flicker as it is hidden for the screenshot.
" + + "Warning: 'Hide Split PMs' has no effect if 'Split friends private chat' is not enabled in the game settings", position = 1010, section = advancedSection ) - default boolean screenshotHideChat() { - return false; + default ChatPrivacyMode chatPrivacy() { + return ChatPrivacyMode.HIDE_SPLIT_PM; } + @ConfigItem( + keyName = "chatPrivacy", + name = "", + description = "" + ) + void setChatPrivacy(ChatPrivacyMode mode); + @ConfigItem( keyName = "sendDiscordUser", name = "Send Discord Profile", diff --git a/src/main/java/dinkplugin/SettingsManager.java b/src/main/java/dinkplugin/SettingsManager.java index 15100b14..3603f35d 100644 --- a/src/main/java/dinkplugin/SettingsManager.java +++ b/src/main/java/dinkplugin/SettingsManager.java @@ -3,6 +3,7 @@ import com.google.common.collect.ImmutableSet; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import dinkplugin.domain.ChatPrivacyMode; import dinkplugin.domain.ConfigImportPolicy; import dinkplugin.domain.FilterMode; import dinkplugin.domain.SeasonalPolicy; @@ -57,6 +58,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; +import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -125,7 +128,9 @@ public boolean isNamePermitted(String name) { @VisibleForTesting public void init() { - migrateSeasonal(); + migrateBoolean("ignoreSeasonalWorlds", ignoreSeasonal -> ignoreSeasonal ? SeasonalPolicy.REJECT : SeasonalPolicy.ACCEPT, config::setSeasonalPolicy); + migrateBoolean("screenshotHideChat", hide -> hide ? ChatPrivacyMode.HIDE_ALL : ChatPrivacyMode.HIDE_NONE, config::setChatPrivacy); + setFilteredNames(config.filteredNames()); configManager.getConfigDescriptor(config).getItems().forEach(item -> { String key = item.key(); @@ -389,11 +394,10 @@ private void setFilteredNames(String configValue) { log.debug("Updated RSN Filter List to: {}", filteredNames); } - private void migrateSeasonal() { - String key = "ignoreSeasonalWorlds"; - Boolean ignoreSeasonal = configManager.getConfiguration(CONFIG_GROUP, key, Boolean.TYPE); - if (ignoreSeasonal == null) return; - config.setSeasonalPolicy(ignoreSeasonal ? SeasonalPolicy.REJECT : SeasonalPolicy.ACCEPT); + private void migrateBoolean(String key, Function transform, Consumer consumer) { + Boolean bool = configManager.getConfiguration(CONFIG_GROUP, key, Boolean.TYPE); + if (bool == null) return; + consumer.accept(transform.apply(bool)); configManager.unsetConfiguration(CONFIG_GROUP, key); } diff --git a/src/main/java/dinkplugin/domain/ChatPrivacyMode.java b/src/main/java/dinkplugin/domain/ChatPrivacyMode.java new file mode 100644 index 00000000..9509cd26 --- /dev/null +++ b/src/main/java/dinkplugin/domain/ChatPrivacyMode.java @@ -0,0 +1,17 @@ +package dinkplugin.domain; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public enum ChatPrivacyMode { + HIDE_NONE("Show All"), + HIDE_SPLIT_PM("Hide Split PMs"), + HIDE_ALL("Hide All"); + + private final String displayName; + + @Override + public String toString() { + return this.displayName; + } +} diff --git a/src/main/java/dinkplugin/util/Utils.java b/src/main/java/dinkplugin/util/Utils.java index e6ecc9d4..0c99cc97 100644 --- a/src/main/java/dinkplugin/util/Utils.java +++ b/src/main/java/dinkplugin/util/Utils.java @@ -5,6 +5,7 @@ import com.google.gson.reflect.TypeToken; import dinkplugin.DinkPluginConfig; import dinkplugin.domain.AccountType; +import dinkplugin.domain.ChatPrivacyMode; import lombok.experimental.UtilityClass; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -311,8 +312,9 @@ public byte[] convertImageToByteArray(BufferedImage bufferedImage, String format } public void captureScreenshot(Client client, ClientThread clientThread, DrawManager drawManager, ImageCapture imageCapture, ExecutorService executor, DinkPluginConfig config, Consumer consumer) { - boolean chatHidden = hideWidget(config.screenshotHideChat(), client, ComponentID.CHATBOX_FRAME); - boolean whispersHidden = hideWidget(config.screenshotHideChat(), client, PRIVATE_CHAT_WIDGET); + ChatPrivacyMode privacyMode = config.chatPrivacy(); + boolean chatHidden = hideWidget(privacyMode == ChatPrivacyMode.HIDE_ALL, client, ComponentID.CHATBOX_FRAME); + boolean whispersHidden = hideWidget(privacyMode != ChatPrivacyMode.HIDE_NONE, client, PRIVATE_CHAT_WIDGET); drawManager.requestNextFrameListener(frame -> { if (config.includeClientFrame()) { executor.execute(() -> consumer.accept(imageCapture.addClientFrame(frame))); From 780eaa6871e5b410e9e2ba66edec07e504d522d7 Mon Sep 17 00:00:00 2001 From: iProdigy <8106344+iProdigy@users.noreply.github.com> Date: Sun, 22 Dec 2024 20:00:06 -0600 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bffba29..ff1d05d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Unreleased +- Minor: Allow hiding just split private chat from screenshots. (#630) + ## 1.10.19 - Bugfix: Use latest dynamic config when queried, rather than the cached value from okhttp. (#625)