Good Grid
The ultimate DrawGridLayer rewrite and API!
- Rotation Support
- Extensive API
- Bug Fixes
Editor Extension in MegaHack cannot be detected, thus the grid size will too small unless you enable extension override in this mod's settings.
Here's what you can do with the API as a Developer:
Everything here is under the alpha::grid namespace.
API.hpp
void overrideGridBoundsSize(cocos2d::CCSize size)
Sets the grid's max width and height bounds (useful for editor extenders and limiters).
cocos2d::CCSize getGridBoundsSize()
Returns the max width and height bounds of the grid.
void overrideGridBoundsOrigin(cocos2d::CCPoint origin)
Sets the grid's origin (bottom left) coordinates.
cocos2d::CCPoint getGridBoundsOrigin()
Returns the coordinates of the grid's origin.
bool isObjectVisible(GameObject* object)
Util to check if an object is visible (accounting for selecting, group and hide options).
Color.hpp
This class can store either 1 or 2 colors. It can be constructed just like a ccColor4B, and they are compatible with each other. When there is a second color, what is drawn will be done as a gradient of the two rather than one color. It also stores the blending mode if you wish to set that.
DrawGridBase.hpp
This class is what makes up every part of the new DrawGridLayer, it is a CCNode and thus can have its visibility and z order set. Every child on the DrawGridLayer inherits this class. It provides a few methods as well as some virtuals you can override that will be called when added to the DrawGridLayer as a child. This also contains a few of the API methods seen above for convenience.
void drawLine(const cocos2d::CCPoint& start, const cocos2d::CCPoint& end, const alpha::grid::Color& color, float width, bool relative = false)
Draws a line to the screen with two coordinates where it starts and ends. The width is the line width. Relative is if it scales with the editor zoom.
void drawRect(const cocos2d::CCRect& rect, const alpha::grid::Color& color)
Draws a rectangle to the screen with a CCRect param dictating the bounds and a color param to set its color.
void drawRectOutline(const cocos2d::CCRect& rect, const alpha::grid::Color& color, float width, bool relative = false)
Draws a rectangle outline to the screen with a CCRect param dictating the bounds, a color param to set its color, and the width of the outline. Relative is if it scales with the editor zoom.
virtual void draw(const CCRect& visibleRect);
A virtual you can override that will draw what is within it to the DrawGridLayer, The rect param is the bounds of the screen in the grid's node space to handle culling, these respect scale and rotation, please use these for the best performance.
DrawLayers
You can include all the draw layers by including DrawLayers.hpp
setPropertiesFor methods will be in order of priority set and all will run.
class Grid : public DrawGridBase
The editor grid.
void setGridColor(const alpha::grid::Color& color)
Sets the grid color.
const alpha::grid::Color& getGridColor() const
Returns the grid color.
void setLineWidth(float width)
Sets the line width.
float getLineWidth() const
Returns the line width.
class Bounds : public DrawGridBase
The bounds of the editor (white vertical line at X: 0 and the max and minimum height).
void setTopBoundColor(const alpha::grid::Color& color)
Sets the top bound color.
const alpha::grid::Color& getTopBoundColor() const
Returns the top bound color.
void setBottomBoundColor(const alpha::grid::Color& color)
Sets the bottom bound color.
const alpha::grid::Color& getBottomBoundColor() const
Returns the bottom bound color.
void setVerticalBoundColor(const alpha::grid::Color& color)
Sets the vertical bound color.
const alpha::grid::Color& getVerticalBoundColor() const
Returns the vertical bound color.
void seTopBoundtLineWidth(float width)
Sets the top bound line width.
float getTopBoundLineWidth() const
Returns the top bounc line width.
void setBottomBoundLineWidth(float width)
Sets the bottom bound line width.
float getBottomBoundLineWidth() const
Returns the bottom bound line width.
void setVerticalBoundLineWidth(float width)
Sets the vertical bound line width.
float getVerticalBoundLineWidth() const
Returns the vertical bound line width.
class Ground : public DrawGridBase
The ground lines (when in a non cube/robot gamemode).
void setTopGroundColor(const alpha::grid::Color& color)
Sets the top ground color.
const alpha::grid::Color& getTopGroundColor() const
Returns the top ground color.
void setBottomGroundColor(const alpha::grid::Color& color)
Sets the bottom ground color.
const alpha::grid::Color& getBottomGroundColor() const
Returns the bottom ground color.
void setTopGroundLineWidth(float width)
Sets the top ground line width.
float getTopGroundLineWidth() const
Returns the top ground line width.
void setBottomGroundLineWidth(float width)
Sets the bottom ground line width.
float getBottomGroundLineWidth() const
Returns the bottom ground line width.
class GuideObjects : public DrawGridBase
These are the objects that show portal bounds when preview is enabled.
void setPropertiesForObject(geode::Function colorForObject, int priority = 0)
Lets you pass in a method that allows for modifying the colors, as well as passing in the object. An example would be setting colors depending on an object.
class EffectLines : public DrawGridBase
These are the lines triggers show when not spawn or touch triggered.
void setPropertiesForObject(geode::Function colorForObject, int priority = 0)
Lets you pass in a method that allows for modifying the color, as well as passing in the object. An example would be setting colors depending on an object.
class DurationLines : public DrawGridBase
These are the duration lines triggers show.
void setPropertiesForObject(geode::Function colorForObject, int priority = 0)
Lets you pass in a method that allows for modifying the color, as well as passing in the object. An example would be setting colors depending on an object.
class Guidelines : public DrawGridBase
These are the music guidelines you can set when choosing a song.
void setPropertiesForValue(geode::Function colorForValue, int priority = 0)
Lets you pass in a method that allows for modifying the color, as well as passing in the numeric color value the guideline is set to (view https://wyliemaster.github.io/gddocs/#/resources/client/level-components/guideline-string for more info). An example would be setting colors depending on the value, expanding what color values already exist.
class BPMTriggers : public DrawGridBase
These are the bpm guidelines you can set with a BPM Trigger.
void setPropertiesForBeats(geode::Function colorForBeats, int priority = 0)
Lets you pass in a method that allows for modifying the color, as well as passing in the object, what beat the line being modified is on, and how many beats per bar there are. An example would be changing the beat color depending on what beat it is in a bar.
class AudioLine : public DrawGridBase
This is the line that shows when you play music in the editor.
void setPropertiesForTime(geode::Function colorForTime, int priority = 0);
Lets you pass in a method that allows for modifying the color, as well as passing in if playback is live, the song's time, and the position of the line. An example would be setting the line color hue based on the time.
class CenterCross : public DrawGridBase
The center vertical and horizontal lines that mark before and after a trigger activates.
void setVerticalLineColor(const alpha::grid::Color& color)
Sets the vertical line color.
const alpha::grid::Color& getVerticalLineColor() const
Returns the vertical line color.
void setHorizontalLineColor(const alpha::grid::Color& color)
Sets the horizontal line color.
const alpha::grid::Color& getVerticalLineColor() const
Returns the horizontal line color.
void setVerticalLineWidth(float width)
Sets the vertical line width.
float getVerticalLineWidth() const
Returns the vertical line width.
void setHorizontalLineWidth(float width)
Sets the horizontal line width.
float getHoritzontalLineWidth() const
Returns the horizontal line width.
class PreviewLockLine : public DrawGridBase
The line that shows the position where preview is locked.
void setLineColor(const alpha::grid::Color& color)
Sets the line color.
const alpha::grid::Color& getLineColor() const
Returns the line color.
void setLineWidth(float width)
Sets the line width.
float getLineWidth() const
Returns the line width.