Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2020-05-21 13:34:48 +02:00
13 changed files with 330 additions and 194 deletions

View File

@@ -24,12 +24,14 @@
*/
package net.runelite.client.config;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import net.runelite.api.Constants;
import net.runelite.client.Notifier;
import net.runelite.client.ui.ContainableFrame;
import net.runelite.client.ui.overlay.components.ComponentConstants;
@ConfigGroup(RuneLiteConfig.GROUP_NAME)
public interface RuneLiteConfig extends Config
@@ -348,11 +350,24 @@ public interface RuneLiteConfig extends Config
return true;
}
@ConfigItem(
keyName = "overlayBackgroundColor",
name = "Overlay Color",
description = "Configures the background color of infoboxes and overlays",
position = 27,
titleSection = "overlayTitle"
)
@Alpha
default Color overlayBackgroundColor()
{
return ComponentConstants.STANDARD_BACKGROUND_COLOR;
}
@ConfigTitleSection(
keyName = "infoboxTitle",
name = "Infoboxes",
description = "",
position = 27
position = 28
)
default Title infoboxTitle()
{
@@ -363,7 +378,7 @@ public interface RuneLiteConfig extends Config
keyName = "infoBoxVertical",
name = "Display infoboxes vertically",
description = "Toggles the infoboxes to display vertically",
position = 28,
position = 29,
titleSection = "infoboxTitle"
)
default boolean infoBoxVertical()

View File

@@ -47,6 +47,7 @@ import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.events.OverlayMenuClicked;
import net.runelite.client.events.PluginChanged;
@@ -104,15 +105,28 @@ public class OverlayManager
private final ConfigManager configManager;
private final EventBus eventBus;
private final RuneLiteConfig runeLiteConfig;
@Inject
private OverlayManager(final ConfigManager configManager, final EventBus eventBus)
private OverlayManager(final ConfigManager configManager, final EventBus eventBus, final RuneLiteConfig runeLiteConfig)
{
this.configManager = configManager;
this.eventBus = eventBus;
this.runeLiteConfig = runeLiteConfig;
eventBus.subscribe(PluginChanged.class, this, this::onPluginChanged);
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
}
public void onConfigChanged(final ConfigChanged event)
{
if (!RuneLiteConfig.GROUP_NAME.equals(event.getGroup()) || !"overlayBackgroundColor".equals(event.getKey()))
{
return;
}
overlays.forEach(this::updateOverlayConfig);
}
private void onPluginChanged(final PluginChanged event)
@@ -169,12 +183,15 @@ public class OverlayManager
// Add is always true
overlays.add(overlay);
loadOverlay(overlay);
updateOverlayConfig(overlay);
// WidgetItemOverlays have a reference to the overlay manager in order to get the WidgetItems
// for each frame.
if (overlay instanceof WidgetItemOverlay)
{
((WidgetItemOverlay) overlay).setOverlayManager(this);
}
rebuildOverlayLayers();
return true;
}
@@ -302,6 +319,15 @@ public class OverlayManager
overlay.setPreferredPosition(position);
}
private void updateOverlayConfig(final Overlay overlay)
{
if (overlay instanceof OverlayPanel)
{
// Update preferred color for overlay panels based on configuration
((OverlayPanel) overlay).setPreferredColor(runeLiteConfig.overlayBackgroundColor());
}
}
private void saveOverlayLocation(final Overlay overlay)
{
final String key = overlay.getName() + OVERLAY_CONFIG_PREFERRED_LOCATION;

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.ui.overlay;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import lombok.Getter;
@@ -49,6 +50,11 @@ public abstract class OverlayPanel extends Overlay
*/
private boolean dynamicFont = false;
/**
* Preferred color used for panel component background
*/
private Color preferredColor = null;
protected OverlayPanel()
{
super();
@@ -83,6 +89,13 @@ public abstract class OverlayPanel extends Overlay
}
}
final Color oldBackgroundColor = panelComponent.getBackgroundColor();
if (getPreferredColor() != null && ComponentConstants.STANDARD_BACKGROUND_COLOR.equals(oldBackgroundColor))
{
panelComponent.setBackgroundColor(getPreferredColor());
}
final Dimension dimension = panelComponent.render(graphics);
if (clearChildren)
@@ -91,6 +104,7 @@ public abstract class OverlayPanel extends Overlay
}
panelComponent.setPreferredSize(oldSize);
panelComponent.setBackgroundColor(oldBackgroundColor);
return dimension;
}
}

View File

@@ -31,7 +31,6 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import lombok.Getter;
import lombok.Setter;
import net.runelite.client.ui.overlay.components.table.TableComponent;
@@ -49,7 +48,7 @@ public class PanelComponent implements LayoutableRenderableEntity
private Dimension preferredSize = new Dimension(ComponentConstants.STANDARD_WIDTH, 0);
@Setter
@Nullable
@Getter
private Color backgroundColor = ComponentConstants.STANDARD_BACKGROUND_COLOR;
@Getter

View File

@@ -111,6 +111,7 @@ public class InfoBoxOverlay extends OverlayPanel
infoBoxComponent.setImage(box.getScaledImage());
infoBoxComponent.setTooltip(box.getTooltip());
infoBoxComponent.setPreferredSize(new Dimension(config.infoBoxSize(), config.infoBoxSize()));
infoBoxComponent.setBackgroundColor(config.overlayBackgroundColor());
panelComponent.getChildren().add(infoBoxComponent);
}