ground markers: Add import/export menu option toggle

This commit is contained in:
Cyborger1
2021-02-28 16:47:08 -08:00
committed by Jordan Atwood
parent 2d5d490b50
commit c1b2017bb1
3 changed files with 35 additions and 3 deletions

View File

@@ -31,9 +31,12 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("groundMarker")
@ConfigGroup(GroundMarkerConfig.GROUND_MARKER_CONFIG_GROUP)
public interface GroundMarkerConfig extends Config
{
String GROUND_MARKER_CONFIG_GROUP = "groundMarker";
String SHOW_IMPORT_EXPORT_KEY_NAME = "showImportExport";
@Alpha
@ConfigItem(
keyName = "markerColor",
@@ -64,4 +67,14 @@ public interface GroundMarkerConfig extends Config
{
return false;
}
@ConfigItem(
keyName = SHOW_IMPORT_EXPORT_KEY_NAME,
name = "Show Import/Export options",
description = "Show the Import/Export options on the minimap right-click menu"
)
default boolean showImportExport()
{
return true;
}
}

View File

@@ -54,6 +54,7 @@ import net.runelite.api.events.MenuOptionClicked;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.game.chatbox.ChatboxPanelManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@@ -190,7 +191,10 @@ public class GroundMarkerPlugin extends Plugin
{
overlayManager.add(overlay);
overlayManager.add(minimapOverlay);
sharingManager.addMenuOptions();
if (config.showImportExport())
{
sharingManager.addImportExportMenuOptions();
}
loadPoints();
eventBus.register(sharingManager);
}
@@ -280,6 +284,21 @@ public class GroundMarkerPlugin extends Plugin
}
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals(GroundMarkerConfig.GROUND_MARKER_CONFIG_GROUP)
&& event.getKey().equals(GroundMarkerConfig.SHOW_IMPORT_EXPORT_KEY_NAME))
{
sharingManager.removeMenuOptions();
if (config.showImportExport())
{
sharingManager.addImportExportMenuOptions();
}
}
}
private void markTile(LocalPoint localPoint)
{
if (localPoint == null)

View File

@@ -79,7 +79,7 @@ class GroundMarkerSharingManager
this.gson = gson;
}
void addMenuOptions()
void addImportExportMenuOptions()
{
menuManager.addManagedCustomMenu(EXPORT_MARKERS_OPTION);
menuManager.addManagedCustomMenu(IMPORT_MARKERS_OPTION);