Home Artists Posts Import Register

Content

For the past week and a half I have been working on moving a bunch of UI code from GDScript to C++, mainly the block layout manager which handles block stamping, drag&drop, block resizing and tempo transformations.

This started with just reimplementing the actual logic for how blocks should move around, hopefully fixing all the existing bugs and not introducing too many new ones. The complications of Blockhead's drag and drop system come from a couple of design rules I decided on early on:

  • Placed blocks can never overlap (perhaps this will change later if I decide to add automatic crossfading)
  • Blocks in a selection shouldn't obstruct the placement of the "root" block (the block directly under the mouse cursor). So if they collide with something on the workspace they should automatically search vertically for an available space.

As I made progress it made sense to also move other aspects of the system to c++ such as the drawing of lane insertion markers and snapping indicators, the actual lane insertion operations, and the sample override feature (If you didn't know, while adding a single sample to the workspace you can hover over an existing sample block to temporarily replace the sample, and then click to confirm the replacement.)

This  refactoring is taking a while but several existing bugs have been fixed and I think the blocks are already moving around in a more satisfactory way. It should also be easier from now on to tweak and make changes to the behaviour.

The code is clearer than it was before but still not super clean because the system still has to interact with so many other elements which only exist as pure GDScript objects, meaning I have to make heavy use of Godot's object system to pass data back and forth.

Comments

No comments found for this post.