Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
10 changes: 2 additions & 8 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,18 @@ jobs:

- name: Build mod apk
run: bash ./gradlew assemble
continue-on-error: true
Comment on lines 28 to +30

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop swallowing build failures

In the release workflow, a failed bash ./gradlew assemble now continues to the artifact upload and release steps instead of failing the job immediately; when the APK build fails late or produces only partial outputs, the workflow can still publish a release without the expected APK, masking the broken build. The same pattern is also applied to the tool jar step below.

Useful? React with 👍 / 👎.


- name: Build tool jar
run: bash ./gradlew :tool:jar

- name: Build web jar
working-directory: web/web
run: bash ./gradlew bootJar
continue-on-error: true

- name: List build outputs
run: |
echo "=== APK Files ==="
ls -la app/build/outputs/apk/
echo "\n=== Tool JAR ==="
ls -la tool/build/libs/
echo "\n=== Web JAR ==="
ls -la web/web/build/libs/

- name: Upload built files (Artifact)
uses: actions/upload-artifact@v4
Expand All @@ -51,7 +47,6 @@ jobs:
path: |
app/build/outputs/apk/*.apk
tool/build/libs/tool.jar
web/web/build/libs/*.jar

- name: Generate safe tag and release info
id: release_info
Expand Down Expand Up @@ -99,7 +94,6 @@ jobs:
files: |
app/build/outputs/apk/release/*.apk
tool/build/libs/*.jar
web/web/build/libs/*.jar
generate_release_notes: true
prerelease: true
env:
Expand Down
2,349 changes: 2,349 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

Binary file removed .gradle/8.13/checksums/checksums.lock
Binary file not shown.
Binary file removed .gradle/8.13/checksums/md5-checksums.bin
Binary file not shown.
Binary file removed .gradle/8.13/checksums/sha1-checksums.bin
Binary file not shown.
Binary file removed .gradle/8.13/executionHistory/executionHistory.bin
Binary file not shown.
Binary file removed .gradle/8.13/executionHistory/executionHistory.lock
Binary file not shown.
Binary file removed .gradle/8.13/fileChanges/last-build.bin
Binary file not shown.
Binary file removed .gradle/8.13/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed .gradle/8.13/fileHashes/fileHashes.lock
Binary file not shown.
Binary file removed .gradle/8.13/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file removed .gradle/8.13/gc.properties
Empty file.
Binary file removed .gradle/8.14.4/checksums/checksums.lock
Binary file not shown.
Binary file removed .gradle/8.14.4/checksums/md5-checksums.bin
Binary file not shown.
Binary file removed .gradle/8.14.4/checksums/sha1-checksums.bin
Binary file not shown.
Binary file removed .gradle/8.14.4/executionHistory/executionHistory.lock
Binary file not shown.
Binary file removed .gradle/8.14.4/fileChanges/last-build.bin
Binary file not shown.
Binary file removed .gradle/8.14.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed .gradle/8.14.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file removed .gradle/8.14.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file removed .gradle/8.14.4/gc.properties
Empty file.
Binary file removed .gradle/8.14/checksums/checksums.lock
Binary file not shown.
Binary file removed .gradle/8.14/executionHistory/executionHistory.lock
Binary file not shown.
Binary file removed .gradle/8.14/fileChanges/last-build.bin
Binary file not shown.
Binary file removed .gradle/8.14/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed .gradle/8.14/fileHashes/fileHashes.lock
Binary file not shown.
Binary file removed .gradle/8.14/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file removed .gradle/8.14/gc.properties
Empty file.
Binary file removed .gradle/9.0.0/checksums/checksums.lock
Binary file not shown.
Binary file removed .gradle/9.0.0/checksums/md5-checksums.bin
Binary file not shown.
Binary file removed .gradle/9.0.0/checksums/sha1-checksums.bin
Binary file not shown.
Binary file removed .gradle/9.0.0/executionHistory/executionHistory.lock
Binary file not shown.
Binary file removed .gradle/9.0.0/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed .gradle/9.0.0/fileHashes/fileHashes.lock
Binary file not shown.
Binary file removed .gradle/9.0.0/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file removed .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 0 additions & 2 deletions .gradle/buildOutputCleanup/cache.properties

This file was deleted.

Binary file removed .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
2 changes: 0 additions & 2 deletions .gradle/config.properties

This file was deleted.

Binary file removed .gradle/file-system.probe
Binary file not shown.
Empty file removed .gradle/vcs-1/gc.properties
Empty file.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
- [Eve-aic.md](Eve-aic.md)
- [NEXT_STEPS.md](NEXT_STEPS.md)
- [Tool 模块文档](tool/README.md)
- [Web 自动布局功能](web/AUTO_LAYOUT_FEATURE.md)
- [Web HELP](web/web/HELP.md)
- [Git 提交规范](.github/git-commit-instructions.md)


Expand Down
14 changes: 7 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ plugins {

android {
namespace = "com.mindustry.ide"
compileSdk {
version = release(36)
}
compileSdk = 36

defaultConfig {
applicationId = "com.mindustry.ide"
Expand All @@ -36,18 +34,20 @@ android {
buildFeatures {
compose = true
}
kotlinOptions {
jvmTarget = "17"
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
}

dependencies {
implementation(project(":tool"))

implementation("androidx.compose.material3:material3:1.4.0")
val mindustryVersion = "v157.4"

implementation("androidx.core:core-ktx:1.18.0")
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.9.0")
implementation("androidx.activity:activity-compose:1.8.2")
implementation(platform("androidx.compose:compose-bom:2024.09.00"))
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all subprojects/modules.
plugins {
id("com.android.application") version "8.12.0" apply false
id("com.android.application") version "8.7.3" apply false
id("org.jetbrains.kotlin.plugin.compose") version "2.3.21" apply false
id("org.jetbrains.kotlin.jvm") version "2.3.21" apply false
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Binary file not shown.
2 changes: 0 additions & 2 deletions tool/.gradle/buildOutputCleanup/cache.properties

This file was deleted.

2 changes: 2 additions & 0 deletions tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,5 @@ val editor = MyJsonEditor(myParser)
- `DetectingContentParser.kt` 目前为空文件,需要根据需求实现
- `JsonWorkFile.import()` 和 `export()` 方法尚未实现
- `JsonParser.load()` 方法需要在子类中实现具体逻辑

## JsonApi的ws服务器规范
3 changes: 3 additions & 0 deletions tool/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ dependencies {

// Jsoup for HTML parsing
implementation("org.jsoup:jsoup:1.22.2")

// WebSocket Server
implementation("org.java-websocket:Java-WebSocket:1.5.7")
}
Binary file modified tool/build/classes/kotlin/main/META-INF/tool.kotlin_module
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@

ɝ
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
8
7
0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tool/build/kotlin/compileKotlin/cacheable/last-build.bin
Binary file not shown.
Binary file not shown.
Binary file modified tool/build/libs/tool.jar
Binary file not shown.
240 changes: 240 additions & 0 deletions tool/src/main/java/com/mindustry/ide/tool/json/JsonApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
package com.mindustry.ide.tool.json

import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import org.java_websocket.WebSocket
import org.java_websocket.handshake.ClientHandshake
import org.java_websocket.server.WebSocketServer
import java.net.InetSocketAddress


/**
* 将JsonEditorTool封装成可调用的api
* @author ZenXSin
**/
class JsonApi {

val toolManagers = mutableMapOf<String, Pair<JsonEditorTool, Tool>>()

class Tool(val jet: JsonEditorTool) {
fun getAllClass(): List<String> {
return jet.parser.classMap?.keys()?.map { it.toString() } ?: listOf("JsonEditorTool列表为空,请先初始化")
}

fun getAllField(className: String): List<String> {
return jet.parser.classMap?.get(className)?.fields?.map { it.name } ?: listOf("类 $className 不存在,请检查")
}

fun getFieldDoc(className: String, fieldName: String): String {
return jet.parser.getFieldDoc(className, fieldName)
}

fun getFieldDefaultValue(className: String, fieldName: String): String {
return jet.parser.getFieldDefaultValue(className, fieldName)
}


}

class ToolData {
val classDatas: MutableMap<Int, Tool> = mutableMapOf()
val parser: JsonParser = JsonParser()
private var nextId: Int = 0

var error: (String) -> Unit = {}
var info: (String) -> Unit = {}
var warning: (String) -> Unit = {}
var debug: (String) -> Unit = {}

fun newClass(className: String): Int {
val id = nextId++
val tool = Tool(ApiJsonEditorTool(parser))
classDatas[id] = tool
debug("----------")
debug("创建类: $className, ID: $id")
debug("----------")
return id
}

fun removeClass(classId: Int): Boolean {
debug("----------")
if (classDatas.containsKey(classId)) {
debug("类 $classId 存在")
} else {
debug("类 $classId 不存在")
}
debug("删除类: $classId")
debug("----------")
return classDatas.remove(classId) != null
}

inner class ApiJsonEditorTool(parser: JsonParser) : JsonEditorTool(parser) {
override fun error(message: String) {
this@ToolData.error(message)
}

override fun info(message: String) {
this@ToolData.info(message)
}

override fun warning(message: String) {
this@ToolData.warning(message)
}

override fun debug(message: String) {
this@ToolData.debug(message)
}
}

class JsonApiWebSocketHandler(val toolData: ToolData, val port: Int) {
private var server: Server? = null

fun start() {
if (server != null) {
println("WebSocket 服务器已在运行")
return
}
server = Server(InetSocketAddress(port))
server?.start()
println("WebSocket 服务器启动在端口: $port")
}

fun stop() {
server?.let {
try {
it.stop(1000)
println("WebSocket 服务器已停止")
} catch (e: Exception) {
println("停止服务器失败: ${e.message}")
} finally {
server = null
}
}
}

init {
toolData.info = {
broadcast("")
}
}

fun broadcast(message: String) {
server?.broadcast(message)
println("广播消息: $message")
}

class Server(address: InetSocketAddress) : WebSocketServer(address) {
override fun onOpen(conn: WebSocket, handshake: ClientHandshake) {
println("客户端连接: ${conn.remoteSocketAddress}")
}

override fun onMessage(conn: WebSocket, message: String) {
println("收到消息: $message")
conn.send("Echo: $message")
Comment on lines +134 to +136

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Dispatch WebSocket messages to the API

For any client that connects to the new WebSocket server and sends one of the defined request types such as AllClass or AllField, onMessage currently only returns Echo: ... and never parses WebSocketData or calls ToolData/Tool, so the advertised callable WebSocket API cannot actually be used.

Useful? React with 👍 / 👎.

}

override fun onClose(conn: WebSocket, code: Int, reason: String, remote: Boolean) {
println("客户端断开: ${conn.remoteSocketAddress}, 原因: $reason")
}

override fun onError(conn: WebSocket?, ex: Exception) {
println("WebSocket 错误: ${ex.message}")
}

override fun onStart() {
println("WebSocket 服务器已启动")
}
}

}
}
}

/**
* 规范化的Api接口
* @author ZenXSin
* @param content 内容
* @param wsType 内容类型
* @param out 推送还是接收,默认为接收
* @param strList 接收消息时解析的内容,按照wsType中input的顺序排列
**/

@Serializable
data class WebSocketData(
var wsType: WebSocketDataType,
var content: String,
var out: Boolean = false,
var strList: MutableList<String> = mutableListOf()
) {
init {
if (!out) {
val json = Json.parseToJsonElement(content)

for (i in wsType.input) {
when (i.second) {
DataType.String -> {
strList.add(json.jsonObject[i.first]!!.jsonPrimitive.content)
}

DataType.Int -> {
strList.add(json.jsonObject[i.first]!!.jsonPrimitive.content)
}

DataType.Float -> {
strList.add(json.jsonObject[i.first]!!.jsonPrimitive.content)
}

DataType.List -> {
val jsonArray = json.jsonObject[i.first]!!.jsonArray
strList.add(jsonArray.toString()) //[x1,x2]
}

DataType.Boolean -> {
strList.add(json.jsonObject[i.first]!!.jsonPrimitive.content)
}

DataType.Object -> TODO()
}
}
} else {
//TODO 暂时不知道些什么
}
}

}

/**
* WebSocket推送消息的类型
* @author ZenXSin
* @param input 外部推送接收的内容
* @param output 内部推送发送的内容
**/
enum class WebSocketDataType(
val input: List<Pair<String, DataType>> = listOf(),
val output: List<Pair<String, DataType>> = listOf()
) {
Log(listOf("text" to DataType.String)),
AllClass(output = listOf("Class_List" to DataType.List)),
AllField(listOf("Class_Name" to DataType.String), listOf("Field_List" to DataType.List))
}

enum class DataType {
String, Int, Float, List, Boolean, Object
}

class InputData {
var str: String = ""
var int: Int = 0
var float: Float = 0f
var list: MutableList<InputData> = mutableListOf()
var boolean: Boolean = false
var obj: () -> Unit = {}
}

//Test
fun main() {

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import arc.struct.ObjectMap
import arc.util.Nullable

/**Json编辑工具封装,需实现日志输出*/
abstract class JsonEditorTool(val parser: IJsonParser) {
abstract class JsonEditorTool(val parser: JsonParser) {
abstract fun error(message: String)
abstract fun info(message: String)
abstract fun warning(message: String)
abstract fun debug(message: String)

fun getClassByName(name: String): Class<*> {
val ret = parser.classMap?.get(name)
Expand Down
Loading