Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Copy everything in the following tag..
- *
- * //COPY
- * this is what you will copy..
- * //ENDCOPY
- */
- import java.awt.*;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.LinkedList;
- import javax.imageio.ImageIO;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.*;
- import org.rsbot.script.methods.Skills;
- @ScriptManifest(authors = {"Dew"}, keywords = {"Paint"}, name = "FuserPAINT", description = "Demo Paint - To Be Edited", version = 1.0)
- public class paintforubuntu extends Script implements PaintListener, MouseListener {
- //COPY - these are needed variables
- public long startTime = 0, millis = 0, hours = 0, minutes = 0, seconds = 0;
- public Double ver = getClass().getAnnotation(ScriptManifest.class).version();
- Point p;
- private int startXP = 0;
- private int XPGained = 0;
- public boolean showPaint = true;
- private String Status = "Setting up";
- public MousePaint mousePaint = new MousePaint();
- public Image fuserScriptsLogo, userLogo, paintBackGround, closeButton, openButton, Avatar;
- //ENDCOPY
- //COPY
- Color Color1 = new Color(255, 255, 255),
- Transparent = new Color(255, 255, 255, 0);
- Font Font1 = new Font("Calibri", 1, 14),
- Font2 = new Font("Calibri", 0, 14),
- Font3 = new Font("Calibri", 0, 9);
- //ENDCOPY
- //COPY -These are needed to make the image links work
- Rectangle fuserScriptsLogoRectangle = new Rectangle(4, 276, 207, 69),
- userLogoRectangle = new Rectangle(9, 347, 124, 28),
- closeButtonRectangle = new Rectangle(426, 345, 22, 22),
- openButtonRectangle = new Rectangle(474, 345, 22, 22),
- avatarRectangle = new Rectangle(448, 345, 65, 65);
- //ENDCOPY
- @Override
- public boolean onStart() {
- //COPY -these are the images to load
- // (CHANGE}url to the user avatar spot - Your Avatar HERE - MAKE
- // SURE the pixel ratio is 65x65px
- Avatar = getImage("http://i.imgur.com/XaXmd.png");
- // (CHANGE)URL to the user logo spot - Your Logo HERE - MAKE
- // SURE the pixel ratio is 124x28px
- userLogo = getImage("http://i.imgur.com/yzKFM.png");
- fuserScriptsLogo = getImage("http://i.imgur.com/yzKFM.png");
- paintBackGround = getImage("http://i.imgur.com/9vt7j.png");
- closeButton = getImage("http://i.imgur.com/RqFu8.png");
- openButton = getImage("http://i.imgur.com/OPMSU.png");
- //ENDCOPY
- return true;
- }
- //COPY
- private Image getImage(final String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (final IOException e) {
- return null;
- }
- }
- //ENDCOPY
- //COPY -- this is the actual paint itself
- // <editor-fold defaultstate="collapsed" desc="Paint">
- private final RenderingHints renderHints = new RenderingHints(
- RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- public void mainPaint(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- // (CHANGE) Change the skill.
- if ((skills.getCurrentExp(Skills.CONSTRUCTION) - startExperience) > 0
- && startExperience > 0) {
- experienceGained = skills.getCurrentExp(Skills.CONSTRUCTION)
- - startExperience;
- }
- long millis = System.currentTimeMillis() - startTime;
- long totalseconds = millis / 1000;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * 1000 * 60 * 60;
- long minutes = millis / (1000 * 60);
- millis -= minutes * 1000 * 60;
- long seconds = millis / 1000;
- if (showPaint) {
- g2.drawImage(fuserScriptsLogo, 4, 276, null);
- g2.drawImage(paintBackGround, -1, 328, null);
- g2.drawImage(userLogo, 9, 347, null);
- g2.drawImage(closeButton, 426, 345, null);
- g2.drawImage(Avatar, 448, 345, null);
- g2.setColor(Constants.Transparent);
- g2.draw(Constants.fuserScriptsLogoRectangle);
- g2.draw(Constants.closeButtonRectangle);
- g2.draw(Constants.userLogoRectangle);
- g2.setColor(Constants.Color1);
- // START - current script version text
- g2.setFont(Constants.Font1);
- g2.drawString("Current Script Version:", 197, 358);
- g2.setFont(Constants.Font2);
- g2.drawString(
- ""
- + getClass().getAnnotation(ScriptManifest.class).version(), 335, 358);
- // END - current script version text
- // EDIT - Close Button Text - Remove or leave
- //g2.setFont(Constants.Font3);
- //g2.drawString("Close Button:", 373, 353);
- // EDIT - End of Close Button Text
- // START - Run Time
- g2.setFont(Constants.Font1);
- g2.drawString("Run Time:", 14, 400);
- g2.setFont(Constants.Font2);
- if (startTime != 0) {
- g2.drawString(hours + " Hours " + minutes + " Minutes "
- + seconds + " Seconds", 121, 400);
- } else {
- g2.drawString("Script loading...", 121, 400);
- }
- // END - Run Time
- // START - Experience
- if (experienceGained > 0 && totalseconds > 0) {
- g2.setFont(Constants.Font1);
- g2.drawString("Total Xp Gained:", 12, 431);
- g2.setFont(Constants.Font2);
- g2.drawString("" + experienceGained, 120, 431);
- g2.setFont(Constants.Font1);
- g2.drawString("Xp/hr:", 10, 462);
- g2.setFont(Constants.Font2);
- experiencePerHour = (int) (3600 * experienceGained / totalseconds);
- g2.drawString("" + experiencePerHour, 119, 464);
- //CHANGE, uncomment calculations if needed
- // runesPerHour = (int) (3600*runesMade/totalseconds);
- // essensePerHour = (int)
- // (3600*((int)((expGained)/runeExp))/totalseconds);
- // totalProfit = (long)
- // ((runesMade*runePrice)-(essenceCount*essencePrice));
- // profitPerHour = (long) (3600*totalProfit/totalseconds);
- }
- // END - Experience
- // START - Time to Next Level
- long timeToLevel = 0;
- g2.setFont(Constants.Font1);
- g2.drawString("Time to Next Level:", 340, 454);
- g2.setFont(Constants.Font2);
- String timeToLevel2 = "Calculating...";
- g2.drawString(timeToLevel2, 454, 454);
- if (experiencePerHour > 0) {
- g2.setFont(Constants.Font2);
- timeToLevel = (skills.getExpToNextLevel(Skills.CONSTRUCTION) * 60 / experiencePerHour);
- if (timeToLevel >= 60) {
- long thours = (int) timeToLevel / 60;
- long tmin = (timeToLevel - (thours * 60));
- timeToLevel2 = thours + " Hours, " + tmin + " Minutes";
- } else {
- timeToLevel2 = timeToLevel + " Minutes";
- }
- }
- // END - Time to Next Level
- // START - Script Status
- g2.setFont(Constants.Font1);
- g2.drawString("Script Status:", 200, 473);
- g2.setFont(Constants.Font2);
- g2.drawString(Status, 283, 474);
- // END - Script Status
- } else {
- g2.setColor(Constants.Transparent);
- g2.draw(Constants.openButtonRectangle);
- g2.drawImage(openButton, 474, 345, null);
- }
- }
- @Override
- public void onRepaint(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g2.setRenderingHints(renderHints);
- mainPaint(g2);
- mousePaint.Draw(g2);
- }
- // </editor-fold>
- //END
- //COPY -- this is needed to make links work
- // <editor-fold defaultstate="collapsed" desc="mouseClicked">
- @Override
- public void mouseClicked(MouseEvent mouseEvent) {
- Point mousePoint = mouseEvent.getPoint();
- if (Constants.fuserScriptsLogoRectangle.contains(mousePoint)
- && showPaint) {
- sendToURL("http://fuserscripts.cz.cc/community/");
- } else if (Constants.userLogoRectangle.contains(mousePoint)
- && showPaint) {
- log("Currently, the Thread is not active! Please wait until I update this.");
- // sendToURL("http://fuserscripts.cz.cc/community/index.php?/topic/76-fuserpaint-skeleton/");
- } else if (Constants.avatarRectangle.contains(mousePoint) && showPaint) {
- sendToURL("http://fuserscripts.cz.cc/community/index.php?/user/19-dew/");
- } else if (Constants.closeButtonRectangle.contains(mousePoint)
- && showPaint) {
- showPaint = false;
- } else if (Constants.openButtonRectangle.contains(mousePoint)
- && !showPaint) {
- showPaint = true;
- }
- }
- public void sendToURL(String url) {
- try {
- java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
- } catch (Exception exception) {
- log("[ERROR]SendToURL: " + exception.getLocalizedMessage());
- }
- }
- @Override
- public void mouseEntered(MouseEvent e) {
- }
- @Override
- public void mouseExited(MouseEvent e) {
- }
- @Override
- public void mousePressed(MouseEvent e) {
- }
- @Override
- public void mouseReleased(MouseEvent e) {
- }
- // </editor-fold>
- //ENDCOPY
- //COPY -- this is the mouse stuff.
- // <editor-fold defaultstate="collapsed" desc="MousePaint">
- public class MousePaint {
- public int waveSize = 0;
- @SuppressWarnings({"serial"})
- public class mousePathPoint extends Point {
- private long finishTime;
- private double lastingTime;
- public mousePathPoint(int x, int y, int lastingTime) {
- super(x, y);
- this.lastingTime = lastingTime;
- finishTime = System.currentTimeMillis() + lastingTime;
- }
- public boolean isUp() {
- return System.currentTimeMillis() > finishTime;
- }
- }
- public double getRot(int ticks) {
- return (System.currentTimeMillis() % (360 * ticks)) / ticks;
- }
- public LinkedList<mousePathPoint> mousePath = new LinkedList<mousePathPoint>();
- public void drawTrail(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g2.setStroke(new BasicStroke(1));
- while (!mousePath.isEmpty() && mousePath.peek().isUp()) {
- mousePath.remove();
- }
- Point clientCursor = mouse.getLocation();
- mousePathPoint mpp = new mousePathPoint(clientCursor.x,
- clientCursor.y, 250);
- if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) {
- mousePath.add(mpp);
- }
- mousePathPoint lastPoint = null;
- for (mousePathPoint a : mousePath) {
- if (lastPoint != null) {
- long mpt = System.currentTimeMillis()
- - mouse.getPressTime();
- if (mouse.getPressTime() == -1 || mpt >= 250) {
- g2.setColor(Color.GREEN);
- }
- if (mpt < 250) {
- g2.setColor(Color.RED);
- }
- g2.drawLine(a.x, a.y, lastPoint.x, lastPoint.y);
- }
- lastPoint = a;
- }
- }
- public void drawMouse(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g2.setRenderingHints(new RenderingHints(
- RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON));
- g2.setStroke(new BasicStroke(3));
- g2.setColor(Color.BLACK);
- g2.drawOval(mouse.getLocation().x - 13, mouse.getLocation().y - 13,
- 25, 25);
- g2.setStroke(new BasicStroke(1));
- g2.setColor(new Color(0, 0, 0, 114));
- g2.fillOval(mouse.getLocation().x - 13, mouse.getLocation().y - 13,
- 25, 25);
- Point MouseLocation = mouse.getLocation();
- long mpt = System.currentTimeMillis() - mouse.getPressTime();
- g2.rotate(Math.toRadians(getRot(5)), mouse.getLocation().x,
- mouse.getLocation().y);
- if (mouse.getPressTime() == -1 || mpt >= 250) {
- g2.setColor(Color.GREEN);
- g2.drawLine(MouseLocation.x - 5, MouseLocation.y,
- MouseLocation.x + 5, MouseLocation.y);
- g2.drawLine(MouseLocation.x, MouseLocation.y - 5,
- MouseLocation.x, MouseLocation.y + 5);
- }
- if (mpt < 250) {
- g2.setColor(Color.RED);
- g2.drawLine(MouseLocation.x - 5, MouseLocation.y,
- MouseLocation.x + 5, MouseLocation.y);
- g2.drawLine(MouseLocation.x, MouseLocation.y - 5,
- MouseLocation.x, MouseLocation.y + 5);
- }
- }
- public void drawWave(Graphics g, Color color) {
- Graphics2D g2 = (Graphics2D) g;
- Point MouseLoc = mouse.getPressLocation();
- long mpt = System.currentTimeMillis() - mouse.getPressTime();
- g2.setRenderingHints(new RenderingHints(
- RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON));
- g2.setColor(color);
- if (mpt < 1000) {
- waveSize = (int) (mpt / 7.5);
- } else {
- waveSize = 0;
- }
- g2.setStroke(new BasicStroke(3));
- g2.drawOval(MouseLoc.x - (waveSize / 2), MouseLoc.y
- - (waveSize / 2), waveSize, waveSize);
- g2.drawOval(MouseLoc.x - ((waveSize / 2) / 2), MouseLoc.y
- - ((waveSize / 2) / 2), waveSize / 2, waveSize / 2);
- }
- public void Draw(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g2.setRenderingHints(new RenderingHints(
- RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON));
- drawWave(g2, Color.BLACK);
- drawTrail(g2);
- drawMouse(g2);
- }
- }
- // </editor-fold>
- //ENDCOPY
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement