Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/civinfo/civinfo.js
Show All 15 Lines | function init(settings) | ||||
civSelection.selected = 0; | civSelection.selected = 0; | ||||
} | } | ||||
/** | /** | ||||
* Give the first character a larger font. | * Give the first character a larger font. | ||||
*/ | */ | ||||
function bigFirstLetter(str, size) | function bigFirstLetter(str, size) | ||||
{ | { | ||||
return '[font="sans-bold-' + (size + 6) + '"]' + str[0] + '[/font]' + '[font="sans-bold-' + size + '"]' + str.substring(1) + '[/font]'; | return setFont(str[0], 'sans-bold-' + (size + 6)) + setFont(str.substring(1), 'sans-bold-' + size); | ||||
} | } | ||||
/** | /** | ||||
* Set heading font - bold and mixed caps | * Set heading font - bold and mixed caps | ||||
* | * | ||||
* @param string {string} | * @param string {string} | ||||
* @param size {number} - Font size | * @param size {number} - Font size | ||||
* @returns {string} | * @returns {string} | ||||
*/ | */ | ||||
function heading(string, size) | function heading(string, size) | ||||
{ | { | ||||
var textArray = string.split(" "); | var textArray = string.split(" "); | ||||
for (let i in textArray) | for (let i in textArray) | ||||
{ | { | ||||
var word = textArray[i]; | var word = textArray[i]; | ||||
var wordCaps = word.toUpperCase(); | var wordCaps = word.toUpperCase(); | ||||
// Check if word is capitalized, if so assume it needs a big first letter | // Check if word is capitalized, if so assume it needs a big first letter | ||||
// Check if toLowerCase changes the character to avoid false positives from special signs | // Check if toLowerCase changes the character to avoid false positives from special signs | ||||
if (word.length && word[0].toLowerCase() != word[0]) | if (word.length && word[0].toLowerCase() != word[0]) | ||||
textArray[i] = bigFirstLetter(wordCaps, size); | textArray[i] = bigFirstLetter(wordCaps, size); | ||||
else | else | ||||
textArray[i] = '[font="sans-bold-' + size + '"]' + wordCaps + '[/font]'; // TODO: Would not be necessary if we could do nested tags | textArray[i] = setFont(wordCaps, 'sans-bold-' + size); // TODO: Would not be necessary if we could do nested tags | ||||
} | } | ||||
return textArray.join(" "); | return textArray.join(" "); | ||||
} | } | ||||
/** | /** | ||||
* Prepends a backslash to all quotation marks. | * Prepends a backslash to all quotation marks. | ||||
* @param str {string} | * @param str {string} | ||||
Show All 9 Lines | |||||
* | * | ||||
* @param obj {Object} | * @param obj {Object} | ||||
* @returns {string} | * @returns {string} | ||||
*/ | */ | ||||
function subHeading(obj) | function subHeading(obj) | ||||
{ | { | ||||
if (!obj.Name) | if (!obj.Name) | ||||
return ""; | return ""; | ||||
let string = '[font="sans-bold-14"]' + obj.Name + '[/font] '; | let string = setFont(obj.Name, "sans-bold-14"); | ||||
if (obj.History) | if (obj.History) | ||||
string += '[icon="iconInfo" tooltip="' + escapeQuotation(obj.History) + '" tooltip_style="civInfoTooltip"]'; | string += '[icon="iconInfo" tooltip="' + escapeQuotation(obj.History) + '" tooltip_style="civInfoTooltip"]'; | ||||
if (obj.Description) | if (obj.Description) | ||||
string += '\n ' + obj.Description; | string += '\n ' + obj.Description; | ||||
return coloredText(string + "\n", "white"); | return coloredText(string + "\n", "white"); | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator