From fc8d5c276d4fdeb54eb1fd07f920feb390eab235 Mon Sep 17 00:00:00 2001 From: cubewhy Date: Mon, 29 Jan 2024 21:37:36 +0800 Subject: [PATCH] help of api --- .../org/cubewhy/celestial/gui/GuiLauncher.kt | 13 +++++++----- .../org/cubewhy/celestial/gui/LauncherNews.kt | 6 +----- .../celestial/gui/elements/help/HelpApi.kt | 20 +++++++++++++++++-- .../resources/languages/launcher.properties | 6 ++++++ .../languages/launcher_en.properties | 6 ++++++ .../languages/launcher_ja.properties | 6 ++++++ .../languages/launcher_ko.properties | 12 +++++++++++ .../languages/launcher_zh.properties | 6 ++++++ 8 files changed, 63 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/org/cubewhy/celestial/gui/GuiLauncher.kt b/src/main/kotlin/org/cubewhy/celestial/gui/GuiLauncher.kt index f8a9134e..17de96f2 100644 --- a/src/main/kotlin/org/cubewhy/celestial/gui/GuiLauncher.kt +++ b/src/main/kotlin/org/cubewhy/celestial/gui/GuiLauncher.kt @@ -36,6 +36,9 @@ import javax.swing.* class GuiLauncher : JFrame() { private val guiPlugins = GuiPlugins() + lateinit var layoutX: CardLayout + lateinit var mainPanel: JPanel + init { // register with EventManager register(this) @@ -92,9 +95,9 @@ class GuiLauncher : JFrame() { this.add(menu, BorderLayout.NORTH) // main panel - val mainPanel = Panel() - val layout = CardLayout() - mainPanel.layout = layout + mainPanel = JPanel() + layoutX = CardLayout() + mainPanel.layout = layoutX // TODO: add enabled pages (from metadata) // add pages mainPanel.add("news", GuiNews()) @@ -104,8 +107,8 @@ class GuiLauncher : JFrame() { mainPanel.add("about", GuiAbout()) // bind buttons - btnPrevious.addActionListener { layout.previous(mainPanel) } - btnNext.addActionListener { layout.next(mainPanel) } + btnPrevious.addActionListener { layoutX.previous(mainPanel) } + btnNext.addActionListener { layoutX.next(mainPanel) } this.add(mainPanel) // add MainPanel // try to find the exist game process diff --git a/src/main/kotlin/org/cubewhy/celestial/gui/LauncherNews.kt b/src/main/kotlin/org/cubewhy/celestial/gui/LauncherNews.kt index bd5c932f..173f6d57 100644 --- a/src/main/kotlin/org/cubewhy/celestial/gui/LauncherNews.kt +++ b/src/main/kotlin/org/cubewhy/celestial/gui/LauncherNews.kt @@ -63,11 +63,7 @@ class LauncherNews(val json: JsonObject) : JPanel() { val button = JButton(text) button.addActionListener { - try { - Desktop.getDesktop().browse(URI.create(json["link"].asString)) - } catch (ex: IOException) { - throw RuntimeException(ex) - } + Desktop.getDesktop().browse(URI.create(json["link"].asString)) } this.add(button) diff --git a/src/main/kotlin/org/cubewhy/celestial/gui/elements/help/HelpApi.kt b/src/main/kotlin/org/cubewhy/celestial/gui/elements/help/HelpApi.kt index 487089eb..b9bed3c6 100644 --- a/src/main/kotlin/org/cubewhy/celestial/gui/elements/help/HelpApi.kt +++ b/src/main/kotlin/org/cubewhy/celestial/gui/elements/help/HelpApi.kt @@ -6,11 +6,27 @@ package org.cubewhy.celestial.gui.elements.help +import org.cubewhy.celestial.Celestial +import org.cubewhy.celestial.Celestial.f import org.cubewhy.celestial.gui.elements.HelpPage +import java.awt.CardLayout +import javax.swing.JButton import javax.swing.JLabel +import javax.swing.JTextArea class HelpApi : HelpPage("API") { init { - this.add(JLabel("Help of api, WIP.")) + this.add(JTextArea(f.getString("gui.help.api")).readOnly()) + this.add(JButton(f.getString("gui.settings.title")).let { + it.addActionListener { + Celestial.launcherFrame.layoutX.show(Celestial.launcherFrame.mainPanel, "settings") + } + it + }) } -} \ No newline at end of file +} + +private fun JTextArea.readOnly(): JTextArea { + this.isEditable = false + return this +} diff --git a/src/main/resources/languages/launcher.properties b/src/main/resources/languages/launcher.properties index 21b553d3..4b7c3d7f 100644 --- a/src/main/resources/languages/launcher.properties +++ b/src/main/resources/languages/launcher.properties @@ -239,4 +239,10 @@ gui.plugins.info.meta.dependencies=Dependencies gui.version.fetch=Fetch json gui.help.document=Online help gui.help.context.api=Document about the API +gui.help.api=LunarCN API: https://api.lunarclient.top\n\ +Moonsworth API: https://api.lunarclientprod.com\n\ +You can switch the API in the settings, but do not put a trailing slash ("\\\\") when typing\n\ +\n\ +Of course, you can also build the API yourself. We have open sourced the backend of the API (not Moonsworth API, only copycat)\n\ +Can be found at https://github.com/CubeWhyMC/website diff --git a/src/main/resources/languages/launcher_en.properties b/src/main/resources/languages/launcher_en.properties index ce4f1fef..b70ffb1f 100644 --- a/src/main/resources/languages/launcher_en.properties +++ b/src/main/resources/languages/launcher_en.properties @@ -239,3 +239,9 @@ gui.plugins.info.meta.dependencies=Dependencies gui.version.fetch=Fetch json gui.help.document=Online help1 gui.help.context.api=Document about the API +gui.help.api=LunarCN API: https://api.lunarclient.top\n\ +Moonsworth API: https://api.lunarclientprod.com\n\ +You can switch the API in the settings, but do not put a trailing slash ("\\\\") when typing\n\ +\n\ +Of course, you can also build the API yourself. We have open sourced the backend of the API (not Moonsworth API, only copycat)\n\ +Can be found at https://github.com/CubeWhyMC/website diff --git a/src/main/resources/languages/launcher_ja.properties b/src/main/resources/languages/launcher_ja.properties index 1a660422..12e32b6c 100644 --- a/src/main/resources/languages/launcher_ja.properties +++ b/src/main/resources/languages/launcher_ja.properties @@ -250,4 +250,10 @@ gui.plugins.info.meta.dependencies=依存関係 gui.version.fetch=jsonを取得 gui.help.document=オンラインヘルプ gui.help.context.api=APIに関するドキュメント +gui.help.api=LunarCN API: https://api.lunarclient.top\n\ +ムーンズワース API: https://api.lunarclientprod.com\n\ +設定で API を切り替えることができますが、入力時に末尾にスラッシュ (「\\\\」) を入れないでください\n\ +\n\ +もちろん、API を自分で構築することもできます。API のバックエンドをオープンソース化しました (Moonsworth API ではなく、コピーキャットのみ)\n\ +https://github.com/CubeWhyMC/website で見つけることができます。 diff --git a/src/main/resources/languages/launcher_ko.properties b/src/main/resources/languages/launcher_ko.properties index 73a532a4..7b28080d 100644 --- a/src/main/resources/languages/launcher_ko.properties +++ b/src/main/resources/languages/launcher_ko.properties @@ -245,3 +245,15 @@ gui.plugins.info.meta.dependencies=종속성 gui.version.fetch=json 가져오기 gui.help.document=온라인 도움말 gui.help.context.api=API에 관한 문서 +gui.help.api=LunarCN API: https://api.lunarclient.top\n\ +문스워스 API: https://api.lunarclientprod.com\n\ +설정에서 API를 전환할 수 있지만 입력할 때 후행 슬래시("\\\\")를 넣지 마십시오.\n\ +\\N\ +물론 API를 직접 구축할 수도 있습니다. 우리는 API의 백엔드를 오픈 소스로 제공했습니다(Moonsworth API가 아니라 모방만 가능함)\n\ +https://github.com/CubeWhyMC/website에서 찾을 수 있습니다. +gui.help.api=LunarCN API: https://api.lunarclient.top\n\ +문스워스 API: https://api.lunarclientprod.com\n\ +설정에서 API를 전환할 수 있지만 입력할 때 후행 슬래시("\\\\")를 넣지 마십시오.\n\ +\\N\ +물론 API를 직접 구축할 수도 있습니다. 우리는 API의 백엔드를 오픈 소스로 제공했습니다(Moonsworth API가 아니라 모방만 가능함)\n\ +https://github.com/CubeWhyMC/website에서 찾을 수 있습니다. diff --git a/src/main/resources/languages/launcher_zh.properties b/src/main/resources/languages/launcher_zh.properties index 566cdc32..55eef579 100644 --- a/src/main/resources/languages/launcher_zh.properties +++ b/src/main/resources/languages/launcher_zh.properties @@ -241,4 +241,10 @@ gui.plugins.info.meta.dependencies=依赖项 gui.version.fetch=获取Json gui.help.document=帮助页面(在线) gui.help.context.api=API帮助 +gui.help.api=LunarCN API: https://api.lunarclient.top\n\ +Moonsworth API: https://api.lunarclientprod.com\n\ +在设置中可以切换API, 但是输入时末尾不要带斜杠("\\\\")\n\ +\n\ +当然, 你也可以自己搭建API, 我们开源了API的后端(非Moonsworth API, 仅山寨)\n\ +可以在 https://github.com/CubeWhyMC/website 找到