Difference between revisions of "Template:Season"

From Stardew Valley Wiki
Jump to navigation Jump to search
(adding size instead of width (standardize params); null alt (always followed by season text))
(new format for list of allowed values; tweaks to parameters)
Line 1: Line 1:
 
<includeonly><!--
 
<includeonly><!--
  
// Define the allowed values.  Handling multiple quirks/oddities. Ideally, all of the names would work equally well
+
// Define the allowed values, with handling for various quirks/oddities.
// as displayed text, wiki page names, and icon names.  But that's not possible.  So top priority is to
+
//  First column=icon name -> same in all languages
// create a list of valid page names.  That's why 'Seasons' is primary name for 'All', 'Any', 'All Seasons'
+
//   Second column=link (wiki page) name, generally same as displayed text -> needs translation
 +
//   All other values are synonyms
 
// Marriage, Deviations are for sake of NPC schedule sections (and translations)
 
// Marriage, Deviations are for sake of NPC schedule sections (and translations)
-->{{#arraydefine:$engl_seasons|Spring, Summer, Fall, Winter, Seasons, Marriage, Deviations, Fall, Seasons, Seasons}}<!--
+
// For 'All Seasons' case, display text doesn't match icon or wiki-link, so
-->{{#arraydefine:$lang_seasons|Spring, Summer, Fall, Winter, Seasons, Marriage, Deviations, Autumn, All, Any}}<!--
+
// define default display text in $lang_allseasons, with parameter allowing any other preferred value
-->{{#arraydefine:$lang_allshort | All }}<!--
+
-->{{ParseInputValues|code=season||
-->{{#arraydefine:$lang_alllong  | All Seasons}}<!--
+
,All Seasons Icon, Seasons, All, All Seasons, Any, Always,
 +
,Spring,
 +
,Summer,
 +
,Fall,  Fall, Autumn,
 +
,Winter,
 +
,Mermaid's Pendant, Marriage,
 +
,Deviations,
 +
}}{{#arraydefine:$lang_allseasons | All }}<!--
  
 
// END OF translated text
 
// END OF translated text
Line 15: Line 23:
 
-->{{#if:{{#pos:{{{1|}}}|{{Bracket|2}}File}}|{{{1}}}|<!--
 
-->{{#if:{{#pos:{{{1|}}}|{{Bracket|2}}File}}|{{{1}}}|<!--
 
// Parse input data, then loop over all extracted entries
 
// Parse input data, then loop over all extracted entries
-->{{#arraydefine:$sseason|{{ParseInputValues|{{{1|}}}|{{#arrayprint:$engl_seasons}}|{{#arrayprint:$lang_seasons}}|default=true}}}}<!--
+
-->{{#arraydefine:$sseason|{{ParseInputValues|{{{1|}}}|code=season|default=true}}}}<!--
-->{{#if:{{#arrayprint:$sseason}} |
 
<span style="display:inline; margin-right:0; white-space: nowrap"><!--
 
 
-->{{#arrayprint:$sseason||@season@|<!--
 
-->{{#arrayprint:$sseason||@season@|<!--
  
// Add space and bullet if this is not first entry
+
// Convert @season@ (icon name) into translated page name
-->{{#ifexpr:{{#arraysearch:$sseason|@season@}}>0|</span>&#32;•&#32;<span style="display:inline; margin-right:0; white-space: nowrap">}}<!--
+
-->{{#arraydefine:$slink_text|{{ParseInputValues|code=season|@season@|translate=true}}}}<!--
  
// Convert @season@ (english page name) into translated page name
+
// On first entry, add sort-key if requested. On other entries, add space and bullet.
-->{{#arraydefine:$slink_text|{{#arrayindex:$lang_seasons|{{#arraysearch:$engl_seasons|@season@}}}}}}<!--
+
-->{{#ifexpr:{{#arraysearch:$sseason|@season@}}>0
 +
    |&#32;•&#32;
 +
    |{{#if:{{{sortkey|}}}|
 +
        <span class="sortkey" style="display:none;">{{#if:{{#arrayprint:$slink_text}}
 +
  |{{#expr:{{ParseInputValues|code=season|@season@|translate=index}}+1}}
 +
  |0}}</span>
 +
  }}}}<span style="display:inline; margin-right:0; white-space: nowrap"><!--
  
// Display the non-icon, non-linkable cases: Devations, and unmatched text (detected by empty link_text)
+
// Display the non-icon, non-linkable cases: Deviations, and unmatched text (detected by empty link_text)
// This is also how text_only option is handled
+
// This is also where text_only option is handled
 
-->{{#ifeq:{{#arrayprint:$slink_text}}|
 
-->{{#ifeq:{{#arrayprint:$slink_text}}|
 
     | {{ucfirst:@season@}}
 
     | {{ucfirst:@season@}}
 
     | {{#ifexpr: {{#ifeq:@season@|Deviations|1|0}} or {{#if:{{{text_only|}}}|1|0}}
 
     | {{#ifexpr: {{#ifeq:@season@|Deviations|1|0}} or {{#if:{{{text_only|}}}|1|0}}
         | {{#if:{{{no_translate|}}}|@season@|{{#arrayprint:$slink_text}}}}
+
         | {{#if:{{{no_translate|}}}
| <!--
+
    |{{#ifeq:@season@|All Seasons Icon|All|@season@}}
 +
    |{{#ifeq:@season@|All Seasons Icon|{{#arrayprint:$lang_allseasons}}|{{#arrayprint:$slink_text}}}}}}
 +
|<!--
  
 
// Display the normal cases: first display icon
 
// Display the normal cases: first display icon
-->[[File:{{#switch:@season@
+
-->[[File:@[email protected]|
      |Spring
+
    {{#if:{{{size|}}}|{{{size}}}px|{{{width|24px}}}}} | link={{#arrayprint:$slink_text}} | alt=]]&nbsp;<!--
      |Summer
 
      |Fall
 
      |Winter    = @season@
 
      |Seasons    = All_Seasons_Icon
 
      |Marriage  = Mermaid's Pendant
 
  }}.png | {{#if:{{{size|}}}|{{{size}}}px|{{{width|24px}}}}} | link={{#arrayprint:$slink_text}} | alt=]]&nbsp;<!--
 
  
 
// Add link, with special treatment for text of All Seasons
 
// Add link, with special treatment for text of All Seasons
 
-->[[{{#arrayprint:$slink_text}}|<!--
 
-->[[{{#arrayprint:$slink_text}}|<!--
-->{{#ifeq:@season@|Seasons
+
-->{{#ifeq:@season@|All Seasons Icon
       |{{#if:{{{do_short|}}}|{{#arrayprint:$lang_allshort}}|{{#arrayprint:$lang_alllong}}}}
+
       |{{#if:{{{all|}}}|{{{all|}}}|{{#arrayprint:$lang_allseasons}}}}
 
       |{{#arrayprint:$slink_text}}}}]]<!--
 
       |{{#arrayprint:$slink_text}}}}]]<!--
-->}}}}}}</span>}}}}</includeonly><noinclude>{{Englishdoc}}{{#ifexist:{{FULLPAGENAME}}/doc |<nowiki/>
+
-->}}}}</span>}}}}</includeonly><noinclude>{{Englishdoc}}{{#ifexist:{{FULLPAGENAME}}/doc |<nowiki/>
 
{{{{FULLPAGENAME}}/doc}} }}</noinclude>
 
{{{{FULLPAGENAME}}/doc}} }}</noinclude>

Revision as of 16:51, 10 September 2020

Description

This template displays the icon for the requested season, plus the season as a link to its associated article.

Notes

The template recognizes two special values of season, Marriage and Deviations, for the sake of NPC schedule pages (see Template:ScheduleHeader).

Use

{{Season|name of season|day (optional)|width (optional)}}

Examples

{{Season|Spring}}
{{Season|Marriage}}
{{Season|Deviations}}
{{Season|All|width=48}}
{{Season|Summer|24}}

Results:
Template:ParseInputValues[[File:Template:ParseInputValues.png|

    24px | link=Template:ParseInputValues | alt=]] [[Template:ParseInputValues|Template:ParseInputValues]]

Template:ParseInputValues[[File:Template:ParseInputValues.png|

    24px | link=Template:ParseInputValues | alt=]] [[Template:ParseInputValues|Template:ParseInputValues]]

Template:ParseInputValues[[File:Template:ParseInputValues.png|

    24px | link=Template:ParseInputValues | alt=]] [[Template:ParseInputValues|Template:ParseInputValues]]

Template:ParseInputValues[[File:Template:ParseInputValues.png|

    48 | link=Template:ParseInputValues | alt=]] [[Template:ParseInputValues|Template:ParseInputValues]]

Template:ParseInputValues[[File:Template:ParseInputValues.png|

    24px | link=Template:ParseInputValues | alt=]] [[Template:ParseInputValues|Template:ParseInputValues]]