Java Code Examples for com.watabou.noosa.Game#version()
The following examples show how to use
com.watabou.noosa.Game#version() .
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: 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 2
Source File: StatusPane.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void createChildren() { bg = new NinePatch( Assets.Interfaces.STATUS, 0, 0, 128, 36, 85, 0, 45, 0 ); add( bg ); add( new Button(){ @Override protected void onClick () { Camera.main.panTo( Dungeon.hero.sprite.center(), 5f ); GameScene.show( new WndHero() ); } @Override public GameAction keyAction() { return SPDAction.HERO_INFO; } }.setRect( 0, 1, 30, 30 )); btnJournal = new JournalButton(); add( btnJournal ); btnMenu = new MenuButton(); add( btnMenu ); avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier ); add( avatar ); compass = new Compass( Statistics.amuletObtained ? Dungeon.level.entrance : Dungeon.level.exit ); add( compass ); rawShielding = new Image( Assets.Interfaces.SHLD_BAR ); rawShielding.alpha(0.5f); add(rawShielding); shieldedHP = new Image( Assets.Interfaces.SHLD_BAR ); add(shieldedHP); hp = new Image( Assets.Interfaces.HP_BAR ); add( hp ); exp = new Image( Assets.Interfaces.XP_BAR ); add( exp ); bossHP = new BossHealthBar(); add( bossHP ); level = new BitmapText( PixelScene.pixelFont); level.hardlight( 0xFFEBA4 ); add( level ); depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.pixelFont); depth.hardlight( 0xCACFC2 ); depth.measure(); add( depth ); danger = new DangerIndicator(); add( danger ); buffs = new BuffIndicator( Dungeon.hero ); add( buffs ); add( pickedUp = new Toolbar.PickedUpItem()); version = new BitmapText( "v" + Game.version, PixelScene.pixelFont); version.alpha( 0.5f ); add(version); }
Example 3
Source File: StatusPane.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override protected void createChildren() { bg = new NinePatch( Assets.STATUS, 0, 0, 128, 36, 85, 0, 45, 0 ); add( bg ); add( new TouchArea<GameAction>( 0, 1, 31, 31 ) { @Override protected void onClick( NoosaInputProcessor.Touch touch ) { Image sprite = Dungeon.hero.sprite; Camera.main.panTo( sprite.center(), 5f ); GameScene.show( new WndHero() ); } @Override public boolean onKeyUp(NoosaInputProcessor.Key<GameAction> key) { boolean handled = true; switch (key.action) { case HERO_INFO: onClick( null ); break; case JOURNAL: GameScene.show( new WndJournal() ); break; default: handled = false; break; } return handled; } } ); btnJournal = new JournalButton(); add( btnJournal ); btnMenu = new MenuButton(); add( btnMenu ); avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier ); add( avatar ); compass = new Compass( Statistics.amuletObtained ? Dungeon.level.entrance : Dungeon.level.exit ); add( compass ); rawShielding = new Image( Assets.SHLD_BAR ); rawShielding.alpha(0.5f); add(rawShielding); shieldedHP = new Image( Assets.SHLD_BAR ); add(shieldedHP); hp = new Image( Assets.HP_BAR ); add( hp ); exp = new Image( Assets.XP_BAR ); add( exp ); bossHP = new BossHealthBar(); add( bossHP ); level = new BitmapText( PixelScene.pixelFont); level.hardlight( 0xFFEBA4 ); add( level ); depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.pixelFont); depth.hardlight( 0xCACFC2 ); depth.measure(); add( depth ); danger = new DangerIndicator(); add( danger ); buffs = new BuffIndicator( Dungeon.hero ); add( buffs ); add( pickedUp = new Toolbar.PickedUpItem()); version = new BitmapText( "v" + Game.version, PixelScene.pixelFont); version.alpha( 0.5f ); add(version); }