Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Rectangle a readonly struct. #21178

Merged
merged 2 commits into from Nov 14, 2023
Merged

Conversation

pchote
Copy link
Member

@pchote pchote commented Oct 31, 2023

This PR completes a long-standing TODO from #15973.

The ability to directly manipulate widget bounds is important for WidgetLogic usability, so a thin WidgetBounds struct 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 onto Widget directly.

Height = height;
}

public static explicit operator Rectangle(WidgetBounds src)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair. Yes I'd take a ToRectangle.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Game.Renderer.EnableScissor is only used by the widget code right? Why can't the signature be changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a core engine function that doesn't have visibility of the mod-defined WidgetBounds type.

@pchote
Copy link
Member Author

pchote commented Nov 6, 2023

Updated.

Copy link
Member

@penev92 penev92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A wise man once told me "immutable things good" 👍

@penev92 penev92 merged commit 73be364 into OpenRA:bleed Nov 14, 2023
3 checks passed
@penev92
Copy link
Member

penev92 commented Nov 14, 2023

Changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants