Remove some CB side tabs, add region tabs

This commit is contained in:
jafea7 2025-03-31 18:40:20 +11:00
parent 66b72908e2
commit 784db3100e
3 changed files with 72 additions and 6 deletions

View File

@ -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;
@ -13,6 +16,7 @@ import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
public class ChaturbateConfigUi extends AbstractConfigUI {
@ -104,6 +108,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<String> 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++);
@ -125,4 +159,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<String> getChaturbateRegions() {
return new ArrayList<>(Config.getInstance().getSettings().chaturbateRegions);
}
}

View File

@ -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<String, String> 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<String> 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<String> getChaturbateRegions() {
return new ArrayList<>(Config.getInstance().getSettings().chaturbateRegions);
}
}

View File

@ -54,6 +54,7 @@ public class Settings {
public String chaturbateUsername = "";
public String chaturbateBaseUrl = "https://chaturbate.com";
public int chaturbateMsBetweenRequests = 3000;
public Set<String> chaturbateRegions = new HashSet<>();
public boolean chooseStreamQuality = false;
public String colorAccent = "#FFFFFF";
public String colorBase = "#FFFFFF";