/** Returns a java.io.File that represents this file handle. Note the returned file will only be usable for * {@link FileType#Absolute} and {@link FileType#External} file handles. */ public File file () { if (type == FileType.External) return new File(Gdx.files.getExternalStoragePath(), file.getPath()); return file; }
/** Returns a java.io.File that represents this file handle. Note the returned file will only be usable for * {@link FileType#Absolute} and {@link FileType#External} file handles. */ public File file () { if (type == FileType.External) return new File(Gdx.files.getExternalStoragePath(), file.getPath()); return file; }
/** Returns a java.io.File that represents this file handle. Note the returned file will only be usable for * {@link FileType#Absolute} and {@link FileType#External} file handles. */ public File file () { if (type == FileType.External) return new File(Gdx.files.getExternalStoragePath(), file.getPath()); return file; }
/** Returns a java.io.File that represents this file handle. Note the returned file will only be usable for * {@link FileType#Absolute} and {@link FileType#External} file handles. */ public File file () { if (type == FileType.External) return new File(Gdx.files.getExternalStoragePath(), file.getPath()); return file; }
message += "External storage path: " + Gdx.files.getExternalStoragePath() + "\n";
private void testAbsolute () throws IOException { String path = new File(Gdx.files.getExternalStoragePath(), "meow").getAbsolutePath(); FileHandle handle = Gdx.files.absolute(path); handle.delete();
/** Returns a java.io.File that represents this file handle. Note the returned file will only be usable for * {@link FileType#Absolute} and {@link FileType#External} file handles. */ public File file () { if (type == FileType.External) return new File(Gdx.files.getExternalStoragePath(), file.getPath()); return file; }
/** Returns a java.io.File that represents this file handle. Note the returned file will only be usable for * {@link FileType#Absolute} and {@link FileType#External} file handles. */ public File file () { if (type == FileType.External) return new File(Gdx.files.getExternalStoragePath(), file.getPath()); return file; }
private void storeBeatmap(SimpleSong beatmap, String fileName) { File output = new File(Gdx.files.getExternalStoragePath() + "/" + fileName); String json = new Gson().toJson(beatmap); try { FileOutputStream fos = new FileOutputStream(output); fos.write(json.getBytes("UTF-8")); fos.close(); } catch (IOException e) { Gdx.app.error("BEATMAP_STORE", "Failed to store the beatmap file."); } }
private String getSaveDirectoryForGame(String gameIdentifier) { switch (OsInformation.getOs()) { case WINDOWS: return Paths .get(Gdx.files.getExternalStoragePath(), "AppData", "Roaming", gameIdentifier).toAbsolutePath() .toString(); case MAC: return Paths .get(Gdx.files.getExternalStoragePath(), "Library", "Application Support", gameIdentifier) .toAbsolutePath().toString(); case UNIX: if (gameIdentifier.contains(".")) { gameIdentifier = gameIdentifier.substring(gameIdentifier .indexOf('.') + 1); } return Paths .get(Gdx.files.getExternalStoragePath(), "." + gameIdentifier).toAbsolutePath().toString(); default: return Paths.get(Gdx.files.getLocalStoragePath()).toAbsolutePath() .toString(); } }
private void storeMusicFile(InputStream inputStream, String fileName) { File output = new File(Gdx.files.getExternalStoragePath() + "/beatmaps/soundfiles/" + fileName); if (output.exists()) { Gdx.app.log("OSZ_MUSIC_LOADER", "File [" + fileName + "] already exists, skipping."); return; } try { FileOutputStream fos = new FileOutputStream(output); // tried bigger blocks, didn't really get better performance. byte[] buffer = new byte[BLOCK_SIZE]; int len = inputStream.read(buffer, 0, BLOCK_SIZE); while (len != -1) { fos.write(buffer, 0, len); len = inputStream.read(buffer, 0, BLOCK_SIZE); } inputStream.close(); fos.close(); } catch (IOException e) { Gdx.app.error("OSZ_MUSIC_LOADER", "Failed to store the music file."); } }
public static Music loadSongByName(String name) { try { // try loading the file FileHandle handle = Gdx.files.absolute(Gdx.files.getExternalStoragePath() + SONGFILE_PREFIX + name); return Gdx.audio.newMusic(handle); } catch(Exception e) { // if it failed, try loading the file with a different extension (in case the extension was not specified) FileHandle handle = null; String path = Gdx.files.getExternalStoragePath() + SONGFILE_PREFIX + name.replaceAll("\\.[a-zA-Z0-9]+$",""); for(String ext : SONGFILE_PRIO) { try { handle = Gdx.files.absolute(path + ext); return Gdx.audio.newMusic(handle); } catch(Exception e2) { continue; } } return null; } }
public static void reloadBeatmaps() { if (Gdx.files.absolute(Gdx.files.getExternalStoragePath() + "beatmaps/datafiles").exists()) { for (String fileName : Gdx.files.absolute(Gdx.files.getExternalStoragePath() + "beatmaps/datafiles").file().list()) { String fullPath = Gdx.files.getExternalStoragePath() + "beatmaps/datafiles/" + fileName; // if for any reason the user placed .osu/.osz files in the datafiles, we process them if (Gdx.files.absolute(fullPath).isDirectory() || (!fileName.endsWith(".rs") && !fileName.endsWith(".osz") && !fileName.endsWith(".osu"))) continue; externalManager.load("beatmaps/datafiles/" + fileName, List.class); } // process osu files from the beatmaps folder for (String fileName : Gdx.files.absolute(Gdx.files.getExternalStoragePath() + "beatmaps/").file().list()) { String fullPath = Gdx.files.getExternalStoragePath() + "beatmaps/" + fileName; if (Gdx.files.absolute(fullPath).isDirectory() || (!fileName.endsWith(".osz") && !fileName.endsWith(".osu"))) continue; externalManager.load("beatmaps/" + fileName, List.class); } } else { (Gdx.files.absolute(Gdx.files.getExternalStoragePath() + "beatmaps")).mkdirs(); (Gdx.files.absolute(Gdx.files.getExternalStoragePath() + "beatmaps/datafiles")).mkdirs(); (Gdx.files.absolute(Gdx.files.getExternalStoragePath() + "beatmaps/soundfiles")).mkdirs(); } }
public SimpleSong loadSong(SongFileInfo beatmap) { FileHandle handle = Gdx.files.absolute(Gdx.files.getExternalStoragePath() + "/" + beatmap.getFileName()); SimpleSong song = null; String jsonDefinition = handle.readString("UTF-8"); try { song = new Gson().fromJson(jsonDefinition, SimpleSong.class); validateSong(song); song.setValid(true); beatmap.song_name = song.song_name; if (errors.size() > 0) { beatmap.song_name = "Error: Beatmap format invalid. (" + handle.file().getName() + ")"; song.setValid(false); } } catch (Exception e) { song = new SimpleSong(); song.song_name = "Invalid JSON Format: " + handle.file().getName(); song.difficulty = 1; beatmap.song_name = "Error: Invalid JSON Format. (" + handle.file().getName() + ")"; errors.add("Invalid JSON Format"); song.setValid(false); } finally { if (song != null) { song.setResourceName(handle.nameWithoutExtension().replaceAll("_(easy|normal|hard|expert)$", "")); } } return song; }
public static void loadConfiguration() { Preferences prefs = Gdx.app.getPreferences("sif_train_config"); offset = prefs.getInteger("offset", 0); inputOffset = prefs.getInteger("input_offset", 0); songVolume = prefs.getInteger("song_vol", 100); feedbackVolume = prefs.getInteger("feedback_vol", 100); pathToBeatmaps = prefs.getString("path_to_beatmaps", Gdx.files.getExternalStoragePath() + "beatmaps"); playHintSounds = prefs.getBoolean("play_hint_sounds", false); noteSpeed = prefs.getInteger("note_speed", 6); overallDifficulty = prefs.getInteger("overall_difficulty", 7); // default to song name sorting sortMode = prefs.getInteger("sorting_mode", SongUtils.SORTING_MODE_SONG_NAME); sortOrder = prefs.getInteger("sorting_order", SongUtils.SORTING_MODE_ASCENDING); // default to the new mode randomMode = prefs.getInteger("random_mode", SongUtils.RANDOM_MODE_NEW); // sync mode syncMode = prefs.getInteger("sync_mode", SongUtils.SYNC_MODE_1); }