Skip to content

Commit

Permalink
help of api
Browse files Browse the repository at this point in the history
  • Loading branch information
cubewhy committed Jan 29, 2024
1 parent 97bab43 commit fc8d5c2
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 12 deletions.
13 changes: 8 additions & 5 deletions src/main/kotlin/org/cubewhy/celestial/gui/GuiLauncher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand All @@ -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
Expand Down
6 changes: 1 addition & 5 deletions src/main/kotlin/org/cubewhy/celestial/gui/LauncherNews.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 18 additions & 2 deletions src/main/kotlin/org/cubewhy/celestial/gui/elements/help/HelpApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
}
}

private fun JTextArea.readOnly(): JTextArea {
this.isEditable = false
return this
}
6 changes: 6 additions & 0 deletions src/main/resources/languages/launcher.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions src/main/resources/languages/launcher_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions src/main/resources/languages/launcher_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 で見つけることができます。

12 changes: 12 additions & 0 deletions src/main/resources/languages/launcher_ko.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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에서 찾을 수 있습니다.
6 changes: 6 additions & 0 deletions src/main/resources/languages/launcher_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 找到

0 comments on commit fc8d5c2

Please sign in to comment.