From be2df15d2e24690a96aee5143c032aae1a86aee1 Mon Sep 17 00:00:00 2001 From: Jafea7 Date: Mon, 7 Apr 2025 18:21:11 +1000 Subject: [PATCH] Add region options to CB --- .../sites/chaturbate/ChaturbateConfigUi.java | 47 +++++++++++++++++++ .../chaturbate/ChaturbateTabProvider.java | 30 +++++++++--- common/src/main/java/ctbrec/Settings.java | 2 +- 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/client/src/main/java/ctbrec/ui/sites/chaturbate/ChaturbateConfigUi.java b/client/src/main/java/ctbrec/ui/sites/chaturbate/ChaturbateConfigUi.java index dd885821..01f77b97 100644 --- a/client/src/main/java/ctbrec/ui/sites/chaturbate/ChaturbateConfigUi.java +++ b/client/src/main/java/ctbrec/ui/sites/chaturbate/ChaturbateConfigUi.java @@ -1,5 +1,8 @@ package ctbrec.ui.sites.chaturbate; +import java.util.ArrayList; +import java.util.List; + import ctbrec.Config; import ctbrec.sites.chaturbate.Chaturbate; import ctbrec.ui.DesktopIntegration; @@ -9,6 +12,7 @@ import javafx.geometry.Insets; import javafx.scene.Parent; import javafx.scene.control.*; import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; public class ChaturbateConfigUi extends AbstractConfigUI { @@ -100,6 +104,36 @@ public class ChaturbateConfigUi extends AbstractConfigUI { GridPane.setColumnSpan(requestThrottle, 2); layout.add(requestThrottle, 1, row++); + Label regionsLabel = new Label("Region Tabs"); + layout.add(regionsLabel, 0, row); + List regions = getChaturbateRegions(); + + HBox checkboxContainer = new HBox(10); + + CheckBox asiaOther = new CheckBox("Asia/Oth"); + asiaOther.setSelected(regions.contains("AS,O")); + asiaOther.setOnAction(e -> toggleRegion("AS,O", asiaOther.isSelected())); + HBox.setMargin(asiaOther, new Insets(0, 0, 0, 7)); + checkboxContainer.getChildren().add(asiaOther); + + CheckBox euRu = new CheckBox("Eu/Ru"); + euRu.setSelected(regions.contains("ER")); + euRu.setOnAction(e -> toggleRegion("ER", euRu.isSelected())); + checkboxContainer.getChildren().add(euRu); + + CheckBox nthAm = new CheckBox("Nth Am"); + nthAm.setSelected(regions.contains("NA")); + nthAm.setOnAction(e -> toggleRegion("NA", nthAm.isSelected())); + checkboxContainer.getChildren().add(nthAm); + + CheckBox sthAm = new CheckBox("Sth Am"); + sthAm.setSelected(regions.contains("SA")); + sthAm.setOnAction(e -> toggleRegion("SA", sthAm.isSelected())); + checkboxContainer.getChildren().add(sthAm); + + layout.add(checkboxContainer, 1, row, 4, 1); + row++; + var createAccount = new Button("Create new Account"); createAccount.setOnAction(e -> DesktopIntegration.open(Chaturbate.REGISTRATION_LINK)); layout.add(createAccount, 1, row++); @@ -121,4 +155,17 @@ public class ChaturbateConfigUi extends AbstractConfigUI { return layout; } + private void toggleRegion(String region, boolean selected) { + var settings = Config.getInstance().getSettings(); + if (selected) { + settings.chaturbateRegions.add(region); + } else { + settings.chaturbateRegions.remove(region); + } + save(); + } + + private List getChaturbateRegions() { + return new ArrayList<>(Config.getInstance().getSettings().chaturbateRegions); + } } diff --git a/client/src/main/java/ctbrec/ui/sites/chaturbate/ChaturbateTabProvider.java b/client/src/main/java/ctbrec/ui/sites/chaturbate/ChaturbateTabProvider.java index dee19dfa..8fb217f2 100644 --- a/client/src/main/java/ctbrec/ui/sites/chaturbate/ChaturbateTabProvider.java +++ b/client/src/main/java/ctbrec/ui/sites/chaturbate/ChaturbateTabProvider.java @@ -1,5 +1,6 @@ package ctbrec.ui.sites.chaturbate; +import ctbrec.Config; import ctbrec.sites.chaturbate.Chaturbate; import ctbrec.ui.sites.AbstractTabProvider; import ctbrec.ui.tabs.PaginatedScheduledService; @@ -8,7 +9,9 @@ import javafx.scene.Scene; import javafx.scene.control.Tab; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class ChaturbateTabProvider extends AbstractTabProvider { @@ -33,13 +36,24 @@ public class ChaturbateTabProvider extends AbstractTabProvider { tabs.add(createTab("Trans", apiUrl + "/roomlist/room-list/?enable_recommendations=false&genders=t")); tabs.add(createTab("Private", apiUrl + "/roomlist/room-list/?enable_recommendations=false&private=true")); tabs.add(createTab("Hidden", apiUrl + "/roomlist/room-list/?enable_recommendations=false&hidden=true")); - tabs.add(createTab("Gaming", apiUrl + "/roomlist/room-list/?enable_recommendations=false&gaming=true")); + // tabs.add(createTab("Gaming", apiUrl + "/roomlist/room-list/?enable_recommendations=false&gaming=true")); + Map regionMap = new HashMap<>(); + regionMap.put("AS,O", "Asia/Oth"); + regionMap.put("ER", "Eu/Ru"); + regionMap.put("NA", "Nth Amer"); + regionMap.put("SA", "Sth Amer"); + List enabledRegions = getChaturbateRegions(); + for (String region : enabledRegions) { + String url = apiUrl + "/roomlist/room-list/?regions=" + region; + String title = regionMap.getOrDefault(region, region); + tabs.add(createTab(title, url)); + } followedTab.setScene(scene); followedTab.setRecorder(recorder); followedTab.setImageAspectRatio(9.0 / 16.0); tabs.add(followedTab); - tabs.add(createApiTab("Top Rated", apiUrl + "/discover/carousels/top-rated/")); - tabs.add(createApiTab("Trending", apiUrl + "/discover/carousels/trending/")); + // tabs.add(createApiTab("Top Rated", apiUrl + "/discover/carousels/top-rated/")); + // tabs.add(createApiTab("Trending", apiUrl + "/discover/carousels/trending/")); return tabs; } @@ -60,8 +74,12 @@ public class ChaturbateTabProvider extends AbstractTabProvider { return tab; } - private Tab createApiTab(String title, String apiUrl) { - var updateService = new ChaturbateApiUpdateService(apiUrl, (Chaturbate) site); - return createTab(title, updateService); + // private Tab createApiTab(String title, String apiUrl) { + // var updateService = new ChaturbateApiUpdateService(apiUrl, (Chaturbate) site); + // return createTab(title, updateService); + // } + + private List getChaturbateRegions() { + return new ArrayList<>(Config.getInstance().getSettings().chaturbateRegions); } } diff --git a/common/src/main/java/ctbrec/Settings.java b/common/src/main/java/ctbrec/Settings.java index e97a0b3b..70cbc4ce 100644 --- a/common/src/main/java/ctbrec/Settings.java +++ b/common/src/main/java/ctbrec/Settings.java @@ -219,7 +219,7 @@ public class Settings { public String xlovecamPassword = ""; public boolean stripchatVR = true; public boolean streamrayRecordGoalShows = false; - public boolean checkForUpdates = true; + public boolean checkForUpdates = false; public int thumbCacheSize = 16; public boolean dreamcamVR = true; public String filterBlacklist = "";