@@ -1218,6 +1218,27 @@ private void refreshDatapackStructureVisibility() {
12181218 SeedMapMinimapManager .refreshIfOpenWithGeneratorFlags (this .generatorFlags );
12191219 }
12201220
1221+ private void toggleMinimapFromOptions () {
1222+ if (SeedMapMinimapManager .isVisible ()) {
1223+ SeedMapMinimapManager .hide ();
1224+ this .pushOptionsInfo ("Minimap disabled." );
1225+ return ;
1226+ }
1227+ LocalPlayer player = this .minecraft .player ;
1228+ if (player == null ) {
1229+ this .pushOptionsError ("Cannot enable minimap without a player." );
1230+ return ;
1231+ }
1232+ SeedMapMinimapManager .show (this .seed , this .dimension , this .version , this .generatorFlags , player .blockPosition ());
1233+ this .pushOptionsInfo ("Minimap enabled." );
1234+ }
1235+
1236+ private void updateMinimapSetting (Runnable updater ) {
1237+ updater .run ();
1238+ Configs .save ();
1239+ SeedMapMinimapManager .refreshIfOpenWithGeneratorFlags (this .generatorFlags );
1240+ }
1241+
12211242 private int enabledDatapackStructureCount () {
12221243 List <DatapackStructureManager .CustomStructureSet > sets = DatapackStructureManager .get (this .worldIdentifier );
12231244 if (sets == null || sets .isEmpty ()) {
@@ -5562,6 +5583,108 @@ public void extractRenderState(GuiGraphicsExtractor context, int mouseX, int mou
55625583 }
55635584 }
55645585
5586+ private final class MinimapSettingsScreen extends Screen {
5587+ private final Screen previous ;
5588+ private @ Nullable Button rotateButton ;
5589+ private @ Nullable LabeledSlider offsetXSlider ;
5590+ private @ Nullable LabeledSlider offsetYSlider ;
5591+ private @ Nullable LabeledSlider widthSlider ;
5592+ private @ Nullable LabeledSlider heightSlider ;
5593+ private @ Nullable LabeledSlider zoomSlider ;
5594+ private @ Nullable LabeledSlider iconScaleSlider ;
5595+ private @ Nullable LabeledSlider opacitySlider ;
5596+
5597+ private MinimapSettingsScreen (Screen previous ) {
5598+ super (Component .literal ("Minimap Settings" ));
5599+ this .previous = previous ;
5600+ }
5601+
5602+ @ Override
5603+ protected void init () {
5604+ super .init ();
5605+ int panelWidth = 320 ;
5606+ int left = this .width / 2 - panelWidth / 2 ;
5607+ int top = this .height / 2 - 98 ;
5608+ int gap = 4 ;
5609+ int rowHeight = 20 ;
5610+ int halfWidth = (panelWidth - gap ) / 2 ;
5611+ int y = top ;
5612+
5613+ this .rotateButton = this .addRenderableWidget (Button .builder (this .rotateLabel (), button -> {
5614+ SeedMapScreen .this .updateMinimapSetting (() -> Configs .SeedMapMinimapRotateWithPlayer = !Configs .SeedMapMinimapRotateWithPlayer );
5615+ button .setMessage (this .rotateLabel ());
5616+ }).bounds (left , y , panelWidth , rowHeight ).build ());
5617+ y += rowHeight + gap ;
5618+
5619+ this .offsetXSlider = this .addRenderableWidget (new LabeledSlider (left , y , halfWidth , rowHeight , "Offset X" , 0.0D , 512.0D ,
5620+ () -> Configs .SeedMapMinimapOffsetX ,
5621+ next -> SeedMapScreen .this .updateMinimapSetting (() -> Configs .SeedMapMinimapOffsetX = (int ) Math .round (Math .clamp (next , 0.0D , 512.0D ))),
5622+ value -> Integer .toString ((int ) Math .round (value ))));
5623+ this .offsetYSlider = this .addRenderableWidget (new LabeledSlider (left + halfWidth + gap , y , halfWidth , rowHeight , "Offset Y" , 0.0D , 512.0D ,
5624+ () -> Configs .SeedMapMinimapOffsetY ,
5625+ next -> SeedMapScreen .this .updateMinimapSetting (() -> Configs .SeedMapMinimapOffsetY = (int ) Math .round (Math .clamp (next , 0.0D , 512.0D ))),
5626+ value -> Integer .toString ((int ) Math .round (value ))));
5627+ y += rowHeight + gap ;
5628+
5629+ this .widthSlider = this .addRenderableWidget (new LabeledSlider (left , y , halfWidth , rowHeight , "Width" , 64.0D , 512.0D ,
5630+ () -> Configs .SeedMapMinimapWidth ,
5631+ next -> SeedMapScreen .this .updateMinimapSetting (() -> Configs .SeedMapMinimapWidth = (int ) Math .round (Math .clamp (next , 64.0D , 512.0D ))),
5632+ value -> Integer .toString ((int ) Math .round (value ))));
5633+ this .heightSlider = this .addRenderableWidget (new LabeledSlider (left + halfWidth + gap , y , halfWidth , rowHeight , "Height" , 64.0D , 512.0D ,
5634+ () -> Configs .SeedMapMinimapHeight ,
5635+ next -> SeedMapScreen .this .updateMinimapSetting (() -> Configs .SeedMapMinimapHeight = (int ) Math .round (Math .clamp (next , 64.0D , 512.0D ))),
5636+ value -> Integer .toString ((int ) Math .round (value ))));
5637+ y += rowHeight + gap ;
5638+
5639+ this .zoomSlider = this .addRenderableWidget (new LabeledSlider (left , y , panelWidth , rowHeight , "Zoom" , Configs .SeedMapMinPixelsPerBiome , 16.0D ,
5640+ () -> Configs .SeedMapMinimapPixelsPerBiome ,
5641+ next -> SeedMapScreen .this .updateMinimapSetting (() -> Configs .SeedMapMinimapPixelsPerBiome = sanitizePixelsPerBiome (next , Configs .SeedMapMinPixelsPerBiome )),
5642+ value -> String .format (Locale .ROOT , "%.2f" , value )));
5643+ y += rowHeight + gap ;
5644+
5645+ this .iconScaleSlider = this .addRenderableWidget (new LabeledSlider (left , y , halfWidth , rowHeight , "Icon Scale" , 0.25D , 4.0D ,
5646+ () -> Configs .SeedMapMinimapIconScale ,
5647+ next -> SeedMapScreen .this .updateMinimapSetting (() -> Configs .SeedMapMinimapIconScale = Math .clamp (next , 0.25D , 4.0D )),
5648+ value -> String .format (Locale .ROOT , "%.2f" , value )));
5649+ this .opacitySlider = this .addRenderableWidget (new LabeledSlider (left + halfWidth + gap , y , halfWidth , rowHeight , "Opacity" , 0.0D , 1.0D ,
5650+ () -> Configs .SeedMapMinimapOpacity ,
5651+ next -> SeedMapScreen .this .updateMinimapSetting (() -> Configs .SeedMapMinimapOpacity = Math .clamp (next , 0.0D , 1.0D )),
5652+ value -> String .format (Locale .ROOT , "%.2f" , value )));
5653+ y += rowHeight + 16 ;
5654+
5655+ this .addRenderableWidget (Button .builder (Component .literal ("Done" ), button -> this .onClose ())
5656+ .bounds (this .width / 2 - 80 , y , 160 , rowHeight ).build ());
5657+ }
5658+
5659+ private Component rotateLabel () {
5660+ return Component .literal ("Rotate With Player: " + (Configs .SeedMapMinimapRotateWithPlayer ? "ON" : "OFF" ));
5661+ }
5662+
5663+ private void syncSliderValues () {
5664+ if (this .offsetXSlider != null ) this .offsetXSlider .syncFromGetter ();
5665+ if (this .offsetYSlider != null ) this .offsetYSlider .syncFromGetter ();
5666+ if (this .widthSlider != null ) this .widthSlider .syncFromGetter ();
5667+ if (this .heightSlider != null ) this .heightSlider .syncFromGetter ();
5668+ if (this .zoomSlider != null ) this .zoomSlider .syncFromGetter ();
5669+ if (this .iconScaleSlider != null ) this .iconScaleSlider .syncFromGetter ();
5670+ if (this .opacitySlider != null ) this .opacitySlider .syncFromGetter ();
5671+ }
5672+
5673+ @ Override
5674+ public void onClose () {
5675+ this .minecraft .setScreen (this .previous instanceof OptionsScreen ? new OptionsScreen () : this .previous );
5676+ }
5677+
5678+ @ Override
5679+ public void extractRenderState (GuiGraphicsExtractor context , int mouseX , int mouseY , float delta ) {
5680+ if (this .rotateButton != null ) this .rotateButton .setMessage (this .rotateLabel ());
5681+ this .syncSliderValues ();
5682+ context .fill (0 , 0 , this .width , this .height , 0xAA000000 );
5683+ context .centeredText (this .font , this .title , this .width / 2 , this .height / 2 - 118 , 0xFFFFFFFF );
5684+ super .extractRenderState (context , mouseX , mouseY , delta );
5685+ }
5686+ }
5687+
55655688 private final class KeybindsScreen extends Screen {
55665689 private final Screen previous ;
55675690 private final java .util .List <KeybindRow > rows = new java .util .ArrayList <>();
@@ -5745,6 +5868,8 @@ private final class KeybindRow {
57455868 }
57465869
57475870 private final class OptionsScreen extends Screen {
5871+ private @ Nullable Button minimapToggleButton ;
5872+
57485873 private OptionsScreen () {
57495874 super (Component .literal ("SeedMapper Options" ));
57505875 }
@@ -5884,6 +6009,16 @@ protected void init() {
58846009 .build ());
58856010 y += rowHeight + sectionGapLarge ;
58866011
6012+ this .minimapToggleButton = this .addRenderableWidget (Button .builder (this .minimapToggleLabel (), button -> {
6013+ SeedMapScreen .this .toggleMinimapFromOptions ();
6014+ button .setMessage (this .minimapToggleLabel ());
6015+ }).bounds (left , y , halfWidth , rowHeight ).build ());
6016+ this .addRenderableWidget (Button .builder (Component .literal ("Minimap Settings" ), button ->
6017+ this .minecraft .setScreen (new MinimapSettingsScreen (this )))
6018+ .bounds (left + halfWidth + gap , y , halfWidth , rowHeight )
6019+ .build ());
6020+ y += rowHeight + gap ;
6021+
58876022 this .addRenderableWidget (Button .builder (Component .literal ("Keybinds" ), button ->
58886023 this .minecraft .setScreen (new KeybindsScreen (this )))
58896024 .bounds (left , y , halfWidth , rowHeight )
@@ -5895,12 +6030,10 @@ protected void init() {
58956030 y += rowHeight + sectionGapLarge ;
58966031
58976032 this .addRenderableWidget (Button .builder (Component .literal ("Export JSON" ), button -> SeedMapScreen .this .exportVisibleStructures ())
5898- .bounds (stackedLeft , y , stackedWidth , rowHeight )
6033+ .bounds (left , y , halfWidth , rowHeight )
58996034 .build ());
5900- y += rowHeight + gap ;
5901-
59026035 this .addRenderableWidget (Button .builder (Component .literal ("Export Xaero" ), button -> SeedMapScreen .this .exportVisibleStructuresToXaero ())
5903- .bounds (stackedLeft , y , stackedWidth , rowHeight )
6036+ .bounds (left + halfWidth + gap , y , halfWidth , rowHeight )
59046037 .build ());
59056038 y += rowHeight + gap ;
59066039
@@ -5949,6 +6082,10 @@ private Component espProfileLabel() {
59496082 return Component .literal ("ESP Settings" );
59506083 }
59516084
6085+ private Component minimapToggleLabel () {
6086+ return Component .literal ("Minimap: " + (SeedMapMinimapManager .isVisible () ? "ON" : "OFF" ));
6087+ }
6088+
59526089 private Component datapackStructuresLabel () {
59536090 return Component .literal ("Datapack Structures: " + (Configs .ShowDatapackStructures ? "ON" : "OFF" ));
59546091 }
@@ -5960,6 +6097,7 @@ public void onClose() {
59606097
59616098 @ Override
59626099 public void extractRenderState (GuiGraphicsExtractor context , int mouseX , int mouseY , float delta ) {
6100+ if (this .minimapToggleButton != null ) this .minimapToggleButton .setMessage (this .minimapToggleLabel ());
59636101 context .fill (0 , 0 , this .width , this .height , 0xAA000000 );
59646102 context .centeredText (this .font , this .title , this .width / 2 , 6 , 0xFFFFFFFF );
59656103 if (!SeedMapScreen .this .optionsStatusEntries .isEmpty ()) {
@@ -6058,10 +6196,16 @@ boolean mouseClicked(MouseButtonEvent event) {
60586196 @ Override
60596197 public void onClose () {
60606198 super .onClose ();
6199+ this .disposeMapResources (true );
6200+ }
6201+
6202+ protected void disposeMapResources (boolean saveConfig ) {
60616203 this .biomeTileCache .values ().forEach (Tile ::close );
60626204 this .slimeChunkTileCache .values ().forEach (Tile ::close );
6063- this .seedMapExecutor .close (this .arena ::close );
6064- Configs .save ();
6205+ this .seedMapExecutor .close (this .arena ::close );
6206+ if (saveConfig ) {
6207+ Configs .save ();
6208+ }
60656209 }
60666210
60676211 class FeatureWidget {
0 commit comments