Merge pull request #781 from DanielNoord/bugfix

Fix bug with expanded upgrade section
This commit is contained in:
Daniël van Noord
2021-05-01 20:29:44 +02:00
committed by GitHub
7 changed files with 37 additions and 37 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,20 +0,0 @@
import { CMOptions } from '../VariablesAndData';
/**
* This function toggles the upgrade to be always expanded
* It is called by a change in CM.Options.ToolWarnPos
* and upon creation of the warning tooltip by CM.Disp.UpdateTooltipWarnings()
*/
export default function ToggleUpgradeSectionsAlwaysExpanded() {
Object.values(document.getElementsByClassName('storeSection')).forEach((section) => {
if (CMOptions.UpgradesNeverCollapse || section.id === 'products') {
section.style.height = 'auto'; // eslint-disable-line no-param-reassign
} else if (section.id === 'vaultUpgrades') {
section.style.height = '30px'; // eslint-disable-line no-param-reassign
} else if (section.id === 'upgrades') {
section.style.height = '60px'; // eslint-disable-line no-param-reassign
} else {
section.style.height = '60px'; // eslint-disable-line no-param-reassign
}
});
}

View File

@@ -7,10 +7,10 @@ import ToggleSectionHideButtons from '../Config/Toggles/ToggleSectionHideButtons
import ToggleToolWarnPos from '../Config/Toggles/ToggleToolWarnPos'; import ToggleToolWarnPos from '../Config/Toggles/ToggleToolWarnPos';
import ToggleUpgradeBarAndColour from '../Config/Toggles/ToggleUpgradeBarAndColour'; import ToggleUpgradeBarAndColour from '../Config/Toggles/ToggleUpgradeBarAndColour';
import ToggleUpgradeBarFixedPos from '../Config/Toggles/ToggleUpgradeBarFixedPos'; import ToggleUpgradeBarFixedPos from '../Config/Toggles/ToggleUpgradeBarFixedPos';
import ToggleUpgradeSectionsAlwaysExpanded from '../Config/Toggles/ToggleUpgradeSectionsAlwaysExpanded';
import ToggleWrinklerButtons from '../Config/Toggles/ToggleWrinklerButtons'; import ToggleWrinklerButtons from '../Config/Toggles/ToggleWrinklerButtons';
import { CMOptions } from '../Config/VariablesAndData'; import { CMOptions } from '../Config/VariablesAndData';
import UpdateBuildings from '../Disp/BuildingsUpgrades/Buildings'; import UpdateBuildings from '../Disp/BuildingsUpgrades/Buildings';
import UpdateUpgradeSectionsHeight from '../Disp/BuildingsUpgrades/UpdateUpgradeSectionsHeight';
import UpdateUpgrades from '../Disp/BuildingsUpgrades/Upgrades'; import UpdateUpgrades from '../Disp/BuildingsUpgrades/Upgrades';
import RefreshScale from '../Disp/HelperFunctions/RefreshScale'; import RefreshScale from '../Disp/HelperFunctions/RefreshScale';
import { UpdateFavicon } from '../Disp/TabTitle/FavIcon'; import { UpdateFavicon } from '../Disp/TabTitle/FavIcon';
@@ -325,7 +325,7 @@ const Config = {
'Toggle to make the upgrades sections always expanded to the size needed to display all upgrades', 'Toggle to make the upgrades sections always expanded to the size needed to display all upgrades',
true, true,
() => { () => {
ToggleUpgradeSectionsAlwaysExpanded(); UpdateUpgradeSectionsHeight();
}, },
), ),
DragonAuraInfo: new SettingStandard( DragonAuraInfo: new SettingStandard(

View File

@@ -0,0 +1,27 @@
import { CMOptions } from '../../Config/VariablesAndData';
/**
* This function toggles the upgrade to be always expanded
* It is called by a change in CM.Options.ToolWarnPos
* and upon creation of the warning tooltip by CM.Disp.UpdateTooltipWarnings()
*/
export default function UpdateUpgradeSectionsHeight() {
Object.values(document.getElementsByClassName('storeSection')).forEach((section) => {
if (CMOptions.UpgradesNeverCollapse || section.id === 'products') {
section.style.height = 'auto'; // eslint-disable-line no-param-reassign
} else if (section.id === 'vaultUpgrades') {
section.style.height = ''; // eslint-disable-line no-param-reassign
section.style.minHeight = '0px'; // eslint-disable-line no-param-reassign
} else if (section.id === 'upgrades') {
section.style.height = ''; // eslint-disable-line no-param-reassign
if (section.className.includes('hasMenu')) {
section.style.minHeight = '82px'; // eslint-disable-line no-param-reassign
} else {
section.style.minHeight = '60px'; // eslint-disable-line no-param-reassign
}
} else {
section.style.height = ''; // eslint-disable-line no-param-reassign
section.style.minHeight = '60px'; // eslint-disable-line no-param-reassign
}
});
}

View File

@@ -2,15 +2,13 @@ import ToggleWrinklerButtons from '../Config/Toggles/ToggleWrinklerButtons';
import { CMOptions } from '../Config/VariablesAndData'; import { CMOptions } from '../Config/VariablesAndData';
import Beautify from './BeautifyAndFormatting/Beautify'; import Beautify from './BeautifyAndFormatting/Beautify';
import UpdateBuildings from './BuildingsUpgrades/Buildings'; import UpdateBuildings from './BuildingsUpgrades/Buildings';
import UpdateUpgradeSectionsHeight from './BuildingsUpgrades/UpdateUpgradeSectionsHeight';
import UpdateUpgrades from './BuildingsUpgrades/Upgrades'; import UpdateUpgrades from './BuildingsUpgrades/Upgrades';
import { UpdateBotBar } from './InfoBars/BottomBar'; import { UpdateBotBar } from './InfoBars/BottomBar';
import { UpdateTimerBar } from './InfoBars/TimerBar'; import { UpdateTimerBar } from './InfoBars/TimerBar';
import RefreshMenu from './MenuSections/Refreshmenu'; import RefreshMenu from './MenuSections/Refreshmenu';
import UpdateTooltips from './Tooltips/UpdateTooltips'; import UpdateTooltips from './Tooltips/UpdateTooltips';
import { import { CheckWrinklerTooltip, UpdateWrinklerTooltip } from './Tooltips/WrinklerTooltips';
CheckWrinklerTooltip,
UpdateWrinklerTooltip,
} from './Tooltips/WrinklerTooltips';
/** /**
* This function handles all custom drawing for the Game.Draw() function. * This function handles all custom drawing for the Game.Draw() function.
@@ -26,16 +24,14 @@ export default function CMDrawHook() {
) { ) {
const timer = document.getElementById('CMStatsAutosaveTimer'); const timer = document.getElementById('CMStatsAutosaveTimer');
if (timer) { if (timer) {
timer.innerText = Game.sayTime( timer.innerText = Game.sayTime(Game.fps * 60 - (Game.T % (Game.fps * 60)), 4);
Game.fps * 60 - (Game.T % (Game.fps * 60)),
4,
);
} }
} }
// Update colors // Update colors
UpdateBuildings(); UpdateBuildings();
UpdateUpgrades(); UpdateUpgrades();
UpdateUpgradeSectionsHeight();
// Redraw timers // Redraw timers
UpdateTimerBar(); UpdateTimerBar();
@@ -58,10 +54,7 @@ export default function CMDrawHook() {
// Replace Cookies counter because Orteil uses very weird code to "pad" it... // Replace Cookies counter because Orteil uses very weird code to "pad" it...
if (CMOptions.Scale) { if (CMOptions.Scale) {
let str = l('cookies').innerHTML.replace( let str = l('cookies').innerHTML.replace(/.*(?=<br>)/i, Beautify(Game.cookies));
/.*(?=<br>)/i,
Beautify(Game.cookies),
);
if (Game.prefs.monospace) str = `<span class="monospace">${str}</span>`; if (Game.prefs.monospace) str = `<span class="monospace">${str}</span>`;
l('cookies').innerHTML = str; l('cookies').innerHTML = str;
} }