Skip to content

Commit

Permalink
Added item id to item mapping screen, filled item properties panel
Browse files Browse the repository at this point in the history
Enabled JAXB plugind (toString, hashcode, etc.)
Added custom toString strategy for JAXB classes
Added switch for dumping ItemCategory tree in toString
  • Loading branch information
starcatter committed Mar 22, 2019
1 parent b83e77d commit 85627cd
Show file tree
Hide file tree
Showing 6 changed files with 356 additions and 262 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* The MIT License
*
* Copyright 2017 the_bob.
Expand All @@ -23,18 +23,21 @@
*/
package thebob.assetmanager.managers.items.categories;

import thebob.assetmanager.managers.items.Item;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import thebob.assetmanager.managers.items.Item;

/**
*
* @author the_bob
*/
public class ItemCategory {

public static boolean dumpTreeInToString = false;

public static class SubCategoryItemIterator implements Iterator<Item> {

Iterator<ItemCategory> category;
Expand Down Expand Up @@ -155,39 +158,43 @@ public Iterator<Item> subCategoryItemIterator() {
}

public String toString() {
StringBuilder sb = new StringBuilder();
if (subCategoryCount() + totalItemCount() > 0) {
sb.append('\n');
for (int i = 0; i < depth; i++) {
sb.append('\t');
}
sb.append('[');
sb.append(name);
sb.append(']');
if (totalItemCount() > 0) {
sb.append(", ");
sb.append(totalItemCount());
sb.append(" items: ");

for (Iterator<Item> iterator = items.iterator(); iterator.hasNext();) {
sb.append('\n');
for (int i = 0; i < depth + 1; i++) {
sb.append('\t');
}
sb.append(iterator.next().getName());
}
}
if (subCategoryCount() > 0) {
sb.append(", ");
sb.append(subCategoryCount());
sb.append(" sub categories: ");
for (Iterator<ItemCategory> iterator = children.iterator(); iterator.hasNext();) {
ItemCategory next = iterator.next();
sb.append(next);
}
}
}
return sb.toString();
if(dumpTreeInToString){
StringBuilder sb = new StringBuilder();
if (subCategoryCount() + totalItemCount() > 0) {
sb.append('\n');
for (int i = 0; i < depth; i++) {
sb.append('\t');
}
sb.append('[');
sb.append(name);
sb.append(']');
if (totalItemCount() > 0) {
sb.append(", ");
sb.append(totalItemCount());
sb.append(" items: ");

for (Iterator<Item> iterator = items.iterator(); iterator.hasNext(); ) {
sb.append('\n');
for (int i = 0; i < depth + 1; i++) {
sb.append('\t');
}
sb.append(iterator.next().getName());
}
}
if (subCategoryCount() > 0) {
sb.append(", ");
sb.append(subCategoryCount());
sb.append(" sub categories: ");
for (Iterator<ItemCategory> iterator = children.iterator(); iterator.hasNext(); ) {
ItemCategory next = iterator.next();
sb.append(next);
}
}
}
return sb.toString();
} else {
return name;
}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions ja2MapTool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>


<!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* The MIT License
*
* Copyright 2017 starcatter.
Expand All @@ -23,25 +23,29 @@
*/
package thebob.ja2maptool.components;

import javafx.scene.control.Label;
import javafx.scene.control.TreeItem;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import thebob.assetmanager.managers.items.Item;

/**
*
* @author the_bob
*/
public class ItemMappingTreeItem extends TreeItem<String> {

Item item;

public ItemMappingTreeItem(Item item) {
super(item.getName(), new ImageView(item.getImage()));
this.item = item;
super(item.getName(), new VBox(
new ImageView(item.getImage()), new Label(String.valueOf(item.getId())))
);
this.item = item;
}

public Item getItem() {
return item;
return item;
}

}
Loading

0 comments on commit 85627cd

Please sign in to comment.