forked from HMCL-dev/HMCL
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'official/main' into prs-base
- Loading branch information
Showing
31 changed files
with
1,039 additions
and
902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
241 changes: 122 additions & 119 deletions
241
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
/* | ||
* Hello Minecraft! Launcher | ||
* Copyright (C) 2024 huangyuhui <[email protected]> and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package org.jackhuang.hmcl.ui.versions; | ||
|
||
import com.github.steveice10.opennbt.tag.builtin.*; | ||
|
@@ -10,11 +27,14 @@ | |
import javafx.collections.ObservableList; | ||
import javafx.geometry.Pos; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.ProgressIndicator; | ||
import javafx.scene.control.ScrollPane; | ||
import javafx.scene.layout.BorderPane; | ||
import javafx.scene.layout.StackPane; | ||
import javafx.scene.layout.VBox; | ||
import org.jackhuang.hmcl.game.World; | ||
import org.jackhuang.hmcl.task.Schedulers; | ||
import org.jackhuang.hmcl.task.Task; | ||
import org.jackhuang.hmcl.ui.FXUtils; | ||
import org.jackhuang.hmcl.ui.construct.ComponentList; | ||
import org.jackhuang.hmcl.ui.construct.DoubleValidator; | ||
|
@@ -32,22 +52,36 @@ | |
import static org.jackhuang.hmcl.util.i18n.I18n.formatDateTime; | ||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; | ||
|
||
/** | ||
* @author Glavo | ||
*/ | ||
public final class WorldInfoPage extends StackPane implements DecoratorPage { | ||
private final World world; | ||
private final CompoundTag levelDat; | ||
private final CompoundTag dataTag; | ||
private CompoundTag levelDat; | ||
|
||
private final ObjectProperty<State> stateProperty = new SimpleObjectProperty<>(); | ||
private final ObjectProperty<State> stateProperty; | ||
|
||
public WorldInfoPage(World world) throws IOException { | ||
public WorldInfoPage(World world) { | ||
this.world = world; | ||
this.levelDat = world.readLevelDat(); | ||
this.dataTag = levelDat.get("Data"); | ||
this.stateProperty = new SimpleObjectProperty<>(State.fromTitle(i18n("world.info.title", world.getWorldName()))); | ||
|
||
this.getChildren().add(new ProgressIndicator()); | ||
Task.supplyAsync(world::readLevelDat) | ||
.whenComplete(Schedulers.javafx(), ((result, exception) -> { | ||
if (exception == null) { | ||
this.levelDat = result; | ||
loadWorldInfo(); | ||
} else { | ||
LOG.warning("Failed to load level.dat", exception); | ||
this.getChildren().setAll(new Label(i18n("world.info.failed"))); | ||
} | ||
})).start(); | ||
} | ||
|
||
private void loadWorldInfo() { | ||
CompoundTag dataTag = levelDat.get("Data"); | ||
CompoundTag worldGenSettings = dataTag.get("WorldGenSettings"); | ||
|
||
stateProperty.set(State.fromTitle(i18n("world.info.title", world.getWorldName()))); | ||
|
||
ScrollPane scrollPane = new ScrollPane(); | ||
scrollPane.setFitToHeight(true); | ||
scrollPane.setFitToWidth(true); | ||
|
@@ -483,7 +517,6 @@ String formatPosition(Tag tag) { | |
Tag z = listTag.get(2); | ||
|
||
if (x instanceof DoubleTag && y instanceof DoubleTag && z instanceof DoubleTag) { | ||
//noinspection MalformedFormatString | ||
return this == OVERWORLD | ||
? String.format("(%.2f, %.2f, %.2f)", x.getValue(), y.getValue(), z.getValue()) | ||
: String.format("%s (%.2f, %.2f, %.2f)", name, x.getValue(), y.getValue(), z.getValue()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.