Example usage for com.badlogic.gdx.files FileHandle toString

List of usage examples for com.badlogic.gdx.files FileHandle toString

Introduction

In this page you can find the example usage for com.badlogic.gdx.files FileHandle toString.

Prototype

public String toString() 

Source Link

Usage

From source file:com.badlogic.gdx.tests.utils.AssetsFileGenerator.java

License:Apache License

private static final void traverse(FileHandle directory, String base, StringBuffer list) {
    if (directory.name().equals(".svn"))
        return;//  ww w .ja v  a 2s.  c o  m
    String dirName = directory.toString().replace("\\", "/").replace(base, "") + "/";
    System.out.println(dirName);
    for (FileHandle file : directory.list()) {
        if (file.isDirectory()) {
            traverse(file, base, list);
        } else {
            String fileName = file.toString().replace("\\", "/").replace(base, "");
            if (fileName.endsWith(".png") || fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) {
                list.append("i:" + fileName + "\n");
                System.out.println(fileName);
            } else if (fileName.endsWith(".glsl") || fileName.endsWith(".fnt") || fileName.endsWith(".pack")
                    || fileName.endsWith(".obj") || file.extension().equals("") || fileName.endsWith("txt")) {
                list.append("t:" + fileName + "\n");
                System.out.println(fileName);
            } else {
                if (fileName.endsWith(".mp3") || fileName.endsWith(".ogg") || fileName.endsWith(".wav"))
                    continue;
                list.append("b:" + fileName + "\n");
                System.out.println(fileName);
            }
        }
    }
}

From source file:com.wotf.gui.view.SessionLocal.java

/**
 * {@inheritDoc}//from   w w  w.  j av a 2s .c o m
 */
@Override
public void show() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);// Make the stage consume events
    //System.out.println(Gdx.files.internal("maps"));
    skin = new Skin(Gdx.files.internal("uiskin.json"));
    teams = new List(skin);

    // Alle teams en labels hiervoor.
    Table teamstable = new Table();
    Table mapstable = new Table();
    Table settingstable = new Table();
    Table teamselecttable = new Table();
    teamstable.setBackground(new NinePatchDrawable(getNinePatch(("GUI/tblbg.png"), 150, 150, 160, 160)));
    mapstable.setBackground(new NinePatchDrawable(getNinePatch(("GUI/tblbg.png"), 220, 220, 160, 160)));
    teamselecttable.setBackground(new NinePatchDrawable(getNinePatch(("GUI/tblbg.png"), 100, 100, 160, 160)));

    Label selectteamlabel = new Label("Team selection", skin);
    teamselecttable.add(selectteamlabel).padBottom(15);
    teamselecttable.row();
    TextButton btnteamalpha = new TextButton("Alpha", skin); // Use the initialized skin
    btnteamalpha.setColor(Color.BLUE);
    btnteamalpha.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Team teamalpha = new Team("Alpha", Color.BLUE);
            teamalpha.setPlayer(defaultPlayer);
            teamalpha.setColorname(teamalpha.getColor().toString());

            int selectedunitcount = Integer.parseInt(unitbox.getSelected().toString());
            addUnitsSingleTeam(selectedunitcount, teamalpha);

            btnteamalpha.setTouchable(Touchable.disabled);
            btnteamalpha.setColor(Color.LIGHT_GRAY);
        }
    });

    teamselecttable.add(btnteamalpha).padBottom(10).width(150).height(50);
    teamselecttable.row();
    TextButton btnteambeta = new TextButton("Beta", skin); // Use the initialized skin
    btnteambeta.setColor(Color.CORAL);
    btnteambeta.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Team teambeta = new Team("Beta", Color.CORAL);
            teambeta.setPlayer(defaultPlayer);
            teambeta.setColorname(teambeta.getColor().toString());

            int selectedunitcount = Integer.parseInt(unitbox.getSelected().toString());
            addUnitsSingleTeam(selectedunitcount, teambeta);

            btnteambeta.setTouchable(Touchable.disabled);
            btnteambeta.setColor(Color.LIGHT_GRAY);
        }
    });
    teamselecttable.add(btnteambeta).padBottom(10).width(150).height(50);
    teamselecttable.row();
    TextButton btnteamgamma = new TextButton("Gamma", skin); // Use the initialized skin
    btnteamgamma.setColor(Color.GREEN);
    btnteamgamma.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Team teamgamma = new Team("Gamma", Color.GREEN);
            teamgamma.setPlayer(defaultPlayer);
            teamgamma.setColorname(teamgamma.getColor().toString());

            int selectedunitcount = Integer.parseInt(unitbox.getSelected().toString());
            addUnitsSingleTeam(selectedunitcount, teamgamma);

            btnteamgamma.setTouchable(Touchable.disabled);
            btnteamgamma.setColor(Color.LIGHT_GRAY);
        }
    });
    teamselecttable.add(btnteamgamma).width(150).height(50);
    teamselecttable.setWidth(200);
    teamselecttable.setHeight(320);
    teamselecttable.setPosition(500, 360);
    stage.addActor(teamselecttable);

    Label wotflabel = new Label("War of the Figures", skin);
    wotflabel.setPosition(Gdx.graphics.getWidth() / 2 - wotflabel.getWidth() / 2, 740);
    stage.addActor(wotflabel);

    Label iplabel = new Label("IP :", skin);
    settingstable.add(iplabel).width(120);
    Label ipvallabel = new Label("127.0.0.1", skin);
    settingstable.add(ipvallabel).width(180);
    settingstable.row();

    Object[] turntimevals = new Object[6];
    turntimevals[0] = "10";
    turntimevals[1] = "20";
    turntimevals[2] = "30";
    turntimevals[3] = "40";
    turntimevals[4] = "50";
    turntimevals[5] = "60";
    Label turntimelabel = new Label("Turn Time :", skin);
    settingstable.add(turntimelabel).width(120);
    SelectBox turntimebox = new SelectBox(skin);
    turntimebox.setItems(turntimevals);
    turntimebox.setSelectedIndex(3);
    turntimebox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            gameSettings.setTurnTime(Integer.parseInt(turntimebox.getSelected().toString()));
        }
    });
    settingstable.add(turntimebox).width(180);
    settingstable.row();

    Object[] physicsvals = new Object[2];
    physicsvals[0] = "True";
    physicsvals[1] = "False";
    Label physicslabel = new Label("Physics :", skin);
    settingstable.add(physicslabel).width(120);
    SelectBox physicsbox = new SelectBox(skin);
    physicsbox.setItems(physicsvals);
    physicsbox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            gameSettings.setPhysics(Boolean.parseBoolean(physicsbox.getSelected().toString()));
        }
    });
    settingstable.add(physicsbox).width(180);
    settingstable.row();

    Object[] weaponsvals = new Object[3];
    weaponsvals[0] = "All Weapons";
    weaponsvals[1] = "Non-Explosive";
    weaponsvals[2] = "Grenades Only";
    Label weaponslabel = new Label("Weapons :", skin);
    settingstable.add(weaponslabel).width(120);
    SelectBox weaponsbox = new SelectBox(skin);
    weaponsbox.setItems(weaponsvals);
    settingstable.add(weaponsbox).width(180);
    settingstable.row();

    Object[] timervals = new Object[3];
    timervals[0] = "60";
    timervals[1] = "30";
    timervals[2] = "10";
    Label timerlabel = new Label("Timer :", skin);
    settingstable.add(timerlabel).width(120);
    SelectBox timerbox = new SelectBox(skin);
    timerbox.setItems(timervals);
    timerbox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            gameSettings.setMaxTime(Integer.parseInt(timerbox.getSelected().toString()));
        }
    });
    settingstable.add(timerbox).width(180);
    settingstable.row();

    Object[] unitvals = new Object[4];
    unitvals[0] = "1";
    unitvals[1] = "2";
    unitvals[2] = "3";
    unitvals[3] = "4";
    Label unitlabel = new Label("Units :", skin);
    settingstable.add(unitlabel).width(120);
    unitbox = new SelectBox(skin);
    unitbox.setItems(unitvals);
    unitbox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            int selectedunitcount = Integer.parseInt(unitbox.getSelected().toString());
            gameSettings.setMaxUnitCount(selectedunitcount);
            refreshUnitsForTeam(selectedunitcount);

        }
    });
    settingstable.add(unitbox).width(180);

    settingstable.setWidth(300);
    settingstable.setHeight(200);
    settingstable.setPosition(30, 110);
    stage.addActor(settingstable);

    ArrayList<String> mapslist = new ArrayList<>();
    FileHandle dirHandle = Gdx.files.internal("maps");
    for (FileHandle entry : dirHandle.list()) {
        mapslist.add(entry.toString());
    }

    map1 = new Image(new Texture(mapslist.get(0)));
    map1.setPosition(20, 70);
    map1.setWidth(400);
    map1.setHeight(230);
    mapstable.addActor(map1);
    SelectBox chooseMap = new SelectBox(skin);
    chooseMap.setItems(mapslist.toArray());
    chooseMap.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            mapstable.removeActor(map1);
            map1 = new Image(new Texture(mapslist.get(chooseMap.getSelectedIndex())));
            map1.setPosition(20, 70);
            map1.setWidth(400);
            map1.setHeight(230);
            map1.invalidate();
            mapstable.addActor(map1);
            // Table image is not updating for some reason. Does it need to be redrawn? Or the Stage?
        }
    });
    chooseMap.setWidth(400);
    chooseMap.setPosition(20, 20);
    mapstable.addActor(chooseMap);
    mapstable.setPosition(30, 360);
    mapstable.setHeight(320);
    mapstable.setWidth(440);
    stage.addActor(mapstable);

    Label teamslabel = new Label("Teams", skin);
    teamstable.setPosition(730, 360);
    teamstable.add(teamslabel);
    teamstable.row();
    teamstable.add(teams).width(200);
    teamstable.setWidth(300);
    teamstable.setHeight(320);
    stage.addActor(teamstable);

    TextButton start = new TextButton("Start", skin); // Use the initialized skin
    start.setColor(Color.BLACK);
    start.setWidth(300);
    start.setHeight(60);
    start.setPosition(590, 180);
    stage.addActor(start);
    start.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (teamList.size() < 2) {
                return;
            }

            // Selected MaxTime to an integer.
            gameSettings.setMaxTime(Integer.parseInt(timerbox.getSelected().toString()));

            // Selected TurnTime to an integer.
            gameSettings.setTurnTime(Integer.parseInt(turntimebox.getSelected().toString()));

            gameSettings.setIsLocal(true);
            // Create the map
            Map map = new Map(chooseMap.getSelected().toString().substring(5));

            try {
                sessionLocal = new Session(defaultPlayer, "localHost", gameSettings);
                sessionLocal.addPlayer(defaultPlayer);
            } catch (RemoteException ex) {
                Gdx.app.log("SessionLocal", ex.getMessage());
            }

            game.setScreen(new GameEngine(game, gameSettings, map, sessionLocal, defaultPlayer));
        }
    });

    TextButton exit = new TextButton("Exit", skin); // Use the initialized skin
    exit.setColor(Color.BLACK);
    exit.setWidth(300);
    exit.setHeight(60);
    exit.setPosition(590, 110);
    stage.addActor(exit);
    exit.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new MainMenu(game));
        }
    });

}

From source file:forge.sound.AudioClip.java

License:Open Source License

private AudioClip(final FileHandle fileHandle) {
    try {//w  w w  . j av  a  2 s .com
        clip = Gdx.audio.newSound(fileHandle);
    } catch (Exception ex) {
        System.err.println("Unable to load sound file: " + fileHandle.toString());
    }
}

From source file:mobi.shad.s3lib.main.S3File.java

License:Apache License

/**
 * Pobiera katalog dysku zwraca w postaci tablicy stringw
 *
 * @param directory - katalog do odczytania
 * @return - tablica plikow danego katalogu
 *///from   w  ww  .  java 2  s.c o m
public static String[] getDirectoryList(String directory, String defaultDir, boolean externalMode,
        final String[] extensionMask) {

    FilenameFilter filter = new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {

            if (name.startsWith(".")) {
                return false;
            }
            if (name.equalsIgnoreCase("res.dat")) {
                return false;
            }
            if (name.equalsIgnoreCase("_meta")) {
                return false;
            }
            if (dir.isFile()) {
                return false;
            }

            if (extensionMask != null) {
                boolean flag = false;
                for (String ext : extensionMask) {
                    if (name.contains(ext)) {
                        flag = true;
                    }
                }
                return flag;
            }
            return true;
        }
    };

    FilenameFilter filterDir = new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {

            if (name.equalsIgnoreCase("..")) {
                return true;
            }
            if (name.startsWith(".")) {
                return false;
            }
            if (name.equalsIgnoreCase("res.dat")) {
                return false;
            }
            if (name.equalsIgnoreCase("_meta")) {
                return false;
            }
            if (dir.isFile()) {
                return false;
            }
            if (extensionMask != null) {
                if (!dir.isFile()) {
                    return true;
                }
                boolean flag = false;
                for (String ext : extensionMask) {
                    if (name.contains(ext)) {
                        flag = true;
                    }
                }
                return flag;
            }
            return true;
        }
    };

    if (S3Constans.RESOURCE_DEBUG) {
        S3Log.log("getDirectoryList::getDir",
                "currentDir: " + directory + " defaultDir: " + defaultDir + " externalMode: " + externalMode,
                5);
    }

    String[] metaDirInfo = null;
    String[] out = null;
    String[] children = null;
    String[] childrenInternal = null;
    FileHandle directoryHandle;
    File dir;

    if (externalMode) {

        directoryHandle = Gdx.files.absolute(directory);
        if (S3Constans.RESOURCE_DEBUG) {
            S3Log.log("getDirectoryList::getDir", "Read external DIR part 1: " + directoryHandle.toString(), 3);
        }

        String extension = directoryHandle.extension();
        if ( //
             //
             //
        extension.equalsIgnoreCase("png") || extension.equalsIgnoreCase("jpg")
                || extension.equalsIgnoreCase("gif") || extension.equalsIgnoreCase("tif")
                || extension.equalsIgnoreCase("bmp") || extension.equalsIgnoreCase("jpeg")
                || extension.equalsIgnoreCase("tga") || //
                                                                                                                                                                                                                                                                                    //
                                                                                                                                                                                                                                                                                    //
                extension.equalsIgnoreCase("txt") || extension.equalsIgnoreCase("xml")
                || extension.equalsIgnoreCase("html") || extension.equalsIgnoreCase("htm")
                || extension.equalsIgnoreCase("rtf") || extension.equalsIgnoreCase("pdf")
                || extension.equalsIgnoreCase("epub") || //
                                                                                                                                                                                                                                                                                     //
                                                                                                                                                                                                                                                                                     //
                extension.equalsIgnoreCase("avi") || extension.equalsIgnoreCase("mpg")
                || extension.equalsIgnoreCase("wmf") || //
                                                                                                                               //
                                                                                                                               //
                extension.equalsIgnoreCase("mp3") || extension.equalsIgnoreCase("ogg") || //
                                                                                          //
                                                                                          //
                extension.equalsIgnoreCase("exe") || extension.equalsIgnoreCase("com")
                || extension.equalsIgnoreCase("zip") || extension.equalsIgnoreCase("rar")
                || extension.equalsIgnoreCase("bz2")) {
            directory = directoryHandle.parent().path();
            directoryHandle = getFileHandle(directory, false, false);
        }

        if (S3Constans.RESOURCE_DEBUG) {
            S3Log.log("getDirectoryList::getDir", "Read external DIR part 2: " + directoryHandle.toString(), 3);
        }

        dir = directoryHandle.file();
        children = dir.list(filterDir);

        FileHandle fh;
        if (children != null) {
            for (int i = 0; i < children.length; i++) {
                String string = children[i];
                fh = Gdx.files.absolute(string);
                if (fh.isDirectory()) {
                    children[i] = "<Dir> " + string;
                }
            }
        }

    } else {
        //
        // Odczyt plikw internal
        //
        if (!defaultDir.equalsIgnoreCase("")) {

            if (S3Constans.RESOURCE_DEBUG) {
                S3Log.log("getDirectoryList::getDir", "= Read META File ========================", 2);
            }

            String metaDir = defaultDir;
            FileHandle metaFileHandle;
            metaFileHandle = getFileHandle(metaDir, true, false);

            if (!metaFileHandle.extension().equalsIgnoreCase("")) {
                metaDir = metaFileHandle.parent().path() + "/_meta";
            } else if (metaFileHandle.isDirectory()) {
                metaDir = metaDir + "/_meta";
            } else {
                if (metaDir.startsWith("data/")) {
                    metaDir = metaDir + "/_meta";
                } else {
                    metaDir = "data/" + metaDir + "/_meta";
                }
            }
            if (S3Constans.RESOURCE_DEBUG) {
                S3Log.log("getDirectoryList::getDir",
                        "Prepare to read _meta dir info >>>>>>>>>>>>>> " + metaDir.toString(), 3);
            }

            //
            // Odczyt pliku _meta dla wewntrznego katalogu
            //
            metaFileHandle = getFileHandle(metaDir, true, false);
            if (metaFileHandle.exists()) {
                if (S3Constans.RESOURCE_DEBUG) {
                    S3Log.log("getDirectoryList::getDir", "Read _meta dir info >>>>>>>>>>>  "
                            + metaFileHandle.path() + " ext: " + metaFileHandle.extension(), 3);
                }
                try {
                    String readString = metaFileHandle.readString();
                    if (readString != null) {
                        if (readString.length() > 10) {

                            String[] lines = readString.split("\n");
                            LinkedList<String> list = new LinkedList<String>();
                            for (int i = 0; i < lines.length; i++) {
                                String line = lines[i].trim();
                                if (!line.equalsIgnoreCase("_meta") && !line.equalsIgnoreCase(".")
                                        && !line.equalsIgnoreCase("..") && line.length() > 1) {
                                    list.add(line);
                                }
                            }
                            metaDirInfo = list.toArray(new String[list.size()]);
                        }
                    }

                } catch (Exception ex) {
                    S3Log.error(S3.class.getName(), "Error Read _meta data ...", ex);
                }
            }
        }

        //
        // Odczyt fizycznego katalogu (zewntrznego)
        //

        if (S3Constans.RESOURCE_DEBUG) {
            S3Log.log("getDirectoryList::getDir", "= Read external DIR ========================", 2);
        }

        directoryHandle = getFileHandle(directory, false, false, false);
        if (!directoryHandle.extension().equalsIgnoreCase("")) {
            directory = directoryHandle.parent().path();
            directoryHandle = getFileHandle(directory, false, false);
        }
        dir = directoryHandle.file();

        if (S3Constans.RESOURCE_DEBUG) {
            S3Log.log("getDirectoryList::getDir", "Prepare to read external dir info: "
                    + directoryHandle.toString() + " file: " + dir.getAbsolutePath(), 3);
        }

        children = dir.list(filter);

        //
        // Odczyt fizycznego katalogu (wewntrznego)
        //
        if (S3Constans.RESOURCE_DEBUG) {
            S3Log.log("getDirectoryList::getDir", "= Read internal DIR ========================", 2);
        }
        directoryHandle = getFileHandle(directory, true, true, false);
        if (!directoryHandle.extension().equalsIgnoreCase("")) {
            directory = directoryHandle.parent().path();
            directoryHandle = getFileHandle(directory, false, false);
        }
        dir = directoryHandle.file();

        if (S3Constans.RESOURCE_DEBUG) {
            S3Log.log("getDirectoryList::getDir", "Prepare to read internal dir info >>>>>>>>>>>>>> "
                    + directoryHandle.toString() + " dir: " + dir.getAbsolutePath(), 3);
        }
        childrenInternal = dir.list(filter);
    }

    if (S3Constans.RESOURCE_DEBUG) {
        S3Log.log("getDirectoryList::getDir", "Result meta: " + metaDirInfo, 3);
        S3Log.log("getDirectoryList::getDir", "Result children: " + children, 3);
        S3Log.log("getDirectoryList::getDir", "Result childrenInternal: " + childrenInternal, 3);
    }
    //
    // ?czenie wynikw
    //
    Array<String> merageArray = new Array();
    if (metaDirInfo != null) {
        merageArray.addAll(metaDirInfo);
    }
    if (children != null) {
        for (int i = 0; i < children.length; i++) {
            if (!merageArray.contains(children[i], false)) {
                merageArray.add(children[i]);
            }
        }
    }
    if (childrenInternal != null) {
        for (int i = 0; i < childrenInternal.length; i++) {
            if (!merageArray.contains(childrenInternal[i], false)) {
                merageArray.add(childrenInternal[i]);
            }
        }
    }

    merageArray.sort();
    out = new String[merageArray.size];
    for (int i = 0; i < merageArray.size; i++) {
        if (!merageArray.get(i).equalsIgnoreCase("_meta")) {
            out[i] = merageArray.get(i);
            // if (S3Constans.NOTICE){
            S3Log.log("getDirectoryList::getDirectoryList", "Add file: " + out[i]);
            // }
        }
    }

    if (out == null) {
        return new String[] {};
    }
    return out;
}

From source file:mobi.shad.s3lib.main.S3File.java

License:Apache License

/**
 * @param fileHandle//  ww w.  j  a v  a 2s.co  m
 * @return
 */
public static String getFileSaveName(FileHandle fileHandle) {
    return getFileSaveName(fileHandle.toString());
}

From source file:net.spookygames.gdx.sfx.android.AndroidAudioDurationResolver.java

License:Open Source License

@SuppressLint("NewApi")
@Override//from   ww w  .  j  a  v a2 s.  c  o  m
public float resolveSoundDuration(Sound sound, FileHandle soundFile) {
    // TODO Change the world, make this happen
    // return ((AndroidSound)sound).getDuration();

    if (Build.VERSION.SDK_INT >= 10) {
        try {
            return sdk10Duration(soundFile);
        } catch (IllegalArgumentException ex) {
            Gdx.app.error("gdx-sfx", "Unable to resolve duration of sound file " + soundFile.toString(), ex);
        }
    }

    return -1f;
}

From source file:net.spookygames.gdx.sfx.desktop.DesktopAudioDurationResolver.java

License:Open Source License

@Override
public float resolveMusicDuration(Music music, FileHandle musicFile) {
    // TODO Change the world, make this happen
    // return ((OpenALMusic) music).duration();

    if (music instanceof Wav.Music) {
        try {/*from  ww  w.java  2s . co m*/
            return wavDuration(musicFile);
        } catch (UnsupportedAudioFileException e) {
            Gdx.app.error("gdx-sfx", "Unable to resolve duration of wav file " + musicFile.toString(), e);
        } catch (IOException e) {
            Gdx.app.error("gdx-sfx", "Unable to resolve duration of wav file " + musicFile.toString(), e);
        }
    } else if (music instanceof Mp3.Music) {
        try {
            return mp3Duration(musicFile);
        } catch (BitstreamException e) {
            Gdx.app.error("gdx-sfx", "Unable to resolve duration of mp3 file " + musicFile.toString(), e);
        }
    } else if (music instanceof Ogg.Music) {
        try {
            return oggDuration(musicFile);
        } catch (JOrbisException e) {
            Gdx.app.error("gdx-sfx", "Unable to resolve duration of ogg file " + musicFile.toString(), e);
        }
    }

    return -1f;
}

From source file:org.destinationsol.DevTextureProvider.java

License:Apache License

private TextureAtlas.AtlasRegion newTex(FileHandle fh, String name, int idx, FileHandle configFile) {
    Texture tex;//  w  ww  . j  a  va2 s .  c  o  m
    if (fh.exists()) {
        tex = new Texture(fh);
    } else {
        tex = myMissingTex;
        String msg = "texture not found: " + fh;
        DebugOptions.MISSING_TEXTURE_ACTION.handle(msg);
    }
    String definedBy = configFile == null ? "hardcoded" : configFile.toString();
    return new SolTex(tex, name, idx, definedBy);
}

From source file:org.destinationsol.game.sound.SoundManager.java

License:Apache License

private SolSound getSound0(String relPath, @Nullable FileHandle configFile, boolean looped, float basePitch) {
    if (relPath.isEmpty())
        return null;
    String key = relPath + "#" + basePitch;
    SolSound res = mySounds.get(key);//from   w  ww.  j a v  a2s  . c  om
    if (res != null)
        return res;

    String definedBy = configFile == null ? "hardcoded" : configFile.path();
    String dirPath = DIR + relPath;
    String paramsPath = dirPath + "/params.txt";
    FileHandle dir = FileManager.getInstance().getStaticFile(dirPath);
    float[] params = loadSoundParams(paramsPath);
    float loopTime = params[1];
    float baseVolume = params[0];
    ArrayList<Sound> sounds = new ArrayList<Sound>();
    boolean[] emptyDirArr = { false };
    fillSounds(sounds, dir, emptyDirArr);
    boolean emptyDir = emptyDirArr[0];
    res = new SolSound(dir.toString(), definedBy, loopTime, baseVolume, basePitch, sounds, emptyDir);
    mySounds.put(key, res);
    if (!emptyDir && looped && loopTime == 0)
        throw new AssertionError("please specify loopTime value in " + paramsPath);
    if (emptyDir) {
        String warnMsg = "found no sounds in " + dir;
        if (configFile != null) {
            warnMsg += " (defined in " + configFile.path() + ")";
        }
        DebugOptions.MISSING_SOUND_ACTION.handle(warnMsg);
    }
    return res;
}