Make Rectangle a readonly struct. - #21178
Conversation
2434e52 to
b0f2a97
Compare
| Height = height; | ||
| } | ||
|
|
||
| public static explicit operator Rectangle(WidgetBounds src) |
There was a problem hiding this comment.
Eww. I'd rather expose any helpers we needed, IntersectsWith, Contains, etc directly for ergonomic use and convert to a Rectangle internally if we're interested in reusing the logic.
There was a problem hiding this comment.
The issue is that Game.Renderer.EnableScissor requires a Rectangle and can't (IMO) cleanly be changed otherwise - and it seems a bit redundant to add those methods if we still need to convert to a Rectangle afterwards anyway.
I can replace this with to a .ToRectangle() method if that would be preferrable.
There was a problem hiding this comment.
Fair. Yes I'd take a ToRectangle.
There was a problem hiding this comment.
Game.Renderer.EnableScissor is only used by the widget code right? Why can't the signature be changed?
There was a problem hiding this comment.
its a core engine function that doesn't have visibility of the mod-defined WidgetBounds type.
b0f2a97 to
479993b
Compare
|
Updated. |
479993b to
2f366c2
Compare
2f366c2 to
0be6e59
Compare
penev92
left a comment
There was a problem hiding this comment.
A wise man once told me "immutable things good" 👍
This PR completes a long-standing TODO from #15973.
The ability to directly manipulate widget bounds is important for WidgetLogic usability, so a thin
WidgetBoundsstruct is created to keep this ability. In the future we could (with a bit of FieldLoader magic to route the IntegerExpressions to different fields) move the four integers ontoWidgetdirectly.