
de.lessvoid.nifty.examples.resolution.ResolutionScreen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nifty-examples Show documentation
Show all versions of nifty-examples Show documentation
Lots of Nifty example code! You can find the source for nearly all demos/tutorials in here.
package de.lessvoid.nifty.examples.resolution;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.NiftyEventSubscriber;
import de.lessvoid.nifty.controls.DropDown;
import de.lessvoid.nifty.controls.DropDownSelectionChangedEvent;
import de.lessvoid.nifty.controls.ListBox;
import de.lessvoid.nifty.examples.NiftyExample;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
/**
* @author void
*/
public class ResolutionScreen implements ScreenController, NiftyExample {
private Nifty nifty;
@Nullable
private DropDown dropDown;
private ResolutionControl resControl;
public ResolutionScreen(final ResolutionControl newControl) {
resControl = newControl;
}
@SuppressWarnings("unchecked")
@Override
public void bind(@Nonnull final Nifty newNifty, @Nonnull final Screen screen) {
this.nifty = newNifty;
this.dropDown = screen.findNiftyControl("resolutions", DropDown.class);
ListBox listBox = screen.findNiftyControl("listBox", ListBox.class);
fillResolutionDropDown(screen);
dropDown.selectItem(resControl.getCurrentResolution());
listBox.addItem("Test");
listBox.addItem("TestTestTestTestTestTestTestTestTestTestTestTest");
listBox.selectItem("Test");
}
@Override
public void onStartScreen() {
}
@Override
public void onEndScreen() {
}
@NiftyEventSubscriber(id = "resolutions")
public void onResolution(final String id, @Nonnull final DropDownSelectionChangedEvent event) {
resControl.setResolution(event.getSelection());
nifty.resolutionChanged();
}
private void fillResolutionDropDown(final Screen screen) {
final Collection resolutions = resControl.getResolutions();
for (T mode : resolutions) {
dropDown.addItem(mode);
}
}
@Nonnull
@Override
public String getStartScreen() {
return "start";
}
@Nonnull
@Override
public String getMainXML() {
return "resolution/resolution.xml";
}
@Nonnull
@Override
public String getTitle() {
return "Nifty Screen Resolution";
}
@Override
public void prepareStart(@Nonnull Nifty nifty) {
nifty.registerScreenController(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy