IdlePixel+ Overview Panel

Single panel to control many skills

当前为 2024-01-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IdlePixel+ Overview Panel
  3. // @namespace lbtechnology.info
  4. // @version 1.4.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. id: "hiddenItems",
  90. label: "Do not edit manually. Use GUI.",
  91. type: "string",
  92. default: ""
  93. }
  94. ]
  95. });
  96. this.previous = "";
  97. this.hiddenConfigActive = false;
  98. }
  99.  
  100. onConfigsChanged() {
  101. this.applyConfigs()
  102. }
  103.  
  104. onLogin() {
  105. window["var_show_item"] = 1 // For overriding Smitty's itembox hiding
  106. this.loadHiddenItems()
  107.  
  108. const onlineCount = $(".top-bar .gold:not(#top-bar-admin-link)");
  109. onlineCount.before(`
  110. <a href="#" class="hover float-end link-no-decoration"
  111. onclick="event.preventDefault(); IdlePixelPlus.setPanel('overview')"
  112. title="Overview">Overview&nbsp;&nbsp;&nbsp;
  113. </a>
  114. `);
  115.  
  116. this.addStyles()
  117. this.createPanel()
  118. this.addBonemealbinToPanel()
  119. this.addMeteorsToPanel()
  120. this.toggleMultiHarvest()
  121. this.addGatheringAreasToPanel()
  122. this.highlightGathering()
  123. this.applyConfigs()
  124.  
  125. const standardItemBoxes = {
  126. overviewLogsContainer: {
  127. itemList: ["logs", "oak_logs", "willow_logs", "maple_logs", "stardust_logs", "pine_logs", "redwood_logs", "dense_logs"],
  128. onClickString: "IdlePixelPlus.plugins['overview'].clicksLogs(this.getAttribute('ov-data-item'))",
  129. onContextMenu: ""
  130. },
  131. overviewBonemealContainer: {
  132. itemList: ["bones", "big_bones", "ice_bones", "blood_bones", "dragon_bones", "ashes"],
  133. onClickString: "IdlePixelPlus.plugins['overview'].clicksBones(this.getAttribute('ov-data-item'), 'left')",
  134. onContextMenu: "IdlePixelPlus.plugins['overview'].clicksBones(this.getAttribute('ov-data-item'), 'right'); return false;"
  135. },
  136. overviewSeedsContainer: {
  137. itemList: [
  138. "dotted_green_leaf_seeds", "green_leaf_seeds", "lime_leaf_seeds", "gold_leaf_seeds",
  139. "crystal_leaf_seeds", "red_mushroom_seeds", "stardust_seeds", "tree_seeds", "oak_tree_seeds",
  140. "willow_tree_seeds", "maple_tree_seeds", "stardust_tree_seeds", "pine_tree_seeds", "redwood_tree_seeds",
  141. "apple_tree_seeds", "banana_tree_seeds", "orange_tree_seeds", "palm_tree_seeds", "dragon_fruit_tree_seeds",
  142. "bone_tree_seeds", "lava_tree_seeds", "strange_tree_seeds", "potato_seeds", "carrot_seeds", "beet_seeds", "broccoli_seeds"
  143. ],
  144. onClickString: "IdlePixelPlus.plugins['overview'].clicksSeeds(this.getAttribute('ov-data-item'), 'left')",
  145. onContextMenu: "IdlePixelPlus.plugins['overview'].clicksSeeds(this.getAttribute('ov-data-item'), 'right'); return false;"
  146. },
  147. overviewBarsContainer: {
  148. itemList: ["bronze_bar", "iron_bar", "silver_bar", "gold_bar", "promethium_bar", "titanium_bar", "ancient_bar", "dragon_bar"],
  149. onClickString: "Modals.open_stardust_or_sell_item_dialogue('crafting', this.getAttribute('ov-data-item'))",
  150. onContextMenu: "IdlePixelPlus.plugins['overview'].rightClicksBars(this.getAttribute('ov-data-item')); return false;"
  151. },
  152. overviewOresContainer: {
  153. itemList: ["stone", "copper", "iron", "silver", "gold", "promethium", "titanium", "ancient_ore", "dragon_ore"],
  154. onClickString: "Modals.open_stardust_or_sell_item_dialogue('mining', this.getAttribute('ov-data-item'))",
  155. onContextMenu: ""
  156. },
  157. overviewRecipeContainer: {
  158. itemList: ["dotted_salad", "chocolate_cake", "lime_leaf_salad", "golden_apple", "banana_jello", "orange_pie", "pancakes", "coconut_stew", "dragon_fruit_salad",
  159. "potato_shake", "carrot_shake", "beet_shake", "broccoli_shake"],
  160. onClickString: "IdlePixelPlus.plugins['overview'].clicksRecipe(this.getAttribute('ov-data-item'), 'left')",
  161. onContextMenu: "IdlePixelPlus.plugins['overview'].clicksRecipe(this.getAttribute('ov-data-item'), 'right'); return false;"
  162. },
  163. overviewGatheringBagsContainer: {
  164. itemList: ["gathering_loot_bag_mines", "gathering_loot_bag_fields", "gathering_loot_bag_forest", "gathering_loot_bag_fishing_pond",
  165. "gathering_loot_bag_kitchen", "gathering_loot_bag_gem_mine", "gathering_loot_bag_castle", "gathering_loot_bag_junk"],
  166. onClickString: "IdlePixelPlus.plugins['overview'].clicksBags(this.getAttribute('ov-data-item'), 'left')",
  167. onContextMenu: "IdlePixelPlus.plugins['overview'].clicksBags(this.getAttribute('ov-data-item'), 'right'); return false;"
  168. },
  169. overviewGemContainer: {
  170. itemList: ["sapphire", "emerald", "ruby", "diamond", "blood_diamond"],
  171. onClickString: "",
  172. onContextMenu: ""
  173. },
  174. overviewSDCrystalContainer: {
  175. itemList: ["small_stardust_prism", "medium_stardust_prism", "large_stardust_prism", "huge_stardust_prism"],
  176. onClickString: "IdlePixelPlus.plugins['overview'].clicksSDCrystals(this.getAttribute('ov-data-item'), 'left')",
  177. onContextMenu: "IdlePixelPlus.plugins['overview'].clicksSDCrystals(this.getAttribute('ov-data-item'), 'right'); return false;"
  178. },
  179. overviewGeodeContainer: {
  180. itemList: ["grey_geode", "blue_geode", "green_geode", "red_geode", "cyan_geode", "ancient_geode"],
  181. onClickString: "IdlePixelPlus.plugins['overview'].clicksGeode(this.getAttribute('ov-data-item'), 'left')",
  182. onContextMenu: "IdlePixelPlus.plugins['overview'].clicksGeode(this.getAttribute('ov-data-item'), 'right'); return false;"
  183. },
  184. overviewMineralContainer: {
  185. itemList: ["blue_marble_mineral", "amethyst_mineral", "sea_crystal_mineral", "dense_marble_mineral", "fluorite_mineral", "clear_marble_mineral",
  186. "jade_mineral", "lime_quartz_mineral", "opal_mineral", "purple_quartz_mineral", "amber_mineral", "smooth_pearl_mineral",
  187. "sulfer_mineral", "topaz_mineral", "tanzanite_mineral", "magnesium_mineral", "frozen_mineral", "blood_crystal_mineral"],
  188. onClickString: "IdlePixelPlus.plugins['overview'].clicksMineral(this.getAttribute('ov-data-item'), 'left')",
  189. onContextMenu: "IdlePixelPlus.plugins['overview'].clicksMineral(this.getAttribute('ov-data-item'), 'right'); return false;"
  190. },
  191. overviewPotionContainer: {
  192. itemList: ["stardust_potion", "energy_potion", "anti_disease_potion", "tree_speed_potion", "smelting_upgrade_potion", "great_stardust_potion", "farming_speed_potion",
  193. "rare_monster_potion", "super_stardust_potion", "gathering_unique_potion", "heat_potion", "bait_potion", "bone_potion", "furnace_speed_potion", "promethium_potion",
  194. "super_rare_monster_potion", "ultra_stardust_potion", "cooks_dust_potion", "fighting_dust_potion", "tree_dust_potion", "farm_dust_potion",
  195. "magic_shiny_crystal_ball_potion", "birdhouse_potion", "rocket_potion", "titanium_potion", "blue_orb_potion", "geode_potion", "magic_crystal_ball_potion",
  196. "stone_converter_potion", "rain_potion", "combat_loot_potion", "rotten_potion", "merchant_speed_potion", "green_orb_potion", "ancient_potion", "guardian_key_potion",
  197. "red_orb_potion"],
  198. onClickString: "IdlePixelPlus.plugins['overview'].clicksPotion(this.getAttribute('ov-data-item'))",
  199. onContextMenu: "IdlePixelPlus.plugins['overview'].rightClicksPotion(this.getAttribute('ov-data-item')); return false;"
  200. }
  201. /*,
  202. template: {
  203. itemList: [],
  204. onClickString: "",
  205. onContextMenu: ""
  206. }*/
  207. }
  208.  
  209. for (const [containerId, itemData] of Object.entries(standardItemBoxes)) {
  210. this.addStandardItemsToPanel(containerId, itemData)
  211. }
  212. this.hideHiddenItems()
  213. }
  214.  
  215. onMessageReceived(data) {
  216. if(Globals.currentPanel !== "panel-overview"){return;}
  217. if (data.startsWith("SET_ITEMS")){
  218. this.updatePanelTrees()
  219. this.updatePanelPlants()
  220. this.updatePanelCooking()
  221. this.updateSmeltingPanel()
  222. }
  223. }
  224.  
  225. addStyles(){
  226. let borderColour
  227.  
  228. if ("ui-tweaks" in IdlePixelPlus.plugins){
  229. borderColour = IdlePixelPlus.plugins["ui-tweaks"].config["font-color-panels"]
  230. } else {
  231. borderColour = "black"
  232. }
  233.  
  234. $("head").append(`
  235. <style id="styles-overview">
  236. .overviewSkillModule {
  237. border-radius: 3px;
  238. border-style: outset;
  239. }
  240. .overviewGatheringBoxArea {
  241. width: 150px;
  242. height: 150px;
  243. border-radius: 30px;
  244. }
  245. .overviewGatheringBoxSelected {
  246. box-shadow: 0 0 15px #80ed6f;
  247. }
  248. .overviewDottedBorder {
  249. border-radius: 2px;
  250. border: 1px dotted ${borderColour};
  251. }
  252. .overviewHiddenItem {
  253. display: none;
  254. }
  255. .overviewConfigCover {
  256. position: absolute;
  257. width: 100px;
  258. height: 100px;
  259. border-radius: 5pt;
  260. }
  261. .overviewHiddenCover {
  262. z-index: -1;
  263. }
  264. .overviewConfigShown {
  265. background-color: rgba(0, 200, 0, 25%);
  266. }
  267. .overviewConfigHidden {
  268. background-color: rgba(200, 0, 0, 25%);
  269. }
  270. </style>
  271. `)
  272. }
  273.  
  274. createPanel(){
  275. const title = `<span>Overview</span><span><button type="button" class="btn btn-outline-primary" style="margin-left: 2%;" onclick="IdlePixelPlus.plugins['overview'].toggleHideConfig()">Hide Items</button></span>`
  276.  
  277. IdlePixelPlus.addPanel("overview", title, function() {
  278. const content = `
  279. <div id="overviewTopLevelRow" class="row row-cols-3 d-flex flex-wrap">
  280. <div id="overviewFarmingModule" class="col overviewSkillModule">
  281. <div id="overviewBonemealContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  282. <div id="overviewSeedsContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  283. <div id="overviewFarmingPlotContainer" class="row farming-patches-area g-0 overviewDottedBorder">
  284. <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>
  285. <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>
  286. <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>
  287. <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>
  288. <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>
  289. </div>
  290. <div class="row">
  291. <div class="col text-center overviewDottedBorder"><button id="overviewHarvestAll" class="btn btn-primary" type="button" onclick="IdlePixelPlus.plugins.slapchop.quickHarvest()">Harvest All</button></div>
  292. </div>
  293. </div>
  294. <div id="overviewGatheringModule" class="col overviewSkillModule">
  295. <div id="overviewGatheringBagsContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  296. <div id="overviewGatheringAreasContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  297. </div>
  298. <div id="overviewMineralModule" class="col overviewSkillModule">
  299. <div id="overviewGemContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  300. <div id="overviewSDCrystalContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  301. <div id="overviewGeodeContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  302. <div id="overviewMineralContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  303. </div>
  304. <div id="overviewWoodcuttingModule" class="col overviewSkillModule">
  305. <div class="row">
  306. <div class="col-lg-3 overviewDottedBorder">
  307. <div>
  308. <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>
  309. <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>
  310. <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>
  311. </div>
  312. </div>
  313. <div class="col">
  314. <div id="overviewLogsContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  315. </div>
  316. </div>
  317. <div id="overviewWCPlotContainer" class="row farming-patches-area g-0 overviewDottedBorder">
  318. <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>
  319. <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>
  320. <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>
  321. <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>
  322. <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>
  323. </div>
  324. <div class="row">
  325. <div class="col text-center overviewDottedBorder"><button id="overviewChopAll" class="btn btn-primary" type="button" onclick="IdlePixelPlus.plugins.slapchop.quickChop()">Chop All</button></div>
  326. </div>
  327. </div>
  328. <div id="overviewSmeltingModule" class="col overviewSkillModule">
  329. <div class="row">
  330. <div class="col">
  331. <div class="row">
  332. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Oil</label><label id="overviewOilNum" class="form-label">0</label></div>
  333. </div>
  334. <div class="row">
  335. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Lava</label><label id="overviewLavaNum" class="form-label">0</label></div>
  336. </div>
  337. <div class="row">
  338. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Buckets</label><label id="overviewBucketsNum" class="form-label">0</label></div>
  339. </div>
  340. </div>
  341. <div class="col text-center align-self-center"><img id="overviewFurnaceIcon" src="https://idlepixel.s3.us-east-2.amazonaws.com/images/promethium_furnace.png" onclick="Modals.open_furnace_dialogue()" /></div>
  342. <div class="col">
  343. <div class="row">
  344. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Charcoal</label><label id="overviewCharcoalNum" class="form-label">0</label></div>
  345. </div>
  346. <div class="row">
  347. <div class="col d-flex justify-content-between overviewDottedBorder"><label class="form-label">Plasma</label><label id="overviewPlasmaNum" class="form-label">0</label></div>
  348. </div>
  349. <div class="row">
  350. <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>
  351. </div>
  352. </div>
  353. </div>
  354. <div id="overviewBarsContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  355. <div id="overviewOresContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  356. </div>
  357. <div id="overviewCookingModule" class="col overviewSkillModule">
  358. <div class="row">
  359. <div class="col-xl-4 text-center align-self-center overviewDottedBorder"><img id="overviewCooksBookItem" style="width: 100px;height: 100px;" onclick="IdlePixelPlus.plugins[&#39;overview&#39;].clicksCooksBook(&#39;left&#39;)" oncontextmenu="IdlePixelPlus.plugins[&#39;overview&#39;].clicksCooksBook(&#39;right&#39;); return false;" /></div>
  360. <div class="col text-center align-self-center overviewDottedBorder"><label id="overviewCooksBookTimer" class="col-form-label">0</label></div>
  361. </div>
  362. <div id="overviewRecipeContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  363. </div>
  364. <div id="overviewBrewingModule" class="col overviewSkillModule">
  365. <div id="overviewPotionContainer" class="row g-0 d-flex justify-content-evenly overviewDottedBorder"></div>
  366. </div>
  367. <div id="overviewFishingModule" class="col overviewSkillModule"></div>
  368. <div id="overviewMachineryModule" class="col overviewSkillModule"></div>
  369. </div>
  370. `
  371. return content
  372. });
  373. }
  374.  
  375. applyConfigs() {
  376. // Modules per row
  377. const colClass = "row-cols-" + this.getConfig("colNum")
  378. const topLevel = $("#overviewTopLevelRow")
  379.  
  380. for(let i = 0; i <= 12 ; i++) {
  381. const oldClass = `row-cols-${i}`
  382. topLevel.removeClass(oldClass)
  383. }
  384.  
  385. topLevel.addClass(colClass)
  386.  
  387. // Enable/disable modules
  388. const moduleList = [
  389. ["farmingEnabled", "overviewFarmingModule"],
  390. ["gatheringEnabled", "overviewGatheringModule"],
  391. ["mineralsEnabled", "overviewMineralModule"],
  392. ["woodcuttingEnabled", "overviewWoodcuttingModule"],
  393. ["smeltingEnabled", "overviewSmeltingModule"],
  394. ["cookingEnabled", "overviewCookingModule"],
  395. ["brewingEnabled", "overviewBrewingModule"],
  396. ["fishingEnabled", "overviewFishingModule"],
  397. ["machineryEnabled", "overviewMachineryModule"]
  398. ]
  399.  
  400. moduleList.forEach(module => {
  401. const moduleEnabled = this.getConfig(module[0])
  402.  
  403. const moduleLocation = $(`#${module[1]}`)
  404.  
  405. if (moduleEnabled){
  406. moduleLocation.show()
  407. } else {
  408. moduleLocation.hide()
  409. }
  410. })
  411. }
  412.  
  413. formatTimeWithDays(timeInSecs) {
  414. let timerStr = "";
  415. const hour24 = 24 * 60 * 60;
  416.  
  417. const timerDays = Math.floor(timeInSecs / hour24);
  418. if(timeInSecs > hour24) {
  419. timerStr = `${timerDays}d ${format_time(timeInSecs - (timerDays * hour24))}`
  420. } else {
  421. timerStr = `${format_time(timeInSecs - (timerDays * hour24))}`
  422. }
  423.  
  424. return timerStr;
  425. }
  426.  
  427. getFurnace(){
  428. const furnaceList = ["dragon_furnace", "ancient_furnace", "titanium_furnace", "promethium_furnace", "gold_furnace",
  429. "silver_furnace", "iron_furnace", "bronze_furnace", "stone_furnace"]
  430. for(let i = 0; i < furnaceList.length; i++) {
  431. const furnace = furnaceList[i]
  432. if(window["var_"+furnace]){
  433. return furnace
  434. }
  435. }
  436. return "";
  437. }
  438.  
  439. addStandardItemsToPanel(containerId, itemData){
  440. const itemList = itemData.itemList
  441. const itemOnClick = itemData.onClickString
  442. const itemRightClick = itemData.onContextMenu
  443.  
  444. itemList.forEach((itemType) => {
  445. const itemElementString = `<div class="col d-flex justify-content-center overviewItemBoxContainer">
  446. <div class="overviewConfigCover overviewHiddenCover" ov-data-item="${itemType}" onclick="IdlePixelPlus.plugins['overview'].toggleCover(this)"></div>
  447. <itembox data-item="show_item" ov-data-item="${itemType}" id="overview-itembox-${itemType}" onclick="${itemOnClick}" onContextMenu="${itemRightClick}" class="shadow hover">
  448. <div class="center mt-1"><img src="https://d1xsc8x7nc5q8t.cloudfront.net/images/${itemType}.png" title="${itemType}"></div>
  449. <div class="center mt-2"> <item-display data-format="number" data-key="${itemType}"></item-display></div>
  450. </itembox>
  451. </div>`
  452. const itemBox = $.parseHTML(itemElementString)
  453. $(`#${containerId}`).append(itemBox)
  454. })
  455. }
  456.  
  457. addGatheringAreasToPanel(){
  458. const areaData = [
  459. {
  460. id: "overviewGatheringBoxMines",
  461. background: "background-dark-grey",
  462. image: "gathering_mine.png",
  463. name: "mines"
  464. },
  465. {
  466. id: "overviewGatheringBoxFields",
  467. background: "background-dark-green",
  468. image: "gathering_field.png",
  469. name: "fields"
  470. },
  471. {
  472. id: "overviewGatheringBoxForest",
  473. background: "background-brown",
  474. image: "gathering_forest.png",
  475. name: "forest"
  476. },
  477. {
  478. id: "overviewGatheringBoxFishingPond",
  479. background: "background-dark-blue",
  480. image: "gathering_fishing_pond.png",
  481. name: "fishing_pond"
  482. },
  483. {
  484. id: "overviewGatheringBoxKitchen",
  485. background: "background-dark-orange",
  486. image: "gathering_kitchen.png",
  487. name: "kitchen"
  488. },
  489. {
  490. id: "overviewGatheringBoxGemMine",
  491. background: "background-dark-cyan",
  492. image: "gathering_gem_mine.png",
  493. name: "gem_mine"
  494. },
  495. {
  496. id: "overviewGatheringBoxCastle",
  497. background: "background-veryrare",
  498. image: "gathering_castle.png",
  499. name: "castle"
  500. }
  501. ]
  502.  
  503. areaData.forEach((area) => {
  504. const areaId = area.id
  505. const background = area.background
  506. const image = area.image
  507. const name = area.name
  508.  
  509. const areaElementString = `<div class="col d-flex justify-content-center">
  510. <div id="${areaId}" class="d-flex ${background} hover overviewGatheringBoxArea"
  511. ov-data-item="${name}" onclick="IdlePixelPlus.plugins['overview'].changeGatheringArea(this.getAttribute('ov-data-item'))">
  512. <img class="m-auto w-80 h-80" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/${image}" />
  513. </div>
  514. </div>`
  515. const areaBox = $.parseHTML(areaElementString)
  516. $(`#overviewGatheringAreasContainer`).append(areaBox)
  517. })
  518. }
  519.  
  520. addMeteorsToPanel(){
  521. const meteorString = `
  522. <div class="col d-flex justify-content-center">
  523. <itembox data-item="show_item" ov-data-item="meteor" class="shadow hover itembox-resource-mining-1"
  524. onclick="Modals.open_image_modal('METEOR', 'images/meteor.png', 'Mine the material from the meteor?', 'Mine it!', 'Close', 'MINE_METEOR')"
  525. oncontextmenu="websocket.send('MINE_METEOR')"
  526. >
  527. <div class="center mt-1"><img draggable="false" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/meteor.png" title="meteor"></div>
  528. <div class="center mt-2"><item-display data-format="number" data-key="meteor">0</item-display></div>
  529. </itembox>
  530. </div>`
  531.  
  532. const meteorBox = $.parseHTML(meteorString)
  533. $("#overviewGeodeContainer").append(meteorBox)
  534. }
  535.  
  536. addBonemealbinToPanel(){
  537. const binString = `
  538. <div class="col d-flex justify-content-center">
  539. <itembox data-item="show_item" ov-data-item="bonemeal_bin" class="shadow hover bone-item-box">
  540. <div class="center mt-1"><img draggable="false" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/bonemeal_bin.png" title="bonemeal_bin"></div>
  541. <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>
  542. </itembox>
  543. </div>`
  544.  
  545. const bonemealBox = $.parseHTML(binString)
  546. $("#overviewBonemealContainer").append(bonemealBox)
  547. }
  548.  
  549. toggleMultiHarvest(){
  550. if (!("slapchop" in IdlePixelPlus.plugins)){
  551. $("#overviewChopAll").hide()
  552. $("#overviewHarvestAll").hide()
  553. }
  554. }
  555.  
  556. updatePanelTrees(){
  557. for(let i = 1; i < 6; i++) {
  558. const tree = Items.getItemString("tree_" + i);
  559. const stage = Items.getItem("tree_stage_" + i);
  560. const tree_time = Items.getItem("tree_timer_"+ i)
  561. let time_string
  562.  
  563. if(tree_time===0){
  564. time_string = "EMPTY"
  565. } else if (tree_time===1){
  566. time_string = "READY"
  567. } else {
  568. time_string = this.formatTimeWithDays(tree_time)
  569. }
  570.  
  571. $(`#overviewWoodcuttingTimer-${i}`).html(time_string)
  572.  
  573. let img_url
  574.  
  575. if(tree !== "none"){
  576. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_${tree}_${stage}.png`
  577. } else {
  578. if(i === 4 || i === 5){
  579. if(!DonorShop.has_donor_active(Items.getItem("donor_tree_patches_timestamp"))){
  580. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_locked.png`
  581. } else {
  582. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png`
  583. }
  584. } else {
  585. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/woodcutting_none.png`
  586. }
  587. }
  588. $(`#overviewWoodcuttingPatchImg-${i}`).attr("src", img_url)
  589. }
  590. }
  591.  
  592. updatePanelPlants(){
  593. for(let i = 1; i < 6; i++) {
  594. const crop = Items.getItemString("farm_" + i);
  595. const stage = Items.getItem("farm_stage_" + i);
  596. const crop_time = Items.getItem("farm_timer_"+ i)
  597. let time_string
  598.  
  599. if(crop_time===0){
  600. time_string = "EMPTY"
  601. } else if (crop_time===1){
  602. time_string = "READY"
  603. } else {
  604. time_string = this.formatTimeWithDays(crop_time)
  605. }
  606.  
  607. $(`#overviewFarmingTimer-${i}`).html(time_string)
  608.  
  609. let img_url
  610.  
  611. if(crop !== "none"){
  612. if (Items.getItem("farm_death_" + i) === 1){
  613. img_url = "https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_dead_leaf.png"
  614. } else {
  615. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_${crop}_${stage}.png`
  616. }
  617. } else {
  618. if(i === 4 || i === 5){
  619. if(!DonorShop.has_donor_active(Items.getItem("donor_tree_patches_timestamp"))){
  620. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_locked.png`
  621. } else {
  622. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_none.png`
  623. }
  624. } else {
  625. img_url = `https://idlepixel.s3.us-east-2.amazonaws.com/images/farming_none.png`
  626. }
  627. }
  628. $(`#overviewFarmingPatchImg-${i}`).attr("src", img_url)
  629. }
  630. }
  631.  
  632. updatePanelCooking() {
  633. let current_item = IdlePixelPlus.getVarOrDefault("cooks_book_item", "cooks_book", "string")
  634. if (current_item === "none"){current_item="cooks_book"}
  635.  
  636. const current_time = IdlePixelPlus.getVarOrDefault("cooks_book_timer", 0, "int")
  637. let formatted_time
  638. if (current_time<=1){
  639. formatted_time = "Completed."
  640. } else {
  641. formatted_time = this.formatTimeWithDays(current_time)
  642. }
  643.  
  644. $("#overviewCooksBookItem").attr("src", `https://d1xsc8x7nc5q8t.cloudfront.net/images/${current_item}.png`)
  645. $("#overviewCooksBookTimer").html(`${formatted_time}`)
  646. }
  647.  
  648. updateSmeltingPanel(){
  649. /*oil, lava, buckets, coal, plasma, fire, furnace, bar_click*/
  650. const oilNum = IdlePixelPlus.getVarOrDefault("oil", 0, "int")
  651. const lavaNum = IdlePixelPlus.getVarOrDefault("lava", 0, "int")
  652. const bucketsNum = IdlePixelPlus.getVarOrDefault("iron_bucket", 0, "int")
  653. const charcoalNum = IdlePixelPlus.getVarOrDefault("charcoal", 0, "int")
  654. const plasmaNum = IdlePixelPlus.getVarOrDefault("plasma", 0, "int")
  655. const dFireNum = IdlePixelPlus.getVarOrDefault("dragon_fire", 0, "int")
  656.  
  657. const furnaceType = this.getFurnace()
  658.  
  659. $("#overviewOilNum").html(oilNum)
  660. $("#overviewLavaNum").html(lavaNum)
  661. $("#overviewBucketsNum").html(bucketsNum)
  662. $("#overviewCharcoalNum").html(charcoalNum)
  663. $("#overviewPlasmaNum").html(plasmaNum)
  664. $("#overviewDFNum").html(dFireNum)
  665.  
  666. $("#overviewFurnaceIcon").attr("src", `https://idlepixel.s3.us-east-2.amazonaws.com/images/${furnaceType}.png`)
  667. }
  668.  
  669. clicksLogs(logType){
  670. const action = $('input[name=overviewUseLogsType]:checked').val();
  671. if (action === "none") {return;}
  672. if (action === "heat"){
  673. Modals.clicks_oven_log(logType)
  674. } else if (action === "charcoal"){
  675. if ("slapchop" in IdlePixelPlus.plugins){
  676. IdlePixelPlus.plugins.slapchop.quickFoundry(logType)
  677. } else {
  678. Modals.open_foundry_clicks_log(logType)
  679. }
  680. }
  681. }
  682.  
  683. clicksSeeds(seedType, clickType){
  684. let n = IdlePixelPlus.getVarOrDefault(seedType, 0, "int");
  685.  
  686. if(clickType==="left" && n>1) {
  687. n = 1;
  688. }
  689. const donor = DonorShop.has_donor_active(Items.getItem("donor_farm_patches_timestamp"));
  690. const maxPlot = donor ? 5 : 3;
  691. for(let plot = 1; plot <= maxPlot && n > 0; plot++) {
  692. if(IdlePixelPlus.getVar(`farm_${plot}`) === "none") {
  693. websocket.send(`PLANT=${seedType}~${plot}`);
  694. n--;
  695. }
  696. }
  697. }
  698.  
  699. rightClicksBars(barType){
  700. const oreBarMap = {
  701. bronze_bar: "copper",
  702. iron_bar: "iron",
  703. silver_bar: "silver",
  704. gold_bar: "gold",
  705. promethium_bar: "promethium",
  706. titanium_bar: "titanium",
  707. ancient_bar: "ancient_ore",
  708. dragon_bar: "dragon_ore"
  709. }
  710. if ("slapchop" in IdlePixelPlus.plugins){
  711. IdlePixelPlus.plugins.slapchop.quickSmelt(oreBarMap[barType])
  712. } else {
  713. Modals.open_stardust_or_sell_item_dialogue('crafting', barType)
  714. }
  715. }
  716.  
  717. clicksBags(bagType, clickType){
  718. const area = bagType.slice(19)
  719. const num = IdlePixelPlus.getVarOrDefault(bagType, 0, "int");
  720.  
  721. if (clickType === "left"){
  722. Modals.open_input_dialogue_with_value(area, 'Open', 'How many?', num, 'OPEN_GATHERING_LOOT')
  723. } else if (num > 0) {
  724. websocket.send(`OPEN_GATHERING_LOOT=${area}~${num}`);
  725. }
  726. }
  727.  
  728. clicksSDCrystals(crystalType, clickType){
  729. const num = IdlePixelPlus.getVarOrDefault(crystalType, 0, "int");
  730.  
  731. if (clickType === "left"){
  732. Modals.open_input_dialogue_with_value(crystalType, 'Smash', 'How many stardust prism do you want to smash?', num, 'SMASH_STARDUST_PRISM')
  733. } else if (num > 0 ){
  734. websocket.send(`SMASH_STARDUST_PRISM=${crystalType}~${num}`);
  735. }
  736. }
  737.  
  738. clicksGeode(geodeType, clickType){
  739. const num = IdlePixelPlus.getVarOrDefault(geodeType, 0, "int");
  740.  
  741. if (clickType === "left"){
  742. Modals.open_input_dialogue_with_value(geodeType, 'Open', 'How many geodes to you want to crack?', num, 'CRACK_GEODE')
  743. } else if (num > 0 ){
  744. websocket.send(`CRACK_GEODE=${geodeType}~${num}`)
  745. }
  746. }
  747.  
  748. clicksMineral(mineralType, clickType){
  749. const num = IdlePixelPlus.getVarOrDefault(mineralType, 0, "int");
  750.  
  751. if (clickType === "left"){
  752. Modals.clicks_mineral(mineralType)
  753. } else if (num > 0 ){
  754. websocket.send(`MINERAL_XP=${mineralType}~${num}`)
  755. }
  756. }
  757.  
  758. clicksBones(boneType, clickType){
  759. const num = IdlePixelPlus.getVarOrDefault(boneType, 0, "int");
  760.  
  761. if (clickType === "left"){
  762. Farming.clicks_bones(boneType)
  763. } else if (num > 0 ){
  764. websocket.send(`ADD_BONEMEAL=${boneType}~${num}`);
  765. }
  766. }
  767.  
  768. clicksCooksBook(clickType){
  769. const currentRecipe = IdlePixelPlus.getVarOrDefault("cooks_book_item", "none", "string")
  770. if (currentRecipe==="none"){return;}
  771.  
  772. websocket.send("COOKS_BOOK_READY")
  773.  
  774. if (clickType === "left"){return;}
  775.  
  776. websocket.send(`COOKS_BOOK=${currentRecipe}`)
  777. }
  778.  
  779. clicksRecipe(recipe, clickType){
  780. if (clickType === "right"){
  781. websocket.send("COOKS_BOOK_READY")
  782. }
  783.  
  784. websocket.send(`COOKS_BOOK=${recipe}`)
  785. }
  786.  
  787. clicksPotion(potionType){
  788. websocket.send(`BREW=${potionType}~1`)
  789. }
  790.  
  791. rightClicksPotion(potionType){
  792. const potionCount = IdlePixelPlus.getVarOrDefault(potionType, 0, "int")
  793.  
  794. if (potionCount<1){return;}
  795.  
  796. switch(potionType){
  797. case "combat_loot_potion":
  798. if (window["var_combat_loot_potion_timer"] === "0"){
  799. websocket.send(`BREWING_DRINK_COMBAT_LOOT_POTION`);
  800. }
  801. break;
  802. case "rotten_potion":
  803. if (window["var_rotten_potion_timer"] === "0"){
  804. websocket.send(`BREWING_DRINK_ROTTEN_POTION`);
  805. }
  806. break;
  807. case "merchant_speed_potion":
  808. if (window["var_merchant_speed_potion_timer"] === "0"){
  809. websocket.send(`BREWING_DRINK_MERCHANT_SPEED_POTION`);
  810. }
  811. break;
  812. default:
  813. websocket.send(`DRINK=${potionType}`);
  814. break;
  815. }
  816. }
  817.  
  818. highlightGathering(){
  819. this.gatheringMap = {
  820. mines: "overviewGatheringBoxMines",
  821. fields: "overviewGatheringBoxFields",
  822. forest: "overviewGatheringBoxForest",
  823. fishing_pond: "overviewGatheringBoxFishingPond",
  824. kitchen: "overviewGatheringBoxKitchen",
  825. gem_mine: "overviewGatheringBoxGemMine",
  826. castle: "overviewGatheringBoxCastle",
  827. none: "none"
  828. }
  829.  
  830. const currentArea = IdlePixelPlus.getVarOrDefault("current_gathering_area", "none", "string")
  831. const areaId = this.gatheringMap[currentArea]
  832.  
  833. this.selectedGatheringArea = areaId
  834.  
  835. $(`#${areaId}`).addClass("overviewGatheringBoxSelected")
  836. }
  837.  
  838. changeGatheringArea(newArea){
  839. websocket.send("GATHERING=" + newArea);
  840. const newAreaId = this.gatheringMap[newArea]
  841.  
  842. const previousArea = this.selectedGatheringArea
  843. $(`#${previousArea}`).removeClass("overviewGatheringBoxSelected")
  844.  
  845. $(`#${newAreaId}`).addClass("overviewGatheringBoxSelected")
  846. this.selectedGatheringArea = newAreaId
  847. }
  848.  
  849. toggleHideConfig(){
  850. if (this.hiddenConfigActive){
  851. this.exitHideConfig()
  852. } else {
  853. this.enterHideConfig()
  854. }
  855.  
  856. this.hiddenConfigActive = !this.hiddenConfigActive
  857. }
  858.  
  859. loadHiddenItems(){
  860. const itemListString = this.getConfig("hiddenItems")
  861. const itemList = itemListString.split(",")
  862.  
  863. if (itemList[0]===""){itemList.shift()}
  864.  
  865. this.hiddenItems = itemList
  866. }
  867.  
  868. saveHiddenItems(){
  869. IdlePixelPlus.refreshPanel("idlepixelplus")
  870. $(`#idlepixelplus-config-overview-hiddenItems`).val(this.hiddenItems.toString())
  871. IdlePixelPlus.savePluginConfigs("overview")
  872. }
  873.  
  874. toggleCover(cover){
  875. const item = cover.getAttribute('ov-data-item')
  876.  
  877. if(this.hiddenItems.includes(item)){
  878. this.hiddenItems.splice(this.hiddenItems.indexOf(item), 1)
  879. cover.classList.add("overviewConfigShown")
  880. cover.classList.remove("overviewConfigHidden")
  881. } else {
  882. this.hiddenItems.push(item)
  883. cover.classList.remove("overviewConfigShown")
  884. cover.classList.add("overviewConfigHidden")
  885.  
  886. }
  887. }
  888.  
  889. enterHideConfig(){
  890. const overviewPanel = $("#overviewTopLevelRow")
  891. const allItemContainers = $(".overviewItemBoxContainer", overviewPanel)
  892. const allItemCovers = $(".overviewConfigCover", overviewPanel)
  893.  
  894. allItemContainers.removeClass("overviewHiddenItem")
  895. allItemContainers.addClass("d-flex")
  896. allItemCovers.removeClass("overviewHiddenCover")
  897. allItemCovers.addClass("overviewConfigShown")
  898.  
  899. this.hiddenItems.forEach(item => {
  900. const itemContainer = $(`itembox[ov-data-item=${item}]`).parent()
  901. const cover = $(".overviewConfigCover", itemContainer)
  902. cover.removeClass("overviewConfigShown")
  903. cover.addClass("overviewConfigHidden")
  904. })
  905. }
  906.  
  907. exitHideConfig(){
  908. const overviewPanel = $("#overviewTopLevelRow")
  909. const allItemCovers = $(".overviewConfigCover", overviewPanel)
  910.  
  911. allItemCovers.addClass("overviewHiddenCover")
  912.  
  913. this.hideHiddenItems()
  914. this.saveHiddenItems()
  915. }
  916.  
  917. hideHiddenItems() {
  918. const overviewPanel = $("#overviewTopLevelRow")
  919.  
  920. this.hiddenItems.forEach(item => {
  921. const itemContainer = $(`itembox[ov-data-item=${item}]`).parent()
  922. itemContainer.addClass("overviewHiddenItem")
  923. itemContainer.removeClass("d-flex")
  924. })
  925. }
  926. }
  927.  
  928. const plugin = new OverviewPlugin();
  929. IdlePixelPlus.registerPlugin(plugin);
  930.  
  931. })();