Jump to content


Photo

Proposed Change To Xml Schemas


  • Please log in to reply
7 replies to this topic

#1 dteviot

dteviot

    Programming Department

  • [Xenocide Senior Members]
  • 1,479 posts

Posted 25 October 2007 - 07:13 PM

Currently the item.xml is made up of entries like this
<item name="ITEM_XENIUM-122" xsi:type="troopItemType" score="0.1">
	<storage type="STORAGE_GEAR" units="1" />
	<price buy="0" sell="5000" />
	<size xSize="1" ySize="1" mass="3" equipable="false" />
	<throw percentage="0.25" />
</item>
Now, to get the name of the item to show to a user, we look up ITEM_XENIUM-122 in strings.resx and return the matching string. It has been pointed out to me that this means if someone wants to add a new item, they can't just add an entry to item.xml, they will also have to add a matching entry to strings.resx, and then recompile.
My preferred solution to this problem is to add a displayName attribute to the each entry thus:
<item name="ITEM_XENIUM-122" displayName="Xenium-122" xsi:type="troopItemType" score="0.1">
	<storage type="STORAGE_GEAR" units="1" />
	<price buy="0" sell="5000" />
	<size xSize="1" ySize="1" mass="3" equipable="false" />
	<throw percentage="0.25" />
</item>
Can anyone see any problem with doing this?
Note, similar changes should be made to xnet.xml, facility.xml and research.xml.
Saving the world from the scum of the universe is hard work. Especially when you have to create the scum to begin with.

#2 Guest_Azrael Strife_*

Guest_Azrael Strife_*
  • Guests

Posted 25 October 2007 - 08:36 PM

Out of curiosity, what would be the use of the name if we had a displayName part?

#3 Zombie

Zombie

    Colonel

  • Xenocide Creative-Text Departmen
  • 2,947 posts

Posted 25 October 2007 - 09:03 PM

Currently the item.xml is made up of entries like this

<item name="ITEM_XENIUM-122" xsi:type="troopItemType" score="0.1">
	<storage type="STORAGE_GEAR" units="1" />
	<price buy="0" sell="5000" />
	<size xSize="1" ySize="1" mass="3" equipable="false" />
	<throw percentage="0.25" />
</item>
Now, to get the name of the item to show to a user, we look up ITEM_XENIUM-122 in strings.resx and return the matching string. It has been pointed out to me that this means if someone wants to add a new item, they can't just add an entry to item.xml, they will also have to add a matching entry to strings.resx, and then recompile.
My preferred solution to this problem is to add a displayName attribute to the each entry thus:
<item name="ITEM_XENIUM-122" displayName="Xenium-122" xsi:type="troopItemType" score="0.1">
	<storage type="STORAGE_GEAR" units="1" />
	<price buy="0" sell="5000" />
	<size xSize="1" ySize="1" mass="3" equipable="false" />
	<throw percentage="0.25" />
</item>
Can anyone see any problem with doing this?
Note, similar changes should be made to xnet.xml, facility.xml and research.xml.

The way we are currently handling the displayed name of an item is exactly (or very similar to) how X-COM did it. Objects had an "internal" name in OBDATA.DAT which wasn't used anywhere. Thus, if you wanted to change the displayed name you had to edit ENGLISH.DAT (for the Geoscape portion) as well as ENGLISH2.DAT (the Battlescape portion). I don't really see a problem switching it so that the displayed name is defined in ITEM.XML as it would certainly save a few steps. I'd imagine we wouldn't need those string files anymore which would save some space too. :P

- Zombie

Edited by Zombie, 25 October 2007 - 09:13 PM.
Spelling

The Mr. Grognard of X-COM

Zombie: Empirical data's your only man, when formulating a research plan.
A soldier's death is never in vain if it makes the formula more plain.
A few dozen make a better case for refining that third decimal place.
They call me Zombie because I don't sleep, as I slowly struggle to climb this heap,
of corpses, data points, and trials, but from the top - I'll see for miles!


#4 dteviot

dteviot

    Programming Department

  • [Xenocide Senior Members]
  • 1,479 posts

Posted 25 October 2007 - 10:28 PM

Out of curiosity, what would be the use of the name if we had a displayName part?

It would be used when we need to show an item's name to a user. E.g. Buy/sell/transfer screens.
Saving the world from the scum of the universe is hard work. Especially when you have to create the scum to begin with.

#5 Guest_Azrael Strife_*

Guest_Azrael Strife_*
  • Guests

Posted 26 October 2007 - 06:46 AM

Out of curiosity, what would be the use of the name if we had a displayName part?

It would be used when we need to show an item's name to a user. E.g. Buy/sell/transfer screens.

Correct me if I'm wrong, but the displayName would be used, not the name.
name="ITEM_XENIUM-122" displayName="Xenium-122"

Edited by Azrael Strife, 26 October 2007 - 06:46 AM.


#6 red knight

red knight

    Xenocide Project Leader

  • Xenocide Inactive
  • 3,310 posts

Posted 26 October 2007 - 06:55 AM

The only thing that I can think of is that you are not doing localization... there are ways to handle that without resources though.

Greetings
Red Knight
Sourceforge Nick: flois - Federico Andres Lois
Visit my blog at: flois.blogspot.com

Posted Image

Pookie cover me, I am going in.

#7 geerzo

geerzo

    Sergeant

  • Xenocide Programming Department
  • 24 posts

Posted 26 October 2007 - 10:42 AM

<item name="ITEM_XENIUM-122" displayName="Xenium-122" xsi:type="troopItemType" score="0.1">
	<storage type="STORAGE_GEAR" units="1" />
	<price buy="0" sell="5000" />
	<size xSize="1" ySize="1" mass="3" equipable="false" />
	<throw percentage="0.25" />
</item>


I would propose a slight modification so it matched the code a little better.

<item id="ITEM_XENIUM-122" name="Xenium-122" xsi:type="troopItemType" score="0.1">
	<storage type="STORAGE_GEAR" units="1" />
	<price buy="0" sell="5000" />
	<size xSize="1" ySize="1" mass="3" equipable="false" />
	<throw percentage="0.25" />
</item>

Since the code holds the existing "name" attribute in a variable called "id" (in ResearchTopic at least) I just propose we change the XML to match. Then we can use "name" for the display name (or call it "displayName"). Having both "name" and "displayName" could be a bit confusing.

The only thing that I can think of is that you are not doing localization... there are ways to handle that without resources though.


This would require us to translate each XML file, however I think that may be the correct approach anyway. We already have to do it with the Xnet file.

Is there a reason why we don't store research topic descriptions or information in the research.xml to keep it centralized? To provide topic details on the research screen can we just link to the XNet information easily?

#8 StaffSargeant

StaffSargeant

    Sergeant

  • Xenocide Programming Department
  • 30 posts

Posted 26 October 2007 - 10:54 AM

I agree with Red Knight in regards to localization, by changing the schema in this way you add another file for localizers to know about and translate (and XML is fiddly if you are not used to it).

In regards to xnet, research and facility xml files, perhaps these should also be put into their own resource files?

Just my 0.02p