com.badlogic.gdx.Files Java Examples
The following examples show how to use
com.badlogic.gdx.Files.
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: GLSurfaceLauncher.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
public static void start(Arguments arguments) { AppConstants.logFile = LoggerUtils.setupExternalFileOutput(); final LwjglApplicationConfiguration configuration = new LwjglApplicationConfiguration(); configuration.title = AppConstants.APP_TITLE; configuration.addIcon("icon128.png", Files.FileType.Classpath); configuration.addIcon("icon32.png", Files.FileType.Classpath); configuration.addIcon("icon16.png", Files.FileType.Classpath); configuration.preferencesDirectory = AppConstants.EXTERNAL_DIR; configuration.width = 1024; configuration.height = 600; configuration.allowSoftwareMode = arguments.softOpenGL; configuration.useHDPI = true; AppParams appParams = new AppParams(); appParams.startupProject = arguments.project; appParams.debug = arguments.debug; App app = new App(new DesktopClassScanner(), appParams); new LwjglApplication(new WindowParamsPersistingApplicationWrapper(app, configuration), configuration); }
Example #2
Source File: FileUtils.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public static FileHandle getFileHandle( Files.FileType type, String basePath, String name ){ switch (type){ case Classpath: return Gdx.files.classpath( basePath + name ); case Internal: return Gdx.files.internal( basePath + name ); case External: return Gdx.files.external( basePath + name ); case Absolute: return Gdx.files.absolute( basePath + name ); case Local: return Gdx.files.local( basePath + name ); default: return null; } }
Example #3
Source File: DesktopLauncher.java From gdx-vfx with Apache License 2.0 | 5 votes |
public static void main (String[] arg) { Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); config.setTitle("GDX VFX Demo"); config.setWindowIcon(Files.FileType.Classpath, "gdx-vfx-icon16.png", "gdx-vfx-icon32.png", "gdx-vfx-icon64.png", "gdx-vfx-icon128.png"); config.setWindowedMode(640, 480); new Lwjgl3Application(new App(), config); }
Example #4
Source File: DesktopLauncher.java From Klooni1010 with GNU General Public License v3.0 | 5 votes |
public static void main(String[] arg) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = "Klooni 1010!"; config.width = Klooni.GAME_WIDTH; config.height = Klooni.GAME_HEIGHT; config.addIcon("ic_launcher/icon128.png", Files.FileType.Internal); config.addIcon("ic_launcher/icon32.png", Files.FileType.Internal); config.addIcon("ic_launcher/icon16.png", Files.FileType.Internal); new LwjglApplication(new Klooni(null), config); }
Example #5
Source File: DesktopLauncher.java From Unlucky with MIT License | 5 votes |
public static void main(String[] args) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.width = Unlucky.V_WIDTH * Unlucky.V_SCALE; config.height = Unlucky.V_HEIGHT * Unlucky.V_SCALE; config.title = Unlucky.TITLE; config.resizable = false; config.vSyncEnabled = false; config.backgroundFPS = 10; config.foregroundFPS = 60; config.addIcon("desktop_icon128.png", Files.FileType.Internal); config.addIcon("desktop_icon32.png", Files.FileType.Internal); config.addIcon("desktop_icon16.png", Files.FileType.Internal); new LwjglApplication(new Unlucky(), config); }
Example #6
Source File: MainListener.java From skin-composer with MIT License | 5 votes |
public void saveFile(Runnable runnable) { if (projectData.getSaveFile() != null && projectData.getSaveFile().type() != Files.FileType.Local) { dialogFactory.showDialogLoading(() -> { projectData.save(); if (runnable != null) { runnable.run(); } }); } else { saveAsFile(runnable); } }
Example #7
Source File: Generator.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private static void renamePrefixes(String path, String prefix, String newPrefix) { Files files = new LwjglFiles(); for (FileHandle fileHandle : files.local(path).list()) { if (fileHandle.name().startsWith(prefix)) { String newName = newPrefix + fileHandle.name().substring(prefix.length()); println(fileHandle.name() + " -> " + newName); fileHandle.sibling(newName).write(fileHandle.read(), false); fileHandle.delete(); } } }
Example #8
Source File: MPQViewer.java From riiablo with Apache License 2.0 | 5 votes |
public static void main(String[] args) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = TITLE; config.addIcon(ASSETS + "ic_launcher_128.png", Files.FileType.Internal); config.addIcon(ASSETS + "ic_launcher_32.png", Files.FileType.Internal); config.addIcon(ASSETS + "ic_launcher_16.png", Files.FileType.Internal); config.resizable = true; config.width = 1700; config.height = 960; config.foregroundFPS = config.backgroundFPS = 144; Client client = new Client(); new LwjglApplication(client, config); }
Example #9
Source File: Lwjgl3Mini2DxWindow.java From mini2Dx with Apache License 2.0 | 5 votes |
static void setIcon(long windowHandle, String[] imagePaths, Files.FileType imageFileType) { if (SharedLibraryLoader.isMac) return; Pixmap[] pixmaps = new Pixmap[imagePaths.length]; for (int i = 0; i < imagePaths.length; i++) { pixmaps[i] = new Pixmap(Gdx.files.getFileHandle(imagePaths[i], imageFileType)); } setIcon(windowHandle, pixmaps); for (Pixmap pixmap : pixmaps) { pixmap.dispose(); } }
Example #10
Source File: GdxDemoActivity.java From thunderboard-android with Apache License 2.0 | 4 votes |
public Files getFiles() { return this.files; }
Example #11
Source File: FileUtils.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
public static void setDefaultFileProperties( Files.FileType type, String path ){ defaultFileType = type; defaultPath = path; }
Example #12
Source File: FileUtils.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
public static FileHandle getFileHandle( Files.FileType type, String name ){ return getFileHandle( type, "", name ); }
Example #13
Source File: DesktopLauncher.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
public static void main (String[] args) { if (!DesktopLaunchValidator.verifyValidJVMState(args)){ return; } final String title; if (DesktopLauncher.class.getPackage().getSpecificationTitle() == null){ title = System.getProperty("Specification-Title"); } else { title = DesktopLauncher.class.getPackage().getSpecificationTitle(); } Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable throwable) { Game.reportException(throwable); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); throwable.printStackTrace(pw); pw.flush(); String exceptionMsg = sw.toString(); //shorten/simplify exception message to make it easier to fit into a message box exceptionMsg = exceptionMsg.replaceAll("\\(.*:([0-9]*)\\)", "($1)"); exceptionMsg = exceptionMsg.replace("com.shatteredpixel.shatteredpixeldungeon.", ""); exceptionMsg = exceptionMsg.replace("com.watabou.", ""); exceptionMsg = exceptionMsg.replace("com.badlogic.gdx.", ""); exceptionMsg = exceptionMsg.replace("\t", " "); TinyFileDialogs.tinyfd_messageBox(title + " Has Crashed!", title + " has run into an error it can't recover from and has crashed, sorry about that!\n\n" + "If you could, please email this error message to the developer ([email protected]):\n\n" + "version: " + Game.version + "\n" + exceptionMsg, "ok", "error", false ); if (Gdx.app != null) Gdx.app.exit(); } }); Game.version = DesktopLauncher.class.getPackage().getSpecificationVersion(); if (Game.version == null) { Game.version = System.getProperty("Specification-Version"); } try { Game.versionCode = Integer.parseInt(DesktopLauncher.class.getPackage().getImplementationVersion()); } catch (NumberFormatException e) { Game.versionCode = Integer.parseInt(System.getProperty("Implementation-Version")); } if (UpdateImpl.supportsUpdates()){ Updates.service = UpdateImpl.getUpdateService(); } Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); config.setTitle( title ); String basePath = ""; if (SharedLibraryLoader.isWindows) { if (System.getProperties().getProperty("os.name").equals("Windows XP")) { basePath = "Application Data/.shatteredpixel/Shattered Pixel Dungeon/"; } else { basePath = "AppData/Roaming/.shatteredpixel/Shattered Pixel Dungeon/"; } } else if (SharedLibraryLoader.isMac) { basePath = "Library/Application Support/Shattered Pixel Dungeon/"; } else if (SharedLibraryLoader.isLinux) { basePath = ".shatteredpixel/shattered-pixel-dungeon/"; } //copy over prefs from old file location from legacy desktop codebase FileHandle oldPrefs = new Lwjgl3FileHandle(basePath + "pd-prefs", Files.FileType.External); FileHandle newPrefs = new Lwjgl3FileHandle(basePath + SPDSettings.DEFAULT_PREFS_FILE, Files.FileType.External); if (oldPrefs.exists() && !newPrefs.exists()){ oldPrefs.copyTo(newPrefs); } config.setPreferencesConfig( basePath, Files.FileType.External ); SPDSettings.set( new Lwjgl3Preferences( SPDSettings.DEFAULT_PREFS_FILE, basePath) ); FileUtils.setDefaultFileProperties( Files.FileType.External, basePath ); config.setWindowSizeLimits( 480, 320, -1, -1 ); Point p = SPDSettings.windowResolution(); config.setWindowedMode( p.x, p.y ); config.setAutoIconify( true ); //we set fullscreen/maximized in the listener as doing it through the config seems to be buggy DesktopWindowListener listener = new DesktopWindowListener(); config.setWindowListener( listener ); config.setWindowIcon("icons/icon_16.png", "icons/icon_32.png", "icons/icon_64.png", "icons/icon_128.png", "icons/icon_256.png"); new Lwjgl3Application(new ShatteredPixelDungeon(new DesktopPlatformSupport()), config); }
Example #14
Source File: DesktopLauncher.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
public static void main (String[] arg) { String version = DesktopLauncher.class.getPackage().getSpecificationVersion(); if (version == null) { version = "0.7.5f"; } int versionCode; try { versionCode = Integer.parseInt(DesktopLauncher.class.getPackage().getImplementationVersion()); } catch (NumberFormatException e) { versionCode = 383; } LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); if (SharedLibraryLoader.isMac) { config.preferencesDirectory = "Library/Application Support/Shattered Pixel Dungeon/"; } else if (SharedLibraryLoader.isLinux) { config.preferencesDirectory = ".shatteredpixel/shattered-pixel-dungeon/"; } else if (SharedLibraryLoader.isWindows) { String winVer = System.getProperties().getProperty("os.name"); if (winVer.contains("XP")) { config.preferencesDirectory = "Application Data/.shatteredpixel/Shattered Pixel Dungeon/"; } else { config.preferencesDirectory = "AppData/Roaming/.shatteredpixel/Shattered Pixel Dungeon/"; } } // FIXME: This is a hack to get access to the preferences before we have an application setup com.badlogic.gdx.Preferences prefs = new LwjglPreferences(SPDSettings.FILE_NAME, config.preferencesDirectory); boolean isFullscreen = prefs.getBoolean(SPDSettings.KEY_WINDOW_FULLSCREEN, false); //config.fullscreen = isFullscreen; if (!isFullscreen) { config.width = prefs.getInteger(SPDSettings.KEY_WINDOW_WIDTH, SPDSettings.DEFAULT_WINDOW_WIDTH); config.height = prefs.getInteger(SPDSettings.KEY_WINDOW_HEIGHT, SPDSettings.DEFAULT_WINDOW_HEIGHT); } config.addIcon( "ic_launcher_128.png", Files.FileType.Internal ); config.addIcon( "ic_launcher_32.png", Files.FileType.Internal ); config.addIcon( "ic_launcher_16.png", Files.FileType.Internal ); // TODO: It have to be pulled from build.gradle, but I don't know how it can be done config.title = "Shattered Pixel Dungeon"; new LwjglApplication(new ShatteredPixelDungeon( new DesktopSupport(version, versionCode, config.preferencesDirectory, new DesktopInputProcessor()) ), config); }
Example #15
Source File: DesktopMini2DxGame.java From mini2Dx with Apache License 2.0 | 4 votes |
@Override public Files getFiles() { return files; }