Create tooltip for wrinkler buttons #628
This commit is contained in:
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js
vendored
2
dist/CookieMonster.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js.map
vendored
2
dist/CookieMonster.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@ import UpdateUpgrades from './BuildingsUpgrades/Upgrades';
|
||||
import { UpdateBotBar } from './InfoBars/BottomBar';
|
||||
import { UpdateTimerBar } from './InfoBars/TimerBar';
|
||||
import RefreshMenu from './MenuSections/Refreshmenu';
|
||||
import { UpdateTooltips } from './Tooltips/Tooltip';
|
||||
import UpdateTooltips from './Tooltips/UpdateTooltips';
|
||||
import {
|
||||
CheckWrinklerTooltip,
|
||||
UpdateWrinklerTooltip,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { CacheWrinklersFattest } from '../../Cache/VariablesAndData';
|
||||
import PopAllNormalWrinklers from '../HelperFunctions/PopWrinklers';
|
||||
import { CreateTooltip } from '../Tooltips/Tooltip';
|
||||
|
||||
/**
|
||||
* This function creates two objects at the bottom of the left column that allowing popping of wrinklers
|
||||
@@ -12,6 +13,20 @@ export default function CreateWrinklerButtons() {
|
||||
popAllA.onclick = function () {
|
||||
PopAllNormalWrinklers();
|
||||
};
|
||||
popAllA.onmouseout = function () {
|
||||
Game.tooltip.shouldHide = 1;
|
||||
};
|
||||
popAllA.onmouseover = function () {
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(
|
||||
this,
|
||||
function () {
|
||||
return CreateTooltip('wb', 'PopAll');
|
||||
},
|
||||
'this',
|
||||
);
|
||||
Game.tooltip.wobble();
|
||||
};
|
||||
l('sectionLeftExtra').children[0].append(popAllA);
|
||||
const popFattestA = document.createElement('a');
|
||||
popFattestA.id = 'PopFattestWrinklerButton';
|
||||
@@ -21,5 +36,19 @@ export default function CreateWrinklerButtons() {
|
||||
if (CacheWrinklersFattest[1] !== null)
|
||||
Game.wrinklers[CacheWrinklersFattest[1]].hp = 0;
|
||||
};
|
||||
popFattestA.onmouseout = function () {
|
||||
Game.tooltip.shouldHide = 1;
|
||||
};
|
||||
popFattestA.onmouseover = function () {
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(
|
||||
this,
|
||||
function () {
|
||||
return CreateTooltip('wb', 'PopFattest');
|
||||
},
|
||||
'this',
|
||||
);
|
||||
Game.tooltip.wobble();
|
||||
};
|
||||
l('sectionLeftExtra').children[0].append(popFattestA);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import * as UpdateTooltip from './UpdateTooltips';
|
||||
import UpdateTooltips, * as UpdateTooltip from './UpdateTooltips';
|
||||
import { TooltipCreateTooltipBox } from './CreateTooltip';
|
||||
import {
|
||||
Beautify,
|
||||
@@ -32,38 +32,6 @@ export function CreateSimpleTooltip(placeholder, text, minWidth) {
|
||||
Tooltip.appendChild(desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function updates the sections of the tooltips created by CookieMonster
|
||||
*/
|
||||
export function UpdateTooltips() {
|
||||
CopyData();
|
||||
if (l('tooltipAnchor').style.display !== 'none' && l('CMTooltipArea')) {
|
||||
l('CMTooltipArea').innerHTML = '';
|
||||
const tooltipBox = TooltipCreateTooltipBox();
|
||||
l('CMTooltipArea').appendChild(tooltipBox);
|
||||
|
||||
if (TooltipType === 'b') {
|
||||
UpdateTooltip.Building();
|
||||
} else if (TooltipType === 'u') {
|
||||
UpdateTooltip.Upgrade();
|
||||
} else if (TooltipType === 's') {
|
||||
UpdateTooltip.SugarLump();
|
||||
} else if (TooltipType === 'g') {
|
||||
UpdateTooltip.Grimoire();
|
||||
} else if (TooltipType === 'p') {
|
||||
UpdateTooltip.GardenPlots();
|
||||
} else if (TooltipType === 'ha') {
|
||||
UpdateTooltip.HarvestAll();
|
||||
}
|
||||
UpdateTooltip.Warnings();
|
||||
} else if (l('CMTooltipArea') === null) {
|
||||
// Remove warnings if its a basic tooltip
|
||||
if (l('CMDispTooltipWarningParent') !== null) {
|
||||
l('CMDispTooltipWarningParent').remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function enhance the standard tooltips by creating and changing l('tooltip')
|
||||
* The function is called by .onmouseover events that have replaced original code to use CM.Disp.Tooltip()
|
||||
@@ -141,9 +109,10 @@ export function CreateTooltip(type, name) {
|
||||
name[0],
|
||||
name[1],
|
||||
)();
|
||||
// Garden plots
|
||||
// Harvest all button in garden
|
||||
else if (type === 'ha')
|
||||
l('tooltip').innerHTML = Game.ObjectsById[2].minigame.toolTooltip(1)(); // Harvest all button in garden
|
||||
l('tooltip').innerHTML = Game.ObjectsById[2].minigame.toolTooltip(1)();
|
||||
else if (type === 'wb') l('tooltip').innerHTML = '';
|
||||
|
||||
// Adds area for extra tooltip-sections
|
||||
if (
|
||||
@@ -152,7 +121,8 @@ export function CreateTooltip(type, name) {
|
||||
type === 's' ||
|
||||
type === 'g' ||
|
||||
(type === 'p' && !Game.keys[16]) ||
|
||||
type === 'ha'
|
||||
type === 'ha' ||
|
||||
type === 'wb'
|
||||
) {
|
||||
const area = document.createElement('div');
|
||||
area.id = 'CMTooltipArea';
|
||||
|
||||
@@ -8,9 +8,12 @@ import {
|
||||
CacheObjects10,
|
||||
CacheObjects100,
|
||||
CacheUpgrades,
|
||||
CacheWrinklersFattest,
|
||||
CacheWrinklersTotal,
|
||||
} from '../../Cache/VariablesAndData';
|
||||
import ToggleToolWarnPos from '../../Config/Toggles/ToggleToolWarnPos';
|
||||
import { CMOptions } from '../../Config/VariablesAndData';
|
||||
import CopyData from '../../Sim/SimulationData/CopyData';
|
||||
import { SimObjects } from '../../Sim/VariablesAndData';
|
||||
import {
|
||||
Beautify,
|
||||
@@ -37,7 +40,7 @@ import * as Create from './CreateTooltip';
|
||||
/**
|
||||
* This function adds extra info to the Building tooltips
|
||||
*/
|
||||
export function Building() {
|
||||
function Building() {
|
||||
if (CMOptions.TooltipBuildUpgrade === 1 && Game.buyMode === 1) {
|
||||
const tooltipBox = l('CMTooltipBorder');
|
||||
Create.TooltipCreateCalculationSection(tooltipBox);
|
||||
@@ -111,7 +114,7 @@ export function Building() {
|
||||
/**
|
||||
* This function adds extra info to the Upgrade tooltips
|
||||
*/
|
||||
export function Upgrade() {
|
||||
function Upgrade() {
|
||||
const tooltipBox = l('CMTooltipBorder');
|
||||
Create.TooltipCreateCalculationSection(tooltipBox);
|
||||
|
||||
@@ -200,7 +203,7 @@ export function Upgrade() {
|
||||
* This function adds extra info to the Sugar Lump tooltip
|
||||
* It adds to the additional information to l('CMTooltipArea')
|
||||
*/
|
||||
export function SugarLump() {
|
||||
function SugarLump() {
|
||||
if (CMOptions.TooltipLump === 1) {
|
||||
const tooltipBox = l('CMTooltipBorder');
|
||||
|
||||
@@ -219,7 +222,7 @@ export function SugarLump() {
|
||||
* This function adds extra info to the Grimoire tooltips
|
||||
* It adds to the additional information to l('CMTooltipArea')
|
||||
*/
|
||||
export function Grimoire() {
|
||||
function Grimoire() {
|
||||
const minigame = Game.Objects['Wizard tower'].minigame;
|
||||
const spellCost = minigame.getSpellCost(minigame.spellsById[TooltipName]);
|
||||
|
||||
@@ -289,7 +292,7 @@ export function Grimoire() {
|
||||
* This function adds extra info to the Garden plots tooltips
|
||||
* It adds to the additional information to l('CMTooltipArea')
|
||||
*/
|
||||
export function GardenPlots() {
|
||||
function GardenPlots() {
|
||||
const minigame = Game.Objects.Farm.minigame;
|
||||
if (
|
||||
CMOptions.TooltipPlots &&
|
||||
@@ -341,7 +344,7 @@ export function GardenPlots() {
|
||||
* It is called when the Harvest All tooltip is created or refreshed by CM.Disp.UpdateTooltip()
|
||||
* It adds to the additional information to l('CMTooltipArea')
|
||||
*/
|
||||
export function HarvestAll() {
|
||||
function HarvestAll() {
|
||||
const minigame = Game.Objects.Farm.minigame;
|
||||
if (CMOptions.TooltipLump) {
|
||||
l('CMTooltipBorder').appendChild(
|
||||
@@ -391,10 +394,28 @@ export function HarvestAll() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function updates the warnings section of the building and upgrade tooltips
|
||||
* It is called by CM.Disp.UpdateTooltip()
|
||||
* This function adds extra info to the wrinkler button tooltip
|
||||
* It adds to the additional information to l('CMTooltipArea')
|
||||
*/
|
||||
export function Warnings() {
|
||||
function WrinklerButton() {
|
||||
l('tooltip').innerHTML = '';
|
||||
l('tooltip').appendChild(Create.TooltipCreateHeader('Reward:'));
|
||||
|
||||
const WrinklerReward = document.createElement('div');
|
||||
WrinklerReward.id = 'CMWrinklerReward';
|
||||
if (TooltipName === 'PopAll') {
|
||||
WrinklerReward.textContent = CacheWrinklersTotal;
|
||||
} else if (TooltipName === 'PopFattest') {
|
||||
WrinklerReward.textContent = CacheWrinklersFattest[0];
|
||||
}
|
||||
|
||||
l('tooltip').appendChild(WrinklerReward);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function updates the warnings section of the building and upgrade tooltips
|
||||
*/
|
||||
function Warnings() {
|
||||
if (TooltipType === 'b' || TooltipType === 'u') {
|
||||
if (document.getElementById('CMDispTooltipWarningParent') === null) {
|
||||
l('tooltipAnchor').appendChild(Create.TooltipCreateWarningSection());
|
||||
@@ -517,3 +538,38 @@ export function Warnings() {
|
||||
l('CMDispTooltipWarningParent').remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function updates the sections of the tooltips created by CookieMonster
|
||||
*/
|
||||
export default function UpdateTooltips() {
|
||||
CopyData();
|
||||
if (l('tooltipAnchor').style.display !== 'none' && l('CMTooltipArea')) {
|
||||
l('CMTooltipArea').innerHTML = '';
|
||||
const tooltipBox = Create.TooltipCreateTooltipBox();
|
||||
l('CMTooltipArea').appendChild(tooltipBox);
|
||||
|
||||
if (TooltipType === 'b') {
|
||||
Building();
|
||||
} else if (TooltipType === 'u') {
|
||||
Upgrade();
|
||||
} else if (TooltipType === 's') {
|
||||
SugarLump();
|
||||
} else if (TooltipType === 'g') {
|
||||
Grimoire();
|
||||
} else if (TooltipType === 'p') {
|
||||
GardenPlots();
|
||||
} else if (TooltipType === 'ha') {
|
||||
HarvestAll();
|
||||
} else if (TooltipType === 'wb') {
|
||||
l('CMTooltipArea').innerHTML = '';
|
||||
WrinklerButton();
|
||||
}
|
||||
Warnings();
|
||||
} else if (l('CMTooltipArea') === null) {
|
||||
// Remove warnings if its a basic tooltip
|
||||
if (l('CMDispTooltipWarningParent') !== null) {
|
||||
l('CMDispTooltipWarningParent').remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user