-
Notifications
You must be signed in to change notification settings - Fork 733
feat #3763: add April Fool's Day version category #3905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bba19b5
fc06bd7
bf2c50b
f66657c
e4b98f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,7 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres | |
private final JFXCheckBox chkRelease; | ||
private final JFXCheckBox chkSnapshot; | ||
private final JFXCheckBox chkOld; | ||
private final JFXCheckBox chkAprilFools; | ||
private final ComponentList centrePane; | ||
private final StackPane center; | ||
|
||
|
@@ -139,7 +140,10 @@ public VersionsPage(Navigation navigation, String title, String gameVersion, Dow | |
chkOld = new JFXCheckBox(i18n("version.game.old")); | ||
HBox.setMargin(chkOld, new Insets(10, 0, 10, 0)); | ||
|
||
checkPane.getChildren().setAll(chkRelease, chkSnapshot, chkOld); | ||
chkAprilFools = new JFXCheckBox(i18n("version.game.aprilfools")); | ||
HBox.setMargin(chkAprilFools, new Insets(10, 0, 10, 0)); | ||
|
||
checkPane.getChildren().setAll(chkRelease, chkSnapshot, chkOld, chkAprilFools); | ||
} | ||
|
||
list = new JFXListView<>(); | ||
|
@@ -151,18 +155,19 @@ public VersionsPage(Navigation navigation, String title, String gameVersion, Dow | |
HBox refreshPane = new HBox(); | ||
refreshPane.setAlignment(Pos.CENTER_RIGHT); | ||
|
||
btnRefresh = new JFXButton(i18n("button.refresh")); | ||
btnRefresh = new JFXButton(); | ||
btnRefresh.getStyleClass().add("jfx-tool-bar-button"); | ||
btnRefresh.setOnAction(e -> onRefresh()); | ||
|
||
JFXButton btnSearch = new JFXButton(i18n("search")); | ||
JFXButton btnSearch = new JFXButton(); | ||
Glavo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
btnSearch.getStyleClass().add("jfx-tool-bar-button"); | ||
btnSearch.setGraphic(wrap(SVG.SEARCH.createIcon(Theme.blackFill(), -1))); | ||
|
||
searchBar = new HBox(); | ||
{ | ||
searchBar.setAlignment(Pos.CENTER); | ||
searchBar.setPadding(new Insets(0, 5, 0, 0)); | ||
searchBar.setPadding(new Insets(0, 0, 0, 0)); | ||
searchBar.setMaxWidth(130); | ||
|
||
JFXTextField searchField = new JFXTextField(); | ||
searchField.setPromptText(i18n("search")); | ||
|
@@ -235,6 +240,8 @@ public VersionsPage(Navigation navigation, String title, String gameVersion, Dow | |
chkSnapshot.setVisible(hasType); | ||
chkOld.setManaged(hasType); | ||
chkOld.setVisible(hasType); | ||
chkAprilFools.setManaged(hasType); | ||
chkAprilFools.setVisible(hasType); | ||
|
||
if (hasType) { | ||
centrePane.getContent().setAll(toolbarPane, list); | ||
|
@@ -269,6 +276,7 @@ public VersionsPage(Navigation navigation, String title, String gameVersion, Dow | |
chkRelease.selectedProperty().addListener(listener); | ||
chkSnapshot.selectedProperty().addListener(listener); | ||
chkOld.selectedProperty().addListener(listener); | ||
chkAprilFools.selectedProperty().addListener(listener); | ||
queryString.addListener(listener); | ||
|
||
btnRefresh.setGraphic(wrap(SVG.REFRESH.createIcon(Theme.blackFill(), -1))); | ||
|
@@ -297,6 +305,8 @@ private List<RemoteVersion> loadVersions() { | |
return chkSnapshot.isSelected(); | ||
case OLD: | ||
return chkOld.isSelected(); | ||
case APRILFOOLS: | ||
return chkAprilFools.isSelected(); | ||
default: | ||
return true; | ||
} | ||
|
@@ -321,6 +331,7 @@ public void refresh() { | |
chkRelease.setSelected(true); | ||
chkSnapshot.setSelected(true); | ||
chkOld.setSelected(true); | ||
chkAprilFools.setSelected(true); | ||
} else { | ||
list.getItems().setAll(items); | ||
} | ||
|
@@ -418,6 +429,16 @@ public void updateItem(RemoteVersion remoteVersion, boolean empty) { | |
content.setImage(VersionIconType.COMMAND.getIcon()); | ||
content.setExternalLink(i18n("wiki.version.game.snapshot", remoteVersion.getGameVersion())); | ||
break; | ||
case APRILFOOLS: | ||
content.getTags().setAll(i18n("version.game.aprilfools")); | ||
content.setImage(VersionIconType.COMMAND.getIcon()); | ||
if (remoteVersion.getGameVersion().startsWith("2.0")) { | ||
content.setExternalLink(i18n("wiki.version.game.snapshot", "2.0")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The APRILFOOLS case reuses the snapshot wiki link; consider defining a dedicated translation key or URL (e.g., Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
} | ||
else { | ||
content.setExternalLink(i18n("wiki.version.game.snapshot", remoteVersion.getGameVersion())); | ||
} | ||
break; | ||
default: | ||
content.getTags().setAll(i18n("version.game.old")); | ||
content.setImage(VersionIconType.CRAFT_TABLE.getIcon()); | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1351,6 +1351,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.aprilfools=AprilFools | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The English label "AprilFools" lacks spacing; consider changing it to "April Fools" or "April Fool's" for better readability.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||
version.game.old=Historical | ||||||||||
version.game.release=Release | ||||||||||
version.game.releases=Releases | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,7 @@ public enum Type { | |
RELEASE, | ||
SNAPSHOT, | ||
OLD, | ||
PENDING | ||
PENDING, | ||
APRILFOOLS | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -26,7 +26,10 @@ | |||||||||||||
import org.jackhuang.hmcl.util.Immutable; | ||||||||||||||
|
||||||||||||||
import java.time.Instant; | ||||||||||||||
import java.util.Calendar; | ||||||||||||||
import java.util.Date; | ||||||||||||||
import java.util.List; | ||||||||||||||
import java.util.TimeZone; | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* | ||||||||||||||
|
@@ -38,7 +41,7 @@ public final class GameRemoteVersion extends RemoteVersion { | |||||||||||||
private final ReleaseType type; | ||||||||||||||
|
||||||||||||||
public GameRemoteVersion(String gameVersion, String selfVersion, List<String> url, ReleaseType type, Instant releaseDate) { | ||||||||||||||
super(LibraryAnalyzer.LibraryType.MINECRAFT.getPatchId(), gameVersion, selfVersion, releaseDate, getReleaseType(type), url); | ||||||||||||||
super(LibraryAnalyzer.LibraryType.MINECRAFT.getPatchId(), gameVersion, selfVersion, releaseDate, getReleaseType(type, releaseDate, gameVersion), url); | ||||||||||||||
this.type = type; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
@@ -59,8 +62,17 @@ public int compareTo(RemoteVersion o) { | |||||||||||||
return o.getReleaseDate().compareTo(getReleaseDate()); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private static Type getReleaseType(ReleaseType type) { | ||||||||||||||
if (type == null) return Type.UNCATEGORIZED; | ||||||||||||||
private static Type getReleaseType(ReleaseType type, Instant releaseDate, String gameVersion) { | ||||||||||||||
if (type == null || releaseDate == null || gameVersion == null) return Type.UNCATEGORIZED; | ||||||||||||||
if (gameVersion.startsWith("2.0")) return Type.APRILFOOLS; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The hardcoded prefix "2.0" is a magic string; consider extracting it into a descriptive constant (e.g., APRIL_FOOLS_VERSION_PREFIX) to improve readability.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
if (gameVersion.startsWith("1.RV")) return Type.APRILFOOLS; | ||||||||||||||
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); | ||||||||||||||
cal.setTime(Date.from(releaseDate)); | ||||||||||||||
int month = cal.get(Calendar.MONTH); | ||||||||||||||
int day = cal.get(Calendar.DAY_OF_MONTH); | ||||||||||||||
Comment on lines
+69
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This uses the legacy Calendar/Date API; consider using java.time (e.g.,
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
if (month == Calendar.APRIL && day == 1) { | ||||||||||||||
return Type.APRILFOOLS; | ||||||||||||||
} | ||||||||||||||
switch (type) { | ||||||||||||||
case RELEASE: | ||||||||||||||
return Type.RELEASE; | ||||||||||||||
|
@@ -70,6 +82,8 @@ private static Type getReleaseType(ReleaseType type) { | |||||||||||||
return Type.UNCATEGORIZED; | ||||||||||||||
case PENDING: | ||||||||||||||
return Type.PENDING; | ||||||||||||||
case APRILFOOLS: | ||||||||||||||
return Type.APRILFOOLS; | ||||||||||||||
default: | ||||||||||||||
return Type.OLD; | ||||||||||||||
} | ||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.