Skip to content

Commit 190cd48

Browse files
committed
added total progress to TTRUpdater
1 parent b0ed0d9 commit 190cd48

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/lol/hyper/customlauncher/ttrupdater/TTRUpdater.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class TTRUpdater extends JFrame {
5555
public final Logger logger = LogManager.getLogger(this);
5656
private final JProgressBar progressBar;
5757
private final JLabel updateStatus;
58+
private final JLabel fileProgress;
5859

5960
/**
6061
* Create the TTR updater window.
@@ -79,11 +80,14 @@ public TTRUpdater() {
7980

8081
updateStatus = new JLabel("Checking files...");
8182
updateStatus.setAlignmentX(Component.CENTER_ALIGNMENT);
83+
fileProgress = new JLabel();
84+
fileProgress.setAlignmentX(Component.CENTER_ALIGNMENT);
8285
progressBar = new JProgressBar(0, 0);
8386
progressBar.setAlignmentX(Component.CENTER_ALIGNMENT);
8487
panel.add(Box.createRigidArea(new Dimension(0, 30)));
8588
panel.add(updateStatus);
8689
panel.add(progressBar);
90+
panel.add(fileProgress);
8791

8892
progressBar.setBounds(150, 100, 100, 30);
8993
updateStatus.setBounds(70, 25, 370, 40);
@@ -202,7 +206,9 @@ public void checkUpdates() {
202206

203207
// we store files we need to download in filesToDownload
204208
// if there are files in that list, download them
209+
int currentProgress = 0;
205210
if (filesToDownload.size() > 0) {
211+
fileProgress.setText(String.format("Progress: %d / %d", currentProgress, filesToDownload.size()));
206212
File tempFolder = new File("temp");
207213
if (!tempFolder.exists() && !tempFolder.mkdirs()) {
208214
logger.error("Unable to create temp folder!");
@@ -260,6 +266,8 @@ public void checkUpdates() {
260266
updateStatus.setText("Finished extracting file " + fileToDownload);
261267
long extractedTime = TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
262268
logger.info("Finished extracting file " + downloadName + ". Took " + extractedTime + "ms.");
269+
currentProgress++;
270+
fileProgress.setText(String.format("Progress: %d / %d", currentProgress, filesToDownload.size()));
263271
}
264272
// delete all files in the temp folder
265273
File[] tempFolderFiles = tempFolder.listFiles();

0 commit comments

Comments
 (0)