Пример #1
0
  @Override
  protected void build(Controller controller) {

    widget = new Image();

    ApplicationAssets assets = controller.getApplicationAssets();
    Skin skin = assets.getSkin();
    I18N i18n = assets.getI18N();

    this.time =
        new TextField("", skin) {
          @Override
          public float getPrefWidth() {
            return IMAGE_WIDTH;
          }
        };

    IconButton dup = new IconButton("copy24x24", skin);
    dup.setTooltip(i18n.m("frames.duplicate"));
    dup.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            timeline.duplicate(FrameWidget.this);
          }
        });

    IconButton delete = new IconButton("recycle24x24", skin);
    delete.setTooltip(i18n.m("frames.delete"));
    delete.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            timeline.delete(FrameWidget.this);
          }
        });

    top = new Table();
    top.setVisible(false);
    top.add(dup).left();
    top.add(delete).expandX().right();

    getImage().setScaling(Scaling.fit);
    topCell = add().expandX().fillX();
    row();
    add(widget).height(IMAGE_HEIGHT).width(IMAGE_WIDTH);
    row();
    add(time);
  }
Пример #2
0
  /**
   * Attempts to save the contents of the {@link #mesh} to a file located in the {@link
   * GameStructure#IMAGES_FOLDER}.
   *
   * @return true if everything went OK.
   */
  public boolean save() {
    if (!this.mesh.hasSomethingToSave()) return false;

    // Get a correct image name
    String savingPath = GameStructure.IMAGES_FOLDER;
    I18N i18n = this.controller.getApplicationAssets().getI18N();
    EditorGameAssets gameAssets = this.controller.getEditorGameAssets();
    FileHandle savingDir = gameAssets.resolve(savingPath);
    if (!savingDir.exists()) {
      savingDir.mkdirs();
    }
    String name = i18n.m("element");
    savingPath += name;
    FileHandle savingImage = null;
    int i = 0;
    do {
      savingImage = gameAssets.resolve(savingPath + (++i) + ".png");
    } while (savingImage.exists());

    // Get a correct thumbnail name
    String thumbSavingPath = GameStructure.THUMBNAILS_PATH;
    FileHandle thumbSavingDir = gameAssets.resolve(thumbSavingPath);
    if (!thumbSavingDir.exists()) {
      thumbSavingDir.mkdirs();
    }

    thumbSavingPath += name;
    FileHandle thumbSavingImage = null;
    i = 0;
    do {
      thumbSavingImage = gameAssets.resolve(thumbSavingPath + (++i) + ".png");
    } while (thumbSavingImage.exists());

    this.mesh.save(this.savePath = savingImage, this.thumbSavePath = thumbSavingImage);

    return true;
  }