loottracker: Lazily rebuild panels
This commit is contained in:
@@ -162,6 +162,10 @@ class LootTrackerBox extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
records.add(record);
|
records.add(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rebuild()
|
||||||
|
{
|
||||||
buildItems();
|
buildItems();
|
||||||
|
|
||||||
priceLabel.setText(StackFormatter.quantityToStackSize(totalPrice) + " gp");
|
priceLabel.setText(StackFormatter.quantityToStackSize(totalPrice) + " gp");
|
||||||
|
|||||||
@@ -325,7 +325,12 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
final String subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : "";
|
final String subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : "";
|
||||||
final LootTrackerRecord record = new LootTrackerRecord(eventName, subTitle, items, System.currentTimeMillis());
|
final LootTrackerRecord record = new LootTrackerRecord(eventName, subTitle, items, System.currentTimeMillis());
|
||||||
records.add(record);
|
records.add(record);
|
||||||
buildBox(record);
|
LootTrackerBox box = buildBox(record);
|
||||||
|
if (box != null)
|
||||||
|
{
|
||||||
|
box.rebuild();
|
||||||
|
updateOverall();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -381,6 +386,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
logsContainer.removeAll();
|
logsContainer.removeAll();
|
||||||
boxes.clear();
|
boxes.clear();
|
||||||
records.forEach(this::buildBox);
|
records.forEach(this::buildBox);
|
||||||
|
boxes.forEach(LootTrackerBox::rebuild);
|
||||||
updateOverall();
|
updateOverall();
|
||||||
logsContainer.revalidate();
|
logsContainer.revalidate();
|
||||||
logsContainer.repaint();
|
logsContainer.repaint();
|
||||||
@@ -391,12 +397,12 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
* add its items to it, updating the log's overall price and kills. If not, a new log will be created
|
* add its items to it, updating the log's overall price and kills. If not, a new log will be created
|
||||||
* to hold this entry's information.
|
* to hold this entry's information.
|
||||||
*/
|
*/
|
||||||
private void buildBox(LootTrackerRecord record)
|
private LootTrackerBox buildBox(LootTrackerRecord record)
|
||||||
{
|
{
|
||||||
// If this record is not part of current view, return
|
// If this record is not part of current view, return
|
||||||
if (!record.matches(currentView))
|
if (!record.matches(currentView))
|
||||||
{
|
{
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group all similar loot together
|
// Group all similar loot together
|
||||||
@@ -407,8 +413,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
if (box.matches(record))
|
if (box.matches(record))
|
||||||
{
|
{
|
||||||
box.combine(record);
|
box.combine(record);
|
||||||
updateOverall();
|
return box;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,8 +461,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
boxes.add(box);
|
boxes.add(box);
|
||||||
logsContainer.add(box, 0);
|
logsContainer.add(box, 0);
|
||||||
|
|
||||||
// Update overall
|
return box;
|
||||||
updateOverall();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOverall()
|
private void updateOverall()
|
||||||
|
|||||||
Reference in New Issue
Block a user