Java Code Examples for com.watabou.noosa.Game#versionCode()
The following examples show how to use
com.watabou.noosa.Game#versionCode() .
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: DebugUpdates.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void checkForUpdate(UpdateResultCallback callback) { //turn on to test update UI if (false){ debugUpdateInfo = new AvailableUpdateData(); debugUpdateInfo.versionCode = Game.versionCode+1; debugUpdateInfo.URL = "http://www.google.com"; callback.onUpdateAvailable(debugUpdateInfo); } else { debugUpdateInfo = null; callback.onNoUpdateFound(); } }
Example 2
Source File: WelcomeScene.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); final int gameversion = ShatteredPixelDungeon.version(); BitmapTextMultiline title; BitmapTextMultiline text; if (gameversion == 0) { text = createMultiline(TXT_Welcome, 8); title = createMultiline(TTL_Welcome, 16); } else if (gameversion <= Game.versionCode) { text = createMultiline(TXT_Update, 6 ); title = createMultiline(TTL_Update, 9 ); } else { text = createMultiline( TXT_Future, 8 ); title = createMultiline( TTL_Future, 16 ); } int w = Camera.main.width; int h = Camera.main.height; int pw = w - 10; int ph = h - 50; title.maxWidth = pw; title.measure(); title.hardlight(Window.SHPX_COLOR); title.x = align( (w - title.width()) / 2 ); title.y = align( 8 ); add( title ); NinePatch panel = Chrome.get(Chrome.Type.WINDOW); panel.size( pw, ph ); panel.x = (w - pw) / 2; panel.y = (h - ph) / 2; add( panel ); ScrollPane list = new ScrollPane( new Component() ); add( list ); list.setRect( panel.x + panel.marginLeft(), panel.y + panel.marginTop(), panel.innerWidth(), panel.innerHeight()); list.scrollTo( 0, 0 ); Component content = list.content(); content.clear(); text.maxWidth = (int) panel.innerWidth(); text.measure(); content.add(text); content.setSize( panel.innerWidth(), text.height() ); RedButton okay = new RedButton("Okay!") { @Override protected void onClick() { ShatteredPixelDungeon.version(Game.versionCode); Game.switchScene(TitleScene.class); } }; /* okay.setRect(text.x, text.y + text.height() + 5, 55, 18); add(okay); RedButton changes = new RedButton("Changes") { @Override protected void onClick() { parent.add(new WndChanges()); } }; changes.setRect(text.x + 65, text.y + text.height() + 5, 55, 18); add(changes);*/ okay.setRect((w - pw) / 2, h - 22, pw, 18); add(okay); Archs archs = new Archs(); archs.setSize( Camera.main.width, Camera.main.height ); addToBack( archs ); fadeIn(); }
Example 3
Source File: Dungeon.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
public static void init() { difficultyLevel = ShatteredPixelDungeon.getDifficulty(); version = Game.versionCode; challenges = ShatteredPixelDungeon.challenges(); Generator.initArtifacts(); Actor.clear(); Actor.resetNextID(); PathFinder.setMapSize( Level.WIDTH, Level.HEIGHT ); Scroll.initLabels(); Potion.initColors(); Ring.initGems(); Statistics.reset(); Journal.reset(); quickslot.reset(); QuickSlotButton.reset(); depth = 0; gold = 0; if (difficultyLevel == DIFF_TUTOR) { tutorial_mob_seen = false; tutorial_tactics_tip = false; tutorial_food_found = false; tutorial_sign_seen = false; tutorial_key_found = false; tutorial_altar_seen = false; tutorial_wellA_seen = false; tutorial_wellT_seen = false; tutorial_wellH_seen = false; tutorial_boss_found = false; tutorial_garden_found = false; } droppedItems = new SparseArray<>(); for (limitedDrops a : limitedDrops.values()) a.count = 0; switch (difficultyLevel) { case DIFF_ENDLESS: transmutation = Random.IntRange( 6, 14 ); altarLevel = 5; break; case DIFF_TUTOR: case DIFF_EASY: transmutation = Random.IntRange( 4, 10 ); altarLevel = Random.IntRange(1, 3); break; case DIFF_HARD: transmutation = Random.IntRange( 6, 14 ); altarLevel = Random.IntRange(3, 5); break; case DIFF_NTMARE: transmutation = Random.IntRange( 6, 15 ); altarLevel = Random.IntRange(3, 6); break; case DIFF_TEST: case DIFF_NORM: default: transmutation = Random.IntRange( 6, 14 ); altarLevel = Random.IntRange(2, 4); break; } chapters = new HashSet<>(); Ghost.Quest.reset(); Wandmaker.Quest.reset(); Blacksmith.Quest.reset(); Imp.Quest.reset(); Room.shuffleTypes(); hero = new Hero(); hero.live(); Badges.reset(); StartScene.curClass.initHero( hero ); // remove in progress game files.. // DSM-xxxx this is what is destroying our Rankings scene //for(String fileName : Game.instance.fileList()){ // if(fileName.startsWith("game_") || fileName.endsWith(".dat") && (fileName.startsWith(hero.heroClass.title()))){ // Game.instance.deleteFile(fileName); // } //} }
Example 4
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 5
Source File: Dungeon.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
public static void saveGame( int save ) { try { Bundle bundle = new Bundle(); version = Game.versionCode; bundle.put( VERSION, version ); bundle.put( SEED, seed ); bundle.put( CHALLENGES, challenges ); bundle.put( HERO, hero ); bundle.put( GOLD, gold ); bundle.put( DEPTH, depth ); for (int d : droppedItems.keyArray()) { bundle.put(Messages.format(DROPPED, d), droppedItems.get(d)); } for (int p : portedItems.keyArray()){ bundle.put(Messages.format(PORTED, p), portedItems.get(p)); } quickslot.storePlaceholders( bundle ); Bundle limDrops = new Bundle(); LimitedDrops.store( limDrops ); bundle.put ( LIMDROPS, limDrops ); int count = 0; int ids[] = new int[chapters.size()]; for (Integer id : chapters) { ids[count++] = id; } bundle.put( CHAPTERS, ids ); Bundle quests = new Bundle(); Ghost .Quest.storeInBundle( quests ); Wandmaker .Quest.storeInBundle( quests ); Blacksmith .Quest.storeInBundle( quests ); Imp .Quest.storeInBundle( quests ); bundle.put( QUESTS, quests ); SpecialRoom.storeRoomsInBundle( bundle ); SecretRoom.storeRoomsInBundle( bundle ); Statistics.storeInBundle( bundle ); Notes.storeInBundle( bundle ); Generator.storeInBundle( bundle ); Scroll.save( bundle ); Potion.save( bundle ); Ring.save( bundle ); Actor.storeNextID( bundle ); Bundle badges = new Bundle(); Badges.saveLocal( badges ); bundle.put( BADGES, badges ); FileUtils.bundleToFile( GamesInProgress.gameFile(save), bundle); } catch (IOException e) { GamesInProgress.setUnknown( save ); ShatteredPixelDungeon.reportException(e); } }
Example 6
Source File: Dungeon.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
public static void saveGame( int save ) { try { Bundle bundle = new Bundle(); version = Game.versionCode; bundle.put( VERSION, version ); bundle.put( SEED, seed ); bundle.put( CHALLENGES, challenges ); bundle.put( HERO, hero ); bundle.put( GOLD, gold ); bundle.put( DEPTH, depth ); for (int d : droppedItems.keyArray()) { bundle.put(Messages.format(DROPPED, d), droppedItems.get(d)); } for (int p : portedItems.keyArray()){ bundle.put(Messages.format(PORTED, p), portedItems.get(p)); } quickslot.storePlaceholders( bundle ); Bundle limDrops = new Bundle(); LimitedDrops.store( limDrops ); bundle.put ( LIMDROPS, limDrops ); int count = 0; int ids[] = new int[chapters.size()]; for (Integer id : chapters) { ids[count++] = id; } bundle.put( CHAPTERS, ids ); Bundle quests = new Bundle(); Ghost .Quest.storeInBundle( quests ); Wandmaker .Quest.storeInBundle( quests ); Blacksmith .Quest.storeInBundle( quests ); Imp .Quest.storeInBundle( quests ); bundle.put( QUESTS, quests ); SpecialRoom.storeRoomsInBundle( bundle ); SecretRoom.storeRoomsInBundle( bundle ); Statistics.storeInBundle( bundle ); Notes.storeInBundle( bundle ); Generator.storeInBundle( bundle ); Scroll.save( bundle ); Potion.save( bundle ); Ring.save( bundle ); Actor.storeNextID( bundle ); Bundle badges = new Bundle(); Badges.saveLocal( badges ); bundle.put( BADGES, badges ); FileUtils.bundleToFile( GamesInProgress.gameFile(save), bundle); } catch (IOException e) { GamesInProgress.setUnknown( save ); ShatteredPixelDungeon.reportException(e); } }
Example 7
Source File: UpdateNotification.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
public UpdateNotification(){ super(); if (latestVersion <= 1) { Thread thread = new Thread() { @Override public void run() { try { int currentVersion = Game.versionCode; URL versionInfo = new URL("https://raw.githubusercontent.com/00-Evan/shattered-pixel-dungeon-gdx/master/desktop/VersionInfo.txt"); BufferedReader inforeader = new BufferedReader(new InputStreamReader(versionInfo.openStream())); latestVersion = Integer.parseInt(inforeader.readLine()); if (latestVersion > currentVersion) { updateAvailable = true; } else { updateAvailable = false; updateMessage(); return; } //Update vs Patch, where a patch just appends a letter and usually fixes bugs. int latestFullRelease = Integer.parseInt(inforeader.readLine()); latestIsUpdate = (currentVersion < latestFullRelease); // Affects visibility. Basically, if we don't have the latest update, grab its message, // otherwise grab the latest version's message, this way your told about an update // you don't have, even if the latest version is a patch. String latestVersionMessage = inforeader.readLine(); String latestUpdateMessage = inforeader.readLine(); latestMessage = latestIsUpdate ? latestUpdateMessage : latestVersionMessage; updateURL = inforeader.readLine(); updateMessage(); } catch (Exception e) { latestVersion = -1; updateMessage(); } } }; thread.start(); } }
Example 8
Source File: Dungeon.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 2 votes |
public static void init() { version = Game.versionCode; challenges = SPDSettings.challenges(); seed = DungeonSeed.randomSeed(); Actor.clear(); Actor.resetNextID(); Random.pushGenerator( seed ); Scroll.initLabels(); Potion.initColors(); Ring.initGems(); SpecialRoom.initForRun(); SecretRoom.initForRun(); Random.resetGenerators(); Statistics.reset(); Notes.reset(); quickslot.reset(); QuickSlotButton.reset(); depth = 0; gold = 0; droppedItems = new SparseArray<>(); portedItems = new SparseArray<>(); for (LimitedDrops a : LimitedDrops.values()) a.count = 0; chapters = new HashSet<>(); Ghost.Quest.reset(); Wandmaker.Quest.reset(); Blacksmith.Quest.reset(); Imp.Quest.reset(); Generator.reset(); hero = new Hero(); hero.live(); Badges.reset(); GamesInProgress.selectedClass.initHero( hero ); }
Example 9
Source File: Dungeon.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 2 votes |
public static void init() { version = Game.versionCode; challenges = SPDSettings.challenges(); seed = DungeonSeed.randomSeed(); Actor.clear(); Actor.resetNextID(); Random.seed( seed ); Scroll.initLabels(); Potion.initColors(); Ring.initGems(); SpecialRoom.initForRun(); SecretRoom.initForRun(); Random.seed(); Statistics.reset(); Notes.reset(); quickslot.reset(); QuickSlotButton.reset(); depth = 0; gold = 0; droppedItems = new SparseArray<>(); portedItems = new SparseArray<>(); for (LimitedDrops a : LimitedDrops.values()) a.count = 0; chapters = new HashSet<>(); Ghost.Quest.reset(); Wandmaker.Quest.reset(); Blacksmith.Quest.reset(); Imp.Quest.reset(); Generator.reset(); Generator.initArtifacts(); hero = new Hero(); hero.live(); Badges.reset(); GamesInProgress.selectedClass.initHero( hero ); }