Skip to content

Commit

Permalink
调整UI
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveNotSet committed Jun 23, 2024
1 parent 43054e5 commit 1073eba
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -85,9 +85,9 @@ public boolean runSync(String baseDir, Config.SourceProperty source, ProgressRec
List<String> filesToCreate = localMetadata.getFilesToCreate(remoteMetadata);
List<String> filesToUpdate = localMetadata.getFilesToUpdate(remoteMetadata);
List<String> 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("正在创建或删除需要的目录……");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 1073eba

Please sign in to comment.