2424import net .minecraft .util .ITickable ;
2525
2626import codechicken .lib .raytracer .CuboidRayTraceResult ;
27+ import com .cleanroommc .modularui .api .IPanelHandler ;
2728import com .cleanroommc .modularui .api .drawable .IKey ;
2829import com .cleanroommc .modularui .api .widget .IWidget ;
2930import com .cleanroommc .modularui .api .widget .Interactable ;
3839import com .cleanroommc .modularui .value .sync .PanelSyncHandler ;
3940import com .cleanroommc .modularui .value .sync .PanelSyncManager ;
4041import com .cleanroommc .modularui .value .sync .StringSyncValue ;
42+ import com .cleanroommc .modularui .value .sync .SyncHandler ;
4143import com .cleanroommc .modularui .widgets .ButtonWidget ;
4244import com .cleanroommc .modularui .widgets .ListWidget ;
4345import com .cleanroommc .modularui .widgets .ToggleButton ;
44- import com .cleanroommc .modularui .widgets .layout .Column ;
46+ import com .cleanroommc .modularui .widgets .layout .Flow ;
4547import com .cleanroommc .modularui .widgets .layout .Row ;
4648import com .cleanroommc .modularui .widgets .textfield .TextFieldWidget ;
4749import org .jetbrains .annotations .NotNull ;
4850import org .jetbrains .annotations .Nullable ;
4951
5052import java .io .IOException ;
5153import java .util .ArrayList ;
52- import java .util .HashSet ;
5354import java .util .List ;
5455import java .util .Objects ;
55- import java .util .Set ;
5656import java .util .UUID ;
5757import java .util .regex .Pattern ;
5858
@@ -146,13 +146,13 @@ public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncMan
146146 .bindPlayerInventory ();
147147 }
148148
149- protected Column createWidgets (ModularPanel panel , PanelSyncManager syncManager ) {
149+ protected Flow createWidgets (ModularPanel panel , PanelSyncManager syncManager ) {
150150 var name = new StringSyncValue (this ::getColorStr , this ::updateColor );
151151
152152 var entrySelectorSH = createEntrySelector (panel );
153153 syncManager .syncValue ("entry_selector" , entrySelectorSH );
154154
155- return new Column ().coverChildrenHeight ().top (24 )
155+ return Flow . column ().coverChildrenHeight ().top (24 )
156156 .margin (7 , 0 ).widthRel (1f )
157157 .child (new Row ().marginBottom (2 )
158158 .coverChildrenHeight ()
@@ -171,18 +171,18 @@ protected Column createWidgets(ModularPanel panel, PanelSyncManager syncManager)
171171 .disableHoverBackground ()
172172 .addTooltipLine (IKey .lang ("cover.generic.ender.open_selector" ))
173173 .onMousePressed (i -> {
174- if (entrySelectorSH .isPanelOpen ()) {
175- entrySelectorSH .closePanel ();
176- } else {
177- entrySelectorSH .openPanel ();
178- }
179- Interactable .playButtonClickSound ();
174+ // if (entrySelectorSH.isPanelOpen()) {
175+ // entrySelectorSH.closePanel();
176+ // } else {
177+ // entrySelectorSH.openPanel();
178+ // }
179+ // Interactable.playButtonClickSound();
180180 return true ;
181181 })))
182182 .child (createIoRow ());
183183 }
184184
185- protected abstract PanelSyncHandler createEntrySelector (ModularPanel panel );
185+ protected abstract EntrySelectorSH createEntrySelector (ModularPanel panel );
186186
187187 protected abstract IWidget createEntrySlot ();
188188
@@ -217,7 +217,7 @@ protected IWidget createPrivateButton() {
217217 protected IWidget createIoRow () {
218218 var ioEnabled = new BooleanSyncValue (this ::isIoEnabled , this ::setIoEnabled );
219219
220- return new Row ().marginBottom (2 )
220+ return Flow . row ().marginBottom (2 )
221221 .coverChildrenHeight ()
222222 .child (new ToggleButton ()
223223 .value (ioEnabled )
@@ -291,20 +291,19 @@ public void writeToNBT(@NotNull NBTTagCompound nbt) {
291291 nbt .setInteger ("Frequency" , activeEntry .getColor ());
292292 }
293293
294- protected abstract class EntrySelectorSH extends PanelSyncHandler {
294+ protected abstract class EntrySelectorSH extends SyncHandler implements IPanelHandler {
295295
296- private static final int TRACK_SUBPANELS = 3 ;
296+ // private static final int TRACK_SUBPANELS = 3;
297297 private static final int DELETE_ENTRY = 1 ;
298298 private final EntryTypes <T > type ;
299299 private final ModularPanel mainPanel ;
300300 private static final String PANEL_NAME = "entry_selector" ;
301- private final Set <String > opened = new HashSet <>();
301+ // private final Set<String> opened = new HashSet<>();
302302 protected UUID playerUUID ;
303303
304304 protected EntrySelectorSH (ModularPanel mainPanel , EntryTypes <T > type ) {
305- super (mainPanel , EntrySelectorSH ::defaultPanel );
306- this .type = type ;
307305 this .mainPanel = mainPanel ;
306+ this .type = type ;
308307 }
309308
310309 @ Override
@@ -313,18 +312,33 @@ public void init(String key, PanelSyncManager syncManager) {
313312 this .playerUUID = syncManager .getPlayer ().getUniqueID ();
314313 }
315314
316- private static ModularPanel defaultPanel (PanelSyncManager syncManager , PanelSyncHandler syncHandler ) {
317- return GTGuis .createPopupPanel (PANEL_NAME , 168 , 112 );
318- }
319-
320315 public UUID getPlayerUUID () {
321316 return isPrivate ? playerUUID : null ;
322317 }
323318
324319 @ Override
320+ public void openPanel () {}
321+
322+ @ Override
323+ public void closePanel () {}
324+
325+ @ Override
326+ public void closePanelInternal () {}
327+
328+ @ Override
329+ public void closeSubPanels () {}
330+
331+ @ Override
332+ public void deleteCachedPanel () {}
333+
334+ @ Override
335+ public boolean isSubPanel () {
336+ return false ;
337+ }
338+
325339 public ModularPanel createUI (PanelSyncManager syncManager ) {
326340 List <String > names = new ArrayList <>(VirtualEnderRegistry .getEntryNames (getPlayerUUID (), type ));
327- return super . createUI ( syncManager )
341+ return GTGuis . createPopupPanel ( PANEL_NAME , 168 , 112 )
328342 .child (IKey .lang ("cover.generic.ender.known_channels" )
329343 .color (UI_TITLE_COLOR ).asWidget ()
330344 .top (6 )
@@ -345,7 +359,7 @@ protected IWidget createRow(String name, ModularPanel mainPanel, PanelSyncManage
345359 var entryDescriptionSH = new EntryDescriptionSH (mainPanel , key , entry );
346360 syncManager .syncValue (key , isPrivate ? 1 : 0 , entryDescriptionSH );
347361
348- return new Row ()
362+ return Flow . row ()
349363 .left (4 )
350364 .marginBottom (2 )
351365 .height (18 )
@@ -363,7 +377,7 @@ protected IWidget createRow(String name, ModularPanel mainPanel, PanelSyncManage
363377 .tooltipBuilder (tooltip -> {
364378 String desc = entry .getDescription ();
365379 if (!desc .isEmpty ())
366- tooltip .addLine (desc );
380+ tooltip .add (desc );
367381 })
368382 .width (64 )
369383 .height (16 )
@@ -374,12 +388,12 @@ protected IWidget createRow(String name, ModularPanel mainPanel, PanelSyncManage
374388 .addTooltipLine (IKey .lang ("cover.generic.ender.set_description.tooltip" ))
375389 .onMousePressed (i -> {
376390 // open entry settings
377- if (entryDescriptionSH .isPanelOpen ()) {
378- entryDescriptionSH .closePanel ();
379- } else {
380- entryDescriptionSH .openPanel ();
381- }
382- Interactable .playButtonClickSound ();
391+ // if (entryDescriptionSH.isPanelOpen()) {
392+ // entryDescriptionSH.closePanel();
393+ // } else {
394+ // entryDescriptionSH.openPanel();
395+ // }
396+ // Interactable.playButtonClickSound();
383397 return true ;
384398 }))
385399 .child (createSlotWidget (entry ))
@@ -399,69 +413,78 @@ protected IWidget createRow(String name, ModularPanel mainPanel, PanelSyncManage
399413 }));
400414 }
401415
402- @ Override
403- public void closePanel () {
404- var manager = getSyncManager ().getModularSyncManager ().getPanelSyncManager (PANEL_NAME );
405- for (var key : opened ) {
406- if (manager .getSyncHandler (key ) instanceof PanelSyncHandler psh ) {
407- psh .closePanel ();
408- }
409- }
410- super .closePanel ();
411- }
412-
413- @ Override
414- @ SuppressWarnings ("UnstableApiUsage" )
415- public void closePanelInternal () {
416- var manager = getSyncManager ().getModularSyncManager ().getPanelSyncManager (PANEL_NAME );
417- for (var key : opened ) {
418- if (manager .getSyncHandler (key ) instanceof PanelSyncHandler psh ) {
419- psh .closePanel ();
420- }
421- }
422- super .closePanelInternal ();
423- }
416+ // @Override
417+ // public void closePanel() {
418+ // var manager = getSyncManager().getModularSyncManager().getPanelSyncManager(PANEL_NAME);
419+ // for (var key : opened) {
420+ // if (manager.getSyncHandler(key) instanceof PanelSyncHandler psh) {
421+ // psh.closePanel();
422+ // }
423+ // }
424+ // super.closePanel();
425+ // }
426+
427+ // @Override
428+ // @SuppressWarnings("UnstableApiUsage")
429+ // public void closePanelInternal() {
430+ // var manager = getSyncManager().getModularSyncManager().getPanelSyncManager(PANEL_NAME);
431+ // for (var key : opened) {
432+ // if (manager.getSyncHandler(key) instanceof PanelSyncHandler psh) {
433+ // psh.closePanel();
434+ // }
435+ // }
436+ // super.closePanelInternal();
437+ // }
424438
425439 @ Override
426440 public void readOnClient (int i , PacketBuffer packetBuffer ) throws IOException {
427- if (i == TRACK_SUBPANELS ) {
428- handleTracking (packetBuffer );
429- }
430- super .readOnClient (i , packetBuffer );
441+ // if (i == TRACK_SUBPANELS) {
442+ // handleTracking(packetBuffer);
443+ // }
444+ // super.readOnClient(i, packetBuffer);
431445 }
432446
433447 @ Override
434448 public void readOnServer (int i , PacketBuffer packetBuffer ) throws IOException {
435- if (i == TRACK_SUBPANELS ) {
436- handleTracking (packetBuffer );
437- }
438- super .readOnServer (i , packetBuffer );
449+ // if (i == TRACK_SUBPANELS) {
450+ // handleTracking(packetBuffer);
451+ // }
452+ // super.readOnServer(i, packetBuffer);
439453 if (i == DELETE_ENTRY ) {
440454 UUID uuid = UUID .fromString (NetworkUtils .readStringSafe (packetBuffer ));
441455 String name = NetworkUtils .readStringSafe (packetBuffer );
442456 deleteEntry (uuid , name );
443457 }
444458 }
445459
446- private void handleTracking (PacketBuffer buffer ) {
447- boolean add = buffer .readBoolean ();
448- String key = NetworkUtils .readStringSafe (buffer );
449- if (key != null ) {
450- if (add ) opened .add (key );
451- else opened .remove (key );
452- }
453- }
460+ // private void handleTracking(PacketBuffer buffer) {
461+ // boolean add = buffer.readBoolean();
462+ // String key = NetworkUtils.readStringSafe(buffer);
463+ // if (key != null) {
464+ // if (add) opened.add(key);
465+ // else opened.remove(key);
466+ // }
467+ // }
454468
455- private class EntryDescriptionSH extends PanelSyncHandler {
469+ private static class EntryDescriptionSH extends SyncHandler implements IPanelHandler {
456470
457471 /**
458472 * Creates a PanelSyncHandler
459473 *
460474 * @param mainPanel the main panel of the current GUI
461475 */
462476 public EntryDescriptionSH (ModularPanel mainPanel , String key , VirtualEntry entry ) {
463- super (mainPanel , (syncManager , syncHandler ) -> defaultPanel (syncHandler , key , entry ));
477+ // super(mainPanel, (syncManager, syncHandler) -> defaultPanel(syncHandler, key, entry));
464478 }
479+ //
480+ // @Override
481+ // public boolean isSubPanel() {
482+ // return subPanel;
483+ // }
484+ //
485+ // public boolean isPanelOpen() {
486+ // return this.open;
487+ // }
465488
466489 private static ModularPanel defaultPanel (@ NotNull PanelSyncHandler syncHandler , String key ,
467490 VirtualEntry entry ) {
@@ -487,23 +510,43 @@ private static ModularPanel defaultPanel(@NotNull PanelSyncHandler syncHandler,
487510
488511 @ Override
489512 public void openPanel () {
490- opened .add (getKey ());
491- EntrySelectorSH .this .sync (3 , buffer -> {
492- buffer .writeBoolean (true );
493- NetworkUtils .writeStringSafe (buffer , getKey ());
494- });
495- super .openPanel ();
513+ // opened.add(getKey());
514+ // EntrySelectorSH.this.sync(3, buffer -> {
515+ // buffer.writeBoolean(true);
516+ // NetworkUtils.writeStringSafe(buffer, getKey());
517+ // });
518+ // super.openPanel();
496519 }
497520
498521 @ Override
499522 public void closePanel () {
500- opened .remove (getKey ());
501- EntrySelectorSH .this .sync (3 , buffer -> {
502- buffer .writeBoolean (false );
503- NetworkUtils .writeStringSafe (buffer , getKey ());
504- });
505- super .closePanel ();
523+ // opened.remove(getKey());
524+ // EntrySelectorSH.this.sync(3, buffer -> {
525+ // buffer.writeBoolean(false);
526+ // NetworkUtils.writeStringSafe(buffer, getKey());
527+ // });
528+ // super.closePanel();
506529 }
530+
531+ @ Override
532+ public void closeSubPanels () {}
533+
534+ @ Override
535+ public void closePanelInternal () {}
536+
537+ @ Override
538+ public void deleteCachedPanel () {}
539+
540+ @ Override
541+ public boolean isSubPanel () {
542+ return false ;
543+ }
544+
545+ @ Override
546+ public void readOnClient (int id , PacketBuffer buf ) throws IOException {}
547+
548+ @ Override
549+ public void readOnServer (int id , PacketBuffer buf ) throws IOException {}
507550 }
508551
509552 protected abstract IWidget createSlotWidget (T entry );
0 commit comments