diff --git a/CookieMonster.js b/CookieMonster.js index 2ba8446..5005890 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -786,7 +786,7 @@ CM.ConfigGroups = { Notification: "Notification", Tooltip: "Tooltips", Statistics: "Statitics", - Other: "Other"}, + Notation: "Notation"}, /******** * Section: An array (CM.ConfigData) containing all Config options @@ -912,10 +912,10 @@ CM.ConfigData.TimeFormat = {type: 'bool', group: 'Statistics', label: ['Time XXd CM.ConfigData.DetailedTime = {type: 'bool', group: 'Statistics', label: ['Detailed Time OFF', 'Detailed Time ON'], desc: 'Change how time is displayed in certain statistics and tooltips', toggle: true, func: function() {CM.Disp.ToggleDetailedTime();}}; CM.ConfigData.GrimoireBar = {type: 'bool', group: 'Statistics', label: ['Grimoire Magic Meter Timer OFF', 'Grimoire Magic Meter Timer ON'], desc: 'A timer on how long before the Grimoire magic meter is full', toggle: true}; -// Statistics -CM.ConfigData.Scale = {type: 'bool', group: 'Other', label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Scientific Notation', 'Engineering Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; -CM.ConfigData.ScaleDecimals = {type: 'bool', group: 'Other', label: ['1 decimals', '2 decimals', '3 decimals'], desc: 'Set the number of decimals used when applicable', toggle: false, func: function() {CM.Disp.RefreshScale();}}; -CM.ConfigData.ScaleSeparator = {type: 'bool', group: 'Other', label: ['. for decimals', '. for thousands'], desc: 'Set the separator used for decimals and thousands', toggle: false, func: function() {CM.Disp.RefreshScale();}}; +// Notation +CM.ConfigData.Scale = {type: 'bool', group: 'Notation', label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Scientific Notation', 'Engineering Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; +CM.ConfigData.ScaleDecimals = {type: 'bool', group: 'Notation', label: ['1 decimals', '2 decimals', '3 decimals'], desc: 'Set the number of decimals used when applicable', toggle: false, func: function() {CM.Disp.RefreshScale();}}; +CM.ConfigData.ScaleSeparator = {type: 'bool', group: 'Notation', label: ['. for decimals (Standard)', '. for thousands'], desc: 'Set the separator used for decimals and thousands', toggle: false, func: function() {CM.Disp.RefreshScale();}}; /******** * Disp * @@ -1085,7 +1085,6 @@ CM.Disp.GetTimeColor = function(time) { * @param {any} frac Used in some scenario's by CM.Backup.Beautify (Game's original function) * @param {number} forced Used to force (type 3) in certains cases * @returns {string} Formatted number - * TODO: Add functionality to choose amount of decimals and separators */ CM.Disp.Beautify = function(num, frac, forced) { var decimals = CM.Config.ScaleDecimals + 1; @@ -1104,10 +1103,11 @@ CM.Disp.Beautify = function(num, frac, forced) { return num } else if (-1 < timesTenToPowerThree && timesTenToPowerThree < 2) { + // TODO: Add changing separators of thousands and making this cut-off user configurable answer = Math.round(num * 100) / 100; } else if (CM.Config.Scale == 3 && !forced || forced == 3) { // Scientific notation, 123456789 => 1.235E+8 - answer = num[0] + '.' + answer = num[0] + (CM.Config.ScaleSeparator ? ',' : '.'); i = 0; while (i < decimals - 1) { answer += num[i + 2]; // num has a 0-based index and [1] is a '.' @@ -1132,7 +1132,7 @@ CM.Disp.Beautify = function(num, frac, forced) { numbersToAdd = (restOfNumber.indexOf('.') > -1 ? restOfNumber.indexOf('.') + 1 + decimals : (restOfNumber.length)) i = 0 while (i < numbersToAdd - 1 && i < restOfNumber.length - 1) { - answer += restOfNumber[i]; + answer += (CM.Config.ScaleSeparator && restOfNumber[i] == '.' ? ',' : restOfNumber[i]); i++ } answer += (i + 1 < restOfNumber.length ? Math.round(restOfNumber[i] + '.' + restOfNumber[i + 1]) : restOfNumber[i]); @@ -4181,7 +4181,8 @@ CM.ConfigDefault = { GrimoireBar: 1, Scale: 2, ScaleDecimals: 2, - OptionsPref: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Other: 1}, + ScaleSeparator: 0, + OptionsPref: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Notation: 1}, StatsPref: {Lucky: 1, Conjure: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}, SortBuildings: 0, diff --git a/src/Data.js b/src/Data.js index d88e167..ee0eff1 100644 --- a/src/Data.js +++ b/src/Data.js @@ -46,7 +46,7 @@ CM.ConfigGroups = { Notification: "Notification", Tooltip: "Tooltips", Statistics: "Statitics", - Other: "Other"}, + Notation: "Notation"}, /******** * Section: An array (CM.ConfigData) containing all Config options @@ -172,8 +172,8 @@ CM.ConfigData.TimeFormat = {type: 'bool', group: 'Statistics', label: ['Time XXd CM.ConfigData.DetailedTime = {type: 'bool', group: 'Statistics', label: ['Detailed Time OFF', 'Detailed Time ON'], desc: 'Change how time is displayed in certain statistics and tooltips', toggle: true, func: function() {CM.Disp.ToggleDetailedTime();}}; CM.ConfigData.GrimoireBar = {type: 'bool', group: 'Statistics', label: ['Grimoire Magic Meter Timer OFF', 'Grimoire Magic Meter Timer ON'], desc: 'A timer on how long before the Grimoire magic meter is full', toggle: true}; -// Statistics -CM.ConfigData.Scale = {type: 'bool', group: 'Other', label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Scientific Notation', 'Engineering Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; -CM.ConfigData.ScaleDecimals = {type: 'bool', group: 'Other', label: ['1 decimals', '2 decimals', '3 decimals'], desc: 'Set the number of decimals used when applicable', toggle: false, func: function() {CM.Disp.RefreshScale();}}; -CM.ConfigData.ScaleSeparator = {type: 'bool', group: 'Other', label: ['. for decimals', '. for thousands'], desc: 'Set the separator used for decimals and thousands', toggle: false, func: function() {CM.Disp.RefreshScale();}}; +// Notation +CM.ConfigData.Scale = {type: 'bool', group: 'Notation', label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Scientific Notation', 'Engineering Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; +CM.ConfigData.ScaleDecimals = {type: 'bool', group: 'Notation', label: ['1 decimals', '2 decimals', '3 decimals'], desc: 'Set the number of decimals used when applicable', toggle: false, func: function() {CM.Disp.RefreshScale();}}; +CM.ConfigData.ScaleSeparator = {type: 'bool', group: 'Notation', label: ['. for decimals (Standard)', '. for thousands'], desc: 'Set the separator used for decimals and thousands', toggle: false, func: function() {CM.Disp.RefreshScale();}}; diff --git a/src/Disp.js b/src/Disp.js index 5c02c48..1db11f2 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -166,7 +166,6 @@ CM.Disp.GetTimeColor = function(time) { * @param {any} frac Used in some scenario's by CM.Backup.Beautify (Game's original function) * @param {number} forced Used to force (type 3) in certains cases * @returns {string} Formatted number - * TODO: Add functionality to choose amount of decimals and separators */ CM.Disp.Beautify = function(num, frac, forced) { var decimals = CM.Config.ScaleDecimals + 1; @@ -185,10 +184,11 @@ CM.Disp.Beautify = function(num, frac, forced) { return num } else if (-1 < timesTenToPowerThree && timesTenToPowerThree < 2) { + // TODO: Add changing separators of thousands and making this cut-off user configurable answer = Math.round(num * 100) / 100; } else if (CM.Config.Scale == 3 && !forced || forced == 3) { // Scientific notation, 123456789 => 1.235E+8 - answer = num[0] + '.' + answer = num[0] + (CM.Config.ScaleSeparator ? ',' : '.'); i = 0; while (i < decimals - 1) { answer += num[i + 2]; // num has a 0-based index and [1] is a '.' @@ -213,7 +213,7 @@ CM.Disp.Beautify = function(num, frac, forced) { numbersToAdd = (restOfNumber.indexOf('.') > -1 ? restOfNumber.indexOf('.') + 1 + decimals : (restOfNumber.length)) i = 0 while (i < numbersToAdd - 1 && i < restOfNumber.length - 1) { - answer += restOfNumber[i]; + answer += (CM.Config.ScaleSeparator && restOfNumber[i] == '.' ? ',' : restOfNumber[i]); i++ } answer += (i + 1 < restOfNumber.length ? Math.round(restOfNumber[i] + '.' + restOfNumber[i + 1]) : restOfNumber[i]); diff --git a/src/Main.js b/src/Main.js index c18b3dd..9a37183 100644 --- a/src/Main.js +++ b/src/Main.js @@ -552,7 +552,8 @@ CM.ConfigDefault = { GrimoireBar: 1, Scale: 2, ScaleDecimals: 2, - OptionsPref: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Other: 1}, + ScaleSeparator: 0, + OptionsPref: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Notation: 1}, StatsPref: {Lucky: 1, Conjure: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}, SortBuildings: 0,