コード例 #1
0
  @Override
  public void update(float dt) {
    gridSlider.setValue(gridSize);
    zoomSlider.setValue(cam.zoom);

    stage.act();
    cam.update();
  }
コード例 #2
0
ファイル: ColorSampler.java プロジェクト: shadoq/lib.2xy.pl
 /** @param color */
 public void setColor(Color color) {
   colorR = color.r;
   colorG = color.g;
   colorB = color.b;
   colorA = color.a;
   if (sliderR != null) {
     sliderR.setValue(colorR * 100);
     sliderG.setValue(colorG * 100);
     sliderB.setValue(colorB * 100);
     sliderA.setValue(colorA * 100);
     setBtnColorSampleColor();
   }
 }
コード例 #3
0
  @Override
  public void render() {
    Gdx.gl.glClearColor(
        background.rgb.getRed() / 255f,
        background.rgb.getGreen() / 255f,
        background.rgb.getBlue() / 255f,
        background.rgb.getAlpha() / 255f);

    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    boolean hasUserInput = false;
    if (input.getText() != null && input.getText().length() != 0) hasUserInput = true;
    final String text =
        hasUserInput ? input.getText() : "The quick brown fox jumps over the lazy dog";

    float scale = scaleSlider.getValue();

    cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    batch.setProjectionMatrix(cam.combined);

    batch.getProjectionMatrix().scale(scale, scale, 0.0f);

    //		batch.getTransformMatrix().scale(scale, scale, 0.0f);

    if (fonts != null) {
      batch.begin();

      int x = 5;
      int y = 0;

      for (FontElement e : fonts) {
        y += e.font.getLineHeight() + 5;
        String str = hasUserInput ? text : e.name + " " + e.size + ": " + text;
        e.font.draw(batch, str, x, y);
      }

      batch.end();
    }

    input.setY(Gdx.graphics.getHeight() - input.getHeight() - 5);
    labelInput.setY(Gdx.graphics.getHeight() - input.getHeight() - 5);

    labelScale.setY(labelInput.getY() - labelInput.getHeight() - 5);
    scaleSlider.setY(input.getY() - input.getHeight() - 5);
    scaleAmt.setY(scaleSlider.getY());

    linearFiltering.setY(scaleSlider.getY() - scaleSlider.getHeight() - 10);

    stage.act();
    stage.draw();
  }
コード例 #4
0
 void loadPrefs() {
   debugBonesCheckbox.setChecked(prefs.getBoolean("debugBones", true));
   debugRegionsCheckbox.setChecked(prefs.getBoolean("debugRegions", false));
   debugMeshHullCheckbox.setChecked(prefs.getBoolean("debugMeshHull", false));
   debugMeshTrianglesCheckbox.setChecked(prefs.getBoolean("debugMeshTriangles", false));
   debugPathsCheckbox.setChecked(prefs.getBoolean("debugPaths", true));
   premultipliedCheckbox.setChecked(prefs.getBoolean("premultiplied", true));
   loopCheckbox.setChecked(prefs.getBoolean("loop", false));
   speedSlider.setValue(prefs.getFloat("speed", 0.3f));
   mixSlider.setValue(prefs.getFloat("mix", 0.3f));
   scaleSlider.setValue(prefs.getFloat("scale", 1));
   skeletonX = prefs.getInteger("x", 0);
   skeletonY = prefs.getInteger("y", 0);
   animationList.setSelected(prefs.getString("animationName", null));
   skinList.setSelected(prefs.getString("skinName", null));
   prefsLoaded = true;
 }
コード例 #5
0
	@Override
	public void onProfileChange(Profile profile) {
		Setting setting = settingController.getCurrentSetting();
		if (setting != null && areWidgetsInitialized()) {
			musicSlider.setValue(setting.getVolumeMusic() * 100);
			effectsSlider.setValue(setting.getVolumeEffects() * 100);
			zoomCheckBox.setChecked(setting.isZoomEnabled());
			colorBlindnessCheckBox.setChecked(setting.isColorblindEnabled());
		} else if (areWidgetsInitialized()) {
			musicSlider.setValue(50);
			effectsSlider.setValue(50);
			zoomCheckBox.setChecked(false);
			colorBlindnessCheckBox.setChecked(false);

		}

	}
コード例 #6
0
 void savePrefs() {
   if (!prefsLoaded) return;
   prefs.putBoolean("debugBones", debugBonesCheckbox.isChecked());
   prefs.putBoolean("debugRegions", debugRegionsCheckbox.isChecked());
   prefs.putBoolean("debugMeshHull", debugMeshHullCheckbox.isChecked());
   prefs.putBoolean("debugMeshTriangles", debugMeshTrianglesCheckbox.isChecked());
   prefs.putBoolean("debugPaths", debugPathsCheckbox.isChecked());
   prefs.putBoolean("premultiplied", premultipliedCheckbox.isChecked());
   prefs.putBoolean("loop", loopCheckbox.isChecked());
   prefs.putFloat("speed", speedSlider.getValue());
   prefs.putFloat("mix", mixSlider.getValue());
   prefs.putFloat("scale", scaleSlider.getValue());
   prefs.putInteger("x", skeletonX);
   prefs.putInteger("y", skeletonY);
   TrackEntry current = state.getCurrent(0);
   if (current != null) {
     String name = current.animation.name;
     if (name.equals("<empty>")) name = current.next == null ? "" : current.next.animation.name;
     prefs.putString("animationName", name);
   }
   if (skinList.getSelected() != null) prefs.putString("skinName", skinList.getSelected());
   prefs.flush();
 }
コード例 #7
0
    void initialize() {
      skin.getFont("default").getData().markupEnabled = true;

      for (int i = 0; i < 6; i++) trackButtons.add(new TextButton(i + "", skin, "toggle"));

      animationList.getSelection().setRequired(false);

      premultipliedCheckbox.setChecked(true);

      loopCheckbox.setChecked(true);

      scaleSlider.setValue(1);
      scaleSlider.setSnapToValues(new float[] {1, 1.5f, 2, 2.5f, 3, 3.5f}, 0.01f);

      mixSlider.setValue(0.3f);
      mixSlider.setSnapToValues(new float[] {1, 1.5f, 2, 2.5f, 3, 3.5f}, 0.1f);

      speedSlider.setValue(1);
      speedSlider.setSnapToValues(new float[] {0.5f, 0.75f, 1, 1.25f, 1.5f, 2, 2.5f}, 0.1f);

      alphaSlider.setValue(1);
      alphaSlider.setDisabled(true);

      window.setMovable(false);
      window.setResizable(false);
      window.setKeepWithinStage(false);
      window.setX(-3);
      window.setY(-2);

      window.getTitleLabel().setColor(new Color(0.76f, 1, 1, 1));
      window.getTitleTable().add(openButton).space(3);
      window.getTitleTable().add(minimizeButton).width(20);

      skinScroll.setFadeScrollBars(false);

      animationScroll.setFadeScrollBars(false);
    }
コード例 #8
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);
    }
コード例 #9
0
ファイル: ColorSampler.java プロジェクト: shadoq/lib.2xy.pl
  private void initalize() {

    //
    // Wygenerowanie buttonow
    //
    sliderR = GuiResource.slider(0, 100, 1, "colorDialogSliderR", skin);
    sliderG = GuiResource.slider(0, 100, 1, "colorDialogSliderG", skin);
    sliderB = GuiResource.slider(0, 100, 1, "colorDialogSliderB", skin);
    sliderA = GuiResource.slider(0, 100, 1, "colorDialogSliderA", skin);

    //
    // Fix slider FixScroll
    //
    sliderR.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
          }
        });

    sliderG.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
          }
        });

    sliderB.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
          }
        });

    sliderA.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
          }
        });

    labelTextR = GuiResource.label("R", "colorTextDialogLabelR", skin);
    labelTextG = GuiResource.label("G", "colorTextDialogLabelG", skin);
    labelTextB = GuiResource.label("B", "colorTextDialogLabelB", skin);
    labelTextA = GuiResource.label("A", "colorTextDialogLabelA", skin);

    labelR = GuiResource.label("red", "colorDialogLabelR", skin);
    labelG = GuiResource.label("green", "colorDialogLabelG", skin);
    labelB = GuiResource.label("blue", "colorDialogLabelB", skin);
    labelA = GuiResource.label("alpha", "colorDialogLabelA", skin);

    color = new Color();

    //
    // Tworzenie image textury podgladu
    //
    pixmap = new Pixmap(128, 32, Pixmap.Format.RGBA8888); // Pixmap.Format.RGBA8888);
    pixmap.setColor(1, 1, 1, 1);
    pixmap.fillRectangle(0, 0, 128, 32);
    texture = new Texture(pixmap);
    region = new TextureRegion(texture);
    imageActor = new Image(region);

    //
    // Podpiecie akcji do buttonow i sliderow
    //
    sliderR.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float value = sliderR.getValue();
            colorR = value / 100;
            setBtnColorSampleColor();
          }
        });

    sliderG.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float value = sliderG.getValue();
            colorG = value / 100;
            setBtnColorSampleColor();
          }
        });

    sliderB.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float value = sliderB.getValue();
            colorB = value / 100;
            setBtnColorSampleColor();
          }
        });

    sliderA.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float value = sliderA.getValue();
            colorA = value / 100;
            setBtnColorSampleColor();
          }
        });

    add(labelTextR).left().width(10);
    add(sliderR).left().fillX().expandX();
    add(labelR).left().width(20);
    row();
    add(labelTextG).left().width(10);
    add(sliderG).left().fillX().expandX();
    add(labelG).left().width(20);
    row();
    add(labelTextB).left().width(10);
    add(sliderB).left().fillX().expandX();
    add(labelB).left().width(20);

    if (alphaChanel) {
      row();
      add(labelTextA).left().width(10);
      add(sliderA).left().fillX().expandX();
      add(labelA).left().width(20);
    }

    row();
    add().left().width(Cfg.gridX1);
    add(imageActor).left().colspan(2);

    //
    // Inicjacja stanów
    //
    if (colorR < 0) {
      colorR = 0;
    }
    if (colorR > 1) {
      colorR = 1;
    }
    if (colorG < 0) {
      colorG = 0;
    }
    if (colorG > 1) {
      colorG = 1;
    }
    if (colorB < 0) {
      colorB = 0;
    }
    if (colorB > 1) {
      colorB = 1;
    }
    if (colorA < 0) {
      colorA = 0;
    }
    if (colorA > 1) {
      colorA = 1;
    }

    sliderR.setValue(colorR * 100);
    sliderG.setValue(colorG * 100);
    sliderB.setValue(colorB * 100);
    sliderA.setValue(colorA * 100);
    setBtnColorSampleColor();
  }
コード例 #10
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);
	}
コード例 #11
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);
  }
コード例 #12
0
  @Override
  public void create() {

    //		Gdx.gl.glClearColor(
    //			background.rgb.getRed() / 255f,
    //			background.rgb.getGreen() / 255f,
    //			background.rgb.getBlue() / 255f,
    //			background.rgb.getAlpha() / 255f);
    //		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    //		Gdx.graphics.setContinuousRendering(false);
    //		Gdx.graphics.requestRendering();

    cam = new OrthographicCamera();
    batch = new SpriteBatch();

    stage = new Stage();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    input = new TextField("", skin);

    // can't use Table here since it will conflict with the Swing Table toolkit
    // this is why static is shit -.-
    labelInput = new Label("Sample Text:", skin);
    labelScale = new Label("Scale:", skin);
    scaleAmt = new Label("1.0", skin);

    labelInput.setHeight(input.getHeight());
    labelInput.setPosition(10, Gdx.graphics.getHeight() - labelInput.getHeight() - 5);
    input.setPosition(
        labelInput.getX() + labelInput.getWidth() + 10,
        Gdx.graphics.getHeight() - input.getHeight() - 5);

    scaleSlider = new Slider(0, 3, 0.05f, false, skin);
    scaleSlider.setSnapToValues(new float[] {0.0f, 0.5f, 1.0f}, 0.05f);

    scaleSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent arg0, Actor arg1) {
            scaleAmt.setText(String.format("%.2f", scaleSlider.getValue()));
          }
        });
    scaleSlider.setValue(1.0f);
    scaleAmt.setText(String.format("%.2f", scaleSlider.getValue()));

    linearFiltering = new ToggleBox("Linear Filtering", skin);
    linearFiltering.addListener(
        new ClickListener() {
          public void clicked(InputEvent ev, float x, float y) {
            updateFiltering();
          }
        });

    scaleAmt.setHeight(scaleSlider.getHeight());
    labelScale.setHeight(scaleSlider.getHeight());

    labelScale.setPosition(
        input.getX() - 10 - labelScale.getWidth(), labelInput.getY() - labelInput.getHeight() - 5);
    scaleSlider.setPosition(input.getX(), input.getY() - input.getHeight() - 5);
    scaleAmt.setPosition(scaleSlider.getX() + scaleSlider.getWidth() + 5, scaleSlider.getY());

    linearFiltering.setPosition(input.getX(), scaleSlider.getY() - scaleSlider.getHeight() - 10);

    Gdx.input.setInputProcessor(stage);
    stage.addActor(labelInput);
    stage.addActor(input);
    stage.addActor(labelScale);
    stage.addActor(scaleSlider);
    stage.addActor(scaleAmt);
    stage.addActor(linearFiltering);

    myButton = new TextButton("Blah", skin);
  }
コード例 #13
0
  public LevelEditorGameState(GameStateManager gsm) {
    super(gsm);

    bitmapFont = new BitmapFont();
    stage = new Stage();

    Skin skin = new Skin(Gdx.files.internal("uiskin.json"));
    Label titleLabel = new Label("Level Editor", skin);
    stage.addActor(titleLabel);
    Table table = new Table();
    stage.addActor(table);
    table.setSize(V_WIDTH / 3, V_HEIGHT);
    table.setPosition(0, 0);
    table.debug(); // show debug shit

    int i = 0;
    for (E_TOOL e : E_TOOL.values()) {
      // for use in the input listener
      final E_TOOL temp = e;
      TextButton b = new TextButton(e.name(), skin);
      b.addListener(
          new InputListener() {
            @Override
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
              current_Tool = temp;
              return false;
            }
          });

      if (++i % 2 == 0) {
        table.row();
      }
      table.add(b);
    }

    table.row();

    table.add(new Label("Zoom", skin));
    zoomSlider = new Slider(0.1f, 10.0f, 0.1f, false, skin);
    zoomSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            cam.zoom = zoom = zoomSlider.getValue();
          }
        });
    table.add(zoomSlider);

    table.row();

    table.add(new Label("Grid", skin));
    gridSlider = new Slider(1, 20, 1, false, skin);
    gridSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            gridSize = (int) gridSlider.getValue();
          }
        });
    table.add(gridSlider);

    final List pointTypeList = new List(skin);
    pointTypeList.setItems(Point.TYPE.values());
    pointTypeList.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            point_Type = (Point.TYPE) pointTypeList.getSelected();
          }
        });

    final List shapeTypeList = new List(skin);
    shapeTypeList.setItems(Shape.TYPE.values());
    shapeTypeList.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            shape_Type = (Shape.TYPE) shapeTypeList.getSelected();
          }
        });

    table.row();
    table.add(pointTypeList);

    table.row();
    table.add(shapeTypeList);

    current_Tool = E_TOOL.SELECT;
    point_Type = Point.TYPE.SPAWN;
    shape_Type = Shape.TYPE.WALL;

    gridSize = 2;
    width = V_WIDTH;
    height = V_HEIGHT;
    zoom = 5;

    cam.zoom = zoom;

    filename = "blacklevel.lvl";
    loadLevel(filename);

    setInputProcessor(new InputMultiplexer(stage, new EditorInputAdapter()));
  }
コード例 #14
0
  public StatusBarPanel() {
    setTouchable(Touchable.childrenOnly);

    moneyLabel = makeValueLabel("0");
    moneyIncomeLabel = makeValueLabel("0");
    moneyExpensesLabel = makeValueLabel("0");
    experienceLabel = makeValueLabel("0");
    populationLabel = makeValueLabel("0");
    employmentLabel = makeValueLabel("0");
    gameSpeedLabel = makeValueLabel(SceneManager.activeScene().getTimeMultiplier() + "x");
    starRatingBar = new RatingBar(0, 5);

    whiteSwatch = TowerAssetManager.texture(TowerAssetManager.WHITE_SWATCH);
    backgroundTexture = TowerAssetManager.texture("hud/window-bg.png");
    backgroundTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    defaults();
    center();

    // TODO these need to be moved to the resources file
    row().pad(devicePixel(2)).padBottom(0);
    add(makeHeader("MONEY", Color.LIGHT_GRAY)).center();
    add(makeHeader("INCOME", Color.LIGHT_GRAY)).center();
    add(makeHeader("EXPENSES", Color.LIGHT_GRAY)).center();
    add(makeHeader("POPULATION", Color.LIGHT_GRAY)).center();
    add(makeHeader("EMPLOYMENT", Color.LIGHT_GRAY)).center();
    Label gameSpeedHeader = makeHeader("GAME SPEED", Color.LIGHT_GRAY);
    add(gameSpeedHeader).center();
    Label starRatingHeader = makeHeader("STAR RATING", Color.LIGHT_GRAY);
    add(starRatingHeader).center();

    row().pad(devicePixel(2)).padTop(0);
    add(moneyLabel);
    add(moneyIncomeLabel);
    add(moneyExpensesLabel);
    add(populationLabel);
    add(employmentLabel);
    add(gameSpeedLabel);
    add(starRatingBar);

    if (TowerConsts.ENABLE_NEWS_TICKER) {
      row().pad(devicePixel(2)).padLeft(devicePixel(-4)).padRight(devicePixel(-4));
      add(new HorizontalRule(Colors.ICS_BLUE_SEMI_TRANSPARENT, 1)).fillX().colspan(7);

      row().pad(0);
      add(new NewsTickerPanel()).colspan(7).left();
    }

    dubai7StarWonder = AchievementEngine.instance().findById("dubai-7-star-wonder");

    gameSpeedOverlay = new PopOver();
    gameSpeedOverlay.alignArrow(Align.left);
    gameSpeedOverlay
        .add(new Image(TowerAssetManager.textureFromAtlas("snail", "hud/buttons.txt")))
        .center();
    gameSpeedSlider =
        new Slider(
            TowerConsts.GAME_SPEED_MIN,
            TowerConsts.GAME_SPEED_MAX,
            0.5f,
            false,
            TowerAssetManager.getCustomSkin());
    gameSpeedOverlay.add(gameSpeedSlider).width(devicePixel(150));
    gameSpeedOverlay
        .add(new Image(TowerAssetManager.textureFromAtlas("rabbit", "hud/buttons.txt")))
        .center();
    gameSpeedOverlay.pack();
    gameSpeedOverlay.setVisible(false);

    gameSpeedSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float remainder = gameSpeedSlider.getValue() * 2f / 2f;
            SceneManager.activeScene().setTimeMultiplier(remainder);
          }
        });

    SceneManager.activeScene().events().register(this);

    starRatingPopOver = new TowerRatingPopOver();
    starRatingPopOver.setVisible(false);

    pack();

    VibrateClickListener gameSpeedToggleListener =
        new VibrateClickListener() {
          @Override
          public void onClick(InputEvent event, float x, float y) {
            gameSpeedOverlay.toggle(StatusBarPanel.this, gameSpeedLabel);
          }
        };
    gameSpeedHeader.addListener(gameSpeedToggleListener);
    gameSpeedLabel.addListener(gameSpeedToggleListener);

    VibrateClickListener starRatingListener =
        new VibrateClickListener() {
          @Override
          public void onClick(InputEvent event, float x, float y) {
            starRatingPopOver.toggle(StatusBarPanel.this, starRatingBar);
          }
        };
    starRatingHeader.addListener(starRatingListener);
    starRatingBar.addListener(starRatingListener);

    setTouchable(Touchable.enabled);
    addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {}
        });
  }
コード例 #15
0
 @Subscribe
 public void TowerScene_onGameSpeedChange(GameSpeedChangeEvent event) {
   gameSpeedSlider.setValue(event.scene.getTimeMultiplier());
   gameSpeedLabel.setText(event.scene.getTimeMultiplier() + "x");
 }
コード例 #16
0
  @Override
  public void render() {
    long timeToRun = (long) (sliderMillisAvailablePerFrame.getValue() * 1000000f);
    scheduler.run(timeToRun);

    renderer.begin(ShapeType.Filled);
    int level = 0;
    worldMap.setLevel(level);
    int xMax = HierarchicalTiledGraph.sizeX[level];
    int yMax = HierarchicalTiledGraph.sizeY[level];
    for (int x = 0; x < xMax; x++) {
      for (int y = 0; y < yMax; y++) {
        switch (worldMap.getNode(x, y).type) {
          case TiledNode.TILE_FLOOR:
            renderer.setColor(Color.WHITE);
            break;
          case TiledNode.TILE_WALL:
            renderer.setColor(Color.GRAY);
            break;
          default:
            renderer.setColor(Color.BLACK);
            break;
        }
        renderer.rect(x * width, y * width, width, width);
      }
    }

    // Draw path nodes
    for (int p = 0; p < numPaths; p++) {
      TiledSmoothableGraphPath<HierarchicalTiledNode> path = paths[p];
      int nodeCount = path.getCount();
      if (nodeCount == 0) break;
      renderer.setColor(p % 2 == 0 ? Color.RED : Color.ORANGE);
      for (int i = 0; i < nodeCount; i++) {
        HierarchicalTiledNode node = path.nodes.get(i);
        renderer.rect(node.x * width, node.y * width, width, width);
      }
    }

    if (smooth) {
      renderer.end();
      renderer.begin(ShapeType.Line);
      // Draw lines between path nodes
      for (int p = 0; p < numPaths; p++) {
        TiledSmoothableGraphPath<HierarchicalTiledNode> path = paths[p];
        int nodeCount = path.getCount();
        if (nodeCount > 0) {
          float hw = width / 2f;
          HierarchicalTiledNode prevNode = path.nodes.get(0);
          renderer.setColor(p % 2 == 0 ? Color.RED : Color.ORANGE);
          for (int i = 1; i < nodeCount; i++) {
            HierarchicalTiledNode node = path.nodes.get(i);
            renderer.line(
                node.x * width + hw,
                node.y * width + hw,
                prevNode.x * width + hw,
                prevNode.y * width + hw);
            prevNode = node;
          }
        }
      }
    }

    // Draw the lower level node of the buildings (usually a tile close to the center of mass)
    level = 1;
    worldMap.setLevel(level);
    xMax = HierarchicalTiledGraph.sizeX[level];
    yMax = HierarchicalTiledGraph.sizeY[level];
    renderer.end();
    renderer.begin(ShapeType.Line);
    renderer.setColor(Color.MAROON);
    float hw = width * .5f;
    for (int x = 0; x < xMax; x++) {
      for (int y = 0; y < yMax; y++) {
        HierarchicalTiledNode lln = worldMap.getNode(x, y).getLowerLevelNode();
        renderer.circle(lln.x * width + hw, lln.y * width + hw, hw);
      }
    }

    renderer.end();
  }
コード例 #17
0
ファイル: UITest.java プロジェクト: ElEsteban/libgdx
  @Override
  public void create() {
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    texture1 = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
    texture2 = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    TextureRegion image = new TextureRegion(texture1);
    TextureRegion imageFlipped = new TextureRegion(image);
    imageFlipped.flip(true, true);
    TextureRegion image2 = new TextureRegion(texture2);
    // stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false, new
    // PolygonSpriteBatch());
    stage = new Stage();
    // stage.setViewport(new ExtendViewport(800, 480));
    Gdx.input.setInputProcessor(stage);

    // Group.debug = true;

    ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class));
    style.imageUp = new TextureRegionDrawable(image);
    style.imageDown = new TextureRegionDrawable(imageFlipped);
    ImageButton iconButton = new ImageButton(style);

    Button buttonMulti = new TextButton("Multi\nLine\nToggle", skin, "toggle");
    Button imgButton = new Button(new Image(image), skin);
    Button imgToggleButton = new Button(new Image(image), skin, "toggle");

    Label myLabel = new Label("this is some text.", skin);
    myLabel.setWrap(true);

    Table t = new Table();
    t.row();
    t.add(myLabel);

    t.layout();

    CheckBox checkBox = new CheckBox("Check me", skin);
    final Slider slider = new Slider(0, 10, 1, false, skin);
    TextField textfield = new TextField("", skin);
    textfield.setMessageText("Click here!");
    SelectBox dropdown = new SelectBox(skin);
    dropdown.setItems(
        "Android1",
        "Windows1",
        "Linux1",
        "OSX1",
        "Android2",
        "Windows2",
        "Linux2",
        "OSX2",
        "Android3",
        "Windows3",
        "Linux3",
        "OSX3",
        "Android4",
        "Windows4",
        "Linux4",
        "OSX4",
        "Android5",
        "Windows5",
        "Linux5",
        "OSX5",
        "Android6",
        "Windows6",
        "Linux6",
        "OSX6",
        "Android7",
        "Windows7",
        "Linux7",
        "OSX7");
    dropdown.setSelected("Linux6");
    Image imageActor = new Image(image2);
    ScrollPane scrollPane = new ScrollPane(imageActor);
    List list = new List(skin);
    list.setItems(listEntries);
    list.getSelection().setMultiple(true);
    list.getSelection().setRequired(false);
    // list.getSelection().setToggle(true);
    ScrollPane scrollPane2 = new ScrollPane(list, skin);
    scrollPane2.setFlickScroll(false);
    SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false, skin, "default-horizontal");
    fpsLabel = new Label("fps:", skin);

    // configures an example of a TextField in password mode.
    final Label passwordLabel = new Label("Textfield in password mode: ", skin);
    final TextField passwordTextField = new TextField("", skin);
    passwordTextField.setMessageText("password");
    passwordTextField.setPasswordCharacter('*');
    passwordTextField.setPasswordMode(true);

    // window.debug();
    Window window = new Window("Dialog", skin);
    window.getButtonTable().add(new TextButton("X", skin)).height(window.getPadTop());
    window.setPosition(0, 0);
    window.defaults().spaceBottom(10);
    window.row().fill().expandX();
    window.add(iconButton);
    window.add(buttonMulti);
    window.add(imgButton);
    window.add(imgToggleButton);
    window.row();
    window.add(checkBox);
    window.add(slider).minWidth(100).fillX().colspan(3);
    window.row();
    window.add(dropdown);
    window.add(textfield).minWidth(100).expandX().fillX().colspan(3);
    window.row();
    window.add(splitPane).fill().expand().colspan(4).maxHeight(200);
    window.row();
    window.add(passwordLabel).colspan(2);
    window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2);
    window.row();
    window.add(fpsLabel).colspan(4);
    window.pack();

    // stage.addActor(new Button("Behind Window", skin));
    stage.addActor(window);

    textfield.setTextFieldListener(
        new TextFieldListener() {
          public void keyTyped(TextField textField, char key) {
            if (key == '\n') textField.getOnscreenKeyboard().show(false);
          }
        });

    slider.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("UITest", "slider: " + slider.getValue());
          }
        });

    iconButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            new Dialog("Some Dialog", skin, "dialog") {
              protected void result(Object object) {
                System.out.println("Chosen: " + object);
              }
            }.text("Are you enjoying this demo?")
                .button("Yes", true)
                .button("No", false)
                .key(Keys.ENTER, true)
                .key(Keys.ESCAPE, false)
                .show(stage);
          }
        });
  }
コード例 #18
0
  /**
   * by which menu Screen this option screen was called
   *
   * @param pScreen
   */
  public OptionsScreen(MenuScreen pScreen) {
    screen = pScreen;
    game = screen.game;
    stage = new Stage();
    stage.setViewport(800, 480, false);
    skin = new Skin(Gdx.files.internal("ui/myskin.json"));

    Table table = new Table();
    table.setSize(800, 480);

    Label title = new Label("options", skin);
    title.setFontScale(2f);
    table.add(title).colspan(2).align(Align.center);
    table.row();

    Label namel = new Label("name:", skin);
    table.add(namel);

    TextField name = new TextField("", skin);
    table.add(name);
    table.row();

    Label graphicl = new Label("graphic:", skin);
    table.add(graphicl);

    CheckBox graphic = new CheckBox("", skin);
    table.add(graphic);
    table.row();

    Label soundl = new Label("sound:", skin);
    table.add(soundl);

    final Slider sound = new Slider(0, 100, 1, false, skin);
    sound.setValue(game.preferences.getInteger("volume", 100));
    table.add(sound);
    table.row();

    Label themel = new Label("theme:", skin);
    table.add(themel);

    String[] items = {"cool", "mega", "awesome"};
    SelectBox theme = new SelectBox(items, skin);

    theme.getSelection();
    table.add(theme);
    table.row();

    TextButton back = new TextButton("back to menu", skin);
    back.addListener(
        new ClickListener() {
          public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
            stage.addAction(
                Actions.sequence(
                    Actions.moveTo(800, 0, 0.5f),
                    new Action() {

                      @Override
                      public boolean act(float delta) {

                        game.preferences.putInteger("volume", (int) sound.getValue());
                        game.preferences.flush();

                        Resources.page_turn.play();
                        screen.game.setScreen(screen);
                        return false;
                      }
                    }));
          }
        });
    table.add(back).colspan(2).align(Align.center).padTop(20);

    stage.addActor(table);
    stage.addAction(Actions.moveTo(800, 0));
    stage.addAction(Actions.moveTo(0, 0, 0.5f));

    Gdx.input.setInputProcessor(stage);
  }