From b0eb6e4411a232d9ca0906f5072e3c492f84e9ef Mon Sep 17 00:00:00 2001 From: 0xb00bface <0xboobface@gmail.com> Date: Sat, 2 Jan 2021 14:49:56 +0100 Subject: [PATCH] Add setting to show total model count in title bar --- .../java/ctbrec/ui/CamrecApplication.java | 26 +++++++++++++++---- .../java/ctbrec/ui/settings/SettingsTab.java | 3 +++ common/src/main/java/ctbrec/Settings.java | 1 + .../ctbrec/recorder/NextGenLocalRecorder.java | 5 ++++ .../main/java/ctbrec/recorder/Recorder.java | 2 ++ .../java/ctbrec/recorder/RemoteRecorder.java | 5 ++++ 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/client/src/main/java/ctbrec/ui/CamrecApplication.java b/client/src/main/java/ctbrec/ui/CamrecApplication.java index 1278e97d..11fa65ce 100644 --- a/client/src/main/java/ctbrec/ui/CamrecApplication.java +++ b/client/src/main/java/ctbrec/ui/CamrecApplication.java @@ -1,6 +1,8 @@ package ctbrec.ui; +import static ctbrec.event.Event.Type.*; + import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; @@ -349,11 +351,12 @@ public class CamrecApplication extends Application { EventBusHolder.BUS.register(new Object() { @Subscribe public void handleEvent(Event evt) { - if(evt.getType() == Event.Type.MODEL_ONLINE || evt.getType() == Event.Type.MODEL_STATUS_CHANGED || evt.getType() == Event.Type.RECORDING_STATUS_CHANGED) { + if (evt.getType() == MODEL_ONLINE || evt.getType() == MODEL_STATUS_CHANGED || evt.getType() == RECORDING_STATUS_CHANGED) { try { - List models = recorder.getCurrentlyRecording(); - activeRecordings = models.size(); - String windowTitle = activeRecordings > 0 ? "(" + activeRecordings + ") " + title : title; + int modelCount = recorder.getModelCount(); + List currentlyRecording = recorder.getCurrentlyRecording(); + activeRecordings = currentlyRecording.size(); + String windowTitle = getActiveRecordings(activeRecordings, modelCount) + title; Platform.runLater(() -> primaryStage.setTitle(windowTitle)); updateStatus(); } catch (Exception e) { @@ -361,6 +364,19 @@ public class CamrecApplication extends Application { } } } + + private String getActiveRecordings(int activeRecordings, int modelCount) { + if (activeRecordings > 0) { + StringBuilder s = new StringBuilder("(").append(activeRecordings); + if (config.getSettings().totalModelCountInTitle) { + s.append("/").append(modelCount); + } + s.append(") "); + return s.toString(); + } else { + return ""; + } + } }); } @@ -377,7 +393,7 @@ public class CamrecApplication extends Application { bytesPerSecond = 0; } String humanReadable = ByteUnitFormatter.format(bytesPerSecond); - String status = String.format("Recording %s / %s models @ %s/s", activeRecordings, recorder.getModels().size(), humanReadable); + String status = String.format("Recording %s / %s models @ %s/s", activeRecordings, recorder.getModelCount(), humanReadable); Platform.runLater(() -> statusLabel.setText(status)); } diff --git a/client/src/main/java/ctbrec/ui/settings/SettingsTab.java b/client/src/main/java/ctbrec/ui/settings/SettingsTab.java index ab9e55e5..7e9051ad 100644 --- a/client/src/main/java/ctbrec/ui/settings/SettingsTab.java +++ b/client/src/main/java/ctbrec/ui/settings/SettingsTab.java @@ -123,6 +123,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { private SimpleStringProperty path; private SimpleStringProperty downloadFilename; private SimpleBooleanProperty requireAuthentication; + private SimpleBooleanProperty totalModelCountInTitle; private SimpleBooleanProperty transportLayerSecurity; private SimpleBooleanProperty fastScrollSpeed; private ExclusiveSelectionProperty recordLocal; @@ -176,6 +177,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { downloadFilename = new SimpleStringProperty(null, "downloadFilename", settings.downloadFilename); requireAuthentication = new SimpleBooleanProperty(null, "requireAuthentication", settings.requireAuthentication); requireAuthentication.addListener(this::requireAuthenticationChanged); + totalModelCountInTitle = new SimpleBooleanProperty(null, "totalModelCountInTitle", settings.totalModelCountInTitle); transportLayerSecurity = new SimpleBooleanProperty(null, "transportLayerSecurity", settings.transportLayerSecurity); recordLocal = new ExclusiveSelectionProperty(null, "localRecording", settings.localRecording, "Local", "Remote"); postProcessingThreads = new SimpleIntegerProperty(null, "postProcessingThreads", settings.postProcessingThreads); @@ -208,6 +210,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { Setting.of("Add models from clipboard", monitorClipboard, "Monitor clipboard for model URLs and automatically add them to the recorder").needsRestart(), Setting.of("Fast scroll speed", fastScrollSpeed, "Makes the thumbnail overviews scroll faster with the mouse wheel").needsRestart(), Setting.of("Show confirmation dialogs", confirmationDialogs, "Show confirmation dialogs for irreversible actions"), + Setting.of("Total model count in title", totalModelCountInTitle, "Show the total number of models in the title bar"), Setting.of("Start Tab", startTab), Setting.of("Colors (Base / Accent)", new ColorSettingsPane(Config.getInstance())).needsRestart() ), diff --git a/common/src/main/java/ctbrec/Settings.java b/common/src/main/java/ctbrec/Settings.java index d120ba3c..8cd2cfee 100644 --- a/common/src/main/java/ctbrec/Settings.java +++ b/common/src/main/java/ctbrec/Settings.java @@ -147,6 +147,7 @@ public class Settings { public String stripchatUsername = ""; public String stripchatPassword = ""; public boolean stripchatUseXhamster = false; + public boolean totalModelCountInTitle = false; public boolean transportLayerSecurity = true; public int thumbWidth = 180; public boolean updateThumbnails = true; diff --git a/common/src/main/java/ctbrec/recorder/NextGenLocalRecorder.java b/common/src/main/java/ctbrec/recorder/NextGenLocalRecorder.java index 3934b817..74c81669 100644 --- a/common/src/main/java/ctbrec/recorder/NextGenLocalRecorder.java +++ b/common/src/main/java/ctbrec/recorder/NextGenLocalRecorder.java @@ -722,4 +722,9 @@ public class NextGenLocalRecorder implements Recorder { LOG.info("Resuming recorder"); recording = true; } + + @Override + public int getModelCount() { + return models.size(); + } } diff --git a/common/src/main/java/ctbrec/recorder/Recorder.java b/common/src/main/java/ctbrec/recorder/Recorder.java index 3c2ce825..58a730e9 100644 --- a/common/src/main/java/ctbrec/recorder/Recorder.java +++ b/common/src/main/java/ctbrec/recorder/Recorder.java @@ -140,4 +140,6 @@ public interface Recorder { * @throws InvalidKeyException */ public void resume() throws InvalidKeyException, NoSuchAlgorithmException, IOException; + + public int getModelCount(); } diff --git a/common/src/main/java/ctbrec/recorder/RemoteRecorder.java b/common/src/main/java/ctbrec/recorder/RemoteRecorder.java index a8771de2..6cde231e 100644 --- a/common/src/main/java/ctbrec/recorder/RemoteRecorder.java +++ b/common/src/main/java/ctbrec/recorder/RemoteRecorder.java @@ -591,4 +591,9 @@ public class RemoteRecorder implements Recorder { public void resume() throws InvalidKeyException, NoSuchAlgorithmException, IOException { sendRequest("resumeRecorder"); } + + @Override + public int getModelCount() { + return models.size(); + } }