Ticket #3986: modCredits.diff
File modCredits.diff, 8.9 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/credits/credits.js
1 1 var g_PanelNames = ["special", "programming", "art", "translators", "misc", "donators"]; 2 var g_PanelTexts = []; 2 var g_ButtonNames = {}; 3 var g_PanelTexts = {}; 3 4 var g_ActivePanel = -1; 4 5 5 6 function init() … … 6 7 { 7 8 // Load credits list from the disk and parse them 8 9 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 } 10 20 21 placeButtons(); 11 22 selectPanel(0); 12 23 } 13 24 25 function 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 14 49 // Run through a "Content" list and parse elements for formatting and translation 15 50 function parseHelper(list) 16 51 { … … 48 83 return result; 49 84 } 50 85 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 63 86 function selectPanel(i) 64 87 { 65 88 if (g_ActivePanel != -1) 66 89 { 67 let oldPanelButton = Engine.GetGUIObjectByName( g_PanelNames[g_ActivePanel] + "PanelButton");90 let oldPanelButton = Engine.GetGUIObjectByName("creditsPanelButton[" + g_ActivePanel+ "]"); 68 91 oldPanelButton.sprite = "BackgroundBox"; 69 92 } 70 93 71 94 g_ActivePanel = i; 72 let newPanelButton = Engine.GetGUIObjectByName( g_PanelNames[g_ActivePanel] + "PanelButton");95 let newPanelButton = Engine.GetGUIObjectByName("creditsPanelButton[" + g_ActivePanel+ "]"); 73 96 newPanelButton.sprite = "ForegroundBox"; 74 97 75 98 let creditsText = Engine.GetGUIObjectByName("creditsText"); 76 creditsText.caption = g_PanelTexts[ i];99 creditsText.caption = g_PanelTexts[g_PanelNames[i]]; 77 100 } -
binaries/data/mods/public/gui/credits/credits.xml
8 8 9 9 <objects> 10 10 <script file="gui/common/functions_global_object.js"/> 11 <script file="gui/credits/credits.js"/>11 <script directory="gui/credits/"/> 12 12 13 13 <!-- Add a translucent black background to fade out the menu page --> 14 14 <object type="image" z="0" sprite="ModernFade"/> 15 15 16 16 <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"> 18 18 <translatableAttribute id="caption">0 A.D. Credits</translatableAttribute> 19 19 </object> 20 20 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> 26 28 </object> 27 29 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"> 64 31 <object name="creditsText" type="text" style="textPanel"/> 65 32 </object> 66 33 -
binaries/data/mods/public/gui/credits/texts/art.json
1 1 { 2 "Title": "Art", 2 3 "Content": [ 3 4 { 4 5 "Title": "Artistic managers", -
binaries/data/mods/public/gui/credits/texts/donators.json
1 1 { 2 "Title": "Donors", 2 3 "Content" : [ 3 4 { 4 5 "Title": "Pledgie Drive 1", -
binaries/data/mods/public/gui/credits/texts/misc.json
1 1 { 2 "Title": "Miscellaneous", 2 3 "Content": [ 3 4 { 4 5 "Title": "History References", -
binaries/data/mods/public/gui/credits/texts/programming.json
1 1 { 2 "Title": "Programming", 2 3 "Content": [ 3 4 { 4 5 "Title": "Programming managers", -
binaries/data/mods/public/gui/credits/texts/special.json
1 1 { 2 "Title": "Special Credits", 2 3 "Content": [ 3 4 { 4 5 "Title": "In Memoriam", -
binaries/data/mods/public/gui/credits/texts/translators.json
1 1 { 2 "Title": "Translators", 2 3 "Content": [ 3 4 { 4 5 "List": [ … … 1994 1995 "LangName": "T\u00fcrk\u00e7e" 1995 1996 } 1996 1997 ] 1997 } 1998 No newline at end of file 1998 } -
source/tools/i18n/creditTranslators.py
72 72 langsLists = {} 73 73 74 74 # Create the new JSON data 75 newJSONData = {' Content': []}75 newJSONData = {'Title': 'Translators', 'Content': []} 76 76 77 77 # First get the already existing lists. If they correspond with some of the credited languages, 78 78 # add them to the new data after processing, else add them immediately.