|
|
|
|
@@ -1,3 +1,20 @@
|
|
|
|
|
/*
|
|
|
|
|
* Hello Minecraft! Launcher
|
|
|
|
|
* Copyright (C) 2024 huangyuhui <huanghongxun2008@126.com> 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.FXCollections;
|
|
|
|
|
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.logging.Logger.LOG;
|
|
|
|
|
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 @@ public final class WorldInfoPage extends StackPane implements DecoratorPage {
|
|
|
|
|
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());
|
|
|
|
|
|