Ok, I think it's time for an update.
I have quite a lot implemented in
Flutter, but there are two big issues that make me unsure if this is the right way to go.
First, Flutter has a
drawAtlas method, which allows to render a lot of things on the canvas with a really good performance, but if I use it, there will be some black lines on the screen. It's most likely the
Flutter antialiasing issue, which is open for a few years now, and nobody knows when it'll be fixed.
View attachment 67663
I tried rendering the map using a
for
loop instead, and it looks good, but the performance is of course very bad when there's a lot of tiles on the screen. So a 'workaround' would be to use the
for
loop if zoom is not smaller than ~0.5x and then switch to
drawAtlas
. But it still sucks.
Second,
Dart (programming language used by Flutter) doesn't have real multithreading mechanism. It has isolates, but they are not really threads, because each isolate has its own memory and there's no way to access another isolate. This means if I want to pass data from one isolate to another one, Dart will copy them in memory, which is a costly operation. So for example, if I want to save project changes, I need to copy all the changes in memory to the isolate inside which I want to save changes, and copying will be done in UI isolate, freezing the UI. If the project is imported from TFS files, saving it for the first time means it'll have to copy the whole project data, so the UI will freeze for a minute or two. This one, I could actually accept, because importing projects won't happen that often.
But, there is
Tauri. And I'm thinking about it. It's basically better
Electron with
Rust backend (and native WebView under the hood). So I could write map rendering and IO operations in Rust, compile it to
Wasm and put it on WebView together with the UI written in HTML+JS+CSS. Of course, I would use a frontend framework, like
React or
Svelte. Or even
Yew. So the plan is to play with it for a while and if it turns out to be a good tool for the job, I'll port my existing Flutter project.
Now, I also need some feedback regarding project structure. I'm still not sure what format should map areas be saved in, but for now I used json (mostly because Dart has native support for it). What do you think about this:
JSON:
{
"tiles": {
"32099,31567,9": [
6967,
{
"item": 3031,
"count": 24
},
{
"item": 3028,
"count": 12
}
]
}
}
If the only attribute an entity has is item, then instead of
{ "item": 6967 }
it's
6967
, to save disk space and make it more readable. The same applies to tiles, if a tile has some attributes, for example protection zone, it becomes:
JSON:
{
"attributes": {
"protectionZone": true
},
"entities": [
6967,
{
"item": 3031,
"count": 24
},
{
"item": 3028,
"count": 12
}
]
}
And last, I was also thinking about storing assets (sprites). If we'll have human-readable map files, why should we use .spr file? So instead I created a directory with items assets, and each item also has its own directory. Images names contain information about frame, pattern x/y/z and layer. What do you think?
View attachment 67664