當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceLoader.resourceExists方法代碼示例

本文整理匯總了Java中org.newdawn.slick.util.ResourceLoader.resourceExists方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceLoader.resourceExists方法的具體用法?Java ResourceLoader.resourceExists怎麽用?Java ResourceLoader.resourceExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.newdawn.slick.util.ResourceLoader的用法示例。


在下文中一共展示了ResourceLoader.resourceExists方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSoundFileName

import org.newdawn.slick.util.ResourceLoader; //導入方法依賴的package包/類
/**
 * Returns the sound file name, with extension, by first looking through
 * the skins directory and then the default resource locations.
 * @param filename the base file name
 * @return the full file name, or null if no file found
 */
private static String getSoundFileName(String filename) {
	String wav = String.format("%s.wav", filename), mp3 = String.format("%s.mp3", filename);
	File skinDir = SkinService.skin.getDirectory();
	if (skinDir != null) {
		File skinWAV = new File(skinDir, wav), skinMP3 = new File(skinDir, mp3);
		if (skinWAV.isFile())
			return skinWAV.getAbsolutePath();
		if (skinMP3.isFile())
			return skinMP3.getAbsolutePath();
	}
	if (ResourceLoader.resourceExists(wav))
		return wav;
	if (ResourceLoader.resourceExists(mp3))
		return mp3;
	return null;
}
 
開發者ID:yugecin,項目名稱:opsu-dance,代碼行數:23,代碼來源:SoundController.java

示例2: getTextureData

import org.newdawn.slick.util.ResourceLoader; //導入方法依賴的package包/類
/**
 * Gets the texture data.
 *
 * @param string the string
 * @return the texture data
 */
public static AnimationData getTextureData(String string) {
	AnimationData t = textures.get(string);
	if(t != null) {
		return t;
	} else {
		//try to get it, in case we forgot
		System.err.println("Warn: " + string + " not explicitly defined");
		for(String loc: searchFolders){
			if(ResourceLoader.resourceExists("res/" + loc + "/" + string + ".png")){
				AnimationData txt = new AnimationData("res/" + loc + "/" + string + ".png");
				textures.put(string, txt);
				return txt;
			}
			
		}
		return textures.get("whoops");
	}
}
 
開發者ID:eliatlarge,項目名稱:FEMultiPlayer-V2,代碼行數:25,代碼來源:FEResources.java

示例3: getSoundFileName

import org.newdawn.slick.util.ResourceLoader; //導入方法依賴的package包/類
/**
 * Returns the sound file name, with extension, by first looking through
 * the skins directory and then the default resource locations.
 * @param filename the base file name
 * @return the full file name, or null if no file found
 */
private static String getSoundFileName(String filename) {
	String wav = String.format("%s.wav", filename), mp3 = String.format("%s.mp3", filename);
	File skinDir = Options.getSkin().getDirectory();
	if (skinDir != null) {
		File skinWAV = new File(skinDir, wav), skinMP3 = new File(skinDir, mp3);
		if (skinWAV.isFile())
			return skinWAV.getAbsolutePath();
		if (skinMP3.isFile())
			return skinMP3.getAbsolutePath();
	}
	if (ResourceLoader.resourceExists(wav))
		return wav;
	if (ResourceLoader.resourceExists(mp3))
		return mp3;
	return null;
}
 
開發者ID:itdelatrisu,項目名稱:opsu,代碼行數:23,代碼來源:SoundController.java

示例4: play

import org.newdawn.slick.util.ResourceLoader; //導入方法依賴的package包/類
/**
 * Plays an audio file at the preview position.
 * If the audio file is already playing, then nothing will happen.
 * @param beatmap the beatmap to play
 * @param loop whether or not to loop the track
 * @param preview whether to start at the preview time (true) or beginning (false)
 */
public static void play(final Beatmap beatmap, final boolean loop, final boolean preview) {
	// new track: load and play
	if (lastBeatmap == null || !beatmap.audioFilename.equals(lastBeatmap.audioFilename)) {
		final File audioFile = beatmap.audioFilename;
		if (!audioFile.isFile() && !ResourceLoader.resourceExists(audioFile.getPath())) {
			BarNotifListener.EVENT.make().onBarNotif(String.format("Could not find track '%s'.",
				audioFile.getName()));
			return;
		}

		reset();
		System.gc();

		switch (Utils.getFileExtension(beatmap.audioFilename.getName())) {
		case "ogg":
		case "mp3":
			trackLoader = new Thread() {
				@Override
				public void run() {
					loadTrack(audioFile, (preview) ? beatmap.previewTime : 0, loop);
				}
			};
			trackLoader.start();
			break;
		default:
			break;
		}
	}

	// new track position: play at position
	else if (beatmap.previewTime != lastBeatmap.previewTime)
		playAt(beatmap.previewTime, loop);

	lastBeatmap = beatmap;
}
 
開發者ID:yugecin,項目名稱:opsu-dance,代碼行數:43,代碼來源:MusicController.java

示例5: read

import org.newdawn.slick.util.ResourceLoader; //導入方法依賴的package包/類
@Override
public void read(String s) {
	String oldThemeString = themeString;
	themeString = s;
	Beatmap beatmap = getThemeBeatmap();
	if (beatmap == null) {
		themeString = oldThemeString;
		Log.warn(String.format("The theme song string [%s] is malformed.", s));
	} else if (!beatmap.audioFilename.isFile() && !ResourceLoader.resourceExists(beatmap.audioFilename.getName())) {
		themeString = oldThemeString;
		Log.warn(String.format("Cannot find theme song [%s].", beatmap.audioFilename.getAbsolutePath()));
	}
}
 
開發者ID:itdelatrisu,項目名稱:opsu,代碼行數:14,代碼來源:Options.java

示例6: play

import org.newdawn.slick.util.ResourceLoader; //導入方法依賴的package包/類
/**
 * Plays an audio file at the preview position.
 * If the audio file is already playing, then nothing will happen.
 * @param beatmap the beatmap to play
 * @param loop whether or not to loop the track
 * @param preview whether to start at the preview time (true) or beginning (false)
 */
public static void play(final Beatmap beatmap, final boolean loop, final boolean preview) {
	// new track: load and play
	if (lastBeatmap == null || !beatmap.audioFilename.equals(lastBeatmap.audioFilename)) {
		final File audioFile = beatmap.audioFilename;
		if (!audioFile.isFile() && !ResourceLoader.resourceExists(audioFile.getPath())) {
			UI.getNotificationManager().sendBarNotification(String.format("Could not find track '%s'.", audioFile.getName()));
			return;
		}

		reset();
		Utils.gc(false);

		switch (BeatmapParser.getExtension(beatmap.audioFilename.getName())) {
		case "ogg":
		case "mp3":
			trackLoader = new Thread() {
				@Override
				public void run() {
					loadTrack(audioFile, (preview) ? beatmap.previewTime : 0, loop);
				}
			};
			trackLoader.start();
			break;
		default:
			break;
		}
	}

	// new track position: play at position
	else if (beatmap.previewTime != lastBeatmap.previewTime)
		playAt(beatmap.previewTime, loop);

	lastBeatmap = beatmap;
}
 
開發者ID:itdelatrisu,項目名稱:opsu,代碼行數:42,代碼來源:MusicController.java


注:本文中的org.newdawn.slick.util.ResourceLoader.resourceExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。