Skip to content

Commit

Permalink
#1 Mapped in new icons in favour of default game icons.
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesDonnelly committed Jun 7, 2019
1 parent 4bcd0b5 commit 14e718e
Show file tree
Hide file tree
Showing 48 changed files with 127 additions and 44 deletions.
2 changes: 1 addition & 1 deletion docs/de/emotes.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/de/minions.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/de/mounts.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/de/orchestrion.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/en/emotes.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/en/minions.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/en/mounts.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/en/orchestrion.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/fr/emotes.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/fr/minions.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/fr/mounts.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/fr/orchestrion.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/icons/methods.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"60432":[0,0,24,24],"60438":[0,24,24,24],"60929":[0,48,16,16],"61575":[24,0,24,24],"71201":[0,64,16,16],"71221":[48,24,16,16],"80103":[48,0,19,24],"80104":[83,32,13,16],"80105":[83,16,13,16],"80106":[83,0,13,16],"80108":[68,64,13,16],"80109":[55,64,13,16],"80110":[83,48,13,16],"80112":[42,64,13,16],"80113":[29,64,13,16],"80121":[16,64,13,16],"92013":[24,24,24,24],"alchemist":[67,48,16,16],"armorer":[67,16,16,16],"blacksmith":[67,0,16,16],"carpenter":[48,48,16,16],"goldsmith":[32,48,16,16],"leatherworker":[16,48,16,16],"weaver":[67,32,16,16]}
{"60432":[40,0],"60438":[40,80],"60929":[0,40],"71201":[40,40],"71221":[80,0],"achievement":[80,40],"alchemist":[0,80],"armorer":[0,0],"blacksmith":[80,80],"carpenter":[120,0],"event":[120,40],"goldsmith":[120,80],"leatherworker":[0,120],"shop":[40,120],"weaver":[80,120]}
Binary file modified docs/icons/methods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/ja/emotes.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ja/minions.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ja/mounts.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ja/orchestrion.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
29
52
Binary file modified icons-raw/methods/60432.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons-raw/methods/60438.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons-raw/methods/60929.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons-raw/methods/61575.png
Binary file not shown.
Binary file modified icons-raw/methods/71201.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons-raw/methods/71221.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons-raw/methods/80103.png
Binary file not shown.
Binary file removed icons-raw/methods/80104.png
Binary file not shown.
Binary file removed icons-raw/methods/80105.png
Binary file not shown.
Binary file removed icons-raw/methods/80106.png
Binary file not shown.
Binary file removed icons-raw/methods/80108.png
Binary file not shown.
Binary file removed icons-raw/methods/80109.png
Binary file not shown.
Binary file removed icons-raw/methods/80110.png
Binary file not shown.
Binary file removed icons-raw/methods/80112.png
Binary file not shown.
Binary file removed icons-raw/methods/80113.png
Binary file not shown.
Binary file removed icons-raw/methods/80121.png
Binary file not shown.
Binary file removed icons-raw/methods/92013.png
Binary file not shown.
Binary file added icons-raw/methods/achievement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons-raw/methods/alchemist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons-raw/methods/armorer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons-raw/methods/blacksmith.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons-raw/methods/carpenter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons-raw/methods/event.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons-raw/methods/goldsmith.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons-raw/methods/leatherworker.png
Binary file added icons-raw/methods/shop.png
Binary file modified icons-raw/methods/weaver.png
8 changes: 4 additions & 4 deletions src/config/_localisationHelper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
achievementShort: (entry, language) => ([
'achievementShort',
92013,
'achievement',
[entry.name[language]]
]),
craftShort: (entry, language) => ([
Expand All @@ -17,7 +17,7 @@ module.exports = {
quest: {
eventQuestShort: (quest, language) => ([
'eventQuestShort',
quest.icon,
'event',
[quest.level, quest.name[language], quest.journal.category[language]]
]),
msqShort: (quest, language) => ([
Expand All @@ -34,7 +34,7 @@ module.exports = {
shop: {
gilShort: (entry, language) => ([
'gilShopShort',
61575,
'shop',
[
entry.cost,
entry.currency.name[language],
Expand All @@ -46,7 +46,7 @@ module.exports = {
]),
specialShort: (entry, language) => ([
'specialShopShort',
61575,
'shop',
[
entry.cost,
entry.currency.name[language],
Expand Down
127 changes: 105 additions & 22 deletions src/parsers/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,24 @@ async function fetchIconsFromPaths(paths = [], folderRef = '') {

for (const [index, path] of paths.entries()) {
const iconData = await new Promise(resolve => {
const apiPath = `https://xivapi.com${path}`;
let apiPath;
let savePath;

if (typeof path === 'object') {
apiPath = `https://xivapi.com${path.path}`,
savePath = `./icons-raw/${folderRef}/${path.as}.png`;
} else {
apiPath = `https://xivapi.com${path}`;
savePath = `./icons-raw/${folderRef}/${(
path.replace(/^.*\/([A-Za-z0-9]+)\.png$/, (_, group) => {
if (isNaN(Number(group))) {
return group;
}
const savePath = `./icons-raw/${folderRef}/${(
path.replace(/^.*\/([A-Za-z0-9]+)\.png$/, (_, group) => {
if (isNaN(Number(group))) {
return group;
}
return Number(group);
})
)}.png`;
return Number(group);
})
)}.png`;
}

// Do not fetch the image if it already exists.
if (fs.existsSync(savePath)) {
Expand Down Expand Up @@ -219,11 +226,13 @@ function getCraftingIconPaths() {
...arr,
...recipeGroup.map(recipe => recipe.iconPath)
]), []).forEach(iconPath => {
if (paths.indexOf(iconPath) !== -1) {
const mappedPath = mapIconPath(iconPath);

if (paths.find(path => path.as === mappedPath.as)) {
return;
}

paths.push(iconPath);
paths.push(mappedPath);
});

return paths;
Expand All @@ -241,11 +250,13 @@ function getGatheringIconPaths() {
...arr,
...nodeGroup.map(node => node.iconPath)
]), []).forEach(iconPath => {
if (paths.indexOf(iconPath) !== -1) {
const mappedPath = mapIconPath(iconPath);

if (paths.find(path => path.as === mappedPath.as)) {
return;
}

paths.push(iconPath);
paths.push(mappedPath);
});

return paths;
Expand All @@ -259,20 +270,92 @@ function getQuestJournalIconPaths() {

const paths = [];

Object.values(quests).reduce((arr, questGroup) => ([
Object.values(quests).reduce((arr, nodeGroup) => ([
...arr,
...questGroup.map(quest => quest.iconPath)
...nodeGroup.map(quest => quest.iconPath)
]), []).forEach(iconPath => {
if (paths.indexOf(iconPath) !== -1) {
const mappedPath = mapIconPath(iconPath);

if (paths.find(path => path.as === mappedPath.as)) {
return;
}

paths.push(iconPath);
paths.push(mappedPath);
});

return paths;
}

function mapIconPath(iconPath) {
const pathAfterReplace = iconPath.replace(/^.*\/([A-Za-z0-9]+)\.png$/, (_, group) => {
if (isNaN(Number(group))) {
return group;
}

return Number(group);
});

switch (pathAfterReplace) {
// Crafting classes
case 'alchemist':
return { path: '/i/092000/092037.png', as: pathAfterReplace };
case 'armorer':
return { path: '/i/092000/092033.png', as: pathAfterReplace };
case 'blacksmith':
return { path: '/i/092000/092032.png', as: pathAfterReplace };
case 'carpenter':
return { path: '/i/092000/092031.png', as: pathAfterReplace };
case 'culinarian':
return { path: '/i/092000/092038.png', as: pathAfterReplace };
case 'goldsmith':
return { path: '/i/092000/092034.png', as: pathAfterReplace };
case 'leatherworker':
return { path: '/i/092000/092035.png', as: pathAfterReplace };
case 'weaver':
return { path: '/i/092000/092036.png', as: pathAfterReplace };

// Gathering classes
case '60438': // Miner
return { path: '/i/092000/092039.png', as: pathAfterReplace };
case '60432': // Botanist
return { path: '/i/092000/092040.png', as: pathAfterReplace };
case '60929': // Fisher
return { path: '/i/092000/092041.png', as: pathAfterReplace };

// Quests
case '71201': // Regular quests
case '71221': // Main Scenario quests
return { path: iconPath, as: pathAfterReplace };
case '80101': // Event quest: Halloween 1
case '80102': // Event quest: FFXIII collaboration
case '80103': // Event quest: Halloween 2
case '80104': // Event quest: Slime
case '80105': // Event quest: Little Ladies Day
case '80106': // Event quest: Christmas
case '80107': // Event quest: Pegasus
case '80108': // Event quest: Valentine's Day
case '80109': // Event quest: Flowers
case '80110': // Event quest: Easter
case '80111': // Event quest: Chinese New Year
case '80112': // Event quest: Chinese New Year: Sheep
case '80113': // Event quest: Generic event
case '80115': // Event quest: Chinese New Year: Monkey
case '80116': // Event quest: Gold Saucer
case '80117': // Event quest: Yokai Watch collaboration
case '80118': // Event quest: Chinese New Year: Rooster
case '80119': // Event quest: Chinese New Year: Dog
case '80120': // Event quest: Chinese New Year: Boar
case '80121': // Event quest: Monster Hunter collaboration
case '80123': // Event quest: FFXV collaboration
return { path: '/i/092000/092012.png', as: 'event' };


default:
console.warn(`No mapped icon path for ${pathAfterReplace} (${iconPath})`);
return { path: iconPath, as: pathAfterReplace };
}
}

/**
* Minify a folder of icon images.
* @param {Array} savedImagePaths - An array of saved image paths.
Expand All @@ -282,7 +365,7 @@ function getQuestJournalIconPaths() {
async function minifySavedIcons(savedImagePaths = [], folderRef = '', config) {
console.time(`${folderRef}Minify`);
console.info(`Minifying ${folderRef} icons...`);

const use = [
imageminAdvpng()
];
Expand Down Expand Up @@ -476,11 +559,11 @@ async function parseMethodIcons() {
...getCraftingIconPaths(),
...getGatheringIconPaths(),
...getQuestJournalIconPaths(),
'/img-misc/061575.png',
'/i/092000/092013.png'
{ path: '/i/092000/092019.png', as: 'shop' },
{ path: '/i/092000/092013.png', as: 'achievement' }
];

await processIconGroup(paths, 'methods', { resize: 24 });
await processIconGroup(paths, 'methods', { resize: 40 });
console.timeEnd('ObtainMethodIcons');
}

Expand Down

0 comments on commit 14e718e

Please sign in to comment.