FAForever / FAForever/faf-moderator-client

Intercept and visualize the callbacks for the new painting feature

Open
#256 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
5
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Related to: https://github.com/FAForever/fa/pull/6726

We recently introduced the ability to paint directly on the map. With this issue I describe the format so that it can be parsed by the moderator client.

```lua
---@alias UIInterleavedBrushStrokeSamples number[]
```

The name of the sim callback is `SharePaintingBrushStroke`. The data (its argument) is structured as:

```lua
--- Represents a shared brushStroke that is send across the network. The data structure is slightly different to reduce network bandwidth.
---@class UISharedBrushStroke
---@field PaintingAdapterIdentifier string
---@field Samples UIInterleavedBrushStrokeSamples
---@field ShareId number
```

The command source is the player that is responsible for the painting. The painting itself is inside the `Samples` field which is just an array of numbers. The numbers are interleaved (world) coordinates. They are interleaved by [ToInterleavedBrushStrokeSamples](https://github.com/FAForever/fa/blob/develop/lua/ui/game/painting/ShareAdapters/PaintingCanvasAdapter.lua#L222-L243), and then turned back into data that you can work with at [FromInterleavedBrushStrokeSamples ](https://github.com/FAForever/fa/blob/develop/lua/ui/game/painting/ShareAdapters/PaintingCanvasAdapter.lua#L245-L270). Feel free to use a different data structure - the data structures used in the game are designed for maximum efficiency. As an example, [through the use of a structure of arrays instead of an array of structures](https://en.wikipedia.org/wiki/AoS_and_SoA).

Note that the parsing should probably be done in https://github.com/FAForever/faf-java-commons. I'd recommend to store it as a list of drawings and add the command source (and perhaps the name of the player) for convenience.

In the moderator client you'll need a way to map the points to a canvas. I'm not familiar with Java to suggest an approach.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.