seclerp / rider-monogame

MonoGame plugin for JetBrains Rider
https://plugins.jetbrains.com/plugin/18415-monogame
MIT License
30 stars 0 forks source link

MGCB: Implement UI for editing `.mgcb` files (integrated MGCB Editor) #26

Open seclerp opened 2 months ago

seclerp commented 2 months ago

Implementation status

Motivation

Dealing with dotnet-mgcb-editor and satelite tools like dotnet-mgcb-editor-mac is complicated:

  1. MGCB Editor still doesn't work on Apple Silicon chips properly
  2. "Open in MGCB Editor" requires complex .NET Tools tracking in different places for different versions of MonoGame
  3. The MGCB Editor installation process relies on the user's .NET Tools setup, including proper .dotnet/tools folder mapping

Because of bullet 1, we also can't ship the tool binaries together with the plugin.

So, it makes sense to introduce a UI for editing..mgcb files without direct dependency in the dotnet-mgcb-editor tool. It will also replace MGCB Previewer for .mgcb files, which is currently available as a separate previewer pane.

Analysis

Standalone MGCB Editor looks like this:

image

Designing .mgcb

It has the following major UI parts:

image

There are also a couple of actions to add new content to the file:

Building .mgcb

MGCB Editor has such build-related toolbar actions:

Design

MGCB Editor tool window

The new editor will be implemented as a separate tool window called "MGCB Editor", instead of an embedded previewer pane near the file. It will have a .mgcb file selector to switch between multiple files (in case of a multi-platform solution setup).

Selecting the .mgcb file in the Solution view or in the code editor will by default switch the file in the tool window to the selected one.

The "MGCB Editor" tool window will have an identical layout to the existing previewer - 2 panels divided by a splitter:

image_2024-10-04_23-09-06

Additionally, the new tool window will have toolbar actions, similar to the standalone editor's actions.

By default, MGCB Editor will be placed in the upper-right corner (e.g. Database)

MGCB Build Log tool window

Build actions will request content build, representing its result in a separate Build-like tool window called "MGCB Build Log". It will have the same or a similar output as the standalone MGCB Editor's build output.

Implementation notes

The vast majority of content-related boilerplate and additional stuff is implemented in the MonoGame.Framework.Content.Pipeline library. It can be reused to build content and read metadata.

We don't need to write new parser MGCB files to pass them to the build engine. We already have parsers on frontend, based on IJPL's PSI.

Note: Backend PSI coming with feature/mgcb-backend-psi branch will help too.

Open questions

Links