Ticket #3986: modCredits.diff

File modCredits.diff, 8.9 KB (added by sanderd17, 8 years ago)
  • binaries/data/mods/public/gui/credits/credits.js

     
    11var g_PanelNames = ["special", "programming", "art", "translators", "misc", "donators"];
    2 var g_PanelTexts = [];
     2var g_ButtonNames = {};
     3var g_PanelTexts = {};
    34var g_ActivePanel = -1;
    45
    56function init()
     
    67{
    78    // Load credits list from the disk and parse them
    89    for (let name of g_PanelNames)
    9         g_PanelTexts.push(parseJSONCredits(name));
     10    {
     11        let json = Engine.ReadJSONFile("gui/credits/texts/" + name + ".json");
     12        if (!json || !json.Content)
     13        {
     14            error("Could not load credits for " + name + "!");
     15            continue;
     16        }
     17        g_ButtonNames[name] = json.Title || name;
     18        g_PanelTexts[name] = parseHelper(json.Content);
     19    }
    1020
     21    placeButtons();
    1122    selectPanel(0);
    1223}
    1324
     25function placeButtons()
     26{
     27    const numButtons = 20;
     28    if (g_PanelNames.length > numButtons)
     29        warn("Could not display some credits.");
     30
     31    for (let i = 0; i < numButtons; ++i)
     32    {
     33        let button = Engine.GetGUIObjectByName("creditsPanelButton[" + i + "]");
     34        if (i >= g_PanelNames.length)
     35        {
     36            button.hidden = true;
     37            continue;
     38        }
     39        let size = button.size;
     40        size.top = i * 35;
     41        size.bottom = size.top + 30;
     42        button.size = size;
     43        button.onPress = (function(i){ return function() {selectPanel(i);}; })(i);
     44        let buttonText = Engine.GetGUIObjectByName("creditsPanelButtonText[" + i + "]");
     45        buttonText.caption = translate(g_ButtonNames[g_PanelNames[i]]);
     46    }
     47}
     48
    1449// Run through a "Content" list and parse elements for formatting and translation
    1550function parseHelper(list)
    1651{
     
    4883    return result;
    4984}
    5085
    51 function parseJSONCredits(panelName)
    52 {
    53     let json = Engine.ReadJSONFile("gui/credits/texts/" + panelName + ".json");
    54     if (!json || !json.Content)
    55     {
    56         error("Could not load credits for " + panelName + "!");
    57         return "";
    58     }
    59 
    60     return parseHelper(json.Content);
    61 }
    62 
    6386function selectPanel(i)
    6487{
    6588    if (g_ActivePanel != -1)
    6689    {
    67         let oldPanelButton = Engine.GetGUIObjectByName(g_PanelNames[g_ActivePanel] + "PanelButton");
     90        let oldPanelButton = Engine.GetGUIObjectByName("creditsPanelButton[" + g_ActivePanel+ "]");
    6891        oldPanelButton.sprite = "BackgroundBox";
    6992    }
    7093
    7194    g_ActivePanel = i;
    72     let newPanelButton = Engine.GetGUIObjectByName(g_PanelNames[g_ActivePanel] + "PanelButton");
     95    let newPanelButton = Engine.GetGUIObjectByName("creditsPanelButton[" + g_ActivePanel+ "]");
    7396    newPanelButton.sprite = "ForegroundBox";
    7497
    7598    let creditsText = Engine.GetGUIObjectByName("creditsText");
    76     creditsText.caption = g_PanelTexts[i];
     99    creditsText.caption = g_PanelTexts[g_PanelNames[i]];
    77100}
  • binaries/data/mods/public/gui/credits/credits.xml

     
    88
    99<objects>
    1010    <script file="gui/common/functions_global_object.js"/>
    11     <script file="gui/credits/credits.js"/>
     11    <script directory="gui/credits/"/>
    1212
    1313    <!-- Add a translucent black background to fade out the menu page -->
    1414    <object type="image" z="0" sprite="ModernFade"/>
    1515
    1616    <object type="image" style="ModernDialog" size="50%-473 24 50%+473 100%-24">
    17         <object style="ModernLabelText" type="text" size="50%-128 -18 50%+128 14">
     17        <object style="ModernLabelText" name="dialogTitle" type="text" size="50%-128 -18 50%+128 14">
    1818            <translatableAttribute id="caption">0 A.D. Credits</translatableAttribute>
    1919        </object>
    2020
    21         <object name="specialPanelButton" type="button" sprite="BackgroundBox" size="20 50 150 80">
    22             <action on="Press">selectPanel(0);</action>
    23             <object type="text" style="ModernLabelText" ghost="true">
    24                 <translatableAttribute id="caption">Special Credits</translatableAttribute>
    25             </object>
     21        <object type="image" size="20 30 210 100%-54">
     22            <repeat count="20">
     23                <object name="creditsPanelButton[n]" type="button" sprite="BackgroundBox" size="0 0 190 30">
     24                    <object type="text" name="creditsPanelButtonText[n]" style="ModernLabelText" ghost="true">
     25                    </object>
     26                </object>
     27            </repeat>
    2628        </object>
    2729
    28         <object name="programmingPanelButton" type="button" sprite="BackgroundBox" size="155 50 305 80">
    29             <action on="Press">selectPanel(1);</action>
    30             <object type="text" style="ModernLabelText" ghost="true">
    31                 <translatableAttribute id="caption">Programming</translatableAttribute>
    32             </object>
    33         </object>
    34 
    35         <object name="artPanelButton" type="button" sprite="BackgroundBox" size="310 50 460 80">
    36             <action on="Press">selectPanel(2);</action>
    37             <object type="text" style="ModernLabelText" ghost="true">
    38                 <translatableAttribute id="caption">Art</translatableAttribute>
    39             </object>
    40         </object>
    41 
    42         <object name="translatorsPanelButton" type="button" sprite="BackgroundBox" size="465 50 615 80">
    43             <action on="Press">selectPanel(3);</action>
    44             <object type="text" style="ModernLabelText" ghost="true">
    45                 <translatableAttribute id="caption">Translators</translatableAttribute>
    46             </object>
    47         </object>
    48 
    49         <object name="miscPanelButton" type="button" sprite="BackgroundBox" size="620 50 770 80">
    50             <action on="Press">selectPanel(4);</action>
    51             <object type="text" style="ModernLabelText" ghost="true">
    52                 <translatableAttribute id="caption">Miscellaneous</translatableAttribute>
    53             </object>
    54         </object>
    55 
    56         <object name="donatorsPanelButton" type="button" sprite="BackgroundBox" size="775 50 925 80">
    57             <action on="Press">selectPanel(5);</action>
    58             <object type="text" style="ModernLabelText" ghost="true">
    59                 <translatableAttribute id="caption">Donors</translatableAttribute>
    60             </object>
    61         </object>
    62 
    63         <object type="image" sprite="ModernFade" size="20 85 100%-20 100%-54">
     30        <object type="image" sprite="ModernFade" size="220 30 100%-20 100%-54">
    6431            <object name="creditsText" type="text" style="textPanel"/>
    6532        </object>
    6633
  • binaries/data/mods/public/gui/credits/texts/art.json

     
    11{
     2    "Title": "Art",
    23    "Content": [
    34    {
    45        "Title": "Artistic managers",
  • binaries/data/mods/public/gui/credits/texts/donators.json

     
    11{
     2    "Title": "Donors",
    23    "Content" : [
    34    {
    45        "Title": "Pledgie Drive 1",
  • binaries/data/mods/public/gui/credits/texts/misc.json

     
    11{
     2    "Title": "Miscellaneous",
    23    "Content": [
    34    {
    45        "Title": "History References",
  • binaries/data/mods/public/gui/credits/texts/programming.json

     
    11{
     2    "Title": "Programming",
    23    "Content": [
    34    {
    45        "Title": "Programming managers",
  • binaries/data/mods/public/gui/credits/texts/special.json

     
    11{
     2    "Title": "Special Credits",
    23    "Content": [
    34    {
    45        "Title": "In Memoriam",
  • binaries/data/mods/public/gui/credits/texts/translators.json

     
    11{
     2    "Title": "Translators",
    23    "Content": [
    34        {
    45            "List": [
     
    19941995            "LangName": "T\u00fcrk\u00e7e"
    19951996        }
    19961997    ]
    1997 }
    1998  No newline at end of file
     1998}
  • source/tools/i18n/creditTranslators.py

     
    7272langsLists = {}
    7373
    7474# Create the new JSON data
    75 newJSONData = {'Content': []}
     75newJSONData = {'Title': 'Translators', 'Content': []}
    7676
    7777# First get the already existing lists. If they correspond with some of the credited languages,
    7878# add them to the new data after processing, else add them immediately.