Class GuiPlacement
java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.gui.placement.GuiPlacement
Finds where to put something of your own so it keeps out of the way of what else is on the screen: you give its size
and where you'd like it, and it comes back there if that is clear, else at the nearest clear place found by sliding it
in the directions you allow, past whatever is in its way, without leaving the bounds you set.
GuiPlacement.Position at = GuiPlacement.hud()
.size(width, 16).at(x, 4).gap(2)
.directions(GuiPlacement.Direction.DOWN)
.find();
GuiAreas.unrecorded(() -> drawMine(graphics, at.x(), at.y()));
By default it searches every direction within the whole screen and leaves out anything covering more than 40% of the
screen (vignettes and other overlays aren't in anyone's way). Client and render thread only.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final recordWhere to draw it, and whether it moved out of the way of something. -
Method Summary
Modifier and TypeMethodDescriptionstatic GuiPlacementA placement among the areas given.at(int x, int y) Where it would go if nothing were in the way (its top left corner).directions(GuiPlacement.Direction... directions) The directions it may slide in to get clear (every one unless set).find()The place found: where it goes, and whether it had to move from where it was asked to go.gap(int gap) The pixels kept clear between it and anything else.static GuiPlacementhud()A placement among what the HUD drew last frame.Leaves out the areas this matches as well (it adds to what is left out already).ignoreDrawnInside(int x, int y, int width, int height) Leaves out the things drawn wholly inside this box, a panel of your own say (widgets there still count).ignoreOverlays(float share) Leaves out anything covering more than this share of the screen, 0 to 1 (0.4 unless set; 1 keeps everything).static GuiPlacementscreen()A placement among what the open screen drew last frame and its widgets.size(int width, int height) The size of what is being placed.within(int x, int y, int width, int height) The box it must stay inside (the whole screen unless set).
-
Method Details
-
hud
A placement among what the HUD drew last frame. -
screen
A placement among what the open screen drew last frame and its widgets. -
among
A placement among the areas given. -
size
The size of what is being placed. -
at
Where it would go if nothing were in the way (its top left corner). -
gap
The pixels kept clear between it and anything else. -
within
The box it must stay inside (the whole screen unless set). -
directions
The directions it may slide in to get clear (every one unless set). -
ignoreOverlays
Leaves out anything covering more than this share of the screen, 0 to 1 (0.4 unless set; 1 keeps everything). -
ignore
Leaves out the areas this matches as well (it adds to what is left out already). -
ignoreDrawnInside
Leaves out the things drawn wholly inside this box, a panel of your own say (widgets there still count). -
find
The place found: where it goes, and whether it had to move from where it was asked to go.
-