Create tooltip for wrinkler buttons #628

This commit is contained in:
Daniël van Noord
2021-03-15 12:51:25 +01:00
parent 71479a05e7
commit 9e9158ce81
7 changed files with 104 additions and 49 deletions

View File

@@ -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';