Merge pull request #541 from Sethtroll/addmultipleimages
Add Blast furnace plugin
This commit is contained in:
@@ -198,7 +198,31 @@ public enum Varbits
|
|||||||
* Nightmare Zone
|
* Nightmare Zone
|
||||||
*/
|
*/
|
||||||
NMZ_ABSORPTION(3956, 1067, 5, 14),
|
NMZ_ABSORPTION(3956, 1067, 5, 14),
|
||||||
NMZ_POINTS(3949, 1059, 0, 19);
|
NMZ_POINTS(3949, 1059, 0, 19),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blast Furnace
|
||||||
|
*/
|
||||||
|
BLAST_FURNACE_COPPER_ORE(959, 549, 16, 23),
|
||||||
|
BLAST_FURNACE_TIN_ORE(950, 547, 8, 15),
|
||||||
|
BLAST_FURNACE_IRON_ORE(951, 547, 16, 23),
|
||||||
|
BLAST_FURNACE_COAL(949, 547, 0, 7),
|
||||||
|
BLAST_FURNACE_MITHRIL_ORE(952, 547, 24, 31),
|
||||||
|
BLAST_FURNACE_ADAMANTITE_ORE(953, 548, 0, 7),
|
||||||
|
BLAST_FURNACE_RUNITE_ORE(954, 548, 8, 15),
|
||||||
|
BLAST_FURNACE_SILVER_ORE(955, 548, 24, 31),
|
||||||
|
BLAST_FURNACE_GOLD_ORE(955, 548, 16, 23),
|
||||||
|
|
||||||
|
BLAST_FURNACE_BRONZE_BAR(941, 545, 0, 7),
|
||||||
|
BLAST_FURNACE_IRON_BAR(942, 545, 8, 15),
|
||||||
|
BLAST_FURNACE_STEEL_BAR(943, 545, 16, 23),
|
||||||
|
BLAST_FURNACE_MITHRIL_BAR(944, 545, 24, 31),
|
||||||
|
BLAST_FURNACE_ADAMANTITE_BAR(945, 546, 0, 7),
|
||||||
|
BLAST_FURNACE_RUNITE_BAR(946, 546, 8, 15),
|
||||||
|
BLAST_FURNACE_SILVER_BAR(948, 546, 24, 31),
|
||||||
|
BLAST_FURNACE_GOLD_BAR(947, 546, 16, 23),
|
||||||
|
|
||||||
|
BLAST_FURNACE_COFFER(5357, 795, 1, 31);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* varbit id
|
* varbit id
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public class WidgetID
|
|||||||
public static final int EXPERIENCE_DROP_GROUP_ID = 122;
|
public static final int EXPERIENCE_DROP_GROUP_ID = 122;
|
||||||
public static final int PUZZLE_BOX_GROUP_ID = 306;
|
public static final int PUZZLE_BOX_GROUP_ID = 306;
|
||||||
public static final int NIGHTMARE_ZONE_GROUP_ID = 202;
|
public static final int NIGHTMARE_ZONE_GROUP_ID = 202;
|
||||||
|
public static final int BLAST_FURNACE_GROUP_ID = 474;
|
||||||
|
|
||||||
static class WorldMap
|
static class WorldMap
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -169,7 +169,9 @@ public enum WidgetInfo
|
|||||||
|
|
||||||
PUZZLE_BOX(WidgetID.PUZZLE_BOX_GROUP_ID, WidgetID.PuzzleBox.VISIBLE_BOX),
|
PUZZLE_BOX(WidgetID.PUZZLE_BOX_GROUP_ID, WidgetID.PuzzleBox.VISIBLE_BOX),
|
||||||
|
|
||||||
NIGHTMARE_ZONE(WidgetID.NIGHTMARE_ZONE_GROUP_ID, 1);
|
NIGHTMARE_ZONE(WidgetID.NIGHTMARE_ZONE_GROUP_ID, 1),
|
||||||
|
|
||||||
|
BLAST_FURNACE_COFFER(WidgetID.BLAST_FURNACE_GROUP_ID, 0);
|
||||||
|
|
||||||
private final int groupId;
|
private final int groupId;
|
||||||
private final int childId;
|
private final int childId;
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
|
||||||
|
* 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.blastfurnace;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.runelite.api.ItemID;
|
||||||
|
import net.runelite.api.Varbits;
|
||||||
|
|
||||||
|
public enum BarsOres
|
||||||
|
{
|
||||||
|
COPPER_ORE(Varbits.BLAST_FURNACE_COPPER_ORE, ItemID.COPPER_ORE),
|
||||||
|
TIN_ORE(Varbits.BLAST_FURNACE_TIN_ORE, ItemID.TIN_ORE),
|
||||||
|
IRON_ORE(Varbits.BLAST_FURNACE_IRON_ORE, ItemID.IRON_ORE),
|
||||||
|
COAL(Varbits.BLAST_FURNACE_COAL, ItemID.COAL),
|
||||||
|
MITHRIL_ORE(Varbits.BLAST_FURNACE_MITHRIL_ORE, ItemID.MITHRIL_ORE),
|
||||||
|
ADAMANTITE_ORE(Varbits.BLAST_FURNACE_ADAMANTITE_ORE, ItemID.ADAMANTITE_ORE),
|
||||||
|
RUNITE_ORE(Varbits.BLAST_FURNACE_RUNITE_ORE, ItemID.RUNITE_ORE),
|
||||||
|
SILVER_ORE(Varbits.BLAST_FURNACE_SILVER_ORE, ItemID.SILVER_ORE),
|
||||||
|
GOLD_ORE(Varbits.BLAST_FURNACE_GOLD_ORE, ItemID.GOLD_ORE),
|
||||||
|
BRONZE_BAR(Varbits.BLAST_FURNACE_BRONZE_BAR, ItemID.BRONZE_BAR),
|
||||||
|
IRON_BAR(Varbits.BLAST_FURNACE_IRON_BAR, ItemID.IRON_BAR),
|
||||||
|
STEEL_BAR(Varbits.BLAST_FURNACE_STEEL_BAR, ItemID.STEEL_BAR),
|
||||||
|
MITHRIL_BAR(Varbits.BLAST_FURNACE_MITHRIL_BAR, ItemID.MITHRIL_BAR),
|
||||||
|
ADAMANTITE_BAR(Varbits.BLAST_FURNACE_ADAMANTITE_BAR, ItemID.ADAMANTITE_BAR),
|
||||||
|
RUNITE_BAR(Varbits.BLAST_FURNACE_RUNITE_BAR, ItemID.RUNITE_BAR),
|
||||||
|
SILVER_BAR(Varbits.BLAST_FURNACE_SILVER_BAR, ItemID.SILVER_BAR),
|
||||||
|
GOLD_BAR(Varbits.BLAST_FURNACE_GOLD_BAR, ItemID.GOLD_BAR);
|
||||||
|
|
||||||
|
private static final Map<Varbits, BarsOres> VARBIT = new HashMap<>();
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
for (BarsOres s : values())
|
||||||
|
{
|
||||||
|
VARBIT.put(s.getVarbit(), s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Varbits varbit;
|
||||||
|
@Getter
|
||||||
|
private final int itemID;
|
||||||
|
|
||||||
|
BarsOres(Varbits varbit, int itemID)
|
||||||
|
{
|
||||||
|
this.varbit = varbit;
|
||||||
|
this.itemID = itemID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BarsOres getVarbit(Varbits varbit)
|
||||||
|
{
|
||||||
|
return VARBIT.get(varbit);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
|
||||||
|
* 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.blastfurnace;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import static net.runelite.api.Varbits.BLAST_FURNACE_COFFER;
|
||||||
|
import net.runelite.api.widgets.Widget;
|
||||||
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
|
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||||
|
|
||||||
|
class BlastFurnaceCofferOverlay extends Overlay
|
||||||
|
{
|
||||||
|
private final Client client;
|
||||||
|
private final BlastFurnacePlugin plugin;
|
||||||
|
private final BlastFurnaceConfig config;
|
||||||
|
private final PanelComponent panelComponent = new PanelComponent();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
BlastFurnaceCofferOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
|
||||||
|
{
|
||||||
|
setPosition(OverlayPosition.TOP_LEFT);
|
||||||
|
this.client = client;
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension render(Graphics2D graphics, Point parent)
|
||||||
|
{
|
||||||
|
if (plugin.getConveyorBelt() == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget sack = client.getWidget(WidgetInfo.BLAST_FURNACE_COFFER);
|
||||||
|
|
||||||
|
panelComponent.getLines().clear();
|
||||||
|
|
||||||
|
if (sack != null)
|
||||||
|
{
|
||||||
|
sack.setHidden(true);
|
||||||
|
|
||||||
|
panelComponent.getLines().add(new PanelComponent.Line(
|
||||||
|
"Coffer:",
|
||||||
|
NumberFormat.getInstance().format(client.getSetting(BLAST_FURNACE_COFFER)) + " gp"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return panelComponent.render(graphics, parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
|
||||||
|
* 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.blastfurnace;
|
||||||
|
|
||||||
|
import net.runelite.client.config.Config;
|
||||||
|
import net.runelite.client.config.ConfigGroup;
|
||||||
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
|
||||||
|
@ConfigGroup(
|
||||||
|
keyName = "blastfurnace",
|
||||||
|
name = "Blast Furnace",
|
||||||
|
description = "Configuration for the Blast furnace plugin"
|
||||||
|
)
|
||||||
|
public interface BlastFurnaceConfig extends Config
|
||||||
|
{
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "enabled",
|
||||||
|
name = "Enable",
|
||||||
|
description = "Configures whether to enable the blast furnace plugin"
|
||||||
|
)
|
||||||
|
default boolean enabled()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "showConveyorBelt",
|
||||||
|
name = "Show Conveyor belt clickbox",
|
||||||
|
description = "Configures whether or not the clickbox for the conveyor belt is displayed"
|
||||||
|
)
|
||||||
|
default boolean showConveyorBelt()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
|
||||||
|
* 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.blastfurnace;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.client.game.ItemManager;
|
||||||
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
|
import net.runelite.client.ui.overlay.components.ImagePanelComponent;
|
||||||
|
|
||||||
|
class BlastFurnaceOverlay extends Overlay
|
||||||
|
{
|
||||||
|
private final Client client;
|
||||||
|
private final BlastFurnacePlugin plugin;
|
||||||
|
private final BlastFurnaceConfig config;
|
||||||
|
private final ImagePanelComponent imagePanelComponent = new ImagePanelComponent();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ItemManager itemManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
BlastFurnaceOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
|
||||||
|
{
|
||||||
|
setPosition(OverlayPosition.TOP_LEFT);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.client = client;
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension render(Graphics2D graphics, Point parent)
|
||||||
|
{
|
||||||
|
if (!config.enabled() || plugin.getConveyorBelt() == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
imagePanelComponent.getImages().clear();
|
||||||
|
|
||||||
|
for (BarsOres varbit : BarsOres.values())
|
||||||
|
{
|
||||||
|
int amount = client.getSetting(varbit.getVarbit());
|
||||||
|
|
||||||
|
if (amount == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
imagePanelComponent.getImages().add(getImage(varbit.getItemID(), amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
return imagePanelComponent.render(graphics, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BufferedImage getImage(int itemID, int amount)
|
||||||
|
{
|
||||||
|
BufferedImage image = itemManager.getImage(itemID, amount, true);
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
|
||||||
|
* 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.blastfurnace;
|
||||||
|
|
||||||
|
import com.google.common.eventbus.Subscribe;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.runelite.api.GameObject;
|
||||||
|
import net.runelite.api.GameState;
|
||||||
|
import static net.runelite.api.ObjectID.CONVEYOR_BELT;
|
||||||
|
import net.runelite.api.events.GameObjectDespawned;
|
||||||
|
import net.runelite.api.events.GameObjectSpawned;
|
||||||
|
import net.runelite.api.events.GameStateChanged;
|
||||||
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.plugins.Plugin;
|
||||||
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
|
||||||
|
@PluginDescriptor(
|
||||||
|
name = "Blast Furnace"
|
||||||
|
)
|
||||||
|
public class BlastFurnacePlugin extends Plugin
|
||||||
|
{
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
|
private GameObject conveyorBelt;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BlastFurnaceOverlay overlay;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BlastFurnaceCofferOverlay cofferOverlay;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ConveyorBeltOverlay conveyorBeltOverlay;
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
BlastFurnaceConfig provideConfig(ConfigManager configManager)
|
||||||
|
{
|
||||||
|
return configManager.getConfig(BlastFurnaceConfig.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Overlay> getOverlays()
|
||||||
|
{
|
||||||
|
return Arrays.asList(overlay, cofferOverlay, conveyorBeltOverlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onGameObjectSpawn(GameObjectSpawned event)
|
||||||
|
{
|
||||||
|
GameObject gameObject = event.getGameObject();
|
||||||
|
if (gameObject.getId() == CONVEYOR_BELT)
|
||||||
|
{
|
||||||
|
conveyorBelt = gameObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onGameObjectDespawn(GameObjectDespawned event)
|
||||||
|
{
|
||||||
|
GameObject gameObject = event.getGameObject();
|
||||||
|
if (gameObject.getId() == CONVEYOR_BELT)
|
||||||
|
{
|
||||||
|
conveyorBelt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onGameStateChanged(GameStateChanged event)
|
||||||
|
{
|
||||||
|
if (event.getGameState() == GameState.LOADING)
|
||||||
|
{
|
||||||
|
conveyorBelt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Seth <Sethtroll3@gmail.com>
|
||||||
|
* 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.blastfurnace;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.geom.Area;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.GameObject;
|
||||||
|
import net.runelite.api.Point;
|
||||||
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
|
|
||||||
|
class ConveyorBeltOverlay extends Overlay
|
||||||
|
{
|
||||||
|
private static final int MAX_DISTANCE = 2350;
|
||||||
|
|
||||||
|
private final Client client;
|
||||||
|
private final BlastFurnacePlugin plugin;
|
||||||
|
private final BlastFurnaceConfig config;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ConveyorBeltOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
|
||||||
|
{
|
||||||
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
|
this.client = client;
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension render(Graphics2D graphics, java.awt.Point parent)
|
||||||
|
{
|
||||||
|
if (!config.enabled() || !config.showConveyorBelt() || plugin.getConveyorBelt() == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point localLocation = client.getLocalPlayer().getLocalLocation();
|
||||||
|
Point mousePosition = client.getMouseCanvasPosition();
|
||||||
|
|
||||||
|
GameObject object = plugin.getConveyorBelt();
|
||||||
|
|
||||||
|
Point location = object.getLocalLocation();
|
||||||
|
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
|
||||||
|
{
|
||||||
|
Area objectClickbox = object.getClickbox();
|
||||||
|
if (objectClickbox != null)
|
||||||
|
{
|
||||||
|
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
|
||||||
|
{
|
||||||
|
graphics.setColor(Color.RED.darker());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
graphics.setColor(Color.RED);
|
||||||
|
}
|
||||||
|
graphics.draw(objectClickbox);
|
||||||
|
graphics.setColor(new Color(0xFF, 0, 0, 20));
|
||||||
|
graphics.fill(objectClickbox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -70,7 +70,7 @@ public class FightCaveOverlay extends Overlay
|
|||||||
BufferedImage prayerImage = getPrayerImage(attack);
|
BufferedImage prayerImage = getPrayerImage(attack);
|
||||||
ImagePanelComponent imagePanelComponent = new ImagePanelComponent();
|
ImagePanelComponent imagePanelComponent = new ImagePanelComponent();
|
||||||
imagePanelComponent.setTitle("Switch!");
|
imagePanelComponent.setTitle("Switch!");
|
||||||
imagePanelComponent.setImage(prayerImage);
|
imagePanelComponent.getImages().add(prayerImage);
|
||||||
return imagePanelComponent.render(graphics, parent);
|
return imagePanelComponent.render(graphics, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,6 @@
|
|||||||
package net.runelite.client.ui.overlay.components;
|
package net.runelite.client.ui.overlay.components;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import lombok.Setter;
|
|
||||||
import net.runelite.client.ui.overlay.RenderableEntity;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
@@ -36,6 +32,12 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import net.runelite.client.ui.overlay.RenderableEntity;
|
||||||
|
|
||||||
public class ImagePanelComponent implements RenderableEntity
|
public class ImagePanelComponent implements RenderableEntity
|
||||||
{
|
{
|
||||||
@@ -54,8 +56,8 @@ public class ImagePanelComponent implements RenderableEntity
|
|||||||
@Setter
|
@Setter
|
||||||
private Color backgroundColor = BackgroundComponent.DEFAULT_BACKGROUND_COLOR;
|
private Color backgroundColor = BackgroundComponent.DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
@Setter
|
@Getter
|
||||||
private BufferedImage image;
|
private final List<BufferedImage> images = new ArrayList<>();
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private Point position = new Point();
|
private Point position = new Point();
|
||||||
@@ -65,18 +67,35 @@ public class ImagePanelComponent implements RenderableEntity
|
|||||||
{
|
{
|
||||||
final Dimension dimension = new Dimension();
|
final Dimension dimension = new Dimension();
|
||||||
final FontMetrics metrics = graphics.getFontMetrics();
|
final FontMetrics metrics = graphics.getFontMetrics();
|
||||||
int height = TOP_BORDER + (Strings.isNullOrEmpty(title) ? 0 : metrics.getHeight())
|
|
||||||
+ SEPARATOR + image.getHeight() + BOTTOM_BORDER;
|
//Determine max height and width of images
|
||||||
int width = Math.max(Strings.isNullOrEmpty(title) ? 0 : metrics.stringWidth(title), image.getWidth()) + SIDE_BORDER * 2;
|
int maxImageHeight = 0;
|
||||||
|
int imageWidth = 0;
|
||||||
|
for (final BufferedImage image : images)
|
||||||
|
{
|
||||||
|
if (image.getHeight() > maxImageHeight)
|
||||||
|
{
|
||||||
|
maxImageHeight = image.getHeight();
|
||||||
|
}
|
||||||
|
imageWidth += image.getWidth() + SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int height = TOP_BORDER + (Strings.isNullOrEmpty(title) ? 0 : metrics.getHeight() + SEPARATOR)
|
||||||
|
+ maxImageHeight + BOTTOM_BORDER;
|
||||||
|
int width = Math.max(Strings.isNullOrEmpty(title) ? 0 : metrics.stringWidth(title), imageWidth) + SIDE_BORDER * 2;
|
||||||
dimension.setSize(width, height);
|
dimension.setSize(width, height);
|
||||||
|
|
||||||
if (dimension.height == 0)
|
if (dimension.height == TOP_BORDER + BOTTOM_BORDER)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate panel dimensions
|
int y = position.y + TOP_BORDER;
|
||||||
int y = position.y + TOP_BORDER + metrics.getHeight();
|
if (!Strings.isNullOrEmpty(title))
|
||||||
|
{
|
||||||
|
// Calculate panel dimensions
|
||||||
|
y += metrics.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
// Render background
|
// Render background
|
||||||
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
||||||
@@ -95,8 +114,13 @@ public class ImagePanelComponent implements RenderableEntity
|
|||||||
y += SEPARATOR;
|
y += SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render image
|
// Render all images
|
||||||
graphics.drawImage(image, position.x + (width - image.getWidth()) / 2, y, null);
|
int imageOffsetX = ((width - imageWidth) / 2) - (SEPARATOR / 2);
|
||||||
|
for (final BufferedImage image : images)
|
||||||
|
{
|
||||||
|
graphics.drawImage(image, imageOffsetX + ((width / images.size()) - image.getWidth()) / 2, y, null);
|
||||||
|
imageOffsetX += image.getWidth() + SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
return dimension;
|
return dimension;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user