Remove uses of state-mutating Rectangle.Offset and Intersect.

This commit is contained in:
Paul Chote
2018-12-30 16:24:11 +00:00
parent 0b641c20df
commit 015316e909
3 changed files with 10 additions and 5 deletions

View File

@@ -214,7 +214,7 @@ namespace OpenRA
{ {
// Must remain inside the current scissor rect // Must remain inside the current scissor rect
if (scissorState.Any()) if (scissorState.Any())
rect.Intersect(scissorState.Peek()); rect = Rectangle.Intersect(rect, scissorState.Peek());
Flush(); Flush();
Context.EnableScissor(rect.Left, rect.Top, rect.Width, rect.Height); Context.EnableScissor(rect.Left, rect.Top, rect.Width, rect.Height);

View File

@@ -11,6 +11,7 @@
using System; using System;
using OpenRA.Network; using OpenRA.Network;
using OpenRA.Primitives;
using OpenRA.Widgets; using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic namespace OpenRA.Mods.Common.Widgets.Logic
@@ -212,10 +213,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
// Hide the logo and center just the text // Hide the logo and center just the text
if (title != null) if (title != null)
title.Bounds.Offset(logo.Bounds.Left - title.Bounds.Left, 0); title.Bounds.X = logo.Bounds.Left;
if (version != null) if (version != null)
version.Bounds.Offset(logo.Bounds.Left - version.Bounds.Left, 0); version.Bounds.X = logo.Bounds.X;
width -= logo.Bounds.Width; width -= logo.Bounds.Width;
} }
@@ -228,7 +229,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var container = panel.GetOrNull("MOD_CONTAINER"); var container = panel.GetOrNull("MOD_CONTAINER");
if (container != null) if (container != null)
{ {
container.Bounds.Offset((container.Bounds.Width - width) / 2, 0); container.Bounds.X += (container.Bounds.Width - width) / 2;
container.Bounds.Width = width; container.Bounds.Width = width;
} }
} }

View File

@@ -178,7 +178,11 @@ namespace OpenRA.Mods.Common.Widgets
var drawBounds = backgroundRect.InflateBy(-BorderWidth, -BorderWidth, -BorderWidth, -BorderWidth); var drawBounds = backgroundRect.InflateBy(-BorderWidth, -BorderWidth, -BorderWidth, -BorderWidth);
Game.Renderer.EnableScissor(drawBounds); Game.Renderer.EnableScissor(drawBounds);
drawBounds.Offset(-ChildOrigin); // ChildOrigin enumerates the widget tree, so only evaluate it once
var co = ChildOrigin;
drawBounds.X -= co.X;
drawBounds.Y -= co.Y;
foreach (var child in Children) foreach (var child in Children)
if (child.Bounds.IntersectsWith(drawBounds)) if (child.Bounds.IntersectsWith(drawBounds))
child.DrawOuter(); child.DrawOuter();