コード例 #1
0
  public SettingsScreen(AbstractScreen parentScreen) {
    super(parentScreen);
    initFitViewport();

    //        final AbstractAuthService authService =
    // mAdapter.getPlatformServices().getAuthService();

    mBgStage.loadImage(this, "Bg/menu/settings-bg.jpg");

    BackButton.create(this, MainMenuScreen.class);

    mSettings = new LocalSettings();

    final CheckBox cbSounds = new CheckBox("", RM.getCheckBoxStyle());
    cbSounds.setBounds(20, 500, SES.BUTTON_HEIGHT, SES.BUTTON_HEIGHT);
    cbSounds.setChecked(mSettings.getSoundEnabled());

    mStage.addActor(cbSounds);
    cbSounds.addListener(
        new ClickListener() {

          @Override
          public void clicked(InputEvent event, float x, float y) {
            mSettings.setSoundEnabled(cbSounds.isChecked());
            mSettings.flush();
          }
        });

    Label lblSounds = new Label("Sound effects", RM.getLabelStyle());
    lblSounds.setBounds(120, 500, 200, SES.BUTTON_HEIGHT);
    mStage.addActor(lblSounds);

    final CheckBox cbMusic = new CheckBox("", RM.getCheckBoxStyle());
    cbMusic.setBounds(20, 400, SES.BUTTON_HEIGHT, SES.BUTTON_HEIGHT);
    cbMusic.setChecked(mSettings.getMusicEnabled());
    mStage.addActor(cbMusic);
    cbMusic.addListener(
        new ClickListener() {

          public void clicked(InputEvent event, float x, float y) {
            mSettings.setMusicEnabled(cbMusic.isChecked());
            mSettings.flush();
          }
        });

    Label lblMusic = new Label("Music", RM.getLabelStyle());
    lblMusic.setBounds(120, 400, 200, SES.BUTTON_HEIGHT);
    mStage.addActor(lblMusic);

    TextButton btnGooglePlayLink = new TextButton("GooglePlay", RM.getTextButtonStyle());
    btnGooglePlayLink.setBounds(SES.buttonRight(), 20, SES.BUTTON_WIDTH, SES.BUTTON_HEIGHT);
    mStage.addActor(btnGooglePlayLink);
    btnGooglePlayLink.addListener(
        new ClickListener() {

          public void clicked(InputEvent event, float x, float y) {}
        });
  }
コード例 #2
0
ファイル: OptionsMenu.java プロジェクト: cody82/gravityshock
  @Override
  public void show() {
    skin = Assets.getSkin();
    ui = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    Gdx.input.setInputProcessor(ui);

    window =
        new Window("window", skin) {
          protected void drawBackground(SpriteBatch batch, float parentAlpha) {}
        };

    window.setBounds(0, 0, ui.getWidth(), ui.getHeight());
    window.setMovable(false);
    window.setColor(0, 0, 0, 0.8f);

    // window.debug();
    window.defaults().spaceBottom(10);
    window.row().fill().expandX();

    final CheckBox bloom = new CheckBox("Enable Bloom", skin);
    bloom.addListener(
        new InputListener() {
          @Override
          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);
            boolean b = bloom.isChecked();
            game.setBloom(b);
            Util.setBloomOption(b);
          }
        });

    bloom.setChecked(Util.getBloomOption());

    window.add(bloom).fill(0f, 0f);

    final TextButton button = new TextButton("Done", skin);
    button.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            game.startMainMenu();
            return true;
          }
        });

    window.add(button).fill(0f, 0f);

    ui.addActor(window);
  }
コード例 #3
0
ファイル: SettingsMenu.java プロジェクト: bugjoe/andoria
  private Cell addCheckBox(String text, Settings.Key key) {
    final CheckBox checkBox = new CheckBox(text, Resources.getSkin());
    final Settings.Key _key = key;

    checkBox.setChecked(Settings.getBoolean(_key));
    checkBox.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent changeEvent, Actor actor) {
            final boolean value = Settings.getBoolean(_key);
            Settings.setBoolean(_key, !value);
          }
        });

    return add(checkBox).left();
  }
コード例 #4
0
  private void createSoundFXToggleButton(AssetManager assetManager) {

    Texture soundFXButtonActiveTexture =
        assetManager.get("soundfxbutton_active.png", Texture.class);
    Texture soundFXButtonInactiveTexture =
        assetManager.get("soundfxbutton_inactive.png", Texture.class);

    // Run
    // "texture through 2 other thingys to turn it into a "TextureRegiionDrawable,
    // which is what the "Button" constructor needs.
    TextureRegion soundFXActiveButtonTR = new TextureRegion(soundFXButtonActiveTexture);
    TextureRegion soundFXInactiveButtonTR = new TextureRegion(soundFXButtonInactiveTexture);

    TextureRegionDrawable soundFXButtonActiveTRD = new TextureRegionDrawable(soundFXActiveButtonTR);
    TextureRegionDrawable soundFXButtonInactiveTRD =
        new TextureRegionDrawable(soundFXInactiveButtonTR);

    // Create the start button
    CheckBoxStyle s = new CheckBoxStyle();
    s.font = new BitmapFont();
    s.checkboxOn = soundFXButtonActiveTRD;
    s.checkboxOn.setMinHeight(buttonRowHeight);
    s.checkboxOn.setMinWidth(buttonRowHeight);
    s.checkboxOff = soundFXButtonInactiveTRD;
    s.checkboxOff.setMinHeight(buttonRowHeight);
    s.checkboxOff.setMinWidth(buttonRowHeight);
    soundFXButton = new CheckBox("", s);
    soundFXButton.setChecked(true);

    // Define how big it is.
    soundFXButton.setBounds(0f, 0f, buttonRowHeight, buttonRowHeight);

    // Move it to where it should go on the screen.
    soundFXButton.setPosition(
        screenDimensions.x - (buttonColumnWidth + verticalBorderAmount * 4),
        screenDimensions.y - (horizontalBorderAmount + buttonRowHeight * 4 + lineSpacing * 3));

    // Tell it to notify this class (StartScreen) when clicked.
    soundFXButton.addListener(this);

    // Add it to the stage so it will "act" and "draw" when the stage does.
    stage.addActor(soundFXButton);
  }
コード例 #5
0
  public PanelProperties(String title, Skin skin) {
    super(title, skin);

    scroll.getListeners().removeIndex(0);

    TextFieldFilter filter =
        new TextFieldFilter() {
          @Override
          public boolean acceptChar(TextField textField, char c) {
            textBuffer = textField.getText();
            cursorBuffer = textField.getCursorPosition();
            if (c == '-' && (cursorBuffer == 0 || updateProperties)) return true;
            if (c >= '0' && c <= '9' || c == '.') return true;

            return false;
          }
        };

    TextFieldListener listener =
        new TextFieldListener() {
          @Override
          public void keyTyped(TextField textField, char c) {
            if (editActors == null || c == 0 || c == '\t') return;

            if (c == '\r' || c == '\n') {
              getStage().setKeyboardFocus(null);
              return;
            }

            GroupCommand groupCommand = new GroupCommand();

            for (Actor model : editActors) {
              if (textField == name) {
                NameCommand nameCommand = new NameCommand();
                nameCommand.setNewName(textField.getText());
                nameCommand.addActor(model);
                nameCommand.addUpdater(
                    ((MainScreen) GameInstance.game.getScreen()).getTree().panelUpdater);
                groupCommand.addCommand(nameCommand);
              } else {
                if (c == '.'
                    && textField.getText().indexOf(c) != textField.getText().lastIndexOf(c)) {
                  textField.setText(textBuffer);
                  textField.setCursorPosition(cursorBuffer);
                  return;
                }

                if (textField.getText().isEmpty()) return;

                try {
                  Float value = Float.parseFloat(textField.getText());
                  if (textField == positionX) {
                    TranslateCommand transCommand = new TranslateCommand();
                    transCommand.setNewPosition(value, model.getY());
                    transCommand.addActor(model);
                    groupCommand.addCommand(transCommand);
                  } else if (textField == positionY) {
                    TranslateCommand transCommand = new TranslateCommand();
                    transCommand.setNewPosition(model.getX(), value);
                    transCommand.addActor(model);
                    groupCommand.addCommand(transCommand);
                  } else if (textField == rotation) {
                    RotateCommand rotateCommand = new RotateCommand();
                    rotateCommand.setAngle(value);
                    rotateCommand.addActor(model);
                    groupCommand.addCommand(rotateCommand);
                  } else if (textField == scaleX) {
                    ScaleCommand scaleCommand = new ScaleCommand();
                    scaleCommand.setNewScale(
                        value, lockRatio.isChecked() ? value : model.getScaleY());
                    scaleCommand.addActor(model);
                    groupCommand.addCommand(scaleCommand);

                    if (lockRatio.isChecked()) scaleY.setText(scaleX.getText());
                  } else if (textField == scaleY) {
                    ScaleCommand scaleCommand = new ScaleCommand();
                    scaleCommand.setNewScale(model.getScaleX(), value);
                    scaleCommand.addActor(model);
                    groupCommand.addCommand(scaleCommand);
                  } else {
                    ColorCommand colorCommand = new ColorCommand();
                    colorCommand.addActor(model);
                    value /= 255.0f;
                    value = Math.min(1.0f, Math.max(0.0f, value));
                    if (textField == r) colorCommand.setR(value);
                    else if (textField == g) colorCommand.setG(value);
                    else if (textField == b) colorCommand.setB(value);
                    else colorCommand.setA(value);
                    groupCommand.addCommand(colorCommand);
                  }
                } catch (NumberFormatException exception) {
                }
              }
            }

            if (groupCommand.getCommands().size > 0)
              CommandController.instance.addCommand(groupCommand, false);
          }
        };

    InputListener tabListener =
        new InputListener() {
          @Override
          public boolean keyUp(InputEvent event, int keycode) {
            if (event.getCharacter() == '\t') {
              Actor actor = event.getListenerActor();
              if (actor instanceof TextField) ((TextField) actor).selectAll();
            }
            return true;
          }
        };

    // name
    name = new TextField("", skin);
    name.setTextFieldListener(listener);
    name.addListener(tabListener);
    content.add(new Label("Name: ", skin));
    content.add(name);

    // visible
    visible = new CheckBox(" visible", skin);
    visible.getStyle().disabledFontColor = disableColor;
    visible.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            if (updateProperties || editActors == null) return;

            GroupCommand groupCommand = new GroupCommand();

            for (Actor model : editActors) {
              VisibleCommand command = new VisibleCommand();
              command.setNewVisible(visible.isChecked());
              command.addActor(model);
              groupCommand.addCommand(command);
            }

            CommandController.instance.addCommand(groupCommand);
          }
        });
    content.add(visible);

    content.row();

    // position
    positionX = new TextField("", skin);
    positionX.setTextFieldListener(listener);
    positionX.setTextFieldFilter(filter);
    positionX.addListener(tabListener);
    positionY = new TextField("", skin);
    positionY.setTextFieldListener(listener);
    positionY.setTextFieldFilter(filter);
    positionY.addListener(tabListener);
    content.add(new Label("Position: ", skin));
    content.add(positionX);
    content.add(positionY);

    content.row();

    // angle
    rotation = new TextField("", skin);
    rotation.setTextFieldListener(listener);
    rotation.setTextFieldFilter(filter);
    rotation.addListener(tabListener);
    content.add(new Label("Angle: ", skin));
    content.add(rotation);

    lockRatio = new CheckBox(" ratio", skin);
    lockRatio.getStyle().disabledFontColor = disableColor;
    lockRatio.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            if (updateProperties || editActors == null) return;

            scaleY.setDisabled(lockRatio.isChecked());
            scaleY.setColor(lockRatio.isChecked() ? disableColor : enableColor);

            if (lockRatio.isChecked()) {
              scaleY.setText(scaleX.getText());

              GroupCommand groupCommand = new GroupCommand();
              for (Actor model : editActors) {
                ScaleCommand scaleCommand = new ScaleCommand();
                scaleCommand.setNewScale(model.getScaleX(), model.getScaleX());
                scaleCommand.addActor(model);
                groupCommand.addCommand(scaleCommand);
              }
              CommandController.instance.addCommand(groupCommand);
            }
          }
        });
    content.add(lockRatio);

    content.row();

    // scale
    scaleX = new TextField("", skin);
    scaleX.setTextFieldListener(listener);
    scaleX.setTextFieldFilter(filter);
    scaleX.addListener(tabListener);
    scaleY = new TextField("", skin);
    scaleY.setTextFieldListener(listener);
    scaleY.setTextFieldFilter(filter);
    scaleX.addListener(tabListener);
    content.add(new Label("Scale: ", skin));
    content.add(scaleX);
    content.add(scaleY);

    content.row();

    r = new TextField("", skin);
    r.setTextFieldListener(listener);
    r.setTextFieldFilter(filter);
    r.addListener(tabListener);
    g = new TextField("", skin);
    g.setTextFieldListener(listener);
    g.setTextFieldFilter(filter);
    g.addListener(tabListener);
    b = new TextField("", skin);
    b.setTextFieldListener(listener);
    b.setTextFieldFilter(filter);
    b.addListener(tabListener);
    a = new TextField("", skin);
    a.setTextFieldListener(listener);
    a.setTextFieldFilter(filter);
    a.addListener(tabListener);
    content.add(new Label("Color: ", skin));

    Table colorTable = new Table(skin);
    colorTable.defaults().spaceBottom(10);
    colorTable.defaults().space(10);
    colorTable.add(r).width(75);
    colorTable.add(g).width(75);
    content.add(colorTable);
    colorTable = new Table(skin);
    colorTable.defaults().spaceBottom(10);
    colorTable.defaults().space(10);
    colorTable.add(b).width(75);
    colorTable.add(a).width(75);
    content.add(colorTable);

    content.row();

    final TextButtonStyle styleButton = skin.get(TextButtonStyle.class);
    TextButtonStyle style =
        new TextButtonStyle(styleButton.up, styleButton.down, styleButton.down, styleButton.font);
    style.disabledFontColor = disableColor;
    advancedButton = new TextButton("Advanced", style);
    advancedButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            PanelAdvanced advanced = ((MainScreen) GameInstance.game.getScreen()).getAdvanced();
            advanced.setVisible(advancedButton.isChecked());
          }
        });
    content.add(new Label("Settings: ", skin));
    content.add(advancedButton);

    setSize(450, 300);
    setEditActors(null);
  }
コード例 #6
0
    void events() {
      window.addListener(
          new InputListener() {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
              event.cancel();
              return true;
            }
          });

      openButton.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              FileDialog fileDialog = new FileDialog((Frame) null, "Choose skeleton file");
              fileDialog.setMode(FileDialog.LOAD);
              fileDialog.setVisible(true);
              String name = fileDialog.getFile();
              String dir = fileDialog.getDirectory();
              if (name == null || dir == null) return;
              loadSkeleton(new FileHandle(new File(dir, name).getAbsolutePath()));
            }
          });

      setupPoseButton.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              if (skeleton != null) skeleton.setToSetupPose();
            }
          });
      bonesSetupPoseButton.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              if (skeleton != null) skeleton.setBonesToSetupPose();
            }
          });
      slotsSetupPoseButton.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              if (skeleton != null) skeleton.setSlotsToSetupPose();
            }
          });

      minimizeButton.addListener(
          new ClickListener() {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
              event.cancel();
              return super.touchDown(event, x, y, pointer, button);
            }

            public void clicked(InputEvent event, float x, float y) {
              if (minimizeButton.isChecked()) {
                window.getCells().get(0).setActor(null);
                window.setHeight(37);
                minimizeButton.setText("+");
              } else {
                window.getCells().get(0).setActor(root);
                ui.window.setHeight(Gdx.graphics.getHeight() + 8);
                minimizeButton.setText("-");
              }
            }
          });

      scaleSlider.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              scaleLabel.setText(Float.toString((int) (scaleSlider.getValue() * 100) / 100f));
              if (!scaleSlider.isDragging()) loadSkeleton(skeletonFile);
            }
          });

      speedSlider.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              speedLabel.setText(Float.toString((int) (speedSlider.getValue() * 100) / 100f));
            }
          });

      alphaSlider.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              alphaLabel.setText(Float.toString((int) (alphaSlider.getValue() * 100) / 100f));
              int track = trackButtons.getCheckedIndex();
              if (track > 0) {
                TrackEntry current = state.getCurrent(track);
                if (current != null) {
                  current.setAlpha(alphaSlider.getValue());
                  current.resetRotationDirections();
                }
              }
            }
          });

      mixSlider.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              mixLabel.setText(Float.toString((int) (mixSlider.getValue() * 100) / 100f));
              if (state != null) state.getData().setDefaultMix(mixSlider.getValue());
            }
          });

      animationList.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              if (state != null) {
                String name = animationList.getSelected();
                if (name == null)
                  state.setEmptyAnimation(trackButtons.getCheckedIndex(), ui.mixSlider.getValue());
                else setAnimation();
              }
            }
          });

      loopCheckbox.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              setAnimation();
            }
          });

      skinList.addListener(
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              if (skeleton != null) {
                String skinName = skinList.getSelected();
                if (skinName == null) skeleton.setSkin((Skin) null);
                else skeleton.setSkin(skinName);
                skeleton.setSlotsToSetupPose();
              }
            }
          });

      ChangeListener trackButtonListener =
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              int track = ui.trackButtons.getCheckedIndex();
              if (track == -1) return;
              TrackEntry current = state.getCurrent(track);
              animationList.getSelection().setProgrammaticChangeEvents(false);
              animationList.setSelected(current == null ? null : current.animation.name);
              animationList.getSelection().setProgrammaticChangeEvents(true);

              alphaSlider.setDisabled(track == 0);
              alphaSlider.setValue(current == null ? 1 : current.alpha);
            }
          };
      for (TextButton button : trackButtons.getButtons()) button.addListener(trackButtonListener);

      Gdx.input.setInputProcessor(
          new InputMultiplexer(
              stage,
              new InputAdapter() {
                public boolean touchDown(int screenX, int screenY, int pointer, int button) {
                  touchDragged(screenX, screenY, pointer);
                  return false;
                }

                public boolean touchDragged(int screenX, int screenY, int pointer) {
                  skeletonX = screenX;
                  skeletonY = Gdx.graphics.getHeight() - screenY;
                  return false;
                }

                public boolean touchUp(int screenX, int screenY, int pointer, int button) {
                  savePrefs();
                  return false;
                }
              }));

      ChangeListener savePrefsListener =
          new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
              if (actor instanceof Slider && ((Slider) actor).isDragging()) return;
              savePrefs();
            }
          };
      debugBonesCheckbox.addListener(savePrefsListener);
      debugRegionsCheckbox.addListener(savePrefsListener);
      debugMeshHullCheckbox.addListener(savePrefsListener);
      debugMeshTrianglesCheckbox.addListener(savePrefsListener);
      debugPathsCheckbox.addListener(savePrefsListener);
      premultipliedCheckbox.addListener(savePrefsListener);
      loopCheckbox.addListener(savePrefsListener);
      speedSlider.addListener(savePrefsListener);
      mixSlider.addListener(savePrefsListener);
      scaleSlider.addListener(savePrefsListener);
      animationList.addListener(savePrefsListener);
      skinList.addListener(savePrefsListener);
    }
コード例 #7
0
  public OptionScreen(Anvil anvil) {
    super(anvil);

    Skin skin = new Skin(Gdx.files.internal(Systems.Skin));

    back = new Texture(Gdx.files.internal(Locale.SYSTEM_UI_PATH + "marble.png"));
    background = new Image(back);

    FreeTypeFontGenerator gen =
        new FreeTypeFontGenerator(Gdx.files.internal(Locale.FONT_BASE + "Canted Comic.ttf"));
    FreeTypeFontParameter par = new FreeTypeFontParameter();
    par.size = 20;
    par.borderColor = Color.BLACK;
    par.color = Color.WHITE;
    par.borderWidth = 2;
    BitmapFont font = gen.generateFont(par);

    LabelStyle ls = new LabelStyle();
    ls.font = font;

    CheckBox vsync = new CheckBox("VSync", skin);
    vsync.setChecked(getBool("Graphics", "useVsync"));
    vsync.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            bVsync = vsync.isChecked();
            vsync.setChecked(vsync.isChecked() ? false : true);
          }
        });

    Separator sep = new Separator();

    CheckBox controller = new CheckBox("Use Controller", skin);
    controller.setChecked(getBool("Controls", "useController"));
    controller.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {}
        });

    TextButton okay = new TextButton("Apply", skin);
    okay.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            save();
            anvil.setScreen(new MenuScreen(anvil));
          }
        });

    Table opt = new Table(skin);
    opt.setFillParent(true);
    opt.setBackground(background.getDrawable());

    opt.add(new Label("Graphics", ls)).row();
    opt.add(sep);
    opt.add(vsync).row();
    opt.add().row();
    opt.add().row();
    opt.add().row();

    opt.add(okay).align(Align.bottomLeft);

    stage.addActor(opt);
    Gdx.input.setInputProcessor(stage);
  }
コード例 #8
0
	private void fillTable() {
		StyleHelper helper = StyleHelper.getInstance();
		ImageButton back = new ImageButton(
				helper.getImageButtonStyleRound("widgets/icon-back"));

		Table scrollTable = new Table();
		// ScrollPane scroll = new ScrollPane(scrollTable);

		Label gameplay = new Label(_("settings_title_gameplay"),
				helper.getLabelStyle(40));
		Label zoom = new Label(_("settings_title_zoom"), helper.getLabelStyle());
		Label colorBlindness = new Label(_("settings_title_color_blindness"),
				helper.getLabelStyle());
		Label sound = new Label(_("settings_title_sound"),
				helper.getLabelStyle(40));
		Label music = new Label(_("settings_title_music"),
				helper.getLabelStyle());
		Label effects = new Label(_("settings_title_effects"),
				helper.getLabelStyle());
		Label profile = new Label(_("settings_title_profile"),
				helper.getLabelStyle(40));

		zoomCheckBox = new CheckBox("", helper.getCheckBoxStyle());
		colorBlindnessCheckBox = new CheckBox("", helper.getCheckBoxStyle());

		musicSlider = new Slider(0, 100, 1, false, helper.getSliderStyle());
		effectsSlider = new Slider(0, 100, 1, false, helper.getSliderStyle());

		musicSlider.setValue(50);
		effectsSlider.setValue(50);

		TextButton editProfile = new TextButton(
				_("settings_button_edit_profile"), helper.getTextButtonStyle());

		// add listeners
		back.addListener(new LogicalPredecessorListener());

		SettingListener settingListener = new SettingListener();

		zoomCheckBox.addListener(settingListener);
		colorBlindnessCheckBox.addListener(settingListener);

		musicSlider.addListener(settingListener);
		effectsSlider.addListener(settingListener);

		editProfile.addListener(new ClickListener() {
			@Override
			public void clicked(InputEvent event, float x, float y) {
				if (game.getProfileController().getCurrentProfile() != null) {
					Dialog dialog = new EditProfileDialog();
					dialog.show(stage);
				} else {
					Dialog dialog = new NotificationDialog(
							_("warning_no_profile_selected"));
					dialog.show(stage);
				}

			}
		});

		scrollTable.defaults().left().space(10);
		scrollTable.add(gameplay).row();
		scrollTable.add(zoom).expandX().padLeft(30);
		scrollTable.add(zoomCheckBox).size(50).center().row();
		scrollTable.add(colorBlindness).expandX().padLeft(30);
		scrollTable.add(colorBlindnessCheckBox).size(50).center().row();
		scrollTable.add(sound).row();
		scrollTable.add(music).padLeft(30);
		scrollTable.add(musicSlider).width(300).height(50).row();
		scrollTable.add(effects).padLeft(30);
		scrollTable.add(effectsSlider).width(300).height(50).row();
		scrollTable.add(profile).row();
		scrollTable.add(editProfile).width(300).height(75);

		scrollTable.pad(50).padRight(150);
		table.add(back).size(100).top().left();
		table.add(scrollTable).expand().fill();
		table.pad(30);

		onProfileChange(null);
	}
コード例 #9
0
  @SuppressWarnings("unchecked")
  @Override
  public void create(Table table) {
    lastEndTileX = -1;
    lastEndTileY = -1;
    startTileX = 1;
    startTileY = 1;

    // Create the map
    worldMap = new HierarchicalTiledGraph();
    int roomCount = 100;
    int roomMinSize = 2;
    int roomMaxSize = 8;
    int squashIterations = 100;
    worldMap.init(roomCount, roomMinSize, roomMaxSize, squashIterations);

    paths =
        (TiledSmoothableGraphPath<HierarchicalTiledNode>[]) new TiledSmoothableGraphPath[NUM_PATHS];
    for (int i = 0; i < NUM_PATHS; i++) {
      paths[i] = new TiledSmoothableGraphPath<HierarchicalTiledNode>();
    }
    numPaths = 0;
    heuristic = new TiledManhattanDistance<HierarchicalTiledNode>();
    IndexedAStarPathFinder<HierarchicalTiledNode> levelPathFinder =
        new IndexedAStarPathFinder<HierarchicalTiledNode>(worldMap, true);
    pathFinder = new HierarchicalPathFinder<HierarchicalTiledNode>(worldMap, levelPathFinder);
    pathSmoother =
        new PathSmoother<HierarchicalTiledNode, Vector2>(
            new TiledRaycastCollisionDetector<HierarchicalTiledNode>(worldMap));
    pathSmootherRequest = new PathSmootherRequest<HierarchicalTiledNode, Vector2>();

    requestPool =
        new Pool<MyPathFinderRequest>() {
          @Override
          protected MyPathFinderRequest newObject() {
            return new MyPathFinderRequest();
          }
        };
    PathFinderQueue<HierarchicalTiledNode> pathFinderQueue =
        new PathFinderQueue<HierarchicalTiledNode>(pathFinder);
    MessageManager.getInstance().addListener(pathFinderQueue, PF_REQUEST);

    scheduler = new LoadBalancingScheduler(100);
    scheduler.add(pathFinderQueue, 1, 0);

    renderer = new ShapeRenderer();
    inputProcessor = new TiledHierarchicalAStarInputProcessor(this);

    Table detailTable = new Table(container.skin);

    detailTable.row();
    checkSmooth = new CheckBox("[RED]S[]mooth Path", container.skin);
    checkSmooth.setChecked(smooth);
    checkSmooth.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            CheckBox checkBox = (CheckBox) event.getListenerActor();
            smooth = checkBox.isChecked();
            updatePath(true);
          }
        });
    detailTable.add(checkSmooth);

    detailTable.row();
    checkDiagonal = new CheckBox("Prefer [RED]D[]iagonal", container.skin);
    checkDiagonal.setChecked(worldMap.diagonal);
    checkDiagonal.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            CheckBox checkBox = (CheckBox) event.getListenerActor();
            worldMap.diagonal = checkBox.isChecked();
            updatePath(true);
          }
        });
    detailTable.add(checkDiagonal);

    detailTable.row();
    addSeparator(detailTable);

    detailTable.row();
    checkMetrics = new CheckBox("Calculate [RED]M[]etrics", container.skin);
    checkMetrics.setChecked(metrics);
    checkMetrics.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            CheckBox checkBox = (CheckBox) event.getListenerActor();
            metrics = checkBox.isChecked();
            updatePath(true);
          }
        });
    detailTable.add(checkMetrics);
    detailTable.row();
    addSeparator(detailTable);

    detailTable.row();
    sliderMillisAvailablePerFrame = new Slider(0.1f, 40f, 0.1f, false, container.skin);
    sliderMillisAvailablePerFrame.setValue(16);
    final Label labelMillisAvailablePerFrame =
        new Label(
            "Millis Available per Frame [[" + sliderMillisAvailablePerFrame.getValue() + "]",
            container.skin);
    detailTable.add(labelMillisAvailablePerFrame);
    detailTable.row();
    sliderMillisAvailablePerFrame.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            labelMillisAvailablePerFrame.setText(
                "Millis Available per Frame [[" + sliderMillisAvailablePerFrame.getValue() + "]");
          }
        });
    Table sliderMapfTable = new Table();
    sliderMapfTable.add(new Label("[RED]-[]  ", container.skin));
    sliderMapfTable.add(sliderMillisAvailablePerFrame);
    sliderMapfTable.add(new Label("  [RED]+[]", container.skin));
    detailTable.add(sliderMapfTable);

    detailWindow = createDetailWindow(detailTable);
  }