Skip to content

Fundamentals of gooey

Info

The idea of this article is to explain the general architecture of gooey. This is a more technical article and it is not super critical for you to start building UI in your games with gooey, but it can be a very useful tool to better understand how it works and be able to debug issues more easily. It can also serve as a starting point should you wish to extend the library (either forking it or submitting a pull request) or even build your own thing.

How is gooey built

The library consists of the following elements:

  • A general constructor function, __UIWidget, which is a "base" constructor;
  • Specific constructor functions per widget (e.g. UIPanel, UIGrid, etc.), each of which extends __UIWidget;
  • A manager object named UI, which is an invisible controller object that handles the rendering and interaction in the background;
  • A set of convenience functions, ui_* that absract methods from UI for you to setup;
  • A configuration script, __Configuration__;
  • A dependency for rendering text, namely, JujuAdams's ScribbleDX.

About the __UIWidget constructor

This constructor serves as a "base class" for the actual widget. As such, you should not use it to instantiate new widgets. There is no need to interact with __UIWidget directly.

About the UI manager object

The UI manager object is a persistent, unique object that will exist in your project to manage rendering and interaction of widgets. It will operate silently in the background. You can interact with it via the convenience functions, to set certain things.

Prior to version 2024.6, the UI manager object needed to be added manually to the project, ensuring it was the first object being created. However, this is not needed anymore, as gooey will now automagically create and manage it.

Library standards and syntax

The library uses the following naming conventions:

  • PascalCase for naming constructors and the manager object
    • The prefix __ for denoting "private" things - stuff you shouldn't mess with
  • camelCase for naming methods
  • snake_case for naming of convenience functions

Also, gooey implements a fluent interface for widgets - this is, it lets you chain most methods together.

Organization

The gooey folder you will see when importing the .YYMPS file will have the following structure:

  • Dependencies folder - This will house all required dependencies. As of this writing, ScribbleDX is the only dependency. The gooey file (and the log) will indicate the version of ScribbleDX that is included in each release.
  • Internal folder - This is a collection of scripts where the code for the constructors and convenience functions is housed. Since 2024.12, this is broken up in several scripts by widget type, for easier management.
    • For customizing certain things about how text is rendered, you will have to edit the different ScribbleDX configuration scripts. Please refer to Scribble's documentation in order to do this.
  • Test Sprites - Kenney UI folder - This is the bundled set of sprites from Kenney's UI asset pack, which come included in case you want to use them to prototype (or even use in your game!) If you are not using them, you can safely delete the folder.
  • The __Configuration__ script, which houses several macro configuration variables
  • The gooey imagotype as a sprite
  • The UI manager object

The log message level

gooey includes a message level configuration that determines the amount of info that is printed in the GameMaker log. This is a setting you can either change in the configuration script before compiling, or at runtime with convenience functions. This is handled via an enum named UI_MESSAGE_LEVEL. You can select between the following elements:

Message level Explanation
NOTICE Basically no messages, save from displaying the version number at game start.
ERROR Apart from the above, gooey will also display messages about errors.
WARNING Apart from the above, gooey will include some warnings that are not game breaking but could result in unwanted behavior.
INFO The highest level of messages. Apart from the above, gooey will provide messages about each widget being created or destroyed, for example.