Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3220 closed enhancement (fixed)

[PATCH] Add an <include> tag in xml templates for inclusion of an external xml

Reported by: Karamel Owned by: sanderd17
Priority: Nice to Have Milestone: Alpha 19
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

While trying to include latin voices for Roman units I would like to avoid defining the same <Sound> element for each units.

It cannot be set with parent because it already sets the generic traits for every civ.

rome_support_female_citizen.xml could become

<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_unit_support_female_citizen">
  <Identity>
    <Civ>rome</Civ>
    <SpecificName>Romana</SpecificName>
    <GenericName>Roman Woman</GenericName>
    <Icon>units/rome_support_female_citizen.png</Icon>
	<SelectionGroupName>units/rome_support_female_citizen</SelectionGroupName>
    <History>Roman women in the Republic were in a similar state as their Greek counterparts. When a Roman woman married their dowry and property passed to their father-in-law, while she herself became the property of her husband. Their job was to raise the children and helping in farm work or running the family business. It was a sign of affluence when a man's wife did not have to work.</History>
  </Identity>
  <VisualActor>
    <Actor>units/romans/female_citizen.xml</Actor>
  </VisualActor>
  <include file="units/include_latin_female_sound.xml" />
</Entity>

include_latin_female_sound.xml would look like

<?xml version="1.0" encoding="utf-8"?>
<Sound>
  <SoundGroups>
    <select>voice/latin/civ_female_select.xml</select>
    <order_walk>voice/latin/civ_female_walk.xml</order_walk>
    <order_attack>voice/latin/civ_female_attack.xml</order_attack>
    <order_build>voice/latin/civ_female_build.xml</order_build>
    <order_gather>voice/latin/civ_female_gather_together.xml</order_gather>
    <order_repair>voice/latin/civ_female_repair.xml</order_repair>
    <order_garrison>voice/latin/civ_female_garrison.xml</order_garrison>
  </SoundGroups>
</Sound>

My current work would be altering Xeromyces::Load to generate an xmb with the included file. This requires Load to have an other parameter: document root, currently

VfsPath(TEMPLATE_ROOT)

in TemplateLoader

VfsPath path = VfsPath(TEMPLATE_ROOT) / wstring_from_utf8(templateName + ".xml");

Attachments (7)

male_hellenes_voices_xml.zip (2.8 KB ) - added by Karamel 9 years ago.
Edited hellene voices xml filenames
latin_voices_mono.zip (375.7 KB ) - added by Karamel 9 years ago.
Latin voices directory, xml and edited ogg
0001_lang_tags.patch (2.5 KB ) - added by Karamel 9 years ago.
{lang} and {gender} tag support patch
0002_voice_templates.patch (101.6 KB ) - added by Karamel 9 years ago.
Template patch to use {lang} and {gender} and include latin voices for Romans. Set hellenes voice to greek.
greek_voices_xml.zip (12.8 KB ) - added by Karamel 9 years ago.
Greek xml voices (was hellenes)
voice_replace.zip (832.5 KB ) - added by Karamel 9 years ago.
Latin/Greek voices, full directory
cart_healer_voice_fix.patch (1.2 KB ) - added by Karamel 9 years ago.
Fix for cart_support_healer_b.xml voice

Download all attachments as: .zip

Change History (22)

comment:1 by sanderd17, 9 years ago

I'm not really convinced about this. The included templates certainly shouldn't be placed in the units/ directory.

What about mimicking the stuff we do in the productionQueue? There we define which units can be produced based on a civ, and replace {civ} by the appropriate string.

In your case, you could add a "language" key to the identity component, and define the soundgroup as

<Sound>
  <SoundGroups>
    <select>voice/{lang}/civ_female_select.xml</select>
    <order_walk>voice/{lang}/civ_female_walk.xml</order_walk>
    <order_attack>voice/{lang}/civ_female_attack.xml</order_attack>
    <order_build>voice/{lang}/civ_female_build.xml</order_build>
    <order_gather>voice/{lang}/civ_female_gather_together.xml</order_gather>
    <order_repair>voice/{lang}/civ_female_repair.xml</order_repair>
    <order_garrison>voice/{lang}/civ_female_garrison.xml</order_garrison>
  </SoundGroups>
</Sound>

Then you can define the soundgroup per unit type, and for every individual unit, you just need to define what language he speaks. And use a generic language for default units.

Best would be to come on IRC and discuss it.

comment:2 by Karamel, 9 years ago

I'm now logged on #0ad-dev for discussions (I was only on #0ad).

I implemented the {lang} code and <Lang> tag in <Identity> and it seems to be working for it. Thus the code looks a bit ugly with the codes hard-defined and only applyable in <SoundGroups>, like for {civ}.

It has derived from <include>, but I'll add a <Gender> tag and abstract sound files to voices/{lang}/civ/civ_{gender}_"order".xml

Though it is not a generic solution as everything is hardcoded in 0 A.D. and not a Pyrogenesis feature.

comment:3 by Karamel, 9 years ago

Here are the patches for inclusion of latin voices in templates and use of {lang} and {gender} tags

0001_lang_tags.patch adds support for {lang} and {gender} tags in SoundGroups. It is an svn diff file. 0002_voice_templates.patch edits the actual templates to use them. It cannot be applyed directly as it requires the hellenes and latin voices to be in the same format. For this use the following commands

mv binaries/data/mods/public/audio/actor/human/death/death.xml binaries/data/mods/public/audio/actor/human/death/male_death.xml
mv binaries/data/mods/public/audio/voice/hellenes/civ/female/* binaries/data/mods/public/audio/voice/hellenes/civ/
rmdir binaries/data/mods/public/audio/voice/hellenes/civ/female
rm binaries/data/mods/public/audio/voice/hellenes/civ/civ_male_ack.xml

Then unzip male_hellenes_voices.xml.zip in binary/data/mods/public/audio/voice/hellenes and latin_voices_mono.zip in binary/data/mods/public/audio/voices. The latin audio files are resampled to be in mono for positional sound with OpenAL and moved in a civ directory. Then you can apply the 0002_voice_templates.patch

by Karamel, 9 years ago

Edited hellene voices xml filenames

by Karamel, 9 years ago

Attachment: latin_voices_mono.zip added

Latin voices directory, xml and edited ogg

by Karamel, 9 years ago

Attachment: 0001_lang_tags.patch added

{lang} and {gender} tag support patch

by Karamel, 9 years ago

Attachment: 0002_voice_templates.patch added

Template patch to use {lang} and {gender} and include latin voices for Romans. Set hellenes voice to greek.

by Karamel, 9 years ago

Attachment: greek_voices_xml.zip added

Greek xml voices (was hellenes)

comment:4 by Karamel, 9 years ago

I updated the patches with remarks from sanderd (just optimizations).

hellenes directory was renamed to greek and this language was set for Hellenes civilizations.

comment:5 by sanderd17, 9 years ago

Are you still working on this? Or do you consider it ready for review?

comment:6 by Karamel, 9 years ago

I think it's ready. I'm not working on it at that time but I'm open to any suggestion for inclusion. In fact I'm waiting for it or for inclusion :)

comment:7 by sanderd17, 9 years ago

Keywords: patch review added; Xeromyces Template XML removed
Milestone: BacklogAlpha 19
Summary: Add an <include> tag in xml templates for inclusion of an external xml[PATCH] Add an <include> tag in xml templates for inclusion of an external xml

In that case, it's best to add the needed tags, so it gets in the review queue (else we might forget about it). See SubmittingPatches

comment:8 by sanderd17, 9 years ago

I tried to apply your patch to test it. But it's not completely clear what to do with the voices zip. AFAIK, there are also files in the SVN directory that need to be moved or removed.

Could you provide a single drop-in replacement for the current voices directory? So we can just remove the current voices, and extract your zip there? Would make testing a lot easier.

by Karamel, 9 years ago

Attachment: voice_replace.zip added

Latin/Greek voices, full directory

comment:9 by Karamel, 9 years ago

You can then apply the 2 patches and replace the voices directory with the one provided.

Thanks for the review and sorry for the tags.

comment:10 by sanderd17, 9 years ago

Owner: set to sanderd17
Resolution: fixed
Status: newclosed

In 16681:

Add some structure to the voice files. Use the structure in the templates to enable parameters. Resample the voices to be mono/positional. Patch by karamel. Fixes #3220

comment:11 by sanderd17, 9 years ago

Keywords: review removed

I've applied your voices structure, and I'm very happy with the uniformisation of the paths and templates.

However, I think that currently the voices are too silent. Probably because of converting it to mono, the perceived gain is halved. I would like if you could work a bit further on the voices. But we couldn't leave this patch lingering along any longer, as it was already difficult to apply, and conflicts would only make it more difficult.

comment:12 by sanderd17, 9 years ago

In 16685:

Fix male death. Refs #3220

comment:13 by Karamel, 9 years ago

Keywords: review added
Resolution: fixed
Status: closedreopened

Carthaginian healer still have old voice path. It is the last unit to have reference to hellene voice in template. Patching it.

by Karamel, 9 years ago

Attachment: cart_healer_voice_fix.patch added

Fix for cart_support_healer_b.xml voice

comment:14 by sanderd17, 9 years ago

Resolution: fixed
Status: reopenedclosed

In 16725:

Fix Carthagian healer voices. Patch by karamel. Fixes #3220

comment:15 by sanderd17, 9 years ago

Keywords: review removed

Updated the template. Though next time, it's better to just tell us on IRC, or open a new ticket if you can't reach us.

Last edited 9 years ago by sanderd17 (previous) (diff)
Note: See TracTickets for help on using tickets.