openrune: finish login, questhelper works

This commit is contained in:
therealunull
2020-12-13 15:59:05 -05:00
parent b54ff7f7db
commit 06fd8e4802
12 changed files with 107 additions and 50 deletions

View File

@@ -28,6 +28,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.annotation.Nullable;
import net.runelite.http.api.RuneLiteAPI;
import okhttp3.HttpUrl;
public class RuneLiteProperties
@@ -144,7 +145,7 @@ public class RuneLiteProperties
public static HttpUrl getPluginHubBase()
{
String version = System.getProperty(PLUGINHUB_VERSION, properties.getProperty(PLUGINHUB_VERSION));
return HttpUrl.parse(properties.get(PLUGINHUB_BASE) + "/" + version);
return HttpUrl.parse(properties.get(PLUGINHUB_BASE) + "/" + RuneLiteAPI.getVersion());
}
public static String getImgurClientId()

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.callback;
import com.google.inject.Injector;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -39,22 +40,27 @@ import java.awt.image.VolatileImage;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.BufferProvider;
import net.runelite.api.Client;
import net.runelite.api.Entity;
import net.runelite.api.MainBufferProvider;
import net.runelite.api.NullItemID;
import net.runelite.api.RenderOverview;
import net.runelite.api.Skill;
import net.runelite.api.WorldMapManager;
import net.runelite.api.events.BeforeMenuRender;
import net.runelite.api.events.BeforeRender;
import net.runelite.api.events.FakeXpDrop;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.hooks.Callbacks;
import net.runelite.api.hooks.DrawCallbacks;
import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP_VIEW;
import net.runelite.api.widgets.WidgetItem;
import net.runelite.client.Notifier;
import net.runelite.client.RuneLite;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
@@ -84,8 +90,8 @@ public class Hooks implements Callbacks
private static final GameTick GAME_TICK = new GameTick();
private static final BeforeRender BEFORE_RENDER = new BeforeRender();
@Inject
private Client client;
private static final Injector injector = RuneLite.getInjector();
private static final Client client = injector.getInstance(Client.class);
@Inject
private OverlayRenderer renderer;
@@ -535,4 +541,43 @@ public class Hooks implements Callbacks
);
eventBus.post(fakeXpDrop);
}
public static void clearColorBuffer(int x, int y, int width, int height, int color)
{
BufferProvider bp = client.getBufferProvider();
int canvasWidth = bp.getWidth();
int[] pixels = bp.getPixels();
int pixelPos = y * canvasWidth + x;
int pixelJump = canvasWidth - width;
for (int cy = y; cy < y + height; cy++)
{
for (int cx = x; cx < x + width; cx++)
{
pixels[pixelPos++] = 0;
}
pixelPos += pixelJump;
}
}
public static void renderDraw(Entity entity, int orientation, int pitchSin, int pitchCos, int yawSin, int yawCos, int x, int y, int z, long hash)
{
DrawCallbacks drawCallbacks = client.getDrawCallbacks();
if (drawCallbacks != null)
{
drawCallbacks.draw(entity, orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash);
}
else
{
entity.draw(orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash);
}
}
public static boolean drawMenu()
{
BeforeMenuRender event = new BeforeMenuRender();
client.getCallbacks().post(event);
return event.isConsumed();
}
}

View File

@@ -67,12 +67,13 @@ public class ExternalPluginClient
{
HttpUrl manifest = RuneLiteProperties.getPluginHubBase()
.newBuilder()
.addPathSegments("manifest.js")
.addPathSegment("manifest.js")
.build();
try (Response res = okHttpClient.newCall(new Request.Builder().url(manifest).build()).execute())
{
if (res.code() != 200)
{
System.out.println(manifest.url().toString());
throw new IOException("Non-OK response code: " + res.code());
}

View File

@@ -109,8 +109,8 @@ public class MenuManager
{
for (MenuEntry menuEntry : client.getMenuEntries())
{
String option = menuEntry.getMenuOption();
String target = menuEntry.getMenuTarget();
String option = menuEntry.getOption();
String target = menuEntry.getTarget();
if (option.equals(customMenuOption.getMenuOption()) && target.equals(customMenuOption.getMenuTarget()))
{
@@ -128,7 +128,7 @@ public class MenuManager
return;
}
int widgetId = event.getWidgetId();
int widgetId = event.getActionParam1();
Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId);
for (WidgetMenuOption currentMenu : options)
@@ -139,9 +139,9 @@ public class MenuManager
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
menuEntry.setMenuOption(currentMenu.getMenuOption());
menuEntry.setWidgetId(widgetId);
menuEntry.setMenuTarget(currentMenu.getMenuTarget());
menuEntry.setOption(currentMenu.getMenuOption());
menuEntry.setActionParam1(widgetId);
menuEntry.setTarget(currentMenu.getMenuTarget());
menuEntry.setType(MenuAction.RUNELITE.getId());
client.setMenuEntries(menuEntries);
@@ -241,17 +241,17 @@ public class MenuManager
return; // not a managed widget option or custom player option
}
int widgetId = event.getWidgetId();
int widgetId = event.getActionParam1();
Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId);
for (WidgetMenuOption curMenuOption : options)
{
if (curMenuOption.getMenuTarget().equals(event.getMenuTarget())
&& curMenuOption.getMenuOption().equals(event.getMenuOption()))
if (curMenuOption.getMenuTarget().equals(event.getTarget())
&& curMenuOption.getMenuOption().equals(event.getOption()))
{
WidgetMenuOptionClicked customMenu = new WidgetMenuOptionClicked();
customMenu.setMenuOption(event.getMenuOption());
customMenu.setMenuTarget(event.getMenuTarget());
customMenu.setMenuOption(event.getOption());
customMenu.setMenuTarget(event.getTarget());
customMenu.setWidget(curMenuOption.getWidget());
eventBus.post(customMenu);
return; // don't continue because it's not a player option
@@ -260,14 +260,14 @@ public class MenuManager
// removes bounty hunter emblem tag and tier from player name, e.g:
// "username<img=20>5<col=40ff00> (level-42)" -> "username<col=40ff00> (level-42)"
String target = BOUNTY_EMBLEM_TAG_AND_TIER_REGEXP.matcher(event.getMenuTarget()).replaceAll("");
String target = BOUNTY_EMBLEM_TAG_AND_TIER_REGEXP.matcher(event.getTarget()).replaceAll("");
// removes tags and level from player names for example:
// <col=ffffff>username<col=40ff00> (level-42) or <col=ffffff><img=2>username</col>
String username = Text.removeTags(target).split("[(]")[0].trim();
PlayerMenuOptionClicked playerMenuOptionClicked = new PlayerMenuOptionClicked();
playerMenuOptionClicked.setMenuOption(event.getMenuOption());
playerMenuOptionClicked.setMenuOption(event.getOption());
playerMenuOptionClicked.setMenuTarget(username);
eventBus.post(playerMenuOptionClicked);

View File

@@ -148,7 +148,7 @@ public class OverlayManager
{
List<OverlayMenuEntry> menuEntries = overlay.getMenuEntries();
OverlayMenuEntry overlayMenuEntry = menuEntries.stream()
.filter(me -> me.getOption().equals(event.getMenuOption()))
.filter(me -> me.getOption().equals(event.getOption()))
.findAny()
.orElse(null);
if (overlayMenuEntry != null)

View File

@@ -877,8 +877,8 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
OverlayMenuEntry overlayMenuEntry = menuEntries.get(i);
final MenuEntry entry = new MenuEntry();
entry.setMenuOption(overlayMenuEntry.getOption());
entry.setMenuTarget(ColorUtil.wrapWithColorTag(overlayMenuEntry.getTarget(), JagexColors.MENU_TARGET));
entry.setOption(overlayMenuEntry.getOption());
entry.setTarget(ColorUtil.wrapWithColorTag(overlayMenuEntry.getTarget(), JagexColors.MENU_TARGET));
entry.setType(overlayMenuEntry.getMenuAction().getId());
entry.setType(overlayManager.getOverlays().indexOf(overlay)); // overlay id

View File

@@ -197,7 +197,7 @@ public class InfoBoxOverlay extends OverlayPanel
InfoBox infoBox = hoveredComponent.getInfoBox();
OverlayMenuEntry overlayMenuEntry = infoBox.getMenuEntries().stream()
.filter(me -> me.getOption().equals(menuOptionClicked.getMenuOption()))
.filter(me -> me.getOption().equals(menuOptionClicked.getOption()))
.findAny()
.orElse(null);
if (overlayMenuEntry != null)