IdlePixel+ Overview Panel

Single panel to control many skills

目前為 2023-12-19 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name IdlePixel+ Overview Panel
  3. // @namespace lbtechnology.info
  4. // @version 1.2.0
  5. // @description Single panel to control many skills
  6. // @author Lux-Ferre
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play*
  9. // @grant none
  10. // @require https://greasyfork.org/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. class OverviewPlugin extends IdlePixelPlusPlugin {
  17. constructor() {
  18. super("overview", {
  19. about: {
  20. name: GM_info.script.name,
  21. version: GM_info.script.version,
  22. author: GM_info.script.author,
  23. description: GM_info.script.description
  24. },
  25. config: [
  26. {
  27. id: "colNum",
  28. label: "Number of modules per row",
  29. type: "integer",
  30. min: 1,
  31. max: 12,
  32. default: 3
  33. },
  34. {
  35. id: "farmingEnabled",
  36. label: "farmingEnabled",
  37. type: "boolean",
  38. default: true
  39. },
  40. {
  41. id: "gatheringEnabled",
  42. label: "gatheringEnabled",
  43. type: "boolean",
  44. default: true
  45. },
  46. {
  47. id: "mineralsEnabled",
  48. label: "mineralsEnabled",
  49. type: "boolean",
  50. default: true
  51. },
  52. {
  53. id: "woodcuttingEnabled",
  54. label: "woodcuttingEnabled",
  55. type: "boolean",
  56. default: true
  57. },
  58. {
  59. id: "smeltingEnabled",
  60. label: "smeltingEnabled",
  61. type: "boolean",
  62. default: true
  63. },
  64. {
  65. id: "cookingEnabled",
  66. label: "cookingEnabled",
  67. type: "boolean",
  68. default: true
  69. },
  70. {
  71. id: "brewingEnabled",
  72. label: "brewingEnabled",
  73. type: "boolean",
  74. default: true
  75. },
  76. {
  77. id: "fishingEnabled",
  78. label: "fishingEnabled",
  79. type: "boolean",
  80. default: false
  81. },
  82. {
  83. id: "machineryEnabled",
  84. label: "machineryEnabled",
  85. type: "boolean",
  86. default: false
  87. }
  88. ]
  89. });
  90. this.previous = "";
  91. }
  92.  
  93. onConfigsChanged() {
  94. this.applyConfigs()
  95. }
  96.  
  97. onLogin() {
  98. const onlineCount = $(".top-bar .gold:not(#top-bar-admin-link)");
  99. onlineCount.before(`
  100. <a href="#" class="hover float-end link-no-decoration"
  101. onclick="event.preventDefault(); IdlePixelPlus.setPanel('overview')"
  102. title="Overview">Overview&nbsp;&nbsp;&nbsp;</a>
  103. `);
  104.  
  105. this.addStyles()
  106. this.createPanel()
  107. this.addBonemealbinToPanel()
  108. this.addMeteorsToPanel()
  109. this.toggleMultiHarvest()
  110. this.addGatheringAreasToPanel()
  111. this.highlightGathering()
  112. this.applyConfigs()
  113.  
  114. const standardItemBoxes = {
  115. overviewLogsContainer: {
  116. itemList: ["logs", "oak_logs", "willow_logs", "maple_logs", "stardust_logs", "pine_logs", "redwood_logs", "dense_logs"],
  117. onClickString: "IdlePixelPlus.plugins['overview'].clicksLogs(this.getAttribute('ov-data-item'))"
  118. },
  119. overviewBonemealContainer: {
  120. itemList: ["bones", "big_bones", "ice_bones", "blood_bones", "dragon_bones", "ashes"],
  121. onClickString: "Farming.clicks_bones(this.getAttribute('ov-data-item'))"
  122. },
  123. overviewSeedsContainer: {
  124. itemList: [
  125. "dotted_green_leaf_seeds", "green_leaf_seeds", "lime_leaf_seeds", "gold_leaf_seeds",
  126. "crystal_leaf_seeds", "red_mushroom_seeds", "stardust_seeds", "tree_seeds", "oak_tree_seeds",
  127. "willow_tree_seeds", "maple_tree_seeds", "stardust_tree_seeds", "pine_tree_seeds", "redwood_tree_seeds",
  128. "apple_tree_seeds", "banana_tree_seeds", "orange_tree_seeds", "palm_tree_seeds", "dragon_fruit_tree_seeds",
  129. "bone_tree_seeds", "lava_tree_seeds", "strange_tree_seeds", "potato_seeds", "carrot_seeds", "beet_seeds", "broccoli_seeds"
  130. ],
  131. onClickString: "IdlePixelPlus.plugins['overview'].clicksSeeds(this.getAttribute('ov-data-item'))"
  132. },
  133. overviewBarsContainer: {
  134. itemList: ["bronze_bar", "iron_bar", "silver_bar", "gold_bar", "promethium_bar", "titanium_bar", "ancient_bar", "dragon_bar"],
  135. onClickString: "IdlePixelPlus.plugins['overview'].clicksBars(this.getAttribute('ov-data-item'))"
  136. },
  137. overviewOresContainer: {
  138. itemList: ["stone", "copper", "iron", "silver", "gold", "promethium", "titanium", "ancient_ore", "dragon_ore"],
  139. onClickString: "Modals.open_stardust_or_sell_item_dialogue('mining', this.getAttribute('ov-data-item'))"
  140. },
  141. overviewRecipeContainer: {
  142. itemList: ["dotted_salad", "chocolate_cake", "lime_leaf_salad", "golden_apple", "banana_jello", "orange_pie", "pancakes", "coconut_stew", "dragon_fruit_salad",
  143. "potato_shake", "carrot_shake", "beet_shake", "broccoli_shake"],
  144. onClickString: `websocket.send('COOKS_BOOK=' + this.getAttribute('ov-data-item'))`
  145. },
  146. overviewGatheringBagsContainer: {
  147. itemList: ["gathering_loot_bag_mines", "gathering_loot_bag_fields", "gathering_loot_bag_forest", "gathering_loot_bag_fishing_pond",
  148. "gathering_loot_bag_kitchen", "gathering_loot_bag_gem_mine", "gathering_loot_bag_castle", "gathering_loot_bag_junk"],
  149. onClickString: "Modals.open_input_dialogue_with_value(this.getAttribute('ov-data-item').slice(19), 'Open', 'How many?', Items.getItem(this.getAttribute('ov-data-item')), 'OPEN_GATHERING_LOOT')"
  150. },
  151. overviewGemContainer: {
  152. itemList: ["sapphire", "emerald", "ruby", "diamond", "blood_diamond"],
  153. onClickString: ""
  154. },
  155. overviewSDCrystalContainer: {
  156. itemList: ["small_stardust_prism", "medium_stardust_prism", "large_stardust_prism", "huge_stardust_prism"],
  157. onClickString: "Modals.open_input_dialogue_with_value(this.getAttribute('ov-data-item'), 'Smash', 'How many stardust prism do you want to smash?', Items.getItem(this.getAttribute('ov-data-item')), 'SMASH_STARDUST_PRISM')"
  158. },
  159. overviewGeodeContainer: {
  160. itemList: ["grey_geode", "blue_geode", "green_geode", "red_geode", "cyan_geode", "ancient_geode"],
  161. onClickString: "Modals.open_input_dialogue_with_value(this.getAttribute('ov-data-item'), 'Open', 'How many geodes to you want to crack?', Items.getItem(this.getAttribute('ov-data-item')), 'CRACK_GEODE')"
  162. },
  163. overviewMineralContainer: {
  164. itemList: ["blue_marble_mineral", "amethyst_mineral", "sea_crystal_mineral", "dense_marble_mineral", "fluorite_mineral", "clear_marble_mineral",
  165. "jade_mineral", "lime_quartz_mineral", "opal_mineral", "purple_quartz_mineral", "amber_mineral", "smooth_pearl_mineral",
  166. "sulfer_mineral", "topaz_mineral", "tanzanite_mineral", "magnesium_mineral", "frozen_mineral", "blood_crystal_mineral"],
  167. onClickString: "Modals.clicks_mineral(this.getAttribute('ov-data-item'))"
  168. },
  169. overviewPotionContainer: {
  170. itemList: ["stardust_potion", "energy_potion", "anti_disease_potion", "tree_speed_potion", "smelting_upgrade_potion", "great_stardust_potion", "farming_speed_potion",
  171. "rare_monster_potion", "super_stardust_potion", "gathering_unique_potion", "heat_potion", "bait_potion", "bone_potion", "furnace_speed_potion", "promethium_potion",
  172. "super_rare_monster_potion", "ultra_stardust_potion", "cooks_dust_potion", "fighting_dust_potion", "tree_dust_potion", "farm_dust_potion",
  173. "magic_shiny_crystal_ball_potion", "birdhouse_potion", "rocket_potion", "titanium_potion", "blue_orb_potion", "geode_potion", "magic_crystal_ball_potion",
  174. "stone_converter_potion", "rain_potion", "combat_loot_potion", "rotten_potion", "merchant_speed_potion", "green_orb_potion", "ancient_potion", "guardian_key_potion",
  175. "red_orb_potion"],
  176. onClickString: ""
  177. }
  178. /*,
  179. template: {
  180. itemList: [],
  181. onClickString: ""
  182. }*/
  183. }
  184.  
  185. for (const [containerId, itemData] of Object.entries(standardItemBoxes)) {
  186. this.addStandardItemsToPanel(containerId, itemData)
  187. }
  188.  
  189. this.addRightClickToPotions()
  190. }
  191.  
  192. onMessageReceived(data) {
  193. if(Globals.currentPanel !== "panel-overview"){return;}
  194. if (data.startsWith("SET_ITEMS")){
  195. this.updatePanelTrees()
  196. this.updatePanelPlants()
  197. this.updatePanelCooking()
  198. this.updateSmeltingPanel()
  199. }
  200. }
  201.  
  202. addStyles(){
  203. let borderColour
  204.  
  205. if ("ui-tweaks" in IdlePixelPlus.plugins){
  206. borderColour = IdlePixelPlus.plugins["ui-tweaks"].config["font-color-panels"]
  207. } else {
  208. borderColour = "black"
  209. }
  210.  
  211. $("head").append(`
  212. <style id="styles-overview">
  213. .overviewSkillModule {
  214. border-radius: 3px;
  215. border-style: outset;
  216. }
  217. .overviewGatheringBoxArea {
  218. width: 150px;
  219. height: 150px;
  220. border-radius: 30px;
  221. }
  222. .overviewGatheringBoxSelected {
  223. box-shadow: 0 0 15px #80ed6f;
  224. }
  225. .overviewDottedBorder {
  226. border-radius: 2px;
  227. border: 1px dotted ${borderColour};
  228. }
  229. </style>
  230. `)
  231. }
  232.  
  233. createPanel(){
  234. IdlePixelPlus.addPanel("overview", "Overview", function() {
  235. const content = `
  236. <div id="overviewTopLevelRow" class="row row-cols-3 d-flex flex-wrap">
  237. <div id="overviewFarmingModule" class="col overviewSkillModule">
  238. <div id="overviewBonemealContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  239. <div id="overviewSeedsContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  240. <div id="overviewFarmingPlotContainer" class="row farming-patches-area g-0 overviewDottedBorder">
  241. <div id="overviewFarmingPlot-1" class="col text-center d-flex flex-column align-items-center"><img id="overviewFarmingPatchImg-1" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Farming.clicksPlot(1)" /><label id="overviewFarmingTimer-1" class="form-label">0</label></div>
  242. <div id="overviewFarmingPlot-2" class="col text-center d-flex flex-column align-items-center"><img id="overviewFarmingPatchImg-2" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Farming.clicksPlot(2)" /><label id="overviewFarmingTimer-2" class="form-label">0</label></div>
  243. <div id="overviewFarmingPlot-3" class="col text-center d-flex flex-column align-items-center"><img id="overviewFarmingPatchImg-3" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Farming.clicksPlot(3)" /><label id="overviewFarmingTimer-3" class="form-label">0</label></div>
  244. <div id="overviewFarmingPlot-4" class="col text-center d-flex flex-column align-items-center"><img id="overviewFarmingPatchImg-4" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Farming.clicksPlot(4)" /><label id="overviewFarmingTimer-4" class="form-label">0</label></div>
  245. <div id="overviewFarmingPlot-5" class="col text-center d-flex flex-column align-items-center"><img id="overviewFarmingPatchImg-5" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Farming.clicksPlot(5)" /><label id="overviewFarmingTimer-5" class="form-label">0</label></div>
  246. </div>
  247. <div class="row">
  248. <div class="col text-center overviewDottedBorder"><button id="overviewHarvestAll" class="btn btn-primary" type="button" onclick="IdlePixelPlus.plugins.slapchop.quickHarvest()">Harvest All</button></div>
  249. </div>
  250. </div>
  251. <div id="overviewGatheringModule" class="col overviewSkillModule">
  252. <div id="overviewGatheringBagsContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  253. <div id="overviewGatheringAreasContainer" class="row gx-0 gy-2 d-flex justify-content-evenly overviewDottedBorder"></div>
  254. </div>
  255. <div id="overviewMineralModule" class="col overviewSkillModule">
  256. <div id="overviewGemContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  257. <div id="overviewSDCrystalContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  258. <div id="overviewGeodeContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  259. <div id="overviewMineralContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  260. </div>
  261. <div id="overviewWoodcuttingModule" class="col overviewSkillModule">
  262. <div class="row">
  263. <div class="col-lg-3 overviewDottedBorder">
  264. <div>
  265. <div class="form-check"><input id="overviewUseLogsNone" class="form-check-input" type="radio" checked name="overviewUseLogsType" value="none" /><label class="form-check-label" for="overviewUseLogsNone">None</label></div>
  266. <div class="form-check"><input id="overviewUseLogsHeat" class="form-check-input" type="radio" name="overviewUseLogsType" value="heat" /><label class="form-check-label" for="overviewUseLogsHeat">Heat</label></div>
  267. <div class="form-check"><input id="overviewUseLogsCharcoal" class="form-check-input" type="radio" name="overviewUseLogsType" value="charcoal" /><label class="form-check-label" for="overviewUseLogsCharcoal">Charcoal</label></div>
  268. </div>
  269. </div>
  270. <div class="col">
  271. <div id="overviewLogsContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  272. </div>
  273. </div>
  274. <div id="overviewWCPlotContainer" class="row farming-patches-area g-0 overviewDottedBorder">
  275. <div id="overviewWCPlot-1" class="col text-center d-flex flex-column align-items-center"><img id="overviewWoodcuttingPatchImg-1" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Woodcutting.clicksPlot(1)" /><label id="overviewWoodcuttingTimer-1" class="form-label">0</label></div>
  276. <div id="overviewWCPlot-2" class="col text-center d-flex flex-column align-items-center"><img id="overviewWoodcuttingPatchImg-2" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Woodcutting.clicksPlot(2)" /><label id="overviewWoodcuttingTimer-2" class="form-label">0</label></div>
  277. <div id="overviewWCPlot-3" class="col text-center d-flex flex-column align-items-center"><img id="overviewWoodcuttingPatchImg-3" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Woodcutting.clicksPlot(3)" /><label id="overviewWoodcuttingTimer-3" class="form-label">0</label></div>
  278. <div id="overviewWCPlot-4" class="col text-center d-flex flex-column align-items-center"><img id="overviewWoodcuttingPatchImg-4" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Woodcutting.clicksPlot(4)" /><label id="overviewWoodcuttingTimer-4" class="form-label">0</label></div>
  279. <div id="overviewWCPlot-5" class="col text-center d-flex flex-column align-items-center"><img id="overviewWoodcuttingPatchImg-5" class="farming-patch" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png" width="75" onclick="Woodcutting.clicksPlot(5)" /><label id="overviewWoodcuttingTimer-5" class="form-label">0</label></div>
  280. </div>
  281. <div class="row">
  282. <div class="col text-center overviewDottedBorder"><button id="overviewChopAll" class="btn btn-primary" type="button" onclick="IdlePixelPlus.plugins.slapchop.quickChop()">Chop All</button></div>
  283. </div>
  284. </div>
  285. <div id="overviewSmeltingModule" class="col overviewSkillModule">
  286. <div class="row">
  287. <div class="col">
  288. <div class="row">
  289. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Oil</label><label id="overviewOilNum" class="form-label">0</label></div>
  290. </div>
  291. <div class="row">
  292. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Lava</label><label id="overviewLavaNum" class="form-label">0</label></div>
  293. </div>
  294. <div class="row">
  295. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Buckets</label><label id="overviewBucketsNum" class="form-label">0</label></div>
  296. </div>
  297. </div>
  298. <div class="col text-center align-self-center"><img id="overviewFurnaceIcon" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/promethium_furnace.png" /></div>
  299. <div class="col">
  300. <div class="row">
  301. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Charcoal</label><label id="overviewCharcoalNum" class="form-label">0</label></div>
  302. </div>
  303. <div class="row">
  304. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Plasma</label><label id="overviewPlasmaNum" class="form-label">0</label></div>
  305. </div>
  306. <div class="row">
  307. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">D. Fire</label><label id="overviewDFireNum" class="form-label">0</label></div>
  308. </div>
  309. </div>
  310. </div>
  311. <div id="overviewBarsContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  312. <div id="overviewOresContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  313. </div>
  314. <div id="overviewCookingModule" class="col overviewSkillModule">
  315. <div class="row">
  316. <div class="col-xl-4 text-center align-self-center overviewDottedBorder"><img id="overviewCooksBookItem" style="width: 100px;height: 100px;" onclick="websocket.send(&#39;COOKS_BOOK_READY&#39;)" /></div>
  317. <div class="col text-center align-self-center overviewDottedBorder"><label id="overviewCooksBookTimer" class="col-form-label">0</label></div>
  318. </div>
  319. <div id="overviewRecipeContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  320. </div>
  321. <div id="overviewBrewingModule" class="col overviewSkillModule">
  322. <div id="overviewPotionContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  323. </div>
  324. <div id="overviewFishingModule" class="col overviewSkillModule"></div>
  325. <div id="overviewMachineryModule" class="col overviewSkillModule"></div>
  326. </div>
  327. `
  328. return content
  329. });
  330. }
  331.  
  332. applyConfigs() {
  333. // Modules per row
  334. const colClass = "row-cols-" + this.getConfig("colNum")
  335. const topLevel = $("#overviewTopLevelRow")
  336. for(let i = 0; i <= 12 ; i++) {
  337. const oldClass = `row-cols-${i}`
  338. topLevel.removeClass(oldClass)
  339. }
  340.  
  341. topLevel.addClass(colClass)
  342.  
  343. // Enable/disable modules
  344.  
  345. const moduleList = [
  346. ["farmingEnabled", "overviewFarmingModule"],
  347. ["gatheringEnabled", "overviewGatheringModule"],
  348. ["mineralsEnabled", "overviewMineralModule"],
  349. ["woodcuttingEnabled", "overviewWoodcuttingModule"],
  350. ["smeltingEnabled", "overviewSmeltingModule"],
  351. ["cookingEnabled", "overviewCookingModule"],
  352. ["brewingEnabled", "overviewBrewingModule"],
  353. ["fishingEnabled", "overviewFishingModule"],
  354. ["machineryEnabled", "overviewMachineryModule"]
  355. ]
  356.  
  357. moduleList.forEach(module => {
  358. const moduleEnabled = this.getConfig(module[0])
  359.  
  360. const moduleLocation = $(`#${module[1]}`)
  361.  
  362. if (moduleEnabled){
  363. moduleLocation.show()
  364. } else {
  365. moduleLocation.hide()
  366. }
  367. })
  368.  
  369. }
  370.  
  371. formatTimeWithDays(timeInSecs) {
  372. let timerStr = "";
  373. const hour24 = 24 * 60 * 60;
  374.  
  375. const timerDays = Math.floor(timeInSecs / hour24);
  376. if(timeInSecs > hour24) {
  377. timerStr = `${timerDays}d ${format_time(timeInSecs - (timerDays * hour24))}`
  378. } else {
  379. timerStr = `${format_time(timeInSecs - (timerDays * hour24))}`
  380. }
  381. return timerStr;
  382. }
  383.  
  384. getFurnace(){
  385. const furnaceList = ["dragon_furnace", "ancient_furnace", "titanium_furnace", "promethium_furnace", "gold_furnace",
  386. "silver_furnace", "iron_furnace", "bronze_furnace", "stone_furnace"]
  387. for(let i = 0; i < furnaceList.length; i++) {
  388. const furnace = furnaceList[i]
  389. if(window["var_"+furnace]){
  390. return furnace
  391. }
  392. }
  393. return "";
  394. }
  395.  
  396. addStandardItemsToPanel(containerId, itemData){
  397. const itemList = itemData.itemList
  398. const itemOnClick = itemData.onClickString
  399.  
  400. itemList.forEach((itemType) => {
  401. const itemElementString = `<div class="col d-flex justify-content-center">
  402. <itembox data-item="playtime" ov-data-item="${itemType}" id="overview-itembox-${itemType}" onclick="${itemOnClick}" class="shadow hover">
  403. <div class="center mt-1"><img src="https://d1xsc8x7nc5q8t.cloudfront.net/images/${itemType}.png" title="${itemType}"></div>
  404. <div class="center mt-2"> <item-display data-format="number" data-key="${itemType}"></item-display></div>
  405. </itembox>
  406. </div>`
  407. const itemBox = $.parseHTML(itemElementString)
  408. $(`#${containerId}`).append(itemBox)
  409. })
  410. }
  411.  
  412. addGatheringAreasToPanel(){
  413. const areaData = [
  414. {
  415. id: "overviewGatheringBoxMines",
  416. background: "background-dark-grey",
  417. image: "gathering_mine.png",
  418. name: "mines"
  419. },
  420. {
  421. id: "overviewGatheringBoxFields",
  422. background: "background-dark-green",
  423. image: "gathering_field.png",
  424. name: "fields"
  425. },
  426. {
  427. id: "overviewGatheringBoxForest",
  428. background: "background-brown",
  429. image: "gathering_forest.png",
  430. name: "forest"
  431. },
  432. {
  433. id: "overviewGatheringBoxFishingPond",
  434. background: "background-dark-blue",
  435. image: "gathering_fishing_pond.png",
  436. name: "fishing_pond"
  437. },
  438. {
  439. id: "overviewGatheringBoxKitchen",
  440. background: "background-dark-orange",
  441. image: "gathering_kitchen.png",
  442. name: "kitchen"
  443. },
  444. {
  445. id: "overviewGatheringBoxGemMine",
  446. background: "background-dark-cyan",
  447. image: "gathering_gem_mine.png",
  448. name: "gem_mine"
  449. },
  450. {
  451. id: "overviewGatheringBoxCastle",
  452. background: "background-veryrare",
  453. image: "gathering_castle.png",
  454. name: "castle"
  455. }
  456. ]
  457. areaData.forEach((area) => {
  458. const areaId = area.id
  459. const background = area.background
  460. const image = area.image
  461. const name = area.name
  462.  
  463. const areaElementString = `<div class="col d-flex justify-content-center">
  464. <div id="${areaId}" class="d-flex ${background} hover overviewGatheringBoxArea"
  465. ov-data-item="${name}" onclick="IdlePixelPlus.plugins['overview'].changeGatheringArea(this.getAttribute('ov-data-item'))">
  466. <img class="m-auto w-80 h-80" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/${image}" />
  467. </div>
  468. </div>`
  469. const areaBox = $.parseHTML(areaElementString)
  470. $(`#overviewGatheringAreasContainer`).append(areaBox)
  471. })
  472. }
  473. addMeteorsToPanel(){
  474. const meteorString = `
  475. <div class="col d-flex justify-content-center">
  476. <itembox data-item="playtime" ov-data-item="meteor" class="shadow hover itembox-resource-mining-1" onclick="Modals.open_image_modal('METEOR', 'images/meteor.png', 'Mine the material from the meteor?<br /><br /><span class=\'color-grey font-small\'>This action requires level 90 in mining.</span>','Mine it!','Close','MINE_METEOR')">
  477. <div class="center mt-1"><img draggable="false" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/meteor.png" title="meteor"></div>
  478. <div class="center mt-2"><item-display data-format="number" data-key="meteor">0</item-display></div>
  479. </itembox>
  480. </div>`
  481.  
  482. const meteorBox = $.parseHTML(meteorString)
  483. $("#overviewGeodeContainer").append(meteorBox)
  484. }
  485.  
  486. addBonemealbinToPanel(){
  487. const binString = `
  488. <div class="col d-flex justify-content-center">
  489. <itembox data-item="playtime" ov-data-item="bonemeal_bin" class="shadow hover bone-item-box">
  490. <div class="center mt-1"><img draggable="false" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/bonemeal_bin.png" title="bonemeal_bin"></div>
  491. <div class="center mt-2"> <img src="https://d1xsc8x7nc5q8t.cloudfront.net/images/bonemeal_icon.png"> <item-display data-format="number" data-key="bonemeal">0</item-display></div>
  492. </itembox>
  493. </div>`
  494.  
  495. const bonemealBox = $.parseHTML(binString)
  496. $("#overviewBonemealContainer").append(bonemealBox)
  497. }
  498.  
  499. addRightClickToPotions(){
  500. $("#overviewPotionContainer").find("itembox").attr("oncontextmenu", "IdlePixelPlus.plugins['overview'].clicksPotion(this.getAttribute('ov-data-item')); return false;")
  501. }
  502.  
  503. toggleMultiHarvest(){
  504. if (!("slapchop" in IdlePixelPlus.plugins)){
  505. $("#overviewChopAll").hide()
  506. $("#overviewHarvestAll").hide()
  507. }
  508. }
  509.  
  510. updatePanelTrees(){
  511. for(let i = 1; i < 6; i++) {
  512. const tree = Items.getItemString("tree_" + i);
  513. const stage = Items.getItem("tree_stage_" + i);
  514. const tree_time = Items.getItem("tree_timer_"+ i)
  515. let time_string
  516.  
  517. if(tree_time===0){
  518. time_string = "EMPTY"
  519. } else if (tree_time===1){
  520. time_string = "READY"
  521. } else {
  522. time_string = this.formatTimeWithDays(tree_time)
  523. }
  524.  
  525. $(`#overviewWoodcuttingTimer-${i}`).html(time_string)
  526.  
  527. let img_url
  528.  
  529. if(tree !== "none"){
  530. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_${tree}_${stage}.png`
  531. } else {
  532. if(i === 4 || i === 5){
  533. if(!DonorShop.has_donor_active(Items.getItem("donor_tree_patches_timestamp"))){
  534. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_locked.png`
  535. } else {
  536. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png`
  537. }
  538. } else {
  539. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png`
  540. }
  541. }
  542. $(`#overviewWoodcuttingPatchImg-${i}`).attr("src", img_url)
  543. }
  544. }
  545.  
  546. updatePanelPlants(){
  547. for(let i = 1; i < 6; i++) {
  548. const crop = Items.getItemString("farm_" + i);
  549. const stage = Items.getItem("farm_stage_" + i);
  550. const crop_time = Items.getItem("farm_timer_"+ i)
  551. let time_string
  552.  
  553. if(crop_time===0){
  554. time_string = "EMPTY"
  555. } else if (crop_time===1){
  556. time_string = "READY"
  557. } else {
  558. time_string = this.formatTimeWithDays(crop_time)
  559. }
  560.  
  561. $(`#overviewFarmingTimer-${i}`).html(time_string)
  562.  
  563. let img_url
  564.  
  565. if(crop !== "none"){
  566. if (Items.getItem("farm_death_" + i) === 1){
  567. img_url = "https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_dead_leaf.png"
  568. } else {
  569. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_${crop}_${stage}.png`
  570. }
  571. } else {
  572. if(i === 4 || i === 5){
  573. if(!DonorShop.has_donor_active(Items.getItem("donor_tree_patches_timestamp"))){
  574. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_locked.png`
  575. } else {
  576. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_none.png`
  577. }
  578. } else {
  579. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_none.png`
  580. }
  581. }
  582. $(`#overviewFarmingPatchImg-${i}`).attr("src", img_url)
  583. }
  584. }
  585. updatePanelCooking() {
  586. let current_item = IdlePixelPlus.getVarOrDefault("cooks_book_item", "cooks_book", "string")
  587. if (current_item === "none"){current_item="cooks_book"}
  588.  
  589. const current_time = IdlePixelPlus.getVarOrDefault("cooks_book_timer", 0, "int")
  590. let formatted_time
  591. if (current_time<=1){
  592. formatted_time = "Completed."
  593. } else {
  594. formatted_time = this.formatTimeWithDays(current_time)
  595. }
  596.  
  597. $("#overviewCooksBookItem").attr("src", `https://d1xsc8x7nc5q8t.cloudfront.net/images/${current_item}.png`)
  598. $("#overviewCooksBookTimer").html(`${formatted_time}`)
  599. }
  600.  
  601. updateSmeltingPanel(){
  602. /*oil, lava, buckets, coal, plasma, fire, furnace, bar_click*/
  603. const oilNum = IdlePixelPlus.getVarOrDefault("oil", 0, "int")
  604. const lavaNum = IdlePixelPlus.getVarOrDefault("lava", 0, "int")
  605. const bucketsNum = IdlePixelPlus.getVarOrDefault("iron_bucket", 0, "int")
  606. const charcoalNum = IdlePixelPlus.getVarOrDefault("charcoal", 0, "int")
  607. const plasmaNum = IdlePixelPlus.getVarOrDefault("plasma", 0, "int")
  608. const dFireNum = IdlePixelPlus.getVarOrDefault("dragon_fire", 0, "int")
  609.  
  610. const furnaceType = this.getFurnace()
  611.  
  612. $("#overviewOilNum").html(oilNum)
  613. $("#overviewLavaNum").html(lavaNum)
  614. $("#overviewBucketsNum").html(bucketsNum)
  615. $("#overviewCharcoalNum").html(charcoalNum)
  616. $("#overviewPlasmaNum").html(plasmaNum)
  617. $("#overviewDFNum").html(dFireNum)
  618.  
  619. $("#overviewFurnaceIcon").attr("src", `https://idlepixel.s3.us-east-2.amazonaws.com/images/${furnaceType}.png`)
  620. }
  621.  
  622. clicksLogs(logType){
  623. const action = $('input[name=overviewUseLogsType]:checked').val();
  624. if (action === "none") {return;}
  625. if (action === "heat"){
  626. Modals.clicks_oven_log(logType)
  627. } else if (action === "charcoal"){
  628. if ("slapchop" in IdlePixelPlus.plugins){
  629. IdlePixelPlus.plugins.slapchop.quickFoundry(logType)
  630. } else {
  631. Modals.open_foundry_clicks_log(logType)
  632. }
  633. }
  634. }
  635.  
  636. clicksSeeds(seedType){
  637. if ("slapchop" in IdlePixelPlus.plugins){
  638. IdlePixelPlus.plugins.slapchop.quickPlant(seedType, "altKey")
  639. } else {
  640. Farming.clicks_seed(seedType)
  641. }
  642. }
  643.  
  644. clicksBars(barType){
  645. const oreBarMap = {
  646. bronze_bar: "copper",
  647. iron_bar: "iron",
  648. silver_bar: "silver",
  649. gold_bar: "gold",
  650. promethium_bar: "promethium",
  651. titanium_bar: "titanium",
  652. ancient_bar: "ancient_ore",
  653. dragon_bar: "dragon_ore"
  654. }
  655. if ("slapchop" in IdlePixelPlus.plugins){
  656. IdlePixelPlus.plugins.slapchop.quickSmelt(oreBarMap[barType])
  657. } else {
  658. Modals.open_stardust_or_sell_item_dialogue('crafting', barType)
  659. }
  660. }
  661.  
  662. clicksPotion(potionType){
  663. const potionCount = IdlePixelPlus.getVarOrDefault(potionType, 0, "int")
  664.  
  665. if (potionCount<1){return;}
  666.  
  667. switch(potionType){
  668. case "combat_loot_potion":
  669. if (window["var_combat_loot_potion_timer"] === "0"){
  670. websocket.send(`BREWING_DRINK_COMBAT_LOOT_POTION`);
  671. }
  672. break;
  673. case "rotten_potion":
  674. if (window["var_rotten_potion_timer"] === "0"){
  675. websocket.send(`BREWING_DRINK_ROTTEN_POTION`);
  676. }
  677. break;
  678. case "merchant_speed_potion":
  679. if (window["var_merchant_speed_potion_timer"] === "0"){
  680. websocket.send(`BREWING_DRINK_MERCHANT_SPEED_POTION`);
  681. }
  682. break;
  683. default:
  684. IdlePixelPlus.sendMessage(`DRINK=${potionType}`);
  685. break;
  686. }
  687. }
  688.  
  689. highlightGathering(){
  690. this.gatheringMap = {
  691. mines: "overviewGatheringBoxMines",
  692. fields: "overviewGatheringBoxFields",
  693. forest: "overviewGatheringBoxForest",
  694. fishing_pond: "overviewGatheringBoxFishingPond",
  695. kitchen: "overviewGatheringBoxKitchen",
  696. gem_mine: "overviewGatheringBoxGemMine",
  697. castle: "overviewGatheringBoxCastle",
  698. none: "none"
  699. }
  700.  
  701. const currentArea = IdlePixelPlus.getVarOrDefault("current_gathering_area", "none", "string")
  702. const areaId = this.gatheringMap[currentArea]
  703.  
  704. this.selectedGatheringArea = areaId
  705.  
  706. $(`#${areaId}`).addClass("overviewGatheringBoxSelected")
  707. }
  708.  
  709. changeGatheringArea(newArea){
  710. websocket.send("GATHERING=" + newArea);
  711. const newAreaId = this.gatheringMap[newArea]
  712.  
  713. const previousArea = this.selectedGatheringArea
  714. $(`#${previousArea}`).removeClass("overviewGatheringBoxSelected")
  715.  
  716. $(`#${newAreaId}`).addClass("overviewGatheringBoxSelected")
  717. this.selectedGatheringArea = newAreaId
  718. }
  719. }
  720.  
  721. const plugin = new OverviewPlugin();
  722. IdlePixelPlus.registerPlugin(plugin);
  723. })();