use of gaiasky.util.scene2d.OwnTextTooltip in project gaiasky by langurmonkey.
the class VisualEffectsComponent method initialize.
@SuppressWarnings("unchecked")
public void initialize() {
float contentWidth = ControlsWindow.getContentWidth();
/* Star brightness */
starBrightness = new OwnSliderPlus(I18n.txt("gui.starbrightness"), Constants.MIN_SLIDER, Constants.MAX_SLIDER, Constants.SLIDER_STEP_TINY, Constants.MIN_STAR_BRIGHTNESS, Constants.MAX_STAR_BRIGHTNESS, skin);
starBrightness.setName("star brightness");
starBrightness.setWidth(contentWidth);
starBrightness.setMappedValue(Settings.settings.scene.star.brightness);
starBrightness.addListener(event -> {
if (event instanceof ChangeEvent && hackProgrammaticChangeEvents) {
EventManager.publish(Event.STAR_BRIGHTNESS_CMD, starBrightness, starBrightness.getMappedValue());
return true;
}
return false;
});
/* Star brightness power */
starBrightnessPower = new OwnSliderPlus(I18n.txt("gui.starbrightness.pow"), Constants.MIN_STAR_BRIGHTNESS_POW, Constants.MAX_STAR_BRIGHTNESS_POW, Constants.SLIDER_STEP_TINY, skin);
starBrightnessPower.setName("star brightness power");
starBrightnessPower.setWidth(contentWidth);
starBrightnessPower.setMappedValue(Settings.settings.scene.star.power);
starBrightnessPower.addListener(event -> {
if (event instanceof ChangeEvent && hackProgrammaticChangeEvents) {
EventManager.publish(Event.STAR_BRIGHTNESS_POW_CMD, starBrightnessPower, starBrightnessPower.getValue());
return true;
}
return false;
});
/* Star size */
starSize = new OwnSliderPlus(I18n.txt("gui.star.size"), Constants.MIN_STAR_POINT_SIZE, Constants.MAX_STAR_POINT_SIZE, Constants.SLIDER_STEP_TINY, skin);
starSize.setName("star size");
starSize.setWidth(contentWidth);
starSize.setMappedValue(Settings.settings.scene.star.pointSize);
starSize.addListener(event -> {
if (flag && event instanceof ChangeEvent) {
EventManager.publish(Event.STAR_POINT_SIZE_CMD, starSize, starSize.getMappedValue());
return true;
}
return false;
});
/* Star min opacity */
starMinOpacity = new OwnSliderPlus(I18n.txt("gui.star.opacity"), Constants.MIN_STAR_MIN_OPACITY, Constants.MAX_STAR_MIN_OPACITY, Constants.SLIDER_STEP_TINY, skin);
starMinOpacity.setName("star min opacity");
starMinOpacity.setWidth(contentWidth);
starMinOpacity.setMappedValue(Settings.settings.scene.star.opacity[0]);
starMinOpacity.addListener(event -> {
if (event instanceof ChangeEvent && hackProgrammaticChangeEvents) {
EventManager.publish(Event.STAR_MIN_OPACITY_CMD, starMinOpacity, starMinOpacity.getMappedValue());
return true;
}
return false;
});
/* Ambient light */
ambientLight = new OwnSliderPlus(I18n.txt("gui.light.ambient"), Constants.MIN_AMBIENT_LIGHT, Constants.MAX_AMBIENT_LIGHT, Constants.SLIDER_STEP_TINY, skin);
ambientLight.setName("ambient light");
ambientLight.setWidth(contentWidth);
ambientLight.setMappedValue(Settings.settings.scene.renderer.ambient);
ambientLight.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.AMBIENT_LIGHT_CMD, ambientLight, ambientLight.getMappedValue());
return true;
}
return false;
});
/* Label size */
labelSize = new OwnSliderPlus(I18n.txt("gui.label.size"), Constants.MIN_LABEL_SIZE, Constants.MAX_LABEL_SIZE, Constants.SLIDER_STEP_TINY, skin);
labelSize.setName("label size");
labelSize.setWidth(contentWidth);
labelSize.setMappedValue(Settings.settings.scene.label.size);
labelSize.addListener(event -> {
if (event instanceof ChangeEvent && hackProgrammaticChangeEvents) {
float val = labelSize.getMappedValue();
EventManager.publish(Event.LABEL_SIZE_CMD, labelSize, val);
return true;
}
return false;
});
/* Line width */
lineWidth = new OwnSliderPlus(I18n.txt("gui.line.width"), Constants.MIN_LINE_WIDTH, Constants.MAX_LINE_WIDTH, Constants.SLIDER_STEP_TINY, Constants.MIN_LINE_WIDTH, Constants.MAX_LINE_WIDTH, skin);
lineWidth.setName("line width");
lineWidth.setWidth(contentWidth);
lineWidth.setMappedValue(Settings.settings.scene.lineWidth);
lineWidth.addListener(event -> {
if (event instanceof ChangeEvent && hackProgrammaticChangeEvents) {
float val = lineWidth.getMappedValue();
EventManager.publish(Event.LINE_WIDTH_CMD, lineWidth, val);
return true;
}
return false;
});
/* Elevation multiplier */
elevMult = new OwnSliderPlus(I18n.txt("gui.elevation.multiplier"), Constants.MIN_ELEVATION_MULT, Constants.MAX_ELEVATION_MULT, 0.1f, false, skin);
elevMult.setName("elevation mult");
elevMult.setWidth(contentWidth);
elevMult.setValue((float) MathUtilsd.roundAvoid(Settings.settings.scene.renderer.elevation.multiplier, 1));
elevMult.addListener(event -> {
if (event instanceof ChangeEvent) {
float val = elevMult.getValue();
EventManager.publish(Event.ELEVATION_MULTIPLIER_CMD, elevMult, val);
return true;
}
return false;
});
/* Reset defaults */
OwnTextIconButton resetDefaults = new OwnTextIconButton(I18n.txt("gui.resetdefaults"), skin, "reset");
resetDefaults.align(Align.center);
resetDefaults.setWidth(contentWidth);
resetDefaults.addListener(new OwnTextTooltip(I18n.txt("gui.resetdefaults.tooltip"), skin));
resetDefaults.addListener(event -> {
if (event instanceof ChangeEvent) {
// Read defaults from internal settings file
try {
Path confFolder = Settings.settings.assetsPath("conf");
Path internalFolderConfFile = confFolder.resolve(SettingsManager.getConfigFileName(Settings.settings.runtime.openVr));
Yaml yaml = new Yaml();
Map<Object, Object> conf = yaml.load(Files.newInputStream(internalFolderConfFile));
float br = ((Double) ((Map<String, Object>) ((Map<String, Object>) conf.get("scene")).get("star")).get("brightness")).floatValue();
float pow = ((Double) ((Map<String, Object>) ((Map<String, Object>) conf.get("scene")).get("star")).get("power")).floatValue();
float ss = ((Double) ((Map<String, Object>) ((Map<String, Object>) conf.get("scene")).get("star")).get("pointSize")).floatValue();
float pam = (((java.util.List<Double>) ((Map<String, Object>) ((Map<String, Object>) conf.get("scene")).get("star")).get("opacity")).get(0)).floatValue();
float amb = ((Double) ((Map<String, Object>) ((Map<String, Object>) conf.get("scene")).get("renderer")).get("ambient")).floatValue();
float ls = ((Double) ((Map<String, Object>) ((Map<String, Object>) conf.get("scene")).get("label")).get("size")).floatValue();
float lw = ((Double) ((Map<String, Object>) conf.get("scene")).get("lineWidth")).floatValue();
float em = ((Double) ((Map<String, Object>) ((Map<String, Object>) ((Map<Object, Object>) conf.get("scene")).get("renderer")).get("elevation")).get("multiplier")).floatValue();
// Events
EventManager m = EventManager.instance;
m.post(Event.STAR_BRIGHTNESS_CMD, resetDefaults, br);
m.post(Event.STAR_BRIGHTNESS_POW_CMD, resetDefaults, pow);
m.post(Event.STAR_POINT_SIZE_CMD, resetDefaults, ss);
m.post(Event.STAR_MIN_OPACITY_CMD, resetDefaults, pam);
m.post(Event.AMBIENT_LIGHT_CMD, resetDefaults, amb);
m.post(Event.LABEL_SIZE_CMD, resetDefaults, ls);
m.post(Event.LINE_WIDTH_CMD, resetDefaults, lw);
m.post(Event.ELEVATION_MULTIPLIER_CMD, resetDefaults, em);
} catch (IOException e) {
logger.error(e, "Error loading default configuration file");
}
return true;
}
return false;
});
/* Add to group */
VerticalGroup lightingGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left);
lightingGroup.space(pad9);
lightingGroup.addActor(starBrightness);
lightingGroup.addActor(starBrightnessPower);
lightingGroup.addActor(starSize);
lightingGroup.addActor(starMinOpacity);
lightingGroup.addActor(ambientLight);
lightingGroup.addActor(lineWidth);
lightingGroup.addActor(labelSize);
lightingGroup.addActor(elevMult);
lightingGroup.addActor(resetDefaults);
component = lightingGroup;
EventManager.instance.subscribe(this, Event.STAR_POINT_SIZE_CMD, Event.STAR_BRIGHTNESS_CMD, Event.STAR_BRIGHTNESS_POW_CMD, Event.STAR_MIN_OPACITY_CMD, Event.LABEL_SIZE_CMD, Event.LINE_WIDTH_CMD);
}
use of gaiasky.util.scene2d.OwnTextTooltip in project gaiasky by langurmonkey.
the class DesktopMusicActors method getActors.
@Override
public Actor[] getActors(Skin skin) {
ImageButton musicTooltip = new OwnImageButton(skin, "tooltip");
musicTooltip.addListener(new OwnTextTooltip(I18n.txt("gui.tooltip.music", SysUtils.getDefaultMusicDir()), skin));
ImageButton reloadMusic = new OwnImageButton(skin, "reload");
reloadMusic.setName("reload music");
reloadMusic.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.MUSIC_RELOAD_CMD, this);
return true;
}
return false;
});
reloadMusic.addListener(new OwnTextTooltip(I18n.txt("gui.music.reload"), skin));
return new Actor[] { musicTooltip, reloadMusic };
}
use of gaiasky.util.scene2d.OwnTextTooltip in project gaiasky by langurmonkey.
the class ExternalInformationUpdater method update.
public void update(final IFocus focus) {
GaiaSky.postRunnable(() -> {
if (focus != null) {
logger.debug("Looking up network resources for '" + focus.getName() + "'");
infoCell = table.add().left();
gaiaCell = table.add().left();
simbadCell = table.add().left();
// Add table
if (focus instanceof IStarFocus) {
EventManager.publish(Event.UPDATE_ARCHIVE_VIEW_ACTION, this, focus);
if (gaiaButton != null)
gaiaButton.remove();
gaiaButton = new OwnTextButton(I18n.txt("gui.focusinfo.archive"), skin);
gaiaButton.pad(pad / 3f, pad, pad / 3f, pad);
gaiaButton.addListener(new GaiaButtonListener((IStarFocus) focus));
gaiaButton.addListener(new OwnTextTooltip(I18n.txt("gui.tooltip.gaiaarchive"), skin));
gaiaCell.setActor(gaiaButton).padRight(pad);
} else {
gaiaCell.padRight(0);
}
String wikiname = focus.getName().replace(' ', '_');
setWikiLink(wikiname, focus, new LinkListener() {
@Override
public void ok(String link) {
if (infoCell != null) {
try {
String actualWikiname = link.substring(Constants.URL_WIKIPEDIA.length());
EventManager.publish(Event.UPDATE_WIKI_INFO_ACTION, this, actualWikiname);
if (infoButton != null)
infoButton.remove();
infoButton = new OwnTextButton(I18n.txt("gui.focusinfo.moreinfo"), skin);
infoButton.addListener(new OwnTextTooltip(I18n.txt("gui.tooltip.wiki"), skin));
infoButton.pad(pad / 3f, pad, pad / 3f, pad);
infoButton.addListener((event) -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.SHOW_WIKI_INFO_ACTION, this, actualWikiname);
return true;
}
return false;
});
infoCell.setActor(infoButton).padRight(pad);
} catch (Exception ignored) {
}
}
}
@Override
public void ko(String link) {
if (infoCell != null)
infoCell.padRight(0);
}
});
setSimbadLink(focus, new LinkListener() {
@Override
public void ok(String link) {
if (simbadCell != null) {
try {
if (simbadLink != null) {
simbadLink.remove();
}
simbadLink = new Link(I18n.txt("gui.focusinfo.simbad"), linkStyle, "");
simbadLink.addListener(new OwnTextTooltip(I18n.txt("gui.tooltip.simbad"), skin));
simbadLink.setLinkURL(link);
simbadCell.setActor(simbadLink);
} catch (Exception ignored) {
}
}
}
@Override
public void ko(String link) {
}
});
}
});
}
use of gaiasky.util.scene2d.OwnTextTooltip 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));
}
}
use of gaiasky.util.scene2d.OwnTextTooltip in project gaiasky by langurmonkey.
the class MusicComponent method initialize.
@Override
public void initialize() {
float componentWidth = 264f;
nf = NumberFormatFactory.getFormatter("##0");
intf = NumberFormatFactory.getFormatter("#00");
/* Previous track */
prev = new OwnImageButton(skin, "audio-bwd");
prev.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.MUSIC_PREVIOUS_CMD, prev);
return true;
}
return false;
});
prev.addListener(new OwnTextTooltip(I18n.txt("gui.music.previous"), skin));
/* Play/pause */
play = new OwnImageButton(skin, "audio-playpause");
play.setChecked(false);
play.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.MUSIC_PLAYPAUSE_CMD, play);
return true;
}
return false;
});
play.addListener(new OwnTextTooltip(I18n.txt("gui.music.playpause"), skin));
/* Next track */
next = new OwnImageButton(skin, "audio-fwd");
next.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.MUSIC_NEXT_CMD, next);
return true;
}
return false;
});
next.addListener(new OwnTextTooltip(I18n.txt("gui.music.next"), skin));
/* Volume */
vol = new OwnLabel(I18n.txt("gui.music.volume.short") + ": " + nf.format(getVolumePercentage()) + "%", skin, "mono-pink");
vol.addListener(new OwnTextTooltip(I18n.txt("gui.music.volume"), skin));
vol.receiveScrollEvents();
vol.addListener(event -> {
if (event instanceof InputEvent) {
InputEvent ie = (InputEvent) event;
if (ie.getType().equals(InputEvent.Type.scrolled)) {
float scroll = -ie.getScrollAmountY() * 0.1f;
float currentVol = getVolume();
float newVol = Math.max(0f, Math.min(1f, currentVol + scroll));
EventManager.publish(Event.MUSIC_VOLUME_CMD, vol, newVol);
vol.setText(I18n.txt("gui.music.volume.short") + ": " + nf.format(getVolumePercentage()) + "%");
return true;
}
}
return false;
});
/* Position mm:ss */
position = new OwnLabel(toMinutesSeconds(0f), skin, "mono");
/* Track name */
track = new OwnLabel("", skin, "mono");
float space3 = 4.8f;
VerticalGroup musicGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left).space(space3);
HorizontalGroup playGroup = new HorizontalGroup();
playGroup.setWidth(componentWidth);
playGroup.space(18f);
prev.align(Align.left);
play.align(Align.left);
next.align(Align.left);
playGroup.addActor(prev);
playGroup.addActor(play);
playGroup.addActor(next);
playGroup.addActor(vol);
HorizontalGroup trackGroup = new HorizontalGroup();
trackGroup.space(16f);
trackGroup.addActor(position);
trackGroup.addActor(track);
musicGroup.addActor(playGroup);
musicGroup.addActor(trackGroup);
component = musicGroup;
Task musicUpdater = new Task() {
@Override
public void run() {
position.setText(toMinutesSeconds(MusicManager.instance.getPosition()));
slideTrackName();
}
};
Timer.schedule(musicUpdater, 1, 1);
}
Aggregations