Java Code Examples for com.badlogic.gdx.files.FileHandle#nameWithoutExtension()

The following examples show how to use com.badlogic.gdx.files.FileHandle#nameWithoutExtension() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectData.java    From skin-composer with MIT License 6 votes vote down vote up
public Array<RecentFile> getRecentFiles() {
    Array<RecentFile> returnValue = new Array<>();
    int maxIndex = Math.min(MAX_RECENT_FILES, generalPref.getInteger("recentFilesCount", 0));
    for (int i = 0; i < maxIndex; i++) {
        String path = generalPref.getString("recentFile" + i);
        FileHandle file = new FileHandle(path);
        RecentFile recentFile = new RecentFile();
        recentFile.fileHandle = file;
        recentFile.name = file.nameWithoutExtension();
        if (file.exists()) {
            returnValue.add(recentFile);
        }
    }
    
    return returnValue;
}
 
Example 2
Source File: BatchConvertDialog.java    From talos with Apache License 2.0 5 votes vote down vote up
private void convertOne(FileHandle fileHandle) {
    String subPath;

    if (inputPathField.getText().length() == fileHandle.parent().path().length()) {
        subPath = File.separator;
    } else {
         subPath = fileHandle.parent().path().substring(inputPathField.getText().length() + 1) + File.separator;
    }
    String projectPath = outputPath + File.separator + "projects" +  File.separator + subPath + fileHandle.nameWithoutExtension() + ".tls";
    String runtimePath = outputPath + File.separator + "runtime" +  File.separator + subPath + fileHandle.nameWithoutExtension() + ".p";

    FileHandle projectDestination = Gdx.files.absolute(projectPath);
    FileHandle exportDestination = Gdx.files.absolute(runtimePath);

    String result = "ok";
    try {
        TalosMain.Instance().TalosProject().importFromLegacyFormat(fileHandle);
        // now that it's done save TLS file
        TalosMain.Instance().ProjectController().saveProject(projectDestination);
        TalosMain.Instance().TalosProject().exportProject(exportDestination);

    } catch (Exception e) {
        result = "nok";
    }

    String text = "converting: " + fileHandle.name() + "        " + result + "\n";


    logItems.add(new Label(text, getSkin()));
    logArea.setItems(logItems);
    Label lbl = logArea.getItems().get(logArea.getItems().size-1);
    logArea.setSelected(lbl);
    scrollPane.layout();
    scrollPane.scrollTo(0, 0, 0, 0);
}
 
Example 3
Source File: PolylineModuleWrapper.java    From talos with Apache License 2.0 5 votes vote down vote up
public void setTexture(String path) {
    FileHandle fileHandle = tryAndFineTexture(path);
    if(fileHandle.exists()) {
        TextureRegion region = new TextureRegion(new Texture(fileHandle));
        module.setRegion(fileHandle.nameWithoutExtension(), region);
        dropWidget.setDrawable(new TextureRegionDrawable(region));
    }
    filePath = fileHandle.path();
    regionName = fileHandle.nameWithoutExtension();
}
 
Example 4
Source File: TextureDropModuleWrapper.java    From talos with Apache License 2.0 5 votes vote down vote up
public void setTexture(String path) {
    FileHandle fileHandle = tryAndFindTexture(path);
    if(fileHandle.exists()) {
        Sprite region = new Sprite(new Texture(fileHandle));
        setModuleRegion(fileHandle.nameWithoutExtension(), region);
        dropWidget.setDrawable(new TextureRegionDrawable(region));
    }
    filePath = fileHandle.path();
    regionName = fileHandle.nameWithoutExtension();
}
 
Example 5
Source File: BvBWorkspace.java    From talos with Apache License 2.0 5 votes vote down vote up
public void updateParticle(FileHandle handle) {
    String name = handle.nameWithoutExtension();
    if(vfxLibrary.containsKey(name)) {
        ParticleEffectDescriptor descriptor = new ParticleEffectDescriptor();
        descriptor.setAssetProvider(TalosMain.Instance().TalosProject().getProjectAssetProvider());
        descriptor.load(handle);
        vfxLibrary.put(name, descriptor);

        skeletonContainer.updateEffect(name, descriptor);
    }
}
 
Example 6
Source File: MainController.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
private void updateRecentProjects() {
    Array<FileHandle> recentProjects = this.recentProjects.getRecentProjects();
    actorsFileMenu.miOpenRecent.setDisabled(recentProjects.size == 0);
    actorsFileMenu.pmOpenRecent.clear();
    for (final FileHandle file : recentProjects) {
        if (file.equals(getProject().getProjectFile())) continue;

        MenuItem menuItem = new MenuItem(file.nameWithoutExtension());
        menuItem.setShortcut(CommonUtils.ellipsize(file.path(), 72)); // Will use shortcut label to display file path
        menuItem.getShortcutCell().left().expandX();
        menuItem.getLabelCell().expand(false, false).left();
        menuItem.getImageCell().width(0); // Shrink image cell to zero, we don't need it
        menuItem.pack();
        menuItem.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeEvent event, Actor actor) {
                Gdx.app.postRunnable(new Runnable() {
                    @Override
                    public void run() {
                        final ProjectModel project = projectSerializer.loadProject(file);
                        if (project != null) {
                            globalActions.commonDialogs.checkUnsavedChanges(new Runnable() {
                                @Override
                                public void run() {
                                    modelService.setProject(project);
                                }
                            });
                        }
                    }
                });
            }
        });
        actorsFileMenu.pmOpenRecent.addItem(menuItem);
    }
}
 
Example 7
Source File: Theme.java    From Klooni1010 with GNU General Public License v3.0 4 votes vote down vote up
private Theme update(final FileHandle handle) {
    if (skin == null) {
        throw new NullPointerException("A Theme.skin must be set before updating any Theme instance");
    }

    final JsonValue json = new JsonReader().parse(handle.readString());

    name = handle.nameWithoutExtension();
    displayName = json.getString("name");
    price = json.getInt("price");

    JsonValue colors = json.get("colors");
    // Java won't allow unsigned integers, we need to use Long
    background = new Color((int) Long.parseLong(colors.getString("background"), 16));
    foreground = new Color((int) Long.parseLong(colors.getString("foreground"), 16));

    JsonValue buttonColors = colors.get("buttons");
    Color[] buttons = new Color[buttonColors.size];
    for (int i = 0; i < buttons.length; ++i) {
        buttons[i] = new Color((int) Long.parseLong(buttonColors.getString(i), 16));
        if (buttonStyles[i] == null) {
            buttonStyles[i] = new ImageButton.ImageButtonStyle();
        }
        // Update the style. Since every button uses an instance from this
        // array, the changes will appear on screen automatically.
        buttonStyles[i].up = skin.newDrawable("button_up", buttons[i]);
        buttonStyles[i].down = skin.newDrawable("button_down", buttons[i]);
    }

    currentScore = new Color((int) Long.parseLong(colors.getString("current_score"), 16));
    highScore = new Color((int) Long.parseLong(colors.getString("high_score"), 16));
    bonus = new Color((int) Long.parseLong(colors.getString("bonus"), 16));
    bandColor = new Color((int) Long.parseLong(colors.getString("band"), 16));
    textColor = new Color((int) Long.parseLong(colors.getString("text"), 16));

    emptyCell = new Color((int) Long.parseLong(colors.getString("empty_cell"), 16));

    JsonValue cellColors = colors.get("cells");
    cells = new Color[cellColors.size];
    for (int i = 0; i < cells.length; ++i) {
        cells[i] = new Color((int) Long.parseLong(cellColors.getString(i), 16));
    }

    String cellTextureFile = json.getString("cell_texture");
    cellTexture = SkinLoader.loadPng("cells/" + cellTextureFile);

    return this;
}