Skip to content

Commit eef068d

Browse files
committed
more updates to the updater window
1 parent f44585f commit eef068d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,16 @@ public TTRUpdater(String title, Path installLocation) throws IOException {
7171
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
7272

7373
JLabel updateStatus = new JLabel("Checking files...");
74-
JProgressBar progressBar = new JProgressBar(0, 22);
74+
updateStatus.setAlignmentX(Component.CENTER_ALIGNMENT);
75+
JProgressBar progressBar = new JProgressBar(0, 0);
76+
progressBar.setAlignmentX(Component.CENTER_ALIGNMENT);
77+
panel.add(Box.createRigidArea(new Dimension(0, 30)));
7578
panel.add(updateStatus);
7679
panel.add(progressBar);
7780

7881
progressBar.setBounds(150, 100, 100, 30);
7982
updateStatus.setBounds(70, 25, 370, 40);
8083

81-
8284
frame.add(panel);
8385
frame.setVisible(true);
8486
frame.setLocationRelativeTo(null);
@@ -147,6 +149,7 @@ public TTRUpdater(String title, Path installLocation) throws IOException {
147149
return;
148150
}
149151

152+
progressBar.setMaximum(patches.length());
150153
for (String key : patches.keySet()) {
151154
progressBar.setValue(progressBar.getValue() + 1);
152155
JSONObject currentFile = (JSONObject) patches.get(key);
@@ -216,12 +219,17 @@ public TTRUpdater(String title, Path installLocation) throws IOException {
216219
logger.info(filesToDownload.size() + " file(s) are going to be downloaded.");
217220
logger.info(filesToDownload);
218221

222+
progressBar.setValue(0); //reset
223+
219224
for (String fileToDownload : filesToDownload) {
225+
progressBar.setMaximum(fileToDownload.length());
220226
JSONObject file = patches.getJSONObject(fileToDownload);
221227
String dl = file.getString("dl");
222228
try {
223229
logger.info("Downloading " + PATCHES_URL_DL + dl);
224230
updateStatus.setText("Downloading " + dl);
231+
progressBar.setVisible(true);
232+
progressBar.setValue(progressBar.getValue() + 1);
225233
FileUtils.copyURLToFile(
226234
new URL(PATCHES_URL_DL + dl),
227235
new File(tempFolder + File.separator + dl));
@@ -243,6 +251,7 @@ public TTRUpdater(String title, Path installLocation) throws IOException {
243251
long startTime = System.nanoTime();
244252
logger.info("Extracting file " + dl);
245253
updateStatus.setText("Extracting file " + dl);
254+
progressBar.setVisible(false);
246255
try {
247256
extractFile(dl, fileToDownload);
248257
} catch (IOException e) {

0 commit comments

Comments
 (0)