Merge 00fabd24157a9f155f5b1ff437b93509ffc3519d into 9969dc60c5278340b6b9a4d7facdde620e99d1f5

This commit is contained in:
Glavo 2025-08-02 19:58:38 +08:00 committed by GitHub
commit 0ed52a1cdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 46 additions and 31 deletions

View File

@ -17,11 +17,7 @@
*/
package org.jackhuang.hmcl.ui.download;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXCheckBox;
import com.jfoenix.controls.JFXListView;
import com.jfoenix.controls.JFXSpinner;
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.controls.*;
import javafx.animation.PauseTransition;
import javafx.application.Platform;
import javafx.beans.InvalidationListener;
@ -31,6 +27,8 @@ import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.*;
@ -65,6 +63,7 @@ import org.jackhuang.hmcl.ui.wizard.WizardPage;
import org.jackhuang.hmcl.util.Holder;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.i18n.I18n;
import org.jackhuang.hmcl.util.versioning.GameVersionNumber;
import java.util.List;
import java.util.Locale;
@ -90,9 +89,11 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
private final StackPane failedPane;
private final StackPane emptyPane;
private final TransitionPane root;
private final JFXCheckBox chkRelease;
private final JFXCheckBox chkSnapshot;
private final JFXCheckBox chkOld;
private final ToggleGroup versionTypeGroup;
private final JFXRadioButton radioRelease;
private final JFXRadioButton radioSnapshot;
private final JFXRadioButton radioAprilFools;
private final JFXRadioButton radioOld;
private final ComponentList centrePane;
private final StackPane center;
@ -130,17 +131,25 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
HBox checkPane = new HBox();
checkPane.setSpacing(10);
{
chkRelease = new JFXCheckBox(i18n("version.game.releases"));
chkRelease.setSelected(true);
HBox.setMargin(chkRelease, new Insets(10, 0, 10, 0));
versionTypeGroup = new ToggleGroup();
chkSnapshot = new JFXCheckBox(i18n("version.game.snapshots"));
HBox.setMargin(chkSnapshot, new Insets(10, 0, 10, 0));
var margin = new Insets(10, 0, 10, 0);
chkOld = new JFXCheckBox(i18n("version.game.old"));
HBox.setMargin(chkOld, new Insets(10, 0, 10, 0));
radioRelease = new JFXRadioButton(i18n("version.game.releases"));
radioRelease.setSelected(true);
HBox.setMargin(radioRelease, margin);
checkPane.getChildren().setAll(chkRelease, chkSnapshot, chkOld);
radioSnapshot = new JFXRadioButton(i18n("version.game.snapshots"));
HBox.setMargin(radioSnapshot, margin);
radioAprilFools = new JFXRadioButton(i18n("version.game.april_fools"));
HBox.setMargin(radioAprilFools, margin);
radioOld = new JFXRadioButton(i18n("version.game.old"));
HBox.setMargin(radioOld, margin);
versionTypeGroup.getToggles().setAll(radioRelease, radioSnapshot, radioAprilFools, radioOld);
checkPane.getChildren().setAll(radioRelease, radioSnapshot, radioAprilFools, radioOld);
}
list = new JFXListView<>();
@ -230,12 +239,10 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
versionList = downloadProvider.getVersionListById(libraryId);
boolean hasType = versionList.hasType();
chkRelease.setManaged(hasType);
chkRelease.setVisible(hasType);
chkSnapshot.setManaged(hasType);
chkSnapshot.setVisible(hasType);
chkOld.setManaged(hasType);
chkOld.setVisible(hasType);
for (Toggle toggle : versionTypeGroup.getToggles()) {
((JFXRadioButton) toggle).setManaged(hasType);
((JFXRadioButton) toggle).setVisible(hasType);
}
if (hasType) {
centrePane.getContent().setAll(toolbarPane, list);
@ -267,10 +274,8 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
list.getItems().setAll(versions);
};
chkRelease.selectedProperty().addListener(listener);
chkSnapshot.selectedProperty().addListener(listener);
chkOld.selectedProperty().addListener(listener);
queryString.addListener(listener);
versionTypeGroup.selectedToggleProperty().addListener(listener);
btnRefresh.setGraphic(wrap(SVG.REFRESH.createIcon(Theme.blackFill(), -1)));
@ -292,12 +297,17 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
.filter(it -> {
switch (it.getVersionType()) {
case RELEASE:
return chkRelease.isSelected();
return radioRelease.isSelected();
case PENDING:
return radioSnapshot.isSelected();
case SNAPSHOT:
return chkSnapshot.isSelected();
if (GameVersionNumber.asGameVersion(it.getGameVersion()).isSpecial()) {
return radioAprilFools.isSelected();
} else {
return radioSnapshot.isSelected();
}
case OLD:
return chkOld.isSelected();
return radioOld.isSelected();
default:
return true;
}
@ -319,9 +329,7 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
root.setContent(emptyPane, ContainerAnimations.FADE);
} else {
if (items.isEmpty()) {
chkRelease.setSelected(true);
chkSnapshot.setSelected(true);
chkOld.setSelected(true);
radioRelease.setSelected(true);
} else {
list.getItems().setAll(items);
}

View File

@ -1420,6 +1420,7 @@ version.empty=No Instances
version.empty.add=Add new instance
version.empty.launch=No available instances. Clicking "OK" will take you to the "Download" page.\n\nYou can also download the game or switch game directories via the "Download" or "All Instances" buttons on the HMCL homepage.
version.empty.hint=There are no Minecraft instances here.\nYou can try switching to another game directory or clicking here to download one.
version.game.april_fools=April Fools
version.game.old=Historical
version.game.release=Release
version.game.releases=Releases

View File

@ -1213,6 +1213,7 @@ version.empty=沒有遊戲實例
version.empty.add=進入下載頁安裝遊戲
version.empty.launch=沒有可啟動的遊戲。點擊「確定」將進入「下載」頁面。\n你也可以點擊 HMCL 主介面左側的「下載」按鈕安裝遊戲,或在「實例清單」切換遊戲目錄。
version.empty.hint=沒有已安裝的遊戲。\n你可以切換其他遊戲目錄或者點擊此處進入遊戲下載頁面。
version.game.april_fools=愚人節
version.game.old=遠古版
version.game.release=正式版
version.game.releases=正式版

View File

@ -1223,6 +1223,7 @@ version.empty=没有游戏版本
version.empty.add=进入下载页安装游戏
version.empty.launch=没有可启动的游戏。点击“确定”将进入“下载”页面。\n你也可以点击 HMCL 主界面左侧的“下载”按钮安装游戏,或在“版本列表”切换游戏文件夹。
version.empty.hint=没有已安装的游戏。\n你可以切换其他游戏文件夹或者点击此处进入游戏下载页面。
version.game.april_fools=愚人节
version.game.old=远古版
version.game.release=正式版
version.game.releases=正式版

View File

@ -98,6 +98,10 @@ public abstract class GameVersionNumber implements Comparable<GameVersionNumber>
this.value = value;
}
public boolean isSpecial() {
return this instanceof Special;
}
enum Type {
PRE_CLASSIC, CLASSIC, INFDEV, ALPHA, BETA, NEW
}