Skip to content

Commit

Permalink
Merge remote-tracking branch 'runelite/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Owain94 committed Feb 9, 2020
2 parents c729ef3 + 45c5df3 commit a7a8eb9
Show file tree
Hide file tree
Showing 13 changed files with 503 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private Collection<WidgetItem> getBankItems(Client client)
Rectangle bounds = child.getBounds();
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
// Index is set to 0 because the widget's index does not correlate to the order in the bank
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), 0, bounds, child, false));
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), 0, bounds, child, null));
}
}
return widgetItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private Collection<WidgetItem> getDialogs(Client client)
// set bounds to same size as default inventory
Rectangle bounds = child.getBounds();
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
widgetItems.add(new WidgetItem(child.getId(), child.getItemQuantity(), i - 1, bounds, child, false));
widgetItems.add(new WidgetItem(child.getId(), child.getItemQuantity(), i - 1, bounds, child, null));
}
}
return widgetItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ private Collection<WidgetItem> getInventoryItems(Client client)
}
// set bounds to same size as default inventory
Rectangle bounds = child.getBounds();
bounds.setBounds(bounds.x + dragOffsetX, bounds.y + dragOffsetY, 32, 32);
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i, bounds, child, isDragged));
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
Rectangle dragBounds = child.getBounds();
dragBounds.setBounds(bounds.x + dragOffsetX, bounds.y + dragOffsetY, 32, 32);
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i, bounds, child, dragBounds));
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private Collection<WidgetItem> getShopItems(Client client)
// set bounds to same size as default inventory
Rectangle bounds = child.getBounds();
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i - 1, bounds, child, false)); // todo: maybe this shouldnt just be "false"
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i - 1, bounds, child, null)); // todo: maybe this shouldnt just be "false"
}
}
return widgetItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public Set<HotColdLocation> signal(@Nonnull final WorldPoint worldPoint, @Nonnul
* @see WorldPoint#distanceTo2D
*/
@VisibleForTesting
private static boolean isFirstPointCloserRect(final WorldPoint firstPoint, final WorldPoint secondPoint, final Rectangle rect)
static boolean isFirstPointCloserRect(final WorldPoint firstPoint, final WorldPoint secondPoint, final Rectangle rect)
{
final WorldPoint nePoint = new WorldPoint((rect.x + rect.width), (rect.y + rect.height), 0);

Expand Down Expand Up @@ -163,7 +163,7 @@ private static boolean isFirstPointCloserRect(final WorldPoint firstPoint, final
* @see WorldPoint#distanceTo2D
*/
@VisibleForTesting
private static boolean isFirstPointCloser(final WorldPoint firstPoint, final WorldPoint secondPoint, final WorldPoint worldPoint)
static boolean isFirstPointCloser(final WorldPoint firstPoint, final WorldPoint secondPoint, final WorldPoint worldPoint)
{
return firstPoint.distanceTo2D(worldPoint) < secondPoint.distanceTo2D(worldPoint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
package net.runelite.client.plugins.customcursor;

import java.awt.image.BufferedImage;
import javax.annotation.Nullable;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.client.util.ImageUtil;

@Getter(AccessLevel.PUBLIC)
public enum CustomCursor
{
RS3_GOLD("RS3 Gold", "cursor-rs3-gold.png"),
Expand All @@ -42,12 +44,19 @@ public enum CustomCursor
MOUSE("Mouse", "cursor-mouse.png"),
SARADOMIN_GODSWORD("Saradomin Godsword", "cursor-saradomin-godsword.png"),
ZAMORAK_GODSWORD("Zamorak Godsword", "cursor-zamorak-godsword.png"),
SKILL_SPECS("Skill Specs", "cursor-skill-specs.png");
SKILL_SPECS("Skill Specs", "cursor-skill-specs.png"),
CUSTOM_IMAGE("Custom Image");

private final String name;
@Getter(AccessLevel.PUBLIC)
@Nullable
private final BufferedImage cursorImage;

CustomCursor(String name)
{
this.name = name;
this.cursorImage = null;
}

CustomCursor(final String name, final String icon)
{
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
package net.runelite.client.plugins.customcursor;

import com.google.inject.Provides;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.sound.sampled.AudioInputStream;
Expand All @@ -35,6 +38,7 @@
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLite;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
Expand All @@ -53,6 +57,8 @@
@Singleton
public class CustomCursorPlugin extends Plugin
{
private static final File CUSTOM_IMAGE_FILE = new File(RuneLite.RUNELITE_DIR, "cursor.png");

@Inject
private ClientUI clientUI;

Expand Down Expand Up @@ -125,6 +131,34 @@ private void updateCursor()
skillSpecsRage.start();
}
}
else if (selectedCursor == CustomCursor.CUSTOM_IMAGE)
{
if (CUSTOM_IMAGE_FILE.exists())
{
try
{
BufferedImage image;
synchronized (ImageIO.class)
{
image = ImageIO.read(CUSTOM_IMAGE_FILE);
}
clientUI.setCursor(image, selectedCursor.getName());
}
catch (Exception e)
{
log.error("error setting custom cursor", e);
clientUI.resetCursor();
}
}
else
{
clientUI.resetCursor();
}
return;
}

assert selectedCursor.getCursorImage() != null;
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.getName());

clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2019, Jordan Atwood <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.cluescrolls.clues.hotcold;

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

public class BeginnerHotColdLocationTest
{
private static final Set<HotColdLocation> BEGINNER_HOT_COLD_LOCATIONS = Arrays.stream(HotColdLocation.values())
.filter(HotColdLocation::isBeginnerClue)
.collect(Collectors.toSet());
private static final int EXPECTED_DIMENSION_SIZE = 7;

@Test
public void beginnerHotColdLocationAreaTest()
{

for (final HotColdLocation location : BEGINNER_HOT_COLD_LOCATIONS)
{
assertEquals(EXPECTED_DIMENSION_SIZE, location.getRect().height);
assertEquals(EXPECTED_DIMENSION_SIZE, location.getRect().width);
}
}
}
Loading

0 comments on commit a7a8eb9

Please sign in to comment.