com.badlogic.gdx.scenes.scene2d.ui.SelectBox Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.SelectBox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SelectBoxWidget.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
public Actor getSubWidget() {
    selectBox = new SelectBox<>(TalosMain.Instance().UIStage().getSkin(), "propertyValue");
    noValueLabel = new Label("", TalosMain.Instance().UIStage().getSkin());
    noValueLabel.setAlignment(Align.right);
    stack = new Stack();
    stack.add(noValueLabel);
    stack.add(selectBox);

    noValueLabel.setVisible(false);

    listener = new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            String newValue = selectBox.getSelected();
            valueChanged(newValue);
        }
    };
    selectBox.addListener(listener);

    return stack;
}
 
Example #2
Source File: MainListener.java    From skin-composer with MIT License 6 votes vote down vote up
@Override
public void stylePropertyChanged(StyleProperty styleProperty,
        Actor styleActor) {
    if (styleProperty.type == Drawable.class) {
        dialogFactory.showDialogDrawables(styleProperty, dialogListener);
    } else if (styleProperty.type == Color.class) {
        dialogFactory.showDialogColors(styleProperty, dialogListener);
    } else if (styleProperty.type == BitmapFont.class) {
        dialogFactory.showDialogFonts(styleProperty, dialogListener);
    } else if (styleProperty.type == Float.TYPE) {
        main.getUndoableManager().addUndoable(new UndoableManager.DoubleUndoable(main, styleProperty, ((Spinner) styleActor).getValue()), false);
    } else if (styleProperty.type == ScrollPaneStyle.class) {
        main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true);
    } else if (styleProperty.type == LabelStyle.class) {
        main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true);
    } else if (styleProperty.type == ListStyle.class) {
        main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true);
    }
}
 
Example #3
Source File: EnumOptionsInputPanel.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
EnumOptionsInputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue, Enum<?>[] options) {
	input = new SelectBox<>(skin);

	int l = options.length;
	if(!mandatory) l++;
	Enum<?>[] values = new Enum[l];

	if(!mandatory) {
		values[0] = Empty.EMPTY;
	}

	System.arraycopy(options, 0, values, mandatory ? 0 : 1, options.length);

	input.setItems(values);

	init(skin, title, desc, input, mandatory, defaultValue);
}
 
Example #4
Source File: PropertyTable.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void setProperty(String name, String value) {
	SnapshotArray<Actor> actors = table.getChildren();

	for (Actor a : actors) {
		if (name.equals(a.getName())) {
			if (a instanceof SelectBox<?>) {
				((SelectBox<String>) a).setSelected(value == null ? "" : value);
			} else {
				((TextField) a).setText(value == null ? "" : value);
			}

			return;
		}
	}
}
 
Example #5
Source File: PropertyTable.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public void addProperty(String name, String selected, String[] value) {
	table.row();
	table.add(new Label(name, skin)).expandX().left();

	SelectBox<String> sb = new SelectBox<String>(skin);
	sb.setItems(value);
	if (selected != null)
		sb.setSelected(selected);
	sb.setName(name);
	table.add(sb).expandX().left();

	sb.addListener(new ChangeListener() {

		@SuppressWarnings("unchecked")
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			updateModel(actor.getName(), ((SelectBox<String>) actor).getSelected());
		}
	});
}
 
Example #6
Source File: DropDownSetting.java    From Cubes with MIT License 6 votes vote down vote up
@Override
public Actor getActor(final String settingName, VisualSettingManager visualSettingManager) {
  final SelectBox<String> selectBox = new SelectBox<String>(visualSettingManager.getSkin()) {
    @Override
    protected String toString(String s) {
      return Settings.getLocalisedSettingName(settingName + "." + s);
    }
  };
  selectBox.setItems(options);
  selectBox.setSelected(selected);
  selectBox.addListener(new EventListener() {
    @Override
    public boolean handle(Event event) {
      if (!(event instanceof SettingsMenu.SaveEvent)) return false;
      set(selectBox.getSelected());
      return true;
    }
  });
  return selectBox;
}
 
Example #7
Source File: UIUtils.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public static SelectBox<String> newSelectBox (String[] items, ChangeListener listener) {
	SelectBox<String> sb = new SelectBox<String>(Art.scrSkin);
	if (listener != null) {
		sb.addListener(listener);
	}

	sb.setItems(items);
	return sb;
}
 
Example #8
Source File: MainListener.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public void loadClasses(SelectBox classSelectBox) {
    Array names = new Array<>();
    for (Class clazz : Main.BASIC_CLASSES) {
        names.add(clazz.getSimpleName());
    }
    for (CustomClass customClass : main.getJsonData().getCustomClasses()) {
        names.add(customClass);
    }
    classSelectBox.setItems(names);
}
 
Example #9
Source File: MainListener.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public void loadStyles(SelectBox classSelectBox, SelectBox styleSelectBox) {
    int selection = classSelectBox.getSelectedIndex();
    if (selection < Main.BASIC_CLASSES.length) { 
        Class selectedClass = Main.BASIC_CLASSES[selection];
        styleSelectBox.setItems(jsonData.getClassStyleMap().get(selectedClass));
        styleSelectBox.setSelectedIndex(0);
    } else {
        CustomClass customClass = (CustomClass) classSelectBox.getSelected();
        styleSelectBox.setItems(customClass.getStyles());
    }
}
 
Example #10
Source File: UndoableManager.java    From skin-composer with MIT License 5 votes vote down vote up
public SelectBoxUndoable(RootTable rootTable, StyleProperty property, SelectBox<StyleData> selectBox) {
    this.property = property;
    this.selectBox = selectBox;

    oldValue = (String) property.value;
    newValue = selectBox.getSelected().name;
    this.rootTable = rootTable;
}
 
Example #11
Source File: UndoableManager.java    From skin-composer with MIT License 5 votes vote down vote up
public ParentUndoable(RootTable rootTable, StyleData style, SelectBox<String> selectBox) {
    this.rootTable = rootTable;
    this.style = style;
    this.selectBox = selectBox;
    oldValue = style.parent;
    if (selectBox.getSelectedIndex() == 0) {
        newValue = null;
    } else {
        newValue = selectBox.getSelected();
    }
}
 
Example #12
Source File: UIUtils.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public static SelectBox<String> newSelectBox (String[] items) {
	return newSelectBox(items, null);
}
 
Example #13
Source File: MainListener.java    From skin-composer with MIT License 4 votes vote down vote up
@Override
public void styleParentChanged(StyleData style, SelectBox<String> selectBox) {
    main.getUndoableManager().addUndoable(new UndoableManager.ParentUndoable(root, style, selectBox), true);
}
 
Example #14
Source File: SingleplayerSaveCreateMenu.java    From Cubes with MIT License 4 votes vote down vote up
public SingleplayerSaveCreateMenu() {
  super();
  title = new Label(Localization.get("menu.singleplayer.create.title"), skin.get("title", Label.LabelStyle.class));
  name = new TextField("", skin);
  name.setMessageText(Localization.get("menu.singleplayer.create.name"));
  name.setTextFieldFilter(new TextField.TextFieldFilter() {
    @Override
    public boolean acceptChar(TextField textField, char c) {
      return c >= 0x20 && c < 0x7F;
    }
  });

  generator = new SelectBox<SaveTypeDisplay>(skin);
  String[] types = GeneratorManager.ids();
  SaveTypeDisplay[] display = new SaveTypeDisplay[types.length];
  for (int i = 0; i < types.length; i++) {
    display[i] = new SaveTypeDisplay(types[i]);
  }
  generator.setItems(display);

  mode = new SelectBox<Gamemode>(skin);
  mode.setItems(Gamemode.values());

  seed = new TextField("", skin);
  seed.setMessageText(Localization.get("menu.singleplayer.create.seed"));

  start = new TextButton(Localization.get("menu.singleplayer.create.start"), skin);
  back = MenuTools.getBackButton(this);

  start.addListener(startListener = new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      Adapter.setMenu(new SingleplayerLoadingMenu(ClientSaveManager.createSave(name.getText(), generator.getSelected().id, mode.getSelected(), seed.getText())));
    }
  });

  stage.addActor(title);
  stage.addActor(name);
  stage.addActor(generator);
  stage.addActor(mode);
  stage.addActor(seed);
  stage.addActor(start);
  stage.addActor(back);
}