use of gaiasky.util.LocationLogManager.LocationRecord in project gaiasky by langurmonkey.
the class LocationLogComponent method refresh.
/**
* Refreshes the locations list with the current data in the location log manager
*/
private void refresh() {
locations.clear();
LinkedList<LocationRecord> locations = LocationLogManager.instance().getLocations();
for (int i = locations.size() - 1; i >= 0; i--) {
LocationRecord lr = locations.get(i);
Table recordTable = new Table(skin);
// Create location
Label num = new OwnLabel(Integer.toString(locations.size() - i) + ":", skin, "default-blue");
num.setWidth(30f);
Label name = new OwnLabel(TextUtils.capString(lr.name, 14), skin, "default");
name.addListener(new OwnTextTooltip(lr.name, skin));
name.setWidth(165f);
Label time = new OwnLabel("(" + lr.elapsedString() + ")", skin, "default-pink");
time.addListener(new OwnTextTooltip(I18n.txt("gui.locationlog.visited", lr.entryTime), skin));
time.setWidth(40f);
OwnTextIconButton goToLoc = new OwnTextIconButton("", skin, "go-to");
goToLoc.addListener(new OwnTextTooltip(I18n.txt("gui.locationlog.goto.location", lr.entryTime), skin));
goToLoc.setSize(30f, 30f);
goToLoc.addListener((event) -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.CAMERA_MODE_CMD, goToLoc, CameraManager.CameraMode.FREE_MODE);
EventManager.publish(Event.CAMERA_POS_CMD, goToLoc, lr.position.valuesd());
EventManager.publish(Event.CAMERA_DIR_CMD, goToLoc, lr.direction.values());
EventManager.publish(Event.CAMERA_UP_CMD, goToLoc, lr.up.values());
EventManager.publish(Event.TIME_CHANGE_CMD, goToLoc, lr.simulationTime);
return true;
}
return false;
});
OwnTextIconButton goToObj = new OwnTextIconButton("", skin, "land-on");
goToObj.addListener(new OwnTextTooltip(I18n.txt("gui.locationlog.goto.object", lr.entryTime), skin));
goToObj.setSize(30f, 30f);
goToObj.addListener((event) -> {
if (event instanceof ChangeEvent) {
GaiaSky.postRunnable(() -> ((EventScriptingInterface) GaiaSky.instance.scripting()).setCameraFocusInstantAndGo(lr.name, false));
return true;
}
return false;
});
recordTable.add(num).left().padRight(pad8);
recordTable.add(name).left().padRight(pad8);
recordTable.add(time).left();
Table mainTable = new Table(skin);
mainTable.add(recordTable).left().padRight(pad12 * 1.5f);
mainTable.add(goToLoc).left().padRight(pad8);
mainTable.add(goToObj).left().padRight(pad8);
this.locations.addActor(mainTable);
}
if (locations.size() == 0) {
this.locations.addActor(new OwnLabel(I18n.txt("gui.locationlog.empty"), skin));
}
}
Aggregations