From 1073eba29910049985d0412d72200f813bbfa6c3 Mon Sep 17 00:00:00 2001 From: SteveNotSet <875755151@qq.com> Date: Sun, 23 Jun 2024 15:36:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resourcepackupdater/gui/forms/ProgressForm.java | 8 ++++---- .../cn/zbx1425/resourcepackupdater/gui/gl/GlHelper.java | 8 ++++---- .../cn/zbx1425/resourcepackupdater/io/Dispatcher.java | 6 +++--- .../io/network/DownloadDispatcher.java | 6 +++--- .../resourcepackupdater/io/network/RemoteMetadata.java | 4 ++-- .../resourcepackupdater/textures/font/cantarell.json | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/cn/zbx1425/resourcepackupdater/gui/forms/ProgressForm.java b/src/main/java/cn/zbx1425/resourcepackupdater/gui/forms/ProgressForm.java index 9241fa4..b719713 100644 --- a/src/main/java/cn/zbx1425/resourcepackupdater/gui/forms/ProgressForm.java +++ b/src/main/java/cn/zbx1425/resourcepackupdater/gui/forms/ProgressForm.java @@ -22,14 +22,14 @@ public void render() { float barBegin = 0; float usableBarWidth = progressFormWidth - barBegin - 0; - float progressTextStart = progressFormWidth / 2 - GlHelper.getStringWidth("88%", 16) / 2; - GlHelper.blit(barBegin, 0, usableBarWidth, 30, 0x4435aa8e); + float progressTextStart = progressFormWidth / 2 - GlHelper.getStringWidth(String.format("%d%%", Math.round(primaryProgress * 100)), 16) / 2; + GlHelper.blit(barBegin, 0, usableBarWidth, 30, 0x4400a99d); GlHelper.drawString(progressTextStart, 0 + 10, 80, LINE_HEIGHT, 16, - String.format("%d%%", Math.round(primaryProgress * 100)), 0xff328a75, false, true); + String.format("%d%%", Math.round(primaryProgress * 100)), 0xff00a99d, false, true); GlHelper.end(); GlHelper.begin(GlHelper.PRELOAD_FONT_TEXTURE); GlHelper.enableScissor(0, 0, usableBarWidth * primaryProgress, 30); - GlHelper.blit(barBegin, 0, usableBarWidth, 30, 0xff35aa8e); + GlHelper.blit(barBegin, 0, usableBarWidth, 30, 0xff00a99d); GlHelper.drawString(progressTextStart, 0 + 10, 80, LINE_HEIGHT, 16, String.format("%d%%", Math.round(primaryProgress * 100)), 0xffffffff, false, true); GlHelper.end(); diff --git a/src/main/java/cn/zbx1425/resourcepackupdater/gui/gl/GlHelper.java b/src/main/java/cn/zbx1425/resourcepackupdater/gui/gl/GlHelper.java index 2b8fe1d..473a956 100644 --- a/src/main/java/cn/zbx1425/resourcepackupdater/gui/gl/GlHelper.java +++ b/src/main/java/cn/zbx1425/resourcepackupdater/gui/gl/GlHelper.java @@ -111,8 +111,8 @@ public static void drawString(float x1, float y1, float width, float height, flo } else if (chr == '\r') { // Ignore CR } else if (chr == '\t') { - // Align to 8 spaces - float alignToPixels = (preloadFont.spaceWidthPl + CHAR_SPACING) * 8 * fontSize; + // Align to 10 spaces + float alignToPixels = (preloadFont.spaceWidthPl + CHAR_SPACING) * 10 * fontSize; x = (float) (Math.ceil((x - x1) / alignToPixels) * alignToPixels + x1); } else if (chr == ' ') { x += (preloadFont.spaceWidthPl + CHAR_SPACING) * fontSize; @@ -152,8 +152,8 @@ public static float getStringWidth(String text, float fontSize) { } else if (chr == '\r') { // Ignore CR } else if (chr == '\t') { - // Align to 8 spaces - float alignToPixels = (preloadFont.spaceWidthPl + CHAR_SPACING) * 8 * fontSize; + // Align to 10 spaces + float alignToPixels = (preloadFont.spaceWidthPl + CHAR_SPACING) * 10 * fontSize; x = (float) (Math.ceil(x / alignToPixels) * alignToPixels); } else if (chr == ' ') { x += (preloadFont.spaceWidthPl + CHAR_SPACING) * fontSize; diff --git a/src/main/java/cn/zbx1425/resourcepackupdater/io/Dispatcher.java b/src/main/java/cn/zbx1425/resourcepackupdater/io/Dispatcher.java index 32b7efa..1c6fb98 100644 --- a/src/main/java/cn/zbx1425/resourcepackupdater/io/Dispatcher.java +++ b/src/main/java/cn/zbx1425/resourcepackupdater/io/Dispatcher.java @@ -62,7 +62,7 @@ public boolean runSync(String baseDir, Config.SourceProperty source, ProgressRec if (localMetadata.files.size() < 1) { cb.printLog("正在下载来自远程服务器的资源包。"); - cb.printLog("坐下来喝杯茶等一会吧。"); + cb.printLog("这是第一次下载。坐下来喝杯茶等一会吧。"); } if (remoteChecksum != null) { if (Arrays.equals(localChecksum, remoteChecksum)) { @@ -85,9 +85,9 @@ public boolean runSync(String baseDir, Config.SourceProperty source, ProgressRec List filesToCreate = localMetadata.getFilesToCreate(remoteMetadata); List filesToUpdate = localMetadata.getFilesToUpdate(remoteMetadata); List filesToDelete = localMetadata.getFilesToDelete(remoteMetadata); - cb.printLog(String.format("找到了 %-3d 个新目录、%-3d 个要删除的目录。", + cb.printLog(String.format("找到了 %d 个新目录、%d 个要删除的目录。", dirsToCreate.size(), dirsToDelete.size())); - cb.printLog(String.format("找到了 %-3d 个新文件、%-3d 个要修改的文件、%-3d 个要删除的文件。", + cb.printLog(String.format("找到了 %d 个新文件、%d 个要修改的文件、%d 个要删除的文件。", filesToCreate.size(), filesToUpdate.size(), filesToDelete.size())); cb.printLog("正在创建或删除需要的目录……"); diff --git a/src/main/java/cn/zbx1425/resourcepackupdater/io/network/DownloadDispatcher.java b/src/main/java/cn/zbx1425/resourcepackupdater/io/network/DownloadDispatcher.java index 25e610c..7191f9d 100644 --- a/src/main/java/cn/zbx1425/resourcepackupdater/io/network/DownloadDispatcher.java +++ b/src/main/java/cn/zbx1425/resourcepackupdater/io/network/DownloadDispatcher.java @@ -91,15 +91,15 @@ public void updateSummary() { lastSummaryTime = currentTime; lastSummaryBytes = downloadedBytes; } - String message = String.format(": % 5.2f MiB / % 5.2f MiB; %5d KiB/s", + String message = String.format(": %.2f MiB / %.2f MiB; %d KiB/s", downloadedBytes / 1048576.0, totalBytes / 1048576.0, summaryBytesPerSecond / 1024); progressReceiver.setProgress(downloadedBytes * 1f / totalBytes, 0); String runningProgress = "剩余 " + incompleteTasks.size() + " 个文件\n" + String.join("\n", runningTasks.stream() - .map(task -> " " + ( + .map(task -> " " + ( task.totalBytes == 0 ? "等待" : - String.format("%.1f%%", task.downloadedBytes * 100f / task.totalBytes) + (task.downloadedBytes <= 0.9995 ? String.format("%.1f%%", task.downloadedBytes * 100f / task.totalBytes) : "100%") ) + "\t" + (task.failedAttempts > 0 ? "(第 " + task.failedAttempts + "次重试)" : "") + task.fileName) diff --git a/src/main/java/cn/zbx1425/resourcepackupdater/io/network/RemoteMetadata.java b/src/main/java/cn/zbx1425/resourcepackupdater/io/network/RemoteMetadata.java index aa40f20..21c92a0 100644 --- a/src/main/java/cn/zbx1425/resourcepackupdater/io/network/RemoteMetadata.java +++ b/src/main/java/cn/zbx1425/resourcepackupdater/io/network/RemoteMetadata.java @@ -135,12 +135,12 @@ public void registerWrite(long amountOfBytesWritten) throws IOException { downloadedBytes += (amountOfBytesWritten - lastAmount); long elapsedTimeSecs = (System.currentTimeMillis() - downloadStartTime) / 1000; if (fileSize > 0) { - String message = String.format(": %5d KiB / %5d KiB; %5d KiB/s", + String message = String.format(": %d KiB / %d KiB; %d KiB/s", amountOfBytesWritten / 1024, fileSize / 1024, elapsedTimeSecs == 0 ? 0 : downloadedBytes / elapsedTimeSecs / 1024); cb.setProgress(amountOfBytesWritten * 1f / fileSize, 0); cb.setInfo(String.format("%.2f%%", amountOfBytesWritten * 1f / fileSize * 100), message); } else { - String message = String.format(": %5d KiB 已下载; %5d KiB/s", + String message = String.format(": %d KiB 已下载; %d KiB/s", amountOfBytesWritten / 1024, elapsedTimeSecs == 0 ? 0 : downloadedBytes / elapsedTimeSecs / 1024); cb.setProgress((System.currentTimeMillis() % 1000) / 1000f, 0); cb.setInfo(String.format("%.2f%%", (System.currentTimeMillis() % 1000) / 1000f * 100), message); diff --git a/src/main/resources/assets/resourcepackupdater/textures/font/cantarell.json b/src/main/resources/assets/resourcepackupdater/textures/font/cantarell.json index 7ed7171..e1695bb 100644 --- a/src/main/resources/assets/resourcepackupdater/textures/font/cantarell.json +++ b/src/main/resources/assets/resourcepackupdater/textures/font/cantarell.json @@ -16,7 +16,7 @@ "7":{"x":932,"y":318,"width":18,"height":24,"originX":0,"originY":23,"advance":18}, "8":{"x":821,"y":318,"width":19,"height":24,"originX":0,"originY":23,"advance":18}, "9":{"x":950,"y":318,"width":18,"height":24,"originX":0,"originY":23,"advance":18}, - " ":{"x":420,"y":365,"width":3,"height":3,"originX":1,"originY":1,"advance":16}, + " ":{"x":420,"y":365,"width":3,"height":3,"originX":1,"originY":1,"advance":12}, "!":{"x":1124,"y":318,"width":7,"height":24,"originX":-1,"originY":23,"advance":8}, "\"":{"x":26,"y":365,"width":12,"height":11,"originX":-1,"originY":23,"advance":14}, "#":{"x":553,"y":318,"width":21,"height":24,"originX":0,"originY":23,"advance":21},