mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-20 19:49:47 +07:00
Improved set items impl (see #21)
This commit is contained in:
parent
cdfc592a7d
commit
2567b4cf4f
@ -1,8 +1,24 @@
|
||||
package com.riiablo.codec.excel;
|
||||
|
||||
import com.riiablo.codec.excel.Excel;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
|
||||
public class SetItems extends Excel<SetItems.Entry> {
|
||||
private final ObjectMap<String, Array<SetItems.Entry>> sets = new ObjectMap<>();
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
for (SetItems.Entry item : this) {
|
||||
Array<SetItems.Entry> items = sets.get(item.set);
|
||||
if (items == null) sets.put(item.set, items = new Array<>(6));
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public Array<SetItems.Entry> getItems(SetItems.Entry item) {
|
||||
return sets.get(item.set);
|
||||
}
|
||||
|
||||
public static class Entry extends Excel.Entry {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -846,24 +846,10 @@ public class Item extends Actor implements Disposable {
|
||||
// TODO: This can be cleaned up later -- add support for set detection
|
||||
if (quality == SET) {
|
||||
add().height(font.getLineHeight()).space(SPACING).row();
|
||||
|
||||
final SetItems.Entry set = Riiablo.files.SetItems.get(qualityId);
|
||||
add(new Label(Riiablo.string.lookup(set.set), font, Riiablo.colors.gold)).space(SPACING).row();
|
||||
|
||||
int id = qualityId;
|
||||
for (;;) {
|
||||
if (id - 1 >= 0 && set.set.equalsIgnoreCase(Riiablo.files.SetItems.get(id - 1).set)) {
|
||||
id--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (id >= Riiablo.files.SetItems.size()) break;
|
||||
SetItems.Entry setSibling = Riiablo.files.SetItems.get(id++);
|
||||
if (!set.set.equalsIgnoreCase(setSibling.set)) break;
|
||||
add(new Label(Riiablo.string.lookup(setSibling.index), font, Riiablo.colors.red)).space(SPACING).row();
|
||||
for (SetItems.Entry item : Riiablo.files.SetItems.getItems(set)) {
|
||||
add(new Label(Riiablo.string.lookup(item.index), font, Riiablo.colors.red)).space(SPACING).row();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user