Make it easier for mods to add their own credits. Fixes #3986
This was SVN commit r18281.
This commit is contained in:
parent
ab4c656ff6
commit
4223fad060
@ -1,16 +1,52 @@
|
|||||||
var g_PanelNames = ["special", "programming", "art", "translators", "misc", "donators"];
|
var g_PanelNames = ["special", "programming", "art", "translators", "misc", "donators"];
|
||||||
var g_PanelTexts = [];
|
var g_ButtonNames = {};
|
||||||
|
var g_PanelTexts = {};
|
||||||
var g_ActivePanel = -1;
|
var g_ActivePanel = -1;
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
// Load credits list from the disk and parse them
|
// Load credits list from the disk and parse them
|
||||||
for (let name of g_PanelNames)
|
for (let name of g_PanelNames)
|
||||||
g_PanelTexts.push(parseJSONCredits(name));
|
{
|
||||||
|
let json = Engine.ReadJSONFile("gui/credits/texts/" + name + ".json");
|
||||||
|
if (!json || !json.Content)
|
||||||
|
{
|
||||||
|
error("Could not load credits for " + name + "!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
g_ButtonNames[name] = json.Title || name;
|
||||||
|
g_PanelTexts[name] = parseHelper(json.Content);
|
||||||
|
}
|
||||||
|
|
||||||
|
placeButtons();
|
||||||
selectPanel(0);
|
selectPanel(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function placeButtons()
|
||||||
|
{
|
||||||
|
const numButtons = 20;
|
||||||
|
if (g_PanelNames.length > numButtons)
|
||||||
|
warn("Could not display some credits.");
|
||||||
|
|
||||||
|
for (let i = 0; i < numButtons; ++i)
|
||||||
|
{
|
||||||
|
let button = Engine.GetGUIObjectByName("creditsPanelButton[" + i + "]");
|
||||||
|
if (i >= g_PanelNames.length)
|
||||||
|
{
|
||||||
|
button.hidden = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let size = button.size;
|
||||||
|
size.top = i * 35;
|
||||||
|
size.bottom = size.top + 30;
|
||||||
|
button.size = size;
|
||||||
|
|
||||||
|
button.onPress = (i => function() {selectPanel(i);})(i);
|
||||||
|
let buttonText = Engine.GetGUIObjectByName("creditsPanelButtonText[" + i + "]");
|
||||||
|
buttonText.caption = translate(g_ButtonNames[g_PanelNames[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Run through a "Content" list and parse elements for formatting and translation
|
// Run through a "Content" list and parse elements for formatting and translation
|
||||||
function parseHelper(list)
|
function parseHelper(list)
|
||||||
{
|
{
|
||||||
@ -48,30 +84,15 @@ function parseHelper(list)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseJSONCredits(panelName)
|
|
||||||
{
|
|
||||||
let json = Engine.ReadJSONFile("gui/credits/texts/" + panelName + ".json");
|
|
||||||
if (!json || !json.Content)
|
|
||||||
{
|
|
||||||
error("Could not load credits for " + panelName + "!");
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return parseHelper(json.Content);
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectPanel(i)
|
function selectPanel(i)
|
||||||
{
|
{
|
||||||
if (g_ActivePanel != -1)
|
if (g_ActivePanel != -1)
|
||||||
{
|
{
|
||||||
let oldPanelButton = Engine.GetGUIObjectByName(g_PanelNames[g_ActivePanel] + "PanelButton");
|
let oldPanelButton = Engine.GetGUIObjectByName("creditsPanelButton[" + g_ActivePanel+ "]");
|
||||||
oldPanelButton.sprite = "BackgroundBox";
|
oldPanelButton.sprite = "BackgroundBox";
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ActivePanel = i;
|
g_ActivePanel = i;
|
||||||
let newPanelButton = Engine.GetGUIObjectByName(g_PanelNames[g_ActivePanel] + "PanelButton");
|
Engine.GetGUIObjectByName("creditsPanelButton[" + i + "]").sprite = "ForegroundBox";
|
||||||
newPanelButton.sprite = "ForegroundBox";
|
Engine.GetGUIObjectByName("creditsText").caption = g_PanelTexts[g_PanelNames[i]];
|
||||||
|
|
||||||
let creditsText = Engine.GetGUIObjectByName("creditsText");
|
|
||||||
creditsText.caption = g_PanelTexts[i];
|
|
||||||
}
|
}
|
||||||
|
@ -8,59 +8,26 @@
|
|||||||
|
|
||||||
<objects>
|
<objects>
|
||||||
<script file="gui/common/functions_global_object.js"/>
|
<script file="gui/common/functions_global_object.js"/>
|
||||||
<script file="gui/credits/credits.js"/>
|
<script directory="gui/credits/"/>
|
||||||
|
|
||||||
<!-- Add a translucent black background to fade out the menu page -->
|
<!-- Add a translucent black background to fade out the menu page -->
|
||||||
<object type="image" z="0" sprite="ModernFade"/>
|
<object type="image" z="0" sprite="ModernFade"/>
|
||||||
|
|
||||||
<object type="image" style="ModernDialog" size="50%-473 24 50%+473 100%-24">
|
<object type="image" style="ModernDialog" size="50%-473 24 50%+473 100%-24">
|
||||||
<object style="ModernLabelText" type="text" size="50%-128 -18 50%+128 14">
|
<object style="ModernLabelText" name="dialogTitle" type="text" size="50%-128 -18 50%+128 14">
|
||||||
<translatableAttribute id="caption">0 A.D. Credits</translatableAttribute>
|
<translatableAttribute id="caption">0 A.D. Credits</translatableAttribute>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
<object name="specialPanelButton" type="button" sprite="BackgroundBox" size="20 50 150 80">
|
<object type="image" size="20 30 210 100%-54">
|
||||||
<action on="Press">selectPanel(0);</action>
|
<repeat count="20">
|
||||||
<object type="text" style="ModernLabelText" ghost="true">
|
<object name="creditsPanelButton[n]" type="button" sprite="BackgroundBox" size="0 0 190 30">
|
||||||
<translatableAttribute id="caption">Special Credits</translatableAttribute>
|
<object type="text" name="creditsPanelButtonText[n]" style="ModernLabelText" ghost="true">
|
||||||
</object>
|
</object>
|
||||||
|
</object>
|
||||||
|
</repeat>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
<object name="programmingPanelButton" type="button" sprite="BackgroundBox" size="155 50 305 80">
|
<object type="image" sprite="ModernFade" size="220 30 100%-20 100%-54">
|
||||||
<action on="Press">selectPanel(1);</action>
|
|
||||||
<object type="text" style="ModernLabelText" ghost="true">
|
|
||||||
<translatableAttribute id="caption">Programming</translatableAttribute>
|
|
||||||
</object>
|
|
||||||
</object>
|
|
||||||
|
|
||||||
<object name="artPanelButton" type="button" sprite="BackgroundBox" size="310 50 460 80">
|
|
||||||
<action on="Press">selectPanel(2);</action>
|
|
||||||
<object type="text" style="ModernLabelText" ghost="true">
|
|
||||||
<translatableAttribute id="caption">Art</translatableAttribute>
|
|
||||||
</object>
|
|
||||||
</object>
|
|
||||||
|
|
||||||
<object name="translatorsPanelButton" type="button" sprite="BackgroundBox" size="465 50 615 80">
|
|
||||||
<action on="Press">selectPanel(3);</action>
|
|
||||||
<object type="text" style="ModernLabelText" ghost="true">
|
|
||||||
<translatableAttribute id="caption">Translators</translatableAttribute>
|
|
||||||
</object>
|
|
||||||
</object>
|
|
||||||
|
|
||||||
<object name="miscPanelButton" type="button" sprite="BackgroundBox" size="620 50 770 80">
|
|
||||||
<action on="Press">selectPanel(4);</action>
|
|
||||||
<object type="text" style="ModernLabelText" ghost="true">
|
|
||||||
<translatableAttribute id="caption">Miscellaneous</translatableAttribute>
|
|
||||||
</object>
|
|
||||||
</object>
|
|
||||||
|
|
||||||
<object name="donatorsPanelButton" type="button" sprite="BackgroundBox" size="775 50 925 80">
|
|
||||||
<action on="Press">selectPanel(5);</action>
|
|
||||||
<object type="text" style="ModernLabelText" ghost="true">
|
|
||||||
<translatableAttribute id="caption">Donors</translatableAttribute>
|
|
||||||
</object>
|
|
||||||
</object>
|
|
||||||
|
|
||||||
<object type="image" sprite="ModernFade" size="20 85 100%-20 100%-54">
|
|
||||||
<object name="creditsText" type="text" style="textPanel"/>
|
<object name="creditsText" type="text" style="textPanel"/>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"Title": "Art",
|
||||||
"Content": [
|
"Content": [
|
||||||
{
|
{
|
||||||
"Title": "Artistic managers",
|
"Title": "Artistic managers",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"Title": "Donors",
|
||||||
"Content" : [
|
"Content" : [
|
||||||
{
|
{
|
||||||
"Title": "Pledgie Drive 1",
|
"Title": "Pledgie Drive 1",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"Title": "Miscellaneous",
|
||||||
"Content": [
|
"Content": [
|
||||||
{
|
{
|
||||||
"Title": "History References",
|
"Title": "History References",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"Title": "Programming",
|
||||||
"Content": [
|
"Content": [
|
||||||
{
|
{
|
||||||
"Title": "Programming managers",
|
"Title": "Programming managers",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"Title": "Special Credits",
|
||||||
"Content": [
|
"Content": [
|
||||||
{
|
{
|
||||||
"Title": "In Memoriam",
|
"Title": "In Memoriam",
|
||||||
|
@ -72,7 +72,7 @@ creditsFile.close()
|
|||||||
langsLists = {}
|
langsLists = {}
|
||||||
|
|
||||||
# Create the new JSON data
|
# Create the new JSON data
|
||||||
newJSONData = {'Content': []}
|
newJSONData = {'Title': 'Translators', 'Content': []}
|
||||||
|
|
||||||
# First get the already existing lists. If they correspond with some of the credited languages,
|
# First get the already existing lists. If they correspond with some of the credited languages,
|
||||||
# add them to the new data after processing, else add them immediately.
|
# add them to the new data after processing, else add them immediately.
|
||||||
|
Loading…
Reference in New Issue
Block a user