]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/common/ZeldaIcon.js
map marker icons
[alttp.git] / resources / js / components / common / ZeldaIcon.js
index c53f4fd68def288ae2f231e11dc65b486796237f..ef07b9207f3ecbc5bc0d9b28f76889b5be0a8495 100644 (file)
@@ -27,6 +27,7 @@ const getIconURL = name => {
                case 'ether':
                case 'fairy':
                case 'fighter-shield':
+               case 'fighter-sword':
                case 'fire-rod':
                case 'fire-shield':
                case 'flippers':
@@ -59,24 +60,46 @@ const getIconURL = name => {
                case 'small-key':
                case 'somaria':
                        return `/item/${name}.png`;
+               case 'dungeon-ct':
+               case 'dungeon-dp':
+               case 'dungeon-ep':
+               case 'dungeon-gt':
+               case 'dungeon-hc':
+               case 'dungeon-ip':
+               case 'dungeon-mm':
+               case 'dungeon-pd':
+               case 'dungeon-sp':
+               case 'dungeon-sw':
+               case 'dungeon-th':
+               case 'dungeon-tr':
+               case 'dungeon-tt':
+                       return `/dungeon/${name.substr(8)}.png`;
+               case 'crystal-switch':
+               case 'crystal-switch-blue':
+               case 'crystal-switch-red':
+                       return `/icon/${name}.png`;
                default:
                        return '';
        }
 };
 
-const ZeldaIcon = ({ name }) => {
+const ZeldaIcon = ({ name, title }) => {
        const { t } = useTranslation();
 
        const invert = name.startsWith('not-');
        const strippedName = invert ? name.substr(4) : name;
-       const title = t(`icon.zelda.${name}`);
+       const src = getIconURL(strippedName);
+       const alt = t(`icon.zelda.${name}`);
+       const realTitle = title !== '' ? title || alt : null;
 
        return <span className="zelda-icon">
-               <img
-                       alt={title}
-                       src={getIconURL(strippedName)}
-                       title={title}
-               />
+               {src ?
+                       <img
+                               alt={alt}
+                               src={src}
+                               title={realTitle}
+                       />
+               : null}
                {invert ?
                        <span className="strike">
                                <Icon.SLASH title="" />
@@ -87,6 +110,7 @@ const ZeldaIcon = ({ name }) => {
 
 ZeldaIcon.propTypes = {
        name: PropTypes.string,
+       title: PropTypes.string,
 };
 
 export default ZeldaIcon;