IdlePixel+ Overview Panel

Single panel to control many skills

当前为 2023-12-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IdlePixel+ Overview Panel
  3. // @namespace lbtechnology.info
  4. // @version 1.1.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: false
  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. template: {
  170. itemList: [],
  171. onClickString: ""
  172. }*/
  173. }
  174.  
  175. for (const [containerId, itemData] of Object.entries(standardItemBoxes)) {
  176. this.addStandardItemsToPanel(containerId, itemData)
  177. }
  178. }
  179.  
  180. onMessageReceived(data) {
  181. if(Globals.currentPanel !== "panel-overview"){return;}
  182. if (data.startsWith("SET_ITEMS")){
  183. this.updatePanelTrees()
  184. this.updatePanelPlants()
  185. this.updatePanelCooking()
  186. this.updateSmeltingPanel()
  187. }
  188. }
  189.  
  190. addStyles(){
  191. let borderColour
  192.  
  193. if ("ui-tweaks" in IdlePixelPlus.plugins){
  194. borderColour = IdlePixelPlus.plugins["ui-tweaks"].config["font-color-panels"]
  195. } else {
  196. borderColour = "black"
  197. }
  198.  
  199. $("head").append(`
  200. <style id="styles-overview">
  201. .overviewSkillModule {
  202. border-radius: 3px;
  203. border-style: outset;
  204. }
  205. .overviewGatheringBoxArea {
  206. width: 150px;
  207. height: 150px;
  208. border-radius: 30px;
  209. }
  210. .overviewGatheringBoxSelected {
  211. box-shadow: 0 0 15px #80ed6f;
  212. }
  213. .overviewDottedBorder {
  214. border-radius: 2px;
  215. border: 1px dotted ${borderColour};
  216. }
  217. </style>
  218. `)
  219. }
  220.  
  221. createPanel(){
  222. IdlePixelPlus.addPanel("overview", "Overview", function() {
  223. const content = `
  224. <div id="overviewTopLevelRow" class="row row-cols-3 d-flex flex-wrap">
  225. <div id="overviewFarmingModule" class="col overviewSkillModule">
  226. <div id="overviewBonemealContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  227. <div id="overviewSeedsContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  228. <div id="overviewFarmingPlotContainer" class="row farming-patches-area g-0 overviewDottedBorder">
  229. <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>
  230. <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>
  231. <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>
  232. <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>
  233. <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>
  234. </div>
  235. <div class="row">
  236. <div class="col text-center overviewDottedBorder"><button id="overviewHarvestAll" class="btn btn-primary" type="button" onclick="IdlePixelPlus.plugins.slapchop.quickHarvest()">Harvest All</button></div>
  237. </div>
  238. </div>
  239. <div id="overviewGatheringModule" class="col overviewSkillModule">
  240. <div id="overviewGatheringBagsContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  241. <div id="overviewGatheringAreasContainer" class="row gx-0 gy-2 d-flex justify-content-evenly overviewDottedBorder"></div>
  242. </div>
  243. <div id="overviewMineralModule" class="col overviewSkillModule">
  244. <div id="overviewGemContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  245. <div id="overviewSDCrystalContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  246. <div id="overviewGeodeContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  247. <div id="overviewMineralContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  248. </div>
  249. <div id="overviewWoodcuttingModule" class="col overviewSkillModule">
  250. <div class="row">
  251. <div class="col-lg-3 overviewDottedBorder">
  252. <div>
  253. <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>
  254. <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>
  255. <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>
  256. </div>
  257. </div>
  258. <div class="col">
  259. <div id="overviewLogsContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  260. </div>
  261. </div>
  262. <div id="overviewWCPlotContainer" class="row farming-patches-area g-0 overviewDottedBorder">
  263. <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>
  264. <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>
  265. <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>
  266. <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>
  267. <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>
  268. </div>
  269. <div class="row">
  270. <div class="col text-center overviewDottedBorder"><button id="overviewChopAll" class="btn btn-primary" type="button" onclick="IdlePixelPlus.plugins.slapchop.quickChop()">Chop All</button></div>
  271. </div>
  272. </div>
  273. <div id="overviewSmeltingModule" class="col overviewSkillModule">
  274. <div class="row">
  275. <div class="col">
  276. <div class="row">
  277. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Oil</label><label id="overviewOilNum" class="form-label">0</label></div>
  278. </div>
  279. <div class="row">
  280. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Lava</label><label id="overviewLavaNum" class="form-label">0</label></div>
  281. </div>
  282. <div class="row">
  283. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Buckets</label><label id="overviewBucketsNum" class="form-label">0</label></div>
  284. </div>
  285. </div>
  286. <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>
  287. <div class="col">
  288. <div class="row">
  289. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Charcoal</label><label id="overviewCharcoalNum" 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">Plasma</label><label id="overviewPlasmaNum" 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">D. Fire</label><label id="overviewDFireNum" class="form-label">0</label></div>
  296. </div>
  297. </div>
  298. </div>
  299. <div id="overviewBarsContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  300. <div id="overviewOresContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  301. </div>
  302. <div id="overviewCookingModule" class="col overviewSkillModule">
  303. <div class="row">
  304. <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>
  305. <div class="col text-center align-self-center overviewDottedBorder"><label id="overviewCooksBookTimer" class="col-form-label">0</label></div>
  306. </div>
  307. <div id="overviewRecipeContainer" class="row gx-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  308. </div>
  309. <div id="overviewBrewingModule" class="col overviewSkillModule"></div>
  310. <div id="overviewFishingModule" class="col overviewSkillModule"></div>
  311. <div id="overviewMachineryModule" class="col overviewSkillModule"></div>
  312. </div>
  313. `
  314. return content
  315. });
  316. }
  317.  
  318. applyConfigs() {
  319. // Modules per row
  320. const colClass = "row-cols-" + this.getConfig("colNum")
  321. const topLevel = $("#overviewTopLevelRow")
  322. for(let i = 0; i <= 12 ; i++) {
  323. const oldClass = `row-cols-${i}`
  324. topLevel.removeClass(oldClass)
  325. }
  326.  
  327. topLevel.addClass(colClass)
  328.  
  329. // Enable/disable modules
  330.  
  331. const moduleList = [
  332. ["farmingEnabled", "overviewFarmingModule"],
  333. ["gatheringEnabled", "overviewGatheringModule"],
  334. ["mineralsEnabled", "overviewMineralModule"],
  335. ["woodcuttingEnabled", "overviewWoodcuttingModule"],
  336. ["smeltingEnabled", "overviewSmeltingModule"],
  337. ["cookingEnabled", "overviewCookingModule"],
  338. ["brewingEnabled", "overviewBrewingModule"],
  339. ["fishingEnabled", "overviewFishingModule"],
  340. ["machineryEnabled", "overviewMachineryModule"]
  341. ]
  342.  
  343. moduleList.forEach(module => {
  344. const moduleEnabled = this.getConfig(module[0])
  345.  
  346. const moduleLocation = $(`#${module[1]}`)
  347.  
  348. if (moduleEnabled){
  349. moduleLocation.show()
  350. } else {
  351. moduleLocation.hide()
  352. }
  353. })
  354.  
  355. }
  356.  
  357. formatTimeWithDays(timeInSecs) {
  358. let timerStr = "";
  359. const hour24 = 24 * 60 * 60;
  360.  
  361. const timerDays = Math.floor(timeInSecs / hour24);
  362. if(timeInSecs > hour24) {
  363. timerStr = `${timerDays}d ${format_time(timeInSecs - (timerDays * hour24))}`
  364. } else {
  365. timerStr = `${format_time(timeInSecs - (timerDays * hour24))}`
  366. }
  367. return timerStr;
  368. }
  369.  
  370. getFurnace(){
  371. const furnaceList = ["dragon_furnace", "ancient_furnace", "titanium_furnace", "promethium_furnace", "gold_furnace",
  372. "silver_furnace", "iron_furnace", "bronze_furnace", "stone_furnace"]
  373. for(let i = 0; i < furnaceList.length; i++) {
  374. const furnace = furnaceList[i]
  375. if(window["var_"+furnace]){
  376. return furnace
  377. }
  378. }
  379. return "";
  380. }
  381.  
  382. addStandardItemsToPanel(containerId, itemData){
  383. const itemList = itemData.itemList
  384. const itemOnClick = itemData.onClickString
  385.  
  386. itemList.forEach((itemType) => {
  387. const itemElementString = `<div class="col d-flex justify-content-center">
  388. <itembox data-item="playtime" ov-data-item="${itemType}" id="overview-itembox-${itemType}" onclick="${itemOnClick}" class="shadow hover">
  389. <div class="center mt-1"><img src="https://d1xsc8x7nc5q8t.cloudfront.net/images/${itemType}.png" title="${itemType}"></div>
  390. <div class="center mt-2"> <item-display data-format="number" data-key="${itemType}"></item-display></div>
  391. </itembox>
  392. </div>`
  393. const itemBox = $.parseHTML(itemElementString)
  394. $(`#${containerId}`).append(itemBox)
  395. })
  396. }
  397.  
  398. addGatheringAreasToPanel(){
  399. const areaData = [
  400. {
  401. id: "overviewGatheringBoxMines",
  402. background: "background-dark-grey",
  403. image: "gathering_mine.png",
  404. name: "mines"
  405. },
  406. {
  407. id: "overviewGatheringBoxFields",
  408. background: "background-dark-green",
  409. image: "gathering_field.png",
  410. name: "fields"
  411. },
  412. {
  413. id: "overviewGatheringBoxForest",
  414. background: "background-brown",
  415. image: "gathering_forest.png",
  416. name: "forest"
  417. },
  418. {
  419. id: "overviewGatheringBoxFishingPond",
  420. background: "background-dark-blue",
  421. image: "gathering_fishing_pond.png",
  422. name: "fishing_pond"
  423. },
  424. {
  425. id: "overviewGatheringBoxKitchen",
  426. background: "background-dark-orange",
  427. image: "gathering_kitchen.png",
  428. name: "kitchen"
  429. },
  430. {
  431. id: "overviewGatheringBoxGemMine",
  432. background: "background-dark-cyan",
  433. image: "gathering_gem_mine.png",
  434. name: "gem_mine"
  435. },
  436. {
  437. id: "overviewGatheringBoxCastle",
  438. background: "background-veryrare",
  439. image: "gathering_castle.png",
  440. name: "castle"
  441. }
  442. ]
  443. areaData.forEach((area) => {
  444. const areaId = area.id
  445. const background = area.background
  446. const image = area.image
  447. const name = area.name
  448.  
  449. const areaElementString = `<div class="col d-flex justify-content-center">
  450. <div id="${areaId}" class="d-flex ${background} hover overviewGatheringBoxArea"
  451. ov-data-item="${name}" onclick="IdlePixelPlus.plugins['overview'].changeGatheringArea(this.getAttribute('ov-data-item'))">
  452. <img class="m-auto w-80 h-80" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/${image}" />
  453. </div>
  454. </div>`
  455. const areaBox = $.parseHTML(areaElementString)
  456. $(`#overviewGatheringAreasContainer`).append(areaBox)
  457. })
  458. }
  459. addMeteorsToPanel(){
  460. const meteorString = `
  461. <div class="col d-flex justify-content-center">
  462. <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')">
  463. <div class="center mt-1"><img draggable="false" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/meteor.png" title="meteor"></div>
  464. <div class="center mt-2"><item-display data-format="number" data-key="meteor">0</item-display></div>
  465. </itembox>
  466. </div>`
  467.  
  468. const meteorBox = $.parseHTML(meteorString)
  469. $("#overviewGeodeContainer").append(meteorBox)
  470. }
  471.  
  472. addBonemealbinToPanel(){
  473. const binString = `
  474. <div class="col d-flex justify-content-center">
  475. <itembox data-item="playtime" ov-data-item="bonemeal_bin" class="shadow hover bone-item-box">
  476. <div class="center mt-1"><img draggable="false" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/bonemeal_bin.png" title="bonemeal_bin"></div>
  477. <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>
  478. </itembox>
  479. </div>`
  480.  
  481. const bonemealBox = $.parseHTML(binString)
  482. $("#overviewBonemealContainer").append(bonemealBox)
  483. }
  484.  
  485. toggleMultiHarvest(){
  486. if (!("slapchop" in IdlePixelPlus.plugins)){
  487. $("#overviewChopAll").hide()
  488. $("#overviewHarvestAll").hide()
  489. }
  490. }
  491.  
  492. updatePanelTrees(){
  493. for(let i = 1; i < 6; i++) {
  494. const tree = Items.getItemString("tree_" + i);
  495. const stage = Items.getItem("tree_stage_" + i);
  496. const tree_time = Items.getItem("tree_timer_"+ i)
  497. let time_string
  498.  
  499. if(tree_time===0){
  500. time_string = "EMPTY"
  501. } else if (tree_time===1){
  502. time_string = "READY"
  503. } else {
  504. time_string = this.formatTimeWithDays(tree_time)
  505. }
  506.  
  507. $(`#overviewWoodcuttingTimer-${i}`).html(time_string)
  508.  
  509. let img_url
  510.  
  511. if(tree !== "none"){
  512. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_${tree}_${stage}.png`
  513. } else {
  514. if(i === 4 || i === 5){
  515. if(!DonorShop.has_donor_active(Items.getItem("donor_tree_patches_timestamp"))){
  516. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_locked.png`
  517. } else {
  518. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png`
  519. }
  520. } else {
  521. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png`
  522. }
  523. }
  524. $(`#overviewWoodcuttingPatchImg-${i}`).attr("src", img_url)
  525. }
  526. }
  527.  
  528. updatePanelPlants(){
  529. for(let i = 1; i < 6; i++) {
  530. const crop = Items.getItemString("farm_" + i);
  531. const stage = Items.getItem("farm_stage_" + i);
  532. const crop_time = Items.getItem("farm_timer_"+ i)
  533. let time_string
  534.  
  535. if(crop_time===0){
  536. time_string = "EMPTY"
  537. } else if (crop_time===1){
  538. time_string = "READY"
  539. } else {
  540. time_string = this.formatTimeWithDays(crop_time)
  541. }
  542.  
  543. $(`#overviewFarmingTimer-${i}`).html(time_string)
  544.  
  545. let img_url
  546.  
  547. if(crop !== "none"){
  548. if (Items.getItem("farm_death_" + i) === 1){
  549. img_url = "https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_dead_leaf.png"
  550. } else {
  551. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_${crop}_${stage}.png`
  552. }
  553. } else {
  554. if(i === 4 || i === 5){
  555. if(!DonorShop.has_donor_active(Items.getItem("donor_tree_patches_timestamp"))){
  556. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_locked.png`
  557. } else {
  558. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_none.png`
  559. }
  560. } else {
  561. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_none.png`
  562. }
  563. }
  564. $(`#overviewFarmingPatchImg-${i}`).attr("src", img_url)
  565. }
  566. }
  567. updatePanelCooking() {
  568. let current_item = IdlePixelPlus.getVarOrDefault("cooks_book_item", "cooks_book", "string")
  569. if (current_item === "none"){current_item="cooks_book"}
  570.  
  571. const current_time = IdlePixelPlus.getVarOrDefault("cooks_book_timer", 0, "int")
  572. let formatted_time
  573. if (current_time<=1){
  574. formatted_time = "Completed."
  575. } else {
  576. formatted_time = this.formatTimeWithDays(current_time)
  577. }
  578.  
  579. $("#overviewCooksBookItem").attr("src", `https://d1xsc8x7nc5q8t.cloudfront.net/images/${current_item}.png`)
  580. $("#overviewCooksBookTimer").html(`${formatted_time}`)
  581. }
  582.  
  583. updateSmeltingPanel(){
  584. /*oil, lava, buckets, coal, plasma, fire, furnace, bar_click*/
  585. const oilNum = IdlePixelPlus.getVarOrDefault("oil", 0, "int")
  586. const lavaNum = IdlePixelPlus.getVarOrDefault("lava", 0, "int")
  587. const bucketsNum = IdlePixelPlus.getVarOrDefault("iron_bucket", 0, "int")
  588. const charcoalNum = IdlePixelPlus.getVarOrDefault("charcoal", 0, "int")
  589. const plasmaNum = IdlePixelPlus.getVarOrDefault("plasma", 0, "int")
  590. const dFireNum = IdlePixelPlus.getVarOrDefault("dragon_fire", 0, "int")
  591.  
  592. const furnaceType = this.getFurnace()
  593.  
  594. $("#overviewOilNum").html(oilNum)
  595. $("#overviewLavaNum").html(lavaNum)
  596. $("#overviewBucketsNum").html(bucketsNum)
  597. $("#overviewCharcoalNum").html(charcoalNum)
  598. $("#overviewPlasmaNum").html(plasmaNum)
  599. $("#overviewDFNum").html(dFireNum)
  600.  
  601. $("#overviewFurnaceIcon").attr("src", `https://idlepixel.s3.us-east-2.amazonaws.com/images/${furnaceType}.png`)
  602. }
  603.  
  604. clicksLogs(logType){
  605. const action = $('input[name=overviewUseLogsType]:checked').val();
  606. if (action === "none") {return;}
  607. if (action === "heat"){
  608. Modals.clicks_oven_log(logType)
  609. } else if (action === "charcoal"){
  610. if ("slapchop" in IdlePixelPlus.plugins){
  611. IdlePixelPlus.plugins.slapchop.quickFoundry(logType)
  612. } else {
  613. Modals.open_foundry_clicks_log(logType)
  614. }
  615. }
  616. }
  617.  
  618. clicksSeeds(seedType){
  619. if ("slapchop" in IdlePixelPlus.plugins){
  620. IdlePixelPlus.plugins.slapchop.quickPlant(seedType, "altKey")
  621. } else {
  622. Farming.clicks_seed(seedType)
  623. }
  624. }
  625.  
  626. clicksBars(barType){
  627. const oreBarMap = {
  628. bronze_bar: "copper",
  629. iron_bar: "iron",
  630. silver_bar: "silver",
  631. gold_bar: "gold",
  632. promethium_bar: "promethium",
  633. titanium_bar: "titanium",
  634. ancient_bar: "ancient_ore",
  635. dragon_bar: "dragon_ore"
  636. }
  637. if ("slapchop" in IdlePixelPlus.plugins){
  638. IdlePixelPlus.plugins.slapchop.quickSmelt(oreBarMap[barType])
  639. } else {
  640. Modals.open_stardust_or_sell_item_dialogue('crafting', barType)
  641. }
  642. }
  643.  
  644. highlightGathering(){
  645. this.gatheringMap = {
  646. mines: "overviewGatheringBoxMines",
  647. fields: "overviewGatheringBoxFields",
  648. forest: "overviewGatheringBoxForest",
  649. fishing_pond: "overviewGatheringBoxFishingPond",
  650. kitchen: "overviewGatheringBoxKitchen",
  651. gem_mine: "overviewGatheringBoxGemMine",
  652. castle: "overviewGatheringBoxCastle",
  653. none: "none"
  654. }
  655.  
  656. const currentArea = IdlePixelPlus.getVarOrDefault("current_gathering_area", "none", "string")
  657. const areaId = this.gatheringMap[currentArea]
  658.  
  659. this.selectedGatheringArea = areaId
  660.  
  661. $(`#${areaId}`).addClass("overviewGatheringBoxSelected")
  662. }
  663.  
  664. changeGatheringArea(newArea){
  665. websocket.send("GATHERING=" + newArea);
  666. const newAreaId = this.gatheringMap[newArea]
  667.  
  668. const previousArea = this.selectedGatheringArea
  669. $(`#${previousArea}`).removeClass("overviewGatheringBoxSelected")
  670.  
  671. $(`#${newAreaId}`).addClass("overviewGatheringBoxSelected")
  672. this.selectedGatheringArea = newAreaId
  673. }
  674. }
  675.  
  676. const plugin = new OverviewPlugin();
  677. IdlePixelPlus.registerPlugin(plugin);
  678. })();