Skip to content

Commit

Permalink
Initial version of the mod
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderOlkhovskiy committed Sep 24, 2017
1 parent 1f16cf9 commit 2c83b69
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
@@ -0,0 +1,5 @@
### 0 A.D. Civ Choices Mod

Adds the civ choices dialog allowing to select one of mutually exclusive technologies at the start of the match.

Example technologies are included for Athenians: either Hoplite or Slinger Militia are unlocked in CC via the civ choices dialog.
26 changes: 26 additions & 0 deletions gui/session/civ_choices.js
@@ -0,0 +1,26 @@
function initCivChoicesDialog()
{
let currentPlayer = g_Players[Engine.GetPlayerID()];
let civChoices = g_CivData[currentPlayer.civ].CivChoices;
if (civChoices)
{
for (let i = 0; i < civChoices.length; ++i)
{
let civChoiceButton = Engine.GetGUIObjectByName("civChoice[" + i + "]");
civChoiceButton.caption = GetTechnologyData(civChoices[i]).name.generic;

let size = civChoiceButton.size;
size.top = 20 * i;
size.bottom = 20 * (i + 1);
civChoiceButton.size = size;

civChoiceButton.onPress = (function(tech) { return function() {
Engine.PostNetworkCommand({ "type": "civ-choice", "template": tech });
Engine.GetGUIObjectByName("civChoicesDialogPanel").hidden = true;
}})(civChoices[i]);

civChoiceButton.hidden = false;
}
Engine.GetGUIObjectByName("civChoicesDialogPanel").hidden = false;
}
}
18 changes: 18 additions & 0 deletions gui/session/dialogs/civ_choices_window.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>

<object name="civChoicesDialogPanel"
size="50%-280 50%-200 50%+280 50%+150"
type="image"
hidden="true"
sprite="ModernDialog"
>
<object type="text" style="TitleText" size="50%-96 -16 50%+96 16">
<translatableAttribute id="caption">Civ choices</translatableAttribute>
</object>

<object size="32 64 100%-32 100%-64">
<repeat count="4" var="n">
<object name="civChoice[n]" size="0 0 100% 20" type="button" style="StoneButton" hidden="true"/>
</repeat>
</object>
</object>
2 changes: 2 additions & 0 deletions gui/session/session.js
Expand Up @@ -339,6 +339,8 @@ function init(initData, hotloadData)
onSimulationUpdate();
setTimeout(displayGamestateNotifications, 1000);

initCivChoicesDialog();

// Report the performance after 5 seconds (when we're still near
// the initial camera view) and a minute (when the profiler will
// have settled down if framerates as very low), to give some
Expand Down
8 changes: 8 additions & 0 deletions mod.json
@@ -0,0 +1,8 @@
{
"name": "Civ choices",
"version": "0.0.22",
"label": "Civ choices",
"description": "Adds the civ choices dialog allowing to select one of mutually exclusive technologies at the start of the match.",
"dependencies": ["0ad=0.0.22"],
"type": "Feature"
}
5 changes: 5 additions & 0 deletions simulation/data/civs/athen.json
Expand Up @@ -72,6 +72,11 @@
"Description":"Constructing a Theatron increases the territory expanse of all buildings by +20%."
}
],
"CivChoices":
[
"civ_choices/athen/hoplites",
"civ_choices/athen/militia"
],
"TeamBonuses":
[
{
Expand Down
3 changes: 3 additions & 0 deletions simulation/data/technologies/civ_choices/athen/hoplites.json
@@ -0,0 +1,3 @@
{
"genericName": "Hoplites"
}
3 changes: 3 additions & 0 deletions simulation/data/technologies/civ_choices/athen/militia.json
@@ -0,0 +1,3 @@
{
"genericName": "Militia"
}
5 changes: 5 additions & 0 deletions simulation/helpers/CommandsCivChoice.js
@@ -0,0 +1,5 @@
g_Commands["civ-choice"] = function(player, cmd, data)
{
var cmpTechnologyManager = QueryPlayerIDInterface(player, IID_TechnologyManager);
cmpTechnologyManager.ResearchTechnology(cmd.template);
};
1 change: 1 addition & 0 deletions simulation/templates/units/athen_infantry_slinger_b.xml
Expand Up @@ -16,6 +16,7 @@
<GenericName>Athenian Slinger Militia</GenericName>
<SpecificName>Psilòs Athēnaîos</SpecificName>
<Icon>units/athen_infantry_slinger.png</Icon>
<RequiredTechnology>civ_choices/athen/militia</RequiredTechnology>
</Identity>
<Promotion>
<Entity>units/athen_infantry_slinger_a</Entity>
Expand Down
1 change: 1 addition & 0 deletions simulation/templates/units/athen_infantry_spearman_b.xml
Expand Up @@ -22,6 +22,7 @@
<SpecificName>Hoplítēs Athēnaîos</SpecificName>
<History>Hoplites were the very symbol of Hellenic prestige and citizenship, armed with a spear and a large round bronze-coated shield known as an aspis. Armor was heavy, with bronze helmets and a cuirass of either bronze or linen, in addition to greaves. Hoplites fought in a tight formation called a phalanx, guarding each other with their shields while they attacked the enemy with their 2.5 meter spear or short iron sword.</History>
<Icon>units/athen_infantry_spearman.png</Icon>
<RequiredTechnology>civ_choices/athen/hoplites</RequiredTechnology>
</Identity>
<Promotion>
<Entity>units/athen_infantry_spearman_a</Entity>
Expand Down

0 comments on commit 2c83b69

Please sign in to comment.