com.blastedstudios.gdxworld.plugin.mode.live.LiveWindow Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of GDXWorld Show documentation
Show all versions of GDXWorld Show documentation
Uploads all artifacts belonging to configuration ':archives'
The newest version!
package com.blastedstudios.gdxworld.plugin.mode.live;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.blastedstudios.gdxworld.ui.AbstractWindow;
import com.blastedstudios.gdxworld.util.PluginUtil;
class LiveWindow extends AbstractWindow {
private final HashMap tableMap = new HashMap<>();
private final Table table;
public LiveWindow(final Skin skin) {
super("Live Options", skin);
table = new Table(skin);
Collection providers = PluginUtil.getPlugins(ILiveOptionProvider.class);
for(ILiveOptionProvider provider : providers)
tableMap.put(provider, provider.getTable(skin, this));
final SelectBox liveOptionsSelectbox = new SelectBox<>(skin);
liveOptionsSelectbox.setItems(LiveOptionSelectboxStruct.create(new ArrayList<>(providers)));
liveOptionsSelectbox.addListener(new ChangeListener() {
@Override public void changed(ChangeEvent event, Actor actor) {
update(skin, tableMap.get(liveOptionsSelectbox.getSelected().object));
}
});
add(liveOptionsSelectbox);
row();
add(table);
setMovable(false);
if(!providers.isEmpty())
update(skin, tableMap.get(liveOptionsSelectbox.getSelected().object));
}
private void update(Skin skin, Table optionTable){
table.clear();
table.add(optionTable);
pack();
setPosition(0f, 0f);
}
}