@@ -72,47 +72,82 @@ public static ModularPanel defaultPanel(MetaItem<?>.MetaValueItem valueItem) {
7272 return createPanel (valueItem .unlocalizedName );
7373 }
7474
75- public static ModularPanel createPopupPanel (String name , int width , int height ) {
76- return createPopupPanel (name , width , height , false , false );
75+ public static PopupPanel createPopupPanel (String name , int width , int height ) {
76+ return defaultPopupPanel (name )
77+ .size (width , height );
7778 }
7879
79- public static ModularPanel createPopupPanel (String name , int width , int height , boolean disableBelow ,
80- boolean closeOnOutsideClick ) {
81- return new PopupPanel ( name , width , height , disableBelow , closeOnOutsideClick );
80+ public static PopupPanel createPopupPanel (String name , int width , int height , boolean deleteCachedPanel ) {
81+ return createPopupPanel ( name , width , height )
82+ . deleteCachedPanel ( deleteCachedPanel );
8283 }
8384
84- public static ModularPanel defaultPopupPanel (String name ) {
85- return defaultPopupPanel (name , false , false );
85+ public static PopupPanel defaultPopupPanel (String name ) {
86+ return new PopupPanel (name )
87+ .size (DEFAULT_WIDTH , DEFAULT_HIEGHT );
8688 }
8789
88- public static ModularPanel defaultPopupPanel (String name , boolean disableBelow ,
89- boolean closeOnOutsideClick ) {
90- return new PopupPanel (name , DEFAULT_WIDTH , DEFAULT_HIEGHT , disableBelow , closeOnOutsideClick );
90+ public static PopupPanel defaultPopupPanel (String name , boolean disableBelow ,
91+ boolean closeOnOutsideClick , boolean deleteCachedPanel ) {
92+ return defaultPopupPanel (name )
93+ .disablePanelsBelow (disableBelow )
94+ .closeOnOutOfBoundsClick (closeOnOutsideClick )
95+ .deleteCachedPanel (deleteCachedPanel );
9196 }
9297
93- private static class PopupPanel extends ModularPanel {
98+ public static class PopupPanel extends ModularPanel {
9499
95- private final boolean disableBelow ;
96- private final boolean closeOnOutsideClick ;
100+ private boolean disableBelow ;
101+ private boolean closeOnOutsideClick ;
102+ private boolean deleteCachedPanel ;
97103
98- public PopupPanel (@ NotNull String name , int width , int height , boolean disableBelow ,
99- boolean closeOnOutsideClick ) {
104+ private PopupPanel (@ NotNull String name ) {
100105 super (name );
101- size ( width , height ). align (Alignment .Center );
106+ align (Alignment .Center );
102107 background (GTGuiTextures .BACKGROUND_POPUP );
103108 child (ButtonWidget .panelCloseButton ().top (5 ).right (5 )
104109 .onMousePressed (mouseButton -> {
105110 if (mouseButton == 0 || mouseButton == 1 ) {
106111 this .closeIfOpen (true );
107- if (isSynced () && getSyncHandler () instanceof IPanelHandler handler ) {
108- handler .deleteCachedPanel ();
109- }
110112 return true ;
111113 }
112114 return false ;
113115 }));
116+ }
117+
118+ @ Override
119+ public void onClose () {
120+ super .onClose ();
121+ if (deleteCachedPanel && isSynced () && getSyncHandler () instanceof IPanelHandler handler ) {
122+ handler .deleteCachedPanel ();
123+ }
124+ }
125+
126+ public PopupPanel disablePanelsBelow (boolean disableBelow ) {
114127 this .disableBelow = disableBelow ;
128+ return this ;
129+ }
130+
131+ public PopupPanel closeOnOutOfBoundsClick (boolean closeOnOutsideClick ) {
115132 this .closeOnOutsideClick = closeOnOutsideClick ;
133+ return this ;
134+ }
135+
136+ public PopupPanel deleteCachedPanel (boolean deleteCachedPanel ) {
137+ this .deleteCachedPanel = deleteCachedPanel ;
138+ return this ;
139+ }
140+
141+ @ Override
142+ public PopupPanel size (int w , int h ) {
143+ super .size (w , h );
144+ return this ;
145+ }
146+
147+ @ Override
148+ public PopupPanel size (int val ) {
149+ super .size (val );
150+ return this ;
116151 }
117152
118153 @ Override
0 commit comments