[dteviot] Posted October 26, 2007 Report Share Posted October 26, 2007 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. Link to comment Share on other sites More sharing options...
Guest Azrael Strife Posted October 26, 2007 Report Share Posted October 26, 2007 Out of curiosity, what would be the use of the name if we had a displayName part? Link to comment Share on other sites More sharing options...
Zombie Posted October 26, 2007 Report Share Posted October 26, 2007 (edited) 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. - Zombie Edited October 26, 2007 by Zombie Spelling Link to comment Share on other sites More sharing options...
[dteviot] Posted October 26, 2007 Author Report Share Posted October 26, 2007 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. Link to comment Share on other sites More sharing options...
Guest Azrael Strife Posted October 26, 2007 Report Share Posted October 26, 2007 (edited) 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 October 26, 2007 by Azrael Strife Link to comment Share on other sites More sharing options...
red knight Posted October 26, 2007 Report Share Posted October 26, 2007 The only thing that I can think of is that you are not doing localization... there are ways to handle that without resources though. GreetingsRed Knight Link to comment Share on other sites More sharing options...
geerzo Posted October 26, 2007 Report Share Posted October 26, 2007 <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? Link to comment Share on other sites More sharing options...
StaffSargeant Posted October 26, 2007 Report Share Posted October 26, 2007 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 Link to comment Share on other sites More sharing options...
Recommended Posts