Add Android client compatibility hooks and 2006Scape-Android submodule

This commit is contained in:
Dark98 committed 2026-11-04 00:28:18 +00:00
1 parent 7f1dc47c98
commit fb2bc30305
14 files changed
+942 -491

No files matched your search

+2
View File
@@ -12,6 +12,8 @@
2006Scape Client/bin/ 2006Scape Client/bin/
*.prefs *.prefs
*.classpath *.classpath
target/
**/target/
# Ignore any json files in the server root (should only be config files, the sample file should still be updated) # Ignore any json files in the server root (should only be config files, the sample file should still be updated)
2006Scape Server/*.json 2006Scape Server/*.json
+3
View File
@@ -0,0 +1,3 @@
[submodule "2006Scape-Android"]
path = 2006Scape-Android
url = https://github.com/2006-Scape/2006Scape-Android.git
@@ -0,0 +1,50 @@
/**
* Desktop stub for AndroidHooks so that guarded code compiles cleanly under Maven.
* In the Android build, this file is replaced by the actual Android implementation.
*/
public final class AndroidHooks {
private AndroidHooks() {}
public static boolean isAppInBackground() {
return false;
}
public static void decodeImage(Sprite sprite, byte[] abyte0) {}
public static String getClipBoard() {
return "";
}
public static void takeScreenshot(Game game, boolean sendMessage, String... subfolders) {}
public static void showErrorScreen(Game game, boolean loadingError, boolean genericLoadingError, boolean rsAlreadyLoaded) {}
public static void playSound(byte[] buffer, int offset, int length, int level, int delay) {}
public static void setSoundVolume(int config) {}
public static String getCacheDir() {
return "";
}
public static void playMidi(String location, int midiVolume) {}
public static void stopMidi() {}
public static boolean setMidiVolume(int value) {
return false;
}
public static Object getMusicPlayer() {
return null;
}
public static void pauseMidi() {}
public static void resumeMidi() {}
public static void showKeyboard() {}
public static void hideKeyboard() {}
}
@@ -0,0 +1,141 @@
import java.util.ArrayList;
import java.util.List;
public final class ClientArgs {
private ClientArgs() {}
public static void apply(String rawArgs, Game game) {
if (rawArgs == null || rawArgs.trim().isEmpty()) {
return;
}
apply(splitArgs(rawArgs), game);
}
public static void apply(String[] args, Game game) {
if (args == null || args.length == 0) {
return;
}
for (int i = 0; i < args.length; i++) {
if (args[i] == null) continue;
String arg = args[i].trim().toLowerCase();
switch (arg) {
case "-dev":
case "-local":
case "-offline":
ClientSettings.SERVER_IP = "localhost";
ClientSettings.CHECK_CRC = false;
break;
case "-no-crc":
case "-no-cache-crc":
ClientSettings.CHECK_CRC = false;
break;
case "-crc":
case "-check-crc":
ClientSettings.CHECK_CRC = true;
break;
case "-qol":
case "-fixes":
ClientSettings.CUSTOM_SETTINGS_TAB = true;
ClientSettings.BILINEAR_MINIMAP_FILTERING = true;
ClientSettings.FIX_TRANSPARENCY_OVERFLOW = true;
ClientSettings.FULL_512PX_VIEWPORT = true;
if (!ClientSettings.ANDROID) {
ClientSettings.CONTROL_KEY_ZOOMING = true;
}
break;
case "-no-nav":
case "-disable-nav":
ClientSettings.SHOW_NAVBAR = false;
break;
case "-no-snow":
case "-hide-snow":
case "-disable-snow":
ClientSettings.SNOW_FLOOR_ENABLED = false;
ClientSettings.SNOW_FLOOR_FORCE_ENABLED = false;
ClientSettings.SNOW_OVERLAY_FORCE_ENABLED = false;
ClientSettings.SNOW_OVERLAY_ENABLED = false;
break;
case "-no-roofs":
case "-hide-roofs":
case "-disable-roofs":
ClientSettings.HIDE_ROOFS = true;
break;
case "-roofs":
case "-show-roofs":
ClientSettings.HIDE_ROOFS = false;
break;
case "-show-zoom":
ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES = true;
break;
case "-screenshots":
case "-enable-screenshots":
ClientSettings.SCREENSHOTS_ENABLED = true;
break;
case "-auto-screenshots":
case "-enable-auto-screenshots":
ClientSettings.AUTOMATIC_SCREENSHOTS_ENABLED = true;
break;
}
if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) {
String val = args[++i];
switch (arg) {
case "-s":
case "-server":
case "-ip":
ClientSettings.SERVER_IP = val;
break;
case "-w":
case "-world":
try {
ClientSettings.SERVER_WORLD = Integer.parseInt(val);
} catch (NumberFormatException ignored) {}
break;
case "-u":
case "-user":
case "-username":
if (game != null) {
game.myUsername = val;
}
break;
case "-p":
case "-pass":
case "-password":
if (game != null) {
game.myPassword = val;
}
break;
}
}
}
}
public static String[] splitArgs(String input) {
if (input == null || input.trim().isEmpty()) {
return new String[0];
}
List<String> list = new ArrayList<>();
StringBuilder sb = new StringBuilder();
boolean insideQuotes = false;
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (c == '"' || c == '\'') {
insideQuotes = !insideQuotes;
} else if (Character.isWhitespace(c) && !insideQuotes) {
if (sb.length() > 0) {
list.add(sb.toString());
sb.setLength(0);
}
} else {
sb.append(c);
}
}
if (sb.length() > 0) {
list.add(sb.toString());
}
return list.toArray(new String[0]);
}
}
@@ -7,6 +7,12 @@ import java.math.BigInteger;
*/ */
public class ClientSettings { public class ClientSettings {
/**
* @Android
* Flag indicating Android build/environment. Enabled by default for initial debugging.
*/
public static boolean ANDROID = true;
/** /**
* @QoL * @QoL
* Require control key to zoom the client * Require control key to zoom the client
@@ -0,0 +1,288 @@
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.image.BufferedImage;
import java.awt.image.PixelGrabber;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.Synthesizer;
import javax.swing.JOptionPane;
public final class DesktopHooks {
private DesktopHooks() {}
public static void decodeImage(Sprite sprite, byte[] abyte0, Object component) {
try {
Component comp = (component instanceof Component) ? (Component) component : null;
Image image = Toolkit.getDefaultToolkit().createImage(abyte0);
if (comp != null) {
MediaTracker mediatracker = new MediaTracker(comp);
mediatracker.addImage(image, 0);
mediatracker.waitForAll();
sprite.width = image.getWidth(comp);
sprite.height = image.getHeight(comp);
} else {
Canvas canvas = new Canvas();
MediaTracker mediatracker = new MediaTracker(canvas);
mediatracker.addImage(image, 0);
mediatracker.waitForAll();
sprite.width = image.getWidth(canvas);
sprite.height = image.getHeight(canvas);
}
sprite.trimWidth = sprite.width;
sprite.trimHeight = sprite.height;
sprite.anInt1442 = 0;
sprite.anInt1443 = 0;
sprite.pixels = new int[sprite.width * sprite.height];
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, sprite.width, sprite.height, sprite.pixels, 0, sprite.width);
pixelgrabber.grabPixels();
} catch (Exception _ex) {
System.out.println("Error converting jpg");
}
}
public static String getClipBoard() {
String myString = "";
try {
myString = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
} catch (Exception e) {
e.printStackTrace();
}
String output = "";
for (int i = 0; i < myString.length(); i++) {
int j = (int) myString.charAt(i);
if (j >= 32 && j <= 122) {
output += (char) j;
}
}
return output;
}
public static void takeScreenshot(Game game, boolean sendMessage, String... subfolders) {
try {
Window window = (Window) game.getGameComponent();
Point point = window.getLocationOnScreen();
int x = (int) point.getX();
int y = (int) point.getY();
int w = window.getWidth();
int h = window.getHeight();
Robot robot = new Robot(window.getGraphicsConfiguration().getDevice());
Rectangle captureSize = new Rectangle(x, y, w, h);
BufferedImage bufferedimage = robot.createScreenCapture(captureSize);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
String dateTime = dateFormat.format(new Date());
String fileExtension = game.myUsername != null && !game.myUsername.isEmpty() ? game.myUsername : ClientSettings.SERVER_NAME;
String subfolderPath = String.join(File.separator, subfolders);
if (!subfolderPath.isEmpty()) {
subfolderPath += File.separator;
}
String screenshotDir = System.getProperty("user.home") + File.separatorChar + ClientSettings.SERVER_NAME + File.separatorChar + "screenshots" + File.separatorChar + subfolderPath;
File dir = new File(screenshotDir);
if (!dir.exists()) {
dir.mkdirs();
}
File file = new File(screenshotDir, fileExtension + "_" + dateTime + ".png");
if (!file.exists()) {
ImageIO.write(bufferedimage, "png", file);
if (sendMessage) {
game.pushMessage("A picture has been saved in your screenshots folder.", 0, "");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void showErrorScreen(Game game, boolean loadingError, boolean genericLoadingError, boolean rsAlreadyLoaded) {
Component comp = game.getGameComponent();
if (comp == null) return;
Graphics g = comp.getGraphics();
if (g == null) return;
g.setColor(Color.black);
g.fillRect(0, 0, 765, 503);
game.method4(1);
if (loadingError) {
g.setFont(new Font("Helvetica", 1, 16));
g.setColor(Color.yellow);
int k = 35;
g.drawString("Sorry, an error has occured whilst loading " + ClientSettings.SERVER_NAME + "", 30, k);
k += 50;
g.setColor(Color.white);
g.drawString("To fix this try the following (in order):", 30, k);
k += 50;
g.setColor(Color.white);
g.setFont(new Font("Helvetica", 1, 12));
g.drawString("1: Try closing ALL open web-browser windows, and reloading", 30, k);
k += 30;
g.drawString("2: Try clearing your web-browsers cache from tools->internet options", 30, k);
k += 30;
g.drawString("3: Try using a different game-world", 30, k);
k += 30;
g.drawString("4: Try rebooting your computer", 30, k);
k += 30;
g.drawString("5: Try selecting a different version of Java from the play-game menu", 30, k);
}
if (genericLoadingError) {
g.setFont(new Font("Helvetica", 1, 20));
g.setColor(Color.white);
g.drawString("Error - unable to load game!", 50, 50);
g.drawString("To play " + ClientSettings.SERVER_NAME + " make sure you play from", 50, 100);
g.drawString("" + ClientSettings.SERVER_WEBSITE + "", 50, 150);
}
if (rsAlreadyLoaded) {
g.setColor(Color.yellow);
int l = 35;
g.drawString("Error a copy of " + ClientSettings.SERVER_NAME + " already appears to be loaded", 30, l);
l += 50;
g.setColor(Color.white);
g.drawString("To fix this try the following (in order):", 30, l);
l += 50;
g.setColor(Color.white);
g.setFont(new Font("Helvetica", 1, 12));
g.drawString("1: Try closing ALL open web-browser windows, and reloading", 30, l);
l += 30;
g.drawString("2: Try rebooting your computer, and reloading", 30, l);
}
}
public static void checkJavaVersion() {
if (!System.getProperty("sun.arch.data.model", "").contains("64")) {
JOptionPane.showMessageDialog(null, "You're running 32-bit java. This will definitely cause problems.\nYou can get the right Java 8 at AdoptOpenJDK.net", "You're running 32-bit Java!", JOptionPane.INFORMATION_MESSAGE);
System.out.println("Please upgrade to 64-bit java to avoid problems! (AdoptOpenJDK.net)");
}
try {
if (Double.parseDouble(System.getProperty("java.specification.version", "1.8")) >= 1.9) {
JOptionPane.showMessageDialog(null, "You're not running Java 8. If you're using Parabot, this will cause problems!\nYou can get Java 8 from AdoptOpenJDK.net", "You're not running Java 8!", JOptionPane.INFORMATION_MESSAGE);
System.out.println("Please downgrade to Java 8 to avoid problems! (AdoptOpenJDK.net)");
}
} catch (Exception ignored) {}
}
public static void playSound(byte[] buffer, int offset, int length, int level, int delay) {
new SoundPlayer(new ByteArrayInputStream(buffer, offset, length), level, delay);
}
public static void setSoundVolume(int config) {
SoundPlayer.setVolume(config);
}
public static String getParameter(String s) {
if (Signlink.mainapp instanceof java.applet.Applet) {
return ((java.applet.Applet) Signlink.mainapp).getParameter(s);
}
return "";
}
public static void showDocument(Object caller, String s) {
try {
if (caller instanceof java.applet.Applet) {
java.applet.Applet a = (java.applet.Applet) caller;
java.applet.AppletContext ctx = a.getAppletContext();
if (ctx != null && caller instanceof Game) {
ctx.showDocument(new URL(((Game) caller).getCodeBase(), "loaderror_" + s + ".html"));
}
}
} catch (Exception ignored) {}
}
// Midi support for Signlink
public static Sequencer music = null;
public static Synthesizer synthesizer = null;
public static Sequence sequence = null;
public static void playSignlinkMidi(String location, int midiVolume) {
music = null;
synthesizer = null;
sequence = null;
File midiFile = new File(location);
try {
sequence = MidiSystem.getSequence(midiFile);
music = MidiSystem.getSequencer();
music.open();
music.setSequence(sequence);
} catch (Exception e) {
System.err.println("Problem loading MIDI file.");
e.printStackTrace();
return;
}
if (music instanceof Synthesizer) {
synthesizer = (Synthesizer) music;
} else {
try {
synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
if (synthesizer.getDefaultSoundbank() == null) {
music.getTransmitter().setReceiver(MidiSystem.getReceiver());
} else {
music.getTransmitter().setReceiver(synthesizer.getReceiver());
}
} catch (Exception e) {
e.printStackTrace();
return;
}
}
music.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
music.start();
setSignlinkVolume(midiVolume);
}
public static boolean setSignlinkVolume(int midiVolume) {
if (synthesizer == null) {
return false;
}
int CHANGE_VOLUME = 7;
if (synthesizer.getDefaultSoundbank() == null) {
try {
ShortMessage volumeMessage = new ShortMessage();
for (int i = 0; i < 16; i++) {
volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, i, CHANGE_VOLUME, midiVolume);
volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, i, 39, midiVolume);
MidiSystem.getReceiver().send(volumeMessage, -1);
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
} else {
try {
MidiChannel[] channels = synthesizer.getChannels();
for (int c = 0; channels != null && c < channels.length; c++) {
channels[c].controlChange(CHANGE_VOLUME, midiVolume);
channels[c].controlChange(39, midiVolume);
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
return true;
}
public static void stopSignlinkMidi() {
if (music != null) {
try {
music.stop();
music.close();
} catch (Exception ignored) {}
music = null;
}
}
public static void showKeyboard() {}
public static void hideKeyboard() {}
}
+369 -228
View File
@@ -3,14 +3,7 @@
* THIS IS TO ALLOW LOCAL PARABOT TO CONTINUE TO WORK * THIS IS TO ALLOW LOCAL PARABOT TO CONTINUE TO WORK
*/ */
import javax.imageio.ImageIO;
import javax.swing.*;
import java.applet.AppletContext;
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.EOFException; import java.io.EOFException;
@@ -183,6 +176,10 @@ public class Game extends RSApplet {
static final boolean constructMusic() { static final boolean constructMusic() {
anInt720 = 20; anInt720 = 20;
try { try {
if (ClientSettings.ANDROID) {
aClass56_749 = (Class56) AndroidHooks.getMusicPlayer();
return aClass56_749 != null;
}
aClass56_749 = (Class56) Class.forName("Class56_Sub1_Sub1").newInstance(); aClass56_749 = (Class56) Class.forName("Class56_Sub1_Sub1").newInstance();
} catch (Throwable throwable) { } catch (Throwable throwable) {
return false; return false;
@@ -226,7 +223,9 @@ public class Game extends RSApplet {
if (fetchMusic) { if (fetchMusic) {
byte[] is = musicData; byte[] is = musicData;
if (is != null) { if (is != null) {
if (anInt116 >= 0) if (ClientSettings.ANDROID)
method853(musicVolume2, is, aBoolean995);
else if (anInt116 >= 0)
method684(aBoolean995, anInt116, musicVolume2, is); method684(aBoolean995, anInt116, musicVolume2, is);
else if (anInt139 >= 0) else if (anInt139 >= 0)
method899(anInt139, -1, aBoolean995, is, musicVolume2); method899(anInt139, -1, aBoolean995, is, musicVolume2);
@@ -346,12 +345,12 @@ public class Game extends RSApplet {
} }
private void stopMidi() { private void stopMidi() {
if (Signlink.music != null) { if (ClientSettings.ANDROID) {
if (Signlink.music.isRunning()) { AndroidHooks.stopMidi();
Signlink.fadeOut(); Signlink.midi = "stop";
Signlink.music.stop(); } else {
Signlink.midi = "stop"; DesktopHooks.stopSignlinkMidi();
} Signlink.midi = "stop";
} }
} }
@@ -1014,10 +1013,8 @@ public class Game extends RSApplet {
public void loadError() { public void loadError() {
String s = "ondemand";// was a constant parameter String s = "ondemand";// was a constant parameter
try { if (!ClientSettings.ANDROID) {
getAppletContext().showDocument(new URL(getCodeBase(), "loaderror_" + s + ".html")); DesktopHooks.showDocument(this, s);
} catch (Exception exception) {
exception.printStackTrace();
} }
do { do {
try { try {
@@ -1435,7 +1432,11 @@ public class Game extends RSApplet {
} }
} }
if (action == 4) { if (action == 4) {
SoundPlayer.setVolume(config); if (ClientSettings.ANDROID) {
AndroidHooks.setSoundVolume(config);
} else {
DesktopHooks.setSoundVolume(config);
}
if (config == 0) { if (config == 0) {
aBoolean848 = true; aBoolean848 = true;
setWaveVolume(0); setWaveVolume(0);
@@ -1486,13 +1487,13 @@ public class Game extends RSApplet {
calcEntityScreenPos(k5 * 128 + 64, 20, l5 * 128 + 64); calcEntityScreenPos(k5 * 128 + 64, 20, l5 * 128 + 64);
// only show ground items names if worth more than x (1k default) // only show ground items names if worth more than x (1k default)
if (totalValue >= customSettingMinItemValue) { if (totalValue >= customSettingMinItemValue) {
int color = Color.WHITE.hashCode(); int color = RSColors.WHITE;
if (totalValue >= 1e5) { if (totalValue >= 1e5) {
color = Color.GREEN.hashCode(); color = RSColors.GREEN;
} else if (totalValue >= 1e4) { } else if (totalValue >= 1e4) {
color = Color.CYAN.hashCode(); color = RSColors.CYAN;
} else if (totalValue >= 1e3) { } else if (totalValue >= 1e3) {
color = Color.YELLOW.hashCode(); color = RSColors.YELLOW;
} }
String text = ""; String text = "";
if (item.amount > 1) { if (item.amount > 1) {
@@ -1821,25 +1822,25 @@ public class Game extends RSApplet {
drawButton(customSettingVisiblePlayerNames, centerX - 73, currentY, 146); drawButton(customSettingVisiblePlayerNames, centerX - 73, currentY, 146);
// buttonLeftDisabled.drawSprite(centerX - 73, currentY); // buttonLeftDisabled.drawSprite(centerX - 73, currentY);
aTextDrawingArea_1271.textCenterShadow(Color.YELLOW.hashCode(), centerX, "always visible", currentY + textTop, true); aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "always visible", currentY + textTop, true);
aTextDrawingArea_1271.textCenterShadow(Color.YELLOW.hashCode(), centerX, "player names", currentY + textBottom, true); aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "player names", currentY + textBottom, true);
drawButton(true, centerX - 73, currentY += 40, 146); drawButton(true, centerX - 73, currentY += 40, 146);
aTextDrawingArea_1271.textCenterShadow(Color.YELLOW.hashCode(), centerX, "item drops visible", currentY + textTop, true); aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "item drops visible", currentY + textTop, true);
aTextDrawingArea_1271.textCenterShadow(Color.WHITE.hashCode(), centerX, intToKOrMil(customSettingMinItemValue) + " gp", currentY + textBottom, true); aTextDrawingArea_1271.textCenterShadow(RSColors.WHITE, centerX, intToKOrMil(customSettingMinItemValue) + " gp", currentY + textBottom, true);
drawButton(true, centerX - 73, currentY += 40, 146); drawButton(true, centerX - 73, currentY += 40, 146);
aTextDrawingArea_1271.textCenterShadow(Color.YELLOW.hashCode(), centerX, "draw distance", currentY + textTop, true); aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "draw distance", currentY + textTop, true);
aTextDrawingArea_1271.textCenterShadow(Color.WHITE.hashCode(), centerX, WorldController.drawDistance + " tiles", currentY + textBottom, true); aTextDrawingArea_1271.textCenterShadow(RSColors.WHITE, centerX, WorldController.drawDistance + " tiles", currentY + textBottom, true);
drawButton(customSettingShowExperiencePerHour, centerX - 73, currentY += 40, 146); drawButton(customSettingShowExperiencePerHour, centerX - 73, currentY += 40, 146);
aTextDrawingArea_1271.textCenterShadow(Color.YELLOW.hashCode(), centerX, "show exp info", currentY + textMiddle, true); aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "show exp info", currentY + textMiddle, true);
drawButton(showInfo, centerX - 73, currentY += 40, 146); drawButton(showInfo, centerX - 73, currentY += 40, 146);
aTextDrawingArea_1271.textCenterShadow(Color.YELLOW.hashCode(), centerX, "show debug info", currentY + textMiddle, true); aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "show debug info", currentY + textMiddle, true);
drawButton(customSettingVisualFixes, centerX - 73, currentY += 40, 146); drawButton(customSettingVisualFixes, centerX - 73, currentY += 40, 146);
aTextDrawingArea_1271.textCenterShadow(Color.YELLOW.hashCode(), centerX, "visual fixes", currentY + textMiddle, true); aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "visual fixes", currentY + textMiddle, true);
} catch (Exception e) { } } catch (Exception e) { }
} }
} }
@@ -2191,6 +2192,7 @@ public class Game extends RSApplet {
} }
public void resetLogout() { public void resetLogout() {
boolean wasDisconnected = loggedIn && (pktType != 109) && (anInt1011 <= 0);
try { try {
if (socketStream != null) { if (socketStream != null) {
socketStream.close(); socketStream.close();
@@ -2199,7 +2201,14 @@ public class Game extends RSApplet {
} }
socketStream = null; socketStream = null;
loggedIn = false; loggedIn = false;
loginScreenState = 0; if (wasDisconnected && (ClientSettings.ANDROID || (myUsername != null && myUsername.length() > 0))) {
loginMessage1 = "You were disconnected from the server.";
loginMessage2 = "Press Login to reconnect.";
loginScreenState = 2;
loginScreenCursorPos = (myPassword != null && myPassword.length() > 0) ? 1 : 0;
} else {
loginScreenState = 0;
}
// myUsername = ""; // myUsername = "";
// myPassword = ""; // myPassword = "";
unlinkMRUNodes(); unlinkMRUNodes();
@@ -2339,6 +2348,9 @@ public class Game extends RSApplet {
promptInput = ""; promptInput = "";
friendsListAction = 1; friendsListAction = 1;
aString1121 = "Enter name of friend to add to list"; aString1121 = "Enter name of friend to add to list";
if (ClientSettings.ANDROID) {
AndroidHooks.showKeyboard();
}
} }
if (j == 202) { if (j == 202) {
inputTaken = true; inputTaken = true;
@@ -2347,6 +2359,9 @@ public class Game extends RSApplet {
promptInput = ""; promptInput = "";
friendsListAction = 2; friendsListAction = 2;
aString1121 = "Enter name of friend to delete from list"; aString1121 = "Enter name of friend to delete from list";
if (ClientSettings.ANDROID) {
AndroidHooks.showKeyboard();
}
} }
} }
if (j == 205) { if (j == 205) {
@@ -2360,6 +2375,9 @@ public class Game extends RSApplet {
promptInput = ""; promptInput = "";
friendsListAction = 4; friendsListAction = 4;
aString1121 = "Enter name of player to add to list"; aString1121 = "Enter name of player to add to list";
if (ClientSettings.ANDROID) {
AndroidHooks.showKeyboard();
}
} }
if (j == 502) { if (j == 502) {
inputTaken = true; inputTaken = true;
@@ -2368,6 +2386,9 @@ public class Game extends RSApplet {
promptInput = ""; promptInput = "";
friendsListAction = 5; friendsListAction = 5;
aString1121 = "Enter name of player to delete from list"; aString1121 = "Enter name of player to delete from list";
if (ClientSettings.ANDROID) {
AndroidHooks.showKeyboard();
}
} }
if (j >= 300 && j <= 313) { if (j >= 300 && j <= 313) {
int k = (j - 300) / 2; int k = (j - 300) / 2;
@@ -2764,13 +2785,6 @@ public class Game extends RSApplet {
} }
public AppletContext getAppletContext() {
if (Signlink.mainapp != null) {
return Signlink.mainapp.getAppletContext();
} else {
return super.getAppletContext();
}
}
public void drawLogo() { public void drawLogo() {
byte abyte0[] = titleStreamLoader.getDataForName("title.dat"); byte abyte0[] = titleStreamLoader.getDataForName("title.dat");
@@ -3570,10 +3584,25 @@ public class Game extends RSApplet {
loginFailures = 0; loginFailures = 0;
login(myUsername, myPassword, true); login(myUsername, myPassword, true);
if (!loggedIn) { if (!loggedIn) {
String existingMsg1 = loginMessage1;
String existingMsg2 = loginMessage2;
resetLogout(); resetLogout();
if (existingMsg1 != null && !existingMsg1.isEmpty()) {
loginMessage1 = existingMsg1;
loginMessage2 = existingMsg2;
} else {
loginMessage1 = "You were disconnected from the server.";
loginMessage2 = "Press Login to reconnect.";
}
if (ClientSettings.ANDROID || (myUsername != null && myUsername.length() > 0)) {
loginScreenState = 2;
loginScreenCursorPos = (myPassword != null && myPassword.length() > 0) ? 1 : 0;
}
} }
try { try {
rsSocket.close(); if (rsSocket != null) {
rsSocket.close();
}
} catch (Exception _ex) { } catch (Exception _ex) {
} }
} }
@@ -3621,8 +3650,20 @@ public class Game extends RSApplet {
return; return;
} }
if (inputDialogState != 0) { if (inputDialogState != 0) {
inputDialogState = 0; if (!ClientSettings.ANDROID || (super.saveClickX > 516 || super.saveClickY < 357 || super.saveClickY > 467)) {
inputTaken = true; inputDialogState = 0;
inputTaken = true;
if (ClientSettings.ANDROID) {
AndroidHooks.hideKeyboard();
}
}
}
if (messagePromptRaised) {
if (ClientSettings.ANDROID && (super.saveClickX > 516 || super.saveClickY < 357 || super.saveClickY > 467)) {
messagePromptRaised = false;
inputTaken = true;
AndroidHooks.hideKeyboard();
}
} }
int j = menuActionCmd2[i]; int j = menuActionCmd2[i];
int k = menuActionCmd3[i]; int k = menuActionCmd3[i];
@@ -4312,6 +4353,9 @@ public class Game extends RSApplet {
friendsListAction = 3; friendsListAction = 3;
aLong953 = friendsListAsLongs[k3]; aLong953 = friendsListAsLongs[k3];
aString1121 = "Enter message to send to " + friendsList[k3]; aString1121 = "Enter message to send to " + friendsList[k3];
if (ClientSettings.ANDROID) {
AndroidHooks.showKeyboard();
}
} else { } else {
pushMessage("That player is currently offline.", 0, ""); pushMessage("That player is currently offline.", 0, "");
} }
@@ -4823,13 +4867,6 @@ public class Game extends RSApplet {
super.shouldDebug = true; super.shouldDebug = true;
} }
Component getGameComponent() {
if (Signlink.mainapp != null) {
return Signlink.mainapp;
} else {
return this;
}
}
public void method73() { public void method73() {
do { do {
@@ -4898,6 +4935,9 @@ public class Game extends RSApplet {
if (j == 13 || j == 10) { if (j == 13 || j == 10) {
messagePromptRaised = false; messagePromptRaised = false;
inputTaken = true; inputTaken = true;
if (ClientSettings.ANDROID) {
AndroidHooks.hideKeyboard();
}
if (friendsListAction == 1) { if (friendsListAction == 1) {
long l = TextClass.longForName(promptInput); long l = TextClass.longForName(promptInput);
addFriend(l); addFriend(l);
@@ -4964,10 +5004,16 @@ public class Game extends RSApplet {
} }
inputDialogState = 0; inputDialogState = 0;
inputTaken = true; inputTaken = true;
if (ClientSettings.ANDROID) {
AndroidHooks.hideKeyboard();
}
} }
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
inputDialogState = 0; inputDialogState = 0;
inputTaken = true; inputTaken = true;
if (ClientSettings.ANDROID) {
AndroidHooks.hideKeyboard();
}
pushMessage("Please enter a lower amount.", 0, ""); pushMessage("Please enter a lower amount.", 0, "");
} }
} else if (inputDialogState == 2) { } else if (inputDialogState == 2) {
@@ -4986,6 +5032,9 @@ public class Game extends RSApplet {
} }
inputDialogState = 0; inputDialogState = 0;
inputTaken = true; inputTaken = true;
if (ClientSettings.ANDROID) {
AndroidHooks.hideKeyboard();
}
} }
} else { } else {
// typing characters // typing characters
@@ -5591,48 +5640,10 @@ public class Game extends RSApplet {
} }
public void screenshot(boolean sendMessage, String... subfolders) { public void screenshot(boolean sendMessage, String... subfolders) {
try { if (ClientSettings.ANDROID) {
Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); AndroidHooks.takeScreenshot(this, sendMessage, subfolders);
if (window == null) { } else {
return; DesktopHooks.takeScreenshot(this, sendMessage, subfolders);
}
Point point = window.getLocationOnScreen();
int x = (int) point.getX();
int y = (int) point.getY();
int w = window.getWidth();
int h = window.getHeight();
Robot robot = new Robot(window.getGraphicsConfiguration().getDevice());
Rectangle captureSize = new Rectangle(x, y, w, h);
BufferedImage bufferedimage = robot.createScreenCapture(captureSize);
// Format the current date and time
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
String dateTime = dateFormat.format(new Date());
// Update the file path and naming
String fileExtension = myUsername != null && !myUsername.isEmpty() ? myUsername : ClientSettings.SERVER_NAME;
String subfolderPath = String.join(File.separator, subfolders);
if (!subfolderPath.isEmpty()) {
subfolderPath += File.separator;
}
String screenshotDir = System.getProperty("user.home") + File.separatorChar + ClientSettings.SERVER_NAME + File.separatorChar + "screenshots" + File.separatorChar + subfolderPath;
File dir = new File(screenshotDir);
if (!dir.exists()) {
dir.mkdirs(); // Create the directory if it doesn't exist
}
File file = new File(screenshotDir, fileExtension + "_" + dateTime + ".png");
if (!file.exists()) {
ImageIO.write(bufferedimage, "png", file);
if (sendMessage) {
pushMessage("A picture has been saved in your screenshots folder.", 0, "");
}
}
} catch (Exception e) {
e.printStackTrace();
} }
} }
public void pushMessage(String s, int i, String s1) { public void pushMessage(String s, int i, String s1) {
@@ -6864,11 +6875,17 @@ public class Game extends RSApplet {
//if (soundDelay[index] <= 0) { //if (soundDelay[index] <= 0) {
boolean flag1 = false; boolean flag1 = false;
try { try {
Stream stream = Sounds.method241(soundType[index], sound[index]); Stream soundStream = Sounds.method241(soundType[index], sound[index]);
new SoundPlayer((InputStream) new ByteArrayInputStream(stream.buffer, 0, stream.currentOffset), soundVolume[index], soundDelay[index]); if (soundStream != null && soundStream.currentOffset > 0) {
if (System.currentTimeMillis() + (long) (stream.currentOffset / 22) > aLong1172 + (long) (anInt1257 / 22)) { if (ClientSettings.ANDROID) {
anInt1257 = stream.currentOffset; AndroidHooks.playSound(soundStream.buffer, 0, soundStream.currentOffset, soundVolume[index], soundDelay[index]);
aLong1172 = System.currentTimeMillis(); } else {
DesktopHooks.playSound(soundStream.buffer, 0, soundStream.currentOffset, soundVolume[index], soundDelay[index]);
}
if (System.currentTimeMillis() + (long) (soundStream.currentOffset / 22) > aLong1172 + (long) (anInt1257 / 22)) {
anInt1257 = soundStream.currentOffset;
aLong1172 = System.currentTimeMillis();
}
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
@@ -7033,6 +7050,9 @@ public class Game extends RSApplet {
method58(10, musicVolume, false, 0); method58(10, musicVolume, false, 0);
while (onDemandFetcher.getNodeCount() > 0) { while (onDemandFetcher.getNodeCount() > 0) {
processOnDemandQueue(); processOnDemandQueue();
if (fetchMusic) {
method49();
}
try { try {
Thread.sleep(100L); Thread.sleep(100L);
} catch (Exception _ex) { } catch (Exception _ex) {
@@ -7364,8 +7384,13 @@ public class Game extends RSApplet {
ObjectDef.clientInstance = this; ObjectDef.clientInstance = this;
EntityDef.clientInstance = this; EntityDef.clientInstance = this;
if (myUsername != "" && myPassword != "") if (myUsername != null && !myUsername.isEmpty()) {
login(myUsername, myPassword, false); loginScreenState = 2;
loginScreenCursorPos = (myPassword != null && !myPassword.isEmpty()) ? 1 : 0;
if (myPassword != null && !myPassword.isEmpty()) {
login(myUsername, myPassword, false);
}
}
return; return;
} catch (Exception exception) { } catch (Exception exception) {
Signlink.reporterror("loaderror " + aString1049 + " " + anInt1079); Signlink.reporterror("loaderror " + aString1049 + " " + anInt1079);
@@ -7476,55 +7501,10 @@ public class Game extends RSApplet {
} }
public void showErrorScreen() { public void showErrorScreen() {
Graphics g = getGameComponent().getGraphics(); if (ClientSettings.ANDROID) {
g.setColor(Color.black); AndroidHooks.showErrorScreen(this, loadingError, genericLoadingError, rsAlreadyLoaded);
g.fillRect(0, 0, 765, 503); } else {
method4(1); DesktopHooks.showErrorScreen(this, loadingError, genericLoadingError, rsAlreadyLoaded);
if (loadingError) {
aBoolean831 = false;
g.setFont(new Font("Helvetica", 1, 16));
g.setColor(Color.yellow);
int k = 35;
g.drawString("Sorry, an error has occured whilst loading " + ClientSettings.SERVER_NAME + "", 30, k);
k += 50;
g.setColor(Color.white);
g.drawString("To fix this try the following (in order):", 30, k);
k += 50;
g.setColor(Color.white);
g.setFont(new Font("Helvetica", 1, 12));
g.drawString("1: Try closing ALL open web-browser windows, and reloading", 30, k);
k += 30;
g.drawString("2: Try clearing your web-browsers cache from tools->internet options", 30, k);
k += 30;
g.drawString("3: Try using a different game-world", 30, k);
k += 30;
g.drawString("4: Try rebooting your computer", 30, k);
k += 30;
g.drawString("5: Try selecting a different version of Java from the play-game menu", 30, k);
}
if (genericLoadingError) {
aBoolean831 = false;
g.setFont(new Font("Helvetica", 1, 20));
g.setColor(Color.white);
g.drawString("Error - unable to load game!", 50, 50);
g.drawString("To play " + ClientSettings.SERVER_NAME + " make sure you play from", 50, 100);
g.drawString("" + ClientSettings.SERVER_WEBSITE + "", 50, 150);
}
if (rsAlreadyLoaded) {
aBoolean831 = false;
g.setColor(Color.yellow);
int l = 35;
g.drawString("Error a copy of " + ClientSettings.SERVER_NAME + " already appears to be loaded", 30, l);
l += 50;
g.setColor(Color.white);
g.drawString("To fix this try the following (in order):", 30, l);
l += 50;
g.setColor(Color.white);
g.setFont(new Font("Helvetica", 1, 12));
g.drawString("1: Try closing ALL open web-browser windows, and reloading", 30, l);
l += 30;
g.drawString("2: Try rebooting your computer, and reloading", 30, l);
l += 30;
} }
} }
@@ -8783,6 +8763,10 @@ public class Game extends RSApplet {
return; return;
} }
anInt1061++; anInt1061++;
if (ClientSettings.ANDROID && AndroidHooks.isAppInBackground()) {
anInt1213 = 0;
return;
}
if (!loggedIn) { if (!loggedIn) {
drawLoginScreen(false); drawLoginScreen(false);
} else { } else {
@@ -8896,20 +8880,20 @@ public class Game extends RSApplet {
int debugX = 511 - debugWidth; int debugX = 511 - debugWidth;
int debugY = 334 - debugHeight; int debugY = 334 - debugHeight;
int fill = 0x5d5447; int fill = 0x5d5447;
int fill2 = Color.BLACK.hashCode(); int fill2 = RSColors.BLACK;
int opacity = 140; int opacity = 140;
DrawingArea.fillArea(fill, debugY, debugWidth, debugHeight, opacity, debugX); DrawingArea.fillArea(fill, debugY, debugWidth, debugHeight, opacity, debugX);
DrawingArea.fillArea(fill2, debugY + 1, debugWidth - 2, 16, opacity, debugX + 1); DrawingArea.fillArea(fill2, debugY + 1, debugWidth - 2, 16, opacity, debugX + 1);
DrawingArea.fillPixels(debugY + 18, debugHeight - 19, fill2, debugX + 1, debugWidth - 2); DrawingArea.fillPixels(debugY + 18, debugHeight - 19, fill2, debugX + 1, debugWidth - 2);
chatTextDrawingArea.textLeft(Color.WHITE.darker().hashCode(), "Notification", debugY += 14, debugX + 3); chatTextDrawingArea.textLeft(RSColors.WHITE_DARKER, "Notification", debugY += 14, debugX + 3);
// Bump Y value // Bump Y value
debugY += 3; debugY += 3;
// Draw items // Draw items
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "System update in:", debugY += 15); chatTextDrawingArea.textLeftShadow(true, debugX + 4, RSColors.WHITE, "System update in:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), message, debugY); chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, RSColors.YELLOW, message, debugY);
// Not sure what this is for // Not sure what this is for
anInt849++; anInt849++;
@@ -9001,6 +8985,12 @@ public class Game extends RSApplet {
} }
public void determineMenuSize() { public void determineMenuSize() {
if (isScrollBarAt(super.saveClickX, super.saveClickY)) {
return;
}
if (ClientSettings.ANDROID && (menuActionRow == 0 || (menuActionRow == 1 && menuActionID[0] == 1107))) {
return;
}
int i = chatTextDrawingArea.getTextWidth("Choose Option"); int i = chatTextDrawingArea.getTextWidth("Choose Option");
for (int j = 0; j < menuActionRow; j++) { for (int j = 0; j < menuActionRow; j++) {
int k = chatTextDrawingArea.getTextWidth(menuActionName[j]); int k = chatTextDrawingArea.getTextWidth(menuActionName[j]);
@@ -9317,8 +9307,11 @@ public class Game extends RSApplet {
} }
public String getParameter(String s) { public String getParameter(String s) {
if (ClientSettings.ANDROID) {
return "";
}
if (Signlink.mainapp != null) { if (Signlink.mainapp != null) {
return Signlink.mainapp.getParameter(s); return DesktopHooks.getParameter(s);
} else { } else {
return super.getParameter(s); return super.getParameter(s);
} }
@@ -11627,6 +11620,9 @@ public class Game extends RSApplet {
inputDialogState = 1; inputDialogState = 1;
amountOrNameInput = ""; amountOrNameInput = "";
inputTaken = true; inputTaken = true;
if (ClientSettings.ANDROID) {
AndroidHooks.showKeyboard();
}
pktType = -1; pktType = -1;
return true; return true;
} }
@@ -11635,6 +11631,9 @@ public class Game extends RSApplet {
inputDialogState = 2; inputDialogState = 2;
amountOrNameInput = ""; amountOrNameInput = "";
inputTaken = true; inputTaken = true;
if (ClientSettings.ANDROID) {
AndroidHooks.showKeyboard();
}
pktType = -1; pktType = -1;
return true; return true;
} }
@@ -11910,14 +11909,14 @@ public class Game extends RSApplet {
int debugWidth = 140; int debugWidth = 140;
int debugHeight = 25 + (debugItems * 15); int debugHeight = 25 + (debugItems * 15);
int fill = 0x5d5447; int fill = 0x5d5447;
int fill2 = Color.BLACK.hashCode(); int fill2 = RSColors.BLACK;
int opacity = 140; int opacity = 140;
DrawingArea.fillArea(fill, debugY, debugWidth, debugHeight, opacity, debugX); DrawingArea.fillArea(fill, debugY, debugWidth, debugHeight, opacity, debugX);
DrawingArea.fillArea(fill2, debugY + 1, debugWidth - 2, 16, opacity, debugX + 1); DrawingArea.fillArea(fill2, debugY + 1, debugWidth - 2, 16, opacity, debugX + 1);
DrawingArea.fillPixels(debugY + 18, debugHeight - 19, fill2, debugX + 1, debugWidth - 2); DrawingArea.fillPixels(debugY + 18, debugHeight - 19, fill2, debugX + 1, debugWidth - 2);
chatTextDrawingArea.textLeft(Color.WHITE.darker().hashCode(), "Debug Info", debugY += 14, debugX + 3); chatTextDrawingArea.textLeft(RSColors.WHITE_DARKER, "Debug Info", debugY += 14, debugX + 3);
chatTextDrawingArea.textLeft(super.fps > 40 ? Color.YELLOW.hashCode() : super.fps > 25 ? Color.ORANGE.hashCode() : Color.RED.hashCode(), super.fps + "fps", debugY, debugX + debugWidth - chatTextDrawingArea.getTextWidth(super.fps + "fps") - 3); chatTextDrawingArea.textLeft(super.fps > 40 ? RSColors.YELLOW : super.fps > 25 ? RSColors.ORANGE : RSColors.RED, super.fps + "fps", debugY, debugX + debugWidth - chatTextDrawingArea.getTextWidth(super.fps + "fps") - 3);
// Bump Y value // Bump Y value
debugY += 3; debugY += 3;
@@ -11925,16 +11924,16 @@ public class Game extends RSApplet {
// Draw items // Draw items
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
int memKB = (int) ((runtime.totalMemory() - runtime.freeMemory()) / 1024L); int memKB = (int) ((runtime.totalMemory() - runtime.freeMemory()) / 1024L);
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Memory:", debugY += 15); chatTextDrawingArea.textLeftShadow(true, debugX + 4, RSColors.WHITE, "Memory:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), (memKB / 1024) + "mb", debugY); chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, RSColors.YELLOW, (memKB / 1024) + "mb", debugY);
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Mouse:", debugY += 15); chatTextDrawingArea.textLeftShadow(true, debugX + 4, RSColors.WHITE, "Mouse:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), super.mouseX + ", " + super.mouseY, debugY); chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, RSColors.YELLOW, super.mouseX + ", " + super.mouseY, debugY);
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Coords:", debugY += 15); chatTextDrawingArea.textLeftShadow(true, debugX + 4, RSColors.WHITE, "Coords:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), (myPlayer.smallX[0] + baseX) + ", " + (myPlayer.smallY[0] + baseY), debugY); chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, RSColors.YELLOW, (myPlayer.smallX[0] + baseX) + ", " + (myPlayer.smallY[0] + baseY), debugY);
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Interface:", debugY += 15); chatTextDrawingArea.textLeftShadow(true, debugX + 4, RSColors.WHITE, "Interface:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), "" + openInterfaceID, debugY); chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, RSColors.YELLOW, "" + openInterfaceID, debugY);
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Zoom level:", debugY += 15); chatTextDrawingArea.textLeftShadow(true, debugX + 4, RSColors.WHITE, "Zoom level:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), "" + zoom, debugY); chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, RSColors.YELLOW, "" + zoom, debugY);
} }
if (customSettingShowExperiencePerHour) { if (customSettingShowExperiencePerHour) {
@@ -11944,13 +11943,13 @@ public class Game extends RSApplet {
int debugX = 511 - debugWidth; int debugX = 511 - debugWidth;
int debugY = 0; int debugY = 0;
int fill = 0x5d5447; int fill = 0x5d5447;
int fill2 = Color.BLACK.hashCode(); int fill2 = RSColors.BLACK;
int opacity = 140; int opacity = 140;
DrawingArea.fillArea(fill, debugY, debugWidth, debugHeight, opacity, debugX); DrawingArea.fillArea(fill, debugY, debugWidth, debugHeight, opacity, debugX);
DrawingArea.fillArea(fill2, debugY + 1, debugWidth - 2, 16, opacity, debugX + 1); DrawingArea.fillArea(fill2, debugY + 1, debugWidth - 2, 16, opacity, debugX + 1);
DrawingArea.fillPixels(debugY + 18, debugHeight - 19, fill2, debugX + 1, debugWidth - 2); DrawingArea.fillPixels(debugY + 18, debugHeight - 19, fill2, debugX + 1, debugWidth - 2);
chatTextDrawingArea.textLeft(Color.WHITE.darker().hashCode(), "Experience Info", debugY += 14, debugX + 3); chatTextDrawingArea.textLeft(RSColors.WHITE_DARKER, "Experience Info", debugY += 14, debugX + 3);
// Bump Y value // Bump Y value
debugY += 3; debugY += 3;
@@ -11961,10 +11960,10 @@ public class Game extends RSApplet {
long expPerHour = (long) ((expGained * 3600000D) / (System.currentTimeMillis() - customSettingShowExperiencePerHourStart)); long expPerHour = (long) ((expGained * 3600000D) / (System.currentTimeMillis() - customSettingShowExperiencePerHourStart));
// Draw items // Draw items
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Exp per hour:", debugY += 15); chatTextDrawingArea.textLeftShadow(true, debugX + 4, RSColors.WHITE, "Exp per hour:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), intToShortLetter((int) expPerHour), debugY); chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, RSColors.YELLOW, intToShortLetter((int) expPerHour), debugY);
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Levels gained:", debugY += 15); chatTextDrawingArea.textLeftShadow(true, debugX + 4, RSColors.WHITE, "Levels gained:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), "" + (calculateTotalLevels() - customSettingShowExperiencePerHourStartLevels), debugY); chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, RSColors.YELLOW, "" + (calculateTotalLevels() - customSettingShowExperiencePerHourStartLevels), debugY);
} }
// Draw main screen // Draw main screen
@@ -12000,15 +11999,8 @@ public class Game extends RSApplet {
} }
public Game() { public Game() {
//Test if they're on 32-bit, warn them if they are if (!ClientSettings.ANDROID) {
if (!System.getProperty("sun.arch.data.model").contains("64")) DesktopHooks.checkJavaVersion();
{
JOptionPane.showMessageDialog(null, "You're running 32-bit java. This will definitely cause problems.\nYou can get the right Java 8 at AdoptOpenJDK.net", "You're running 32-bit Java!", JOptionPane.INFORMATION_MESSAGE);
System.out.println("Please upgrade to 64-bit java to avoid problems! (AdoptOpenJDK.net)");
}
if (Double.parseDouble(System.getProperty("java.specification.version")) >= 1.9) {
JOptionPane.showMessageDialog(null, "You're not running Java 8. If you're using Parabot, this will cause problems!\nYou can get Java 8 from AdoptOpenJDK.net", "You're not running Java 8!", JOptionPane.INFORMATION_MESSAGE);
System.out.println("Please downgrade to Java 8 to avoid problems! (AdoptOpenJDK.net)");
} }
server = ClientSettings.SERVER_IP; server = ClientSettings.SERVER_IP;
anIntArrayArray825 = new int[104][104]; anIntArrayArray825 = new int[104][104];
@@ -12608,7 +12600,7 @@ public class Game extends RSApplet {
public static int anInt116; public static int anInt116;
public static boolean aBoolean995; public static boolean aBoolean995;
public static int anInt139; public static int anInt139;
public static int musicVolume = 0; public static int musicVolume = 255;
public int[] gameScreenOffsets; public int[] gameScreenOffsets;
public int anInt1170; public int anInt1170;
public int anInt1215; public int anInt1215;
@@ -12643,75 +12635,75 @@ public class Game extends RSApplet {
this.anInt1187 += (j << 1); this.anInt1187 += (j << 1);
} }
public void keyPressed(KeyEvent keyevent) public void handleKeyPressed(int keyCode, char keyChar, boolean isControlDown, boolean isShiftDown)
{ {
super.keyPressed(keyevent); super.handleKeyPressed(keyCode, keyChar, isControlDown, isShiftDown);
switch (keyevent.getKeyCode()) switch (keyCode)
{ {
case KeyEvent.VK_ESCAPE: case 27: // VK_ESCAPE
closeOpenInterfaces(); closeOpenInterfaces();
break; break;
case KeyEvent.VK_F1: case 112: // VK_F1
needDrawTabArea = true; needDrawTabArea = true;
tabID = 3; tabID = 3;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F2: case 113: // VK_F2
needDrawTabArea = true; needDrawTabArea = true;
tabID = 4; tabID = 4;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F3: case 114: // VK_F3
needDrawTabArea = true; needDrawTabArea = true;
tabID = 5; tabID = 5;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F4: case 115: // VK_F4
needDrawTabArea = true; needDrawTabArea = true;
tabID = 6; tabID = 6;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F5: case 116: // VK_F5
needDrawTabArea = true; needDrawTabArea = true;
tabID = 0; tabID = 0;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F6: case 117: // VK_F6
needDrawTabArea = true; needDrawTabArea = true;
tabID = 1; tabID = 1;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F7: case 118: // VK_F7
needDrawTabArea = true; needDrawTabArea = true;
tabID = 2; tabID = 2;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F8: case 119: // VK_F8
needDrawTabArea = true; needDrawTabArea = true;
tabID = 8; tabID = 8;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F9: case 120: // VK_F9
needDrawTabArea = true; needDrawTabArea = true;
tabID = 11; tabID = 11;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F10: case 121: // VK_F10
needDrawTabArea = true; needDrawTabArea = true;
tabID = 12; tabID = 12;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F11: case 122: // VK_F11
needDrawTabArea = true; needDrawTabArea = true;
tabID = 13; tabID = 13;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_F12: case 123: // VK_F12
needDrawTabArea = true; needDrawTabArea = true;
tabID = 10; tabID = 10;
tabAreaAltered = true; tabAreaAltered = true;
break; break;
case KeyEvent.VK_PAGE_UP: case 33: // VK_PAGE_UP
if (zoom > -1) { if (zoom > -1) {
zoom--; zoom--;
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) { if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
@@ -12719,7 +12711,7 @@ public class Game extends RSApplet {
} }
} }
break; break;
case KeyEvent.VK_PAGE_DOWN: case 34: // VK_PAGE_DOWN
if (zoom < (WorldController.drawDistance / 3)) { if (zoom < (WorldController.drawDistance / 3)) {
zoom++; zoom++;
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) { if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
@@ -12727,17 +12719,17 @@ public class Game extends RSApplet {
} }
} }
break; break;
case KeyEvent.VK_V: case 86: // VK_V
if (keyevent.isControlDown()) { if (isControlDown) {
inputString += getClipBoard(); inputString += getClipBoard();
if (inputString.length() > 80) { if (inputString.length() > 80) {
inputString = inputString.substring(0, 80); inputString = inputString.substring(0, 80);
} }
inputTaken = true; inputTaken = true;
} }
break;
} }
if (ClientSettings.SCREENSHOTS_ENABLED && keyevent.getKeyCode() == KeyEvent.VK_PRINTSCREEN && keyevent.isControlDown()) { if (ClientSettings.SCREENSHOTS_ENABLED && keyCode == 154 && isControlDown) {
screenshot(true); screenshot(true);
} }
} }
@@ -12908,13 +12900,8 @@ public class Game extends RSApplet {
tabAreaAltered = true; tabAreaAltered = true;
} }
public final void mouseWheelMoved(MouseWheelEvent e) { public void adjustZoom(int notches) {
int notches = e.getWheelRotation(); if (openInterfaceID == -1) {
if (ClientSettings.CONTROL_KEY_ZOOMING && !e.isControlDown()) {
return;
}
// If mouse over main game screen, without anything else opened
if (openInterfaceID == -1 && mouseX < 515 && mouseY < 340) {
if (notches < 0) { if (notches < 0) {
if (zoom > -1) { if (zoom > -1) {
zoom--; zoom--;
@@ -12933,26 +12920,180 @@ public class Game extends RSApplet {
} }
} }
public String getClipBoard(){ public void handleMouseWheel(int notches, boolean isControlDown) {
String myString = ""; if (!ClientSettings.ANDROID && ClientSettings.CONTROL_KEY_ZOOMING && !isControlDown) {
try { return;
myString = (String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
} catch (HeadlessException e) {
e.printStackTrace();
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} }
// If mouse over main game screen, without anything else opened
if (openInterfaceID == -1 && mouseX < 515 && mouseY < 340) {
adjustZoom(notches);
}
}
String output = ""; public String getClipBoard() {
for(int i = 0; i < myString.length(); i++) { if (ClientSettings.ANDROID) {
int j = (int) myString.charAt(i); return AndroidHooks.getClipBoard();
if (j >= 32 && j <= 122) { } else {
output += (char) j; return DesktopHooks.getClipBoard();
}
}
public boolean canDragItemAt(int x, int y) {
if (!loggedIn || menuOpen || itemSelected != 0 || spellSelected != 0) {
return false;
}
int prevMouseX = super.mouseX;
int prevMouseY = super.mouseY;
super.mouseX = x;
super.mouseY = y;
lastActiveInvInterface = -1;
mouseInvInterfaceIndex = -1;
processRightClick();
boolean canDrag = false;
if (lastActiveInvInterface != -1 && mouseInvInterfaceIndex != -1) {
RSInterface interf = RSInterface.interfaceCache[lastActiveInvInterface];
if (interf != null && (interf.aBoolean259 || interf.aBoolean235)
&& mouseInvInterfaceIndex >= 0 && mouseInvInterfaceIndex < interf.inv.length
&& interf.inv[mouseInvInterfaceIndex] > 0) {
canDrag = true;
}
}
super.mouseX = prevMouseX;
super.mouseY = prevMouseY;
return canDrag;
}
public boolean startItemDrag(int x, int y) {
if (!loggedIn || menuOpen || itemSelected != 0 || spellSelected != 0) {
return false;
}
super.mouseX = x;
super.mouseY = y;
lastActiveInvInterface = -1;
mouseInvInterfaceIndex = -1;
processRightClick();
if (lastActiveInvInterface != -1 && mouseInvInterfaceIndex != -1) {
RSInterface interf = RSInterface.interfaceCache[lastActiveInvInterface];
if (interf != null && (interf.aBoolean259 || interf.aBoolean235)
&& mouseInvInterfaceIndex >= 0 && mouseInvInterfaceIndex < interf.inv.length
&& interf.inv[mouseInvInterfaceIndex] > 0) {
aBoolean1242 = true;
anInt989 = 10;
anInt1084 = lastActiveInvInterface;
anInt1085 = mouseInvInterfaceIndex;
activeInterfaceType = 2;
anInt1087 = x;
anInt1088 = y;
if (openInterfaceID != -1 && interf.parentID == openInterfaceID) {
activeInterfaceType = 1;
}
if (backDialogID != -1 && interf.parentID == backDialogID) {
activeInterfaceType = 3;
}
super.clickMode2 = 1;
if (activeInterfaceType == 2) {
needDrawTabArea = true;
}
return true;
}
}
return false;
}
public boolean isScrollBarAt(int x, int y) {
if (!loggedIn) {
return false;
}
// 1. Chatbox scrollbar:
// Chat area is drawn at full screen x=17, y=357. Scrollbar thumb is at relative x=463, y=0, width 16, height 77.
// Screen coordinates: x in [480..496], y in [357..434].
if (backDialogID == -1) {
if (x >= 465 && x <= 512 && y >= 345 && y <= 445) {
return true;
} }
} }
return output; // 2. Full screen interface (e.g. cutscene / welcome screen)
if (fullScreenInterfaceId != -1) {
if (checkInterfaceScrollBar(fullScreenInterfaceId, 0, 0, x, y)) {
return true;
}
}
// 3. Open main interface (bank, shop, quest journal, etc.)
if (openInterfaceID != -1) {
if (checkInterfaceScrollBar(openInterfaceID, 4, 4, x, y)) {
return true;
}
}
// 4. Side tab / inventory overlay interface
if (invOverlayInterfaceID != -1) {
if (checkInterfaceScrollBar(invOverlayInterfaceID, 553, 205, x, y)) {
return true;
}
} else if (tabID >= 0 && tabID < tabInterfaceIDs.length && tabInterfaceIDs[tabID] != -1) {
if (checkInterfaceScrollBar(tabInterfaceIDs[tabID], 553, 205, x, y)) {
return true;
}
}
// 5. Chat dialogue interfaces (NPC chat, options, etc.)
if (backDialogID != -1) {
if (checkInterfaceScrollBar(backDialogID, 17, 357, x, y)) {
return true;
}
} else if (dialogID != -1) {
if (checkInterfaceScrollBar(dialogID, 17, 357, x, y)) {
return true;
}
}
return false;
}
private boolean checkInterfaceScrollBar(int interfaceId, int xOffset, int yOffset, int clickX, int clickY) {
if (interfaceId < 0 || interfaceId >= RSInterface.interfaceCache.length) {
return false;
}
RSInterface rsi = RSInterface.interfaceCache[interfaceId];
if (rsi == null) {
return false;
}
return checkInterfaceScrollBar(rsi, xOffset, yOffset, 0, clickX, clickY);
}
private boolean checkInterfaceScrollBar(RSInterface rsi, int i, int l, int scrollPos, int clickX, int clickY) {
if (rsi == null || rsi.children == null || rsi.aBoolean266) {
return false;
}
int count = rsi.children.length;
for (int idx = 0; idx < count; idx++) {
int childId = rsi.children[idx];
if (childId < 0 || childId >= RSInterface.interfaceCache.length) {
continue;
}
RSInterface child = RSInterface.interfaceCache[childId];
if (child == null || child.aBoolean266) {
continue;
}
int i2 = rsi.childX[idx] + i + child.anInt263;
int j2 = rsi.childY[idx] + l - scrollPos + child.anInt265;
if (child.type == 0) {
if (child.scrollMax > child.height) {
int sbX = i2 + child.width;
int sbY = j2;
int sbH = child.height;
// Standard scrollbar width is 16. Allow a touch-friendly margin around it
if (clickX >= sbX - 10 && clickX <= sbX + 26 && clickY >= sbY - 5 && clickY <= sbY + sbH + 5) {
return true;
}
}
if (checkInterfaceScrollBar(child, i2, j2, child.scrollPosition, clickX, clickY)) {
return true;
}
}
}
return false;
} }
} }
+1 -83
View File
@@ -13,90 +13,8 @@ public final class Main {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
// Process client arguments to connect to
for (int i = 0; i < args.length; i++) {
switch(args[i]) {
case "-dev" :
case "-local":
case "-offline":
ClientSettings.SERVER_IP = "localhost";
ClientSettings.CHECK_CRC = false;
break;
case "-no-crc":
case "-no-cache-crc":
ClientSettings.CHECK_CRC = false;
break;
case "-qol":
case "-fixes":
ClientSettings.CUSTOM_SETTINGS_TAB = true;
ClientSettings.BILINEAR_MINIMAP_FILTERING = true;
ClientSettings.FIX_TRANSPARENCY_OVERFLOW = true;
ClientSettings.FULL_512PX_VIEWPORT = true;
ClientSettings.CONTROL_KEY_ZOOMING = true;
break;
case "-no-nav":
case "-disable-nav":
ClientSettings.SHOW_NAVBAR = false;
break;
case"-no-snow":
case"-hide-snow":
case"-disable-snow":
ClientSettings.SNOW_FLOOR_ENABLED = false;
ClientSettings.SNOW_FLOOR_FORCE_ENABLED = false;
ClientSettings.SNOW_OVERLAY_FORCE_ENABLED = false;
ClientSettings.SNOW_OVERLAY_ENABLED = false;
break;
case"-no-roofs":
case"-hide-roofs":
case"-disable-roofs":
ClientSettings.HIDE_ROOFS = true;
break;
case"-show-zoom":
ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES = true;
break;
case"-screenshots":
case"-enable-screenshots":
ClientSettings.SCREENSHOTS_ENABLED = true;
break;
case"-auto-screenshots":
case"-enable-auto-screenshots":
ClientSettings.AUTOMATIC_SCREENSHOTS_ENABLED = true;
break;
}
if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) {
switch(args[i]) {
case "-s":
case "-server":
case "-ip":
ClientSettings.SERVER_IP = args[++i];
break;
}
}
}
Game game = new Game(); Game game = new Game();
ClientArgs.apply(args, game);
// Process other arguments
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) {
switch(args[i]) {
case "-u":
case "-user":
case "-username":
game.myUsername = args[++i];
break;
case "-p":
case "-pass":
case "-password":
game.myPassword = args[++i];
break;
case "-w":
case "-world":
ClientSettings.SERVER_WORLD = Integer.parseInt(args[++i]);
break;
}
}
}
Game.nodeID = 10; Game.nodeID = 10;
Game.portOff = 0; Game.portOff = 0;
+13 -14
View File
@@ -479,22 +479,16 @@ public class RSApplet extends Applet implements Runnable, MouseListener, MouseWh
} }
@Override @Override
public void mouseWheelMoved(MouseWheelEvent e) {} public void mouseWheelMoved(MouseWheelEvent e) {
handleMouseWheel(e.getWheelRotation(), e.isControlDown());
}
@Override public void handleMouseWheel(int notches, boolean isControlDown) {}
public void keyPressed(KeyEvent keyevent) {
public void handleKeyPressed(int i, int j, boolean isCtrl, boolean isShift) {
idleTime = 0; idleTime = 0;
int i = keyevent.getKeyCode(); if (isShift) shiftDown = true;
int j = keyevent.getKeyChar(); if (isCtrl) ctrlDown = true;
switch (keyevent.getKeyCode())
{
case KeyEvent.VK_SHIFT:
shiftDown = true;
break;
case KeyEvent.VK_CONTROL:
ctrlDown = true;
break;
}
if (j < 30) { if (j < 30) {
j = 0; j = 0;
} }
@@ -549,6 +543,11 @@ public class RSApplet extends Applet implements Runnable, MouseListener, MouseWh
} }
} }
@Override
public void keyPressed(KeyEvent keyevent) {
handleKeyPressed(keyevent.getKeyCode(), keyevent.getKeyChar(), keyevent.isControlDown(), keyevent.isShiftDown());
}
@Override @Override
public final void keyReleased(KeyEvent keyevent) { public final void keyReleased(KeyEvent keyevent) {
idleTime = 0; idleTime = 0;
@@ -0,0 +1,15 @@
/**
* Platform-independent RGB/ARGB color constants for DrawingArea and RS2 rendering.
*/
public final class RSColors {
public static final int WHITE = 0xffffff;
public static final int BLACK = 0x000000;
public static final int YELLOW = 0xffff00;
public static final int GREEN = 0x00ff00;
public static final int CYAN = 0x00ffff;
public static final int ORANGE = 0xffc800;
public static final int RED = 0xff0000;
public static final int WHITE_DARKER = 0xc0c0c0;
private RSColors() {}
}
+27 -138
View File
@@ -1,4 +1,3 @@
import java.applet.Applet;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@@ -8,21 +7,6 @@ import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import java.net.URL; import java.net.URL;
import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.Synthesizer;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
public final class Signlink implements Runnable { public final class Signlink implements Runnable {
public static final void startpriv(InetAddress inetaddress) { public static final void startpriv(InetAddress inetaddress) {
@@ -101,60 +85,19 @@ public final class Signlink implements Runnable {
if (waveplay) { if (waveplay) {
String wave = s + saveReq; String wave = s + saveReq;
waveplay = false; waveplay = false;
AudioInputStream audioInputStream = null; if (ClientSettings.ANDROID) {
try { AndroidHooks.playSound(savebuf, 0, savelen, wavevol, 0);
audioInputStream = AudioSystem.getAudioInputStream(new File(wave)); } else {
} catch (UnsupportedAudioFileException e1) { DesktopHooks.playSound(savebuf, 0, savelen, wavevol, 0);
e1.printStackTrace();
return;
} catch (IOException e1) {
e1.printStackTrace();
return;
}
AudioFormat format = audioInputStream.getFormat();
SourceDataLine auline = null;
DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
try {
auline = (SourceDataLine) AudioSystem.getLine(info);
auline.open(format);
} catch (LineUnavailableException e) {
e.printStackTrace();
return;
} catch (Exception e) {
e.printStackTrace();
return;
}
if (auline.isControlSupported(FloatControl.Type.PAN)) {
FloatControl pan = (FloatControl) auline.getControl(FloatControl.Type.PAN);
if (curPosition == Position.RIGHT)
pan.setValue(1.0f);
else if (curPosition == Position.LEFT)
pan.setValue(-1.0f);
}
auline.start();
int nBytesRead = 0;
byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
try {
while (nBytesRead != -1) {
nBytesRead = audioInputStream.read(abData, 0,
abData.length);
if (nBytesRead >= 0)
auline.write(abData, 0, nBytesRead);
}
} catch (IOException e) {
e.printStackTrace();
return;
} finally {
auline.drain();
auline.close();
} }
} }
if (play) { if (play) {
midi = s + saveReq; midi = s + saveReq;
try { try {
if (music != null) { if (ClientSettings.ANDROID) {
music.stop(); AndroidHooks.stopMidi();
music.close(); } else {
DesktopHooks.stopSignlinkMidi();
} }
playMidi(midi); playMidi(midi);
} catch (Exception ex) { } catch (Exception ex) {
@@ -166,7 +109,7 @@ public final class Signlink implements Runnable {
} else if (urlreq != null) { } else if (urlreq != null) {
try { try {
System.out.println("urlstream"); System.out.println("urlstream");
urlstream = new DataInputStream((new URL(mainapp.getCodeBase(), urlreq)).openStream()); urlstream = new DataInputStream((new URL(new URL("http://127.0.0.1"), urlreq)).openStream());
} catch (Exception _ex) { } catch (Exception _ex) {
urlstream = null; urlstream = null;
} }
@@ -184,39 +127,11 @@ public final class Signlink implements Runnable {
* @param location * @param location
*/ */
private void playMidi(String location) { private void playMidi(String location) {
music = null; if (ClientSettings.ANDROID) {
synthesizer = null; AndroidHooks.playMidi(location, midiVolume);
sequence = null;
File midiFile = new File(location);
try {
sequence = MidiSystem.getSequence(midiFile);
music = MidiSystem.getSequencer();
music.open();
music.setSequence(sequence);
} catch (Exception e) {
System.err.println("Problem loading MIDI file.");
e.printStackTrace();
return;
}
if (music instanceof Synthesizer) {
synthesizer = (Synthesizer) music;
} else { } else {
try { DesktopHooks.playSignlinkMidi(location, midiVolume);
synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
if (synthesizer.getDefaultSoundbank() == null) {
music.getTransmitter().setReceiver(MidiSystem.getReceiver());
} else {
music.getTransmitter().setReceiver(synthesizer.getReceiver());
}
} catch (Exception e) {
e.printStackTrace();
return;
}
} }
music.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
music.start();
setVolume(midiVolume);
} }
/** /**
@@ -224,36 +139,12 @@ public final class Signlink implements Runnable {
* @param value * @param value
*/ */
public static boolean setVolume(int value) { public static boolean setVolume(int value) {
if (synthesizer == null) {
return false;
}
int CHANGE_VOLUME = 7;
midiVolume = value; midiVolume = value;
if (synthesizer.getDefaultSoundbank() == null) { if (ClientSettings.ANDROID) {
try { return AndroidHooks.setMidiVolume(value);
ShortMessage volumeMessage = new ShortMessage();
for (int i = 0; i < 16; i++) {
volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, i, CHANGE_VOLUME, midiVolume);
volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, i, 39, midiVolume);
MidiSystem.getReceiver().send(volumeMessage, -1);
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
} else { } else {
try { return DesktopHooks.setSignlinkVolume(value);
MidiChannel[] channels = synthesizer.getChannels();
for (int c = 0; channels != null && c < channels.length; c++) {
channels[c].controlChange(CHANGE_VOLUME, midiVolume);
channels[c].controlChange(39, midiVolume);
}
} catch (Exception e){
e.printStackTrace();
return false;
}
} }
return true;
} }
/** /**
@@ -261,23 +152,21 @@ public final class Signlink implements Runnable {
* Stops the current midi playing. * Stops the current midi playing.
*/ */
public static void fadeOut() { public static void fadeOut() {
if (music == null) { if (ClientSettings.ANDROID) {
return; AndroidHooks.stopMidi();
} } else {
int volume = midiVolume; DesktopHooks.stopSignlinkMidi();
if (music.isRunning()) {
for (int index = midiVolume; index > 0 && volume > 0; index--) {
volume--;
setVolume(volume);
}
} }
} }
public static Sequencer music = null; public static Object music = null;
public static Sequence sequence = null; public static Object sequence = null;
public static Synthesizer synthesizer = null; public static Object synthesizer = null;
public static String findcachedir() { public static String findcachedir() {
if (ClientSettings.ANDROID) {
return AndroidHooks.getCacheDir();
}
String path = System.getProperty("user.home") + "/.2006Scape_file_system/"; String path = System.getProperty("user.home") + "/.2006Scape_file_system/";
File file = new File(path); File file = new File(path);
if (!file.exists()) { if (!file.exists()) {
@@ -389,7 +278,7 @@ public final class Signlink implements Runnable {
public static RandomAccessFile cache_dat = null; public static RandomAccessFile cache_dat = null;
public static final RandomAccessFile[] cache_idx = new RandomAccessFile[5]; public static final RandomAccessFile[] cache_idx = new RandomAccessFile[5];
public static boolean sunjava; public static boolean sunjava;
public static Applet mainapp = null; public static Object mainapp = null;
private static boolean active; private static boolean active;
private static int threadliveid; private static int threadliveid;
private static InetAddress socketip; private static InetAddress socketip;
@@ -403,7 +292,7 @@ public final class Signlink implements Runnable {
private static DataInputStream urlstream = null; private static DataInputStream urlstream = null;
public static boolean reporterror = true; public static boolean reporterror = true;
public static String errorname = ""; public static String errorname = "";
public static Midi midii = new Midi(); public static Object midii = null;
private static int savelen; private static int savelen;
private static String saveReq = null; private static String saveReq = null;
private static byte savebuf[] = null; private static byte savebuf[] = null;
+11 -27
View File
@@ -2,12 +2,6 @@
// Jad home page: http://www.kpdus.com/jad.html // Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) // Decompiler options: packimports(3)
import java.awt.Component;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.image.PixelGrabber;
public final class Sprite extends DrawingArea { public final class Sprite extends DrawingArea {
public Sprite(int i, int j) { public Sprite(int i, int j) {
@@ -17,25 +11,15 @@ public final class Sprite extends DrawingArea {
anInt1442 = anInt1443 = 0; anInt1442 = anInt1443 = 0;
} }
public Sprite(byte abyte0[], Component component) { public Sprite(byte abyte0[]) {
try { this(abyte0, null);
// Image image = }
// Toolkit.getDefaultToolkit().getImage(signlink.findcachedir()+"mopar.jpg");
Image image = Toolkit.getDefaultToolkit().createImage(abyte0); public Sprite(byte abyte0[], Object component) {
MediaTracker mediatracker = new MediaTracker(component); if (ClientSettings.ANDROID) {
mediatracker.addImage(image, 0); AndroidHooks.decodeImage(this, abyte0);
mediatracker.waitForAll(); } else {
width = image.getWidth(component); DesktopHooks.decodeImage(this, abyte0, component);
height = image.getHeight(component);
trimWidth = width;
trimHeight = height;
anInt1442 = 0;
anInt1443 = 0;
pixels = new int[width * height];
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width);
pixelgrabber.grabPixels();
} catch (Exception _ex) {
System.out.println("Error converting jpg");
} }
} }
@@ -533,8 +517,8 @@ public final class Sprite extends DrawingArea {
public int pixels[]; public int pixels[];
public int width; public int width;
public int height; public int height;
private int anInt1442; int anInt1442;
private int anInt1443; int anInt1443;
public int trimWidth; public int trimWidth;
public int trimHeight; public int trimHeight;
} }
+1
Submodule 2006Scape-Android added at d0627d9d8d.
+15 -1
View File
@@ -36,7 +36,21 @@ java -jar Parabot.jar -local
- `2006Scape Server` contains all the server code; mark `src` as the Sources directory - `2006Scape Server` contains all the server code; mark `src` as the Sources directory
- `2006Scape Client` contains all the client code; likewise mark `src` - `2006Scape Client` contains all the client code; likewise mark `src`
- If more than 2 arguments are passed in (can be anything), the client runs locally - If more than 2 arguments are passed in (can be anything), the client runs locally
- `2006Scape-Android` contains the native Android client port (Git submodule, Gradle project)
## Building from command line ## Building from command line
Run `mvn -B clean install` ### Desktop (Server & Client)
Run:
```bash
mvn -B clean install
```
### Android Client APK
Run:
```bash
cd 2006Scape-Android
./gradlew assembleDebug
```
The resulting debug APK is output to `app/build/outputs/apk/debug/app-debug.apk`.