Merge pull request #742 from DanielNoord/favouritesettingsfixes

Changes to favourite settings
This commit is contained in:
Daniël van Noord
2021-04-03 09:13:14 +02:00
committed by GitHub
13 changed files with 75 additions and 42 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,5 +1,5 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import { crateMissing } from '../../Disp/MenuSections/CreateMissingUpgrades'; import { crateMissing } from '../../Disp/MenuSections/Statistics/CreateMissingUpgrades';
import { import {
CacheMissingUpgrades, CacheMissingUpgrades,
CacheMissingUpgradesCookies, CacheMissingUpgradesCookies,

View File

@@ -1,6 +1,6 @@
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import AddMenuStats from './AddStatsPage'; import AddMenuStats from './Statistics/AddStatsPage';
import AddMenuInfo from './InfoPage'; import AddMenuInfo from './Info/InfoPage';
import AddMenuPref from './Settings/SettingsPage'; import AddMenuPref from './Settings/SettingsPage';
/** /**

View File

@@ -1,8 +1,8 @@
/** Functions related to the Stats page */ /** Functions related to the Stats page */
import { ToggleHeader } from '../../Config/ToggleSetting'; import { ToggleHeader } from '../../../Config/ToggleSetting';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import { LatestReleaseNotes, ModDescription } from '../../Data/Moddata'; import { LatestReleaseNotes, ModDescription } from '../../../Data/Moddata';
/** /**
* This function adds stats created by CookieMonster to the stats page * This function adds stats created by CookieMonster to the stats page

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-return-assign */
/** Creates a Prompt similar to the base game without some of the stuff breaking them */ /** Creates a Prompt similar to the base game without some of the stuff breaking them */
export default function CookieMonsterPrompt(content, options) { export default function CookieMonsterPrompt(content, options) {
Game.promptWrapL.className = 'framed'; Game.promptWrapL.className = 'framed';

View File

@@ -13,9 +13,42 @@ import RefreshScale from '../../HelperFunctions/RefreshScale';
import UpdateColours from '../../HelperFunctions/UpdateColours'; import UpdateColours from '../../HelperFunctions/UpdateColours';
import Flash from '../../Notifications/Flash'; import Flash from '../../Notifications/Flash';
import PlaySound from '../../Notifications/Sound'; import PlaySound from '../../Notifications/Sound';
import { FavouriteSettings } from '../../VariablesAndData'; import {
FavouriteSettings,
SimpleTooltipElements,
} from '../../VariablesAndData';
import CookieMonsterPrompt from '../Prompt'; import CookieMonsterPrompt from '../Prompt';
/**
* This function creates the favourite setting star object
* @param {string} config The name of the option
* @returns {object} div The option object
*/
function CreateFavouriteStar(config) {
const FavStar = document.createElement('a');
if (FavouriteSettings.includes(config)) {
FavStar.innerText = '★';
FavStar.style.color = 'yellow';
} else FavStar.innerText = '☆';
FavStar.className = 'option';
FavStar.onclick = function () {
ToggleFavouriteSetting(config);
SaveConfig();
Game.UpdateMenu();
};
FavStar.onmouseover = function () {
Game.tooltip.draw(
this,
escape(SimpleTooltipElements.FavouriteSettingPlaceholder.innerHTML),
);
};
FavStar.onmouseout = function () {
Game.tooltip.hide();
};
FavStar.appendChild(document.createTextNode(' '));
return FavStar;
}
/** /**
* This function creates an option-object for the options page * This function creates an option-object for the options page
* @param {string} config The name of the option * @param {string} config The name of the option
@@ -25,17 +58,7 @@ export default function CreatePrefOption(config) {
const div = document.createElement('div'); const div = document.createElement('div');
div.className = 'listing'; div.className = 'listing';
if (CMOptions.FavouriteSettings === 1) { if (CMOptions.FavouriteSettings === 1) {
const FavStar = document.createElement('a'); div.appendChild(CreateFavouriteStar(config));
if (FavouriteSettings.includes(config)) FavStar.innerText = '★';
else FavStar.innerText = '☆';
FavStar.className = 'option';
FavStar.onclick = function () {
ToggleFavouriteSetting(config);
SaveConfig();
Game.UpdateMenu();
};
div.appendChild(FavStar);
div.appendChild(document.createTextNode(' '));
} }
if (Config[config].type === 'bool') { if (Config[config].type === 'bool') {
const a = document.createElement('a'); const a = document.createElement('a');
@@ -52,6 +75,7 @@ export default function CreatePrefOption(config) {
div.appendChild(a); div.appendChild(a);
const label = document.createElement('label'); const label = document.createElement('label');
label.textContent = Config[config].desc; label.textContent = Config[config].desc;
label.style.lineHeight = '1.6';
div.appendChild(label); div.appendChild(label);
return div; return div;
} }
@@ -102,6 +126,7 @@ export default function CreatePrefOption(config) {
const span = document.createElement('span'); const span = document.createElement('span');
span.className = 'option'; span.className = 'option';
span.textContent = `${Config[config].label} `; span.textContent = `${Config[config].label} `;
span.style.lineHeight = '1.6';
div.appendChild(span); div.appendChild(span);
const input = document.createElement('input'); const input = document.createElement('input');
input.id = ConfigPrefix + config; input.id = ConfigPrefix + config;
@@ -142,6 +167,7 @@ export default function CreatePrefOption(config) {
div.appendChild(a); div.appendChild(a);
const label = document.createElement('label'); const label = document.createElement('label');
label.textContent = Config[config].desc; label.textContent = Config[config].desc;
label.style.lineHeight = '1.6';
div.appendChild(label); div.appendChild(label);
return div; return div;
} }
@@ -163,6 +189,7 @@ export default function CreatePrefOption(config) {
new JsColor(input, { hash: true, position: 'right', onInput: change }); new JsColor(input, { hash: true, position: 'right', onInput: change });
const label = document.createElement('label'); const label = document.createElement('label');
label.textContent = Config[config].desc; label.textContent = Config[config].desc;
label.style.lineHeight = '1.6';
innerSpan.appendChild(label); innerSpan.appendChild(label);
if (config.includes('Flash')) { if (config.includes('Flash')) {
const a = document.createElement('a'); const a = document.createElement('a');
@@ -181,6 +208,7 @@ export default function CreatePrefOption(config) {
const span = document.createElement('span'); const span = document.createElement('span');
span.className = 'option'; span.className = 'option';
span.textContent = `${Config[config].label} `; span.textContent = `${Config[config].label} `;
span.style.lineHeight = '1.6';
div.appendChild(span); div.appendChild(span);
const input = document.createElement('input'); const input = document.createElement('input');
input.id = ConfigPrefix + config; input.id = ConfigPrefix + config;
@@ -199,6 +227,7 @@ export default function CreatePrefOption(config) {
div.appendChild(document.createTextNode(' ')); div.appendChild(document.createTextNode(' '));
const label = document.createElement('label'); const label = document.createElement('label');
label.textContent = Config[config].desc; label.textContent = Config[config].desc;
label.style.lineHeight = '1.6';
div.appendChild(label); div.appendChild(label);
return div; return div;
} }

View File

@@ -3,19 +3,19 @@
import { AddMissingUpgrades } from './CreateMissingUpgrades'; import { AddMissingUpgrades } from './CreateMissingUpgrades';
import * as CreateSections from './CreateStatsSections'; import * as CreateSections from './CreateStatsSections';
import * as CreateElements from './CreateDOMElements'; import * as CreateElements from './CreateDOMElements';
import * as GameData from '../../Data/Gamedata'; import * as GameData from '../../../Data/Gamedata';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import { import {
CacheAverageClicks, CacheAverageClicks,
CacheWrinklersFattest, CacheWrinklersFattest,
CacheWrinklersNormal, CacheWrinklersNormal,
CacheWrinklersTotal, CacheWrinklersTotal,
} from '../../Cache/VariablesAndData'; } from '../../../Cache/VariablesAndData';
import PopAllNormalWrinklers from '../HelperFunctions/PopWrinklers'; import PopAllNormalWrinklers from '../../HelperFunctions/PopWrinklers';
import { ClickTimes, CookieTimes } from '../VariablesAndData'; import { ClickTimes, CookieTimes } from '../../VariablesAndData';
import GetCPS from '../HelperFunctions/GetCPS'; import GetCPS from '../../HelperFunctions/GetCPS';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting'; import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting';
/** /**
* This function adds stats created by CookieMonster to the stats page * This function adds stats created by CookieMonster to the stats page

View File

@@ -1,8 +1,8 @@
/** Section: Functions related to the creation of basic DOM elements page */ /** Section: Functions related to the creation of basic DOM elements page */
import { ToggleHeader } from '../../Config/ToggleSetting'; import { ToggleHeader } from '../../../Config/ToggleSetting';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import { SimpleTooltipElements } from '../VariablesAndData'; import { SimpleTooltipElements } from '../../VariablesAndData';
/** /**
* This function creates a header-object for the stats page * This function creates a header-object for the stats page

View File

@@ -4,7 +4,7 @@ import {
CacheMissingUpgrades, CacheMissingUpgrades,
CacheMissingUpgradesCookies, CacheMissingUpgradesCookies,
CacheMissingUpgradesPrestige, CacheMissingUpgradesPrestige,
} from '../../Cache/VariablesAndData'; } from '../../../Cache/VariablesAndData';
/** /**
* This function creates the missing upgrades sections for prestige, normal and cookie upgrades * This function creates the missing upgrades sections for prestige, normal and cookie upgrades

View File

@@ -1,7 +1,7 @@
/** Functions to create the individual sections of the Statistics page */ /** Functions to create the individual sections of the Statistics page */
import * as GameData from '../../Data/Gamedata'; import * as GameData from '../../../Data/Gamedata';
import { MaxChainCookieReward } from '../../Cache/Stats/ChainCookies'; import { MaxChainCookieReward } from '../../../Cache/Stats/ChainCookies';
import { import {
CacheAvgCPSWithChoEgg, CacheAvgCPSWithChoEgg,
CacheCentEgg, CacheCentEgg,
@@ -35,17 +35,17 @@ import {
CacheSeaSpec, CacheSeaSpec,
CacheWrathCookiesMult, CacheWrathCookiesMult,
CacheWrinklersTotal, CacheWrinklersTotal,
} from '../../Cache/VariablesAndData'; } from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import ResetBonus from '../../Sim/SimulationEvents/ResetAscension'; import ResetBonus from '../../../Sim/SimulationEvents/ResetAscension';
import { import {
Beautify, Beautify,
FormatTime, FormatTime,
} from '../BeautifyAndFormatting/BeautifyFormatting'; } from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../HelperFunctions/GetCPS'; import GetCPS from '../../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import { ColourGreen, ColourRed, ColourTextPre } from '../VariablesAndData'; import { ColourGreen, ColourRed, ColourTextPre } from '../../VariablesAndData';
import { StatsListing, StatsHeader, StatsMissDisp } from './CreateDOMElements'; import { StatsListing, StatsHeader, StatsMissDisp } from './CreateDOMElements';
/** /**

View File

@@ -79,6 +79,11 @@ export const TooltipText = [
'Cheated cookies might break this formula', 'Cheated cookies might break this formula',
'250px', '250px',
], ],
[
'FavouriteSettingPlaceholder',
"Click to set this setting as favourite and show it in 'favourite' settings at the top of the Cookie Monster Settings",
'250px',
],
]; ];
export const SimpleTooltipElements = {}; export const SimpleTooltipElements = {};