forked from 0ad/0ad
Ykkrosh
dd501b2a5a
Support direct access to serializer streams, so serializers can be nested. Make component script "this.template" read-only. Stop globally-subscribed component scripts receiving messages posted to local components, to reduce out-of-sync risks. Move pathfinder data out of entity template directory. Fix GuiInterface deserialization. This was SVN commit r8865.
44 lines
997 B
JavaScript
44 lines
997 B
JavaScript
var g_AIs; // [ {"id": ..., "data": {"name": ..., "description": ..., ...} }, ... ]
|
|
var g_Callback; // for the OK button
|
|
|
|
function init(settings)
|
|
{
|
|
g_Callback = settings.callback;
|
|
|
|
g_AIs = [
|
|
{id: "", data: {name: "None", description: "AI will be disabled for this player."}}
|
|
].concat(settings.ais);
|
|
|
|
var aiSelection = getGUIObjectByName("aiSelection");
|
|
aiSelection.list = [ ai.data.name for each (ai in g_AIs) ];
|
|
|
|
var selected = 0;
|
|
for (var i = 0; i < g_AIs.length; ++i)
|
|
{
|
|
if (g_AIs[i].id == settings.id)
|
|
{
|
|
selected = i;
|
|
break;
|
|
}
|
|
}
|
|
aiSelection.selected = selected;
|
|
}
|
|
|
|
function selectAI(idx)
|
|
{
|
|
var id = g_AIs[idx].id;
|
|
var name = g_AIs[idx].data.name;
|
|
var description = g_AIs[idx].data.description;
|
|
|
|
getGUIObjectByName("aiDescription").caption = description;
|
|
}
|
|
|
|
function returnAI()
|
|
{
|
|
var aiSelection = getGUIObjectByName("aiSelection");
|
|
var idx = aiSelection.selected;
|
|
var id = g_AIs[idx].id;
|
|
var name = g_AIs[idx].data.name;
|
|
g_Callback({"id": id, "name": name});
|
|
}
|