Java 类com.badlogic.gdx.scenes.scene2d.ui.SelectBox 实例源码

项目:Cubes_2    文件:DropDownSetting.java   
@Override
public Actor getActor(VisualSettingManager visualSettingManager) {
    final SelectBox<String> selectBox = new SelectBox<String>(visualSettingManager.getSkin());
    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;
}
项目:joe    文件:ParticleEffectViewer.java   
private void createDropdown() {
    final float screenWidth = Gdx.graphics.getWidth();
    final float screenHeight = Gdx.graphics.getHeight();

    final SelectBox<String> dropdown = new SelectBox<String>(skin);
    dropdown.setSize(screenWidth, screenHeight / 10);
    dropdown.setPosition(0, screenHeight - dropdown.getHeight());

    dropdown.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            inputListener.setSelectedEffectType(dropdown.getSelected());
        }
    });

    // Load dropdown.
    Array<String> effectTypes = ParticleEffectManager.getInstance().getParticleEffectTypes();
    dropdown.setItems(effectTypes);
    dropdown.getStyle().font = font;

    stage.addActor(dropdown);
}
项目:skin-composer    文件:MainListener.java   
@Override
public void stylePropertyChanged(StyleProperty styleProperty,
        Actor styleActor) {
    if (styleProperty.type == Drawable.class) {
        dialogFactory.showDialogDrawables(styleProperty);
    } else if (styleProperty.type == Color.class) {
        dialogFactory.showDialogColors(styleProperty);
    } else if (styleProperty.type == BitmapFont.class) {
        dialogFactory.showDialogFonts(styleProperty);
    } 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);
    }
}
项目:GDXJam    文件:OptionsDialog.java   
public GraphicsOptions (Skin skin) {
    setName("Graphics");
    resolutionSelectBox = new SelectBox<String>(skin);
    resolutionSelectBox.setItems(GameConfig.SUPPORTED_RESOLUTIONS);
    resolutionSelectBox.setSelected(OrionPrefs.getString(StringValue.GRAPHICS_RESOLUTION));

    fullscreenCheckBox = new CheckBox("Fullscreen", skin);
    fullscreenCheckBox.setChecked(OrionPrefs.getBoolean(BooleanValue.GRAPHICS_FULLSCREEN));

    TextButton applyButton = new TextButton("Apply", skin);
    applyButton.addListener(new ChangeListener() {

        @Override
        public void changed (ChangeEvent event, Actor actor) {
            OrionPrefs.putBoolean(BooleanValue.GRAPHICS_FULLSCREEN, fullscreenCheckBox.isChecked());
            OrionPrefs.putString(StringValue.GRAPHICS_RESOLUTION, resolutionSelectBox.getSelected());
            GameManager.refreshDisplayMode();
        }
    });

    add(resolutionSelectBox);
    row();
    add(fullscreenCheckBox);
    row();
    add(applyButton);
}
项目:Alien-Ark    文件:PlacedArtifactTable.java   
public PlacedArtifactTable() {
    setBackground(Styles.NINE_PATCH_POPUP_BG_01);

    selectBox = new SelectBox<ArtifactDefinitions.ConcreteArtifactType>(Styles.UI_SKIN);
    selectBox.setItems(ArtifactDefinitions.ConcreteArtifactType.values());
    add(selectBox);

    addButton = new TextButton("add artifact", Styles.UI_SKIN);
    add(addButton);
    row();

    artifactContent = new Table();
    scrollPane = new ScrollPane(artifactContent);
    scrollPane.setFadeScrollBars(false);
    add(scrollPane).colspan(2).height(200);

    pack();
}
项目:gdx-lml    文件:SelectBoxSelectedLmlAttribute.java   
@Override
public void process(final LmlParser parser, final LmlTag tag, final SelectBox<?> actor,
        final String rawAttributeData) {
    LmlUtilities.getLmlUserObject(actor).addOnCloseAction(new ActorConsumer<Object, Object>() {
        @Override
        @SuppressWarnings("unchecked")
        public Object consume(final Object widget) {
            try {
                actor.setSelectedIndex(parser.parseInt(rawAttributeData, actor));
            } catch (final Exception exception) {
                Exceptions.ignore(exception); // Possible number format exception. Trying to select string.
                ((SelectBox<String>) actor).setSelected(parser.parseString(rawAttributeData, actor));
            }
            return null;
        }
    });
}
项目:libgdxcn    文件:MipMapTest.java   
private void createUI () {
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    ui = new Stage();

    String[] filters = new String[TextureFilter.values().length];
    int idx = 0;
    for (TextureFilter filter : TextureFilter.values()) {
        filters[idx++] = filter.toString();
    }
    hwMipMap = new CheckBox("Hardware Mips", skin);
    minFilter = new SelectBox(skin);
    minFilter.setItems(filters);
    magFilter = new SelectBox(skin.get(SelectBoxStyle.class));
    magFilter.setItems("Nearest", "Linear");

    Table table = new Table();
    table.setSize(ui.getWidth(), 30);
    table.setY(ui.getHeight() - 30);
    table.add(hwMipMap).spaceRight(5);
    table.add(new Label("Min Filter", skin)).spaceRight(5);
    table.add(minFilter).spaceRight(5);
    table.add(new Label("Mag Filter", skin)).spaceRight(5);
    table.add(magFilter);

    ui.addActor(table);
}
项目:Terminkalender    文件:LoginActor.java   
public LoginActor(Skin skin) {
    super(skin);
    login = new Login();

    Window loginWindow = new TWindow("", skin, "window2");
    Label teacherName = new Label("Lehrer", skin);
    teachersSelectBox = new SelectBox<String>(skin);
    TextButton loginButton = new TextButton("Start", skin, "defaultBig");

    setPosition(AppMain.WIDTH / 2, 225);

    loginWindow.add(teacherName).row();
    loginWindow.add(teachersSelectBox).width(175).row();
    loginWindow.add(loginButton).width(175).height(100).colspan(2).padTop(40);
    add(loginWindow);

    loginButton.addListener(new ChangeListener() {
        public void changed (ChangeEvent event, Actor actor) {
            AppMain.user.login(teachersSelectBox.getSelected());
        }
    });
}
项目:Terminkalender    文件:SetTaskInCalendarDialog.java   
private void sendTaskData() {
    String location = locationText.getText();
    if(location.contains(AppWebSockets.POINTSPLIT) || location.contains(AppWebSockets.DATASPLIT) || 
       location.contains(AppWebSockets.TASKSPLIT)) {
        Resources.warningDialog.show("you musn't use ',', ';', or ':'", getStage());
        cancelTask();
    }
    else {
        task.setLocation(locationText.getText());
        int numberPartners = partnertsboxes.size;
        task.clearPartners();
        for(int index = 0; index < numberPartners; ++index) {
            SelectBox<String> partnertsBox = partnertsboxes.get(index);
            task.addPartner(partnertsBox.getSelected());
        }
        if(task.getWhatArray().size > 0) {
            task.setWhat(whatBox.getSelected());
        }
        if(task.getWhereArray().size > 0) {
            task.setWhere(whereBox.getSelected());
        }
        task.addDataServer();
    }
}
项目:ShapeOfThingsThatWere    文件:FramedMenu.java   
public <E> void addSelectBox(String label, E selected, E[] values, Consumer<E> lis) {
  LabelStyle style = skin.get(LabelStyle.class);
  Label l = new Label(label, style);
  table.add(l).minHeight(l.getMinHeight()).prefHeight(l.getPrefHeight());

  SelectBox<E> sb = new SelectBox<E>(skin.get(SelectBoxStyle.class));
  sb.setItems(values);
  sb.setSelected(selected);
  sb.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      lis.accept(sb.getSelected());
    }
  });
  Cell<SelectBox<E>> right = table.add(sb).minHeight(sb.getMinHeight()).prefHeight(sb.getMinHeight());
  if (nbColumns > 2)
    right.colspan(nbColumns - 1);

  table.row();
}
项目:ShapeOfThingsThatWere    文件:FramedMenu.java   
public void addBooleanSelectBox(String label, boolean selected, Consumer<Boolean> lis) {
  LabelStyle style = skin.get(LabelStyle.class);
  Label l = new Label(label, style);
  table.add(l).minHeight(l.getMinHeight()).prefHeight(l.getPrefHeight());

  SelectBox<Boolean> sb = new SelectBox<Boolean>(skin.get(SelectBoxStyle.class));
  sb.setItems(Boolean.TRUE, Boolean.FALSE);
  sb.setSelected(selected);
  sb.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      lis.accept(sb.getSelected());
    }
  });
  Cell<SelectBox<Boolean>> right = table.add(sb).minHeight(sb.getMinHeight()).prefHeight(sb.getMinHeight());
  if (nbColumns > 2)
    right.colspan(nbColumns - 1);

  table.row();
}
项目:GdxStudio    文件:SceneEditor.java   
public static void doClick(Actor actor){
    addField.remove();
    Frame.actorPanel.lock();
    Frame.propertyPanel.clear();
    Frame.effectPanel.clear();
    Frame.eventPanel.clear();
    selectedActor = actor;
    Scene.getCurrentScene().outline(actor);
    Frame.actorPanel.list.setSelectedIndex(Frame.actorPanel.indexOf(actor.getName()));
    StatusBar.updateSelected(actor.getName());
    Frame.dashPanel.update();
    Frame.propertyPanel.update();
    Frame.effectPanel.update();
    Frame.eventPanel.update();
    Frame.actorPanel.unlock();
    if(selectedActor instanceof List || selectedActor instanceof SelectBox){
        addField.setPosition(actor.getX(), actor.getY() - addField.getHeight());
        Scene.getRoot().addActor(addField);
    }
}
项目:GdxStudio    文件:Serializer.java   
public static void setup(){
    registerSerializer(Actor.class, new ActorSerializer());
    registerSerializer(Scene.class, new SceneSerializer());
    registerSerializer(ImageJson.class, new ImageJson());
    registerSerializer(Label.class, new LabelSerializer());
    registerSerializer(Button.class, new ButtonSerializer());
    registerSerializer(TextButton.class, new TextButtonSerializer());
    registerSerializer(Table.class, new TableSerializer());
    registerSerializer(CheckBox.class, new CheckBoxSerializer());
    registerSerializer(SelectBox.class, new SelectBoxSerializer());
    registerSerializer(List.class, new ListSerializer());
    registerSerializer(Slider.class, new SliderSerializer());
    registerSerializer(TextField.class, new TextFieldSerializer());
    registerSerializer(Touchpad.class, new TouchpadSerializer());
    registerSerializer(Sprite.class, new SpriteSerializer());

    registerSerializer(Dialog.class, new DialogSerializer());
    registerSerializer(SplitPane.class, new SplitPaneSerializer());
    registerSerializer(ScrollPane.class, new ScrollPaneSerializer());
    registerSerializer(Stack.class, new StackSerializer());
    registerSerializer(Tree.class, new TreeSerializer());
    registerSerializer(Table.class, new TableSerializer());
    registerSerializer(ButtonGroup.class, new ButtonGroupSerializer());
    registerSerializer(HorizontalGroup.class, new HorizontalGroupSerializer());
    registerSerializer(VerticalGroup.class, new VerticalGroupSerializer());
}
项目:bladecoder-adventure-engine    文件:EditAnimationDialog.java   
private void fillAnimations() {
    @SuppressWarnings("unchecked")
    SelectBox<String> cb = (SelectBox<String>) id.getField();
    cb.clearItems();

    // When creating, give option to add all elements
    if (e == null)
        cb.getItems().add("<ADD ALL>");

    String ids[] = spriteWidget.getAnimations();
    for (String s : ids)
        cb.getItems().add(s);

    cb.getList().setItems(cb.getItems());
    if (cb.getItems().size > 0)
        cb.setSelectedIndex(0);

    cb.invalidateHierarchy();

    setAnimation();
}
项目:bladecoder-adventure-engine    文件:EditAnimationDialog.java   
/**
 * Override to append all animations if selected.
 */
@Override
protected void ok() {
    @SuppressWarnings("unchecked")
    SelectBox<String> cb = (SelectBox<String>) id.getField();

    if (e == null && cb.getSelectedIndex() == 0) {
        for (int i = 1; i < cb.getItems().size; i++) {
            cb.setSelectedIndex(i);
            inputsToModel(true);
            // doc.setId(e, cb.getItems().get(i));

            if (listener != null)
                listener.changed(new ChangeEvent(), this);
        }

    } else {
        super.ok();
    }
}
项目:bladecoder-adventure-engine    文件:EnumOptionsInputPanel.java   
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);
}
项目:bladecoder-adventure-engine    文件:PropertyTable.java   
@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;
        }
    }
}
项目:bladecoder-adventure-engine    文件:PropertyTable.java   
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());
        }
    });
}
项目:bladecoder-adventure-engine    文件:StringOptionsInputPanel.java   
StringOptionsInputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue, String[] options) {
    input = new SelectBox<>(skin);

    int l = options.length;
    if(!mandatory) l++;
    String values[] = new String[l];

    if(!mandatory) {
        values[0] = "";
    }

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

    input.setItems(values);

    init(skin, title, desc, input, mandatory, defaultValue);
}
项目:the-erder    文件:GUIDropdown.java   
public GUIDropdown()
{
    this.name = "GenericBox";
    this.box = new SelectBox<String>(
            GameManager.getSkin(GameManager.selectedSkin), "box");
    this.box.setItems("Close");
    this.box.setSelectedIndex(0);

    ChangeListener listener = new ChangeListener()
    {

        @Override
        public void changed(ChangeEvent event, Actor actor)
        {
            NetGUIAnswer r = new NetGUIAnswer();
            r.name = name;
            r.value = box.getSelected();
            System.out.println(r.value);
            Client.Send(r);
        }
    };

    this.box.addListener(listener);
}
项目:ead    文件:BackgroundTaskDemo.java   
@Override
public AbstractWidget createWidget(Controller controller) {
    Skin skin = controller.getApplicationAssets().getSkin();
    LinearLayout bottomLayout = new LinearLayout(false);
    label = new Label("Stopped", skin);

    bottomLayout.add(label);

    SelectBox<String> selectBox = new SelectBox<String>(skin);
    selectBox.setItems("Just", "a", "drop", "down", "list", "to", "check",
            "that", "UI", "doesn't", "freeze");

    TextButton textButton = new TextButton("Run", skin);
    textButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Gdx.app.postRunnable(launchBackgroundProcess);
        }
    });

    bottomLayout.add(selectBox);
    bottomLayout.add(textButton);
    return bottomLayout;
}
项目:gdx-cclibs    文件:ExampleRunner.java   
@Override
public void create() {
    spriteBatch = new SpriteBatch();
    stage = new Stage(new ScreenViewport());
    skin = new Skin(Gdx.files.internal("uiskin.json"));
    Table table = new Table(skin);
    table.setFillParent(true);
    selectBox = new SelectBox<Class<? extends Example>>(skin){
        protected String toString (Class<? extends Example> obj) {
            return obj.getSimpleName();
        }
    };
    selectBox.setItems(examples);
    table.add(selectBox).fillX().space(20).row();
    stage.addActor(table);
    TextButton startButton = new TextButton("Start example", skin);
    startButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            runSelectedExample();
        }
    });
    table.add(startButton).fillX();

    if (arg != null && arg.length > 0) {
        Class<? extends Example> specifiedExample = getExample(arg[0]);
        if (specifiedExample != null){
            startExample(specifiedExample);
            return;
        }
    }

    setScreen(menuScreen);
}
项目:gdx-cclibs    文件:FlexBatchTest.java   
private void setupUI() {
    stage = new Stage(new ScreenViewport(), quad2dBatch);
    skin = new Skin(Gdx.files.internal("uiskin.json"));

    final SelectBox<Test> selectBox = new SelectBox<Test>(skin);
    selectBox.setItems(Test.values());
    selectBox.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            test = selectBox.getSelected();
            elapsed = 0;
        }
    });
    Table table = new Table();
    table.setFillParent(true);
    table.defaults().padTop(5).left();
    table.top().left().padLeft(5);
    table.add(selectBox).row();
    table.add(new Label("", skin) {
        int fps = -1;

        public void act(float delta) {
            super.act(delta);
            if (Gdx.graphics.getFramesPerSecond() != fps) {
                fps = Gdx.graphics.getFramesPerSecond();
                setText("" + fps);
            }
        }
    }).row();
    stage.addActor(table);
}
项目:Cubes    文件:DropDownSetting.java   
@Override
public Actor getActor(VisualSettingManager visualSettingManager) {
  final SelectBox<String> selectBox = new SelectBox<String>(visualSettingManager.getSkin());
  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;
}
项目:skin-composer    文件:MainListener.java   
@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);
}
项目:skin-composer    文件:MainListener.java   
@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());
    }
}
项目:skin-composer    文件:UndoableManager.java   
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;
}
项目:Opus-Prototype    文件:SamplerSelectBoxElement.java   
public SamplerSelectBoxElement(Skin skin, Stage stage, Samplers samplers,
        boolean showPreview, Class<? extends AbstractSampler> filterClass) {
    super(skin);
    this.samplers = samplers;

    AbstractSampler[] samplerList = Util.filter(samplers.createSamplerList(), filterClass);

    samplerIcon = new Image();
    add(samplerIcon).width(20).height(20);

    samplerSelect = new SelectBox<AbstractSampler>(Styles.SAMPLER_SELECT_BOX_SKIN);
    samplerSelect.setItems(samplerList);
    samplerSelect.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            select(samplerSelect.getSelected());
        }
    });

    preview = new SamplerHoverPreviewElement(skin, 35, stage);
    if (samplerList.length > 0) {
        samplerSelect.setSelected(samplers.getSampler(Editor.DEFAULT_SAMPLER_NAME));
        preview.applySampler(samplers.getSampler(Editor.DEFAULT_SAMPLER_NAME));
    }

    add(samplerSelect);
    if (showPreview) {
        add(preview).width(35).height(35);
    }
}
项目:Opus-Prototype    文件:NoiseSamplerForm.java   
public NoiseSamplerForm(Skin skin, AbstractSampler sampler, Samplers pool) {
    super(skin, sampler, pool);
    this.skin = skin;
    defaults().center().pad(5);
    setBackground(Styles.INNER_BACKGROUND);


    Label algorithmLabel = new Label("algorithm", skin);
    add(algorithmLabel);

    algorithmSelect = new SelectBox(skin);
    String[] algorithmNames = new String[Editor.KNOWN_ALGORITHMS.keySet().size()];
    Editor.KNOWN_ALGORITHMS.keySet().toArray(algorithmNames);
    algorithmSelect.setItems(algorithmNames);
    algorithmSelect.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            notifyChanges();
        }
    });

    add(algorithmSelect);


    loadFromConfig(sampler.getConfig());
    notifyChanges();
}
项目:Opus-Prototype    文件:NewSamplerDialog.java   
public NewSamplerDialog(Skin skin) {
    super("Create new sampler", skin);


    Label nameLabel = new Label("Name", skin);
    getContentTable().add(nameLabel);
    nameField = new TextField("default", skin);
    getContentTable().pad(2);
    getContentTable().add(nameField);
    getContentTable().row();

    selectBox = new SelectBox(skin);
    String[] samplerNames = new String[Samplers.SAMPLER_TO_CONFIG.size()];
    int i = 0;
    for (Class c : Samplers.SAMPLER_TO_CONFIG.keySet()) {
        samplerNames[i] = c.getSimpleName();
        i++;
    }
    selectBox.setItems(samplerNames);
    Label typeLabel = new Label("Type", skin);
    getContentTable().add(typeLabel);
    getContentTable().add(selectBox);

    key(Input.Keys.ENTER, true);
    key(Input.Keys.ESCAPE, false);
    button("create", true);
    button("cancel", false);
}
项目:abattle    文件:Widgets.java   
public SelectBox<String> createDropDown(final String selected, final Collection<String> items) {
  Skin _skin = this.manager.getSkin();
  final SelectBox<String> selectBox = new SelectBox<String>(_skin);
  selectBox.setItems(((String[])Conversions.unwrapArray(items, String.class)));
  selectBox.setSelected(selected);
  return selectBox;
}
项目:gdx-autumn-mvc    文件:ReflectionPreference.java   
@Override
public Object extractFromActor(final Actor actor) {
    if (actor instanceof TextField) {
        return Integer.valueOf(((TextField) actor).getText());
    } else if (actor instanceof List<?>) {
        return ((List<?>) actor).getSelectedIndex();
    } else if (actor instanceof SelectBox<?>) {
        return ((SelectBox<?>) actor).getSelectedIndex();
    }
    throw new GdxRuntimeException("Cannot use default setter of int preference with actor: " + actor);
}
项目:gdx-autumn-mvc    文件:ReflectionPreference.java   
@Override
public Object extractFromActor(final Actor actor) {
    if (actor instanceof Label) {
        return ((Label) actor).getText().toString();
    } else if (actor instanceof TextButton) {
        return ((TextButton) actor).getText();
    } else if (actor instanceof TextField) {
        return ((TextField) actor).getText();
    } else if (actor instanceof List<?>) {
        return Strings.toString(((List<?>) actor).getSelected(), Strings.EMPTY_STRING);
    } else if (actor instanceof SelectBox<?>) {
        return Strings.toString(((SelectBox<?>) actor).getSelected(), Strings.EMPTY_STRING);
    }
    return Strings.toString(actor);
}
项目:gdx-lml    文件:SelectBoxSelectedLmlAttribute.java   
@Override
@SuppressWarnings("unchecked")
public Class<SelectBox<?>> getHandledType() {
    // Double cast as there were a problem with generics - SomeClass.class cannot be returned as
    // <Class<SomeClass<?>>, even though casting never throws ClassCastException in the end.
    return (Class<SelectBox<?>>) (Object) SelectBox.class;
}
项目:gdx-lml    文件:ReflectionPreference.java   
@Override
public Object extractFromActor(final Actor actor) {
    if (actor instanceof TextField) {
        return Integer.valueOf(((TextField) actor).getText());
    } else if (actor instanceof List<?>) {
        return ((List<?>) actor).getSelectedIndex();
    } else if (actor instanceof SelectBox<?>) {
        return ((SelectBox<?>) actor).getSelectedIndex();
    }
    throw new GdxRuntimeException("Cannot use default setter of int preference with actor: " + actor);
}
项目:gdx-lml    文件:ReflectionPreference.java   
@Override
public Object extractFromActor(final Actor actor) {
    if (actor instanceof Label) {
        return ((Label) actor).getText().toString();
    } else if (actor instanceof TextButton) {
        return ((TextButton) actor).getText();
    } else if (actor instanceof TextField) {
        return ((TextField) actor).getText();
    } else if (actor instanceof List<?>) {
        return Strings.toString(((List<?>) actor).getSelected(), Strings.EMPTY_STRING);
    } else if (actor instanceof SelectBox<?>) {
        return Strings.toString(((SelectBox<?>) actor).getSelected(), Strings.EMPTY_STRING);
    }
    return Strings.toString(actor);
}
项目:libgdxcn    文件:ProjectiveTextureTest.java   
public void setupUI () {
    ui = new Stage();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextButton reload = new TextButton("Reload Shaders", skin.get(TextButtonStyle.class));
    camera = new SelectBox(skin.get(SelectBoxStyle.class));
    camera.setItems("Camera", "Light");
    fps = new Label("fps: ", skin.get(LabelStyle.class));

    Table table = new Table();
    table.setFillParent(true);
    table.top().padTop(15);
    table.add(reload).spaceRight(5);
    table.add(camera).spaceRight(5);
    table.add(fps);
    ui.addActor(table);

    reload.addListener(new ClickListener() {
        public void clicked (InputEvent event, float x, float y) {
            ShaderProgram prog = new ShaderProgram(Gdx.files.internal("data/shaders/projtex-vert.glsl").readString(), Gdx.files
                .internal("data/shaders/projtex-frag.glsl").readString());
            if (prog.isCompiled() == false) {
                Gdx.app.log("GLSL ERROR", "Couldn't reload shaders:\n" + prog.getLog());
            } else {
                projTexShader.dispose();
                projTexShader = prog;
            }
        }
    });
}
项目:GdxStudio    文件:StudioPanel.java   
public void createActor(String type){
    switch(type){
        case "Label":
            if(Asset.fontMap.size != 0){
                LabelStyle ls = new LabelStyle();
                ls.font = Asset.fontMap.firstValue();
                Label label = new Label("Text", ls);
                setName(label);
            }
            break;
        case "Image":
            if(Asset.texMap.size != 0){
                setName(new ImageJson(Asset.texMap.firstKey()));
            }
            break;
        case "Texture":setName(new ImageJson(Content.assetPanel.list.getSelectedValue()));break;
        case "Sprite":setName(new Sprite(1f, Asset.texMap.firstKey()));break;
        case "Particle":
            //ParticleEffect pe = new ParticleEffect();
            //pe.load(effectFile, imagesDir);
            break;

        case "Button":setName(new Button(Asset.skin));break;
        case "TextButton":setName(new TextButton("Text", Asset.skin));break;
        case "TextField":setName(new TextField("", Asset.skin));break;
        case "Table":setName(new Table(Asset.skin));break;
        case "CheckBox":setName(new CheckBox("Check", Asset.skin));break;
        case "SelectBox":setName(new SelectBox(new String[]{"First","Second","Third"}, Asset.skin));break;
        case "List":setName(new List(new String[]{"First","Second","Third"}, Asset.skin));break;
        case "Slider":setName(new Slider(0, 10, 1, false, Asset.skin));break;
        case "Dialog":setName(new Dialog("Title", Asset.skin));break;
        case "Touchpad":setName(new Touchpad(5, Asset.skin));break;
        case "Map":setName(new Map(1, 24));break;
        case "None":break;
        default:break;
    }
}
项目:GdxStudio    文件:Serializer.java   
@Override
public void write(Json json, Actor select, Class arg2) {
    json.writeObjectStart();
    writeActor(json, select);
    String items = "";
    for(String s: ((SelectBox)select).getItems())
        items+=s+",";
    json.writeValue("text", items);
    json.writeObjectEnd();
}
项目:gaiasky    文件:PreferencesWindow.java   
private void selectFullscreen(boolean fullscreen, OwnTextField widthField, OwnTextField heightField, SelectBox<DisplayMode> fullScreenResolutions, OwnLabel widthLabel, OwnLabel heightLabel) {
    if (fullscreen) {
        GlobalConf.screen.SCREEN_WIDTH = fullScreenResolutions.getSelected().width;
        GlobalConf.screen.SCREEN_HEIGHT = fullScreenResolutions.getSelected().height;
    } else {
        GlobalConf.screen.SCREEN_WIDTH = Integer.parseInt(widthField.getText());
        GlobalConf.screen.SCREEN_HEIGHT = Integer.parseInt(heightField.getText());
    }

    enableComponents(!fullscreen, widthField, heightField, widthLabel, heightLabel);
    enableComponents(fullscreen, fullScreenResolutions);
}