Moved most replace tooltip funcs to Main.js

This commit is contained in:
Daniel van Noord
2021-01-23 22:36:26 +01:00
parent 1875423a7b
commit 29ba1c66cf
3 changed files with 136 additions and 128 deletions

View File

@@ -2352,31 +2352,10 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) {
CM.Disp[placeholder].appendChild(desc); CM.Disp[placeholder].appendChild(desc);
} }
/**
* This function replaces the original .onmouseover functions of buildings so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'b'
* It is called by CM.DelayInit()
* TODO: Place all ReplaceTooltip functions either under CM.DelayInit() or CM.ReplaceNative()
* TODO: Move this code to Main.js file
*/
CM.Disp.ReplaceTooltipBuild = function() {
CM.Disp.TooltipBuildBackup = [];
for (var i in Game.Objects) {
var me = Game.Objects[i];
if (l('product' + me.id).onmouseover != null) {
CM.Disp.TooltipBuildBackup[i] = l('product' + me.id).onmouseover;
eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}');
}
}
}
/** /**
* This function replaces the original .onmouseover functions of upgrades so that it calls CM.Disp.Tooltip() * This function replaces the original .onmouseover functions of upgrades so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'u' * CM.Disp.Tooltip() sets the tooltip type to 'u'
* It is called by CM.ReplaceNative() * It is called by Game.RebuildUpgrades() through CM.ReplaceNative() and is therefore not permanent like the other ReplaceTooltip functions
* TODO: Place all ReplaceTooltip functions either under CM.DelayInit() or CM.ReplaceNative()
* TODO: Move this code to Main.js file
*
*/ */
CM.Disp.ReplaceTooltipUpgrade = function() { CM.Disp.ReplaceTooltipUpgrade = function() {
CM.Disp.TooltipUpgradeBackup = []; CM.Disp.TooltipUpgradeBackup = [];
@@ -2389,39 +2368,6 @@ CM.Disp.ReplaceTooltipUpgrade = function() {
} }
} }
/**
* This function replaces the original .onmouseover functions of the Grimoire minigame so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'g'
* The function is called by CM.DelayInit()
* TODO: Place all ReplaceTooltip functions either under CM.DelayInit() or CM.ReplaceNative()
* TODO: Move this code to Main.js file
*/
CM.Disp.ReplaceTooltipGrimoire = function() {
if (Game.Objects['Wizard tower'].minigameLoaded) {
CM.Disp.TooltipGrimoireBackup = [];
for (var i in Game.Objects['Wizard tower'].minigame.spellsById) {
if (l('grimoireSpell' + i).onmouseover != null) {
CM.Disp.TooltipGrimoireBackup[i] = l('grimoireSpell' + i).onmouseover;
eval('l(\'grimoireSpell\' + i).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'g\', \'' + i + '\');}, \'this\'); Game.tooltip.wobble();}');
}
}
}
}
/**
* This function replaces the original .onmouseover functions of sugar lumps so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 's'
* The function is called by CM.DelayInit()
* TODO: Place all ReplaceTooltip functions either under CM.DelayInit() or CM.ReplaceNative()
* TODO: Move this code to Main.js file
*/
CM.Disp.ReplaceTooltipLump = function() {
if (Game.canLumps()) {
CM.Disp.TooltipLumpBackup = l('lumps').onmouseover;
eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}');
}
};
/** /**
* This function enhance the standard tooltips by creating and changing l('tooltip') * 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() * The function is called by .onmouseover events that have replaced original code to use CM.Disp.Tooltip()
@@ -4094,12 +4040,10 @@ CM.ReplaceNative = function() {
CM.Backup.scriptLoaded = Game.scriptLoaded; CM.Backup.scriptLoaded = Game.scriptLoaded;
Game.scriptLoaded = function(who, script) { Game.scriptLoaded = function(who, script) {
CM.Backup.scriptLoaded(who, script); CM.Backup.scriptLoaded(who, script);
CM.Disp.ReplaceTooltipGrimoire() CM.Main.ReplaceTooltipGrimoire()
CM.ReplaceNativeGrimoire(); CM.ReplaceNativeGrimoire();
} }
// TODO: Move this ReplaceTooltip function too other ReplaceTooltip functions
// OR: Move all other into this function
CM.Backup.RebuildUpgrades = Game.RebuildUpgrades; CM.Backup.RebuildUpgrades = Game.RebuildUpgrades;
Game.RebuildUpgrades = function() { Game.RebuildUpgrades = function() {
CM.Backup.RebuildUpgrades(); CM.Backup.RebuildUpgrades();
@@ -4107,7 +4051,6 @@ CM.ReplaceNative = function() {
Game.CalculateGains(); Game.CalculateGains();
} }
CM.Backup.DescribeDragonAura = Game.DescribeDragonAura; CM.Backup.DescribeDragonAura = Game.DescribeDragonAura;
/** /**
* This functions adds the function CM.Disp.AddAuraInfo() to Game.DescribeDragonAura() * This functions adds the function CM.Disp.AddAuraInfo() to Game.DescribeDragonAura()
@@ -4171,7 +4114,7 @@ CM.ReplaceNativeGrimoireLaunch = function() {
eval('CM.Backup.GrimoireLaunchMod = ' + minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame')); eval('CM.Backup.GrimoireLaunchMod = ' + minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame'));
Game.Objects['Wizard tower'].minigame.launch = function() { Game.Objects['Wizard tower'].minigame.launch = function() {
CM.Backup.GrimoireLaunchMod(); CM.Backup.GrimoireLaunchMod();
CM.Disp.ReplaceTooltipGrimoire(); CM.Main.ReplaceTooltipGrimoire();
CM.HasReplaceNativeGrimoireDraw = false; CM.HasReplaceNativeGrimoireDraw = false;
CM.ReplaceNativeGrimoireDraw(); CM.ReplaceNativeGrimoireDraw();
} }
@@ -4286,9 +4229,7 @@ CM.DelayInit = function() {
CM.Disp.CreateSimpleTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]); CM.Disp.CreateSimpleTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]);
} }
CM.Disp.CreateWrinklerButtons(); CM.Disp.CreateWrinklerButtons();
CM.Disp.ReplaceTooltipBuild(); CM.Main.ReplaceTooltips();
CM.Disp.ReplaceTooltipGrimoire();
CM.Disp.ReplaceTooltipLump();
CM.Main.AddWrinklerAreaDetect(); CM.Main.AddWrinklerAreaDetect();
CM.Cache.InitCookiesDiff(); CM.Cache.InitCookiesDiff();
CM.ReplaceNative(); CM.ReplaceNative();
@@ -4313,6 +4254,69 @@ CM.DelayInit = function() {
Game.Win('Third-party'); Game.Win('Third-party');
} }
/********
* Section: Functions related to first initizalition of CM */
/**
* This function call all functions that replace Game-tooltips with CM-enhanced tooltips
* It is called by CM.DelayInit()
*/
CM.Main.ReplaceTooltips = function() {
CM.Main.ReplaceTooltipBuild();
CM.Main.ReplaceTooltipGrimoire();
CM.Main.ReplaceTooltipLump();
}
/********
* Section: Functions related to replacing tooltips */
/**
* This function replaces the original .onmouseover functions of buildings so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'b'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipBuild = function() {
CM.Main.TooltipBuildBackup = [];
for (var i in Game.Objects) {
var me = Game.Objects[i];
if (l('product' + me.id).onmouseover != null) {
CM.Main.TooltipBuildBackup[i] = l('product' + me.id).onmouseover;
eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}');
}
}
}
/**
* This function replaces the original .onmouseover functions of the Grimoire minigame so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'g'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipGrimoire = function() {
if (Game.Objects['Wizard tower'].minigameLoaded) {
CM.Main.TooltipGrimoireBackup = [];
for (var i in Game.Objects['Wizard tower'].minigame.spellsById) {
if (l('grimoireSpell' + i).onmouseover != null) {
CM.Main.TooltipGrimoireBackup[i] = l('grimoireSpell' + i).onmouseover;
eval('l(\'grimoireSpell\' + i).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'g\', \'' + i + '\');}, \'this\'); Game.tooltip.wobble();}');
}
}
}
}
/**
* This function replaces the original .onmouseover functions of sugar lumps so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 's'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipLump = function() {
if (Game.canLumps()) {
CM.Main.TooltipLumpBackup = l('lumps').onmouseover;
eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}');
}
};
/******** /********
* Section: Functions related to checking for changes in Minigames/GC's/Ticker * Section: Functions related to checking for changes in Minigames/GC's/Ticker
* TODO: Possibly move this section */ * TODO: Possibly move this section */
@@ -4478,7 +4482,7 @@ CM.Main.CheckWrinklerCount = function() {
* This function creates .onmouseover/out events that determine if the mouse is hovering-over a Wrinkler * This function creates .onmouseover/out events that determine if the mouse is hovering-over a Wrinkler
* It is called by CM.DelayInit * It is called by CM.DelayInit
* TODO: The system for displaying wrinklers should ideally use a similar system as other tooltips * TODO: The system for displaying wrinklers should ideally use a similar system as other tooltips
* Thus, writing a CM.Disp.ReplaceTooltipWrinkler function etc. * Thus, writing a CM.Main.ReplaceTooltipWrinkler function etc.
*/ */
CM.Main.AddWrinklerAreaDetect = function() { CM.Main.AddWrinklerAreaDetect = function() {
l('backgroundLeftCanvas').onmouseover = function() {CM.Disp.TooltipWrinklerArea = 1;}; l('backgroundLeftCanvas').onmouseover = function() {CM.Disp.TooltipWrinklerArea = 1;};

View File

@@ -1171,31 +1171,10 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) {
CM.Disp[placeholder].appendChild(desc); CM.Disp[placeholder].appendChild(desc);
} }
/**
* This function replaces the original .onmouseover functions of buildings so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'b'
* It is called by CM.DelayInit()
* TODO: Place all ReplaceTooltip functions either under CM.DelayInit() or CM.ReplaceNative()
* TODO: Move this code to Main.js file
*/
CM.Disp.ReplaceTooltipBuild = function() {
CM.Disp.TooltipBuildBackup = [];
for (var i in Game.Objects) {
var me = Game.Objects[i];
if (l('product' + me.id).onmouseover != null) {
CM.Disp.TooltipBuildBackup[i] = l('product' + me.id).onmouseover;
eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}');
}
}
}
/** /**
* This function replaces the original .onmouseover functions of upgrades so that it calls CM.Disp.Tooltip() * This function replaces the original .onmouseover functions of upgrades so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'u' * CM.Disp.Tooltip() sets the tooltip type to 'u'
* It is called by CM.ReplaceNative() * It is called by Game.RebuildUpgrades() through CM.ReplaceNative() and is therefore not permanent like the other ReplaceTooltip functions
* TODO: Place all ReplaceTooltip functions either under CM.DelayInit() or CM.ReplaceNative()
* TODO: Move this code to Main.js file
*
*/ */
CM.Disp.ReplaceTooltipUpgrade = function() { CM.Disp.ReplaceTooltipUpgrade = function() {
CM.Disp.TooltipUpgradeBackup = []; CM.Disp.TooltipUpgradeBackup = [];
@@ -1208,39 +1187,6 @@ CM.Disp.ReplaceTooltipUpgrade = function() {
} }
} }
/**
* This function replaces the original .onmouseover functions of the Grimoire minigame so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'g'
* The function is called by CM.DelayInit()
* TODO: Place all ReplaceTooltip functions either under CM.DelayInit() or CM.ReplaceNative()
* TODO: Move this code to Main.js file
*/
CM.Disp.ReplaceTooltipGrimoire = function() {
if (Game.Objects['Wizard tower'].minigameLoaded) {
CM.Disp.TooltipGrimoireBackup = [];
for (var i in Game.Objects['Wizard tower'].minigame.spellsById) {
if (l('grimoireSpell' + i).onmouseover != null) {
CM.Disp.TooltipGrimoireBackup[i] = l('grimoireSpell' + i).onmouseover;
eval('l(\'grimoireSpell\' + i).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'g\', \'' + i + '\');}, \'this\'); Game.tooltip.wobble();}');
}
}
}
}
/**
* This function replaces the original .onmouseover functions of sugar lumps so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 's'
* The function is called by CM.DelayInit()
* TODO: Place all ReplaceTooltip functions either under CM.DelayInit() or CM.ReplaceNative()
* TODO: Move this code to Main.js file
*/
CM.Disp.ReplaceTooltipLump = function() {
if (Game.canLumps()) {
CM.Disp.TooltipLumpBackup = l('lumps').onmouseover;
eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}');
}
};
/** /**
* This function enhance the standard tooltips by creating and changing l('tooltip') * 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() * The function is called by .onmouseover events that have replaced original code to use CM.Disp.Tooltip()

View File

@@ -45,12 +45,10 @@ CM.ReplaceNative = function() {
CM.Backup.scriptLoaded = Game.scriptLoaded; CM.Backup.scriptLoaded = Game.scriptLoaded;
Game.scriptLoaded = function(who, script) { Game.scriptLoaded = function(who, script) {
CM.Backup.scriptLoaded(who, script); CM.Backup.scriptLoaded(who, script);
CM.Disp.ReplaceTooltipGrimoire() CM.Main.ReplaceTooltipGrimoire()
CM.ReplaceNativeGrimoire(); CM.ReplaceNativeGrimoire();
} }
// TODO: Move this ReplaceTooltip function too other ReplaceTooltip functions
// OR: Move all other into this function
CM.Backup.RebuildUpgrades = Game.RebuildUpgrades; CM.Backup.RebuildUpgrades = Game.RebuildUpgrades;
Game.RebuildUpgrades = function() { Game.RebuildUpgrades = function() {
CM.Backup.RebuildUpgrades(); CM.Backup.RebuildUpgrades();
@@ -58,7 +56,6 @@ CM.ReplaceNative = function() {
Game.CalculateGains(); Game.CalculateGains();
} }
CM.Backup.DescribeDragonAura = Game.DescribeDragonAura; CM.Backup.DescribeDragonAura = Game.DescribeDragonAura;
/** /**
* This functions adds the function CM.Disp.AddAuraInfo() to Game.DescribeDragonAura() * This functions adds the function CM.Disp.AddAuraInfo() to Game.DescribeDragonAura()
@@ -122,7 +119,7 @@ CM.ReplaceNativeGrimoireLaunch = function() {
eval('CM.Backup.GrimoireLaunchMod = ' + minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame')); eval('CM.Backup.GrimoireLaunchMod = ' + minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame'));
Game.Objects['Wizard tower'].minigame.launch = function() { Game.Objects['Wizard tower'].minigame.launch = function() {
CM.Backup.GrimoireLaunchMod(); CM.Backup.GrimoireLaunchMod();
CM.Disp.ReplaceTooltipGrimoire(); CM.Main.ReplaceTooltipGrimoire();
CM.HasReplaceNativeGrimoireDraw = false; CM.HasReplaceNativeGrimoireDraw = false;
CM.ReplaceNativeGrimoireDraw(); CM.ReplaceNativeGrimoireDraw();
} }
@@ -237,9 +234,7 @@ CM.DelayInit = function() {
CM.Disp.CreateSimpleTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]); CM.Disp.CreateSimpleTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]);
} }
CM.Disp.CreateWrinklerButtons(); CM.Disp.CreateWrinklerButtons();
CM.Disp.ReplaceTooltipBuild(); CM.Main.ReplaceTooltips();
CM.Disp.ReplaceTooltipGrimoire();
CM.Disp.ReplaceTooltipLump();
CM.Main.AddWrinklerAreaDetect(); CM.Main.AddWrinklerAreaDetect();
CM.Cache.InitCookiesDiff(); CM.Cache.InitCookiesDiff();
CM.ReplaceNative(); CM.ReplaceNative();
@@ -264,6 +259,69 @@ CM.DelayInit = function() {
Game.Win('Third-party'); Game.Win('Third-party');
} }
/********
* Section: Functions related to first initizalition of CM */
/**
* This function call all functions that replace Game-tooltips with CM-enhanced tooltips
* It is called by CM.DelayInit()
*/
CM.Main.ReplaceTooltips = function() {
CM.Main.ReplaceTooltipBuild();
CM.Main.ReplaceTooltipGrimoire();
CM.Main.ReplaceTooltipLump();
}
/********
* Section: Functions related to replacing tooltips */
/**
* This function replaces the original .onmouseover functions of buildings so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'b'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipBuild = function() {
CM.Main.TooltipBuildBackup = [];
for (var i in Game.Objects) {
var me = Game.Objects[i];
if (l('product' + me.id).onmouseover != null) {
CM.Main.TooltipBuildBackup[i] = l('product' + me.id).onmouseover;
eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}');
}
}
}
/**
* This function replaces the original .onmouseover functions of the Grimoire minigame so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'g'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipGrimoire = function() {
if (Game.Objects['Wizard tower'].minigameLoaded) {
CM.Main.TooltipGrimoireBackup = [];
for (var i in Game.Objects['Wizard tower'].minigame.spellsById) {
if (l('grimoireSpell' + i).onmouseover != null) {
CM.Main.TooltipGrimoireBackup[i] = l('grimoireSpell' + i).onmouseover;
eval('l(\'grimoireSpell\' + i).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'g\', \'' + i + '\');}, \'this\'); Game.tooltip.wobble();}');
}
}
}
}
/**
* This function replaces the original .onmouseover functions of sugar lumps so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 's'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipLump = function() {
if (Game.canLumps()) {
CM.Main.TooltipLumpBackup = l('lumps').onmouseover;
eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}');
}
};
/******** /********
* Section: Functions related to checking for changes in Minigames/GC's/Ticker * Section: Functions related to checking for changes in Minigames/GC's/Ticker
* TODO: Possibly move this section */ * TODO: Possibly move this section */
@@ -429,7 +487,7 @@ CM.Main.CheckWrinklerCount = function() {
* This function creates .onmouseover/out events that determine if the mouse is hovering-over a Wrinkler * This function creates .onmouseover/out events that determine if the mouse is hovering-over a Wrinkler
* It is called by CM.DelayInit * It is called by CM.DelayInit
* TODO: The system for displaying wrinklers should ideally use a similar system as other tooltips * TODO: The system for displaying wrinklers should ideally use a similar system as other tooltips
* Thus, writing a CM.Disp.ReplaceTooltipWrinkler function etc. * Thus, writing a CM.Main.ReplaceTooltipWrinkler function etc.
*/ */
CM.Main.AddWrinklerAreaDetect = function() { CM.Main.AddWrinklerAreaDetect = function() {
l('backgroundLeftCanvas').onmouseover = function() {CM.Disp.TooltipWrinklerArea = 1;}; l('backgroundLeftCanvas').onmouseover = function() {CM.Disp.TooltipWrinklerArea = 1;};