v0.7.5: corrected some issues caused by LibGDX

This commit is contained in:
Evan Debenham 2019-08-23 18:58:50 -04:00
parent de10df7866
commit 20f49ac600
5 changed files with 19 additions and 51 deletions

View File

@ -23,6 +23,7 @@ package com.watabou.noosa;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.TimeUtils;
import com.watabou.glscripts.Script;
import com.watabou.gltextures.TextureCache;
import com.watabou.glwrap.Blending;
@ -32,7 +33,6 @@ import com.watabou.input.KeyEvent;
import com.watabou.noosa.audio.Music;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.PlatformSupport;
import com.watabou.utils.SystemTime;
import java.io.PrintWriter;
import java.io.StringWriter;
@ -66,14 +66,10 @@ public class Game implements ApplicationListener {
// New scene class
protected static Class<? extends Scene> sceneClass;
// Current time in milliseconds
protected long now;
// Milliseconds passed since previous update
protected long step;
public static float timeScale = 1f;
public static float elapsed = 0f;
public static float timeTotal = 0f;
public static long realTime = 0;
protected static InputHandler inputHandler;
@ -134,11 +130,6 @@ public class Game implements ApplicationListener {
Gdx.gl.glFlush();
SystemTime.tick();
long rightNow = SystemTime.now;
step = (now == 0 ? 0 : rightNow - now);
now = rightNow;
step();
}
@ -156,8 +147,6 @@ public class Game implements ApplicationListener {
@Override
public void resume() {
paused = false;
now = 0;
}
public void finish(){
@ -236,8 +225,10 @@ public class Game implements ApplicationListener {
}
protected void update() {
Game.elapsed = Game.timeScale * step * 0.001f;
Game.elapsed = Game.timeScale * Gdx.graphics.getDeltaTime();
Game.timeTotal += Game.elapsed;
Game.realTime = TimeUtils.millis();
inputHandler.processAllEvents();

View File

@ -23,6 +23,7 @@ package com.watabou.utils;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.GdxRuntimeException;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -81,7 +82,16 @@ public class FileUtils {
//only works for base path
public static void bundleToFile( String fileName, Bundle bundle ) throws IOException{
bundleToStream( Gdx.files.local(fileName).write(false), bundle);
try {
bundleToStream(Gdx.files.local(fileName).write(false), bundle);
} catch (GdxRuntimeException e){
if (e.getCause() instanceof IOException){
//we want to throw the underlying IOException, not the GdxRuntimeException
throw (IOException)e.getCause();
} else {
throw e;
}
}
}
private static void bundleToStream( OutputStream output, Bundle bundle ) throws IOException{

View File

@ -1,34 +0,0 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.watabou.utils;
import com.badlogic.gdx.utils.TimeUtils;
public class SystemTime {
public static long now;
public static void tick() {
now = TimeUtils.millis();
}
}

View File

@ -474,7 +474,7 @@ public class Dungeon {
private static final String QUESTS = "quests";
private static final String BADGES = "badges";
public static void saveGame( int save ) throws IOException {
public static void saveGame( int save ) {
try {
Bundle bundle = new Bundle();

View File

@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
import com.watabou.noosa.Game;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
import com.watabou.utils.FileUtils;
@ -238,7 +239,7 @@ public enum Rankings {
} catch (IOException e) {
}
}
public static class Record implements Bundlable {
private static final String CAUSE = "cause";