From 4f8fa15ebf4f254c122c570e823394b14f5cc5f1 Mon Sep 17 00:00:00 2001 From: xKylee <48519776+xKylee@users.noreply.github.com> Date: Sat, 30 Nov 2019 16:29:09 +0000 Subject: [PATCH] custom client resizing custom client resizing ability to set custom client profiles --- .../CustomClientResizingConfig.java | 9 + .../CustomClientResizingPlugin.java | 203 ++++++++++ .../CustomClientResizingProfile.java | 18 + .../ui/CustomClientResizingPluginPanel.java | 136 +++++++ .../ui/CustomClientResizingProfilePanel.java | 349 ++++++++++++++++++ .../java/net/runelite/client/ui/ClientUI.java | 12 +- .../net/runelite/client/ui/PluginPanel.java | 2 +- .../plugins/customclientresizing/add_icon.png | Bin 0 -> 121 bytes .../customclientresizing/cancel_icon.png | Bin 0 -> 299 bytes .../customclientresizing/confirm_icon.png | Bin 0 -> 273 bytes .../customclientresizing/delete_icon.png | Bin 0 -> 208 bytes .../customclientresizing/invisible_icon.png | Bin 0 -> 398 bytes .../customclientresizing/panel_icon.png | Bin 0 -> 358 bytes .../customclientresizing/visible_icon.png | Bin 0 -> 312 bytes 14 files changed, 724 insertions(+), 5 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingConfig.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingPlugin.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingProfile.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/ui/CustomClientResizingPluginPanel.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/ui/CustomClientResizingProfilePanel.java create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/add_icon.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/cancel_icon.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/confirm_icon.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/delete_icon.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/invisible_icon.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/panel_icon.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/visible_icon.png diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingConfig.java new file mode 100644 index 0000000000..16c243ce7d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingConfig.java @@ -0,0 +1,9 @@ +package net.runelite.client.plugins.customclientresizing; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; + +@ConfigGroup(CustomClientResizingPlugin.CONFIG_GROUP) +public interface CustomClientResizingConfig extends Config +{ +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingPlugin.java new file mode 100644 index 0000000000..1a1b77c6e1 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingPlugin.java @@ -0,0 +1,203 @@ +package net.runelite.client.plugins.customclientresizing; + +import com.google.common.base.Strings; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.google.inject.Provides; +import java.awt.Dimension; +import java.awt.Rectangle; +import java.awt.image.BufferedImage; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import javax.inject.Inject; +import lombok.Getter; +import net.runelite.api.Client; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.PluginType; +import net.runelite.client.plugins.customclientresizing.ui.CustomClientResizingPluginPanel; +import net.runelite.client.ui.ClientToolbar; +import net.runelite.client.ui.ClientUI; +import net.runelite.client.ui.ContainableFrame; +import net.runelite.client.ui.NavigationButton; +import net.runelite.client.util.ImageUtil; + +@PluginDescriptor( + name = "Custom Client Resizing", + description = "Resize the window to saved profiles", + tags = {"resize", "window", "position", "layout", "manage"}, + type = PluginType.UTILITY, + enabledByDefault = false +) +public class CustomClientResizingPlugin extends Plugin +{ + public static final String CONFIG_GROUP = "customclientresizing"; + private static final String CONFIG_KEY = "customclientresizingprofiles"; + private static final String PLUGIN_NAME = "Custom Client Resizing"; + private static final String ICON_FILE = "panel_icon.png"; + + @Getter + private final List customclientresizingProfiles = new ArrayList<>(); + + @Inject + private Client client; + + @Inject + private CustomClientResizingConfig config; + + @Inject + private ClientToolbar clientToolbar; + + @Inject + private ConfigManager configManager; + + @Inject + private ClientUI clientUi; + + private CustomClientResizingPluginPanel pluginPanel; + private NavigationButton navigationButton; + private NavigationButton titleBarButton; + + @Provides + CustomClientResizingConfig provideConfig(ConfigManager configManager) + { + return configManager.getConfig(CustomClientResizingConfig.class); + } + + @Override + protected void startUp() + { + loadConfig(configManager.getConfiguration(CONFIG_GROUP, CONFIG_KEY)).forEach(customclientresizingProfiles::add); + + pluginPanel = injector.getInstance(CustomClientResizingPluginPanel.class); + pluginPanel.rebuild(); + + final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), ICON_FILE); + + navigationButton = NavigationButton.builder() + .tooltip(PLUGIN_NAME) + .icon(icon) + .priority(1) + .panel(pluginPanel) + .build(); + + titleBarButton = NavigationButton.builder() + .tab(false) + .tooltip("Set resize profile") + .icon(icon) + .onClick(() -> + { + ContainableFrame frame = clientUi.getFrame(); + + + CustomClientResizingProfile active = customclientresizingProfiles.stream().filter(CustomClientResizingProfile::isVisible).findFirst().orElse(null); + if (active == null) + { + return; + } + Rectangle bounds = new Rectangle( + active.getPosition().width, active.getPosition().height, + active.getSize().width, active.getSize().height + ); + if (!clientUi.isSidebarOpen()) + { + bounds.width -= clientUi.getPluginToolbar().getWidth(); + } + if (clientUi.getPluginPanel() == null) + { + bounds.width -= pluginPanel.getWrappedPanel().getPreferredSize().width; + } + frame.setBounds(bounds); + frame.revalidateMinimumSize(); + }) + .build(); + + clientToolbar.addNavigation(titleBarButton); + clientToolbar.addNavigation(navigationButton); + } + + @Override + protected void shutDown() + { + customclientresizingProfiles.clear(); + clientToolbar.removeNavigation(navigationButton); + clientToolbar.removeNavigation(titleBarButton); + + pluginPanel = null; + navigationButton = null; + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (customclientresizingProfiles.isEmpty() && event.getGroup().equals(CONFIG_GROUP) && event.getKey().equals(CONFIG_KEY)) + { + loadConfig(event.getNewValue()).forEach(customclientresizingProfiles::add); + } + + + } + + public void updateConfig() + { + if (customclientresizingProfiles.isEmpty()) + { + configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_KEY); + return; + } + + final Gson gson = new Gson(); + final String json = gson + .toJson(customclientresizingProfiles); + configManager.setConfiguration(CONFIG_GROUP, CONFIG_KEY, json); + } + + private Stream loadConfig(String json) + { + if (Strings.isNullOrEmpty(json)) + { + return Stream.empty(); + } + + final Gson gson = new Gson(); + final List customclientresizingProfileData = gson.fromJson(json, new TypeToken>() + { + }.getType()); + + return customclientresizingProfileData.stream(); + } + + public void addProfile() + { + ContainableFrame frame = clientUi.getFrame(); + CustomClientResizingProfile profile = new CustomClientResizingProfile( + Instant.now().toEpochMilli(), + "Profile " + (customclientresizingProfiles.size() + 1), + new Dimension(frame.getX(), frame.getY()), + new Dimension(frame.getWidth(), frame.getHeight()), + false + ); + + customclientresizingProfiles.add(profile); + pluginPanel.updateProfiles(); + updateConfig(); + } + + public void deleteProfile(final CustomClientResizingProfile profile) + { + customclientresizingProfiles.remove(profile); + pluginPanel.updateProfiles(); + updateConfig(); + } + + public void disableProfiles() + { + customclientresizingProfiles.forEach(e -> e.setVisible(false)); + pluginPanel.updateProfiles(); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingProfile.java b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingProfile.java new file mode 100644 index 0000000000..a6052f7b12 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/CustomClientResizingProfile.java @@ -0,0 +1,18 @@ +package net.runelite.client.plugins.customclientresizing; + +import java.awt.Dimension; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CustomClientResizingProfile +{ + private long id; + private String name; + private Dimension position; + private Dimension size; + private boolean visible; +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/ui/CustomClientResizingPluginPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/ui/CustomClientResizingPluginPanel.java new file mode 100644 index 0000000000..8ece7ef7a8 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/ui/CustomClientResizingPluginPanel.java @@ -0,0 +1,136 @@ +package net.runelite.client.plugins.customclientresizing.ui; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import javax.swing.Box; +import javax.swing.ImageIcon; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import lombok.Getter; +import net.runelite.client.plugins.customclientresizing.CustomClientResizingPlugin; +import net.runelite.client.plugins.customclientresizing.CustomClientResizingProfile; +import net.runelite.client.ui.ColorScheme; +import net.runelite.client.ui.PluginPanel; +import net.runelite.client.util.ImageUtil; + +@Singleton +public class CustomClientResizingPluginPanel extends PluginPanel +{ + private static final ImageIcon ADD_ICON; + private static final ImageIcon ADD_HOVER_ICON; + + private static final Color DEFAULT_BORDER_COLOR = Color.GREEN; + private static final Color DEFAULT_FILL_COLOR = new Color(0, 255, 0, 0); + + private static final int DEFAULT_BORDER_THICKNESS = 3; + + static + { + final BufferedImage addIcon = ImageUtil.getResourceStreamFromClass(CustomClientResizingPlugin.class, "add_icon.png"); + ADD_ICON = new ImageIcon(addIcon); + ADD_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(addIcon, 0.53f)); + } + + private final JLabel addMarker = new JLabel(ADD_ICON); + private final JLabel title = new JLabel(); + private final JPanel markerView = new JPanel(new GridBagLayout()); + @Inject + private CustomClientResizingPlugin plugin; + @Getter + private Color selectedColor = DEFAULT_BORDER_COLOR; + @Getter + private Color selectedFillColor = DEFAULT_FILL_COLOR; + @Getter + private int selectedBorderThickness = DEFAULT_BORDER_THICKNESS; + + public void init() + { + setLayout(new BorderLayout()); + setBorder(new EmptyBorder(10, 10, 10, 10)); + + JPanel northPanel = new JPanel(new BorderLayout()); + northPanel.setBorder(new EmptyBorder(1, 0, 10, 0)); + + title.setText("Resize Profiles"); + title.setForeground(Color.WHITE); + + northPanel.add(title, BorderLayout.WEST); + northPanel.add(addMarker, BorderLayout.EAST); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.setBackground(ColorScheme.DARK_GRAY_COLOR); + + markerView.setBackground(ColorScheme.DARK_GRAY_COLOR); + + updateProfiles(); + + addMarker.setToolTipText("Add new screen marker"); + addMarker.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + plugin.addProfile(); + } + + @Override + public void mouseEntered(MouseEvent mouseEvent) + { + addMarker.setIcon(ADD_HOVER_ICON); + } + + @Override + public void mouseExited(MouseEvent mouseEvent) + { + addMarker.setIcon(ADD_ICON); + } + }); + + centerPanel.add(markerView, BorderLayout.CENTER); + + add(northPanel, BorderLayout.NORTH); + add(centerPanel, BorderLayout.CENTER); + } + + public void rebuild() + { + removeAll(); + repaint(); + revalidate(); + init(); + } + + public void updateProfiles() + { + markerView.removeAll(); + + GridBagConstraints constraints = new GridBagConstraints(); + constraints.fill = GridBagConstraints.HORIZONTAL; + constraints.weightx = 1; + constraints.gridx = 0; + constraints.gridy = 0; + + for (final CustomClientResizingProfile marker : plugin.getCustomclientresizingProfiles()) + { + markerView.add(new CustomClientResizingProfilePanel(plugin, marker), constraints); + constraints.gridy++; + + markerView.add(Box.createRigidArea(new Dimension(0, 10)), constraints); + constraints.gridy++; + } + + repaint(); + revalidate(); + } + +} + diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/ui/CustomClientResizingProfilePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/ui/CustomClientResizingProfilePanel.java new file mode 100644 index 0000000000..475aee9d88 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customclientresizing/ui/CustomClientResizingProfilePanel.java @@ -0,0 +1,349 @@ +package net.runelite.client.plugins.customclientresizing.ui; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSpinner; +import javax.swing.SpinnerModel; +import javax.swing.SpinnerNumberModel; +import javax.swing.border.Border; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.event.ChangeListener; +import net.runelite.client.plugins.customclientresizing.CustomClientResizingPlugin; +import net.runelite.client.plugins.customclientresizing.CustomClientResizingProfile; +import net.runelite.client.ui.ColorScheme; +import net.runelite.client.ui.FontManager; +import net.runelite.client.ui.components.FlatTextField; +import net.runelite.client.util.ImageUtil; + +public class CustomClientResizingProfilePanel extends JPanel +{ + private static final int DEFAULT_FILL_OPACITY = 75; + + private static final Border NAME_BOTTOM_BORDER = new CompoundBorder( + BorderFactory.createMatteBorder(0, 0, 1, 0, ColorScheme.DARK_GRAY_COLOR), + BorderFactory.createLineBorder(ColorScheme.DARKER_GRAY_COLOR)); + + private static final ImageIcon VISIBLE_ICON; + private static final ImageIcon VISIBLE_HOVER_ICON; + private static final ImageIcon INVISIBLE_ICON; + private static final ImageIcon INVISIBLE_HOVER_ICON; + private static final ImageIcon DELETE_ICON; + private static final ImageIcon DELETE_HOVER_ICON; + + static + { + final BufferedImage visibleImg = ImageUtil.getResourceStreamFromClass(CustomClientResizingPlugin.class, "visible_icon.png"); + VISIBLE_ICON = new ImageIcon(visibleImg); + VISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(visibleImg, -100)); + + final BufferedImage invisibleImg = ImageUtil.getResourceStreamFromClass(CustomClientResizingPlugin.class, "invisible_icon.png"); + INVISIBLE_ICON = new ImageIcon(invisibleImg); + INVISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(invisibleImg, -100)); + + final BufferedImage deleteImg = ImageUtil.getResourceStreamFromClass(CustomClientResizingPlugin.class, "delete_icon.png"); + DELETE_ICON = new ImageIcon(deleteImg); + DELETE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(deleteImg, -100)); + } + + private final CustomClientResizingPlugin plugin; + private final CustomClientResizingProfile profile; + private final JLabel visibilityLabel = new JLabel(); + private final JLabel deleteLabel = new JLabel(); + private final FlatTextField nameInput = new FlatTextField(); + private final JLabel save = new JLabel("Save"); + private final JLabel cancel = new JLabel("Cancel"); + private final JLabel rename = new JLabel("Rename"); + + CustomClientResizingProfilePanel(CustomClientResizingPlugin plugin, CustomClientResizingProfile profile) + { + this.plugin = plugin; + this.profile = profile; + + setLayout(new BorderLayout()); + setBackground(ColorScheme.DARKER_GRAY_COLOR); + + JPanel nameWrapper = new JPanel(new BorderLayout()); + nameWrapper.setBackground(ColorScheme.DARKER_GRAY_COLOR); + nameWrapper.setBorder(NAME_BOTTOM_BORDER); + + JPanel nameActions = new JPanel(new BorderLayout(3, 0)); + nameActions.setBorder(new EmptyBorder(0, 0, 0, 8)); + nameActions.setBackground(ColorScheme.DARKER_GRAY_COLOR); + + save.setVisible(false); + save.setFont(FontManager.getRunescapeSmallFont()); + save.setForeground(ColorScheme.PROGRESS_COMPLETE_COLOR); + save.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + profile.setName(nameInput.getText()); + plugin.updateConfig(); + + nameInput.setEditable(false); + updateNameActions(false); + requestFocusInWindow(); + } + + @Override + public void mouseEntered(MouseEvent mouseEvent) + { + save.setForeground(ColorScheme.PROGRESS_COMPLETE_COLOR.darker()); + } + + @Override + public void mouseExited(MouseEvent mouseEvent) + { + save.setForeground(ColorScheme.PROGRESS_COMPLETE_COLOR); + } + }); + + cancel.setVisible(false); + cancel.setFont(FontManager.getRunescapeSmallFont()); + cancel.setForeground(ColorScheme.PROGRESS_ERROR_COLOR); + cancel.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + nameInput.setEditable(false); + nameInput.setText(profile.getName()); + updateNameActions(false); + requestFocusInWindow(); + } + + @Override + public void mouseEntered(MouseEvent mouseEvent) + { + cancel.setForeground(ColorScheme.PROGRESS_ERROR_COLOR.darker()); + } + + @Override + public void mouseExited(MouseEvent mouseEvent) + { + cancel.setForeground(ColorScheme.PROGRESS_ERROR_COLOR); + } + }); + + rename.setFont(FontManager.getRunescapeSmallFont()); + rename.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker()); + rename.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + nameInput.setEditable(true); + updateNameActions(true); + } + + @Override + public void mouseEntered(MouseEvent mouseEvent) + { + rename.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker().darker()); + } + + @Override + public void mouseExited(MouseEvent mouseEvent) + { + rename.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker()); + } + }); + + nameActions.add(save, BorderLayout.EAST); + nameActions.add(cancel, BorderLayout.WEST); + nameActions.add(rename, BorderLayout.CENTER); + + nameInput.setText(profile.getName()); + nameInput.setBorder(null); + nameInput.setEditable(false); + nameInput.setBackground(ColorScheme.DARKER_GRAY_COLOR); + nameInput.setPreferredSize(new Dimension(0, 24)); + nameInput.getTextField().setForeground(Color.WHITE); + nameInput.getTextField().setBorder(new EmptyBorder(0, 8, 0, 0)); + + nameWrapper.add(nameInput, BorderLayout.CENTER); + nameWrapper.add(nameActions, BorderLayout.EAST); + + JPanel bottomContainer = new JPanel(new BorderLayout()); + bottomContainer.setBorder(new EmptyBorder(8, 0, 8, 0)); + bottomContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR); + + JPanel leftActions = new JPanel(new BorderLayout()); + leftActions.setBackground(ColorScheme.DARKER_GRAY_COLOR); + + JPanel positionPanel = createPositionPanel(profile.getPosition().width, profile.getPosition().height); + JPanel sizePanel = createSizePanel(profile.getSize().width, profile.getSize().height); + + leftActions.add(positionPanel, BorderLayout.NORTH); + leftActions.add(sizePanel, BorderLayout.SOUTH); + + JPanel rightActions = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 0)); + rightActions.setBackground(ColorScheme.DARKER_GRAY_COLOR); + + visibilityLabel.setToolTipText(profile.isVisible() ? "Deactivated" : "Activate resize profile"); + visibilityLabel.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + if (profile.isVisible()) + { + return; + } + plugin.disableProfiles(); + profile.setVisible(true); + updateVisibility(); + } + + @Override + public void mouseEntered(MouseEvent mouseEvent) + { + visibilityLabel.setIcon(profile.isVisible() ? VISIBLE_HOVER_ICON : INVISIBLE_HOVER_ICON); + } + + @Override + public void mouseExited(MouseEvent mouseEvent) + { + updateVisibility(); + } + }); + + deleteLabel.setIcon(DELETE_ICON); + deleteLabel.setToolTipText("Delete resize profile"); + deleteLabel.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + int confirm = JOptionPane.showConfirmDialog(CustomClientResizingProfilePanel.this, + "Are you sure you want to permanently delete this resize profile?", + "Warning", JOptionPane.OK_CANCEL_OPTION); + + if (confirm == 0) + { + plugin.deleteProfile(profile); + } + } + + @Override + public void mouseEntered(MouseEvent mouseEvent) + { + deleteLabel.setIcon(DELETE_HOVER_ICON); + } + + @Override + public void mouseExited(MouseEvent mouseEvent) + { + deleteLabel.setIcon(DELETE_ICON); + } + }); + + rightActions.add(visibilityLabel); + rightActions.add(deleteLabel); + + bottomContainer.add(leftActions, BorderLayout.WEST); + bottomContainer.add(rightActions, BorderLayout.EAST); + + add(nameWrapper, BorderLayout.NORTH); + add(bottomContainer, BorderLayout.CENTER); + + updateVisibility(); + } + + private JPanel createPositionPanel(int width, int height) + { + JPanel dimensionPanel = new JPanel(); + dimensionPanel.setLayout(new BorderLayout()); + + JSpinner widthSpinner = createSpinner(width); + JSpinner heightSpinner = createSpinner(height); + + ChangeListener listener = e -> updatePosition((Integer) widthSpinner.getValue(), (Integer) heightSpinner.getValue()); + + widthSpinner.addChangeListener(listener); + heightSpinner.addChangeListener(listener); + + dimensionPanel.add(widthSpinner, BorderLayout.WEST); + dimensionPanel.add(new JLabel(" x "), BorderLayout.CENTER); + dimensionPanel.add(heightSpinner, BorderLayout.EAST); + + return dimensionPanel; + } + + private JPanel createSizePanel(int width, int height) + { + JPanel dimensionPanel = new JPanel(); + dimensionPanel.setLayout(new BorderLayout()); + + JSpinner widthSpinner = createSpinner(width); + JSpinner heightSpinner = createSpinner(height); + + ChangeListener listener = e -> updateSize((Integer) widthSpinner.getValue(), (Integer) heightSpinner.getValue()); + + widthSpinner.addChangeListener(listener); + heightSpinner.addChangeListener(listener); + + dimensionPanel.add(widthSpinner, BorderLayout.WEST); + dimensionPanel.add(new JLabel(" x "), BorderLayout.CENTER); + dimensionPanel.add(heightSpinner, BorderLayout.EAST); + + return dimensionPanel; + } + + private JSpinner createSpinner(int value) + { + SpinnerModel model = new SpinnerNumberModel(value, Integer.MIN_VALUE, Integer.MAX_VALUE, 1); + JSpinner spinner = new JSpinner(model); + Component editor = spinner.getEditor(); + JFormattedTextField spinnerTextField = ((JSpinner.DefaultEditor) editor).getTextField(); + spinnerTextField.setColumns(4); + + return spinner; + } + + private void updateNameActions(boolean saveAndCancel) + { + save.setVisible(saveAndCancel); + cancel.setVisible(saveAndCancel); + rename.setVisible(!saveAndCancel); + + if (saveAndCancel) + { + nameInput.getTextField().requestFocusInWindow(); + nameInput.getTextField().selectAll(); + } + } + + private void updateVisibility() + { + visibilityLabel.setIcon(profile.isVisible() ? VISIBLE_ICON : INVISIBLE_ICON); + plugin.updateConfig(); + } + + private void updatePosition(int x, int y) + { + profile.setPosition(new Dimension(x, y)); + plugin.updateConfig(); + } + + private void updateSize(int w, int h) + { + profile.setSize(new Dimension(w, h)); + plugin.updateConfig(); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index 2244ce5b62..e68855b68e 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -119,6 +119,14 @@ public class ClientUI @Getter private TrayIcon trayIcon; + @Getter + public static ContainableFrame frame; + @Getter + public static ClientPluginToolbar pluginToolbar; + @Getter + private boolean sidebarOpen; + @Getter + public static PluginPanel pluginPanel; private final RuneLiteConfig config; private final KeyManager keyManager; @@ -131,14 +139,10 @@ public class ClientUI private boolean withTitleBar; private BufferedImage sidebarOpenIcon; private BufferedImage sidebarClosedIcon; - public static ContainableFrame frame; private JPanel navContainer; - public static PluginPanel pluginPanel; - public static ClientPluginToolbar pluginToolbar; private ClientTitleToolbar titleToolbar; private JButton currentButton; private NavigationButton currentNavButton; - private boolean sidebarOpen; private JPanel container; private NavigationButton sidebarNavigationButton; private JButton sidebarNavigationJButton; diff --git a/runelite-client/src/main/java/net/runelite/client/ui/PluginPanel.java b/runelite-client/src/main/java/net/runelite/client/ui/PluginPanel.java index 73e9a92f8b..bea0f1f9fc 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/PluginPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/PluginPanel.java @@ -44,7 +44,7 @@ public abstract class PluginPanel extends JPanel @Getter(AccessLevel.PROTECTED) private final JScrollPane scrollPane; - @Getter(AccessLevel.PACKAGE) + @Getter(AccessLevel.PUBLIC) private final JPanel wrappedPanel; protected PluginPanel() diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/add_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/add_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..343c3dce0cd5c460af2627b8a4acb39f68cc86fe GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xa&H|6fVg?3oVGw3ym^DWND5&k} z;uxYaF*)G?V@#UG-}0FczsOIw5!T~$N>Is2IU-(UvQbc7qSu|vgo)vBE7!_33zDV) PwJ~_Q`njxgN@xNAsURJG literal 0 HcmV?d00001 diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/cancel_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/cancel_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3f4915d0419444a5b2307d16643b4a5e36cf62f9 GIT binary patch literal 299 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xa&H|6fVg?3oVGw3ym^DWND0tV? z#W6%<;@pddUPl51*dFM==Q$)Mz3qk*cfNp9({zDtQ70Daq-+${ey`AW=b+m()o2d6 zgNM?>l0SJo)P8=}oaevD?oBqwW%Fk5`)~5OEVZ&NJxBOmVRKpdv~I~Q4&B-|DmeuQ zSa-?vMTy(8=LB8;?jBNc-0DM7!?eb07lTb}>vfERuN!XdTF#g4uk{=e4e6hER(3JY@|k;E?cvG% uC&Da&s~4rW9&b@wcGc44kZIh;zidH`nZ;AQ*G>R>l)=;0&t;ucLK6UgICIPZ literal 0 HcmV?d00001 diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/confirm_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/confirm_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..0a60af087207955948e2325d125a60673398e0eb GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|&H|6fVg?3oVGw3ym^DWND0tY@ z#WBR9_wEHlFJ?y(wg>r>ACx|0`IhMxDZp|$a`_c&j*XkI_;qWjG{5uwX0dEjrBl!B z9fni?-K{=cV^jApw#f5%fNV$1BS!OP<_Vq(qG9`YX-qiokT-kR-h0xooNjDh9CJxB z&P?#d-9UxUdMvAAf?CyW%u9c7W3@aebXf1n=S9Ua34-#wCLGmcVe`FvuCPBa;jw9o z%!v%~Ls2((F0uC6cqnsCeBl@2Ppr2N+pWjvID*%(O= zoHOH+%$A!vUV7YJL9eH#(DuZ-)8-7xH4NKKodQA3cx2$%HFAyg`*4{BtGcSLuHvKI sFS)HQ`)lH2{EYi25{P>A{1bKa2l6jn4>Jw?FaQ7m07*qoM6N<$f+x_c<^TWy literal 0 HcmV?d00001 diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/panel_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/panel_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..01e73df506a73877ef77a2114b7f1ccb45619922 GIT binary patch literal 358 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJtM=93Yk-ZimrLOIEGmGubpVfb;v=$^>Rl?h9Za9BgHi$Yg|24ljdHNu4I?i_V&(C zNL{(qOzaj%=lk`{N}ejxvK1$No}It%DfCD6kwu=v^~t-W{U$AOFKk$?UY+ssi{u=` zS;hR^LI-)(ZaFloXH4o3xxIN|w4w5gm!ex-e+nd;anMqYlF_rMh`SLLLKq{AbM@ksW7VZo0<+7Xk wPV#MW4eZ;{di|P8sHj~*!BO7-VvZkJ@(mosOtwu?0Q!)@)78&qol`;+0OZqv%m4rY literal 0 HcmV?d00001 diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/visible_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/customclientresizing/visible_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..5c4232c808f46b2fee47a5ac1f5045792118165b GIT binary patch literal 312 zcmV-80muG{P)PbXFR49?Xk)cilQ4mGX+kl~|Xh=}~0+3ZeLIV6k(}WZpztPGP zWQzlVKp+q#grIQz0O1R&Rv@UN2--ae-tHFG_o|u6N#@QSSgOKe;|51GfG=Ko4)Y4_ zp0~~{m3s0Yxlr}nk!{-vNAFlIkahhYMk_*gN%?OfG2*YfLX z-W3sa>^O|Ky;%R7)Um0HO6}( literal 0 HcmV?d00001