Remove Graphics::SetClipRect

This commit is contained in:
mniip 2023-04-12 19:24:25 +02:00
parent 9b9b0b794a
commit aa2fa9ed8c
7 changed files with 17 additions and 44 deletions

View File

@ -459,16 +459,6 @@ void Graphics::SwapClipRect(Rect<int> &rect)
clipRect &= video.Size().OriginRect();
}
void Graphics::SetClipRect(int &x, int &y, int &w, int &h)
{
Rect<int> rect = RectSized(Vec2(x, y), Vec2(w, h));
SwapClipRect(rect);
x = rect.TopLeft.X;
y = rect.TopLeft.Y;
w = rect.Size().X;
h = rect.Size().Y;
}
bool Graphics::GradientStop::operator <(const GradientStop &other) const
{
return point < other.point;

View File

@ -104,6 +104,4 @@ public:
Graphics();
void SwapClipRect(Rect<int> &);
[[deprecated("Use SwapClipRect")]]
void SetClipRect(int &x, int &y, int &w, int &h);
};

View File

@ -11,8 +11,6 @@
typedef uint32_t pixel;
constexpr int PIXELCHANNELS = 3;
[[deprecated("Avoid manipulating pixel* as char*")]]
constexpr int PIXELSIZE = 4;
// Least significant byte is blue, then green, then red, then alpha.
// Use sparingly, e.g. when passing packed data to a third party library.

View File

@ -573,10 +573,7 @@ void GameView::NotifyToolListChanged(GameModel * sender)
else
tempButton = new ToolButton(ui::Point(currentX, YRES+1), ui::Point(30, 18), tool->Name, tool->Identifier, tool->Description);
tempButton->clipRectX = 1;
tempButton->clipRectY = YRES + 1;
tempButton->clipRectW = XRES - 1;
tempButton->clipRectH = 18;
tempButton->ClipRect = RectSized(Vec2(1, RES.Y + 1), Vec2(RES.X - 1, 18));
//currentY -= 17;
currentX -= 31;
@ -1848,11 +1845,8 @@ void GameView::DoDraw()
c->Tick();
{
int x = 0;
int y = 0;
int w = WINDOWW;
int h = WINDOWH;
g->SetClipRect(x, y, w, h); // reset any nonsense cliprect Lua left configured
auto rect = g->Size().OriginRect();
g->SwapClipRect(rect); // reset any nonsense cliprect Lua left configured
}
}

View File

@ -45,14 +45,10 @@ void ToolButton::OnMouseUp(int x, int y, unsigned int button)
void ToolButton::Draw(const ui::Point& screenPos)
{
Graphics * g = GetGraphics();
int x = clipRectX;
int y = clipRectY;
int w = clipRectW;
int h = clipRectH;
if (clipRectW && clipRectH)
{
g->SetClipRect(x, y, w, h); // old cliprect is now in x, y, w, h
}
auto rect = ClipRect;
if (ClipRect.Size().X && ClipRect.Size().Y)
g->SwapClipRect(rect); // old cliprect is now in rect
int totalColour = Appearance.BackgroundInactive.Blue + (3*Appearance.BackgroundInactive.Green) + (2*Appearance.BackgroundInactive.Red);
if (Appearance.GetTexture())
@ -85,10 +81,9 @@ void ToolButton::Draw(const ui::Point& screenPos)
{
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, buttonDisplayText, 0, 0, 0, 255);
}
if (clipRectW && clipRectH)
{
g->SetClipRect(x, y, w, h); // apply old clip rect
}
if (ClipRect.Size().X && ClipRect.Size().Y)
g->SwapClipRect(rect); // apply old clip rect
}
void ToolButton::SetSelectionState(int state)

View File

@ -16,8 +16,5 @@ public:
void SetSelectionState(int state);
int GetSelectionState();
Tool *tool;
int clipRectX = 0;
int clipRectY = 0;
int clipRectW = 0;
int clipRectH = 0;
Rect<int> ClipRect = RectSized(Vec2<int>::Zero, Vec2<int>::Zero);
};

View File

@ -3901,11 +3901,12 @@ int LuaScriptInterface::graphics_setClipRect(lua_State * l)
int y = luaL_optinteger(l, 2, 0);
int w = luaL_optinteger(l, 3, WINDOWW);
int h = luaL_optinteger(l, 4, WINDOWH);
luacon_g->SetClipRect(x, y, w, h);
lua_pushinteger(l, x);
lua_pushinteger(l, y);
lua_pushinteger(l, w);
lua_pushinteger(l, h);
auto rect = RectSized(Vec2(x, y), Vec2(w, h));
luacon_g->SwapClipRect(rect);
lua_pushinteger(l, rect.TopLeft.X);
lua_pushinteger(l, rect.TopLeft.Y);
lua_pushinteger(l, rect.Size().X);
lua_pushinteger(l, rect.Size().Y);
return 4;
}