Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @auther Dew of FuserScripts
- * @Since July 22, 2011
- * @Version 1.0
- */
- import java.awt.*;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.image.BufferedImage;
- import java.awt.image.ImageObserver;
- import java.io.IOException;
- import java.lang.reflect.InvocationTargetException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.LinkedList;
- import javax.imageio.ImageIO;
- import javax.swing.SwingUtilities;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.*;
- import org.rsbot.script.methods.Methods;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.wrappers.*;
- @ScriptManifest(authors = {"Dew"}, keywords = {"Paint"}, name = "FuserPAINT", description = "Demo Paint - To Be Edited", version = 1.0)
- public class FuserPaint extends Script implements PaintListener, MouseListener {
- public String paintType = "null";
- public boolean GuiIsOpen = true;
- FuserGui gui = new FuserGui();
- //REPLACE FuserPaint with your ScriptName
- public Double ver = FuserPaint.class.getAnnotation(ScriptManifest.class).version();
- Point p;
- public long startTime = 0;
- public long millis = 0;
- public long hours = 0;
- public long minutes = 0;
- public long seconds = 0;
- //EDIT - as needed
- private int itemsCollected = 0;
- private int itemsHr = 0;
- private int price = 0;
- private int priceHr = 0;
- private int startXP = 0;
- private int XPGained = 0;
- public int itemPrice;
- public boolean showPaint = true;
- BufferedImage normal = null;
- BufferedImage clicked = null;
- //EDIT - This is the cursor. if you like the current cursor, let it be, otherwise,
- //EDIT - upload your own cursor and place the URLs in the following Strings
- /**
- * Not clicked Cursor ID
- */
- public String cursorU = "http://i360.photobucket.com/albums/oo47/perez048/mouseReg.png";
- /**
- * Clicked Cursor ID
- */
- public String cursorC = "http://i360.photobucket.com/albums/oo47/perez048/mouseClicked.png";
- private String status = "Setting up";
- //(CHANGE)REMOVE? - This String is used in my custom mouse speed changer.
- //(CHANGE)REMOVE? - leave this alone if you are going to use it.
- private String MouseSpeed = "Unknown";
- private final Image FuserScriptsLogo = getImage("http://ghostgraphics.net78.net/fuserscripts/template/fuserscriptslogo.png");
- Rectangle FuserScriptsLogoShape = new Rectangle(4, 276, 207, 69);
- //(CHANGE)URL to the user logo spot - Your Logo HERE - MAKE SURE the pixel ratio is 124x28px
- private final Image userLogo = getImage("http://ghostgraphics.net78.net/fuserscripts/template/logohere.png");
- Rectangle userLogoShape = new Rectangle(9, 347, 124, 28);
- private final Image paintBG = getImage("http://ghostgraphics.net78.net/fuserscripts/template/paintbg.png");
- private final Image closeButton = getImage("http://ghostgraphics.net78.net/fuserscripts/template/closebutton.png");
- Rectangle closeButtonShape = new Rectangle(426, 345, 22, 22);
- private final Image openButton = getImage("http://ghostgraphics.net78.net/fuserscripts/template/openbutton.png");
- Rectangle openButtonShape = new Rectangle(474, 345, 22, 22);
- //(CHANGE)URL to the avatar spot - Your Avatar HERE - MAKE SURE the pixel ratio is 65x65px
- private final Image avatarSpot = getImage("http://ghostgraphics.net78.net/fuserscripts/template/avatarspot.png");
- Rectangle avatarSpotShape = new Rectangle(448, 345, 65, 65);
- @Override
- public boolean onStart() {
- try {
- SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- new FuserGui().setVisible(true);
- }
- });
- } catch (InterruptedException ignored) {
- } catch (InvocationTargetException ignored) {
- }
- while (GuiIsOpen) {
- Methods.sleep(25);
- }
- //EDIT - Change Skills.SMITHING
- //EDIT - to the skill needed
- startXP = skills.getCurrentExp(Skills.SMITHING);
- startTime = System.currentTimeMillis();
- try {
- final URL cursorURL = new URL(cursorU);
- final URL cursor80URL = new URL(cursorC);
- normal = ImageIO.read(cursorURL);
- clicked = ImageIO.read(cursor80URL);
- } catch (MalformedURLException e) {
- log("Unable to buffer cursor.");
- } catch (IOException e) {
- log("Unable to open cursor image.");
- }
- paintType = gui.paintType.getSelectedItem().toString();
- return true;
- }
- public int loop() {
- return random(1000,1500);
- }
- @Override
- public void onFinish() {
- }
- //START: Code generated using Enfilade's Easel
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(255, 255, 255);
- private final Color transparent = new Color(255, 255, 255, 0);
- private final Font font1 = new Font("Calibri", 1, 14);
- private final Font font2 = new Font("Calibri", 0, 14);
- private final Font font3 = new Font("Calibri", 0, 9);
- public void mainPaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- if (paintType.equals("Chatbox Paint")) {
- // <editor-fold defaultstate="collapsed" desc="ChatBox Paint">
- // <editor-fold defaultstate="collapsed" desc="Variables">
- //START - Time - DO NOT EDIT
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- //END - Time - DO NOT EDIT
- //(CHANGE)START - Time to Next Level - EDIT where told
- float xpsec = 0;
- if (minutes > 0 || hours > 0 || seconds > 0 && XPGained > 0) {
- xpsec = ((float) XPGained / (float) (seconds + (minutes * 60) + (hours * 60 * 60)));
- }
- float xpmin = xpsec * 60;
- float xphour = xpmin * 60;
- //(CHANGE)EDIT - Skills.SMITHING
- //(CHANGE)EDIT - Change to the skill needed
- float timeTNLhour = 0;
- timeTNLhour = (float) skills.getExpToNextLevel(Skills.SMITHING) / (float) xphour;
- float timeTNLmin = timeTNLhour * 60;
- float timeTNLsec = timeTNLmin * 60;
- float estimatedHour = timeTNLsec / 3600;
- float tempminutes = timeTNLsec % 3600;
- float estimatedMinutes = tempminutes / 60;
- float estimatedSeconds = tempminutes % 60;
- //END - Time to Next Level - EDIT where told
- //(CHANGE)START - XPGained - EDIT Skills.SMITHING
- XPGained = skills.getCurrentExp(Skills.SMITHING) - startXP;
- //END - XPGained - Edit as needed
- //START - xphour - DO NOT EDIT
- xphour = (int) ((XPGained) * 3600000D / (System.currentTimeMillis() - startTime));
- //END - xphour - DO NOT EDIT
- // </editor-fold>
- if (showPaint) {
- // <editor-fold defaultstate="collapsed" desc="PaintOpen">
- g.drawImage(FuserScriptsLogo, 4, 276, null);
- g.drawImage(paintBG, -1, 328, null);
- g.drawImage(userLogo, 9, 347, null);
- g.drawImage(closeButton, 426, 345, null);
- g.drawImage(avatarSpot, 448, 345, null);
- g.setColor(transparent);
- g.draw(FuserScriptsLogoShape);
- g.draw(closeButtonShape);
- g.draw(userLogoShape);
- g.setColor(color1);
- //START - current script version text
- g.setFont(font1);
- g.drawString("Current Script Version:", 197, 358);
- g.setFont(font2);
- g.drawString("" + ver, 335, 358); //this will automatically grab the script version from the manifest
- //END - current script version text
- //EDIT - Close Button Text - Remove or leave
- g.setFont(font3);
- g.drawString("Close Button:", 373, 353);
- //EDIT - End of Close Button Text
- //START - Run Time
- g.setFont(font1);
- g.drawString("Run Time:", 14, 400);
- g.setFont(font2);
- g.drawString("" + hours + ":" + minutes + ":" + seconds, 121, 400); //sets the time automatically
- //END - Run Time
- //START - Total Xp Gained
- g.setFont(font1);
- g.drawString("Total Xp Gained:", 12, 431);
- g.setFont(font2);
- g.drawString("" + XPGained, 120, 431);
- //END - Total Xp Gained
- //START - Total Xp/hr
- g.setFont(font1);
- g.drawString("Total Xp/hr:", 10, 462);
- g.setFont(font2);
- g.drawString("" + xphour, 119, 464);
- //END - Total Xp/hr
- //START - Time to Next Level
- g.setFont(font1);
- g.drawString("Time to Next Level:", 340, 454);
- g.setFont(font2);
- g.drawString("" + (int) estimatedHour + ":" + (int) estimatedMinutes + ":" + (int) estimatedSeconds, 454, 454);
- //END - Time to Next Level
- //START - Script Status
- g.setFont(font1);
- g.drawString("Script Status:", 200, 473);
- g.setFont(font2);
- g.drawString("" + status, 283, 474);
- //END - Script Status
- // </editor-fold>
- } else {
- // <editor-fold defaultstate="collapsed" desc="PaintHidden">
- g.setColor(transparent);
- g.draw(openButtonShape);
- g.drawImage(openButton, 474, 345, null);
- // </editor-fold>
- }
- // </editor-fold>
- } else {
- log("[ERROR]Paint: Bad Paint Type");
- stopScript();
- }
- }
- //END: Code generated using Enfilade's Easel
- @Override
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
- mainPaint(g);
- mousePaint.draw(g);
- }
- // <editor-fold defaultstate="collapsed" desc="MouseStuff">
- @Override
- public void mouseClicked(MouseEvent e) {
- p = e.getPoint();
- if (FuserScriptsLogoShape.contains(p) && showPaint) {
- sendToURL("http://fuserscripts.cz.cc/community/");
- }
- else if (userLogoShape.contains(p) && showPaint) {
- sendToURL("http://fuserscripts.cz.cc/community/index.php?/topic/76-fuserpaint-skeleton/");
- }
- else if (avatarSpotShape.contains(p) && showPaint) {
- sendToURL("http://fuserscripts.cz.cc/community/index.php?/user/19-dew/");
- }
- else if (closeButtonShape.contains(p) && showPaint) {
- showPaint = false;
- }
- else if (openButtonShape.contains(p) && !showPaint) {
- showPaint = true;
- }
- }
- // <editor-fold defaultstate="collapsed" desc="UNUSED">
- @Override
- public void mouseEntered(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- // </editor-fold>
- // </editor-fold>
- public class MousePaint {
- public int waveSize = 0;
- @SuppressWarnings({"serial", "unused"})
- 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 g1) {
- Graphics2D g = (Graphics2D) g1;
- g.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) {
- g.setColor(Color.GREEN);
- }
- if (mpt < 250) {
- g.setColor(Color.RED);
- }
- g.drawLine(a.x, a.y, lastPoint.x, lastPoint.y);
- }
- lastPoint = a;
- }
- }
- public void drawMouse(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
- g.setStroke(new BasicStroke(3));
- g.setColor(Color.BLACK);
- g.drawOval(mouse.getLocation().x - 13, mouse.getLocation().y - 13, 25, 25);
- g.setStroke(new BasicStroke(1));
- g.setColor(new Color(0, 0, 0, 114));
- g.fillOval(mouse.getLocation().x - 13, mouse.getLocation().y - 13, 25, 25);
- Point MouseLoc = mouse.getLocation();
- long mpt = System.currentTimeMillis() - mouse.getPressTime();
- g.rotate(Math.toRadians(getRot(5)), mouse.getLocation().x, mouse.getLocation().y);
- if (mouse.getPressTime() == -1 || mpt >= 250) {
- g.setColor(Color.GREEN);
- g.drawLine(MouseLoc.x - 5, MouseLoc.y, MouseLoc.x + 5, MouseLoc.y);
- g.drawLine(MouseLoc.x, MouseLoc.y - 5, MouseLoc.x, MouseLoc.y + 5);
- }
- if (mpt < 250) {
- g.setColor(Color.RED);
- g.drawLine(MouseLoc.x - 5, MouseLoc.y, MouseLoc.x + 5, MouseLoc.y);
- g.drawLine(MouseLoc.x, MouseLoc.y - 5, MouseLoc.x, MouseLoc.y + 5);
- }
- }
- public void drawWave(Graphics g1, Color c) {
- Point MouseLoc = mouse.getPressLocation();
- long mpt = System.currentTimeMillis() - mouse.getPressTime();
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
- g.setColor(c);
- if (mpt < 1000) {
- waveSize = (int) (mpt / 7.5);
- } else {
- waveSize = 0;
- }
- g.setStroke(new BasicStroke(3));
- g.drawOval(MouseLoc.x - (waveSize / 2), MouseLoc.y - (waveSize / 2), waveSize, waveSize);
- g.drawOval(MouseLoc.x - ((waveSize / 2) / 2), MouseLoc.y - ((waveSize / 2) / 2), waveSize / 2, waveSize / 2);
- }
- public void draw(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
- drawWave(g, Color.BLACK);
- drawTrail(g);
- drawMouse(g);
- }
- }
- public MousePaint mousePaint = new MousePaint();
- public void sendToURL(String url) {
- try {
- java.awt.Desktop.getDesktop().browse(
- java.net.URI.create(url));
- } catch (Exception e) {
- log("Error:" + e.getLocalizedMessage());
- }
- }
- // <editor-fold defaultstate="collapsed" desc="GUI">
- public class FuserGui extends javax.swing.JFrame {
- private static final long serialVersionUID = 1L;
- /** Creates new form FuserGui */
- public FuserGui() {
- initComponents();
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- paintType = new javax.swing.JComboBox();
- jLabel2 = new javax.swing.JLabel();
- startbutton = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
- setTitle("FuserPaint - Official Paint Designs");
- setAlwaysOnTop(true);
- setName("FuserPaint - Official Paint Designs"); // NOI18N
- setResizable(false);
- jLabel1.setFont(new java.awt.Font("Calibri", 1, 18)); // NOI18N
- jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- jLabel1.setText("Paint Template GUI");
- paintType.setFont(new java.awt.Font("Calibri", 1, 14)); // NOI18N
- paintType.setModel(new javax.swing.DefaultComboBoxModel(new String[]{
- "Chatbox Paint",
- "Inventory Paint(NOT available)",
- "Regular Paint(NOT available)"}));
- jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- jLabel2.setText("Select the paint to view! - 3 options to come");
- startbutton.setFont(new java.awt.Font("Calibri", 1, 18)); // NOI18N
- startbutton.setText("Start Script");
- startbutton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- startbuttonActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addGap(86, 86, 86).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false).addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(paintType, javax.swing.GroupLayout.Alignment.LEADING, 0, 218, Short.MAX_VALUE)).addGap(96, 96, 96)).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(startbutton, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE).addContainerGap()));
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jLabel1).addGap(24, 24, 24).addComponent(jLabel2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(paintType, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(startbutton, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE).addContainerGap()));
- pack();
- }// </editor-fold>
- private void startbuttonActionPerformed(java.awt.event.ActionEvent evt) {
- setVisible(false);
- GuiIsOpen = false;
- }
- // Variables declaration - do not modify
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JComboBox paintType;
- private javax.swing.JButton startbutton;
- // End of variables declaration
- }
- // </editor-fold>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement