korge
korge copied to clipboard
Evaluate using kotlin code instead of XML for .ktree
@soywiz is there any idea for this issue ?
I am really interesting this one.
It seems this is a reason why we deprecate readKTree, right ?
From my perspective, this looks like we do the same things as Jetpack Compose. (From xml to kotlin declarative ui). So that mean, we have to compile the kotlin code to display the preview, right? If you have any ideas for evaluate this feature, please share. I really really want to try to implement.
@quangson91 that's correct. KTree is deprecated because it forced to create descriptors for each component. That also forced to register them or to include some stuff in the output code that might not be used by some people.
It could be implemented by parsing the code, or executing the code in the JVM only. I wanted to make the editor available on the web too, but to do that JVM execution can't be used, and the Kotlin Compiler is not multiplatform. So I wanted to make a small Kotlin parser for a small subset, and use it to load some definition files, and then serialize the objects by outputing code.
I'm was not planing to work on it at least in until a few weeks, since I want to focus on fixing remaining bugs in KorIO. Do you want to implement it yourself?
Also notice, that this is the API I prepared for also supporting animations in this format:
https://github.com/korlibs/korge-next/blob/2beb13cc9d8b1715d767bf14f60b7eae1dbf9dac/korge/src/commonMain/kotlin/com/soywiz/korge/view/clip/MovieClip.kt
And the idea is implement the editor here:
https://github.com/korlibs/korge-editor
Since it generates code, it shouldn't need anything special to support it in korge-next
@soywiz Thank you for the detail. I will research this one: https://github.com/korlibs/korge-editor
It looks very interesting. Here is some of my view point:
- Parsing kotlin code is harder than parsing json or xml. In unity3d or cocos creator, the scene editor still save its data in json format. So, I think we should keep json/xml as scene format.
- I don't really know how Unity can create a C# Script component then play game on the editor. But my guess is: When the developer press the play button, Unity will generated all necessary code then run that project. So we can do the same.
For the editor, I would like to try implement as standalone first. Please tell me if my understanding is correct (same as the korge-editor target). So I can start to try implement the editor.