feat: help page
This commit is contained in:
@@ -206,6 +206,12 @@ public final class SVG {
|
|||||||
fill, width, height);
|
fill, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Node helpCircleOutline(ObjectBinding<? extends Paint> fill, double width, double height) {
|
||||||
|
return createSVGPath(
|
||||||
|
"M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z",
|
||||||
|
fill, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
public static Node alert(ObjectBinding<? extends Paint> fill, double width, double height) {
|
public static Node alert(ObjectBinding<? extends Paint> fill, double width, double height) {
|
||||||
return createSVGPath("M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z", fill, width, height);
|
return createSVGPath("M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z", fill, width, height);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher
|
||||||
|
* Copyright (C) 2021 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.main;
|
package org.jackhuang.hmcl.ui.main;
|
||||||
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
@@ -63,6 +80,7 @@ public class AboutPage extends StackPane {
|
|||||||
contributors.setTitle(i18n("about.thanks_to.contributors"));
|
contributors.setTitle(i18n("about.thanks_to.contributors"));
|
||||||
contributors.setSubtitle(i18n("about.thanks_to.contributors.statement"));
|
contributors.setSubtitle(i18n("about.thanks_to.contributors.statement"));
|
||||||
contributors.setExternalLink("https://github.com/huanghongxun/HMCL/graphs/contributors");
|
contributors.setExternalLink("https://github.com/huanghongxun/HMCL/graphs/contributors");
|
||||||
|
mcbbs.setExternalLink("https://hmcl.huangyuhui.net/api/redirect/sponsor");
|
||||||
|
|
||||||
IconedTwoLineListItem users = new IconedTwoLineListItem();
|
IconedTwoLineListItem users = new IconedTwoLineListItem();
|
||||||
users.setImage(new Image("/assets/img/craft_table.png", 32, 32, false, true));
|
users.setImage(new Image("/assets/img/craft_table.png", 32, 32, false, true));
|
||||||
|
|||||||
129
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/HelpPage.java
Normal file
129
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/HelpPage.java
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher
|
||||||
|
* Copyright (C) 2021 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.main;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import org.jackhuang.hmcl.task.Schedulers;
|
||||||
|
import org.jackhuang.hmcl.task.Task;
|
||||||
|
import org.jackhuang.hmcl.ui.construct.ComponentList;
|
||||||
|
import org.jackhuang.hmcl.ui.construct.IconedTwoLineListItem;
|
||||||
|
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
||||||
|
import org.jackhuang.hmcl.util.io.HttpRequest;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HelpPage extends SpinnerPane {
|
||||||
|
|
||||||
|
private final VBox content;
|
||||||
|
|
||||||
|
public HelpPage() {
|
||||||
|
content = new VBox();
|
||||||
|
content.setPadding(new Insets(10));
|
||||||
|
content.setSpacing(10);
|
||||||
|
content.setFillWidth(true);
|
||||||
|
setContent(content);
|
||||||
|
|
||||||
|
loadHelp();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadHelp() {
|
||||||
|
showSpinner();
|
||||||
|
Task.<List<HelpCategory>>supplyAsync(() -> HttpRequest.GET("https://hmcl.huangyuhui.net/api/help/").getJson(new TypeToken<List<HelpCategory>>() {
|
||||||
|
}.getType()))
|
||||||
|
.thenAcceptAsync(Schedulers.javafx(), helpCategories -> {
|
||||||
|
for (HelpCategory category : helpCategories) {
|
||||||
|
ComponentList categoryPane = new ComponentList();
|
||||||
|
|
||||||
|
for (Help help : category.getItems()) {
|
||||||
|
IconedTwoLineListItem item = new IconedTwoLineListItem();
|
||||||
|
item.setTitle(help.getTitle());
|
||||||
|
item.setSubtitle(help.getSubtitle());
|
||||||
|
item.setExternalLink(help.getUrl());
|
||||||
|
|
||||||
|
categoryPane.getContent().add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
content.getChildren().add(ComponentList.createComponentListTitle(category.title));
|
||||||
|
content.getChildren().add(categoryPane);
|
||||||
|
}
|
||||||
|
hideSpinner();
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class HelpCategory {
|
||||||
|
@SerializedName("title")
|
||||||
|
private final String title;
|
||||||
|
|
||||||
|
@SerializedName("items")
|
||||||
|
private final List<Help> items;
|
||||||
|
|
||||||
|
public HelpCategory() {
|
||||||
|
this("", Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public HelpCategory(String title, List<Help> items) {
|
||||||
|
this.title = title;
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Help> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Help {
|
||||||
|
@SerializedName("title")
|
||||||
|
private final String title;
|
||||||
|
|
||||||
|
@SerializedName("subtitle")
|
||||||
|
private final String subtitle;
|
||||||
|
|
||||||
|
@SerializedName("url")
|
||||||
|
private final String url;
|
||||||
|
|
||||||
|
public Help() {
|
||||||
|
this("", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Help(String title, String subtitle, String url) {
|
||||||
|
this.title = title;
|
||||||
|
this.subtitle = subtitle;
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubtitle() {
|
||||||
|
return subtitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,15 +36,17 @@ public class LauncherSettingsPage extends BorderPane implements DecoratorPage {
|
|||||||
private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>(new State(i18n("settings.launcher"), null, true, false, true, false, 200));
|
private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>(new State(i18n("settings.launcher"), null, true, false, true, false, 200));
|
||||||
private final TabHeader tab;
|
private final TabHeader tab;
|
||||||
private final TabHeader.Tab<SettingsPage> settingsTab = new TabHeader.Tab<>("settingsPage");
|
private final TabHeader.Tab<SettingsPage> settingsTab = new TabHeader.Tab<>("settingsPage");
|
||||||
|
private final TabHeader.Tab<HelpPage> helpTab = new TabHeader.Tab<>("helpPage");
|
||||||
private final TabHeader.Tab<AboutPage> aboutTab = new TabHeader.Tab<>("aboutPage");
|
private final TabHeader.Tab<AboutPage> aboutTab = new TabHeader.Tab<>("aboutPage");
|
||||||
private final TabHeader.Tab<SponsorPage> sponsorTab = new TabHeader.Tab<>("sponsorPage");
|
private final TabHeader.Tab<SponsorPage> sponsorTab = new TabHeader.Tab<>("sponsorPage");
|
||||||
private final TransitionPane transitionPane = new TransitionPane();
|
private final TransitionPane transitionPane = new TransitionPane();
|
||||||
|
|
||||||
public LauncherSettingsPage() {
|
public LauncherSettingsPage() {
|
||||||
settingsTab.setNodeSupplier(SettingsPage::new);
|
settingsTab.setNodeSupplier(SettingsPage::new);
|
||||||
|
helpTab.setNodeSupplier(HelpPage::new);
|
||||||
sponsorTab.setNodeSupplier(SponsorPage::new);
|
sponsorTab.setNodeSupplier(SponsorPage::new);
|
||||||
aboutTab.setNodeSupplier(AboutPage::new);
|
aboutTab.setNodeSupplier(AboutPage::new);
|
||||||
tab = new TabHeader(settingsTab, sponsorTab, aboutTab);
|
tab = new TabHeader(settingsTab, helpTab, sponsorTab, aboutTab);
|
||||||
|
|
||||||
tab.getSelectionModel().select(settingsTab);
|
tab.getSelectionModel().select(settingsTab);
|
||||||
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
FXUtils.onChangeAndOperate(tab.getSelectionModel().selectedItemProperty(), newValue -> {
|
||||||
@@ -61,6 +63,14 @@ public class LauncherSettingsPage extends BorderPane implements DecoratorPage {
|
|||||||
settingsItem.activeProperty().bind(tab.getSelectionModel().selectedItemProperty().isEqualTo(settingsTab));
|
settingsItem.activeProperty().bind(tab.getSelectionModel().selectedItemProperty().isEqualTo(settingsTab));
|
||||||
settingsItem.setOnAction(e -> tab.getSelectionModel().select(settingsTab));
|
settingsItem.setOnAction(e -> tab.getSelectionModel().select(settingsTab));
|
||||||
|
|
||||||
|
AdvancedListItem helpItem = new AdvancedListItem();
|
||||||
|
helpItem.getStyleClass().add("navigation-drawer-item");
|
||||||
|
helpItem.setTitle(i18n("help"));
|
||||||
|
helpItem.setLeftGraphic(wrap(SVG.helpCircleOutline(null, 20, 20)));
|
||||||
|
helpItem.setActionButtonVisible(false);
|
||||||
|
helpItem.activeProperty().bind(tab.getSelectionModel().selectedItemProperty().isEqualTo(helpTab));
|
||||||
|
helpItem.setOnAction(e -> tab.getSelectionModel().select(helpTab));
|
||||||
|
|
||||||
AdvancedListItem sponsorItem = new AdvancedListItem();
|
AdvancedListItem sponsorItem = new AdvancedListItem();
|
||||||
sponsorItem.getStyleClass().add("navigation-drawer-item");
|
sponsorItem.getStyleClass().add("navigation-drawer-item");
|
||||||
sponsorItem.setTitle(i18n("sponsor"));
|
sponsorItem.setTitle(i18n("sponsor"));
|
||||||
@@ -79,6 +89,7 @@ public class LauncherSettingsPage extends BorderPane implements DecoratorPage {
|
|||||||
|
|
||||||
AdvancedListBox sideBar = new AdvancedListBox()
|
AdvancedListBox sideBar = new AdvancedListBox()
|
||||||
.add(settingsItem)
|
.add(settingsItem)
|
||||||
|
.add(helpItem)
|
||||||
.add(sponsorItem)
|
.add(sponsorItem)
|
||||||
.add(aboutItem);
|
.add(aboutItem);
|
||||||
FXUtils.setLimitWidth(sideBar, 200);
|
FXUtils.setLimitWidth(sideBar, 200);
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public abstract class SettingsView extends StackPane {
|
|||||||
{
|
{
|
||||||
VBox headerLeft = new VBox();
|
VBox headerLeft = new VBox();
|
||||||
|
|
||||||
Label help = new Label(i18n("help"));
|
Label help = new Label(i18n("help.doc"));
|
||||||
Label helpSubtitle = new Label(i18n("help.detail"));
|
Label helpSubtitle = new Label(i18n("help.detail"));
|
||||||
helpSubtitle.getStyleClass().add("subtitle-label");
|
helpSubtitle.getStyleClass().add("subtitle-label");
|
||||||
|
|
||||||
|
|||||||
@@ -203,7 +203,8 @@ folder.resourcepacks=Resource packs
|
|||||||
folder.saves=Saves
|
folder.saves=Saves
|
||||||
folder.screenshots=Screenshots
|
folder.screenshots=Screenshots
|
||||||
|
|
||||||
help=Documentations
|
help=Help
|
||||||
|
help.doc=Documentations
|
||||||
help.detail=For manufacturers of datapacks, modpacks, etc.
|
help.detail=For manufacturers of datapacks, modpacks, etc.
|
||||||
|
|
||||||
input.email=Username must be an email.
|
input.email=Username must be an email.
|
||||||
|
|||||||
@@ -204,7 +204,8 @@ folder.resourcepacks=资源包文件夹
|
|||||||
folder.saves=存档文件夹
|
folder.saves=存档文件夹
|
||||||
folder.screenshots=截图文件夹
|
folder.screenshots=截图文件夹
|
||||||
|
|
||||||
help=Hello Minecraft! Launcher 帮助文档
|
help=帮助
|
||||||
|
help.doc=Hello Minecraft! Launcher 帮助文档
|
||||||
help.detail=可查阅数据包、整合包制作指南等内容。
|
help.detail=可查阅数据包、整合包制作指南等内容。
|
||||||
|
|
||||||
input.email=用户名必须是邮箱
|
input.email=用户名必须是邮箱
|
||||||
|
|||||||
Reference in New Issue
Block a user