Debugger: Lua - Allow negative width/height values in drawRectangle

This commit is contained in:
Sour 2018-06-17 13:32:18 -04:00
parent 24ff779124
commit f18e5054aa
4 changed files with 12 additions and 4 deletions

View file

@ -33,6 +33,15 @@ public:
DrawRectangleCommand(int x, int y, int width, int height, int color, bool fill, int frameCount) :
DrawCommand(frameCount), _x(x), _y(y), _width(width), _height(height), _color(color), _fill(fill)
{
if(width < 0) {
_x += width;
_width = -width;
}
if(height < 0) {
_y += height;
_height = -height;
}
//Invert alpha byte - 0 = opaque, 255 = transparent (this way, no need to specifiy alpha channel all the time)
_color = (~color & 0xFF000000) | (color & 0xFFFFFF);
}

View file

@ -377,8 +377,6 @@ int LuaApi::DrawRectangle(lua_State *lua)
int y = l.ReadInteger();
int x = l.ReadInteger();
checkminparams(4);
errorCond(height <= 0, "height must be >= 1");
errorCond(width <= 0, "width must be >= 1");
DebugHud::GetInstance()->DrawRectangle(x, y, width, height, color, fill, frameCount);

View file

@ -9,11 +9,12 @@ chapter: false
### New Features ###
* New event callbacks: [**<kbd>scriptEnded</kbd>**](/apireference/enums.html#eventtype)
* New event callback: [**<kbd>scriptEnded</kbd>**](/apireference/enums.html#eventtype)
### Changes ###
* The end address parameter for <kbd>[addMemoryCallback](/apireference/callbacks.html#addmemorycallback)</kbd> and <kbd>[removeMemoryCallback](/apireference/callbacks.html#removememorycallback)</kbd> is now optional.
* The <kbd>[drawRectangle](/apireference/drawing.html#drawrectangle)</kbd> function now accepts negative height/width values.
### Bug Fixes ###

View file

@ -71,7 +71,7 @@ Draws a line between (x, y) to (x2, y2) using the specified color for a specific
x - *Integer* X position
y - *Integer* Y position
width - *Integer* The rectangle's width
height - *Integer* The rectangle's height
height - *Integer* The rectangle's height
color - *Integer* Color
fill - *Boolean* Whether or not to draw an outline, or a filled rectangle.
duration - *Integer* Number of frames to display (Default: 1 frame)