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

@@ -25,7 +25,7 @@
object ProjectVersions {
const val launcherVersion = "2.2.0"
const val rlVersion = "1.6.32"
const val rlVersion = "1.6.35"
const val openosrsVersion = "3.5.4"

View File

@@ -37,14 +37,14 @@ public class MenuEntry implements Cloneable
/**
* The option text added to the menu (ie. "Walk here", "Use").
*/
private String menuOption;
private String option;
/**
* The target of the action (ie. Item or Actor name).
* <p>
* If the option does not apply to any target, this field
* will be set to empty string.
*/
private String menuTarget;
private String target;
/**
* An identifier value for the target of the action.
*/
@@ -61,7 +61,7 @@ public class MenuEntry implements Cloneable
/**
* A second additional parameter for the action.
*/
private int widgetId;
private int actionParam1;
/**
* If this field is true and you have single mouse button on and this entry is
* the top entry the right click menu will not be opened when you left click
@@ -70,14 +70,14 @@ public class MenuEntry implements Cloneable
*/
private boolean forceLeftClick;
public MenuEntry(String menuOption, String menuTarget, int type, int opcode, int actionParam0, int widgetId, boolean forceLeftClick)
public MenuEntry(String option, String target, int type, int opcode, int actionParam0, int actionParam1, boolean forceLeftClick)
{
this.menuOption = menuOption;
this.menuTarget = menuTarget;
this.option = option;
this.target = target;
this.type = type;
this.opcode = opcode;
this.actionParam0 = actionParam0;
this.widgetId = widgetId;
this.actionParam1 = actionParam1;
this.forceLeftClick = forceLeftClick;
}
@@ -94,6 +94,16 @@ public class MenuEntry implements Cloneable
}
}
public void setParam0(int i)
{
this.actionParam0 = i;
}
public void setParam1(int i)
{
this.actionParam1 = i;
}
/**
* Get opcode, but as it's enum counterpart
*/

View File

@@ -86,12 +86,12 @@ public class MenuOptionClicked extends MenuEntry implements Event
public void setMenuEntry(MenuEntry e)
{
setMenuOption(e.getMenuOption());
setMenuTarget(e.getMenuTarget());
setOption(e.getOption());
setTarget(e.getTarget());
setType(e.getType());
setOpcode(e.getOpcode());
setActionParam0(e.getActionParam0());
setWidgetId(e.getWidgetId());
setActionParam1(e.getActionParam1());
setForceLeftClick(e.isForceLeftClick());
}
}

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)

View File

@@ -184,12 +184,12 @@ public abstract class MenuMixin implements RSClient
public void setLeftClickMenuEntry(final MenuEntry entry)
{
final int i = getMenuOptionCount() - 1;
getMenuOptions()[i] = entry.getMenuOption();
getMenuTargets()[i] = entry.getMenuTarget();
getMenuOptions()[i] = entry.getOption();
getMenuTargets()[i] = entry.getTarget();
getMenuIdentifiers()[i] = entry.getType();
getMenuOpcodes()[i] = entry.getOpcode();
getMenuArguments1()[i] = entry.getActionParam0();
getMenuArguments2()[i] = entry.getWidgetId();
getMenuArguments2()[i] = entry.getActionParam1();
getMenuForceLeftClick()[i] = entry.isForceLeftClick();
}
@@ -212,10 +212,10 @@ public abstract class MenuMixin implements RSClient
return;
}
tempMenuAction.setOption(entry.getMenuOption());
tempMenuAction.setOption(entry.getOption());
tempMenuAction.setOpcode(entry.getOpcode());
tempMenuAction.setIdentifier(entry.getType());
tempMenuAction.setParam0(entry.getActionParam0());
tempMenuAction.setParam1(entry.getWidgetId());
tempMenuAction.setParam1(entry.getActionParam1());
}
}

View File

@@ -750,12 +750,12 @@ public abstract class RSClientMixin implements RSClient
for (int i = 0; i < count; ++i)
{
MenuEntry entry = entries[i] = new MenuEntry();
entry.setMenuOption(menuOptions[i]);
entry.setMenuTarget(menuTargets[i]);
entry.setOption(menuOptions[i]);
entry.setTarget(menuTargets[i]);
entry.setType(menuIdentifiers[i]);
entry.setOpcode(menuTypes[i]);
entry.setActionParam0(params0[i]);
entry.setWidgetId(params1[i]);
entry.setActionParam1(params1[i]);
entry.setForceLeftClick(leftClick[i]);
}
return entries;
@@ -781,12 +781,12 @@ public abstract class RSClientMixin implements RSClient
continue;
}
menuOptions[count] = entry.getMenuOption();
menuTargets[count] = entry.getMenuTarget();
menuOptions[count] = entry.getOption();
menuTargets[count] = entry.getTarget();
menuIdentifiers[count] = entry.getType();
menuTypes[count] = entry.getOpcode();
params0[count] = entry.getActionParam0();
params1[count] = entry.getWidgetId();
params1[count] = entry.getActionParam1();
leftClick[count] = entry.isForceLeftClick();
++count;
}
@@ -828,12 +828,12 @@ public abstract class RSClientMixin implements RSClient
if (event.isModified() && client.getMenuOptionCount() == newCount)
{
options[oldCount] = event.getMenuOption();
targets[oldCount] = event.getMenuTarget();
options[oldCount] = event.getOption();
targets[oldCount] = event.getTarget();
identifiers[oldCount] = event.getType();
opcodes[oldCount] = event.getOpcode();
arguments1[oldCount] = event.getActionParam0();
arguments2[oldCount] = event.getWidgetId();
arguments2[oldCount] = event.getActionParam1();
forceLeftClick[oldCount] = event.isForceLeftClick();
}
}
@@ -1425,14 +1425,14 @@ public abstract class RSClientMixin implements RSClient
{
client.getLogger().info(
"|MenuAction|: MenuOption={} MenuTarget={} Id={} Opcode={} Param0={} Param1={} CanvasX={} CanvasY={} Authentic={}",
menuOptionClicked.getMenuOption(), menuOptionClicked.getMenuTarget(), menuOptionClicked.getType(),
menuOptionClicked.getOpcode(), menuOptionClicked.getActionParam0(), menuOptionClicked.getWidgetId(),
menuOptionClicked.getOption(), menuOptionClicked.getTarget(), menuOptionClicked.getType(),
menuOptionClicked.getOpcode(), menuOptionClicked.getActionParam0(), menuOptionClicked.getActionParam1(),
canvasX, canvasY, authentic
);
}
copy$menuAction(menuOptionClicked.getActionParam0(), menuOptionClicked.getWidgetId(), menuOptionClicked.getOpcode(),
menuOptionClicked.getType(), menuOptionClicked.getMenuOption(), menuOptionClicked.getMenuTarget(), canvasX, canvasY);
copy$menuAction(menuOptionClicked.getActionParam0(), menuOptionClicked.getActionParam1(), menuOptionClicked.getOpcode(),
menuOptionClicked.getType(), menuOptionClicked.getOption(), menuOptionClicked.getTarget(), canvasX, canvasY);
}
@Override