use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class BuildItemsDbForIcons method doIt.
private void doIt(HashMap<Integer, Item> items) {
for (Integer id : items.keySet()) {
Item item = items.get(id);
// Filter on essences: (set USE_UNIQUE_ICONS to false)
// String tulkas=item.getProperty(ItemPropertyNames.TULKAS_CATEGORY);
// String category=item.getSubCategory();
// if ((category==null) || (!category.contains("Essence"))) continue;
// Filter on some specific item ids:
// int idValue=id.intValue();
// if ((idValue==1879097298) || (idValue==1879109623)
// || (idValue==1879109618) || (idValue==1879083770) || (idValue==1879115686))
// {
String iconId = item.getProperty(ItemPropertyNames.ICON_ID);
_iconsIds.add(iconId);
String backgroundIconId = item.getProperty(ItemPropertyNames.BACKGROUND_ICON_ID);
_backgroundIconsIds.add(backgroundIconId);
String key = iconId + "-" + backgroundIconId;
// ImageIcon icon=IconsManager.getItemIcon(iconId,backgroundIconId);
// if (icon!=null) continue;
List<Integer> list = _iconIds2Ids.get(key);
if (list == null) {
list = new ArrayList<Integer>();
_iconIds2Ids.put(key, list);
}
list.add(id);
// }
}
buildDb(items);
System.out.println("#Icon/Background icon pairs: " + _iconIds2Ids.size());
System.out.println("#Icon IDs: " + _iconsIds.size());
System.out.println("#Background icon IDs: " + _backgroundIconsIds.size());
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class ItemPageParser method internalParseItemPage.
/**
* Parse the item page at the given URL.
* @param url URL of item page.
* @return An item or <code>null</code> if an error occurred.
*/
private List<Item> internalParseItemPage(String url) {
List<Item> items = null;
try {
DownloadService downloader = DownloadService.getInstance();
String page = downloader.getPage(url);
Source source = new Source(page);
// <div id="lorebookNoedit">
// Element lorebook=JerichoHtmlUtils.findElementByTagNameAndAttributeValue(source,HTMLElementName.DIV,"id","lorebookNoedit");
// if (lorebook!=null)
{
items = new ArrayList<Item>();
// Fetch identifier
List<Element> itemSections = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(source, HTMLElementName.TABLE, "class", "tooltip");
if ((itemSections != null) && (itemSections.size() > 0)) {
String key = fetchItemKey(source);
_key = key;
for (Element itemSection : itemSections) {
Item item = parseItemSection(itemSection);
if (item != null) {
items.add(item);
item.setKey(key);
}
}
findIdentifiers(items);
}
List<Element> resourceSections = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(source, HTMLElementName.DIV, "class", "lorebookresource");
if ((resourceSections != null) && (resourceSections.size() > 0)) {
String key = fetchItemKey(source);
_key = key;
for (Element resourceSection : resourceSections) {
Item item = parseResourceSection(resourceSection);
if (item != null) {
items.add(item);
item.setKey(key);
}
}
findIdentifiers(items);
}
}
} catch (Exception e) {
items = null;
_logger.error("Cannot parse item page [" + url + "]", e);
}
return items;
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class ItemPageParser method parseItemSection.
private Item parseItemSection(Element itemSection) {
Item ret = null;
try {
_item = null;
Element itemTooltip = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemSection, HTMLElementName.TABLE, "class", "tooltip");
if (itemTooltip != null) {
parseItemDescription(itemTooltip);
}
ret = _item;
} catch (Exception e) {
ret = null;
_logger.error("Item [" + _key + "]. Cannot parse item section!", e);
}
return ret;
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class ItemPageParser method parseResourceSection.
private Item parseResourceSection(Element resourceSection) {
Item ret = null;
try {
Element officialSection = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(resourceSection, HTMLElementName.DIV, "class", "officialsection");
if (officialSection != null) {
ret = new Item();
// Name
String name = null;
Element nameElement = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(officialSection, HTMLElementName.DIV, "class", "lorebooktitle");
if (nameElement != null) {
name = CharacterReference.decodeCollapseWhiteSpace(nameElement.getContent());
if (name != null) {
if (name.startsWith(RESOURCE_SEED)) {
name = name.substring(RESOURCE_SEED.length()).trim();
}
}
}
ret.setName(name);
// Description
List<Element> divs = JerichoHtmlUtils.findElementsByTagName(officialSection, HTMLElementName.DIV);
if ((divs != null) && (divs.size() >= 4)) {
Element div = divs.get(3);
String description = CharacterReference.decodeCollapseWhiteSpace(div.getContent());
ret.setDescription(description);
}
}
} catch (Exception e) {
ret = null;
_logger.error("Item [" + _key + "]. Cannot parse item section!", e);
}
return ret;
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class ItemsConcat method main.
/**
* Main method.
* @param args Not used.
*/
public static void main(String[] args) {
System.out.println("Concatenation of legacy items into one file...");
File itemsDir = new File("d:\\dam\\tmp\\items");
FileFilter fileFilter = new ExtensionPredicate("xml");
File[] itemFiles = itemsDir.listFiles(fileFilter);
if (itemFiles != null) {
// BonusConverter converter=new BonusConverter();
ItemXMLParser parser = new ItemXMLParser();
List<Item> itemsList = new ArrayList<Item>();
for (File itemFile : itemFiles) {
String idStr = itemFile.getName();
idStr = idStr.substring(0, idStr.length() - 4);
int id = NumericTools.parseInt(idStr, -1);
if (id != -1) {
// System.out.println(id);
Item item = parser.parseXML(itemFile);
/*
List<String> bonuses=item.getBonus();
if (bonuses.size()>0)
{
RawBonusParser bonusParser=new RawBonusParser();
BonusManager bonusMgr=bonusParser.build(bonuses);
if (bonusParser.hasWarn())
{
String name=item.getName();
System.out.println("Item: "+id+", name="+name);
for(String bonus : bonuses)
{
System.out.println("\t"+bonus);
}
}
if (bonusMgr!=null)
{
BasicStatsSet stats=converter.getStats(bonusMgr);
item.getStats().setStats(stats);
}
}
*/
item.setIdentifier(id);
itemsList.add(item);
}
}
File toFile = new File("itemsLegacy.xml").getAbsoluteFile();
ItemXMLWriter.writeItemsFile(toFile, itemsList);
}
}
Aggregations