Thondar

KaraFisher 1.0

Jun 23rd, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.94 KB | None | 0 0
  1. import java.awt.*;
  2. import java.text.DecimalFormat;
  3. import java.awt.event.*;
  4. import java.io.BufferedReader;
  5. import java.io.IOException;
  6. import java.io.InputStreamReader;
  7. import java.net.URL;
  8. import java.net.URLConnection;
  9. import javax.swing.*;
  10.  
  11. import org.powerbot.concurrent.Task;
  12. import org.powerbot.concurrent.strategy.Condition;
  13. import org.powerbot.concurrent.strategy.Strategy;
  14. import org.powerbot.game.api.ActiveScript;
  15. import org.powerbot.game.api.Manifest;
  16. import org.powerbot.game.api.methods.Calculations;
  17. import org.powerbot.game.api.methods.Tabs;
  18. import org.powerbot.game.api.methods.Walking;
  19. import org.powerbot.game.api.methods.input.Mouse;
  20. import org.powerbot.game.api.methods.interactive.NPCs;
  21. import org.powerbot.game.api.methods.interactive.Players;
  22. import org.powerbot.game.api.methods.node.SceneEntities;
  23. import org.powerbot.game.api.methods.tab.Inventory;
  24. import org.powerbot.game.api.methods.tab.Skills;
  25. import org.powerbot.game.api.methods.widget.Camera;
  26. import org.powerbot.game.api.util.Random;
  27. import org.powerbot.game.api.util.Time;
  28. import org.powerbot.game.api.wrappers.Area;
  29. import org.powerbot.game.api.wrappers.Tile;
  30. import org.powerbot.game.api.wrappers.interactive.NPC;
  31. import org.powerbot.game.api.wrappers.node.Item;
  32. import org.powerbot.game.api.wrappers.node.SceneObject;
  33. import org.powerbot.game.bot.event.MessageEvent;
  34. import org.powerbot.game.bot.event.listener.MessageListener;
  35. import org.powerbot.game.bot.event.listener.PaintListener;
  36.  
  37. @Manifest(name = "KaraFisher", description = "AIO Karamja Fisher", version = 1.0, authors = {"Thondar"})
  38. public class KaraFisher extends ActiveScript implements PaintListener, MessageListener {
  39.  
  40. private int SwordfishP(int id) throws IOException {
  41. URL url = new URL("http://open.tip.it/json/ge_single_item?item=" + Swordfish);
  42. URLConnection con = url.openConnection();
  43. BufferedReader in = new BufferedReader(new InputStreamReader(
  44. con.getInputStream()));
  45. String line = "";
  46. String inputLine;
  47. while ((inputLine = in.readLine()) != null) {
  48. line += inputLine;
  49. }
  50. in.close();
  51. if (!line.contains("mark_price"))
  52. return -1;
  53. line = line.substring(line.indexOf("mark_price\":\"")
  54. + "mark_price\":\"".length());
  55. line = line.substring(0, line.indexOf("\""));
  56. return Integer.parseInt(line.replaceAll(",", ""));
  57. }
  58.  
  59. private int LobsterP(int id) throws IOException {
  60. URL url = new URL("http://open.tip.it/json/ge_single_item?item=" + Lobster);
  61. URLConnection con = url.openConnection();
  62. BufferedReader in = new BufferedReader(new InputStreamReader(
  63. con.getInputStream()));
  64. String line = "";
  65. String inputLine;
  66. while ((inputLine = in.readLine()) != null) {
  67. line += inputLine;
  68. }
  69. in.close();
  70. if (!line.contains("mark_price"))
  71. return -1;
  72. line = line.substring(line.indexOf("mark_price\":\"")
  73. + "mark_price\":\"".length());
  74. line = line.substring(0, line.indexOf("\""));
  75. return Integer.parseInt(line.replaceAll(",", ""));
  76. }
  77.  
  78. private int TunaP(int id) throws IOException {
  79. URL url = new URL("http://open.tip.it/json/ge_single_item?item=" + Tuna);
  80. URLConnection con = url.openConnection();
  81. BufferedReader in = new BufferedReader(new InputStreamReader(
  82. con.getInputStream()));
  83. String line = "";
  84. String inputLine;
  85. while ((inputLine = in.readLine()) != null) {
  86. line += inputLine;
  87. }
  88. in.close();
  89. if (!line.contains("mark_price"))
  90. return -1;
  91. line = line.substring(line.indexOf("mark_price\":\"")
  92. + "mark_price\":\"".length());
  93. line = line.substring(0, line.indexOf("\""));
  94. return Integer.parseInt(line.replaceAll(",", ""));
  95. }
  96.  
  97. int RandomGift = 14664;
  98. int FishingSpot = 324;
  99. int Stiles = 11267;
  100. int startLVL;
  101. int Lobster = 377;
  102. int Tuna = 359;
  103. int Swordfish = 371;
  104. int TunaCount;
  105. int SwordfishCount;
  106. int LobsterCount;
  107. int FishCount;
  108. int LobsterPrice;
  109. int TunaPrice;
  110. int SwordfishPrice;
  111. int LobsterProfit, TunaProfit, SwordfishProfit,LobsterProfitHour, TunaProfitHour, SwordfishProfitHour, Profit, ProfitHour, FishHour, Profit1, ProfitHour1;
  112. int tab;
  113. int button1;
  114. int button2;
  115.  
  116. long startXP;
  117. long startTime;
  118. long runTime, xpTime;
  119. long hr, min, sec, xphr, xpmin, xpsec;
  120. long xpGain;
  121.  
  122. String time;
  123. String status;
  124. String xptime;
  125.  
  126. GUI g;
  127. private boolean guiWait = true;
  128.  
  129. Tile FishTile = new Tile(2924, 3177, 0);
  130. Tile StilesTile = new Tile(2857, 3146, 0);
  131.  
  132. DecimalFormat format = new DecimalFormat("#.##");
  133.  
  134. boolean start = false;
  135. boolean Note = true;
  136. private static int Cage = -1;
  137.  
  138. Area atStiles = new Area(new Tile(2848, 3141, 0), new Tile(2854, 3146, 0));
  139. Area FishArea = new Area(new Tile(2919, 3173, 0), new Tile(2926, 3181, 0));
  140. Area WalkArea = new Area(new Tile(2847, 3140, 0), new Tile(2918, 3178, 0));
  141.  
  142. Tile[] TilesToBank = new Tile[] { new Tile(2923, 3171, 0),
  143. new Tile(2909, 3172, 0), new Tile(2900, 3164, 0),
  144. new Tile(2897, 3156, 0), new Tile(2892, 3151, 0),
  145. new Tile(2882, 3146, 0), new Tile(2874, 3148, 0),
  146. new Tile(2862, 3147, 0), new Tile(2852, 3142, 0),
  147. };
  148.  
  149. Tile[] TilesToFish = new Tile[] { new Tile(2856, 3143, 0),
  150. new Tile(2866, 3152, 0), new Tile(2875, 3157, 0),
  151. new Tile(2884, 3163, 0), new Tile(2890, 3168, 0),
  152. new Tile(2896, 3172, 0), new Tile(2908, 3173, 0),
  153. new Tile(2919, 3173, 0), new Tile(2924, 3178, 0),
  154. };
  155.  
  156.  
  157.  
  158. @Override
  159. protected void setup() {
  160. log.info("Welcome to KaraFisher 1.0");
  161. log.info("Made by Tarth and Thondar");
  162. start = true;
  163. status = ("Starting Up");
  164.  
  165. try {
  166. LobsterPrice = LobsterP(Lobster);
  167. TunaPrice = TunaP(Tuna);
  168. SwordfishPrice = SwordfishP(Swordfish);
  169. } catch (IOException e) {
  170. e.printStackTrace();
  171. }
  172.  
  173. g = new GUI();
  174. g.setVisible(true);
  175. final WaitGui guiTask = new WaitGui();
  176. provide(new Strategy(guiTask, guiTask));
  177. provide(new Strategy(new WaitGui(), new WaitGui()));
  178.  
  179. startTime = System.currentTimeMillis();
  180.  
  181. startXP = Skills.getExperience(Skills.FISHING);
  182. startLVL = Skills.getLevel(Skills.FISHING);
  183.  
  184. Fish fish = new Fish();
  185. Strategy fishStrategy = new Strategy(fish, fish);
  186. provide(fishStrategy);
  187.  
  188. Fish1 fish1 = new Fish1();
  189. Strategy fish1Strategy = new Strategy(fish1, fish1);
  190. provide(fish1Strategy);
  191.  
  192. Drop drop = new Drop();
  193. Strategy dropStrategy = new Strategy(drop, drop);
  194. provide(dropStrategy);
  195.  
  196. AntiBan ab = new AntiBan();
  197. Strategy abStrategy = new Strategy(ab, ab);
  198. provide(abStrategy);
  199.  
  200. FishWalk fishwalk = new FishWalk();
  201. Strategy fishwalkStrategy = new Strategy(fishwalk, fishwalk);
  202. provide(fishwalkStrategy);
  203.  
  204. BankWalk bankwalk = new BankWalk();
  205. Strategy bankwalkStrategy = new Strategy(bankwalk, bankwalk);
  206. provide(bankwalkStrategy);
  207.  
  208. Bank bank = new Bank();
  209. Strategy bankStrategy = new Strategy(bank, bank);
  210. provide(bankStrategy);
  211.  
  212. Rand rand = new Rand();
  213. Strategy randStrategy = new Strategy(rand, rand);
  214. provide(randStrategy);
  215.  
  216. Stiles stiles = new Stiles();
  217. Strategy stilesStrategy = new Strategy(stiles, stiles);
  218. provide(stilesStrategy);
  219.  
  220. Tabs.INVENTORY.open(false);
  221.  
  222. }
  223.  
  224. private class WaitGui implements Task, Condition {
  225.  
  226. @Override
  227. public void run() {
  228. while (guiWait) {
  229. Time.sleep(500);
  230.  
  231. }
  232. }
  233.  
  234. public boolean validate() {
  235. return guiWait;
  236. }
  237.  
  238. }
  239.  
  240.  
  241. private class Rand implements Task, Condition {
  242.  
  243. @Override
  244. public void run() {
  245. for (Item i : Inventory.getItems()) {
  246. if (i.getId() == RandomGift) {
  247. i.getWidgetChild().interact("Drop");
  248. }
  249. }
  250. }
  251.  
  252. @Override
  253. public boolean validate() {
  254. return Inventory.getItem(RandomGift) != null;
  255. }
  256.  
  257. }
  258.  
  259. private class Fish implements Task, Condition {
  260.  
  261. @Override
  262. public void run() {
  263. Fish();
  264. Time.sleep(Random.nextInt(800, 1200));
  265. }
  266.  
  267. @Override
  268. public boolean validate() {
  269. return !Inventory.isFull() && (Players.getLocal().getAnimation() == -1) && (NPCs.getNearest(FishingSpot).isOnScreen()) && Cage == 0 && FishArea.contains(Players.getLocal());
  270. }
  271.  
  272. }
  273.  
  274. private class Fish1 implements Task, Condition {
  275.  
  276. @Override
  277. public void run() {
  278. Fish1();
  279. Time.sleep(Random.nextInt(800, 1200));
  280. }
  281.  
  282. @Override
  283. public boolean validate() {
  284. return !Inventory.isFull() && (Players.getLocal().getAnimation() == -1) && (NPCs.getNearest(FishingSpot) != null) && Cage == 1 && FishArea.contains(Players.getLocal());
  285. }
  286.  
  287. }
  288.  
  289.  
  290. private class Drop implements Task, Condition {
  291.  
  292. @Override
  293. public void run() {
  294. drop();
  295.  
  296. }
  297.  
  298. @Override
  299. public boolean validate() {
  300. return Inventory.isFull() && Note == false;
  301. }
  302.  
  303. }
  304.  
  305. private class Stiles implements Task, Condition {
  306.  
  307. @Override
  308. public void run() {
  309. Walking.setRun(true);
  310. status = ("Walking To F");
  311. Walking.walk(StilesTile);
  312. Camera.setAngle(Random.nextInt(220, 235));
  313. Camera.setPitch(Random.nextInt(20, 30));
  314. }
  315.  
  316.  
  317. @Override
  318. public boolean validate() {
  319. return Inventory.getCount() != 28 && atStiles.contains(Players.getLocal());
  320. }
  321.  
  322. }
  323.  
  324. private class FishWalk implements Task, Condition {
  325.  
  326. @Override
  327. public void run() {
  328. Walking.setRun(true);
  329. status = ("Walking To Fish");
  330. Walking.newTilePath(TilesToFish).traverse();
  331. Camera.setAngle(Random.nextInt(220, 235));
  332. Camera.setPitch(Random.nextInt(20, 30));
  333. }
  334.  
  335.  
  336. @Override
  337. public boolean validate() {
  338. return Inventory.getCount() != 28 && !FishArea.contains(Players.getLocal());
  339. }
  340.  
  341. }
  342.  
  343. private class BankWalk implements Task, Condition {
  344.  
  345. @Override
  346. public void run() {
  347. Walking.setRun(true);
  348. status = ("Walking");
  349. Walking.newTilePath(TilesToBank).traverse();
  350. Camera.setAngle(Random.nextInt(220, 235));
  351. Camera.setPitch(Random.nextInt(20, 30));
  352. }
  353.  
  354. @Override
  355. public boolean validate() {
  356. return Inventory.isFull() && Note == true;
  357. }
  358.  
  359. }
  360.  
  361. private class Bank implements Task, Condition {
  362.  
  363. @Override
  364. public void run() {
  365. NPCs.getNearest(Stiles).interact("Exchange");
  366. }
  367.  
  368. @Override
  369. public boolean validate() {
  370. return Inventory.isFull() && Note == true && NPCs.getNearest(Stiles).isOnScreen();
  371. }
  372.  
  373. }
  374.  
  375.  
  376. private class AntiBan implements Task, Condition {
  377.  
  378. @Override
  379. public void run() {
  380. switch(Random.nextInt(1, 100)){
  381. case 3:
  382. Camera.setAngle(Random.nextInt(1, 150));
  383. case 33:
  384. Camera.setAngle(Random.nextInt(1, 310));
  385. case 75:
  386. Camera.setAngle(Random.nextInt(1, 210));
  387. default:
  388. }
  389. Time.sleep(Random.nextInt(500, 1000));
  390. }
  391.  
  392. @Override
  393. public boolean validate() {
  394. return start;
  395. }
  396.  
  397. }
  398.  
  399.  
  400. public void Fish() {
  401. log.info("Fishing");
  402. status = ("Fishing");
  403. Tabs.INVENTORY.open(false);
  404. NPC i = NPCs.getNearest(FishingSpot);
  405. if (i != null) {
  406. Camera.turnTo(i.getLocation());
  407. NPCs.getNearest(FishingSpot).interact("Cage");
  408. }
  409. }
  410. public void Fish1() {
  411. log.info("Fishing");
  412. status = ("Fishing");
  413. Tabs.INVENTORY.open(false);
  414. NPC i = NPCs.getNearest(FishingSpot);
  415. if (i != null) {
  416. Camera.turnTo(i.getLocation());
  417. NPCs.getNearest(FishingSpot).interact("Harpoon");
  418. }
  419. }
  420.  
  421. public void drop() {
  422. log.info("Dropping");
  423. status = ("Dropping");
  424. Tabs.INVENTORY.open(false);
  425. for(Item elite:Inventory.getItems()){
  426. if(elite !=null){
  427. elite.getWidgetChild().interact("Drop");
  428. }
  429.  
  430. }
  431.  
  432. }
  433.  
  434. @Override
  435. public void messageReceived(MessageEvent e) {
  436. String txt = e.getMessage().toLowerCase();
  437. if(txt.contains("you catch a lobster")) {
  438. LobsterCount++;
  439. FishCount++;
  440. }
  441. if(txt.contains("you catch a tuna")) {
  442. TunaCount++;
  443. FishCount++;
  444. }
  445. if(txt.contains("you catch a swordfish")) {
  446. SwordfishCount++;
  447. FishCount++;
  448. }
  449.  
  450. }
  451.  
  452. public boolean walkTileMM(Tile tile, int rnd) {
  453. float angle = angleTo(tile) - Camera.getAngleTo(0);
  454. float distance = distanceTo(tile);
  455. if (distance > 18) distance = 18;
  456. angle = (float) (angle * Math.PI / 180);
  457. int x = 627, y = 85;
  458. int dx = (int) (4 * (distance + Random.nextGaussian(0, rnd, 1)) * Math.cos(angle));
  459. int dy = (int) (4 * (distance + Random.nextGaussian(0, rnd, 1)) * Math.sin(angle));
  460. return Mouse.click(x + dx, y - dy, true);
  461. }
  462.  
  463. public float distanceTo(Tile tile){
  464. return (float) Calculations.distance(Players.getLocal().getLocation(), tile);
  465. }
  466. public int angleTo(Tile tile) {
  467. final double ydif = tile.getY() - Players.getLocal().getLocation().getY();
  468. final double xdif = tile.getX() - Players.getLocal().getLocation().getX();
  469. return (int) (Math.atan2(ydif, xdif) * 180 / Math.PI) ;
  470. }
  471.  
  472.  
  473. private AlphaComposite makeComposite(float alpha) {
  474. int type = AlphaComposite.SRC_OVER;
  475.  
  476. return(AlphaComposite.getInstance(type, alpha));
  477. }
  478.  
  479.  
  480. private final Font font1 = new Font("Verdana", 0, 16);
  481. private final Font font2 = new Font("Verdana", 0, 12);
  482. private final Font font3 = new Font("Verdana", 0, 13);
  483. private final Font font4 = new Font("Verdana", 0, 9);
  484.  
  485.  
  486. @Override
  487. public void onRepaint(Graphics g) {
  488. Graphics2D g2d = (Graphics2D) g;
  489.  
  490. runTime = System.currentTimeMillis() - startTime;
  491. time = "";
  492. hr = runTime / (1000 * 60 * 60);
  493. min = (runTime % (1000 * 60 * 60)) / (1000 * 60);
  494. sec = ((runTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
  495.  
  496. xpGain = (Skills.getExperience(Skills.FISHING) - startXP);
  497.  
  498. int xpHour = (int) ((xpGain) * 3600000D / (System
  499. .currentTimeMillis() - startTime));
  500.  
  501. int level = Skills.getLevel(Skills.FISHING);
  502. int startXP = Skills.getExperienceRequired(level);
  503. int nextXP = Skills.getExperienceRequired(level + 1);
  504. double rangeXP = nextXP-startXP;
  505. double currentRelativeXP = Skills.getExperience(Skills.FISHING) - startXP;
  506. double currentXPleft = nextXP - Skills.getExperience(Skills.FISHING);
  507. double percentA = currentRelativeXP/rangeXP;
  508. double percentToLvl = ((percentA) * 100D);
  509.  
  510. double percent = (int) ((percentA) * 500D);
  511.  
  512. xpTime = (long) ((currentXPleft / xpHour) * 3600000D);
  513. xptime = "";
  514.  
  515. if(FishCount == 0) {
  516. xphr = 0;
  517. xpmin = 0;
  518. xpsec = 0;
  519. }
  520. if(FishCount >= 1) {
  521. xphr = xpTime / (1000 * 60 * 60);
  522. xpmin = (xpTime % (1000 * 60 * 60)) / (1000 * 60);
  523. xpsec = ((xpTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
  524. }
  525.  
  526. LobsterProfit = LobsterCount * LobsterPrice;
  527. TunaProfit = TunaCount * TunaPrice;
  528. SwordfishProfit = SwordfishCount * SwordfishPrice;
  529. Profit1 = LobsterProfit + TunaProfit + SwordfishProfit;
  530.  
  531. if (Note == true) {
  532. Profit = Profit1;
  533. }
  534. if (Note == false) {
  535. Profit = 0;
  536. }
  537.  
  538. int LobsterHour = (int) ((LobsterCount) * 3600000D / (System
  539. .currentTimeMillis() - startTime));
  540. int TunaHour = (int) ((TunaCount) * 3600000D / (System
  541. .currentTimeMillis() - startTime));
  542. int SwordfishHour = (int) ((SwordfishCount) * 3600000D / (System
  543. .currentTimeMillis() - startTime));
  544.  
  545. FishHour = LobsterHour + TunaHour + SwordfishHour;
  546.  
  547. LobsterProfitHour = LobsterHour * LobsterPrice;
  548. TunaProfitHour = TunaHour * TunaPrice;
  549. SwordfishProfitHour = SwordfishHour * SwordfishPrice;
  550. ProfitHour1 = SwordfishProfitHour + LobsterProfitHour + TunaProfitHour;
  551.  
  552. if (Note == true) {
  553. ProfitHour = ProfitHour1;
  554. }
  555. if (Note == false) {
  556. ProfitHour = 0;
  557. }
  558.  
  559. Rectangle bg = new Rectangle(10, 10, 160, 320);
  560. g2d.setComposite(makeComposite(.5f));
  561. g2d.setColor(Color.LIGHT_GRAY);
  562. g2d.fill(bg);
  563.  
  564. g2d.setComposite(makeComposite(.5f));
  565. g2d.setColor(Color.BLACK);
  566. g2d.drawRect(10, 10, 160, 320);
  567.  
  568. g2d.setFont(font1);
  569. g2d.setComposite(makeComposite(1f));
  570. g2d.setColor(Color.BLUE);
  571. g2d.drawString("KaraFisher", 50, 30);
  572. g2d.setFont(font3);
  573. g2d.drawString("By Thondar", 55, 45);
  574.  
  575. g2d.setFont(font4);
  576. g2d.setComposite(makeComposite(.8f));
  577. g2d.setColor(Color.BLUE);
  578. g2d.drawString("Version 1.0", 61, 55);
  579.  
  580. g2d.setComposite(makeComposite(.5f));
  581. g2d.setColor(Color.BLACK);
  582. g2d.drawLine(20, 60, 160, 60);
  583. g2d.drawLine(20, 110, 160, 110);
  584. g2d.drawLine(20, 160, 160, 160);
  585. g2d.drawLine(20, 210, 160, 210);
  586. g2d.drawLine(20, 260, 160, 260);
  587. g2d.drawLine(20, 310, 160, 310);
  588.  
  589.  
  590. g2d.setFont(font2);
  591. g2d.setComposite(makeComposite(.8f));
  592. g2d.setColor(new Color (0x00, 0x33, 0xff));
  593. g2d.drawString("Time Run: " + hr + ":" + min + ":" + sec, 30, 80);
  594.  
  595. g2d.setComposite(makeComposite(.8f));
  596. g2d.setColor(new Color (0x00, 0x33, 0xff));
  597. g2d.drawString("Status: " + status, 30, 100);
  598.  
  599. g2d.setComposite(makeComposite(.8f));
  600. g2d.setColor(new Color (0x00, 0x33, 0xff));
  601. g2d.drawString("XP/H: " + xpHour, 30, 130);
  602.  
  603. g2d.setComposite(makeComposite(.8f));
  604. g2d.setColor(new Color (0x00, 0x33, 0xff));
  605. g2d.drawString("XP Gained: " + xpGain, 30, 150);
  606.  
  607. g2d.setComposite(makeComposite(.8f));
  608. g2d.setColor(new Color (0x00, 0x33, 0xff));
  609. g2d.drawString("Current Level: " + (Skills.getLevel(Skills.FISHING)), 30, 180);
  610.  
  611. g2d.setComposite(makeComposite(.8f));
  612. g2d.setColor(new Color (0x00, 0x33, 0xff));
  613. g2d.drawString("Levels Gained: " + (Skills.getLevel(Skills.FISHING) - startLVL), 30, 200);
  614.  
  615. g2d.setComposite(makeComposite(.8f));
  616. g2d.setColor(new Color (0x00, 0x33, 0xff));
  617. g2d.drawString("Fish Cought: " + FishCount, 30, 230);
  618.  
  619. g2d.setComposite(makeComposite(.8f));
  620. g2d.setColor(new Color (0x00, 0x33, 0xff));
  621. g2d.drawString("Fish Cought/h: " + FishHour , 30, 250);
  622.  
  623. g2d.setComposite(makeComposite(.8f));
  624. g2d.setColor(new Color (0x00, 0x33, 0xff));
  625. g2d.drawString("Profit: " + Profit, 30, 280);
  626.  
  627. g2d.setComposite(makeComposite(.8f));
  628. g2d.setColor(new Color (0x00, 0x33, 0xff));
  629. g2d.drawString("Profit/h: " + ProfitHour, 30, 300);
  630.  
  631. g2d.setComposite(makeComposite(.8f));
  632. g2d.setColor(new Color (0x00, 0x33, 0xff));
  633. g2d.drawString("Time to lvl: " + xphr + ":" + xpmin + ":" + xpsec, 30, 325);
  634.  
  635. g2d.setComposite(makeComposite(1f));
  636. g2d.setColor(Color.BLACK);
  637. g2d.drawRect(10, 330, 500, 15);
  638.  
  639. g2d.setComposite(makeComposite(1f));
  640. g2d.setColor(Color.LIGHT_GRAY);
  641. g2d.fillRect(11, 331, 499, 13);
  642.  
  643. g2d.setComposite(makeComposite(1f));
  644. g2d.setColor(Color.GREEN);
  645. g2d.fillRect(11, 331,(int) (percent), 13);
  646.  
  647. g2d.setComposite(makeComposite(1f));
  648. g2d.setColor(Color.BLUE);
  649. g2d.drawString (String.format("%.2f", percentToLvl) + "%" , 225, 342);
  650.  
  651.  
  652. }
  653.  
  654. class GUI extends JFrame {
  655. public GUI() {
  656. initComponents();
  657. }
  658.  
  659. private void StartButtonActionPerformed(ActionEvent e) {
  660. String a = FishCB.getSelectedItem().toString();
  661. if (a.equals("Cage")){
  662. Cage = 0;
  663. }
  664. else{
  665. Cage = 1;
  666. }
  667. if (PowerfishCheck.isSelected()){
  668. Note = false;
  669. }
  670.  
  671. guiWait = false;
  672. g.dispose();
  673. }
  674.  
  675. private void initComponents() {
  676. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  677. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  678. label1 = new JLabel();
  679. label2 = new JLabel();
  680. label3 = new JLabel();
  681. FishCB = new JComboBox<>();
  682. PowerfishCheck = new JRadioButton();
  683. StartButton = new JButton();
  684.  
  685. //======== this ========
  686. Container contentPane = getContentPane();
  687. contentPane.setLayout(null);
  688.  
  689. //---- label1 ----
  690. label1.setText("KaraFisher");
  691. label1.setFont(new Font("Segoe Print", Font.BOLD, 20));
  692. label1.setHorizontalAlignment(SwingConstants.CENTER);
  693. contentPane.add(label1);
  694. label1.setBounds(0, 0, 195, 45);
  695.  
  696. //---- label2 ----
  697. label2.setText("By Thondar");
  698. label2.setHorizontalAlignment(SwingConstants.CENTER);
  699. label2.setFont(new Font("Segoe Print", Font.PLAIN, 11));
  700. contentPane.add(label2);
  701. label2.setBounds(0, 35, 195, 20);
  702.  
  703. //---- label3 ----
  704. label3.setText("How to Fish?");
  705. label3.setFont(new Font("Calibri", Font.PLAIN, 12));
  706. label3.setHorizontalAlignment(SwingConstants.CENTER);
  707. contentPane.add(label3);
  708. label3.setBounds(0, 75, 195, 20);
  709.  
  710. //---- FishCB ----
  711. FishCB.setModel(new DefaultComboBoxModel<>(new String[] {
  712. "Cage",
  713. "Harpoon"
  714. }));
  715. contentPane.add(FishCB);
  716. FishCB.setBounds(35, 90, 125, 30);
  717.  
  718. //---- PowerfishCheck ----
  719. PowerfishCheck.setText("Powerfish?");
  720. PowerfishCheck.setFont(new Font("Calibri", Font.PLAIN, 12));
  721. PowerfishCheck.setHorizontalAlignment(SwingConstants.CENTER);
  722. contentPane.add(PowerfishCheck);
  723. PowerfishCheck.setBounds(0, 125, 195, PowerfishCheck.getPreferredSize().height);
  724.  
  725. //---- StartButton ----
  726. StartButton.setText("Start");
  727. StartButton.setFont(new Font("Calibri", Font.PLAIN, 16));
  728. StartButton.addActionListener(new ActionListener() {
  729. @Override
  730. public void actionPerformed(ActionEvent e) {
  731. StartButtonActionPerformed(e);
  732. }
  733. });
  734. contentPane.add(StartButton);
  735. StartButton.setBounds(5, 170, 185, 55);
  736.  
  737. { // compute preferred size
  738. Dimension preferredSize = new Dimension();
  739. for(int i = 0; i < contentPane.getComponentCount(); i++) {
  740. Rectangle bounds = contentPane.getComponent(i).getBounds();
  741. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  742. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  743. }
  744. Insets insets = contentPane.getInsets();
  745. preferredSize.width += insets.right;
  746. preferredSize.height += insets.bottom;
  747. contentPane.setMinimumSize(preferredSize);
  748. contentPane.setPreferredSize(preferredSize);
  749. }
  750. pack();
  751. setLocationRelativeTo(getOwner());
  752. // JFormDesigner - End of component initialization //GEN-END:initComponents
  753. }
  754.  
  755. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  756. // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
  757. private JLabel label1;
  758. private JLabel label2;
  759. private JLabel label3;
  760. private JComboBox<String> FishCB;
  761. private JRadioButton PowerfishCheck;
  762. private JButton StartButton;
  763. // JFormDesigner - End of variables declaration //GEN-END:variables
  764. }
  765.  
  766.  
  767. }
Advertisement
Add Comment
Please, Sign In to add comment